Ejemplo n.º 1
0
        //Отметка используемых провайдеров и ручного ввода
        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);
            }
        }
Ejemplo n.º 2
0
        //Запись используемых сигналов в SignalsInUse
        private void SaveInUse()
        {
            try
            {
                using (var db = new DaoDb(_projectFile))
                {
                    var old = new SetS();
                    using (var rec = new RecDao(db, "SignalsInUse"))
                    {
                        while (rec.Read())
                        {
                            var code = rec.GetString("FullCode");
                            if ((Signals.ContainsKey(code) && Signals[code].InUse) || HandSignals.ContainsKey(code))
                            {
                                old.Add(code);
                                rec.Put("Del", false);
                            }
                            else
                            {
                                rec.Put("Del", true);
                            }
                        }
                    }
                    db.Execute("DELETE * FROM SignalsInUse WHERE Del=True");
                    var add = new SetS();
                    var use = from s in SignalsList where s.InUse select s;
                    SignalsInUseCount = use.Count();
                    foreach (var s in use)
                    {
                        if (!old.Contains(s.FullCode))
                        {
                            add.Add(s.FullCode);
                        }
                        if (s.InUseSource)
                        {
                            UsedProviders.Add(s.SourceName);
                        }
                        if (s.InUseReceiver)
                        {
                            UsedProviders.Add(s.ReceiverName);
                        }
                    }
                    if (HandSignals.Count > 0 && HandInputSource != null)
                    {
                        UsedProviders.Add(HandInputSource);
                    }
                    foreach (var hand in HandSignals.Values)
                    {
                        if (!old.Contains(hand.FullCode))
                        {
                            add.Add(hand.FullCode);
                        }
                    }

                    using (var rec = new RecDao(db, "SignalsInUse"))
                    {
                        while (rec.Read())
                        {
                            var    s   = rec.GetString("FullCode");
                            Signal sig = Signals.ContainsKey(s) ? Signals[s] : HandSignals[s];
                            sig.ToRecordset(rec, false);
                        }
                        foreach (var s in add.Keys)
                        {
                            Signal sig = Signals.ContainsKey(s) ? Signals[s] : HandSignals[s];
                            sig.ToRecordset(rec, true);
                        }
                    }
                    using (var rec = new RecDao(db, "GraficsList"))
                        while (rec.Read())
                        {
                            rec.Put("UsedUnits", UsingParamsString(Grafics[rec.GetString("Code")].UsingParams));
                        }
                }
            }
            catch (Exception ex)
            {
                AddError("Ошибка сохранения сигналов или графиков", ex);
            }
        }