示例#1
0
        public void Complex()
        {
            var dic = new DicS <int>(1000);

            dic.Clear();
            Assert.AreEqual(0, dic.Count);
            dic.Add("First", 1);
            dic.Add("Second", 2);
            Assert.AreEqual(2, dic.Count);
            Assert.AreEqual(1, dic["first"]);
            Assert.AreEqual(1, dic.Get("FIRST"));
            Assert.AreEqual(2, dic["Second"]);
            var dicAdd = new DicS <int>();

            dicAdd.Add("second", 22);
            dicAdd.Add("third", 33);
            dic.AddDic(dicAdd);
            Assert.AreEqual(3, dic.Count);
            Assert.IsTrue(dic.ContainsKey("THIRD"));
            Assert.IsTrue(dic.ContainsKey("Second"));
            Assert.AreEqual(56, dic.Values.Sum());
            dic.AddDic(dicAdd);
            Assert.AreEqual(3, dic.Count);
            Assert.AreEqual(1, dic["first"]);
            Assert.AreEqual(22, dic["second"]);
            Assert.AreEqual(33, dic["third"]);
            dic.Remove((k, v) => v == 33 || k.ToLower() == "second");
            Assert.AreEqual(1, dic.Count);
            Assert.IsTrue(dic.ContainsKey("First"));
            Assert.IsFalse(dic.ContainsKey("Second"));
        }
示例#2
0
        public void StringFromCollections()
        {
            var dic = new DicS <string>();

            Assert.AreEqual("", dic.ToPropertyString());
            dic.Add("Prop1", "a");
            dic.Add("Prop2", "b");
            dic.Add("Prop3", "c");
            Assert.AreEqual("PROP1=a;PROP2=b;PROP3=c;", dic.ToPropertyString());
            var dict = new Dictionary <string, string>();

            Assert.AreEqual("", dict.ToPropertyString());
            dict.Add("Prop1", "a");
            dict.Add("Prop2", "b");
            dict.Add("Prop3", "c");
            Assert.AreEqual("Prop1=a;Prop2=b;Prop3=c;", dict.ToPropertyString());
            var list = new List <string>();

            Assert.AreEqual("", list.ToPropertyString());
            list.Add("Prop1");
            list.Add("Prop2");
            list.Add("Prop3");
            Assert.AreEqual("Prop1;Prop2;Prop3;", list.ToPropertyString());
            var set = new HashSet <string>();

            Assert.AreEqual("", set.ToPropertyString());
            set.Add("Prop1");
            Assert.AreEqual("Prop1;", set.ToPropertyString());
        }
示例#3
0
 //Добавить ошибку в список
 public void AddError(string errMess, string lexeme, int line, int pos, IToken token = null)
 {
     if (!Errors.ContainsKey(FieldName))
     {
         Errors.Add(FieldName, new ParsingError(FieldName, errMess, lexeme, line, pos, token));
     }
 }
示例#4
0
        //Добавить сигнал в источник
        public ProviderSignal AddSignal(string signalInf, string code, DataType dataType, int idInClone = 0)
        {
            var sig = new ProviderSignal(signalInf, code, dataType, this, idInClone);

            ProviderSignals.Add(code, sig);
            string tableName = sig.Inf["TableName"];
            int    nodeId    = sig.Inf.GetInt("NodeId");
            string prop      = sig.Inf["Prop"];

            if (prop.IsEmpty())
            {
                if (!_objects.ContainsKey(tableName))
                {
                    _objects.Add(tableName, new DicI <ObjectProlog>());
                }
                var ob = _objects[tableName].Add(nodeId, new ObjectProlog(tableName, nodeId, prop));
                _objectsId.Add(nodeId, ob);
                return(ob.AddSignal(sig));
            }
            if (!_totals.ContainsKey(tableName))
            {
                _totals.Add(tableName, new DicI <ObjectProlog>());
            }
            var obt = _totals[tableName].Add(nodeId, new ObjectProlog(tableName, nodeId, prop));

            _totalsId.Add(nodeId, obt);
            return(obt.AddSignal(sig));
        }
示例#5
0
        //Добавить выход
        protected override ProviderOut AddOut(ProviderSignal sig)
        {
            var rout = new RealTimeArchiveOut(this);

            rout.AddSignal(sig);
            return(_outs.Add(sig.Code, rout));
        }
示例#6
0
 //Добавить модуль
 public void AddModule(string code)
 {
     if (!_modules.ContainsKey(code))
     {
         var smod = Project.SchemeModules[code];
         var mod  = new TablikModule(this, code, smod.Name, smod.Description);
         _modules.Add(code, mod);
         foreach (var m in smod.LinkedModules.Values)
         {
             AddModule(m);
             mod.LinkedModules.Add(_modules[m]);
         }
         foreach (var c in smod.LinkedConnects.Values)
         {
             if (Project.SchemeSources.ContainsKey(c))
             {
                 mod.LinkedSources.Add(Sources[c]);
             }
             if (Project.SchemeReceivers.ContainsKey(c))
             {
                 mod.LinkedReceivers.Add(Receivers[c]);
             }
         }
     }
 }
示例#7
0
        //Добавить модуль в поток
        public CalcModule AddModule(string code)
        {
            var m = new CalcModule(Project, code);

            Modules.Add(code, m);
            var sm = Project.SchemeModules[code];

            foreach (var ccode in sm.LinkedConnects.Values)
            {
                var con = AddConnect(ccode);
                if (con.Type == ProviderType.Source)
                {
                    m.LinkedSources.Add(Sources.Add(code, (SourceConnect)con));
                }
                if (con.Type == ProviderType.Receiver)
                {
                    m.LinkedReceivers.Add(Receivers.Add(code, (ReceiverConnect)con));
                }
            }

            foreach (var mcode in sm.LinkedModules.Values)
            {
                if (!Modules.ContainsKey(mcode))
                {
                    AddModule(mcode);
                }
                m.LinkedModules.Add(Modules[mcode]);
            }
            return(m);
        }
示例#8
0
        //Добавить выход в провайдер
        protected override ProviderOut AddOut(ProviderSignal sig)
        {
            string ocode = sig.Inf.Get("Name_Object") + "." + sig.Inf.Get("Name_Device") + "." + sig.Inf.Get("Name_Type");

            return(!Outs.ContainsKey(ocode)
                ? Outs.Add(ocode, new MirOut(this))
                : Outs[ocode]);
        }
示例#9
0
        public void Simple()
        {
            var dic = new DicS <string>();

            Assert.AreEqual(0, dic.Count);
            dic.Add("a", "sa");
            dic.Add("B", "sB");
            Assert.IsTrue(dic.ContainsKey("a"));
            Assert.IsTrue(dic.ContainsKey("b"));
            Assert.AreEqual("sa", dic["a"]);
            Assert.AreEqual("sB", dic["B"]);
            Assert.AreEqual("sa", dic.Get("A"));
            Assert.AreEqual("sB", dic.Get("b", "h"));
            Assert.IsNull(dic["c"]);
            Assert.AreEqual("h", dic.Get("c", "h"));
            Assert.AreEqual(2, dic.Count);
            dic.Add("b", "gghsdauh");
            Assert.AreEqual(2, dic.Count);
            Assert.AreEqual("sB", dic["B"]);
            dic["b"] = "gg";
            Assert.AreEqual(2, dic.Count);
            Assert.AreEqual("gg", dic["B"]);
            dic.Add("c", "SC");
            Assert.IsTrue(dic.ContainsKey("C"));
            Assert.AreEqual(3, dic.Count);
            dic.Add("b", "ssb", true);
            Assert.IsTrue(dic.ContainsKey("b"));
            Assert.IsTrue(dic.ContainsKey("c"));
            Assert.AreEqual("ssb", dic["b"]);
            Assert.IsTrue(dic.Keys.Contains("B"));
            Assert.IsTrue(dic.Values.Contains("ssb"));
            dic.Remove("C");
            Assert.AreEqual(2, dic.Count);
            Assert.IsFalse(dic.ContainsKey("c"));
            Assert.IsNull(dic["c"]);
            Assert.AreEqual("def", dic.Get("C", "def"));
            Assert.IsFalse(dic.Remove("C"));
            Assert.IsFalse(dic.ContainsKey("c"));
            Assert.AreEqual("def", dic.Get("C", "def"));
            Assert.IsFalse(dic.ContainsKey(null));
            dic.Clear();
            Assert.AreEqual(0, dic.Count);
            Assert.IsNull(dic["a"]);
            Assert.IsFalse(dic.ContainsKey("c"));
            Assert.IsFalse(dic.ContainsKey("a"));
        }
示例#10
0
        //Добавить сигнал приемника
        public ProviderSignal AddSignal(string signalInf, string code, DataType dataType)
        {
            if (_signalsCode.ContainsKey(code))
            {
                return(_signalsCode[code]);
            }
            var item = new OpcItem(signalInf, code, dataType, this);

            _signals.Add(item.Code, item);
            _signalsCode.Add(code, item);
            item.Tag           = GetOpcItemTag(item.Inf);
            item.ClientHandler = _signals.Count;
            if (!_items.ContainsKey(item.Tag))
            {
                _items.Add(item.Tag, item);
            }
            return(item);
        }
示例#11
0
 public RowGroupStruct(TablStruct tablStruct, IEnumerable <string> fields)
 {
     TablStruct = tablStruct;
     Fields     = new DicS <DataType>();
     foreach (var field in fields)
     {
         Fields.Add(field, tablStruct.Fields[field]);
     }
 }
示例#12
0
        //Добавить сигнал
        public SourceSignal AddSignal(string fullCode,       //Полный код сигнала
                                      DataType dataType,     //Тип данных
                                      SignalType signalType, //Тип сигнала
                                      string infObject,      //Свойства объекта
                                      string infOut  = "",   //Свойства выхода относительно объекта
                                      string infProp = "")   //Свойства сигнала относительно выхода
        {
            if (_readingSignals.ContainsKey(fullCode))
            {
                return(_readingSignals[fullCode]);
            }
            if (Provider != null)
            {
                Provider.IsPrepared = false;
            }
            var          contextOut = infObject + (infOut.IsEmpty() ? "" : ";" + infOut);
            var          inf        = infObject.ToPropertyDicS().AddDic(infOut.ToPropertyDicS()).AddDic(infProp.ToPropertyDicS());
            SourceSignal sig        = null;

            switch (signalType)
            {
            case SignalType.Mom:
                sig = _initialSignals.Add(fullCode, new MomSignal(this, fullCode, dataType, contextOut, inf));
                break;

            case SignalType.Uniform:
                sig = _initialSignals.Add(fullCode, new UniformSignal(this, fullCode, dataType, contextOut, inf));
                break;

            case SignalType.List:
                sig = _initialSignals.Add(fullCode, new ListSignal(this, fullCode, dataType, contextOut, inf));
                break;

            case SignalType.Clone:
                sig = _initialSignals.Add(fullCode, new CloneSignal((ClonerConnect)this, fullCode, dataType, contextOut, inf));
                break;

            case SignalType.UniformClone:
                sig = _initialSignals.Add(fullCode, new UniformCloneSignal((ClonerConnect)this, fullCode, dataType, contextOut, inf));
                break;
            }
            return(_readingSignals.Add(fullCode, sig));
        }
示例#13
0
        //Добавить сигнал
        public ProviderSignal AddSignal(string signalInf, string code, DataType dataType, int id = 0)
        {
            var sig = new SignalOvation(signalInf, code, dataType, this, 0);

            if (!_objectsId.ContainsKey(sig.Id))
            {
                _objectsId.Add(sig.Id, new ObjectOvation(sig.Id, code));
                if (IsOriginal)
                {
                    if (_objectsId.Count % 200 == 1)
                    {
                        _objectsParts.Add(new List <ObjectOvation>());
                    }
                    _objectsParts[_objectsParts.Count - 1].Add(_objectsId[sig.Id]);
                }
            }
            var ob = _objectsId[sig.Id];

            if (sig.IsState) //Слово состояния
            {
                if (ob.StateSignal == null)
                {
                    _signals.Add(sig.Code, sig);
                }
                return(ob.StateSignal ?? (ob.StateSignal = sig));
            }
            if (sig.Bit == -1)//Аналоговый или дискретный
            {
                ob.IsValue = true;
                if (ob.ValueSignal == null)
                {
                    _signals.Add(sig.Code, sig);
                }
                return(ob.ValueSignal ?? (ob.ValueSignal = sig));
            }
            if (!ob.BitSignals.ContainsKey(sig.Bit))//Бит упакованного
            {
                ob.IsValue = true;
                _signals.Add(sig.Code, sig);
                ob.BitSignals.Add(sig.Bit, sig);
            }
            return(ob.BitSignals[sig.Bit]);
        }
示例#14
0
        //Чтение списка сигналов
        private void ReadSignals()
        {
            AddEvent("Чтение списка сигналов");
            SignalsReceivers.Clear();
            if (ThreadCalc.IsReadSources)
            {
                SignalsSources.Clear();
                _signalsCodes.Clear();
            }

            using (var rec = new ReaderAdo(File, "SELECT * FROM SignalsInUse"))
            {
                int i = 0, n = rec.RecordCount("SELECT Count(*) FROM SignalsInUse");
                while (rec.Read())
                {
                    var sig = new CalcUnit(rec, this, true);
                    if (IsError)
                    {
                        return;
                    }
                    if (ThreadCalc.IsReadSources && !sig.SourceName.IsEmpty())
                    {
                        _signalsCodes.Add(sig.FullCode, sig.DataType);
                        SignalsSources.Add(sig.FullCode, sig);
                        if (sig.CodeObject != null)//null для сигналов ручного ввода
                        {
                            if (!Objects.ContainsKey(sig.CodeObject))
                            {
                                Objects.Add(sig.CodeObject, new CalcObject(sig.CodeObject));
                            }
                            var ob = Objects[sig.CodeObject];
                            ob.Signals.Add(sig.CodeSignal, sig);
                            sig.Object = ob;
                            if (sig.Default)
                            {
                                ob.DefaultSignal = sig;
                            }
                        }
                    }
                    if (ThreadCalc.IsWriteReceivers && !sig.ReceiverName.IsEmpty())
                    {
                        SignalsReceivers.Add(sig.FullCode, sig);
                    }
                    if (++i % 50 == 0)
                    {
                        Procent = i * 100.0 / n;
                    }
                }
            }
        }
示例#15
0
 //Чтение списка параметров
 private void ReadParams()
 {
     try
     {
         foreach (var par in _project.ArchiveParams.Values)
         {
             if (_allTasks || par.FirstParam.Task == _task)
             {
                 var fcode = par.ArchiveParam.FullCode;
                 if (!fcode.Contains("."))
                 {
                     if (!_params.ContainsKey(fcode))
                     {
                         _params.Add(fcode, new VedParam(par, this));
                     }
                 }
                 else
                 {
                     string code = fcode.Substring(0, fcode.LastIndexOf('.'));
                     if (!_params.ContainsKey(code) && _project.ArchiveParams.ContainsKey(code))
                     {
                         _params.Add(code, new VedParam(_project.ArchiveParams[code], this));
                     }
                     var cv = par.RunParam.CalcValue;
                     if (cv != null && cv.SingleValue != null && _params.ContainsKey(code))
                     {
                         _params[code].SubParams.Add(par.LastParam.Code, cv.SingleValue);
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         AddError("Ошибка загрузки списка параметров", ex, "", _project.Code);
     }
 }
示例#16
0
 //Получение списков кодов провайдеров по типам для выпадающих списков
 private static void ReadProvidersLists()
 {
     try
     {
         var prIds = new DicI <ProviderConfig>();
         using (var rec = new ReaderAdo(ConfigFile, "SELECT * FROM SysTabl WHERE (ParamType='Provider') And (ParamValue <>'Коммуникатор')"))
         {
             while (rec.Read())
             {
                 var code = rec.GetString("ParamName");
                 var pr   = new ProviderConfig(rec.GetString("ParamValue").ToProviderType(), code);
                 pr.JointProviders.Add(code);
                 prIds.Add(rec.GetInt("ParamId"), pr);
                 ProviderConfigs.Add(pr.Code, pr);
             }
             foreach (var pr in prIds.Values)
             {
                 if (pr.Type == ProviderType.Source)
                 {
                     ProviderConfigs["CloneSource"].JointProviders.Add(pr.Code);
                 }
             }
             using (var recp = new ReaderAdo(ConfigFile, "SELECT * FROM SysSubTabl WHERE (SubParamName='ProviderFile') Or (SubParamName='JointProviders')"))
                 while (recp.Read())
                 {
                     int id = recp.GetInt("ParamId");
                     if (prIds.ContainsKey(id))
                     {
                         string prop = recp.GetString("SubParamName");
                         var    pval = recp.GetString("SubParamValue");
                         if (prop == "ProviderFile")
                         {
                             prIds[id].File = InfoTaskDir + (pval.StartsWith(@"\") ? pval.Substring(1) : pval);
                         }
                         if (prop == "JointProviders")
                         {
                             prIds[id].JointProviders.AddRange(pval.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries));
                         }
                     }
                 }
         }
     }
     catch (Exception ex)
     {
         ex.MessageError("Ошибка загрузки установленных провайдеров. Не правильный файл Config.accdb");
     }
 }
示例#17
0
        //Получение списка проектов и режимов расчета
        public DicS <ReportProjectSetup> GetProjects()
        {
            var res = new DicS <ReportProjectSetup>();
            int i   = 2;

            try
            {
                while (!SysIsEmpty(i, 4))
                {
                    var pr = new ReportProjectSetup(SysValue(i, 4), SysValue(i, 5));
                    res.Add(pr.CodeFinal, pr);
                    i++;
                }
            }
            catch {}
            return(res);
        }
示例#18
0
 //Добавляет объект в ErrorsObjects
 protected void AddErrorOut(string codeObject,   //Код сигнала
                            string errText,      //Сообщение об ошибке
                            Exception ex = null) //Исключение
 {
     if (!_errorOuts.ContainsKey(codeObject))
     {
         var err = errText + (ex == null ? "" : ". " + ex.Message + ". " + ex.StackTrace);
         _errorOuts.Add(codeObject, err);
         if (ProviderConnect is ClonerConnect)
         {
             var rec = ((ClonerConnect)ProviderConnect).CloneErrorsRec;
             rec.AddNew();
             rec.Put("OutContext", codeObject);
             rec.Put("ErrorDescription", err);
             rec.Update();
         }
     }
 }
示例#19
0
        //Добавить выход в источник
        protected override ProviderOut AddOut(ProviderSignal sig)
        {
            int id = sig.Inf.GetInt("NodeId");

            if (OutsId.ContainsKey(id))
            {
                return(OutsId[id]);
            }
            string tableName = sig.Inf["TableName"];

            if (!Outs.ContainsKey(tableName))
            {
                Outs.Add(tableName, new DicI <LogikaOut>());
            }
            var ob = new LogikaOut(this);

            Outs[tableName].Add(id, ob);
            return(OutsId.Add(id, ob));
        }
示例#20
0
        //Задать максимальный уровень
        //И сразу загрузить список полей из таблицы в Fields
        public void AddLevel(int level)
        {
            var tname = TablName(level);
            var dicn  = new DicI <TablField>();
            var dic   = new DicS <TablField>();
            var t     = _db.Database.TableDefs[tname];
            int i     = 0;

            foreach (Field f in t.Fields)
            {
                if (f.Name != "Id" && f.Name != "ParentId" && f.Name != "Num" && f.Name != "Code")
                {
                    var tf = new TablField(f.Name, i, f.Type.ToDataType());
                    dic.Add(f.Name, tf);
                    dicn.Add(i++, tf);
                }
            }
            Fields.Add(level, dic);
            FieldsNums.Add(level, dicn);
        }
示例#21
0
 //Чтение списка колонок
 private void ReadColumnsList()
 {
     try
     {
         _columnsParams.Clear();
         _columnsVed.Clear();
         using (var rec = new RecDao(_project.File, "SELECT * FROM VedColumns " + (_allTasks ? "" : ("WHERE Task='" + _task + "'")) + " ORDER BY ColumnNum"))
         {
             while (rec.Read())
             {
                 var col = new VedColumn(rec);
                 _columns.Add(col);
                 if (col.SourceType == ColumnSourceType.ParamChar ||
                     col.SourceType == ColumnSourceType.SignalChar ||
                     col.SourceType == ColumnSourceType.ResultValue)
                 {
                     _columnsParams.Add(col.Code, col);
                 }
                 if ((col.SourceType == ColumnSourceType.ParamValue ||
                      col.SourceType == ColumnSourceType.SubValue) &&
                     (col.LinVedView != VedView.None || col.GroupVedView != VedView.None))
                 {
                     _columnsVed.Add(col.Code, col);
                 }
             }
             if (!_task.IsEmpty())
             {
                 using (var rect = new RecDao(rec.DaoDb, "SELECT Tasks.TaskDescription, Tasks.TaskTag FROM Tasks WHERE Task='" + _task + "'"))
                     if (rect.HasRows())
                     {
                         _taskDescription = rect.GetString("TaskDescription");
                         _taskTag         = rect.GetString("TaskTag");
                     }
             }
         }
     }
     catch (Exception ex)
     {
         AddError("Ошибка загрузки списка колонок", ex, "", _project.Code);
     }
 }
示例#22
0
        //Добавить сигнал
        public ProviderSignal AddSignal(string signalInf, string code, DataType dataType, int idInClone = 0)
        {
            var dic   = signalInf.ToPropertyDicS();
            var proj  = dic["Project"];
            var ocode = dic["CodeObject"];
            var itype = dic["IntervalType"].ToIntervalType();
            var sp    = dic["SuperProcessType"].ToSuperProcess();

            if (!_intervalTypes.Contains(itype))
            {
                _intervalTypes.Add(itype);
            }
            if (!_signalsDic.ContainsKey(proj))
            {
                _signalsDic.Add(proj, new DicS <Dictionary <IntervalType, ProviderSignal> >());
                _reportParams.Add(proj, new DicS <ArchiveReportParam>());
            }
            var projdic = _signalsDic[proj];
            var repdic  = _reportParams[proj];

            if (!projdic.ContainsKey(ocode))
            {
                projdic.Add(ocode, new Dictionary <IntervalType, ProviderSignal>());
                repdic.Add(ocode, new ArchiveReportParam(ocode, proj, dataType, sp, CalcParamType.Class, new List <IntervalType>()));
            }
            if (projdic[ocode].ContainsKey(itype))
            {
                return(projdic[ocode][itype]);
            }
            var sig = new ProviderSignal(signalInf, code, dataType, this, idInClone)
            {
                Value = new SingleValue(SingleType.List)
            };

            projdic[ocode].Add(itype, sig);
            ProviderSignals.Add(code, sig);
            repdic[ocode].Queries.Add(itype, new ArchiveQueryValues());
            return(sig);
        }
示例#23
0
        //Добавление объекта
        protected override ProviderOut AddOut(ProviderSignal sig)
        {
            var  table = sig.Inf.Get("Table");
            bool isErr = sig.Inf.Get("IsErrorObject") == "True";
            var  code  = sig.Inf.Get("ObjectCode");

            switch (table)
            {
            case "MomValues":
                return(Outs.ContainsKey(code)
                        ? Outs[code]
                        : Outs.Add(code, new FictiveOut(this, isErr)));

            case "MomValues2":
                return(Outs2.ContainsKey(code)
                        ? Outs2[code]
                        : Outs2.Add(code, new FictiveSmallOut(this)));

            case "MomOperator":
                return(OperatorOut ?? (OperatorOut = new FictiveOperatorOut(this)));
            }
            return(null);
        }
示例#24
0
        //Добавить соединение в поток
        public ProviderConnect AddConnect(string code)
        {
            var con = Connects[code];

            if (!Connects.ContainsKey(code))
            {
                var scon = Project.SchemeConnects[code];
                con = ProvidersFactory.CreateConnect(Logger, scon.Type, scon.Code, scon.Complect, Project.Code);
                con = Connects.Add(code, con);
                if (con.Type == ProviderType.Source)
                {
                    _sources.Add(con.Code, (SourceConnect)con);
                }
                if (con.Type == ProviderType.Receiver)
                {
                    _receivers.Add(con.Code, (ReceiverConnect)con);
                }
                if (!scon.ProviderCode.IsEmpty() && !scon.ProviderInf.IsEmpty())
                {
                    con.JoinProvider(ProvidersFactory.CreateProvider(Logger, scon.ProviderCode, scon.ProviderInf, Project.Code));
                }
            }
            return(con);
        }
示例#25
0
 //Добавляет объект, содержащий один сигнал
 protected override ProviderOut AddOut(ProviderSignal sig)
 {
     return(Objects.Add(sig.Code, new CloneOut(this)));
 }
示例#26
0
        private void butOK_Click(object sender, EventArgs e)
        {
            using (_book.StartAtom("Сохранение настроек"))
            {
                _book.AddEvent("Сохранение настроек отчета");
                if (CodeReport.Text.IsEmpty())
                {
                    Different.MessageError("Код отчета должен быть заполнен");
                    return;
                }
                int  res;
                bool er = (!MonthLength.Text.IsEmpty() && (!int.TryParse(MonthLength.Text, out res) || res < 0));
                er |= (!DayLength.Text.IsEmpty() && (!int.TryParse(DayLength.Text, out res) || res < 0));
                er |= (!HourLength.Text.IsEmpty() && (!int.TryParse(HourLength.Text, out res) || res < 0));
                er |= (!MinuteLength.Text.IsEmpty() && (!int.TryParse(MinuteLength.Text, out res) || res < 0));
                er |= (!DayStart.Text.IsEmpty() && (!int.TryParse(DayStart.Text, out res) || res < 0));
                er |= (!HourStart.Text.IsEmpty() && (!int.TryParse(HourStart.Text, out res) || res < 0));
                er |= (!MinuteLength.Text.IsEmpty() && (!int.TryParse(MinuteLength.Text, out res) || res < 0));
                if (er)
                {
                    Different.MessageError("Указана недопустимая длительность или начало интеравала");
                    return;
                }

                var  sys        = _book.SysPage;
                bool isInternal = false;
                try
                {
                    sys.PutValue("Report", CodeReport.Text);
                    sys.PutValue("ReportName", NameReport.Text);
                    sys.PutValue("ReportDescription", DescriptionReport.Text);
                    sys.PutControl(MonthLength);
                    sys.PutControl(DayLength);
                    sys.PutControl(HourLength);
                    sys.PutControl(MinuteLength);
                    sys.PutControl(DayStart);
                    sys.PutControl(HourStart);
                    sys.PutControl(MinuteStart);
                    sys.PutValue("DifferentLength", radioDifferent.Checked ? "True" : (radioLess.Checked ? "Less" : "Equals"));
                    if (radioNow.Checked)
                    {
                        sys.PutValue("DefaultPeriod", "Now");
                    }
                    if (radioPrevious.Checked)
                    {
                        sys.PutValue("DefaultPeriod", "Previous");
                    }
                    sys.PutValue("DifferentBegin", DifferentBegin.Checked);
                    sys.PutValue("DefaultCalcName", CalcName.Text);
                    sys.PutValue("AllowProjectsRepetitions", AllowProjectsRepetitions.Checked);

                    var list = new List <ReportProjectSetup>();
                    foreach (DataGridViewRow r in Projects.Rows)
                    {
                        if (!r.IsNewRow)
                        {
                            try
                            {
                                var cmode = r.Get("ProjectCalcMode").ToCalcModeType();
                                isInternal |= cmode == CalcModeType.Internal;
                                list.Add(new ReportProjectSetup(r.Get("Project"), AllowProjectsRepetitions.Checked ? r.Get("ProjectCode2") : null, cmode));
                            }
                            catch { }
                        }
                    }
                    sys.PutProjects(list);
                }
                catch (Exception ex)
                {
                    GeneralRep.ShowError("Текущий файл не является файлом отчета InfoTask или был поврежден", ex);
                }

                try { tabMain.Select(); } catch {}
                _codes.Clear();
                _infs.Clear();
                foreach (DataGridViewRow row in Providers.Rows)
                {
                    string name = row.Get("ProviderName");
                    _codes.Add(name, row.Get("ProviderCode"));
                    _infs.Add(name, row.Get("ProviderInf"));
                }

                int tid;
                if (!int.TryParse(ThreadId.Text, out tid))
                {
                    tid = 0;
                }
                if (isInternal)
                {
                    try
                    {
                        _book.AddEvent("Сохранение настроек в ControllerData");
                        using (var db = new DaoDb(General.ControllerFile))
                        {
                            using (var rec = new RecDao(db, "SELECT * FROM Threads WHERE ThreadId=" + tid))
                            {
                                if (!rec.HasRows())
                                {
                                    rec.AddNew();
                                }
                                rec.Put("ApplicationType", "Excel");
                                rec.Put("IsImit", IsImit.Checked);
                                rec.Put("ImitMode", ImitMode.Text);
                                tid = rec.GetInt("ThreadId");
                            }
                            db.Execute("DELETE * FROM Providers WHERE ThreadId=" + tid);
                            db.Execute("DELETE * FROM Projects WHERE ThreadId=" + tid);
                            using (var rec = new RecDao(db, "Projects"))
                                using (var recc = new RecDao(db, "Providers"))
                                {
                                    foreach (DataGridViewRow row in Projects.Rows)
                                    {
                                        if (!row.IsNewRow && row.Get("ProjectCalcMode").ToCalcModeType() == CalcModeType.Internal)
                                        {
                                            rec.AddNew();
                                            rec.Put("ThreadId", tid);
                                            rec.PutFromDataGrid("Project", row);
                                            rec.PutFromDataGrid("ProjectFile", row);
                                        }
                                    }
                                    foreach (DataGridViewRow row in Providers.Rows)
                                    {
                                        if (row.Get("TypeProvider") != "Архив" || row.Get("ProviderName") == "CalcArchive" || (row.Get("ProviderName") == "Report_Archive" && UseOneArchive.Checked))
                                        {
                                            recc.AddNew();
                                            recc.Put("ThreadId", tid);
                                            recc.PutFromDataGrid("ProviderType", row, "TypeProvider");
                                            recc.PutFromDataGrid("ProviderCode", row);
                                            if (row.Get("ProviderName") != "Report_Archive")
                                            {
                                                recc.PutFromDataGrid("ProviderName", row);
                                            }
                                            else
                                            {
                                                recc.Put("ProviderName", "CalcArchive");
                                            }
                                            recc.PutFromDataGrid("ProviderInf", row);
                                            recc.Update();
                                        }
                                    }
                                }
                        }
                    }
                    catch (Exception ex)
                    {
                        GeneralRep.ShowError("Неправильный файл ControllerData.accdb", ex);
                        return;
                    }
                }

                _book.AddEvent("Сохранение настроек в ReporterData");
                try //Настройки отчета в ReporterData
                {
                    using (var db = new DaoDb(General.ReporterFile))
                    {
                        using (var rec = new RecDao(db, "SELECT * FROM Reports WHERE Report = '" + CodeReport.Text + "'"))
                        {
                            if (!rec.HasRows())
                            {
                                rec.AddNew();
                            }
                            rec.Put("Report", CodeReport.Text);
                            rec.Put("ReportName", NameReport.Text);
                            rec.Put("ReportDescription", DescriptionReport.Text);
                            rec.Put("ReportFile", GeneralRep.Application.ActiveWorkbook.FullName);
                            rec.Put("ThreadId", isInternal ? tid : 0);
                            rec.Put("UseOneArchive", UseOneArchive.Checked);
                            rec.Put("CodeArchive", _codes["Report_Archive"]);
                            rec.Put("InfArchive", _infs["Report_Archive"]);
                            string s = "FormTo=" + (FormToTemplate.Checked ? "Template" : (FormToDir.Checked ? "Dir" : "File")) + ";";
                            s += "ResultDir=" + ResultDir.Text + ";";
                            s += "ResultFileName=" + ResultFileName.Text + ";";
                            s += "ResultFile=" + ResultFile.Text + ";";

                            s += "AddDateToName=" + (AddDateToName.Checked ? "True" : "False") + ";";
                            var df = DateNameFormat.Text;
                            if (AddDateToName.Checked && (df.Contains(":") || df.Contains(@"\") || df.Contains(@"/") || df.Contains("[") || df.Contains("]") || df.Contains("*")))
                            {
                                Different.MessageError(@"Указан недопустимый формат даты для имени файла или листа. Имя не должно содержать символов / \ : * [ ]");
                                return;
                            }
                            s += "DateNameFormat=" + df + ";";

                            s += "AddBeginToName=" + (AddBeginToName.Checked ? "True" : "False") + ";";
                            df = BeginNameFormat.Text;
                            if (AddBeginToName.Checked && (df.Contains(":") || df.Contains(@"\") || df.Contains(@"/") || df.Contains("[") || df.Contains("]") || df.Contains("*")))
                            {
                                Different.MessageError(@"Указан недопустимый формат даты для имени файла или листа. Имя не должно содержать символов / \ : * [ ]");
                                return;
                            }
                            s += "BeginNameFormat=" + df + ";";

                            s += "AddEndToName=" + (AddEndToName.Checked ? "True" : "False") + ";";
                            df = EndNameFormat.Text;
                            if (AddEndToName.Checked && (df.Contains(":") || df.Contains(@"\") || df.Contains(@"/") || df.Contains("[") || df.Contains("]") || df.Contains("*")))
                            {
                                Different.MessageError(@"Указан недопустимый формат даты для имени файла или листа. Имя не должно содержать символов / \ : * [ ]");
                                return;
                            }
                            s += "EndNameFormat=" + df + ";";

                            s += "AddCalcNameToName=" + (AddCalcNameToName.Checked ? "True" : "False") + ";";
                            s += "AddSheetToName=" + (AddSheetToName.Checked ? "True" : "False") + ";";
                            s += "SetFocusToFormed=" + (SetFocusToFormed.Checked ? "True" : "False") + ";";
                            rec.Put("FormInf", s);
                            rec.Put("ServerReport", ServerReport.Text);
                            if (!ServerReport.Text.IsEmpty())
                            {
                                var file = new FileInfo(ServerReport.Text);
                                if (!file.Exists || file.Extension != ".xlsx")
                                {
                                    Different.MessageError("Указанный файл контрольного экземпляра не существует или не является файлом Excel, " + ServerReport.Text);
                                }
                                else if (ServerReport.Text == _book.Workbook.FullName)
                                {
                                    Different.MessageError("Файл контрольного бланка расчета не должен совпадать с файлом бланка отчета, " + ServerReport.Text);
                                }
                            }

                            int rid = rec.GetInt("ReportId");
                            rec.Update();
                            db.Execute("DELETE * FROM Projects WHERE ReportId=" + rid);
                            using (var recp = new RecDao(db, "Projects"))
                                foreach (DataGridViewRow r  in Projects.Rows)
                                {
                                    if (!r.IsNewRow)
                                    {
                                        recp.AddNew();
                                        recp.Put("ReportId", rid);
                                        recp.PutFromDataGrid("Project", r);
                                        if (AllowProjectsRepetitions.Checked)
                                        {
                                            recp.PutFromDataGrid("ProjectCode2", r);
                                        }
                                        recp.PutFromDataGrid("ProjectName", r);
                                        recp.PutFromDataGrid("ProjectFile", r);
                                        if (UseOneArchive.Checked)
                                        {
                                            recp.Put("CodeArchive", _codes["Report_Archive"]);
                                            recp.Put("InfArchive", _infs["Report_Archive"]);
                                        }
                                        else if (r.Get("ProjectCalcMode").ToCalcModeType() == CalcModeType.Internal)
                                        {
                                            recp.Put("CodeArchive", _codes["CalcArchive"]);
                                            recp.Put("InfArchive", _infs["CalcArchive"]);
                                        }
                                        else
                                        {
                                            var proj = r.Get("Project");
                                            if (AllowProjectsRepetitions.Checked && !r.Get("ProjectCode2").IsEmpty())
                                            {
                                                proj = r.Get("ProjectCode2");
                                            }
                                            proj += "_Archive";
                                            recp.Put("CodeArchive", _codes[proj]);
                                            recp.Put("InfArchive", _infs[proj]);
                                        }
                                    }
                                }
                        }
                    }
                }
                catch (Exception ex)
                {
                    GeneralRep.ShowError("Неправильный файл ReporterData.accdb", ex);
                }

                _book.ClearReportDataFromMemory();
                CheckProviders();
                Close();
            }
        }
示例#27
0
        //Проверка таблицы сигналов
        public string CheckSignals(bool onlyInUse = false)
        {
            StartAtom(Atom.CheckSignals);
            CountsToZero();
            var objectsId = new DicI <ObjectSignal>();
            var signals   = new DicS <Signal>();

            _objects.Clear();
            try
            {
                if (State == State.Closed)
                {
                    AddError("Копилятор уже был закрыт");
                }
                else if (State == State.Empty)
                {
                    AddError("Проект не загружен");
                }
                else
                {
                    //using (var reco = new RecDao(_projectFile, "SELECT CodeObject, NameObject, TagObject, ObjectId, CommName, ErrMess FROM Objects ORDER BY ObjectId"))
                    using (var reco = new RecDao(_objectsFile, "SELECT CodeObject, NameObject, TagObject, ObjectId, CommName, ErrMess FROM Objects ORDER BY ObjectId")) //ab\
                    {
                        Procent = 10;
                        while (reco.Read())
                        {
                            var ob = new ObjectSignal(reco, true);
                            objectsId.Add(ob.Id, ob);
                            if (!_objects.ContainsKey(ob.Code))
                            {
                                _objects.Add(ob.Code, ob);
                            }
                            else
                            {
                                ob.ErrMess += "Повтор кода объекта (" + ob.Code + "); ";
                                reco.Put("ErrMess", ob.ErrMess);
                                _objects[ob.Code].ErrMess += "Повтор кода объекта (" + ob.Code + "); ";
                            }
                        }
                        Procent = 25;
                        using (var recs = new RecDao(reco.DaoDb, "SELECT ObjectId, Signals.Default, CodeSignal, NameSignal, Units, Signals.DataType, ConstValue, Signals.SourceName, Signals.ReceiverName, Signals.Inf, Signals.FullCode AS FullCode, Signals.ErrMess" + (!onlyInUse ? "" : ", SignalsInUse.FullCode AS FullCodeInUse")
                                                     + " FROM Signals" + (!onlyInUse ? "" : " LEFT JOIN SignalsInUse ON Signals.FullCode=SignalsInUse.FullCode ")))
                        {
                            Procent = 35;
                            while (recs.Read())
                            {
                                var sig = new Signal(recs, objectsId, true);
                                if (onlyInUse)
                                {
                                    sig.InUse = !recs.GetString("FullCodeInUse").IsEmpty();
                                }
                                objectsId[sig.ObjectId].InUse |= sig.InUse;
                                if (signals.ContainsKey(sig.FullCode))
                                {
                                    sig.ErrMess += "Повтор полного кода сигнала (" + sig.FullCode + "); ";
                                }
                                else
                                {
                                    signals.Add(sig.FullCode, sig);
                                }
                                if (sig.ErrMess != "")
                                {
                                    recs.Put("ErrMess", sig.ErrMess, true);
                                    if (sig.InUse || !onlyInUse)
                                    {
                                        SignalsErrorsCount++;
                                    }
                                    objectsId[sig.ObjectId].ErrorInSignals = true;
                                }
                            }
                        }
                        Procent = 80;
                        reco.MoveFirst();
                        while (!reco.EOF)
                        {
                            var ob = objectsId[reco.GetInt("ObjectId")];
                            if (ob.DefalutsCount == 0)
                            {
                                ob.ErrMess += "Объект не содержит сигналов по умолчанию; ";
                            }
                            if (ob.DefalutsCount >= 2)
                            {
                                ob.ErrMess += "Объект содержит более одного сигнала по умолчанию; ";
                            }
                            if (ob.ErrorInSignals)
                            {
                                ob.ErrMess += "Ошибки в сигналах; ";
                            }
                            if (ob.ErrMess != "")
                            {
                                reco.Put("ErrMess", ob.ErrMess);
                                if (!onlyInUse || ob.InUse)
                                {
                                    ObjectsErrorsCount++;
                                }
                            }
                            reco.MoveNext();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                return(ex.MessageError("Ошибка при проверке сигналов"));
            }
            return(FinishAtom(State.Project, State.Project, "Проект: " + _code + "; Объектов с ошибками: " + ObjectsErrorsCount + "; Сигналов с ошибками: " + SignalsErrorsCount));
        }
示例#28
0
        //Получает в память список актуальный список параметров из файла данных, проекта и архива и обновляет список параметров в файле данных
        //Возвращает true, если параметры были обновлены
        public bool UpdateParams()
        {
            if (DataChangeTime >= ProjectChangeTime && DataChangeTime >= ArchiveChangeTime)
            {
                return(false);
            }
            var dataParams    = new DicS <ArchiveParam>();
            var projectParams = new DicS <ArchiveParam>();
            var archiveParams = new DicS <ArchiveParam>();

            try
            {
                if (!File.IsEmpty())
                {
                    Book.AddEvent("Получение списка параметров из проекта", CodeFinal);
                    const string stSql = "SELECT CalcParamsArchive.FullCode As Code, CalcParams.Code AS CodeParam, CalcSubParams.Code AS CodeSubParam, CalcParams.Name, CalcSubParams.Name AS SubName, " +
                                         "CalcParamsArchive.DataType, CalcParams.CalcParamType, CalcParamsArchive.SuperProcessType, CalcParams.Comment, CalcSubParams.Comment AS SubComment, " +
                                         "CalcParamsArchive.Units, CalcParams.Task, CalcParamsArchive.Min, CalcParamsArchive.Max, CalcParamsArchive.DecPlaces, CalcParams.Tag " +
                                         "FROM CalcParams INNER JOIN (CalcSubParams RIGHT JOIN CalcParamsArchive ON CalcSubParams.CalcParamId = CalcParamsArchive.CalcSubParamId) ON CalcParams.CalcParamId = CalcParamsArchive.CalcParamId;";
                    using (var rec = new ReaderAdo(File, stSql))
                        while (rec.Read())
                        {
                            var ap = new ArchiveParam(rec);
                            projectParams.Add(ap.FullCode, ap);
                        }

                    if (CalcMode == CalcModeType.Internal)
                    {
                        Book.AddEvent("Получение параметров ручного ввода из проекта", CodeFinal);
                        using (var rec = new ReaderAdo(File, "SELECT CalcParams.Code, CalcParams.Code AS CodeParam, CalcParams.Name, CalcParams.ResultType AS DataType, CalcParams.Units, CalcParams.Task, CalcParams.CalcParamType, CalcParams.Comment, CalcParams.SuperProcessType, CalcParams.Min, CalcParams.Max, CalcParams.DecPlaces, CalcParams.Tag " +
                                                       "FROM CalcParams WHERE CalcParamType Is Not Null"))
                            while (rec.Read())
                            {
                                var ap = new ArchiveParam(rec);
                                projectParams.Add(ap.FullCode, ap);
                            }
                    }
                }
                if (Archive != null && CalcMode != CalcModeType.Internal)
                {
                    Book.AddEvent("Получение списка параметров из архива", CodeFinal);
                    foreach (var ap in Archive.ReadParams(Code, ReportType.Calc))
                    {
                        archiveParams.Add(ap.FullCode, ap);
                    }
                }

                var dic1 = ProjectChangeTime >= ArchiveChangeTime ? projectParams : archiveParams;
                var dic2 = ProjectChangeTime < ArchiveChangeTime ? projectParams : archiveParams;

                Book.AddEvent("Обновление параметров в файле данных", CodeFinal);
                using (var rec = new RecDao(Book.DataFile, "SELECT * FROM CalcParams WHERE Project='" + CodeFinal + "'"))
                {
                    while (rec.Read())
                    {
                        var ap = new ArchiveParam(rec);
                        dataParams.Add(ap.FullCode, ap);
                        if (!dic1.ContainsKey(ap.FullCode) && !dic2.ContainsKey(ap.FullCode))
                        {
                            rec.Put("SysField", "Del");
                        }
                        else
                        {
                            rec.Put("SysField", "");
                            if (dic1.ContainsKey(ap.FullCode))
                            {
                                dic1[ap.FullCode].ToRecordset(rec, CodeFinal);
                            }
                            else
                            {
                                dic2[ap.FullCode].ToRecordset(rec, CodeFinal);
                            }
                            rec.Put("FromProject", projectParams.ContainsKey(ap.FullCode));
                            rec.Put("FromArchive", archiveParams.ContainsKey(ap.FullCode));
                        }
                    }

                    Book.AddEvent("Добавление недостающих параметров в файл данных", CodeFinal);
                    foreach (var ap in dic1.Values)
                    {
                        if (!dataParams.ContainsKey(ap.FullCode))
                        {
                            dataParams.Add(ap.FullCode, ap);
                            ap.ToRecordset(rec, CodeFinal, true);
                            rec.Put("FromProject", projectParams.ContainsKey(ap.FullCode));
                            rec.Put("FromArchive", archiveParams.ContainsKey(ap.FullCode));
                        }
                    }
                    foreach (var ap in dic2.Values)
                    {
                        if (!dataParams.ContainsKey(ap.FullCode))
                        {
                            ap.ToRecordset(rec, CodeFinal, true);
                            rec.Put("FromProject", projectParams.ContainsKey(ap.FullCode));
                            rec.Put("FromArchive", archiveParams.ContainsKey(ap.FullCode));
                        }
                    }

                    using (var rep = new RecDao(rec.DaoDb, "SELECT LastChange FROM Projects WHERE (ProjectCode2='" + CodeFinal + "') OR (ProjectCode2 Is Null AND Project = '" + CodeFinal + "')"))
                        rep.Put("LastChange", ProjectChangeTime >= ArchiveChangeTime ? ProjectChangeTime : ArchiveChangeTime);
                }
            }
            catch (Exception ex)
            {
                Book.AddError("Ошибка при обновлении спиcка параметров", ex, CodeFinal);
            }
            return(true);
        }
示例#29
0
        //Обновление списка проектов в файле данных отчета
        private IEnumerable <ReportProjectForData> MakeProjectsList()
        {
            AddEvent("Обновление списка проектов");
            var plist = new DicS <ReportProjectForData>();

            try
            {
                using (var rec = new RecDao(General.ReporterFile, "SELECT Reports.Report, Projects.* FROM Reports INNER JOIN Projects ON Reports.ReportId = Projects.ReportId WHERE Report='" + Code + "'"))
                    while (rec.Read())
                    {
                        var p = new ReportProjectForData(this, rec);
                        plist.Add(p.CodeFinal, p);
                    }

                foreach (var pr in SysPage.GetProjects().Values)
                {
                    if (plist.ContainsKey(pr.CodeFinal))
                    {
                        plist[pr.CodeFinal].CalcMode = pr.CalcMode;
                    }
                }
                foreach (var pr in plist.Values)
                {
                    pr.GetChangeTime();
                }
                using (var db = new DaoDb(DataFile))
                {
                    var dic = new SetS();
                    using (var rec = new RecDao(db, "SELECT * FROM Projects"))
                    {
                        while (rec.Read())
                        {
                            var code = rec.GetString("Project");
                            if (code != "Сохранение" && code != "Системные")
                            {
                                if (!plist.ContainsKey(code))
                                {
                                    rec.Put("SysField", "Del");
                                }
                                else
                                {
                                    dic.Add(code);
                                    rec.Put("SysField", "");
                                    plist[code].DataChangeTime = rec.GetTime("LastChange");
                                    plist[code].ToRecordset(rec, false);
                                }
                            }
                        }
                        foreach (var p in plist.Values)
                        {
                            if (!dic.Contains(p.Code))
                            {
                                p.ToRecordset(rec, true);
                            }
                        }
                    }
                    db.Execute("DELETE Cells.* FROM Projects INNER JOIN (CalcParams INNER JOIN Cells ON CalcParams.ParamId = Cells.ParamId) ON Projects.Project = CalcParams.Project WHERE Projects.SysField='Del';");
                    db.Execute("DELETE CalcParams.* FROM Projects INNER JOIN CalcParams ON Projects.Project = CalcParams.Project WHERE Projects.SysField='Del';");
                    db.Execute("DELETE * FROM Projects WHERE Projects.SysField='Del'");
                }
            }
            catch (Exception ex)
            {
                AddError("Ошибка при работе с ReporterData, архивом или файлом данных отчета", ex);
            }
            return(plist.Values);
        }
示例#30
0
 //Запись значений ручного ввода, beg - начало периода расчета
 public void WriteHandInput(DateTime beg, DateTime en)
 {
     if (IsHandInput)
     {
         try
         {
             Book.AddEvent("Сохрание значений ручного ввода из ячеек", CodeFinal);
             var pars = new DicS <ReportHandParam>();
             foreach (var param in Params.Values)
             {
                 if (param.HandInputCell != null)
                 {
                     pars.Add(param.FullCode,
                              new ReportHandParam(param, GeneralRep.ActiveBook.ValueFromCell(param.HandInputCell)));
                 }
             }
             using (var db = new DaoDb(_handInputFile))
             {
                 using (
                     var rec = new RecDao(db,
                                          "SELECT Objects.CodeObject, MomentsValues.Time FROM (Objects INNER JOIN Signals ON Objects.ObjectId = Signals.ObjectId) INNER JOIN MomentsValues ON Signals.SignalId = MomentsValues.SignalId " +
                                          "WHERE (Time >= " + beg.ToAccessString() + ") AND (Time < " + en.ToAccessString() + ")"))
                     while (rec.Read())
                     {
                         if (pars.ContainsKey(rec.GetString("CodeObject")))
                         {
                             rec.Put("Time", Different.MaxDate);
                         }
                     }
                 using (
                     var rec = new RecDao(db,
                                          "SELECT Objects.CodeObject, MomentsStrValues.Time FROM (Objects INNER JOIN Signals ON Objects.ObjectId = Signals.ObjectId) INNER JOIN MomentsStrValues ON Signals.SignalId = MomentsStrValues.SignalId " +
                                          "WHERE (Time >= " + beg.ToAccessString() + ") AND (Time < " + en.ToAccessString() + ")"))
                     while (rec.Read())
                     {
                         if (pars.ContainsKey(rec.GetString("CodeObject")))
                         {
                             rec.Put("Time", Different.MaxDate);
                         }
                     }
                 db.Execute("DELETE * FROM MomentsValues WHERE Time=" + Different.MaxDate.ToAccessString());
                 db.Execute("DELETE * FROM MomentsStrValues WHERE Time=" + Different.MaxDate.ToAccessString());
                 using (
                     var rec = new RecDao(db,
                                          "SELECT Objects.CodeObject, Objects.ObjectId, Signals.CodeSignal, Signals.SignalId FROM Objects INNER JOIN Signals ON Objects.ObjectId = Signals.SignalId")
                     )
                     while (rec.Read())
                     {
                         var code = rec.GetString("CodeObject");
                         if (pars.ContainsKey(code))
                         {
                             pars[code].ObjectId = rec.GetInt("ObjectId");
                             pars[code].SignalId = rec.GetInt("SignalId");
                         }
                     }
                 using (var reco = new RecDao(db, "Objects"))
                     using (var recs = new RecDao(db, "Signals"))
                         foreach (var param in pars.Values)
                         {
                             if (param.ObjectId == 0)
                             {
                                 var ap  = param.ReportParam.ArchiveParam;
                                 var par = ap.FirstParam;
                                 reco.AddNew();
                                 reco.Put("CodeObject", par.Code);
                                 reco.Put("NameObject", par.Name);
                                 param.ObjectId = reco.GetInt("ObjectId");
                                 reco.Update();
                                 recs.AddNew();
                                 recs.Put("ObjectId", param.ObjectId);
                                 recs.Put("CodeSignal", "Руч");
                                 recs.Put("NameSignal", "Ручной ввод");
                                 recs.Put("FullCode", par.Code + ".Руч");
                                 recs.Put("Default", true);
                                 recs.Put("DataType", ap.DataType.ToRussian());
                                 recs.Put("Units", ap.Units);
                                 recs.Put("Min", ap.Min);
                                 recs.Put("Max", ap.Max);
                                 recs.Put("Active", true);
                                 param.SignalId = recs.GetInt("SignalId");
                                 recs.Update();
                             }
                         }
                 using (var rec = new RecDao(db, "MomentsValues"))
                     using (var recs = new RecDao(db, "MomentsStrValues"))
                         foreach (var param in pars.Values)
                         {
                             if (!param.StringValue.IsEmpty())
                             {
                                 var dt = param.ReportParam.ArchiveParam.DataType;
                                 var r  = dt.LessOrEquals(DataType.Real) ? rec : recs;
                                 r.AddNew();
                                 r.Put("SignalId", param.SignalId);
                                 r.Put("Time", beg);
                                 if (dt.LessOrEquals(DataType.Real))
                                 {
                                     var d = param.StringValue.ToDouble();
                                     if (!double.IsNaN(d))
                                     {
                                         r.Put("Value", d);
                                     }
                                     else
                                     {
                                         r.Put("Value", 0);
                                         r.Put("Nd", 1);
                                     }
                                 }
                                 else if (dt == DataType.String)
                                 {
                                     r.Put("StrValue", param.StringValue);
                                 }
                                 else if (dt == DataType.Time)
                                 {
                                     var t = param.StringValue.ToDateTime();
                                     r.Put("TimeValue", t);
                                     if (t == Different.MinDate)
                                     {
                                         r.Put("Nd", 1);
                                     }
                                 }
                             }
                         }
                 using (var sys = new SysTabl(db, false))
                 {
                     var d = sys.Value("BeginInterval").ToDateTime();
                     if (d == Different.MinDate || d > beg)
                     {
                         sys.PutValue("BeginInterval", beg.ToString());
                     }
                     d = sys.Value("EndInterval").ToDateTime();
                     if (d < beg)
                     {
                         sys.PutValue("EndInterval", beg.ToString());
                     }
                 }
             }
         }
         catch (Exception ex)
         {
             Book.AddError("Ошибка при записи ручного ввода", ex);
         }
     }
 }