예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cpObject"></param>
        /// <param name="pathes"></param>
        /// <returns></returns>
        public (bool isError, string errorMessage) SaveCheckPointObjectsToFile(AnalyseObject cpObject, IEnumerable <string> pathes)
        {
            bool   isError      = false;
            string errorMessage = string.Empty;

            //Empty file is not saved
            if (!pathes.Any())
            {
                return(isError, errorMessage);
            }

            try
            {
                string folder = Directory.GetCurrentDirectory() + FolderPath;
                if (!Directory.Exists(folder))
                {
                    Directory.CreateDirectory(folder);
                }

                string file = GetCheckPointFileFullName(cpObject.Type, cpObject.Name, folder);
                File.WriteAllLines(file, pathes);
            }
            catch (Exception ex)
            {
                isError      = true;
                errorMessage = ex.GetFullMessage();
            }

            return(isError, errorMessage);
        }
예제 #2
0
 public void AddWithSortAnalysedRegistry(AnalyseObject obj)
 {
     AnalysedRegistries.Add(obj);
     AnalysedRegistries.Sort(f => f);
 }
예제 #3
0
 public void AddWithSortAnalysedFolder(AnalyseObject obj)
 {
     AnalysedFolders.Add(obj);
     AnalysedFolders.Sort(f => f);
 }
예제 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cpObject"></param>
        /// <returns></returns>
        public (IEnumerable <string> pathes, bool isError, string errorMessage) GetCheckPointObjectPathes(AnalyseObject cpObject)
        {
            bool          isError      = false;
            string        errorMessage = string.Empty;
            List <string> pathes       = new List <string>();

            try
            {
                string file = GetCheckPointFileFullName(cpObject.Type, cpObject.Name);
                if (File.Exists(file))
                {
                    pathes = File.ReadAllLines(file).ToList();
                }

                //If the checkpoint disk matches with the location of the programs,
                //the checkpoint and settings files are added to the list of objects.
                if (cpObject.Type != AnalyseObjectType.Registry)
                {
                    var currentDirectory = Directory.GetCurrentDirectory();
                    if (cpObject.Name.FirstOrDefault() == currentDirectory.FirstOrDefault())
                    {
                        string folder = currentDirectory + FolderPath;
                        if (Directory.Exists(folder))
                        {
                            pathes.Add(folder + SettingsFile);

                            string[] files = Directory.GetFiles(folder, $"*{_checkPointFileExtension}");
                            foreach (string f in files)
                            {
                                pathes.Add(f);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                isError      = true;
                errorMessage = ex.GetFullMessage();
            }

            return(pathes, isError, errorMessage);
        }
예제 #5
0
 public AnalyseProcessActivity(AnalyseObject analyseObject)
 {
     AnalyseObject = analyseObject;
 }