//Запись в SysTabl ведомости private void WriteSysTabl() { using (var sys = new SysTabl(_vedDb)) { sys.PutSubValue("ProjectOptions", "Project", _project.Code); sys.PutSubValue("ProjectOptions", "ProjectName", _project.Name); sys.PutSubValue("ProjectOptions", "ProjectDescription", _project.Description); sys.PutSubValue("ProjectOptions", "ProjectFile", _project.File); sys.PutSubValue("TaskOptions", "Task", _task); sys.PutSubValue("TaskOptions", "TaskDescription", _taskDescription); sys.PutSubValue("VedOptions", "VedName", _task.IsEmpty() ? _project.Name : _task); sys.PutSubValue("VedOptions", "VedDescription", _task.IsEmpty() ? _project.Description : _taskDescription); sys.PutSubValue("VedOptions", "PeriodBegin", _project.ThreadCalc.PeriodBegin.ToString()); sys.PutSubValue("VedOptions", "PeriodEnd", _project.ThreadCalc.PeriodEnd.ToString()); sys.PutSubValue("VedOptions", "CreationTime", DateTime.Now.ToString()); string tag = _project.VedTag; if (!tag.IsEmpty() && !tag.EndsWith(";")) { tag += ";"; } sys.PutTag("VedTag", tag + _taskTag); } }
//Открытие соединения protected override bool Connect() { using (var sys = new SysTabl(CommDataFile)) { _mainArchive.SuccessTime = sys.SubValue("SourceInfo", "MainArchiveSuccessTime").ToDateTime(); _reserveArchive.SuccessTime = sys.SubValue("SourceInfo", "ReserveArchiveSuccessTime").ToDateTime(); } var archives = new SimaticArchive[2]; int b = _reserveArchive.SuccessTime > _mainArchive.SuccessTime ? 0 : 1; archives[b] = _reserveArchive; archives[1 - b] = _mainArchive; for (int iter = 1; iter <= 2; iter++) { if (IsConnected) { Disconnect(); } foreach (var ar in archives) { Logger.AddEvent((iter == 1 ? "Соединение" : "Повторное соединение") + " с архивом", ar.IsReserve ? "Резервный" : "Основной"); var con = ar.Connnect(); if (con != null && con.State == ConnectionState.Open) { _conn = con; SysTabl.PutSubValueS(CommDataFile, "SourceInfo", (ar.IsReserve ? "Reserve" : "Main") + "ArchiveSuccessTime", DateTime.Now.ToString()); return(IsConnected = true); } } Thread.Sleep(30); } Logger.AddError("Не удалось соединиться ни с основным, не с резервным сервером архива"); return(IsConnected = false); }
private void Window_Loaded(object sender, RoutedEventArgs e) { using (var rec = new RecDao(Different.GetInfoTaskDir() + @"General\Config.accdb", "SELECT SysSubTabl.SubParamRowSource FROM SysTabl INNER JOIN SysSubTabl ON SysTabl.ParamId = SysSubTabl.ParamId " + "WHERE ((SysTabl.ParamValue='Приемник') AND (SysSubTabl.SubParamName='OPCServerName'));")) while (rec.Read()) { var set = rec.GetString("SubParamRowSource").ToPropertyHashSet(); foreach (var s in set.Values) { if (!OpcServerName.Items.Contains(s)) { OpcServerName.Items.Add(s); } } } OpcServerName.Items.Add("Matrikon.OPC.Simulation.1"); using (var sys = new SysTabl(Different.GetInfoTaskDir() + @"Controller\ControllerData.accdb")) { OpcServerName.Text = sys.SubValue("DebugWriteOPC", "OpcServerName"); Node.Text = sys.SubValue("DebugWriteOPC", "Node"); OpcTag.Text = sys.SubValue("DebugWriteOPC", "OpcTag"); DataType.Text = sys.SubValue("DebugWriteOPC", "DataType"); TagValue.Text = sys.SubValue("DebugWriteOPC", "TagValue"); } }
//Загрузка SysTabl проекта, needCompilation = true - ругается, если проект не скомпилирован public void ReadSysTabl(bool needCompilation) { try { using (var sys = new SysTabl(File)) { Code = sys.SubValue("ProjectInfo", "Project"); Name = sys.SubValue("ProjectInfo", "ProjectName"); Description = sys.SubValue("ProjectInfo", "ProjectDescription"); VedTag = sys.Tag("VedTag"); if (needCompilation) { Interpolation = sys.SubValue("ProjectInfo", "Interpolation").ToInterpolation(); LastChange = DateTime.Parse(sys.SubValue("CompileStatus", "LastTimeCompile")); } IsMoments = sys.SubValue("ArchiveOptions", "IsMoments") == "True"; IsPeriodic = sys.SubValue("ArchiveOptions", "IsPeriodic") == "True"; IsAbsolute = sys.SubValue("ArchiveOptions", "IsAbsolute") == "True"; IsPrevAbs = sys.SubValue("ArchiveOptions", "IsPrevAbs") == "True"; IsLastBase = sys.SubValue("ArchiveOptions", "IsLastBase") == "True"; IsLastHour = sys.SubValue("ArchiveOptions", "IsLastHour") == "True"; IsLastDay = sys.SubValue("ArchiveOptions", "IsLastDay") == "True"; IsManyBase = sys.SubValue("ArchiveOptions", "IsManyBase") == "True"; IsManyHour = sys.SubValue("ArchiveOptions", "IsManyHour") == "True"; IsManyDay = sys.SubValue("ArchiveOptions", "IsManyDay") == "True"; IsManyMoments = sys.SubValue("ArchiveOptions", "IsManyMoments") == "True"; } } catch (Exception ex) { ThreadCalc.AddError("Недопустимые настройки в файле проекта (SysTabl) или проект никогда не копилировался", ex, "Путь=" + File); } }
//Получение времени источника public TimeInterval GetTime() { TimeIntervals.Clear(); TimeInterval t = null; try { if (IsOriginal) { t = new TimeInterval(Different.MinDate.AddYears(1), DateTime.Now); } else { using (var sys = new SysTabl(DatabaseFile, false)) t = new TimeInterval(DateTime.Parse(sys.Value("BeginInterval")), DateTime.Parse(sys.Value("EndInterval"))); } TimeIntervals.Add(t); } catch (Exception ex) { AddError("Ошибка определения диапазона источника", ex); IsConnected = false; } return(t); }
//Загрузка абсолютных значений для редактирования public void LoadAbsolute() { ClearLists(); foreach (var pr in ProjectsList) { using (StartAtom(Atom.LoadAbsolute, 0, 100, "Проект " + pr.Code, pr.Code)) { try { if (SysTabl.SubValueS(pr.File, "ArchiveOptions", "IsAbsolute") == "True") { //Чтение значений из архива var apars = Archive.ReadAbsoluteEdit(pr.Code, false); //Чтение параметров из проекта using (var rec = new ReaderAdo(pr.File, "SELECT CalcParamsArchive.FullCode as Code, CalcParams.Task, CalcParams.Name, CalcSubParams.Name AS SubName, " + "CalcParamsArchive.Units, CalcParamsArchive.DataType, CalcParamsArchive.SuperProcessType, CalcParams.Comment " + "FROM CalcParams INNER JOIN (CalcSubParams RIGHT JOIN CalcParamsArchive ON CalcSubParams.CalcParamId = CalcParamsArchive.CalcSubParamId) ON CalcParams.CalcParamId = CalcParamsArchive.CalcParamId " + "WHERE (CalcParams.CalcOn=True) And (CalcParams.TaskOn=True) And ((CalcSubParams.CalcOn=True) Or (CalcSubParams.CalcOn Is Null)) " + "ORDER BY Task, FullCode;")) while (rec.Read()) { var sp = rec.GetString("SuperProcessType").ToSuperProcess(); if (sp.IsAbsolute()) { var gip = new GridInputParam(pr.Code, rec, true); if (!ProjectsForFilter.Contains(gip.Project)) { ProjectsForFilter.Add(gip.Project); } if (!TasksForFilter.Contains(gip.Task)) { TasksForFilter.Add(gip.Task); } if (!DataTypesForFilter.Contains(gip.DataType)) { DataTypesForFilter.Add(gip.DataType); } if (apars.ContainsKey(gip.Code)) { var hip = apars[gip.Code]; gip.OldValue = hip.OldValue; gip.OldTime = hip.OldTime.ToString(); gip.Value = hip.Value; gip.Time = hip.Time == Different.MinDate ? null : hip.Time.ToString(); } GridInputParams.Add(gip); } } } } catch (Exception ex) { AddError("Ошибка загрузки абсолютных значений", ex); MessageBox.Show("Ошибка загрузки абсолютных значений", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); } } } }
//Загрузить проект projectFile, compileDir - каталог для компиляции public string LoadProject(string projectFile) { StartAtom(Atom.LoadProject, true, projectFile); CountsToZero(); if (State == State.Closed) { AddError("Копилятор уже был закрыт"); } else { try { if (!DaoDb.Check(projectFile, new[] { "CalcParams", "CalcSubParams", "CalcParamsArchive", "Objects", "Signals", "SignalsInUse", "GraficsList", "GraficsValues" })) { AddError("Указан неправильный файл проекта", null, projectFile); } else { using (var db = new DaoDb(projectFile)) { using (var rec = new RecDao(db, "SELECT * FROM Providers WHERE (ProviderCode='HandInputSource') OR (ProviderCode='HandInputSqlSource')")) if (rec.HasRows()) { HandInputSource = rec.GetString("ProviderName"); } using (var sys = new SysTabl(db)) { _code = sys.SubValue("ProjectInfo", "Project"); _name = sys.SubValue("ProjectInfo", "ProjectName"); sys.PutSubValue("ProjectInfo", "HandInputSource", HandInputSource); //ab _objectsFile = sys.Value("ObjectsFile"); if (string.IsNullOrEmpty(_objectsFile)) { _objectsFile = projectFile; } if (_objectsFile != projectFile) { if (!DaoDb.Check(projectFile, new[] { "CalcParams", "CalcSubParams", "CalcParamsArchive", "Objects", "Signals", "SignalsInUse", "GraficsList", "GraficsValues" })) { AddError("В проекте указан неправильный файл списка объектов", null, projectFile); _objectsFile = projectFile; } } //\ab } } _projectFile = projectFile; } } catch (Exception ex) { AddError("Указан неправильный файл проекта", ex, projectFile); } } return(FinishAtom(State.Project, State.Empty, "Проект:" + _code + ", " + _name)); }
//Диапазон источника protected override TimeInterval GetTimeProvider() { if (!Connect()) { return(TimeInterval.CreateDefault()); } using (var sys = new SysTabl(DbFile)) return(new TimeInterval(sys.Value("BeginInterval").ToDateTime(), sys.Value("EndInterval").ToDateTime())); }
private void FormGroupReportWin_FormClosed(object sender, FormClosedEventArgs e) { using (var sys = new SysTabl(General.ReporterFile)) { sys.PutSubValue("FormGroupReports", "BeginPeriod", BeginPeriod.Text); sys.PutSubValue("FormGroupReports", "EndPeriod", EndPeriod.Text); } GeneralRep.CloseForm(ReporterCommand.GroupReports); }
private void ButSetupHistory_Click(object sender, RoutedEventArgs e) { App.MonitorHistory.Inf = App.MonitorHistory.Setup(); SysTabl.PutValueS(General.ControllerFile, "MonitorHistoryProps", App.MonitorHistory.Inf); foreach (ThreadController t in gridThreads.ItemsSource) { App.MonitorHistory.AddHistoryTables(t.Id); } }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { using (var sys = new SysTabl(Different.GetInfoTaskDir() + @"Controller\ControllerData.accdb")) { sys.PutSubValue("DebugWriteOPC", "OpcServerName", OpcServerName.Text); sys.PutSubValue("DebugWriteOPC", "Node", Node.Text); sys.PutSubValue("DebugWriteOPC", "OpcTag", OpcTag.Text); sys.PutSubValue("DebugWriteOPC", "DataType", DataType.Text); sys.PutSubValue("DebugWriteOPC", "TagValue", TagValue.Text); } }
//Проверка соединения protected override void ConnectProvider() { if (!DaoDb.Check(CloneFile, "InfoTaskClone")) { AddError("Недопустимый файл клона", null, CloneFile); } if (SysTabl.ValueS(CloneFile, "CloneComplect") != SourceConnect.Complect) { AddError(CheckConnectionMessage = "Файл является клоном для другого, несовместимого источника"); } }
public ThreadController(IRecordRead rec) { using (var c = Start()) { Id = rec.GetInt("ThreadId"); ThreadName = Id.ToString(); ApplicationType = ApplicationType.Controller; OpenHistory(General.ControllerDir + @"History\History" + Id + ".accdb", General.HistryTemplateFile, true); PrepareResultFile(); using (StartAtom(Atom.OpenThread)) { try { AddEvent("Чтение списка функций"); ReadFunctions(); AddEvent("Чтение свойств потока"); Comment = rec.GetString("Comment"); IsPeriodic = rec.GetBool("IsPeriodic"); CalcType = IsPeriodic ? "Периодический" : "Разовый"; PeriodLength = rec.GetDouble("PeriodLength", 15); SourcesLate = rec.GetDouble("SourcesLate", 2); RushWaitingTime = rec.GetDouble("RushWaitingTime"); TimeAfterError = rec.GetDouble("TimeAfterError", 5); IsImit = rec.GetBool("IsImit"); ImitModeStr = rec.GetString("ImitMode"); using (var sys = new SysTabl(ResultFile)) { PeriodBegin = sys.SubValue("PeriodInfo", "PeriodBegin").ToDateTime(); PeriodEnd = sys.SubValue("PeriodInfo", "PeriodEnd").ToDateTime(); CalcName = sys.SubValue("PeriodInfo", "CalcName"); StartMoment = sys.SubValue("PeriodInfo", "StartMoment").ToDateTime(); StartTime = sys.SubValue("PeriodInfo", "StartTime").ToDateTime(); StopTime = sys.SubValue("PeriodInfo", "StopTime").ToDateTime(); IsStopTime = sys.SubValue("PeriodInfo", "IsStopTime") == "True"; _lastErrorText = sys.SubValue("LastErrorInfo", "ErrorText"); _lastErrorTime = sys.SubValue("LastErrorInfo", "ErrorPeriodBegin").ToDateTime(); _lastErrorPos = 0; UpdateTablo(); } _state = State.Stopped; } catch (Exception ex) { AddError("Ошибка загрузки потока", ex); } } StartAtom(Atom.ReadSetup, ReadSetup); IsClosed = false; if (c.IsError) { Different.MessageError("Ошибка загрузки данных потока расчета. " + c.ErrorMessage()); } } }
private SourceConnect MakeProviders() { var factory = new ProvidersFactory(); var logger = new Logger(new AppIndicator()); logger.History = new TestHistory(logger); var con = (SourceConnect)factory.CreateConnect(logger, ProviderType.Source, "SourceCon", "Simatic"); var prov = factory.CreateProvider(logger, "SimaticSource", "SQLServer" + SysTabl.SubValueS(TestLib.TestRunDir + "TestsSettings.accdb", "SQLServerSettings", "SqlServer")); con.JoinProvider(prov); return(con); }
private void Window_Loaded(object sender, RoutedEventArgs e) { try { using (var sys = new SysTabl(General.ConfigFile)) AppVersion.Text = sys.SubValue("InfoTask", "AppVersion"); var dbv = new DbVersion(); AppUserOrg.Text = dbv.AUser("Controller"); LicenseNumber.Text = dbv.ANumber("Controller"); } catch { } }
public void StaticFuns() { var file = CopyFile("Static"); Assert.AreEqual("OptionsValue", SysTabl.ValueS(file, "FileOptions")); Assert.AreEqual("ParamValue", SysTabl.ValueS(file, "Param")); Assert.AreEqual("OptionsTag", SysTabl.TagS(file, "FileOptions")); Assert.AreEqual("ParamTag", SysTabl.TagS(file, "Param")); SysTabl.PutValueS(file, "Param", "s1", "t1"); Assert.AreEqual("s1", SysTabl.ValueS(file, "Param")); Assert.AreEqual("t1", SysTabl.TagS(file, "Param")); SysTabl.PutValueS(file, "Param", 22, "t2"); Assert.AreEqual("22", SysTabl.ValueS(file, "Param")); Assert.AreEqual("t2", SysTabl.TagS(file, "Param")); SysTabl.PutValueS(file, "Param", 33.3, "t3"); Assert.AreEqual("33,3", SysTabl.ValueS(file, "Param")); Assert.AreEqual("t3", SysTabl.TagS(file, "Param")); SysTabl.PutValueS(file, "Param", new DateTime(2000, 1, 1)); Assert.AreEqual("01.01.2000 0:00:00", SysTabl.ValueS(file, "Param")); Assert.AreEqual("t3", SysTabl.TagS(file, "Param")); SysTabl.PutValueS(file, "Param", true, ""); Assert.AreEqual("True", SysTabl.ValueS(file, "Param")); Assert.AreEqual("", SysTabl.TagS(file, "Param")); SysTabl.PutTagS(file, "Param", "Tag", "Value"); Assert.AreEqual("Value", SysTabl.ValueS(file, "Param")); Assert.AreEqual("Tag", SysTabl.TagS(file, "Param")); Assert.AreEqual("Тестовый файл", SysTabl.SubValueS(file, "FileOptions", "FileDescription")); Assert.AreEqual("DaoTest", SysTabl.SubValueS(file, "FileOptions", "FileType")); Assert.AreEqual("2.0.0", SysTabl.SubValueS(file, "FileOptions", "FileVersion")); Assert.AreEqual("11.07.2016", SysTabl.SubValueS(file, "FileOptions", "FileVersionDate")); Assert.AreEqual("SubValue", SysTabl.SubValueS(file, "Param", "SubParam")); Assert.AreEqual(null, SysTabl.SubTagS(file, "FileOptions", "FileDescription")); Assert.AreEqual("SubTag", SysTabl.SubTagS(file, "Param", "SubParam")); SysTabl.PutSubValueS(file, "Param", "SubParam", "s1", "t1"); Assert.AreEqual("s1", SysTabl.SubValueS(file, "Param", "SubParam")); Assert.AreEqual("t1", SysTabl.SubTagS(file, "Param", "SubParam")); SysTabl.PutSubValueS(file, "Param", "SubParam", 22, "t2"); Assert.AreEqual("22", SysTabl.SubValueS(file, "Param", "SubParam")); Assert.AreEqual("t2", SysTabl.SubTagS(file, "Param", "SubParam")); SysTabl.PutSubValueS(file, "Param", "SubParam", 33.3, "t3"); Assert.AreEqual("33,3", SysTabl.SubValueS(file, "Param", "SubParam")); Assert.AreEqual("t3", SysTabl.SubTagS(file, "Param", "SubParam")); SysTabl.PutSubValueS(file, "Param", "SubParam", new DateTime(2000, 1, 1)); Assert.AreEqual("01.01.2000 0:00:00", SysTabl.SubValueS(file, "Param", "SubParam")); Assert.AreEqual("t3", SysTabl.SubTagS(file, "Param", "SubParam")); SysTabl.PutSubValueS(file, "Param", "SubParam", true, ""); Assert.AreEqual("True", SysTabl.SubValueS(file, "Param", "SubParam")); Assert.AreEqual("", SysTabl.SubTagS(file, "Param", "SubParam")); SysTabl.PutSubTagS(file, "Param", "SubParam", "Tag", "Value"); Assert.AreEqual("Value", SysTabl.SubValueS(file, "Param", "SubParam")); Assert.AreEqual("Tag", SysTabl.SubTagS(file, "Param", "SubParam")); }
private void CloseResult() { if (_sysResult != null) { _sysResult.Dispose(); _sysResult = null; } if (_dbResilt != null) { _dbResilt.Dispose(); _dbResilt = null; } }
//Чтение списка сигналов из клона private void PrepareForClone(string cloneFile) { try { AddEvent("Чтение свойств клона"); if (!DaoDb.Check(cloneFile, new[] { "Objects", "Signals", "MomentsValues" })) { AddError("Недопустимый файл клона"); } else { using (var db = new DaoDb(cloneFile)) { using (var sys = new SysTabl(db)) { if (_form != null) { _form.CalcName.Text = sys.Value("CloneDescription"); } _cloneInf = sys.Value("CloneInf"); RunSource(sys.SubValue("Source", "ProviderCode"), sys.SubValue("Source", "ProviderName"), sys.SubValue("Source", "ProviderInf")); } AddEvent("Чтение списка сигналов клона"); _source.ClearSignals(); int n = 0; using (var rec = new RecDao(db, "SELECT SignalId, FullCode, DataType, Inf FROM Signals WHERE ConstValue Is Null")) while (rec.Read()) { _source.AddSignal(rec.GetString("Inf"), rec.GetString("FullCode"), rec.GetString("DataType").ToDataType(), rec.GetInt("SignalId")); n++; } AddEvent("Сигналы клона прочитаны", n + " сигналов"); //db.Execute("DELETE * FROM MomentsValues"); //db.Execute("DELETE * FROM Intervals"); using (var rec = new RecDao(db, "Intervals")) { rec.AddNew(); rec.Put("TimeBegin", _timeBegin); rec.Put("TimeEnd", _timeEnd); } } } } catch (Exception ex) { AddError("Ошибка при подготовке клона", ex); } }
//Получение диапазона клона public TimeInterval GetTime() { if (CloneFile.IsEmpty()) { return(new TimeInterval(Different.MinDate, Different.MaxDate)); } using (var sys = new SysTabl(CloneFile)) { TimeIntervals.Clear(); var t = new TimeInterval(sys.Value("BeginInterval").ToDateTime(), IsHandInput ? DateTime.Now : sys.Value("EndInterval").ToDateTime()); TimeIntervals.Add(t); return(t); } }
//Отображает данные для указанного типа приложения app = Excel2007 или Excel2010 public void PutInfo(string app) { ProgrammInfo.Text = app == "Excel2010" ? "Построитель отчетов для Excel 2010 (ReporterExcel2010)" : "Построитель отчетов для Excel 2007 (ReporterExcel2007)"; using (var sys = new SysTabl(General.ConfigFile)) { AppVersion.Text = sys.SubValue("InfoTask", "AppVersion"); } var dbv = new DbVersion(); AppUserOrg.Text = dbv.AUser("Excel"); LicenseNumber.Text = dbv.ANumber("Excel"); Refresh(); }
private void FormGroupReports_Load(object sender, EventArgs e) { using (var db = new DaoDb(General.ReporterFile)) { using (var sys = new SysTabl(db)) { BeginPeriod.Text = sys.SubValue("FormGroupReports", "BeginPeriod"); EndPeriod.Text = sys.SubValue("FormGroupReports", "EndPeriod"); } using (var rec = new RecDao(db, "SELECT * FROM GroupReports ORDER BY GroupCode")) while (rec.Read()) { EditItem(rec); } } }
static void Main() { ControllerDataFile = Different.GetInfoTaskDir() + @"Controller\ControllerData.accdb"; using (var sys = new SysTabl(ControllerDataFile)) { MonitorHistory = new MonitorHistory { Inf = sys.Value("MonitorHistoryProps") }; CheckTime = sys.Value("MonitorHistoryCheckTime").ToDateTime(); } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(ThreadsForm = new ThreadsForm()); }
//Отметка используемых провайдеров и ручного ввода private void SaveUsedProviders() { try { using (var db = new DaoDb(_projectFile)) { using (var rec = new RecDao(db, "Providers")) while (rec.Read()) { switch (rec.GetString("ProviderType").ToProviderType()) { case ProviderType.Communicator: rec.Put("IsUsed", true); break; case ProviderType.Source: case ProviderType.Receiver: rec.Put("IsUsed", UsedProviders.Contains(rec.GetString("ProviderName"))); break; case ProviderType.Archive: rec.Put("IsUsed", UsedProviders.Contains("Archive")); break; } } using (var sys = new SysTabl(db)) { sys.PutSubValue("ArchiveOptions", "IsAbsolute", IsAbsolute ? "True" : "False"); sys.PutSubValue("ArchiveOptions", "IsPeriodic", IsPeriodic ? "True" : "False"); sys.PutSubValue("ArchiveOptions", "IsMoments", IsMoments ? "True" : "False"); sys.PutSubValue("ArchiveOptions", "IsPrevAbs", IsPrevAbs ? "True" : "False"); sys.PutSubValue("ArchiveOptions", "IsLastBase", IsLastBase ? "True" : "False"); sys.PutSubValue("ArchiveOptions", "IsLastHour", IsLastHour ? "True" : "False"); sys.PutSubValue("ArchiveOptions", "IsLastDay", IsLastDay ? "True" : "False"); sys.PutSubValue("ArchiveOptions", "IsManyBase", IsManyBase ? "True" : "False"); sys.PutSubValue("ArchiveOptions", "IsManyHour", IsManyHour ? "True" : "False"); sys.PutSubValue("ArchiveOptions", "IsManyDay", IsManyDay ? "True" : "False"); sys.PutSubValue("ArchiveOptions", "IsManyMoments", IsManyMoments ? "True" : "False"); } } } catch (Exception ex) { AddError("Ошибка сохранения признаков использования провайдеров и ручного ввода", ex); } }
public void Clone() { TestLib.CopyDir(@"Providers\Logika", "Clone"); TestLib.CopyFile(@"Providers\Logika", "prolog.mdb", "CloneProlog.mdb"); var app = new App("Test", new TestIndicator(), false); app.InitTest(); var con = new ClonerConnect(app); con.JoinProvider(app.ProvidersFactory.CreateProvider(app, "LogikaSource", "DbFile=" + TestLib.TestRunDir + @"Providers\Logika\CloneProlog.mdb")); var cloneDir = TestLib.TestRunDir + @"Providers\Logika\Clone\"; SysTabl.PutValueS(cloneDir + "Clone.accdb", "SourceInf", "DbFile=" + TestLib.TestRunDir + @"Providers\Logika\CloneProlog.mdb"); using (con.StartPeriod(D(0), D(24), "Single")) con.MakeClone(cloneDir); TestLib.CompareClones(cloneDir + "Clone.accdb", cloneDir + "CorrectClone.accdb"); }
public void Clone() { TestLib.CopyDir(@"Providers\Mir", "Clone"); var app = new App("Test", new TestIndicator(), false); app.InitTest(); var con = new ClonerConnect(app); con.JoinProvider(app.ProvidersFactory.CreateProvider(app, "MirSource", TestLib.TestSqlInf("EnergyRes"))); var cloneDir = TestLib.TestRunDir + @"Providers\Mir\Clone\"; SysTabl.PutValueS(cloneDir + "Clone.accdb", "SourceInf", TestLib.TestSqlInf("EnergyRes")); using (con.StartPeriod(D(48), D(96), "Single")) con.MakeClone(cloneDir); TestLib.CompareClones(cloneDir + "Clone.accdb", cloneDir + "CorrectClone.accdb"); }
//Создание клона архива public void MakeClone(DateTime beginRead, DateTime endRead, string cloneFile = "", string cloneProps = "") { try { using (var db = new DaoDb(cloneFile)) { using (var sys = new SysTabl(db)) CloneInf = (sys.Value("CloneInf") ?? "").ToPropertyDicS(); using (CloneRec = new RecDao(db, "SELECT * FROM MomentsValues")) using (CloneErrorRec = new RecDao(db, "SELECT * FROM ErrorsList")) GetValues(beginRead, endRead); } } catch (Exception ex) { Logger.AddError("Ошибка при создании клона", ex); } CloneRec = null; }
//Сравниваем версии базы данных и текущего ПО //Возвращает: -1 - ошибка, 0 - версии одинаковы, 1 - нужно обновлять, страые версии ПО совместимы, 2 - старые версии ПО не совместимы private int VersionStatus(string dbPath, DbMode dbMode) { try { PrepareDelegates(dbMode); if (_delegates.Count == 0) { return(0); } using (var sys = new SysTabl(dbPath)) _dbVersion = new Version(sys.SubValue("AppOptions", "AppVersion"), sys.SubValue("AppOptions", "AppVersionDate")); if (_delegates.Last().Version <= _dbVersion) { return(0); } return(_delegates.Exists(x => x.Version > _dbVersion && !x.IsBack) ? 2 : 1); } catch { return(-1); } }
public static void Initialize() { if (_isInitialized) { return; } try { InfoTaskDir = Different.GetInfoTaskDir(); GeneralDir = InfoTaskDir + @"General\"; TmpDir = InfoTaskDir + @"Tmp\"; DocsDir = InfoTaskDir + @"Docs\"; ControllerDir = InfoTaskDir + @"Controller\"; ReporterDir = InfoTaskDir + @"Reporter\"; ConfigFile = GeneralDir + "Config.accdb"; HistryTemplateFile = GeneralDir + "HistoryTemplate.accdb"; if (!DaoDb.Check(GeneralDir + "General.accdb", new[] { "Functions", "FunctionsOverloads" })) { Different.MessageError("Не допустимый General.accdb"); } if (!DaoDb.Check(ConfigFile, new[] { "SysTabl", "SysSubTabl" })) { Different.MessageError("Не допустимый Config.accdb"); } ControllerFile = ControllerDir + "ControllerData.accdb"; if (!DaoDb.Check(ControllerFile, new[] { "Threads", "Projects", "Providers" })) { Different.MessageError("Не допустимый ControllerData.accdb"); } ReporterFile = ReporterDir + "ReporterData.accdb"; ReportTemplateFile = ReporterDir + "ReportTemplate.accdb"; DebugMode = SysTabl.ValueS(ControllerFile, "DebugMode") == "True"; Oka.Register(); ReadProvidersLists(); _isInitialized = true; } catch (Exception ex) { ex.MessageError("Настроечный файл имеет недопустимый формат"); } }
//Открытие и закрытие SysTabl файла Result private void OpenResult() { try { if (_sysResult != null) { _sysResult.Dispose(); } if (_dbResilt != null) { _dbResilt.Dispose(); } _dbResilt = new DaoDb(ResultFile); _sysResult = new SysTabl(_dbResilt); _lastErrorPos = 0; } catch (Exception ex) { AddError("Ошибка при открытии SysTabl файла Result", ex); } }
protected override void OnStartup(StartupEventArgs e) { try { Mutex.OpenExisting("InfoTask.Controller"); MessageBox.Show("Нельзя запустить более одного контроллера одновременно"); Current.Shutdown(); } catch { if (new DbVersion().ACheck("Controller") < 1) { Current.Shutdown(); } Mutex = new Mutex(false, "InfoTask.Controller"); } try { General.Initialize(); Synchro = new Synchro(); MonitorHistory = new MonitorHistory { Inf = SysTabl.ValueS(General.ControllerFile, "MonitorHistoryProps") }; using (var rec = new ReaderAdo(General.ControllerFile, "SELECT * FROM Threads WHERE ApplicationType='Controller' ORDER BY ThreadId")) while (rec.Read()) { AddThread(rec); } Window = new MainCalc(); Window.Show(); Window.App = this; Window.DataContext = this; } catch (Exception ex) { ex.MessageError(); } }