Beispiel #1
0
        /// <summary>
        /// 设置公司短信配置信息
        /// </summary>
        /// <param name="companyId">公司编号</param>
        /// <param name="info">配置信息</param>
        /// <returns></returns>
        public bool SetComSmsConfig(string companyId, EyouSoft.Model.ComStructure.MSmsConfigInfo info)
        {
            if (string.IsNullOrEmpty(companyId))
            {
                return(false);
            }

            var setting = GetModel(companyId);

            if (setting != null && setting.SmsConfig != null && setting.SmsConfig.IsEnabled)
            {
                return(true);
            }

            if (info == null || !info.IsEnabled)
            {
                info = new EyouSoft.BLL.SmsStructure.BSmsAccount().CreateSmsAccount();
            }

            if (info == null)
            {
                return(false);
            }

            bool dalRetCode = dal.SetComSmsConfig(companyId, info);

            string cachekey = string.Format(EyouSoft.Cache.Tag.TagName.ComSetting, companyId);

            EyouSoft.Cache.Facade.EyouSoftCache.Remove(cachekey);

            return(dalRetCode);
        }
Beispiel #2
0
        ///// <summary>
        ///// 根据键名获取值
        ///// </summary>
        ///// <param name="CompanyId"></param>
        ///// <param name="SettingType"></param>
        ///// <returns></returns>
        //public string GetSettingByType(string CompanyId, SysConfiguration SettingType)
        //{
        //    string sql = "SELECT CompanyId,[Key],[Value] FROM tbl_ComSetting WHERE CompanyId = @CompanyId and [Key]=@Key";
        //    DbCommand comm = this._db.GetSqlStringCommand(sql);
        //    this._db.AddInParameter(comm, "CompanyId", DbType.AnsiStringFixedLength, CompanyId);
        //    this._db.AddInParameter(comm, "Key", DbType.String, (int)SettingType);
        //    string value = string.Empty;
        //    using (IDataReader reader = DbHelper.ExecuteReader(comm, this._db))
        //    {
        //        if (reader.Read())
        //        {
        //            value = reader.IsDBNull(reader.GetOrdinal("Value")) ? "0" : reader.GetString(reader.GetOrdinal("Value"));
        //        }
        //    }
        //    return value;
        //}

        /// <summary>
        /// 设置公司短信配置信息
        /// </summary>
        /// <param name="companyId">公司编号</param>
        /// <param name="info">配置信息</param>
        /// <returns></returns>
        public bool SetComSmsConfig(string companyId, EyouSoft.Model.ComStructure.MSmsConfigInfo info)
        {
            #region create xml
            //xml格式<item><val id="key">value</val></item>
            StringBuilder xml = new StringBuilder();
            xml.Append("<item>");
            xml.AppendFormat("<val id='{0}'>{1}</val>", "SmsAccount", info.Account);
            xml.AppendFormat("<val id='{0}'>{1}</val>", "SmsAppKey", info.AppKey);
            xml.AppendFormat("<val id='{0}'>{1}</val>", "SmsAppSecret", info.AppSecret);
            xml.Append("</item>");
            #endregion

            DbCommand cmd = this._db.GetStoredProcCommand(SQL_PROC_SetSettings);
            _db.AddInParameter(cmd, "@CompanyId", DbType.AnsiStringFixedLength, companyId);
            _db.AddInParameter(cmd, "@xml", DbType.Xml, xml.ToString());
            _db.AddOutParameter(cmd, "@RetCode", DbType.Int32, 4);

            int sqlExceptionCode = 0;
            try
            {
                DbHelper.RunProcedure(cmd, _db);
            }
            catch (System.Data.SqlClient.SqlException e)
            {
                sqlExceptionCode = 0 - e.Number;
            }

            if (sqlExceptionCode < 0)
            {
                return(false);
            }
            else
            {
                return(Convert.ToInt32(_db.GetParameterValue(cmd, "RetCode")) == 1);
            }
        }