Example #1
0
        /// <summary>
        /// Saves the created map and run data to the appropriate directory, confirms successful run of the algorithm
        /// </summary>
        /// <param name="started"></param>
        /// <param name="finished"></param>
        /// <param name="resourceUsageFileName"></param>
        protected void ConfirmRunFinished(DateTime started, DateTime finished, string resourceUsageFileName)
        {
            var    mapper  = this as IMapper;
            string mapPath = Path.Combine(DirectoryHelper.GetDataFolderPath(), mapper?.MapFileName ?? throw new InvalidOperationException());
            var    mapData = Parser.ParseMap(mapPath);

            string documentsPath = Path.Combine(
                DirectoryHelper.GetUserDocumentsFolder(),
                Path.GetFileNameWithoutExtension(resourceUsageFileName));

            string currFileLocation    = Path.Combine(DirectoryHelper.GetResourceMonitorsPath(), resourceUsageFileName);
            string destinationLocation = Path.Combine(documentsPath, resourceUsageFileName);

            DirectoryHelper.CreateDirectoryIfNotExists(documentsPath);

            File.Copy(currFileLocation, destinationLocation);
            SaveMap(mapData, started, finished, documentsPath);
            LogRun(resourceUsageFileName);
        }