Ejemplo n.º 1
0
        private static void backupAllFiles(WhamoFilesInformation filesInfo)
        {
            if (File.Exists(filesInfo.OutFilePath))
            {
                File.Copy(filesInfo.OutFilePath, filesInfo.SafeCopyOutFilePath, true);
                File.Delete(filesInfo.OutFilePath);
            }

            if (File.Exists(filesInfo.TabFilePath))
            {
                File.Copy(filesInfo.TabFilePath, filesInfo.SafeCopyTabFilePath, true);
                File.Delete(filesInfo.TabFilePath);
            }

            if (File.Exists(filesInfo.PltFilePath))
            {
                File.Copy(filesInfo.PltFilePath, filesInfo.SafeCopyPltFilePath, true);
                File.Delete(filesInfo.PltFilePath);
            }

            if (File.Exists(filesInfo.ProcessedOutFilePath))
            {
                File.Copy(filesInfo.ProcessedOutFilePath, filesInfo.SafeProcessedOutFilePath, true);
                File.Delete(filesInfo.ProcessedOutFilePath);
            }
        }
Ejemplo n.º 2
0
 private static void deleteLocalWhamoExecutable(WhamoFilesInformation filesInfo)
 {
     if (File.Exists(filesInfo.LocalWhamoPath))
     {
         File.Delete(filesInfo.LocalWhamoPath);
     }
 }
Ejemplo n.º 3
0
        private static void deleteAllBackupFiles(WhamoFilesInformation filesInfo)
        {
            if (File.Exists(filesInfo.SafeCopyOutFilePath))
            {
                File.Delete(filesInfo.SafeCopyOutFilePath);
            }

            if (File.Exists(filesInfo.SafeCopyTabFilePath))
            {
                File.Delete(filesInfo.SafeCopyTabFilePath);
            }

            if (File.Exists(filesInfo.SafeCopyPltFilePath))
            {
                File.Delete(filesInfo.SafeCopyPltFilePath);
            }

            if (File.Exists(filesInfo.SafeCopyOutFilePath))
            {
                File.Delete(filesInfo.SafeCopyOutFilePath);
            }

            if (File.Exists(filesInfo.SafeProcessedOutFilePath))
            {
                File.Delete(filesInfo.SafeProcessedOutFilePath);
            }
        }
Ejemplo n.º 4
0
        private static bool copyLocalWhamoExecutable(WhamoFilesInformation filesInfo)
        {
            if (!File.Exists(filesInfo.LocalWhamoPath))
            {
                ThirdPartyResourcesProvider.CopyWhamoExecutableTo(filesInfo.LocalWhamoPath);
                return(true);
            }

            return(false);
        }
Ejemplo n.º 5
0
 private static void processWhamoOutFile(WhamoFilesInformation filesInfo)
 {
     using (var reader = new OutFileReader(filesInfo.OutFilePath))
     {
         using (var writer = new ProcessedDataFileWriter(filesInfo.ProcessedOutFilePath))
         {
             writer.Write(reader.ProcessOutputData());
         }
     }
 }
Ejemplo n.º 6
0
        private static void executeWhamo(WhamoFilesInformation filesInfo)
        {
            var startInfo = new ProcessStartInfo(filesInfo.LocalWhamoPath);

            startInfo.WorkingDirectory      = Path.GetDirectoryName(filesInfo.WhamoInputFilePath);
            startInfo.RedirectStandardInput = true;
            startInfo.UseShellExecute       = false;
            var whamo = Process.Start(startInfo);

            whamo.StandardInput.WriteLine(Path.GetFileNameWithoutExtension(filesInfo.WhamoInputFilePath));
            whamo.StandardInput.WriteLine(); //Confirm .out file
            whamo.StandardInput.WriteLine(); //Confirm .plt file
            whamo.StandardInput.WriteLine(); //Confirm .tab file
            whamo.CloseMainWindow();
            whamo.WaitForExit();
        }
Ejemplo n.º 7
0
        public static void Launch(string whamoInputFilePath)
        {
            if (whamoInputFilePath == null)
            {
                throw new ArgumentNullException("inputFilePath");
            }

            if (!File.Exists(whamoInputFilePath))
            {
                throw new ArgumentException(string.Format(Strings.InputFileNotFoundError, whamoInputFilePath), "inputFilePath");
            }

            var canDeleteSafeCopies        = false;
            var localWhamoExecutableCopied = false;
            var filesInfo = new WhamoFilesInformation(whamoInputFilePath);

            try
            {
                localWhamoExecutableCopied = copyLocalWhamoExecutable(filesInfo);
                backupAllFiles(filesInfo);
                executeWhamo(filesInfo);
                canDeleteSafeCopies = true;
                processWhamoOutFile(filesInfo);
            }
            catch
            {
                rollBackAllFileChanges(filesInfo);
                canDeleteSafeCopies = true;
                throw;
            }
            finally
            {
                if (canDeleteSafeCopies)
                {
                    deleteAllBackupFiles(filesInfo);
                }

                if (localWhamoExecutableCopied)
                {
                    deleteLocalWhamoExecutable(filesInfo);
                }
            }
        }
Ejemplo n.º 8
0
        private static void rollBackAllFileChanges(WhamoFilesInformation filesInfo)
        {
            if (File.Exists(filesInfo.SafeCopyPltFilePath))
            {
                File.Copy(filesInfo.SafeCopyPltFilePath, filesInfo.PltFilePath, true);
            }

            if (File.Exists(filesInfo.SafeCopyTabFilePath))
            {
                File.Copy(filesInfo.SafeCopyTabFilePath, filesInfo.TabFilePath, true);
            }

            if (File.Exists(filesInfo.SafeCopyOutFilePath))
            {
                File.Copy(filesInfo.SafeCopyOutFilePath, filesInfo.OutFilePath, true);
            }

            if (File.Exists(filesInfo.SafeProcessedOutFilePath))
            {
                File.Copy(filesInfo.SafeProcessedOutFilePath, filesInfo.ProcessedOutFilePath, true);
            }
        }