public TablRow(DaoRec rec) { foreach (Field f in rec.Recordset.Fields) { Means.Add(f.Name, rec.GetMean(f.Type.ToDataType(), f.Name)); } }
public GenBaseRow(ModuleGenerator generator, //Ссылка на генератор GenTemplateTable table, //Описание полей таблицы-шаблона DaoRec rec) //Рекордсет таблицы шаблона генерации { Table = table; Keeper = new GenKeeper(generator); RuleString = rec.GetString(Table.RuleField); if (!RuleString.IsEmpty()) { var parse = Table.IsSub ? new SubRuleParsing(Keeper, Table.RuleField, RuleString) : new RuleParsing(Keeper, Table.RuleField, RuleString); Rule = parse.ResultTree; } foreach (Field field in rec.Recordset.Fields) { var name = field.Name; if (!Table.IsSpecial(name) && !rec.IsNull(name)) { var dataType = field.Type.ToDataType(); if (dataType != DataType.String) { Fields.Add(name, new GenConstNode(rec.GetMean(dataType, name))); } else { string s = rec.GetString(name); if (!s.Contains("[")) { Fields.Add(name, new GenConstNode(null, s)); } else { var fparse = new FieldsParsing(Keeper, name, rec.GetString(name)); var f = (IExprNode)fparse.ResultTree; if (f != null) { Fields.Add(name, f); } } } } } }
//Загрузка сигналов public void LoadSignals() { StartLog("Загрузка сигналов", null, Type + " " + Code).Run(() => { BaseObjectsTypes.Clear(); ObjectsTypes.Clear(); Objects.Clear(); var typesId = new DicI <ObjectType>(); var baseTypesId = new DicI <BaseObjectType>(); var objectsId = new DicI <TablikObject>(); using (var db = new DaoDb(SignalsFile)) { using (var rec = new DaoRec(db, "BaseObjectTypes")) while (rec.Read()) { var t = new BaseObjectType(this, rec); baseTypesId.Add(t.Id, t); BaseObjectsTypes.Add(t.Code, t); BaseObjectsTypes.Add(Code + "." + t.Code, t); } using (var rec = new DaoRec(db, "ObjectTypes")) while (rec.Read()) { var t = new ObjectType(this, rec); typesId.Add(t.Id, t); ObjectsTypes.Add(t.Code, t); ObjectsTypes.Add(Code + "." + t.Code, t); var list = rec.GetString("BaseTypes").ToPropertyList(); foreach (var bt in list) { if (BaseObjectsTypes.ContainsKey(bt)) { t.BaseTypes.Add(BaseObjectsTypes[bt]); } } } using (var rec = new DaoRec(db, "Objects")) while (rec.Read()) { var t = rec.GetString("TypeObject"); if (ObjectsTypes.ContainsKey(t)) { var ob = new TablikObject(this, ObjectsTypes[t], rec); objectsId.Add(ob.Id, ob); Objects.Add(ob.Code, ob); Objects.Add(Code + "." + ob.Code, ob); foreach (Field f in rec.Recordset.Fields) { if (f.Name != "Otm" && f.Name != "ObjectId" && f.Name != "SysField") { var dt = f.Type.ToDataType(); var m = rec.GetMean(dt, f.Name); ob.Props.Add(f.Name, new ObjectProp(f.Name, dt, m)); } } } } using (var rec = new DaoRec(db, "BaseSignals")) while (rec.Read()) { var s = new BaseTablikSignal(this, rec); var t = baseTypesId[rec.GetInt("BaseTypeId")]; t.Signals.Add(s.Code, s); if (rec.GetBool("Default")) { t.Signal = s; } } using (var rec = new DaoRec(db, "Signals")) while (rec.Read()) { var s = new TablikSignal(this, rec); var t = typesId[rec.GetInt("TypeId")]; t.Signals.Add(s.Code, s); if (rec.GetBool("Default")) { t.Signal = s; } foreach (var bt in t.BaseTypes) { var bcode = rec.GetString("CodeSignal" + (bt.SignalColumnNum == 1 ? "" : bt.SignalColumnNum.ToString())); if (!bcode.IsEmpty()) { t.Signals.Add(bcode, s); } } } using (var rec = new DaoRec(db, "ObjectsColumns")) while (rec.Read()) { ObjectsColumns.Add(rec.GetString("CodeColumn"), rec.GetString("DataType").ToDataType()); } } }); }