Example #1
0
        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();
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        /// 获得邮件通知配置信息
        /// </summary>
        /// <param name="session"></param>
        /// <param name="lstParams"></param>
        /// <returns></returns>
        private OperationReturn GetEmailInfo(SessionInfo session, List <string> lstParams)
        {
            OperationReturn optReturn = new OperationReturn();

            try
            {
                string rentToken = session.RentInfo.Token;
                string strSql    = string.Empty;
                switch (session.DBType)
                {
                case 2:
                    strSql    = string.Format("SELECT * FROM T_11_001_{0} WHERE C001 = '{1}' and C002 =24 and C004  = 24041 ORDER BY C005", rentToken, session.RentID);
                    optReturn = MssqlOperation.GetDataSet(session.DBConnectionString, strSql);
                    if (!optReturn.Result)
                    {
                        return(optReturn);
                    }
                    break;

                case 3:
                    strSql    = string.Format("SELECT * FROM T_11_001_{0} WHERE C001 = '{1}' AND C002 =24 AND C004  = 24041  ORDER BY C005", rentToken, session.RentID);
                    optReturn = OracleOperation.GetDataSet(session.DBConnectionString, strSql);
                    if (!optReturn.Result)
                    {
                        return(optReturn);
                    }
                    break;
                }
                DataSet ds = optReturn.Data as DataSet;
                if (ds.Tables.Count <= 0 || ds.Tables[0].Rows.Count <= 0 || ds.Tables[0].Rows.Count < 8)
                {
                    return(optReturn);
                }

                List <string> lstData   = new List <string>();
                EncryptEmail  emailInfo = new EncryptEmail();

                emailInfo.IsEnableEmail      = ds.Tables[0].Rows[0]["C006"].ToString();
                emailInfo.SMTP               = ds.Tables[0].Rows[1]["C006"].ToString();
                emailInfo.SMTPPort           = ds.Tables[0].Rows[2]["C006"].ToString();
                emailInfo.NeedSSL            = ds.Tables[0].Rows[3]["C006"].ToString();
                emailInfo.Account            = ds.Tables[0].Rows[4]["C006"].ToString();
                emailInfo.Pwd                = ds.Tables[0].Rows[5]["C006"].ToString();
                emailInfo.NeedAuthentication = ds.Tables[0].Rows[6]["C006"].ToString();
                emailInfo.EmailAddress       = ds.Tables[0].Rows[7]["C006"].ToString();
                optReturn = XMLHelper.SeriallizeObject <EncryptEmail>(emailInfo);
                if (!optReturn.Result)
                {
                    return(optReturn);
                }

                optReturn.Result = true;
                optReturn.Code   = Defines.RET_SUCCESS;
            }
            catch (Exception ex)
            {
                optReturn.Result    = false;
                optReturn.Code      = Defines.RET_FAIL;
                optReturn.Message   = ex.Message;
                optReturn.Exception = ex;
            }
            return(optReturn);
        }