/// <summary> /// 获取树形数据 /// </summary> /// <param name="e"></param> private void LoadTreeData(DoWorkEventArgs e) { using (SRCLParamSet.CLParamSetSerivceClient client = new SRCLParamSet.CLParamSetSerivceClient()) { var ret = client.GetCLParamSetList(context.SessionID); if (ret.IsSuccess) { e.Result = ret.Data; } else { bgwWait.ReportProgress(PubConstant.WaitMessageStatus.WARNING, ret.Message); } } }
/// <summary> /// 组件工作事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void bgwWait_DoWork(object sender, DoWorkEventArgs e) { bgwWait.ReportProgress(PubConstant.WaitMessageStatus.START); try { switch (e.Argument.ToString()) { case "LoadTreeData": LoadTreeData(e); break; case "SearchData": using (SRCLParamSet.CLParamSetSerivceClient client = new SRCLParamSet.CLParamSetSerivceClient()) { var ret = client.GetCLParamSetsList(context.SessionID, headModel.ID); if (ret.IsSuccess) { headModel = ret.HeadData; lstbodyModel = ret.BodyData.OrderBy(t => t.Priority).ToList(); this.Invoke((MethodInvoker) delegate() { craftsLineParamSetBindingSource.DataSource = ret.HeadData; craftsLineParamSetsBindingSource.DataSource = lstbodyModel; gridControl1.RefreshDataSource(); }); } else { bgwWait.ReportProgress(PubConstant.WaitMessageStatus.WARNING, ret.Message); } } break; case "SaveData": using (SRCLParamSet.CLParamSetSerivceClient client = new SRCLParamSet.CLParamSetSerivceClient()) { if (headModel.ID > 0) //保存 { this.AddSysOperLogs(this.Text, OperateStatus.修改, strCode: headModel.CraftsName); headModel.Modify = context.UserName; headModel.ModifyDate = DateTime.Now; var ret = client.UpdateCLParamSet(context.SessionID, headModel, lstbodyModel.ToArray()); if (ret.IsSuccess) { bgwWait.ReportProgress(PubConstant.WaitMessageStatus.PROMPT, "保存成功!"); this.Invoke((MethodInvoker) delegate() { headModel = ret.HeadData; lstbodyModel = ret.BodyData.OrderBy(t => t.Priority).ToList(); craftsLineParamSetBindingSource.DataSource = headModel; craftsLineParamSetsBindingSource.DataSource = lstbodyModel; }); LoadTreeData(e); } else { bgwWait.ReportProgress(PubConstant.WaitMessageStatus.WARNING, ret.Message); } } else //新增 { this.AddSysOperLogs(this.Text, OperateStatus.增加, strCode: headModel.CraftsName); var ret = client.AddCLParamSet(context.SessionID, headModel, lstbodyModel.ToArray()); if (ret.IsSuccess) { bgwWait.ReportProgress(PubConstant.WaitMessageStatus.PROMPT, "新增成功!"); this.Invoke((MethodInvoker) delegate() { headModel = ret.HeadData; lstbodyModel = ret.BodyData.ToList(); craftsLineParamSetBindingSource.DataSource = headModel; craftsLineParamSetsBindingSource.DataSource = lstbodyModel; }); LoadTreeData(e); } else { bgwWait.ReportProgress(PubConstant.WaitMessageStatus.WARNING, ret.Message); } } } break; case "DelData": using (SRCLParamSet.CLParamSetSerivceClient client = new SRCLParamSet.CLParamSetSerivceClient()) { this.AddSysOperLogs(this.Text, OperateStatus.除, strCode: headModel.CraftsCode); var retDel = client.DelCLParamSet(context.SessionID, headModel.ID); if (retDel.IsSuccess) { bgwWait.ReportProgress(PubConstant.WaitMessageStatus.PROMPT, "删除成功!"); LoadTreeData(e); } else { bgwWait.ReportProgress(PubConstant.WaitMessageStatus.WARNING, retDel.Message); } } break; default: break; } } catch (System.ServiceModel.FaultException <SRCLParamSet.CustomFaultMessage> fex) { Utils.Logger.Error(fex.ToString()); bgwWait.ReportProgress(PubConstant.WaitMessageStatus.ERROR, fex.Message); } catch (Exception ex) { Utils.Logger.Error(ex.ToString()); bgwWait.ReportProgress(PubConstant.WaitMessageStatus.ERROR, ex.Message); } bgwWait.ReportProgress(PubConstant.WaitMessageStatus.END); }