private void GetAllAgent() { try { WebRequest webRequest = new WebRequest(); webRequest.Session = CurrentApp.Session; webRequest.Code = (int)S1103Codes.GetAllAgent; //Service11031Client client = new Service11031Client(); Service11031Client client = new Service11031Client(WebHelper.CreateBasicHttpBinding(CurrentApp.Session), WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service11031")); WebReturn webReturn = client.DoOperation(webRequest); client.Close(); if (!webReturn.Result) { ShowException(string.Format("Fail.\t{0}\t{1}", webReturn.Code, webReturn.Message)); return; } for (int i = 0; i < webReturn.ListData.Count; i++) { strList.Add(webReturn.ListData[i]); } } catch (Exception ex) { ShowException(ex.Message); } }
private void LoadCtledUserIDs() { try { if (AgentItem == null) { return; } long agentObjID = AgentItem.ObjID; WebRequest webRequest = new WebRequest(); webRequest.Session = CurrentApp.Session; webRequest.Code = (int)S1103Codes.GetAgentCtledUserIDs; webRequest.ListData.Add(CurrentApp.Session.UserInfo.UserID.ToString()); webRequest.ListData.Add(agentObjID.ToString()); Service11031Client client = new Service11031Client( WebHelper.CreateBasicHttpBinding(CurrentApp.Session), WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service11031")); WebReturn webReturn = client.DoOperation(webRequest); if (!webReturn.Result) { ShowException(string.Format("WSFail.\t{0}\t{1}", webReturn.Code, webReturn.Message)); return; } if (webReturn.ListData == null) { ShowException(string.Format("ListData is null")); return; } for (int i = 0; i < webReturn.ListData.Count; i++) { string strID = webReturn.ListData[i]; long id; if (long.TryParse(strID, out id)) { mListCtledUserIDs.Add(id); } } CurrentApp.WriteLog("LoadCtledUserIDs", string.Format("End.\t{0}", mListCtledUserIDs.Count)); } catch (Exception ex) { ShowException(ex.Message); } }
private void AgentMMT() { try { if (AgentItem == null) { return; } long agentObjID = AgentItem.ObjID; List <ObjectItem> listAddItems = new List <ObjectItem>(); for (int i = 0; i < mListCtlObjects.Count; i++) { ObjectItem item = mListCtlObjects[i]; if (item.ObjType == ConstValue.RESOURCE_USER) { if (item.ObjID == CurrentApp.Session.UserInfo.UserID) { continue; } //不能给自身分配权限 if (item.IsChecked == true) { listAddItems.Add(item); } } } List <ObjectItem> listDeleteItems = new List <ObjectItem>(); for (int i = 0; i < mListCtlObjects.Count; i++) { ObjectItem item = mListCtlObjects[i]; if (item.ObjType == ConstValue.RESOURCE_USER) { if (item.ObjID == CurrentApp.Session.UserInfo.UserID) { continue; } //不能给自身分配权限 if (item.IsChecked == false) { listDeleteItems.Add(item); } } } if (PageParent != null) { PageParent.SetBusy(true, string.Empty); } int errCode = 0; string strMsg = string.Empty; BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += (s, de) => { try { WebRequest webRequest = new WebRequest(); webRequest.Session = CurrentApp.Session; webRequest.Code = (int)S1103Codes.SaveAgentMMT; webRequest.ListData.Add(CurrentApp.Session.UserInfo.UserID.ToString()); webRequest.ListData.Add(agentObjID.ToString()); webRequest.ListData.Add("1"); int intCount = listAddItems.Count; webRequest.ListData.Add(intCount.ToString()); for (int i = 0; i < intCount; i++) { webRequest.ListData.Add(listAddItems[i].ObjID.ToString()); } Service11031Client client = new Service11031Client(WebHelper.CreateBasicHttpBinding(CurrentApp.Session), WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service11031")); WebReturn webReturn = client.DoOperation(webRequest); if (!webReturn.Result) { errCode = webReturn.Code; strMsg = webReturn.Message; return; } if (webReturn.ListData != null) { for (int i = 0; i < webReturn.ListData.Count; i++) { CurrentApp.WriteLog("AgentMMT", string.Format("Add;{0}", webReturn.ListData[i])); } } webRequest = new WebRequest(); webRequest.Session = CurrentApp.Session; webRequest.Code = (int)S1103Codes.SaveAgentMMT; webRequest.ListData.Add(CurrentApp.Session.UserInfo.UserID.ToString()); webRequest.ListData.Add(agentObjID.ToString()); webRequest.ListData.Add("2"); intCount = listDeleteItems.Count; webRequest.ListData.Add(intCount.ToString()); for (int i = 0; i < intCount; i++) { webRequest.ListData.Add(listDeleteItems[i].ObjID.ToString()); } webReturn = client.DoOperation(webRequest); if (!webReturn.Result) { errCode = webReturn.Code; strMsg = webReturn.Message; return; } if (webReturn.ListData != null) { for (int i = 0; i < webReturn.ListData.Count; i++) { CurrentApp.WriteLog("AgentMMT", string.Format("Delete;{0}", webReturn.ListData[i])); } } } catch (Exception ex) { errCode = Defines.RET_FAIL; strMsg = ex.Message; } }; worker.RunWorkerCompleted += (s, re) => { worker.Dispose(); if (PageParent != null) { PageParent.SetBusy(false, string.Empty); } if (errCode > 0) { ShowException(string.Format("WSFail.\t{0}\t{1}", errCode, strMsg)); return; } ShowInformation(string.Format("Save successful!")); var parent = Parent as PopupPanel; if (parent != null) { parent.IsOpen = false; } }; worker.RunWorkerAsync(); } catch (Exception ex) { ShowException(ex.Message); } }
private void ModifyAgentPassword() { GlobalParamInfo GlobalParam = new GlobalParamInfo(); try { WebRequest webRequest = new WebRequest(); webRequest.Session = CurrentApp.Session; webRequest.Code = (int)RequestCode.WSGetGlobalParamList; webRequest.ListData.Add("11"); webRequest.ListData.Add("11010501"); webRequest.ListData.Add(string.Empty); Service11012Client client = new Service11012Client( WebHelper.CreateBasicHttpBinding(CurrentApp.Session), WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service11012")); WebHelper.SetServiceClient(client); WebReturn webReturn = client.DoOperation(webRequest); client.Close(); if (!webReturn.Result) { ShowException(string.Format("Fail.\t{0}\t{1}", webReturn.Code, webReturn.Message)); return; } OperationReturn optReturn = XMLHelper.DeserializeObject <GlobalParamInfo>(webReturn.ListData[0]); if (!optReturn.Result) { ShowException(string.Format("InitColumnData Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message)); return; } GlobalParam = optReturn.Data as GlobalParamInfo; if (GlobalParam == null) { return; } } catch (Exception ex) { ShowException(ex.Message); } try { WebRequest webRequest = new WebRequest(); webRequest.Session = CurrentApp.Session; webRequest.Code = (int)S1103Codes.UPAgentPwd; webRequest.ListData.Add(mCurrentItem.ObjID.ToString()); // webRequest.ListData.Add(mCurrentItem.Name.ToString()); webRequest.ListData.Add(GlobalParam.ParamValue.Substring(8));//新密码 // Service11031Client client = new Service11031Client(); Service11031Client client = new Service11031Client( WebHelper.CreateBasicHttpBinding(CurrentApp.Session), WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service11031")); WebHelper.SetServiceClient(client); WebReturn webReturn = client.DoOperation(webRequest); client.Close(); if (webReturn.Result) { CurrentApp.ShowInfoMessage(CurrentApp.GetLanguageInfo("S1103030", "Modify Sucessed")); #region 写操作日志 string msg_success = string.Format("{0} {1} :{2}", CurrentApp.Session.UserInfo.UserName, Utils.FormatOptLogString("FO1103004"), mCurrentItem.Name); CurrentApp.WriteOperationLog("1103004", ConstValue.OPT_RESULT_SUCCESS, msg_success); #endregion } else//失败 { ShowException(string.Format("{0}:{1}", CurrentApp.GetLanguageInfo("S1103031", webReturn.Message), webReturn.Message)); #region 写操作日志 string msg_Fail = string.Format("{0} {1} :{2}", CurrentApp.Session.UserInfo.UserName, Utils.FormatOptLogString("FO1103004"), mCurrentItem.Name); CurrentApp.WriteOperationLog("1103004".ToString(), ConstValue.OPT_RESULT_FAIL, msg_Fail); #endregion } } catch (Exception ex) { ShowException(ex.Message); } }
private void DeleteAgent() { try { var item = TvObjects.SelectedItem as ObjectItem; if (item == null) { item = TreeViewOrgAgent.SelectedItem as ObjectItem; if (item == null) { return; } } if (item.ObjType != ConstValue.RESOURCE_AGENT) { return; } var agentInfo = item.Data as AgentInfo; if (agentInfo == null) { return; } var result = MessageBox.Show(string.Format("Confirm delete agent?\r\n\r\n{0}", agentInfo.AgentID), CurrentApp.AppTitle, MessageBoxButton.YesNo, MessageBoxImage.Question); if (result != MessageBoxResult.Yes) { return; } OperationReturn optReturn; optReturn = XMLHelper.SeriallizeObject(agentInfo); if (!optReturn.Result) { ShowException(string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message)); return; } string strInfo = optReturn.Data.ToString(); int errCode = 0; string strMsg = string.Empty; BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += (s, de) => { try { WebRequest webRequest = new WebRequest(); webRequest.Session = CurrentApp.Session; webRequest.Code = (int)S1103Codes.ModifyAgent; webRequest.ListData.Add(CurrentApp.Session.UserInfo.UserID.ToString()); webRequest.ListData.Add("2"); webRequest.ListData.Add(strInfo); Service11031Client client = new Service11031Client(WebHelper.CreateBasicHttpBinding(CurrentApp.Session), WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service11031")); WebReturn webReturn = client.DoOperation(webRequest); client.Close(); if (!webReturn.Result) { errCode = webReturn.Code; strMsg = webReturn.Message; return; } if (webReturn.ListData == null || webReturn.ListData.Count < 1) { errCode = Defines.RET_PARAM_INVALID; strMsg = string.Format("WS return fail."); return; } string strSerialID = webReturn.ListData[0]; CurrentApp.WriteLog("DeleteAgent", string.Format("End.\t{0}", strSerialID)); } catch (Exception ex) { errCode = Defines.RET_FAIL; strMsg = ex.Message; } }; worker.RunWorkerCompleted += (s, re) => { worker.Dispose(); if (errCode > 0) { ShowException(string.Format("{0}\t{1}", errCode, strMsg)); return; } ShowInformation(string.Format("Delete agent successful!")); ReloadData(); }; worker.RunWorkerAsync(); } catch (Exception ex) { ShowException(ex.Message); } }
private void ModifyAgentOrg() { if (AgentItem == null) { return; } var agentInfo = AgentItem.Data as AgentInfo; List <string> listObjectState = new List <string>(); ModifyAgentOrg(mRootItem, ref listObjectState); int errCode = 0; string strMsg = string.Empty; BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += (s, de) => { try { WebRequest webRequest = new WebRequest(); webRequest.Session = CurrentApp.Session; webRequest.Code = (int)S1103Codes.ModifyAgentORGC; webRequest.ListData.Add(agentInfo.SerialID.ToString()); //// webRequest.ListData.Add(listObjectState.Count().ToString()); if (listObjectState.Count >= 2) { // MessageBox.Show("您不能选择多个机构。。"); MessageBox.Show(CurrentApp.GetLanguageInfo("S1103039", "您不能选择多个机构。。")); return; } else { for (int i = 0; i < listObjectState.Count(); i++) { webRequest.ListData.Add(listObjectState[i]); } } // Service11031Client client = new Service11031Client(); Service11031Client client = new Service11031Client( WebHelper.CreateBasicHttpBinding(CurrentApp.Session), WebHelper.CreateEndpointAddress( CurrentApp.Session.AppServerInfo, "Service11031")); WebHelper.SetServiceClient(client); WebReturn webReturn = client.DoOperation(webRequest); client.Close(); if (!webReturn.Result) { errCode = webReturn.Code; strMsg = webReturn.Message; return; } } catch (Exception ex) { errCode = Defines.RET_FAIL; strMsg = ex.Message; } }; worker.RunWorkerCompleted += (s, re) => { worker.Dispose(); if (errCode > 0) { ShowException(string.Format("{0}\t{1}", errCode, strMsg)); return; } ShowInformation(string.Format("Modify agnet successful!")); if (PageParent != null) { PageParent.ReloadData(); } var panel = Parent as PopupPanel; if (panel != null) { panel.IsOpen = false; } }; worker.RunWorkerAsync(); }
private void ModifyAgent() { try { if (AgentItem == null) { return; } var agentInfo = AgentItem.Data as AgentInfo; if (agentInfo == null) { return; } if (string.IsNullOrEmpty(TxtAgentID.Text)) { ShowException(string.Format("AgentID empty!")); return; } if (TxtAgentID.Text.Length > 128) { CurrentApp.ShowInfoMessage(CurrentApp.GetLanguageInfo("S1103040", "Add content should not exceed 120 characters.")); return; } else { agentInfo.AgentID = TxtAgentID.Text; } if (TxtAgentName.Text.Length > 128) { CurrentApp.ShowInfoMessage(CurrentApp.GetLanguageInfo("S1103040", "Add content should not exceed 120 characters.")); return; } else { agentInfo.AgentName = TxtAgentName.Text; } agentInfo.State = RadioStateEnable.IsChecked == true ? 1 : 2; agentInfo.Tenure = ComboBoxTenure.SelectedIndex; OperationReturn optReturn; optReturn = XMLHelper.SeriallizeObject(agentInfo); if (!optReturn.Result) { ShowException(string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message)); return; } string strInfo = optReturn.Data.ToString(); int errCode = 0; string strMsg = string.Empty; BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += (s, de) => { try { WebRequest webRequest = new WebRequest(); webRequest.Session = CurrentApp.Session; webRequest.Code = (int)S1103Codes.ModifyAgent; webRequest.ListData.Add(CurrentApp.Session.UserInfo.UserID.ToString()); webRequest.ListData.Add("3"); webRequest.ListData.Add(strInfo); //Service11031Client client = new Service11031Client(); Service11031Client client = new Service11031Client(WebHelper.CreateBasicHttpBinding(CurrentApp.Session), WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service11031")); WebReturn webReturn = client.DoOperation(webRequest); client.Close(); if (!webReturn.Result) { errCode = webReturn.Code; strMsg = webReturn.Message; return; } if (webReturn.ListData == null || webReturn.ListData.Count < 1) { errCode = Defines.RET_PARAM_INVALID; strMsg = string.Format("WS return fail."); return; } string strSerialID = webReturn.ListData[0]; CurrentApp.WriteLog("ModifyAgent", string.Format("End.\t{0}", strSerialID)); } catch (Exception ex) { errCode = Defines.RET_FAIL; strMsg = ex.Message; } }; worker.RunWorkerCompleted += (s, re) => { worker.Dispose(); if (errCode > 0) { ShowException(string.Format("{0}\t{1}", errCode, strMsg)); return; } ShowInformation(string.Format("Modify agnet successful!")); if (PageParent != null) { PageParent.ReloadData(); } var panel = Parent as PopupPanel; if (panel != null) { panel.IsOpen = false; } }; worker.RunWorkerAsync(); } catch (Exception ex) { ShowException(ex.Message); } }