public void CalificationProjectConfigItemInfoUpsert() { ConfigItemModel oReturn = new ConfigItemModel() { CalificationProjectConfigItemId = 1, CalificationProjectConfigItemInfoModel = new List <ConfigItemInfoModel>() { new ConfigItemInfoModel() { CalificationProjectConfigItemInfoId = 1, Question = new Company.Models.Util.CatalogModel() { ItemId = 609001 }, Rule = new Company.Models.Util.CatalogModel() { ItemId = 2001003, //Menor que (<) }, ValueType = new Company.Models.Util.CatalogModel() { ItemId = 2002002, //Numérico }, Value = "5", Score = "5", Enable = true, }, }, }; oReturn = ProveedoresOnLine.CalificationProject.Controller.CalificationProject.CalificationProjectConfigItemInfoUpsert(oReturn); Assert.AreEqual(true, oReturn.CalificationProjectConfigItemInfoModel.Count > 0); }
//public int AddNewConfigItems(ConfigItemModel objConfigItemModel) //{ // SqlParameter[] paramAdd = new SqlParameter[2]; // paramAdd[0] = new SqlParameter("@ConfigItemName", SqlDbType.VarChar, 100); // paramAdd[0].Value = objConfigItemModel.ConfigItemName; // paramAdd[1] = new SqlParameter("@ConfigItemValue", SqlDbType.VarChar, 100); // paramAdd[1].Value = objConfigItemModel.ConfigItemValue; // try // { // return SqlHelper.ExecuteNonQuery(ConnectionString, CommandType.StoredProcedure, "AddNewConfigItems", paramAdd); // } // catch (V2Exceptions ex) // { // throw; // } // catch (System.Exception ex) // { // FileLog objFileLog = FileLog.GetLogger(); // objFileLog.WriteLine(LogType.Error, ex.Message, "ConfigItemDAL.cs", "AddNewConfigItems", ex.StackTrace); // throw new V2Exceptions(ex.ToString(),ex); // } //} #endregion #region UpdateConfigItems public int UpdateConfigItems(ConfigItemModel objConfigItemModel) { try { SqlParameter[] paramAdd = new SqlParameter[4]; paramAdd[0] = new SqlParameter("@ConfigItemId", SqlDbType.Int); paramAdd[0].Value = objConfigItemModel.ConfigItemIdID; paramAdd[1] = new SqlParameter("@ConfigItemName", SqlDbType.VarChar, 100); paramAdd[1].Value = objConfigItemModel.ConfigItemName; paramAdd[2] = new SqlParameter("@ConfigItemValue", SqlDbType.VarChar, 100); paramAdd[2].Value = objConfigItemModel.ConfigItemValue; paramAdd[3] = new SqlParameter("@ConfigItemDescription", SqlDbType.VarChar, 100); paramAdd[3].Value = objConfigItemModel.ConfigItemDescription; return(SqlHelper.ExecuteNonQuery(ConnectionString, CommandType.StoredProcedure, "UpdateConfigItems", paramAdd)); } catch (V2Exceptions ex) { throw; } catch (System.Exception ex) { FileLog objFileLog = FileLog.GetLogger(); objFileLog.WriteLine(LogType.Error, ex.Message, "ConfigItemDAL.cs", "UpdateConfigItems", ex.StackTrace); throw new V2Exceptions(ex.ToString(), ex); } }
public async Task <IActionResult> Save(ConfigItemModel configItem) { configItem.EnableCache = HttpContext.Request.Form.ContainsKey("enableCache") && HttpContext.Request.Form["enableCache"] == "on"; try { if (configItem.ID == Guid.Empty) { await _configService.AddItemAsync(configItem); } else { await _configService.SaveItemAsync(configItem); } return(Redirect("/Home/Index")); } catch (Exception exception) { var url = "/Home/Edit"; if (configItem.ID != Guid.Empty) { url += $"/{configItem.ID}"; } return(Message(exception.Message, url)); } }
/// <summary> /// 配置项模型 /// </summary> /// <param name="model">服务名称</param> public ConfigItemFileModel(ConfigItemModel model) { ServiceName = model.ServiceName; UpstreamPathTemplate = $"/{ServiceName}/" + "{everything}"; if (model.EnableCache) { FileCacheOptions = new CacheFileModel { Region = $"{ServiceName}Region" }; } }
/// <summary> /// 获得配置项 /// </summary> /// <param name="id"></param> /// <returns></returns> public ConfigItemModel GetConfigItem(Guid id) { if (id == Guid.Empty) { throw new ArgumentNullException(nameof(id), "唯一标识为空"); } ConfigItemModel result = _ocelotConfig.Items.FirstOrDefault(m => m.ID == id); if (result == null) { throw new ArgumentException("唯一标识不存在", nameof(id)); } return(result); }
public static ConfigItemModel CalificationProjectConfigItemInfoUpsert(ConfigItemModel oConfigItemModel) { if (oConfigItemModel != null && oConfigItemModel.CalificationProjectConfigItemInfoModel != null && oConfigItemModel.CalificationProjectConfigItemInfoModel.Count > 0) { oConfigItemModel.CalificationProjectConfigItemInfoModel.All(cinf => { LogManager.Models.LogModel oLog = Company.Controller.Company.GetGenericLogModel(); try { cinf.CalificationProjectConfigItemInfoId = DAL.Controller.CalificationProjectDataController.Instance.CalificationProjectConfigItemInfoUpsert (oConfigItemModel.CalificationProjectConfigItemId, cinf.CalificationProjectConfigItemInfoId, cinf.Question.ItemId, cinf.Rule.ItemId, cinf.ValueType.ItemId, cinf.Value, cinf.Score, cinf.Enable); oLog.IsSuccess = true; } catch (Exception err) { oLog.IsSuccess = false; oLog.Message = err.Message + " - " + err.StackTrace; throw err; } finally { oLog.LogObject = cinf; oLog.RelatedLogInfo.Add(new LogManager.Models.LogInfoModel() { LogInfoType = "SurveyConfigId", Value = cinf.CalificationProjectConfigItemInfoId.ToString(), }); LogManager.ClientLog.AddLog(oLog); } return(true); }); } return(oConfigItemModel); }
/// <summary> /// 删除 /// </summary> /// <param name="id"></param> public async Task DeleteItemAsync(Guid id) { if (id == Guid.Empty) { throw new ArgumentNullException(nameof(id), "唯一标识为空"); } ConfigItemModel result = _ocelotConfig.Items.FirstOrDefault(m => m.ID == id); if (result == null) { throw new ArgumentException("唯一标识不存在", nameof(id)); } _ocelotConfig.Items.Remove(result); await _ocelotConfig.SaveAsync(); }
/// <summary> /// 添加 /// </summary> /// <param name="configItem"></param> public async Task AddItemAsync(ConfigItemModel configItem) { if (string.IsNullOrWhiteSpace(configItem.ServiceName)) { throw new ArgumentNullException(nameof(configItem), "服务名为空"); } if (_ocelotConfig.Items.Any(m => m.ServiceName == configItem.ServiceName)) { throw new ArgumentException("服务名重复", nameof(configItem)); } while (configItem.ID == Guid.Empty || _ocelotConfig.Items.Any(m => m.ID == configItem.ID)) { configItem.ID = Guid.NewGuid(); } _ocelotConfig.Items.Add(configItem); await _ocelotConfig.SaveAsync(); }
//public int AddNewConfigItems(ConfigItemModel objConfigItemModel) //{ // try // { // return objConfigItemDAL.AddNewConfigItems(objConfigItemModel); // } // catch (V2Exceptions ex) // { // throw; // } // catch (System.Exception ex) // { // FileLog objFileLog = FileLog.GetLogger(); // objFileLog.WriteLine(LogType.Error, ex.Message, "ConfigItemBOL.cs", "AddNewConfigItems", ex.StackTrace); // throw new V2Exceptions(ex.ToString(),ex); // } //} #endregion #region UpdateConfigItems public int UpdateConfigItems(ConfigItemModel objConfigItemModel) { try { return(objConfigItemDAL.UpdateConfigItems(objConfigItemModel)); } catch (V2Exceptions ex) { throw; } catch (System.Exception ex) { FileLog objFileLog = FileLog.GetLogger(); objFileLog.WriteLine(LogType.Error, ex.Message, "ConfigItemBOL.cs", "UpdateConfigItems", ex.StackTrace); throw new V2Exceptions(ex.ToString(), ex); } }
/// <summary> /// 保存 /// </summary> /// <param name="configItem">配置项</param> public async Task SaveItemAsync(ConfigItemModel configItem) { if (string.IsNullOrWhiteSpace(configItem.ServiceName)) { throw new ArgumentNullException(nameof(configItem), "服务名为空"); } if (_ocelotConfig.Items.Any(m => m.ID != configItem.ID && m.ServiceName == configItem.ServiceName)) { throw new ArgumentException("服务名重复", nameof(configItem)); } if (configItem.ID == Guid.Empty) { throw new ArgumentNullException(nameof(configItem), "唯一标识为空"); } ConfigItemModel configItemFormDB = _ocelotConfig.Items.FirstOrDefault(m => m.ID == configItem.ID); if (configItemFormDB == null) { throw new ArgumentException("唯一标识不存在", nameof(configItem)); } configItem.CopyProperties(configItemFormDB); await _ocelotConfig.SaveAsync(); }
/// <summary> /// 修改 /// </summary> /// <returns></returns> public IActionResult Edit(Guid id) { ConfigItemModel configItem = id == Guid.Empty ? new ConfigItemModel() : _configService.GetConfigItem(id); return(View(configItem)); }