示例#1
0
        internal void Backup()
        {
            try
            {
                if (!Directory.Exists(_backUpFolderPath))
                {
                    Directory.CreateDirectory(_backUpFolderPath);
                }
                BackupSteps steps = new BackupSteps();
                if (_session.LogLevel != LogLevelEnum.Current)
                {
                    BackupConfigFiles(steps, new List <ConfigItemInfo>(_session.SelectedEVLogs));
                    BackupConfigFiles(steps, new List <ConfigItemInfo>(_session.SelectedFileLogs));
                }
                BackupConfigFiles(steps, new List <ConfigItemInfo>(_session.SelectedTraces));
                SerialtionHelper <BackupSteps> .Serialize(steps, _xmlRestoreSteps);

                new Logger().WriteInfo("Backup Seccessfully.");
            }
            catch (Exception ex)
            {
                new Logger().WriteError($"Faild to backup:{ex.Message}");
                throw new Exception($"Faild to backup:{ex.Message}");
            }
        }
示例#2
0
        public void StartSession(SessionInfo session)
        {
            try
            {
                _currentSession = session;
                _currentSession.SessionOtputFolderPath = Path.Combine(SessionRootFolderPath,
                                                                      $"{_currentSession.SessionFolderPath}_open");
                System.IO.Directory.CreateDirectory($@"{_currentSession.SessionOtputFolderPath}");
                SerialtionHelper <SessionInfo> .Serialize(_currentSession,
                                                          $@"{_currentSession.SessionOtputFolderPath}\SessionInfo.xml");

                //session.Save();
                //Build session folder name yyyy-MM-dd-hh-mm_workflowName_open -done
                //Create the folder under this.SessionRootFolderPath - done
                //Save SessionInfo.xml - done
                //Crete backup (BackupHandler) - done
                new BackUpManager(_currentSession).Backup();
                //Open log levels (XmlHandler) - done
                //Open traces (XmlHanlder) - done
                new XmlHandler(_currentSession).ChangeConfig();
                //Restart processes (ProcessHandler) - done
                new ProcessHandler(_currentSession).RestartService();
                new Logger().WriteInfo("Starting new successfully.");
            }
            // catch non critic exeption
            catch (NonCriticalException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                new Logger().WriteError($"Faild to start session:{ex.Message}");
                throw new Exception($"Faild to start session:{ ex.Message}");
            }
        }
示例#3
0
        private void LoadWorkflows()
        {
            try
            {
                if (!Directory.Exists(WorkflowsRootFolder))
                {
                    Directory.CreateDirectory(WorkflowsRootFolder);
                }
                this.WorkflowsList = new List <WorkflowInfo>()
                {
                    new WorkflowInfo()
                };
                string[] Dir = Directory.GetFiles(WorkflowsRootFolder);
                foreach (var file in Dir)
                {
                    var workflowInfo = SerialtionHelper <WorkflowInfo> .Deserialize(file);

                    WorkflowsList.Add(workflowInfo);
                }
            }
            catch (Exception ex)
            {
                new Logger().WriteError($"Faild to load WorkFlows{ex.Message}");
                throw new Exception($"Faild to load WorkFlows{ex.Message}");
            }
        }
示例#4
0
        public bool CollectData(bool flag = false)
        {
            try
            {
                string from = _currentSession.From.ToString("yyyy-MM-dd-hh-mm");
                string to   = _currentSession.To.ToString("yyyy-MM-dd-hh-mm");
                string path = Path.Combine(_currentSession.SessionOtputFolderPath,
                                           "OutputData",
                                           $@"{from}_{to}");
                string zipFile = Path.Combine(_currentSession.SessionOtputFolderPath,
                                              "OutputData",
                                              $@"{_currentSession.WorkflowName}_{from}_{to}.zip");

                if (!Directory.Exists(path) || flag)
                {
                    if (flag)
                    {
                        File.Delete(zipFile);
                        Directory.Delete(path, true);
                    }
                    Directory.CreateDirectory(path);
                    //Create Output folder for this collect operation
                    //Collect Log events (EVLogHandler)
                    //new EVLogHandler(_currentSession).CollectData();
                    //Collect file logs (FileLogHandler)
                    //Collect traces (TraceHanler)
                    new FilesHandler(_currentSession).CollectData();
                    string name = new DirectoryInfo(path).Name;
                    if (!_currentSession.OutputDirNames.Contains(name))
                    {
                        _currentSession.OutputDirNames.Add(name);
                    }
                    new PackageHandler(_currentSession).Packaging();
                    SerialtionHelper <SessionInfo> .Serialize(_currentSession,
                                                              $@"{_currentSession.SessionOtputFolderPath}\SessionInfo.xml");
                }
                else
                {
                    return(false);
                }
                new Logger().WriteInfo("Collect data successfully.");
                return(true);
            }
            catch (Exception ex)
            {
                new Logger().WriteError($"Faild to Collect data:{ex.Message}");
                throw new Exception($"Faild to Collect data:{ex.Message}");
            }
        }
示例#5
0
        internal void Restore()
        {
            try
            {
                string[]    FilesName = Directory.GetFiles(this._backUpFolderPath);
                BackupSteps steps     = SerialtionHelper <BackupSteps> .Deserialize(_xmlRestoreSteps);

                for (int i = 0; i < steps.FilePath.Count; i++)
                {
                    File.Copy(Path.Combine(this._backUpFolderPath, steps.FileName[i]), steps.FilePath[i], true);
                }
                new Logger().WriteInfo("Restore files seccessfully.");
            }
            catch (Exception ex)
            {
                new Logger().WriteError($"faild to restore:{ex.Message}");
                throw new Exception($"faild to restore:{ex.Message}");
            }
        }