例子,自己的建模,自己照着写。
public override void WebPartCustomAction(object sender, CustomActionEventArgs e) { base.WebPartCustomAction(sender, e); var action = e.Action as Personalization.CustomAction; if (action != null) { switch (action.Parameters) { case "Submit": { e.Result = BtnSubmit_Click(); Page.DisplayMessage(e.Result); break; } } } } protected ResultStatus BtnSubmit_Click() { try { string name=Convert.ToString(RecipeName.Data); string rev= Convert.ToString(RecipeRev.Data); var details = RecipeItems.Data as N_RecipeItemChanges[]; List<N_RecipeItemChanges> list = details.ToList(); List<N_RecipeItemChanges> newlist = new List<N_RecipeItemChanges>(); for (int i=list.Count-1;i>=0;i--) { if (list[i].Product == null || list[i].Product.Name == null) { list.RemoveAt(i); } else { list[i].ListItemAction = ListItemAction.Change; newlist.Add(new N_RecipeItemChanges() { ListItemIndex = list[i].ListItemIndex, ListItemAction = ListItemAction.Change, Name=list[i].Name, Qty=list[i].Qty }); } } N_RecipeMaintService service = new N_RecipeMaintService(FrameworkManagerUtil.GetFrameworkSession().CurrentUserProfile); N_RecipeMaint serviceData = new N_RecipeMaint(); ResultStatus resultStatus = new ResultStatus(); service.BeginTransaction(); serviceData.ObjectToChange = new RevisionedObjectRef(); serviceData.ObjectToChange.Name = name; serviceData.ObjectToChange.Revision = rev; service.Load(serviceData); serviceData = new N_RecipeMaint(); serviceData.ObjectChanges = new N_RecipeChanges(); serviceData.ObjectChanges.N_RecipeItem = newlist.ToArray(); service.ExecuteTransaction(serviceData); resultStatus = service.CommitTransaction(); if (resultStatus.IsSuccess) { return new ResultStatus(resultStatus.Message, true); } return new ResultStatus(resultStatus.ExceptionData.Description, false); } catch (Exception ex) { return new ResultStatus(ex.Message, false); } }
标签:service,Camstar,代码,list,建模,serviceData,ResultStatus,new,resultStatus From: https://www.cnblogs.com/CarryYou-lky/p/17867009.html