private void GetEmailInfo() { Service24041Client client = null; try { WebRequest webRequest = new WebRequest(); webRequest.Code = (int)S2400RequestCode.GetEmailInfo; webRequest.Session = CurrentApp.Session; client = new Service24041Client(WebHelper.CreateBasicHttpBinding(CurrentApp.Session), WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service24041")); WebReturn webReturn = client.DoOperation(webRequest); CurrentApp.MonitorHelper.AddWebReturn(webReturn); if (!webReturn.Result) { ShowException(string.Format("WSFail.\t{0}\t{1}", webReturn.Code, webReturn.Message)); return; } if (string.IsNullOrEmpty(webReturn.Data)) { email = null; } else { OperationReturn optReturn = XMLHelper.DeserializeObject <EncryptEmail>(webReturn.Data as string); if (!optReturn.Result) { email = null; } else { email = optReturn.Data as EncryptEmail; } } } catch (Exception ex) { } finally { if (client != null) { if (client.State == System.ServiceModel.CommunicationState.Opened) { client.Close(); } } } }
private void UpdateEmail() { List <string> lstParams = new List <string>(); string str = radEnableMailYes.IsChecked == true ? "1" : "0"; string strChangeEmailEnable = str; lstParams.Add(str); lstParams.Add(txtSMTP.Text); lstParams.Add(txtSMTPPort.Text); str = radNeedSSLYes.IsChecked == true ? "1" : "0"; lstParams.Add(str); lstParams.Add(txtUser.Text); lstParams.Add(txtPwd.Password); str = radNeedVerificationYes.IsChecked == true ? "1" : "0"; lstParams.Add(str); lstParams.Add(txtEmailAddress.Text); Service24041Client client = null; try { WebRequest webRequest = new WebRequest(); webRequest.Code = (int)S2400RequestCode.UpdateEmailInfo; webRequest.Session = CurrentApp.Session; webRequest.ListData = lstParams; client = new Service24041Client(WebHelper.CreateBasicHttpBinding(CurrentApp.Session), WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service24041")); WebReturn webReturn = client.DoOperation(webRequest); CurrentApp.MonitorHelper.AddWebReturn(webReturn); string strLog = string.Empty; if (!webReturn.Result) { strLog = string.Format("{0}{1}{2}", CurrentApp.Session.UserInfo.UserName, Utils.FormatOptLogString(string.Format("FO2404001")), string.Empty); CurrentApp.WriteOperationLog("2404001", ConstValue.OPT_RESULT_FAIL, strLog); ShowException(string.Format("WSFail.\t{0}\t{1}", webReturn.Code, webReturn.Message)); return; } strLog = string.Format("{0}{1}{2}", CurrentApp.Session.UserInfo.UserName, Utils.FormatOptLogString(string.Format("FO2404001")), string.Empty); if (boIsEnableBefore.ToString() != strChangeEmailEnable) { if (strChangeEmailEnable == "1") { strLog += Utils.FormatOptLogString("2404001") + txtEmailAddress.Text; } else { strLog += Utils.FormatOptLogString("2404002"); } } CurrentApp.WriteOperationLog("2404001", ConstValue.OPT_RESULT_SUCCESS, strLog); ShowInformation(CurrentApp.GetLanguageInfo("COMN001", "Successful operation")); } catch (Exception ex) { ShowException(CurrentApp.GetLanguageInfo("COMN002", "Operation failure") + ",error:" + ex.Message); } finally { if (client != null) { if (client.State == System.ServiceModel.CommunicationState.Opened) { client.Close(); } } } }