/// <summary> /// 得到选项值 /// </summary> /// <param name="valueField"></param> /// <param name="dictionary"></param> /// <returns></returns> private string GetOptionValue(ValueField valueField, Model.Dictionary dictionary) { string value = string.Empty; switch (valueField) { case ValueField.Id: value = dictionary.Id.ToString(); break; case ValueField.Code: value = dictionary.Code; break; case ValueField.Note: value = dictionary.Note; break; case ValueField.Other: value = dictionary.Other; break; case ValueField.Title: value = GetLanguageTitle(dictionary, Tools.GetCurrentLanguage()); break; case ValueField.Value: value = dictionary.Value; break; } return(value ?? string.Empty); }
public Model.Dictionary getDictionary(Model.Dictionary Dictionary1) { StringBuilder strsql = new StringBuilder(); strsql.Append("select * from Dictionary where "); strsql.AppendFormat("dicID='{0}'", Dictionary1.dicID); DataTable dt = sql.ExecuteDataSet(strsql.ToString()).Tables[0]; if (dt.Rows.Count < 1) { return(null); } Model.Dictionary Dictionary = new Model.Dictionary(); Dictionary.dicID = Dictionary1.dicID; Dictionary.dicType = dt.Rows[0]["dicType"].ToString(); Dictionary.dicValue = dt.Rows[0]["dicValue"].ToString(); Dictionary.dicEName = dt.Rows[0]["dicEName"].ToString(); Dictionary.dicCName = dt.Rows[0]["dicCName"].ToString(); Dictionary.ParentID = int.Parse(dt.Rows[0]["ParentID"].ToString()); Dictionary.dicRemark = dt.Rows[0]["dicRemark"].ToString(); Dictionary.CreateTime = dt.Rows[0]["CreateTime"].ToString() == "" ? baddate : DateTime.Parse(dt.Rows[0]["CreateTime"].ToString()); Dictionary.UpdateTime = dt.Rows[0]["UpdateTime"].ToString() == "" ? baddate : DateTime.Parse(dt.Rows[0]["UpdateTime"].ToString()); Dictionary.CreateUser = int.Parse(dt.Rows[0]["CreateUser"].ToString()); Dictionary.UpdateUser = int.Parse(dt.Rows[0]["UpdateUser"].ToString()); Dictionary.IsShow = int.Parse(dt.Rows[0]["IsShow"].ToString()); Dictionary.IsDel = int.Parse(dt.Rows[0]["IsDel"].ToString()); return(Dictionary); }
/// <summary> /// 得到多语言标题 /// </summary> /// <param name="dictionary">字典实体</param> /// <param name="language">语言</param> /// <returns></returns> public string GetLanguageTitle(Model.Dictionary dictionary, string language = "") { string title = string.Empty; if (null == dictionary) { return(title); } if (language.IsNullOrWhiteSpace()) { language = Tools.GetCurrentLanguage(); } switch (language) { case "en-US": title = dictionary.Title_en; break; case "zh": title = dictionary.Title_zh; break; default: title = dictionary.Title; break; } if (title.IsNullOrWhiteSpace()) { title = dictionary.Title; } return(title); }
public IActionResult Body() { string dictId = Request.Querys("id"); string parentId = Request.Querys("parentid"); Model.Dictionary dictionaryModel = null; Business.Dictionary dictionary = new Business.Dictionary(); if (dictId.IsGuid(out Guid guid)) { dictionaryModel = dictionary.Get(guid); } if (null == dictionaryModel) { dictionaryModel = new Model.Dictionary { Id = Guid.NewGuid(), ParentId = parentId.ToGuid(), Sort = dictionary.GetMaxSort(parentId.ToGuid()) }; } ViewData["id"] = dictId.IsNullOrWhiteSpace() ? "" : dictId; ViewData["query"] = Request.UrlQuery(); ViewData["query1"] = "appid=" + Request.Querys("appid") + "&tabid=" + Request.Querys("tabid"); ViewData["refreshId"] = dictionaryModel.ParentId; ViewData["isRoot"] = dictionaryModel.ParentId == Guid.Empty ? "1" : "0";//是否是根节点 return(View(dictionaryModel)); }
public async Task <Dictionary> Handle(AddDictionaryCommand request, CancellationToken cancellationToken) { var dictionaryDomain = new Model.Dictionary(request.Name, request.DictionaryKey); dictionaryDomain.Validate(); #region Persistence var dictionary = dictionaryDomain.ToModel <Command.Dictionary>(_Mapper); await _DictionaryRepository.Add(dictionary); await _UnitOfWork.Commit(); #endregion #region Bus var publishMessage = new Message(); publishMessage.MessageType = "AddDictionary"; var response = dictionaryDomain.ToQueryModel <Query.Dictionary>(_Mapper); publishMessage.SetData(response); await _Bus.SendMessage(publishMessage); #endregion return(response); }
/// <summary> /// 递归添加上级 /// </summary> /// <param name="dictionary"></param> /// <param name="dictionaries"></param> private void AddParents(Model.Dictionary dictionary, List <Model.Dictionary> dictionaries, Guid rootId) { var parent = Get(dictionary.ParentId); if (null != parent && parent.Id != rootId) { dictionaries.Add(parent); AddParents(parent, dictionaries, rootId); } }
/// <summary> /// 得到一个字典项的上级节点数 /// </summary> /// <param name="dictList"></param> /// <param name="dict"></param> /// <returns></returns> private int GetParentCount(List <Model.Dictionary> dictList, Model.Dictionary dict) { int parent = 0; Model.Dictionary parentDict = dictList.Find(p => p.Id == dict.ParentId); while (parentDict != null) { parentDict = dictList.Find(p => p.Id == parentDict.ParentId); parent++; } return(parent); }
/// <summary> /// 递归添加下级 /// </summary> /// <param name="dictionary"></param> /// <param name="dictionaries"></param> private void AddChilds(Model.Dictionary dictionary, List <Model.Dictionary> dictionaries) { var childs = GetChilds(dictionary.Id); if (childs.Count == 0) { return; } foreach (Model.Dictionary child in childs) { dictionaries.Add(child); AddChilds(child, dictionaries); } }
public int update(Model.Dictionary Dictionary) { StringBuilder strsql = new StringBuilder(); strsql.Append("update Dictionary set "); strsql.AppendFormat(" dicType ='{0}',", Dictionary.dicType); strsql.AppendFormat(" dicValue ='{0}',", Dictionary.dicValue); strsql.AppendFormat(" dicEName ='{0}',", Dictionary.dicEName); strsql.AppendFormat(" dicCName =N'{0}',", Dictionary.dicCName); strsql.AppendFormat(" ParentID ='{0}',", Dictionary.ParentID); strsql.AppendFormat(" dicRemark ='{0}',", Dictionary.dicRemark); strsql.AppendFormat(" CreateTime ={0},", Dictionary.CreateTime == baddate ? "null" : "'" + Dictionary.CreateTime.ToString() + "'"); strsql.AppendFormat(" UpdateTime ={0},", Dictionary.UpdateTime == baddate ? "null" : "'" + Dictionary.UpdateTime.ToString() + "'"); strsql.AppendFormat(" CreateUser ='******',", Dictionary.CreateUser); strsql.AppendFormat(" UpdateUser ='******',", Dictionary.UpdateUser); strsql.AppendFormat(" IsShow ='{0}',", Dictionary.IsShow); strsql.AppendFormat(" IsDel ='{0}'", Dictionary.IsDel); strsql.AppendFormat(" where dicID={0}", Dictionary.dicID); return(sql.ExecuteNonQuery(strsql.ToString())); }
public int Add(Model.Dictionary Dictionary) { StringBuilder strsql = new StringBuilder(); strsql.Append("insert into Dictionary values ("); strsql.AppendFormat("'{0}',", Dictionary.dicType); strsql.AppendFormat("'{0}',", Dictionary.dicValue); strsql.AppendFormat("'{0}',", Dictionary.dicEName); strsql.AppendFormat("N'{0}',", Dictionary.dicCName); strsql.AppendFormat("{0},", Dictionary.ParentID); strsql.AppendFormat("'{0}',", Dictionary.dicRemark); strsql.AppendFormat("{0},", Dictionary.CreateTime == baddate ? "null" : "'" + Dictionary.CreateTime.ToString() + "'"); strsql.AppendFormat("{0},", Dictionary.UpdateTime == baddate ? "null" : "'" + Dictionary.UpdateTime.ToString() + "'"); strsql.AppendFormat("{0},", Dictionary.CreateUser); strsql.AppendFormat("{0},", Dictionary.UpdateUser); strsql.AppendFormat("{0},", Dictionary.IsShow); strsql.AppendFormat("{0}", Dictionary.IsDel); strsql.Append(") select SCOPE_IDENTITY()"); return(Convert.ToInt32(sql.ExecuteSc(strsql.ToString()))); }
public string SaveBody(Model.Dictionary dictionaryModel) { if (!ModelState.IsValid) { return(Tools.GetValidateErrorMessag(ModelState)); } Business.Dictionary dictionary = new Business.Dictionary(); if (Request.Querys("id").IsGuid(out Guid guid)) { var oldModel = dictionary.Get(guid); string oldJSON = null == oldModel ? "" : oldModel.ToString(); dictionary.Update(dictionaryModel); Business.Log.Add("修改了数据字典-" + dictionaryModel.Title, type: Business.Log.Type.系统管理, oldContents: oldJSON, newContents: dictionaryModel.ToString()); } else { dictionary.Add(dictionaryModel); Business.Log.Add("添加了数据字典-" + dictionaryModel.Title, dictionaryModel.ToString(), Business.Log.Type.系统管理); } return("保存成功"); }
/// <summary> /// 导入数据字典 /// </summary> /// <param name="json"></param> public string Import(string json) { if (json.IsNullOrWhiteSpace()) { return("要导入的json为空!"); } Newtonsoft.Json.Linq.JArray jArray = null; try { jArray = Newtonsoft.Json.Linq.JArray.Parse(json); } catch { jArray = null; } if (null == jArray) { return("json解析错误!"); } foreach (Newtonsoft.Json.Linq.JObject jObject in jArray) { Model.Dictionary dictionaryModel = jObject.ToObject <Model.Dictionary>(); if (null == dictionaryModel) { continue; } if (Get(dictionaryModel.Id) != null) { Update(dictionaryModel); } else { Add(dictionaryModel); } } return("1"); }
/// <summary> /// 更新一个字典 /// </summary> /// <param name="dictionary"></param> /// <returns></returns> public int Update(Model.Dictionary dictionary) { return(dictionaryData.Update(dictionary)); }
public int Add(Model.Dictionary Dictionary) { return(itu.Add(Dictionary)); }
public Model.Dictionary getDictionary(Model.Dictionary Dictionary1) { return(itu.getDictionary(Dictionary1)); }
/// <summary> /// 添加字典 /// </summary> /// <param name="dictionary"></param> /// <returns></returns> public int Add(Model.Dictionary dictionary) { return(dictionaryData.Add(dictionary)); }
public int update(Model.Dictionary Dictionary) { return(itu.update(Dictionary)); }