private void GetDictionaryInfoByLocal() { List <V_Dictionary> dicts = new List <V_Dictionary>(); List <V_DictionaryInfo> LocalDictionaryInfos = V_DictionaryInfoVM.GetAllV_DictionaryInfo(); foreach (var item in LocalDictionaryInfos) { V_Dictionary dict = SMT.SAAS.Main.CurrentContext.Common.CloneObject <V_DictionaryInfo, V_Dictionary>(item, new V_Dictionary()); dicts.Add(dict); } SaveDictionary(dicts); }
/// <summary> /// 根据字典类型获取所有的字典值,根据时间取值 2011-5-6 /// </summary> /// <param name="sysType">字典类型,为空时获取所有类型的字典值</param> /// <returns>字典值信息列表</returns> public IQueryable <V_Dictionary> GetSysDictionaryByCategoryByUpdateDate(string category, DateTime dt) { try { var ents = from a in ListTemp.AsQueryable() //where (string.IsNullOrEmpty(category) || a.DICTIONCATEGORY == category) && (a.UPDATEDATE > dt || a.CREATEDATE > dt) //orderby a.DICTIONARYVALUE select a; if (!string.IsNullOrEmpty(category)) { ents = ents.Where(p => p.DICTIONCATEGORY == category); } if (dt != null) { ents = ents.Where(p => p.CREATEDATE > dt || p.UPDATEDATE > dt); } List <V_Dictionary> listDict = new List <V_Dictionary>(); if (ents != null) { if (ents.Count() > 0) { ents.ToList().ForEach(item => { V_Dictionary ent = new V_Dictionary(); ent.DICTIONARYID = item.DICTIONARYID; ent.DICTIONARYNAME = item.DICTIONARYNAME; ent.DICTIONARYVALUE = (decimal)item.DICTIONARYVALUE; ent.DICTIONCATEGORY = item.DICTIONCATEGORY; ent.FATHERID = item.T_SYS_DICTIONARY2 == null ? "":item.T_SYS_DICTIONARY2.DICTIONARYID; ent.SYSTEMCODE = item.SYSTEMCODE; ent.ORDERNUMBER = item.ORDERNUMBER; listDict.Add(ent); }); } } return(listDict.Count() > 0 ? listDict.AsQueryable() : null); } catch (Exception ex) { Tracer.Debug("权限系统SysDictionaryBLL-GetSysDictionaryByCategory" + System.DateTime.Now.ToString() + " " + ex.ToString()); return(null); } }
/// <summary> /// 根据字典类型数组获取字典的列表 2011-5-6 /// </summary> /// <param name="sysType">字典类型,为空时获取所有类型的字典值</param> /// <returns>字典值信息列表</returns> public IQueryable <V_Dictionary> GetSysDictionaryByCategoryArray(string[] category) { try { List <V_Dictionary> listDict = new List <V_Dictionary>(); var ents = from a in ListTemp.AsQueryable() select a; if (category.Count() == 0) { return(null); } //if (category.Count() == 1) //{ // foreach (var item in ents) // { // Tracer.Debug(item.DICTIONCATEGORY); // if (item.DICTIONCATEGORY == category[0]) // { // V_Dictionary ent = new V_Dictionary(); // ent.DICTIONARYID = item.DICTIONARYID; // ent.DICTIONARYNAME = item.DICTIONARYNAME; // ent.DICTIONARYVALUE = (decimal)item.DICTIONARYVALUE; // ent.DICTIONCATEGORY = item.DICTIONCATEGORY; // ent.FATHERID = item.T_SYS_DICTIONARY2 == null ? "" : item.T_SYS_DICTIONARY2.DICTIONARYID; // ent.SYSTEMCODE = item.SYSTEMCODE; // ent.ORDERNUMBER = item.ORDERNUMBER; // listDict.Add(ent); // } // } // //var q = (from ent in ents // // where ent.DICTIONCATEGORY == category[0] // // select new V_Dictionary // // { // // DICTIONARYID = ent.DICTIONARYID, // // DICTIONARYNAME = ent.DICTIONARYNAME, // // DICTIONARYVALUE = (decimal)ent.DICTIONARYVALUE, // // DICTIONCATEGORY = ent.DICTIONCATEGORY, // // FATHERID = ent.T_SYS_DICTIONARY2 == null ? "" : ent.T_SYS_DICTIONARY2.DICTIONARYID, // // SYSTEMCODE = ent.SYSTEMCODE, // // ORDERNUMBER = ent.ORDERNUMBER // // }).FirstOrDefault(); // //if (q != null) // //{ // // listDict.Add(q); // //} // return listDict.AsQueryable(); //} string filterstring = ""; List <object> paras = new List <object>(); for (int i = 0; i < category.Count(); i++) { if (!string.IsNullOrEmpty(filterstring)) { filterstring += " or "; filterstring += " DICTIONCATEGORY ==@" + paras.Count().ToString(); paras.Add(category[i]); } else { //单独条件mysql未生效,原因未知 filterstring = " DICTIONCATEGORY ==@" + paras.Count().ToString(); paras.Add(category[i]); } } if (!string.IsNullOrEmpty(filterstring)) { ents = ents.Where(filterstring, paras.ToArray()); } if (ents != null) { if (ents.Count() > 0) { ents.ToList().ForEach(item => { V_Dictionary ent = new V_Dictionary(); ent.DICTIONARYID = item.DICTIONARYID; ent.DICTIONARYNAME = item.DICTIONARYNAME; ent.DICTIONARYVALUE = (decimal)item.DICTIONARYVALUE; ent.DICTIONCATEGORY = item.DICTIONCATEGORY; ent.FATHERID = item.T_SYS_DICTIONARY2 == null ? "" : item.T_SYS_DICTIONARY2.DICTIONARYID; ent.SYSTEMCODE = item.SYSTEMCODE; ent.ORDERNUMBER = item.ORDERNUMBER; listDict.Add(ent); }); } } return(listDict.Count() > 0 ? listDict.AsQueryable() : null); } catch (Exception ex) { Tracer.Debug("权限系统SysDictionaryBLL-GetSysDictionaryByCategory" + System.DateTime.Now.ToString() + " " + ex.ToString()); return(null); } }
/// <summary> /// 根据字典类型数组获取字典的列表 2011-5-6 /// </summary> /// <param name="sysType">字典类型,为空时获取所有类型的字典值</param> /// <returns>字典值信息列表</returns> public IQueryable <V_Dictionary> GetSysDictionaryByCategoryArray(string[] category) { try { var ents = from a in ListTemp.AsQueryable() select a; if (category.Count() == 0) { return(null); } string filterstring = ""; List <object> paras = new List <object>(); for (int i = 0; i < category.Count(); i++) { if (!string.IsNullOrEmpty(filterstring)) { filterstring += " or "; filterstring += " DICTIONCATEGORY ==@" + paras.Count().ToString(); paras.Add(category[i]); } else { filterstring = ""; filterstring = " DICTIONCATEGORY ==@" + paras.Count().ToString(); paras.Add(category[i]); } } if (!string.IsNullOrEmpty(filterstring)) { ents = ents.Where(filterstring, paras.ToArray()); } List <V_Dictionary> listDict = new List <V_Dictionary>(); if (ents != null) { if (ents.Count() > 0) { ents.ToList().ForEach(item => { V_Dictionary ent = new V_Dictionary(); ent.DICTIONARYID = item.DICTIONARYID; ent.DICTIONARYNAME = item.DICTIONARYNAME; ent.DICTIONARYVALUE = (decimal)item.DICTIONARYVALUE; ent.DICTIONCATEGORY = item.DICTIONCATEGORY; ent.FATHERID = item.T_SYS_DICTIONARY2 == null ? "" : item.T_SYS_DICTIONARY2.DICTIONARYID; ent.SYSTEMCODE = item.SYSTEMCODE; ent.ORDERNUMBER = item.ORDERNUMBER; listDict.Add(ent); }); } } return(listDict.Count() > 0 ? listDict.AsQueryable() : null); } catch (Exception ex) { Tracer.Debug("权限系统SysDictionaryBLL-GetSysDictionaryByCategory" + System.DateTime.Now.ToString() + " " + ex.ToString()); return(null); } }