Ejemplo n.º 1
0
        private static int CopyProp(RecDao cfgTemplate, RecDao cfg)
        {
            bool flag = !cfg.FindFirst("ParamName", cfgTemplate.GetString("ParamName"));

            //if (!cfg.FindFirst("ParamName", cfgTemplate.GetString("ParamName")))
            if (flag)
            {
                //    MessageBox.Show("Я не нашел запись в конфиге, о чем сейчас и сообщаю");
                //else MessageBox.Show("Я нашел запись в тимплейте. А вы чем занимаетесь?");
                cfg.AddNew();
            }
            cfg.Put("ParamName", cfgTemplate.GetString("ParamName"));
            cfg.Put("ParamType", cfgTemplate.GetString("ParamType"));
            cfg.Put("ParamValue", cfgTemplate.GetString("ParamValue"));
            cfg.Put("ParamDescription", cfgTemplate.GetString("ParamDescription"));
            cfg.Put("ParamTag", cfgTemplate.GetString("ParamTag"));
            int id = cfg.GetInt("ParamId");

            //MessageBox.Show(flag + " " + cfgTemplate.GetString("ParamName"));
            try
            {
                cfg.Update();
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
            return(id);
        }
Ejemplo n.º 2
0
        //Копирует одну строчку из SysTabl ConfigTemplate вместе с подтаблицей
        private static void CopyConfigProp(string propName, RecDao cfgTemplate, RecDao cfg)
        {
            cfgTemplate.FindFirst("ParamName", propName);
            var id = CopyProp(cfgTemplate, cfg);

            CopySubProp(cfgTemplate.GetInt("ParamId"), cfgTemplate.DaoDb, id, cfg.DaoDb);
        }
Ejemplo n.º 3
0
        //Список совместимых кодов провайдеров для выбранного кода провайдера
        public static List <string> JointProviderCodes(this string code)
        {
            var list = new List <string> {
                code
            };

            using (var rec = new RecDao(Different.GetInfoTaskDir() + @"General\Config.accdb", "SysTabl"))
            {
                if (code == "CloneSource")
                {
                    while (rec.Read())
                    {
                        if (rec.GetString("ParamValue") == "Источник" && rec.GetString("ParamName") != "CloneSource")
                        {
                            list.Add(rec.GetString("ParamName"));
                        }
                    }
                }
                else
                {
                    rec.FindFirst("ParamName", code);
                    if (!rec.NoMatch())
                    {
                        var set = rec.GetString("ParamTag").ToPropertyDicS()["JointProviders"].ToPropertyHashSet();
                        foreach (var c in set.Values)
                        {
                            rec.FindFirst("ParamName", c);
                            if (!rec.NoMatch())
                            {
                                list.Add(c);
                            }
                        }
                    }
                }
            }
            return(list);
        }
Ejemplo n.º 4
0
 //Открывает рекордсет Projects, записывает туда проект и закрывает
 public void AddToDb()
 {
     try
     {
         using (var rec = new RecDao(General.ControllerFile, "SELECT * FROM Projects WHERE (ThreadId=" + Id + ")"))
         {
             if (!rec.FindFirst("Project", Code))
             {
                 rec.AddNew();
             }
             ToRecordset(rec);
         }
     }
     catch (Exception ex)
     {
         ThreadCalc.AddError("Ошибка при записи проекта в ControllerData", ex, Code);
     }
 }
Ejemplo n.º 5
0
        private void FormSetupWin_Load(object sender, EventArgs e)
        {
            _setupIsLoaded = false;
            _book          = GeneralRep.ActiveBook;
            _book.AddEvent("Загрузка свойств отчета");
            var sys = _book.SysPage;

            try
            {   //Свойства отчета
                sys.GetControl(CodeReport, "Report");
                sys.GetControl(NameReport, "ReportName");
                sys.GetControl(DescriptionReport, "ReportDescription");
                FileReport.Text = GeneralRep.Application.ActiveWorkbook.FullName;
                sys.GetControl(MonthLength);
                sys.GetControl(DayLength);
                sys.GetControl(HourLength);
                sys.GetControl(MinuteLength);
                sys.GetControl(DayStart);
                sys.GetControl(HourStart);
                sys.GetControl(MinuteStart);
                radioDifferent.Checked           = sys.GetBoolValue("DifferentLength");
                radioLess.Checked                = sys.GetValue("DifferentLength") == "Less";
                radioEquals.Checked              = sys.GetValue("DifferentLength") == "Equals";
                radioNow.Checked                 = sys.GetValue("DefaultPeriod") == "Now";
                radioPrevious.Checked            = sys.GetValue("DefaultPeriod") != "Now";
                DifferentBegin.Checked           = sys.GetBoolValue("DifferentBegin");
                CalcName.Text                    = sys.GetValue("DefaultCalcName");
                AllowProjectsRepetitions.Checked = sys.GetBoolValue("AllowProjectsRepetitions");
            }
            catch (Exception ex)
            {
                GeneralRep.ShowError("Текущий файл не является файлом отчета InfoTask или был поврежден", ex);
                Close();
                return;
            }

            _book.AddEvent("Загрузка настроек из ReporterData");
            Providers.Rows.Clear();
            try
            {
                if (CodeReport.Text != null)
                {
                    using (var db = new DaoDb(General.ReporterFile))
                    {
                        int rid = 0;
                        using (var rec = new RecDao(db, "SELECT * FROM Reports WHERE Report = '" + CodeReport.Text + "'"))
                            if (rec.HasRows())
                            {
                                ThreadId.Text         = rec.GetInt("ThreadId").ToString();
                                UseOneArchive.Checked = rec.GetBool("UseOneArchive");
                                ServerReport.Text     = rec.GetString("ServerReport");
                                var dic = rec.GetString("FormInf").ToPropertyDicS();
                                FormToTemplate.Checked    = dic["FormTo"] == "Template";
                                FormToDir.Checked         = dic["FormTo"] == "Dir";
                                FormToFile.Checked        = dic["FormTo"] == "File";
                                ResultDir.Text            = dic["ResultDir"];
                                ResultFileName.Text       = dic["ResultFileName"];
                                ResultFile.Text           = dic["ResultFile"];
                                AddDateToName.Checked     = dic.GetBool("AddDateToName");
                                DateNameFormat.Text       = dic["DateNameFormat"];
                                AddBeginToName.Checked    = dic.GetBool("AddBeginToName");
                                BeginNameFormat.Text      = dic["BeginNameFormat"];
                                AddEndToName.Checked      = dic.GetBool("AddEndToName");
                                EndNameFormat.Text        = dic["EndNameFormat"];
                                AddCalcNameToName.Checked = dic.GetBool("AddCalcNameToName");
                                AddSheetToName.Checked    = dic.GetBool("AddSheetToName");
                                SetFocusToFormed.Checked  = dic.GetBool("SetFocusToFormed");
                                rid = rec.GetInt("ReportId");
                                _codes.Add("Report_Archive", rec.GetString("CodeArchive"));
                                _infs.Add("Report_Archive", rec.GetString("InfArchive"));
                            }
                        SetFormingEnabled();
                        labelThreadId.Visible = ThreadId.Visible;

                        //Список проектов
                        using (var recr = new RecDao(db, "SELECT * FROM Projects WHERE ReportId =" + rid))
                            foreach (var pr in sys.GetProjects().Values)
                            {
                                int  rn    = Projects.Rows.Add();
                                var  cells = Projects.Rows[rn].Cells;
                                bool b     = recr.FindFirst("Project", pr.Code);
                                if (AllowProjectsRepetitions.Checked)
                                {
                                    b = !pr.Code2.IsEmpty()
                                        ? recr.FindFirst("ProjectCode2", pr.Code2)
                                        : recr.FindFirst("(Project='" + pr.Code + "') AND ((ProjectCode2 = '') OR (ProjectCode2 Is Null))");
                                }
                                if (b)
                                {
                                    recr.GetToDataGrid("ProjectFile", cells);
                                    recr.GetToDataGrid("ProjectName", cells);
                                    if (AllowProjectsRepetitions.Checked)
                                    {
                                        recr.GetToDataGrid("ProjectCode2", cells);
                                    }
                                    cells["Project"] = new DataGridViewTextBoxCell();
                                    if (!UseOneArchive.Checked && pr.CalcMode != CalcModeType.Internal)
                                    {
                                        var acode = recr.GetString("CodeArchive");
                                        var ainf  = recr.GetString("InfArchive");
                                        _codes.Add(pr.CodeFinal + "_Archive", acode);
                                        _infs.Add(pr.CodeFinal + "_Archive", ainf);
                                    }
                                }
                                cells["Project"].Value         = pr.Code;
                                cells["ProjectCalcMode"].Value = pr.CalcMode.ToRussian();
                                if (AllowProjectsRepetitions.Checked)
                                {
                                    cells["ProjectCode2"].Value = pr.Code2;
                                }
                            }
                    }
                }
            }
            catch (Exception ex)
            {
                GeneralRep.ShowError("Неправильный файл ReporterData.accdb", ex);
                Close();
                return;
            }

            _book.AddEvent("Загрузка настроек из ControllerData");
            try
            {
                int tid;
                if (!int.TryParse(ThreadId.Text, out tid))
                {
                    tid = 0;
                }
                if (tid != 0)
                {
                    using (var rect = new RecDao(General.ControllerFile, "SELECT * FROM Threads WHERE ThreadId = " + tid))
                    {
                        IsImit.Checked = rect.GetBool("IsImit");
                        ImitMode.Text  = rect.GetString("ImitMode");
                        using (var rec = new RecDao(rect.DaoDb, "SELECT * FROM Providers WHERE ThreadId=" + tid))
                            while (rec.Read())
                            {
                                string type = rec.GetString("ProviderType");
                                if (type == "Источник" || type == "Приемник" || (type == "Архив" && !UseOneArchive.Checked) || (type == "Имитатор" && IsImit.Checked))
                                {
                                    string name = rec.GetString("ProviderName");
                                    _codes.Add(name, rec.GetString("ProviderCode"));
                                    _infs.Add(name, rec.GetString("ProviderInf"));
                                }
                            }
                    }
                }
            }
            catch (Exception ex)
            {
                GeneralRep.ShowError("Неправильный файл ControllerData.accdb", ex);
            }
            _setupIsLoaded = true;
            UpdateProvidersList();
        }
Ejemplo n.º 6
0
        public static ActionResult ConfigFillITU(Session session)
        {
            session.Log("Begin ConfigFillITU");
            try
            {
                using (var db = new DaoDb(session.GetTargetPath("General") + "Config.accdb"))
                {
                    bool   cFlag = false;
                    string warnM = "Обнаружены установленные компоненты InfoTask:";
                    using (var cfg = new RecDao(db, "SELECT * FROM SysTabl"))
                    {
                        //Проверка, есть ли установленные иные компоненты ИТ
                        cfg.FindFirst("ParamName='Analyzer'");
                        if (!cfg.NoMatch())
                        {
                            cFlag  = true;
                            warnM += "\n  - Analyzer";
                        }
                        cfg.FindFirst("ParamName='AnalyzerInfoTask'");
                        if (!cfg.NoMatch())
                        {
                            cFlag  = true;
                            warnM += "\n  - AnalyzerInfoTask";
                        }
                        cfg.FindFirst("ParamName='Constructor'");
                        if (!cfg.NoMatch())
                        {
                            cFlag  = true;
                            warnM += "\n  - Constructor";
                        }
                        cfg.FindFirst("ParamName='Reporter'");
                        if (!cfg.NoMatch())
                        {
                            cFlag  = true;
                            warnM += "\n  - Reporter";
                        }
                        cfg.FindFirst("ParamName='KosmotronikaRetroSource'");
                        if (!cfg.NoMatch())
                        {
                            cFlag  = true;
                            warnM += "\n  - KosmotronikaProviders";
                        }
                        cfg.FindFirst("ParamName='OvationSource'");
                        if (!cfg.NoMatch())
                        {
                            cFlag  = true;
                            warnM += "\n  - OvationProviders";
                        }
                        cfg.FindFirst("ParamName='WonderwareHistorianSource'");
                        if (!cfg.NoMatch())
                        {
                            cFlag  = true;
                            warnM += "\n  - WonderwareProviders";
                        }
                        cfg.FindFirst("ParamName='SimaticSource'");
                        if (!cfg.NoMatch())
                        {
                            cFlag  = true;
                            warnM += "\n  - SiemensProviders";
                        }
                        cfg.FindFirst("ParamName='MirSource'");
                        if (!cfg.NoMatch())
                        {
                            cFlag  = true;
                            warnM += "\n  - MirProviders";
                        }
                        cfg.FindFirst("ParamName='PrologSource'");
                        if (!cfg.NoMatch())
                        {
                            cFlag  = true;
                            warnM += "\n  - LogikaProviders";
                        }
                        cfg.FindFirst("ParamName='RasOvation'");
                        if (!cfg.NoMatch())
                        {
                            cFlag  = true;
                            warnM += "\n  - RAS";
                        }
                        cfg.FindFirst("ParamName='RasKosmotronika'");
                        if (!cfg.NoMatch())
                        {
                            cFlag  = true;
                            warnM += "\n  - RasKosmotronika";
                        }
                        cfg.FindFirst("ParamName='RasInfoTask'");
                        if (!cfg.NoMatch())
                        {
                            cFlag  = true;
                            warnM += "\n  - RasInfoTask";
                        }
                    }
                    if (cFlag)
                    {
                        warnM += "\n Необходимо удалить/переустановить и их";
                        MessageBox.Show(warnM);
                        //return ActionResult.UserExit;
                    }

                    if (session.Features["KernelMainFeature"].RequestState == InstallState.Absent)
                    {
                        db.Execute("DELETE * FROM SysTabl WHERE ParamName='InfoTask' OR ParamName='AccessArchive' OR ParamName='SQLServerArchive' " +
                                   "OR ParamName='ArchiveProjectComm' OR ParamName='ArchiveAccessComm' OR ParamName='ArchiveSQLServerComm' OR ParamName='ArchiveAccessSource' " +
                                   "OR ParamName='ArchiveSQLServerSource' OR ParamName='Imitator' OR ParamName='CloneComm' OR ParamName='CloneSource' " +
                                   "OR ParamName='HandInputSource' OR ParamName='HandInputSqlSource' OR ParamName='MonitorHistory'");
                    }

                    if (session.Features["ControllerMonitorFeature"].RequestState == InstallState.Absent)
                    {
                        db.Execute("DELETE * FROM SysTabl WHERE ParamName='Controller'");
                    }
                    if (session.Features["CalcArchiveViewerFeature"].RequestState == InstallState.Absent)
                    {
                        db.Execute("DELETE * FROM SysTabl WHERE ParamName='CalcArchiveViewer'");
                    }
                }
            }
            catch (Exception exception)
            {
                //return ActionResult.UserExit;
                exception.MessageError();
            }
            session.Log("End ConfigFillITU");
            return(ActionResult.Success);
        }