public string GetEnumDes(DicType dic) { return(dic.ToDescription()); }
private void DoICollectionTests(SortedList good, ICollection bad, Hashtable hsh1, DicType dic) { if (good.Count != bad.Count) { hsh1["Count"] = ""; } if (good.IsSynchronized != bad.IsSynchronized) { hsh1["IsSynchronized"] = ""; } if (good.SyncRoot != bad.SyncRoot) { hsh1["SyncRoot"] = ""; } //CopyTo string[] iArr1 = null; string[] iArr2 = null; DictionaryEntry[] dicEnt1; //CopyTo() copies the values!!! iArr1 = new string[good.Count]; iArr2 = new string[good.Count]; bad.CopyTo(iArr2, 0); if (dic == DicType.Value) { dicEnt1 = new DictionaryEntry[good.Count]; good.CopyTo(dicEnt1, 0); for (int i = 0; i < good.Count; i++) { iArr1[i] = (string)((DictionaryEntry)dicEnt1[i]).Value; } for (int i = 0; i < iArr1.Length; i++) { if (!iArr1[i].Equals(iArr2[i])) { hsh1["CopyTo"] = "vanila"; } } iArr1 = new string[good.Count + 5]; iArr2 = new string[good.Count + 5]; for (int i = 0; i < good.Count; i++) { iArr1[i + 5] = (string)((DictionaryEntry)dicEnt1[i]).Value; } bad.CopyTo(iArr2, 5); for (int i = 5; i < iArr1.Length; i++) { if (!iArr1[i].Equals(iArr2[i])) { hsh1["CopyTo"] = "5"; } } } else if (dic == DicType.Key) { for (int i = 0; i < iArr1.Length; i++) { if (!good.Contains(iArr2[i])) { hsh1["CopyTo"] = "Key"; } } } try { bad.CopyTo(iArr2, -1); hsh1["CopyTo"] = ""; } catch (ArgumentException) { } catch (Exception ex) { hsh1["CopyTo"] = ex; } try { bad.CopyTo(null, 5); hsh1["CopyTo"] = ""; } catch (ArgumentNullException) { } catch (Exception ex) { hsh1["CopyTo"] = ex; } //Enumerator IEnumerator ienm1; IEnumerator ienm2; ienm1 = good.GetEnumerator(); ienm2 = bad.GetEnumerator(); DoTheEnumerator(ienm1, ienm2, hsh1, dic, good); }
private void DoIListTests(SortedList good, IList bad, Hashtable hsh1, DicType dic) { if (bad.IsReadOnly != good.IsReadOnly) hsh1["IsReadOnly"] = ""; if (bad.IsFixedSize != good.IsFixedSize) hsh1["IsFixedSize"] = ""; try { if (dic == DicType.Key) { DoICollectionTests(good, bad, hsh1, DicType.Key); for (int i = 0; i < good.Count; i++) { if (!bad.Contains(good.GetKey(i))) hsh1["Contains"] = i; if (bad[i] != good.GetKey(i)) hsh1["Item"] = "get"; if (bad.IndexOf(good.GetKey(i)) != i) hsh1["IndexOf"] = i; } //we change the original and see if it is reflected in the IList good.Add("ThisHasToBeThere", null); if (!bad.Contains("ThisHasToBeThere")) hsh1["Contains"] = "Modified"; if (bad.Count != bad.Count) hsh1["Count"] = "Modified"; } else if (dic == DicType.Value) { DoICollectionTests(good, bad, hsh1, DicType.Value); for (int i = 0; i < good.Count; i++) { if (!bad.Contains(good.GetByIndex(i))) hsh1["Contains"] = i; if (bad[i] != good.GetByIndex(i)) hsh1["Item"] = "get"; if (bad.IndexOf(good.GetByIndex(i)) != i) hsh1["IndexOf"] = i; } //we change the original and see if it is reflected in the IList good.Add("ThisHasToBeThere", "ValueWasJustAdded"); if (!bad.Contains(good["ThisHasToBeThere"])) hsh1["Contains"] = "Modified"; if (bad.Count != bad.Count) hsh1["Count"] = "Modified"; } try { bad.Add("AnyValue"); hsh1["Add"] = "No_Exception thrown"; } catch (NotSupportedException) { } catch (Exception ex) { hsh1["Add"] = ex.GetType().Name; } if (bad.Count != bad.Count) hsh1["Count"] = "ReadWrite"; try { bad.Clear(); hsh1["Clear"] = "No_Exception thrown"; } catch (NotSupportedException) { } catch (Exception ex) { hsh1["Clear"] = ex.GetType().Name; } try { bad.Insert(0, "AnyValue"); hsh1["Insert"] = "No_Exception thrown"; } catch (NotSupportedException) { } catch (Exception ex) { hsh1["Insert"] = ex.GetType().Name; } try { bad.Remove("AnyValue"); hsh1["Remove"] = "No_Exception thrown"; } catch (NotSupportedException) { } catch (Exception ex) { hsh1["Remove"] = ex.GetType().Name; } try { bad.RemoveAt(0); hsh1["RemoveAt"] = "No_Exception thrown"; } catch (NotSupportedException) { } catch (Exception ex) { hsh1["RemoveAt"] = ex.GetType().Name; } } catch (Exception ex) { hsh1["DoIListTests"] = ex; } }
private void DoTheEnumerator(IEnumerator ienm1, IEnumerator ienm2, Hashtable hsh1, DicType dic, SortedList original) { while (ienm1.MoveNext()) { ienm2.MoveNext(); switch (dic) { case DicType.Key: if (((DictionaryEntry)ienm1.Current).Key != ienm2.Current) hsh1["Enumrator"] = ""; break; case DicType.Value: if (((DictionaryEntry)ienm1.Current).Value != ienm2.Current) hsh1["Enumrator"] = ""; break; case DicType.Both: if (((DictionaryEntry)ienm1.Current).Value != ((DictionaryEntry)ienm2.Current).Value) hsh1["Enumrator"] = ""; break; } } ienm1.Reset(); ienm2.Reset(); while (ienm1.MoveNext()) { ienm2.MoveNext(); switch (dic) { case DicType.Key: if (((DictionaryEntry)ienm1.Current).Key != ienm2.Current) hsh1["Enumrator"] = ""; break; case DicType.Value: if (((DictionaryEntry)ienm1.Current).Value != ienm2.Current) hsh1["Enumrator"] = ""; break; } } //we need to modify the original collection and make sure that the enum throws ienm2.Reset(); original.Add("Key_Blah", "Value_Blah"); try { ienm2.MoveNext(); hsh1["Enumerator"] = "NoEXception"; } catch (InvalidOperationException) { } catch (Exception ex) { hsh1["Enumerator"] = ex; } try { object blah = ienm2.Current; hsh1["Enumerator"] = "NoEXception"; } catch (InvalidOperationException) { } catch (Exception ex) { hsh1["Enumerator"] = ex; } try { ienm2.Reset(); hsh1["Enumerator"] = "NoEXception"; } catch (InvalidOperationException) { } catch (Exception ex) { hsh1["Enumerator"] = ex; } }
private void DoTheEnumerator(IEnumerator ienm1, IEnumerator ienm2, Hashtable hsh1, DicType dic, SortedList original) { while (ienm1.MoveNext()) { ienm2.MoveNext(); switch (dic) { case DicType.Key: if (((DictionaryEntry)ienm1.Current).Key != ienm2.Current) { hsh1["Enumrator"] = ""; } break; case DicType.Value: if (((DictionaryEntry)ienm1.Current).Value != ienm2.Current) { hsh1["Enumrator"] = ""; } break; case DicType.Both: if (((DictionaryEntry)ienm1.Current).Value != ((DictionaryEntry)ienm2.Current).Value) { hsh1["Enumrator"] = ""; } break; } } ienm1.Reset(); ienm2.Reset(); while (ienm1.MoveNext()) { ienm2.MoveNext(); switch (dic) { case DicType.Key: if (((DictionaryEntry)ienm1.Current).Key != ienm2.Current) { hsh1["Enumrator"] = ""; } break; case DicType.Value: if (((DictionaryEntry)ienm1.Current).Value != ienm2.Current) { hsh1["Enumrator"] = ""; } break; } } //we need to modify the original collection and make sure that the enum throws ienm2.Reset(); original.Add("Key_Blah", "Value_Blah"); try { ienm2.MoveNext(); hsh1["Enumerator"] = "NoEXception"; } catch (InvalidOperationException) { } catch (Exception ex) { hsh1["Enumerator"] = ex; } try { object blah = ienm2.Current; hsh1["Enumerator"] = "NoEXception"; } catch (InvalidOperationException) { } catch (Exception ex) { hsh1["Enumerator"] = ex; } try { ienm2.Reset(); hsh1["Enumerator"] = "NoEXception"; } catch (InvalidOperationException) { } catch (Exception ex) { hsh1["Enumerator"] = ex; } }
private void DoICollectionTests(SortedList good, ICollection bad, Hashtable hsh1, DicType dic) { if (good.Count != bad.Count) hsh1["Count"] = ""; if (good.IsSynchronized != bad.IsSynchronized) hsh1["IsSynchronized"] = ""; if (good.SyncRoot != bad.SyncRoot) hsh1["SyncRoot"] = ""; //CopyTo string[] iArr1 = null; string[] iArr2 = null; DictionaryEntry[] dicEnt1; //CopyTo() copies the values!!! iArr1 = new string[good.Count]; iArr2 = new string[good.Count]; bad.CopyTo(iArr2, 0); if (dic == DicType.Value) { dicEnt1 = new DictionaryEntry[good.Count]; good.CopyTo(dicEnt1, 0); for (int i = 0; i < good.Count; i++) iArr1[i] = (string)((DictionaryEntry)dicEnt1[i]).Value; for (int i = 0; i < iArr1.Length; i++) { if (!iArr1[i].Equals(iArr2[i])) hsh1["CopyTo"] = "vanila"; } iArr1 = new string[good.Count + 5]; iArr2 = new string[good.Count + 5]; for (int i = 0; i < good.Count; i++) iArr1[i + 5] = (string)((DictionaryEntry)dicEnt1[i]).Value; bad.CopyTo(iArr2, 5); for (int i = 5; i < iArr1.Length; i++) { if (!iArr1[i].Equals(iArr2[i])) { hsh1["CopyTo"] = "5"; } } } else if (dic == DicType.Key) { for (int i = 0; i < iArr1.Length; i++) { if (!good.Contains(iArr2[i])) hsh1["CopyTo"] = "Key"; } } try { bad.CopyTo(iArr2, -1); hsh1["CopyTo"] = ""; } catch (ArgumentException) { } catch (Exception ex) { hsh1["CopyTo"] = ex; } try { bad.CopyTo(null, 5); hsh1["CopyTo"] = ""; } catch (ArgumentNullException) { } catch (Exception ex) { hsh1["CopyTo"] = ex; } //Enumerator IEnumerator ienm1; IEnumerator ienm2; ienm1 = good.GetEnumerator(); ienm2 = bad.GetEnumerator(); DoTheEnumerator(ienm1, ienm2, hsh1, dic, good); }
private void LoadBase() { TreeItems.Clear(); var ssss = Convert.ToInt32(SqlLiteHelper.ExecuteQuery( "SELECT COUNT(*) as count FROM sqlite_master WHERE type='table' and name= 'menu_instances_relation'"). Tables[0].Rows[0][0].ToString().Trim()); if (ssss < 1) { SqlLiteHelper.ExecuteQuery( "CREATE TABLE 'menu_instances_relation' ('father_id' integer,'id' integer,'sort_index' integer,'name' text,'" + "instances_id' integer)"); } try { DataSet ds = SqlLiteHelper.ExecuteQuery("select * from menu_instances_relation", null); if (ds == null) { return; } int mCount = ds.Tables[0].Rows.Count; for (int i = 0; i < mCount; i++) { try { // (id integer NOT NULL,tag text,name text NOT NULL,tooltips text) int fatherId = Convert.ToInt32(ds.Tables[0].Rows[i]["father_id"].ToString().Trim()); int id = Convert.ToInt32(ds.Tables[0].Rows[i]["id"].ToString().Trim()); if ((id >= MenuIdControlAssign.MenuFileGroupIdMin && id <= MenuIdControlAssign.MenuFileGroupIdMax) || (id >= MenuIdControlAssign.MenuIdMin && id <= MenuIdControlAssign.MenuIdMax)) { int sortIndex = Convert.ToInt32(ds.Tables[0].Rows[i]["sort_index"].ToString().Trim()); string name = ds.Tables[0].Rows[i]["name"].ToString().Trim(); int instancesId = Convert.ToInt32(ds.Tables[0].Rows[i]["instances_id"].ToString().Trim()); if (instancesId == 2920022) //moban weizhi { if (fatherId == 0) { if (!DicType.ContainsKey(id)) { DicType.Add(id, name); } else { DicType[id] = name; } } else { if (DicType.ContainsKey(fatherId)) { TreeItems.Add(new TreeItemViewMode() { Id = id, Name = name, IsChecked = false, Description = DicType[fatherId], FatherId = fatherId }); } } } } } catch (Exception ex) { WriteLog.WriteLogError(ex.ToString()); } } } catch (Exception ex) { WriteLog.WriteLogError( "Class MenuInstanceRelationHoldingExtend Function loadItem from SQLlite table menu_instances_relation Occer an Error:" + ex.ToString()); } var args = new PublishEventArgs() { EventId = EventIdAssign.MenuInstanceRelationLoadUpdate, EventType = PublishEventType.Core }; EventPublish.PublishEvent(args); //var lst = new List<MenuInstancesRelation>(); //foreach (var f in TreeItems) // lst.Add(new MenuInstancesRelation() // { // FatherId = f.FatherId, // Id = f.Id, // InstancesId = 2920022, // Name = f.Name, // SortIndex =0, // }); //ServerInstanceRelation.UpdateMenuInstanceRelation(2920022, "MainMenuMa", lst); }
private void DoIListTests(SortedList good, IList bad, Hashtable hsh1, DicType dic) { if (bad.IsReadOnly != good.IsReadOnly) { hsh1["IsReadOnly"] = ""; } if (bad.IsFixedSize != good.IsFixedSize) { hsh1["IsFixedSize"] = ""; } try { if (dic == DicType.Key) { DoICollectionTests(good, bad, hsh1, DicType.Key); for (int i = 0; i < good.Count; i++) { if (!bad.Contains(good.GetKey(i))) { hsh1["Contains"] = i; } if (bad[i] != good.GetKey(i)) { hsh1["Item"] = "get"; } if (bad.IndexOf(good.GetKey(i)) != i) { hsh1["IndexOf"] = i; } } //we change the original and see if it is reflected in the IList good.Add("ThisHasToBeThere", null); if (!bad.Contains("ThisHasToBeThere")) { hsh1["Contains"] = "Modified"; } if (bad.Count != bad.Count) { hsh1["Count"] = "Modified"; } } else if (dic == DicType.Value) { DoICollectionTests(good, bad, hsh1, DicType.Value); for (int i = 0; i < good.Count; i++) { if (!bad.Contains(good.GetByIndex(i))) { hsh1["Contains"] = i; } if (bad[i] != good.GetByIndex(i)) { hsh1["Item"] = "get"; } if (bad.IndexOf(good.GetByIndex(i)) != i) { hsh1["IndexOf"] = i; } } //we change the original and see if it is reflected in the IList good.Add("ThisHasToBeThere", "ValueWasJustAdded"); if (!bad.Contains(good["ThisHasToBeThere"])) { hsh1["Contains"] = "Modified"; } if (bad.Count != bad.Count) { hsh1["Count"] = "Modified"; } } try { bad.Add("AnyValue"); hsh1["Add"] = "No_Exception thrown"; } catch (NotSupportedException) { } catch (Exception ex) { hsh1["Add"] = ex.GetType().Name; } if (bad.Count != bad.Count) { hsh1["Count"] = "ReadWrite"; } try { bad.Clear(); hsh1["Clear"] = "No_Exception thrown"; } catch (NotSupportedException) { } catch (Exception ex) { hsh1["Clear"] = ex.GetType().Name; } try { bad.Insert(0, "AnyValue"); hsh1["Insert"] = "No_Exception thrown"; } catch (NotSupportedException) { } catch (Exception ex) { hsh1["Insert"] = ex.GetType().Name; } try { bad.Remove("AnyValue"); hsh1["Remove"] = "No_Exception thrown"; } catch (NotSupportedException) { } catch (Exception ex) { hsh1["Remove"] = ex.GetType().Name; } try { bad.RemoveAt(0); hsh1["RemoveAt"] = "No_Exception thrown"; } catch (NotSupportedException) { } catch (Exception ex) { hsh1["RemoveAt"] = ex.GetType().Name; } } catch (Exception ex) { hsh1["DoIListTests"] = ex; } }
/// <summary> /// 增加 /// </summary> /// <param name="DicType">DicType实体对象</param> /// <returns>int值,返回自增ID</returns> public int AddReturnId(DicType model) { return(dal.AddReturnId(model)); }
/// <summary> /// 修改 /// </summary> /// <param name="DicType">DicType实体对象</param> /// <returns>bool值,判断是否操作成功</returns> public bool Change(DicType model) { return(dal.Change(model)); }
/// <summary> /// 增加 /// </summary> /// <param name="DicType">DicType实体对象</param> /// <returns>bool值,判断是否操作成功</returns> public bool Add(DicType model) { return(dal.Add(model)); }
public static IList <SysDataDictionary> GetDictionaryList(DicType psn = DicType.全部) { return(SysDataDictService.FindList(o => o.DicPSN == (int)psn && o.CompanyId == CommonService.CompanyId)); }
public static void Print(Expression e, StringBuilder sb) { actions[e.GetType()](e, sb); }
public static void Print(this NewExpression exp, StringBuilder sb) { dic[exp.GetType()](exp, sb);//New Syntax for invoking an action }
/// <summary> /// 新增或修改数据字典信息,只包含(编码,名称,简码字段的表) /// </summary> /// <param name="type">表名枚举类型</param> /// <param name="code">编码</param> /// <param name="name">名称</param> /// <param name="scode">简码</param> /// <param name="oldcode">旧编码</param> /// <param name="typeData">type为b_过敏源枚举时,值为药物字段,b_卫生机构类别时,值为层次字段,其他无效</param> /// <returns></returns> public ResponseModel UpdateDicItems(int type, string code, string name, string scode, string oldcode, int typeData = 0) { //提示信息 var result = new ResponseModel(ResponseCode.Error, "保存基础信息失败!"); //字典表名 string tablename = ""; try { if (isTure(type)) { result.msg = "请求参数异常"; return(result); } DicType dictype = (DicType)type; //字典表名 tablename = dictype.ToString(); //判断是否有该表名 if (tablename.IsNullOrEmpty()) { result.msg = "未找到该基础数据枚举!"; } using (var db = new DbContext()) { var items = 0; var sqlBuilder = db.Sql(""); bool row = false; //判断编码是否存在 var data = db.Sql($"select * from {tablename} where 编码='{code}'").Exists(); //如果该编码存在 if (data) { //判断旧编码是否有值,没值代表新增,编码重复 if (string.IsNullOrEmpty(oldcode)) { row = true; } //判断旧编码和编码是否一致,不一致则为编码重复 else if (oldcode != code) { row = true; } else { row = false; } if (row) { result.msg = "编码已存在!"; return(result); } } //通过旧编码是否有值判断为新增还是修改 if (string.IsNullOrEmpty(oldcode)) { if (type == (int)DicType.b_过敏源 || type == (int)DicType.b_卫生机构类别) { items = db.Sql($"insert into {tablename} values('{code}','{name}','{scode}','{typeData}')").Execute(); } else { items = db.Sql($"insert into {tablename} values('{code}','{name}','{scode}')").Execute(); } } else { //判断旧编码是否有值 if (oldcode.IsNullOrEmpty()) { result.msg = "服务器异常!"; } var sqlStr = ""; var sqlwhere = ""; if (type == (int)DicType.b_过敏源 || type == (int)DicType.b_卫生机构类别) { if (type == (int)DicType.b_卫生机构类别) { sqlwhere = $",层次='{typeData}'"; //修改b_卫生机构类别基础信息 //sqlStr = $"Update {tablename} set 编码='{code}',简码='{scode}',名称='{name}',层次='{typeData}' where 编码='{oldcode}'"; } else { sqlwhere = $",药物='{typeData}'"; //修改b_过敏源基础信息 //sqlStr = $"Update {tablename} set 编码='{code}',简码='{scode}',名称='{name}',药物='{typeData}' where 编码='{oldcode}'"; } } //修改基础信息 sqlStr = $"Update {tablename} set 编码='{code}',简码='{scode}',名称='{name}' {sqlwhere} where 编码='{oldcode}'"; //执行SQL脚本 items = sqlBuilder.SqlText(sqlStr).Execute(); } //保存成功 if (items > 0) { result.code = (int)ResponseCode.Success; result.msg = "保存成功!"; } } } catch (Exception ex) { Logger.Instance.Error("基础数据表名:" + tablename + "修改失败", ex); } return(result); }