public override void InitCfg(string filename) { MainTrace.Add(TraceType.Cfg, $"file => {Path.GetFileName(filename)} "); XmlDocument xdoc = XFunc.Load(filename); foreach (XmlNode cfgNode in xdoc.SelectNodes("descendant::cfg")) { foreach (XmlNode typeNode in cfgNode.SelectNodes("*")) { Type t = GetClassTypeByClassName(typeNode.Name); if (t != null) { MainTrace.Add(TraceType.Cfg, $"Class => {t.Name}"); foreach (XmlNode itemNode in typeNode.SelectNodes("*")) { LockUpdates++; try { MEDMObj obj = MainDic.GetObj(t, itemNode.Name); obj.SetValues(itemNode); MainTrace.Add(TraceType.Cfg, $"Item => {itemNode.Name} ({obj})"); } finally { LockUpdates--; } } } else { MainTrace.Add(TraceType.Error, $"Для узла конфигурации {typeNode.Name} класс не найден"); } } } }
public T Load <T>(XmlNode xnode, string pref = "") where T : MEDMObj { T p = null; string n = XFunc.GetAttr(xnode, "name", ""); if (n != "") { __ = $"{typeof(T).Name}: {n}"; if (pref != "") { n = $"{pref}.{n}"; } p = MainDic.GetObj <T>(n); try { p.SetValues(xnode); } catch (Exception e) { __ = $"error: {e}"; } } else { __ = $"error: Имя {typeof(T).Name} не задано."; } return(p); }
public override void InitUser(string login, string name, string password) { MEntity entity = SelectFirst <MEntity>($"select * from MEntity where EntityTypeId='USR' and code={AddParam(login)}"); if (entity == null) { entity = MainDic.GetObj <MEntity>(null); entity.Code = login; entity.Name = name; entity.EntityTypeId = "USR"; } MPassword pass = SelectFirst <MPassword>($"select * from MPassword where Id={AddParam(login)}"); if (pass == null) { pass = MainDic.GetObj <MPassword>(login); pass.PassCode = MFunc.GetSecurityHash(password); } Save(null); }