Beispiel #1
0
        /// <summary>
        ///保存配置文件到数据库
        /// </summary>
        /// <param name="alarmRequest"></param>
        /// <returns></returns>
        public BasicResponse <bool> SaveConfigToDatabase(SaveConfigToDatabaseRequest alarmRequest)
        {
            var response = new BasicResponse <bool>();

            try
            {
                if (alarmRequest.SettingInfo == null)
                {
                    var settingModel = new SettingModel();
                    settingModel.StrType        = "报警配置";
                    settingModel.StrKey         = "AlarmShowConfig";
                    settingModel.StrKeyCHs      = "报警设置";
                    settingModel.StrValue       = alarmRequest.Config;
                    settingModel.LastUpdateDate = DateTime.Now.ToString();
                    _SettingRepository.AddSetting(settingModel);
                }
                else
                {
                    var settingModel = _SettingRepository.GetSettingById(alarmRequest.SettingInfo.ID);
                    settingModel.StrValue       = alarmRequest.Config;
                    settingModel.LastUpdateDate = DateTime.Now.ToString();
                    _SettingRepository.UpdateSetting(settingModel);
                }
                response.Data = true;
            }
            catch (Exception ex)
            {
                response.Data    = false;
                response.Code    = -100;
                response.Message = ex.Message;
                this.ThrowException("SaveConfigToDatabase-保存配置文件到数据库-发生异常 ", ex);
            }

            return(response);
        }
        public static bool SaveConfigToDatabase(SettingInfo dto, string s)
        {
            bool flg = false;

            try
            {
                if (ClientAlarmConfig.getsererconnectstate())
                {
                    var request = new SaveConfigToDatabaseRequest();
                    request.SettingInfo = dto;
                    request.Config      = s;
                    var response = alarmService.SaveConfigToDatabase(request);
                    flg = response.Data;
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex);
            }
            return(flg);
        }
        public BasicResponse <bool> SaveConfigToDatabase(SaveConfigToDatabaseRequest alarmRequest)
        {
            var responsestr = HttpClientHelper.Post(Webapi + "/v1/alarm/saveconfigtodatabase?token=" + Token, JSONHelper.ToJSONString(alarmRequest));

            return(JSONHelper.ParseJSONString <BasicResponse <bool> >(responsestr));
        }
Beispiel #4
0
 public BasicResponse <bool> SaveConfigToDatabase(SaveConfigToDatabaseRequest alarmRequest)
 {
     return(alarmService.SaveConfigToDatabase(alarmRequest));
 }