Example #1
0
        /// <summary>
        /// 保存配置信息
        /// </summary>
        /// <param name="settingrequest"></param>
        /// <returns></returns>
        public BasicResponse <SettingInfo> SaveSetting(SettingAddRequest settingrequest)
        {
            BasicResponse <SettingInfo> Result = new BasicResponse <SettingInfo>();

            SettingInfo dto = null;

            dto = settingrequest.SettingInfo;

            if (dto == null)
            {
                //throw new Exception("Setting对象为空,请检查是否已赋值!");
                ThrowException("SaveSetting", new Exception("Setting对象为空,请检查是否已赋值!"));
            }
            if (dto.StrKey == "")
            {
                //throw new Exception("SettingDTO对象未定义Key值,请先定义Key后保存!");
                ThrowException("SaveSetting", new Exception("SettingDTO对象未定义Key值,请先定义Key后保存!"));
            }
            if (dto.StrValue.Trim() == "")
            {
                //throw new Exception("SettingDTO对象未定义值,请先输入后保存!");
                ThrowException("SaveSetting", new Exception("SettingDTO对象未定义值,请先输入后保存!"));
            }
            if (dto.InfoState == InfoState.NoChange)
            {
                //throw new Exception("DTO对象未设置状态,请先设置!");
                ThrowException("SaveSetting", new Exception("DTO对象未设置状态,请先设置!"));
            }
            try
            {
                long ID = long.Parse(dto.ID);
                if (dto.InfoState == InfoState.AddNew)
                {
                    ID     = IdHelper.CreateLongId();
                    dto.ID = ID.ToString();
                    Result = AddSetting(settingrequest);
                }
                else
                {
                    SettingUpdateRequest updaterequest = new SettingUpdateRequest();
                    updaterequest.SettingInfo = settingrequest.SettingInfo;
                    Result = UpdateSetting(updaterequest);
                }
                //重新加载缓存
                SettingCacheLoadRequest settingCacheRequest = new SettingCacheLoadRequest();
                _SettingCacheService.LoadSettingCache(settingCacheRequest);
            }
            catch (System.Exception ex)
            {
                ThrowException("SaveSetting", ex);
            }
            return(Result);
        }
 public BasicResponse LoadSettingCache(SettingCacheLoadRequest settingCacheRequest)
 {
     SettingCache.SettingCahceInstance.Load();
     return(new BasicResponse());
 }