//Подготовка провайдера protected override void PrepareProvider() { var set = new SetS(); using (var rec = new DaoRec(Db, "Signals")) { while (rec.Read()) { var code = rec.GetString("FillCode"); var isContains = _outs.ContainsKey(code); rec.Put("IsActive", isContains); if (isContains) { set.Add(code); _outs[code].Id = rec.GetInt("SignalId"); } } foreach (var k in _outs.Keys) { if (!set.Contains(k)) { rec.AddNew(); var o = _outs[k].ValueSignal; rec.Put("FullCode", o.Code); rec.Put("DataType", o.DataType.ToRussian()); rec.Put("SignalType", SignalType.List.ToRussian()); _outs[k].Id = rec.GetInt("SignalId"); } } } CloneRec = new DaoRec(Db, "MomentValues"); CloneStrRec = new DaoRec(Db, "MomentStrValues"); }
//Создание фабрики ошибок protected override IMomErrFactory MakeErrFactory() { AddEvent("Создание фабрики ошибок"); var factory = new MomErrFactory(ProviderConnect.Code, MomErrType.Source); using (var rec = new DaoRec(CloneFile, "MomentErrors")) while (rec.Read()) { int quality = rec.GetInt("Quality"); int num = rec.GetInt("ErrNum"); string text = rec.GetString("ErrText"); factory.AddDescr(num, text, quality); } return(factory); }
//Сохранить подпараметры в таблицу private void SaveSubPars(DaoRec rec) { while (rec.Read()) { SubParamsId[rec.GetInt("SubParamId")].SaveCompileResults(rec); } }
//Загрузка сигналов private void LoadSignals() { AddEvent("Загрузка объектов"); using (var db = new DaoDb(Dir + "UsedSignals.accdb")) { var objectsId = new DicI <CalcObject>(); using (var rec = new DaoRec(db, "UsedObjects")) while (rec.Read()) { var ob = new CalcObject(rec); Objects.Add(ob.Code, ob); objectsId.Add(rec.GetInt("ObjectId"), ob); } AddEvent("Загрузка свойств объектов"); using (var rec = new DaoRec(db, "UsedObjectsProps")) while (rec.Read()) { var mean = MFactory.NewMean(rec.GetString("DataType").ToDataType(), rec.GetString("Mean")); objectsId[rec.GetInt("ObjectId")].Props.Add(rec.GetString("CodeProp"), mean); } AddEvent("Загрузка сигналов"); using (var rec = new DaoRec(db, "UsedSignals")) while (rec.Read()) { } } }
//Сгенерировать таблицу по данному ряду public void Generate(TablsList dataTabls, //Список таблиц с данными для генерации DaoRec rec, //Рекордсет генерируемой таблицы DaoRec subrec) //Рекордсет генерируемой подтаблицы { if (!Keeper.ErrMess.IsEmpty()) { return; } IEnumerable <SubRows> rows = Rule == null ? new SubRows[] { null } : ((NodeRTabl)Rule).SelectRows(dataTabls, null); foreach (var row in rows) { rec.AddNew(); int id = rec.GetInt(Table.IdField); GenerateFields(row, rec); rec.Update(); if (subrec != null) { foreach (var subRowGen in SubRows) { IEnumerable <SubRows> subRows = subRowGen.RuleString.IsEmpty() ? new [] { row } : (((INodeRTabl)subRowGen.Rule).SelectRows(dataTabls, row)); foreach (var subRow in subRows) { subrec.AddNew(); subrec.Put(subRowGen.Table.ParentIdField, id); subRowGen.GenerateFields(subRow, subrec); subrec.Update(); } } } } }
public GenRow(ModuleGenerator generator, //Ссылка на генератор TablsList dataTabls, //Исходные таблицы для генерации GenTemplateTable table, DaoRec rec, //Рекортсет и поля таблицы GenTemplateTable subTable, DaoRec subRec) //Рекордсет и и поля подтаблицы : base(generator, table, rec) { Id = rec.GetInt(table.IdField); var dataTabl = Rule == null ? null : ((NodeRTabl)Rule).Check(dataTabls, null); foreach (var key in Fields.Keys) { Keeper.SetFieldName(key); Fields[key].Check(dataTabl); } if (subRec != null && !subRec.EOF) { Keeper.SetFieldName(""); bool subErr = false; while (subRec.GetInt(subTable.ParentIdField) == Id) { var row = new GenSubRow(generator, dataTabls, dataTabl, subTable, subRec); if (row.Keeper.Errors.Count != 0 && !subErr) { Keeper.AddError("Ошибки в рядах подтаблицы", (IToken)null); subErr = true; } SubRows.Add(row); if (!subRec.MoveNext()) { break; } } } rec.Put(table.ErrField, Keeper.ErrMess); }
//Загрузка списка графиков private void LoadGrafics() { AddEvent("Загрузка списка графиков"); using (var rec = new DaoRec(Dir + "Grafics.accdb", "GraficsList")) while (rec.Read()) { var code = rec.GetString("Code"); Grafics.Add(code, new Grafic(code, rec.GetInt("Dimension"), rec.GetString("GraficType").ToGraficType())); } }
//Чтение Id сигналов клона private void ReadCloneSignals(DaoDb cloneDb) { AddEvent("Чтение сигналов клона"); ClearSignals(); using (var rec = new DaoRec(cloneDb, "Signals")) while (rec.Read()) { var sig = (CloneSignal)AddSignal(rec.GetString("FullCode"), rec.GetString("DataType").ToDataType(), rec.GetString("SignalType").ToSignalType() == SignalType.Uniform ? SignalType.UniformClone : SignalType.Clone, rec.GetString("InfObject"), rec.GetString("InfOut"), rec.GetString("InfProp")); sig.IdInClone = rec.GetInt("SignalId"); } }
//Запись объекта в рекорсеты вместе с сигналами и свойствами public void ToRecordsets(DaoRec recObjects, DaoRec recSignals, DaoRec recProps) { recObjects.AddNew(); recObjects.Put("CodeObject", Code); recObjects.Put("NameObject", Name); recObjects.Put("InfObject", InfObject); int id = recObjects.GetInt("ObjectId"); recObjects.Update(); foreach (var prop in UsedProps.Values) { prop.ToRecordset(recProps, id); } foreach (var sig in UsedSignals) { sig.ToRecordset(recSignals, id, Code); } }
//Отметка в клоне считывемых сигналов, получение Id сигналов protected override void PrepareProvider() { AddEvent("Отметка в клоне считывемых сигналов"); using (var rec = new DaoRec(CloneFile, "SELECT SignalId, FullCode, OtmReadClone FROM Signals")) while (rec.Read()) { string code = rec.GetString("FullCode"); var id = rec.GetInt("SignalId"); if (Objects.ContainsKey(code)) { rec.Put("OtmReadClone", true); var ob = Objects[code]; ObjectsId.Add(id, ob); ObjectsList.Add(ob); } else { rec.Put("OtmReadClone", false); } } }
private void LoadParams(string fileName, string tablName) { using (var db = new DaoDb(Dir + fileName + ".accdb")) { var paramsId = new DicI <CalcParam>(); using (var rec = new DaoRec(db, tablName + "Params")) while (rec.Read()) { var cp = new CalcParam(this, rec, false); CalcParams.Add(cp.Code, cp); paramsId.Add(rec.GetInt("ParamId"), cp); } using (var rec = new DaoRec(db, tablName + "SubParams")) while (rec.Read()) { var cp = new CalcParam(this, rec, true); var owner = paramsId[rec.GetInt("ParamId")]; owner.SubParams.Add(cp.Code, cp); cp.Owner = owner; } } }
//Подготова источника protected override void PrepareProvider() { OutsId.Clear(); OutsId2.Clear(); using (var rec = new DaoRec(DbFile, "Objects")) while (rec.Read()) { var code = rec.GetString("Code"); var table = rec.GetString("TableName"); var id = rec.GetInt("ObjectId"); if (table == "MomValues" && Outs.ContainsKey(code)) { var ob = Outs[code]; ob.IsInitialized = true; OutsId.Add(id, ob).Id = id; } if (table == "MomValues2" && Outs2.ContainsKey(code)) { var ob = Outs2[code]; OutsId2.Add(id, ob).Id = id; } } }
public void RecWrite() { using (var rec = new DaoRec(CopyDb("Write"), "Tabl")) { rec.Read(); rec.Put("IntField", 11); rec.Put("RealField", 1.6); rec.Put("StringField1", "Большой текст"); rec.Put("StringField2", "TextTextTextTextTextText", true); rec.Put("BoolField", false); rec.Put("TimeField", new DateTime(2016, 07, 02)); Assert.AreEqual(11, rec.GetInt("IntField")); Assert.AreEqual(1.6, rec.GetDouble("RealField")); Assert.AreEqual("Большой текст", rec.GetString("StringField1")); Assert.AreEqual("TextTextTe", rec.GetString("StringField2")); Assert.AreEqual(new DateTime(2016, 07, 02), rec.GetTime("TimeField")); Assert.IsFalse(rec.GetBool("BoolField")); Assert.AreEqual(1, rec.GetInt("Id")); rec.Update(); rec.MoveFirst(); Assert.AreEqual(11, rec.GetInt("IntField")); Assert.AreEqual(1.6, rec.GetDouble("RealField")); Assert.AreEqual("Большой текст", rec.GetString("StringField1")); Assert.AreEqual("TextTextTe", rec.GetString("StringField2")); Assert.AreEqual(new DateTime(2016, 07, 02), rec.GetTime("TimeField")); Assert.IsFalse(rec.GetBool("BoolField")); Assert.AreEqual(1, rec.GetInt("Id")); rec.Put(1, 11); rec.Put(2, 1.6); rec.Put(3, "Большой текст"); rec.Put(4, "TextTextTextTextTextText", true); rec.Put(5, false); rec.Put(6, new DateTime(2016, 07, 02)); Assert.AreEqual(11, rec.GetInt("IntField")); Assert.AreEqual(1.6, rec.GetDouble("RealField")); Assert.AreEqual("Большой текст", rec.GetString("StringField1")); Assert.AreEqual("TextTextTe", rec.GetString("StringField2")); Assert.AreEqual(new DateTime(2016, 07, 02), rec.GetTime("TimeField")); Assert.IsFalse(rec.GetBool("BoolField")); Assert.AreEqual(1, rec.GetInt("Id")); rec.Read(); rec.Put("IntField", (int?)null); rec.Put("RealField", (double?)null); rec.Put("StringField1", (string)null); rec.Put("StringField2", "Text", true); rec.Put("BoolField", (bool?)false); rec.Put("TimeField", (DateTime?)null); Assert.AreEqual(null, rec.GetIntNull("IntField")); Assert.AreEqual(0, rec.GetDouble("RealField")); Assert.AreEqual("", rec.GetString("StringField1", "")); Assert.AreEqual("Text", rec.GetString("StringField2")); Assert.AreEqual(false, rec.GetBoolNull("BoolField")); Assert.AreEqual(2, rec.GetInt("Id")); rec.Read(); rec.MovePrevious(); Assert.AreEqual(0, rec.GetInt("IntField")); Assert.AreEqual(null, rec.GetDoubleNull("RealField")); Assert.AreEqual(null, rec.GetString("StringField1")); Assert.AreEqual("Text", rec.GetString("StringField2")); Assert.AreEqual(null, rec.GetTimeNull("TimeField")); Assert.AreEqual(false, rec.GetBool("BoolField")); Assert.AreEqual(2, rec.GetIntNull("Id")); rec.Put(1, (int?)null); rec.Put(2, (double?)null); rec.Put(3, (string)null); rec.Put(4, "Text", true); rec.Put(5, (bool?)false); rec.Put(6, (DateTime?)null); Assert.AreEqual(null, rec.GetIntNull("IntField")); Assert.AreEqual(0, rec.GetDouble("RealField")); Assert.AreEqual("", rec.GetString("StringField1", "")); Assert.AreEqual("Text", rec.GetString("StringField2")); Assert.AreEqual(false, rec.GetBoolNull("BoolField")); Assert.AreEqual(2, rec.GetInt("Id")); Assert.AreEqual(5, rec.RecordCount); Assert.IsTrue(rec.MoveLast()); rec.Delete(); Assert.AreEqual(4, rec.RecordCount); Assert.IsTrue(rec.MoveLast()); Assert.AreEqual(40, rec.GetInt("IntField")); Assert.AreEqual(4.5, rec.GetDouble("RealField")); Assert.AreEqual("Большой текст 4", rec.GetString("StringField1")); Assert.IsTrue(rec.MoveLast()); Assert.IsFalse(rec.MoveNext()); Assert.IsTrue(rec.EOF); rec.AddNew(); rec.Put("IntField", 60); rec.Put("RealField", 6.6); rec.Put("StringField1", "Большой текст 6"); rec.Put("StringField2", "Text6", true); rec.Put("BoolField", true); rec.Put("TimeField", new DateTime(2016, 07, 06)); Assert.AreEqual(60, rec.GetInt("IntField")); Assert.AreEqual(6.6, rec.GetDouble("RealField")); Assert.AreEqual("Большой текст 6", rec.GetString("StringField1")); Assert.AreEqual("Text6", rec.GetString("StringField2")); Assert.AreEqual(new DateTime(2016, 07, 06), rec.GetTime("TimeField")); Assert.IsTrue(rec.GetBool("BoolField")); Assert.AreEqual(6, rec.GetInt("Id")); Assert.IsTrue(rec.MoveFirst()); Assert.IsTrue(rec.MoveLast()); Assert.AreEqual(60, rec.GetInt("IntField")); Assert.AreEqual(6.6, rec.GetDouble("RealField")); Assert.AreEqual("Большой текст 6", rec.GetString("StringField1")); Assert.AreEqual("Text6", rec.GetString("StringField2")); Assert.AreEqual(new DateTime(2016, 07, 06), rec.GetTime("TimeField")); Assert.IsTrue(rec.GetBool("BoolField")); Assert.AreEqual(6, rec.GetInt("Id")); Assert.AreEqual(5, rec.RecordCount); Assert.IsTrue(rec.HasRows); } }
public void RecRead() { using (var rec = new DaoRec(CopyDb("Read"), "Tabl")) { Assert.IsNotNull(rec.DaoDb); Assert.AreEqual(File("Read"), rec.DaoDb.File); Assert.AreEqual(7, rec.FiledsNum.Count); Assert.AreEqual(7, rec.Fileds.Count); Assert.AreEqual(7, rec.FieldsCount); Assert.IsTrue(rec.GetBool("BoolField")); Assert.AreEqual(true, rec.GetBoolNull("BoolField")); Assert.AreEqual(1, rec.GetInt("Id")); Assert.AreEqual(1, rec.GetIntNull("Id")); Assert.AreEqual(10, rec.GetInt("intField")); Assert.AreEqual(10, rec.GetIntNull("IntField")); Assert.AreEqual(1.5, rec.GetDouble("RealField")); Assert.AreEqual(1.5, rec.GetDoubleNull("REALFIELD")); Assert.AreEqual("Большой текст 1", rec.GetString("StringField1")); Assert.AreEqual("Text", rec.GetString("StringField2")); Assert.AreEqual(new DateTime(2016, 7, 1), rec.GetTime("TimeField")); Assert.AreEqual(new DateTime(2016, 7, 1), rec.GetTimeNull("TimeField")); Assert.AreEqual(1, rec.GetInt(0)); Assert.AreEqual(1, rec.GetIntNull(0)); Assert.AreEqual(10, rec.GetInt(1)); Assert.AreEqual(10, rec.GetIntNull(1)); Assert.AreEqual(1.5, rec.GetDouble(2)); Assert.AreEqual(1.5, rec.GetDoubleNull(2)); Assert.AreEqual("Большой текст 1", rec.GetString(3)); Assert.AreEqual("Text", rec.GetString(4)); Assert.AreEqual(true, rec.GetBool(5)); Assert.AreEqual(new DateTime(2016, 7, 1), rec.GetTime(6)); Assert.AreEqual(new DateTime(2016, 7, 1), rec.GetTimeNull(6)); Assert.IsTrue(rec.Read()); Assert.IsTrue(rec.Read()); Assert.IsFalse(rec.GetBool("BoolField")); Assert.AreEqual(false, rec.GetBoolNull("BoolField")); Assert.AreEqual(2, rec.GetInt("Id")); Assert.AreEqual(2, rec.GetIntNull("Id")); Assert.AreEqual(20, rec.GetInt("IntField")); Assert.AreEqual(20, rec.GetIntNull("IntField")); Assert.AreEqual(0, rec.GetDouble("RealField")); Assert.AreEqual(null, rec.GetDoubleNull("RealField")); Assert.AreEqual("Большой текст 2", rec.GetString("StringField1")); Assert.AreEqual("null", rec.GetString("StringField2", "null")); Assert.AreEqual(new DateTime(2016, 7, 2, 2, 3, 4), rec.GetTime("TimeField")); Assert.AreEqual(new DateTime(2016, 7, 2, 2, 3, 4), rec.GetTimeNull("TimeField")); Assert.AreEqual(2, rec.GetInt(0)); Assert.AreEqual(2, rec.GetIntNull(0)); Assert.AreEqual(20, rec.GetInt(1)); Assert.AreEqual(20, rec.GetIntNull(1)); Assert.AreEqual(0, rec.GetDouble(2)); Assert.AreEqual(null, rec.GetDoubleNull(2)); Assert.AreEqual("Большой текст 2", rec.GetString(3)); Assert.AreEqual("null", rec.GetString(4, "null")); Assert.IsFalse(rec.GetBool(5)); Assert.AreEqual(false, rec.GetBoolNull(5)); Assert.AreEqual(new DateTime(2016, 7, 2, 2, 3, 4), rec.GetTime(6)); Assert.AreEqual(new DateTime(2016, 7, 2, 2, 3, 4), rec.GetTimeNull(6)); Assert.IsTrue(rec.Read()); Assert.IsTrue(rec.GetBool("BoolField")); Assert.AreEqual(true, rec.GetBoolNull("BoolField")); Assert.AreEqual(3, rec.GetInt("Id")); Assert.AreEqual(3, rec.GetIntNull("Id")); Assert.AreEqual(0, rec.GetInt("IntField")); Assert.AreEqual(null, rec.GetIntNull("IntField")); Assert.IsTrue(rec.IsNull("IntField")); Assert.AreEqual(3.5, rec.GetDouble("RealField", 300)); Assert.AreEqual(3.5, rec.GetDoubleNull("RealField")); Assert.IsFalse(rec.IsNull("RealField")); Assert.AreEqual("Большой текст 3", rec.GetString("StringField1")); Assert.AreEqual("Text3", rec.GetString("StringField2", "null")); Assert.AreEqual(Static.MinDate, rec.GetTime("TimeField")); Assert.AreEqual(null, rec.GetTimeNull("TimeField")); Assert.AreEqual(3, rec.GetInt(0)); Assert.AreEqual(3, rec.GetIntNull(0)); Assert.AreEqual(0, rec.GetInt(1)); Assert.AreEqual(null, rec.GetIntNull(1)); Assert.IsTrue(rec.IsNull(1)); Assert.AreEqual(3.5, rec.GetDouble(2, 300)); Assert.AreEqual(3.5, rec.GetDoubleNull(2)); Assert.IsFalse(rec.IsNull(2)); Assert.AreEqual("Большой текст 3", rec.GetString(3)); Assert.AreEqual("Text3", rec.GetString(4, "null")); Assert.IsTrue(rec.GetBool(5)); Assert.AreEqual(true, rec.GetBoolNull(5)); Assert.AreEqual(Static.MinDate, rec.GetTime(6)); Assert.AreEqual(null, rec.GetTimeNull(6)); Assert.IsTrue(rec.Read()); Assert.IsTrue(rec.Read()); Assert.IsTrue(rec.GetBool("BoolField")); Assert.AreEqual(true, rec.GetBoolNull("BoolField")); Assert.AreEqual(5, rec.GetInt("Id")); Assert.AreEqual(5, rec.GetIntNull("Id")); Assert.AreEqual(50, rec.GetInt("IntField", 400)); Assert.AreEqual(50, rec.GetIntNull("IntField")); Assert.AreEqual(5.5, rec.GetDouble("RealField")); Assert.AreEqual(5.5, rec.GetDoubleNull("RealField")); Assert.AreEqual("Большой текст 5", rec.GetString("StringField1")); Assert.AreEqual(null, rec.GetString("StringField2")); Assert.AreEqual(new DateTime(2016, 7, 5), rec.GetTime("TimeField")); Assert.AreEqual(new DateTime(2016, 7, 5), rec.GetTimeNull("TimeField")); Assert.IsFalse(rec.Read()); Exception exception = null; try { Assert.IsTrue(rec.GetBool("BoolField")); } catch (Exception ex) { exception = ex; } Assert.IsNotNull(exception); Assert.IsNotNull(rec.Recordset); rec.Recordset.MoveFirst(); Assert.AreEqual(1, (int)rec.Recordset.Fields["Id"].Value); } using (var rec = new DaoRec(File("Read"), "SELECT Tabl.Id, Tabl.IntField AS IntF, Tabl.RealField, SubTabl.StringSubField AS StringF " + "FROM Tabl LEFT JOIN SubTabl ON Tabl.Id = SubTabl.ParentId ORDER BY Tabl.Id, SubTabl.StringSubField;")) { Assert.IsTrue(rec.Read()); Assert.AreEqual(1, rec.GetInt("Id")); Assert.AreEqual(10, rec.GetInt("IntF")); Assert.AreEqual(2, rec.GetInt("RealField")); Assert.AreEqual(1.5, rec.GetDouble("RealField")); Assert.AreEqual("1", rec.GetString("StringF")); Assert.AreEqual(1, rec.GetInt(0)); Assert.AreEqual(10, rec.GetInt(1)); Assert.AreEqual(1.5, rec.GetDouble(2)); Assert.AreEqual("1", rec.GetString(3)); Assert.AreEqual(1, rec.GetIntNull(0)); Assert.AreEqual(10, rec.GetIntNull(1)); Assert.AreEqual(1.5, rec.GetDoubleNull(2)); Assert.IsTrue(rec.Read()); Assert.AreEqual(2, rec.GetInt("Id")); Assert.AreEqual(20, rec.GetInt("IntF")); Assert.AreEqual(0, rec.GetInt("RealField")); Assert.AreEqual(0, rec.GetDouble("RealField")); Assert.AreEqual("22", rec.GetString("StringF")); Assert.IsTrue(rec.Read()); Assert.AreEqual(2, rec.GetInt("Id")); Assert.AreEqual("2", rec.GetString("Id")); Assert.AreEqual(20, rec.GetInt("IntF")); Assert.AreEqual(0, rec.GetInt("RealField")); Assert.AreEqual(null, rec.GetIntNull("RealField")); Assert.AreEqual(0, rec.GetDouble("RealField")); Assert.AreEqual(null, rec.GetDoubleNull("RealField")); Assert.AreEqual("222", rec.GetString("StringF")); Assert.IsTrue(rec.Read()); Assert.AreEqual(3, rec.GetInt("Id")); Assert.AreEqual(0, rec.GetInt("IntF")); Assert.AreEqual(4, rec.GetInt("RealField")); Assert.AreEqual(3.5, rec.GetDouble("RealField")); Assert.AreEqual("333", rec.GetString("StringF")); Assert.IsFalse(rec.EOF); Assert.IsTrue(rec.FindFirst("StringF LIKE '5555*'")); Assert.IsFalse(rec.NoMatch); Assert.AreEqual(50, rec.GetInt("IntF")); Assert.AreEqual("55555", rec.GetString("StringF")); Assert.IsTrue(rec.FindNext("StringF LIKE '5555*'")); Assert.IsFalse(rec.NoMatch); Assert.AreEqual(50, rec.GetInt("IntF")); Assert.AreEqual("555555", rec.GetString("StringF")); Assert.IsFalse(rec.FindNext("StringF LIKE '5555*'")); Assert.IsTrue(rec.NoMatch); Assert.IsTrue(rec.FindFirst("Id", 4)); Assert.IsFalse(rec.NoMatch); Assert.AreEqual(40, rec.GetInt("IntF")); Assert.AreEqual(null, rec.GetString("StringF")); Assert.IsTrue(rec.MovePrevious()); Assert.AreEqual(3.5, rec.GetDouble("RealField")); Assert.AreEqual("3333", rec.GetString("StringF")); Assert.IsTrue(rec.FindFirst("StringF", "22")); Assert.IsFalse(rec.NoMatch); Assert.AreEqual(20, rec.GetInt("IntF")); Assert.IsFalse(rec.FindFirst("StringF", "2222")); Assert.IsTrue(rec.NoMatch); Assert.IsTrue(rec.FindLast("StringF", "3333")); Assert.IsFalse(rec.NoMatch); Assert.AreEqual(3333, rec.GetInt("StringF")); Assert.IsTrue(rec.FindPrevious("Id", 1)); Assert.AreEqual(10, rec.GetInt("IntF")); Assert.IsTrue(rec.FindLast("Id", 5)); Assert.AreEqual(50, rec.GetInt("IntF")); Assert.IsTrue(rec.FindPrevious("StringF", "222")); Assert.AreEqual(20, rec.GetInt("IntF")); Assert.IsTrue(rec.FindNext("StringF", "55555")); Assert.AreEqual(50, rec.GetInt("IntF")); Assert.IsTrue(rec.FindNext("Id", 5)); Assert.AreEqual(50, rec.GetInt("IntF")); Assert.IsFalse(rec.FindNext("StringF", "xxx")); Assert.IsFalse(rec.FindNext("IntF", 234)); } }
//Загрузка сигналов 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()); } } }); }