Пример #1
0
        //Get sys info online
        private void button2_Click(object sender, EventArgs e)
        {
            string methodName = new StackTrace(false).GetFrame(0).GetMethod().Name;

            ClearLog();
            try {
                if (CurrentDxc.ReadInfoFromIp())
                {
                    CurrentDxc.SaveToFile(Cfg);
                    InvokeLog("DXC dsp st sys", CurrentDxc.ToString());
                }
                else
                if (CurrentDxc.LoadFromFile(Cfg))
                {
                    ClearLog();
                    InvokeLog("DXC dsp st sys", "Загружено c файла:");
                    InvokeLog("", CurrentDxc.ToString());
                }
                else
                {
                    ClearLog();
                    InvokeLog("DXC info", "Информации не найдено");
                }
            } catch (Exception ex) {
                Log.WriteLog(methodName, ex.Message);
            }
        }
Пример #2
0
        public void ReadSettings()
        {
            string methodName = new StackTrace(false).GetFrame(0).GetMethod().Name;

            try
            {
                #region Чтение имен DXC
                DxcList.Clear();
                var dxcKeys = Cfg.GetAllKeys("LIST_DXC");
                if (dxcKeys.Count() > 0) //read all DXC NAME--IP
                {                        //KEY - IP
                    //VALUE - NAME
                    foreach (var dxcKey in dxcKeys)
                    {
                        if (String.IsNullOrWhiteSpace(dxcKey))
                        {
                            continue;
                        }
                        ClassDxc newDxc = new ClassDxc(dxcKey);
                        newDxc.CustomName = Cfg.ReadIni("LIST_DXC", dxcKey);
                        if (DxcList.All(x => x.Ip != dxcKey))
                        {
                            DxcList.Add(newDxc);
                        }
                    }
                }
                #endregion
                #region Чтение Информации о DXC
                if (DxcList.Any())
                {
                    for (int i = 0; i < DxcList.Count; i++)
                    {
                        ClassDxc d = DxcList[i];
                        d.LoadFromFile(Cfg);
                        //D.backupPath = Cfg.ReadINI(D.ip, "BackupPath");
                        //D.info.sys_name = Cfg.ReadINI(D.ip, "Sys_Name");
                        //string file = Cfg.ReadIni(d.Ip, "Alarms_file");
                        //if(Cfg.KeyExists("TimeCorrection",D.ip)) D.info.dt=new TimeSpan(long.Parse(Cfg.ReadINI(D.ip,"TimeCorrection")));
                        d.ReadArhivAlarmsForDays(10);
                        DxcList[i] = d;
                    }
                }

                #endregion

                if (Cfg.KeyExists("backupDir", "Global"))
                {
                    BackupPath = Cfg.ReadIni("Global", "backupDir");
                }
                else
                {
                    BackupPath = "";
                }
            }
            catch (Exception exception)
            {
                Log.WriteLog(methodName, exception.Message);
            }
        }