ExecuteWork() 공개 메소드

Performs the job as a background task
public ExecuteWork ( ) : void
리턴 void
        /// <summary>
        ///     Compares the files
        /// </summary>
        public override void ExecuteWork()
        {
            // Open the dictionary but do not store it in the EFS System
            const bool allowErrors = true;
            OpenFileOperation openFileOperation = new OpenFileOperation(OtherFilePath, null, allowErrors, false);
            openFileOperation.ExecuteWork();

            // Compare the files
            if (openFileOperation.Dictionary != null)
            {
                VersionDiff versionDiff = new VersionDiff();
                Comparer.ensureGuidDictionary(Dictionary, openFileOperation.Dictionary);
                Comparer.compareDictionary(Dictionary, openFileOperation.Dictionary, versionDiff);
                versionDiff.MarkVersionChanges(Dictionary);
            }
            else
            {
                MessageBox.Show("Cannot open file, please see log file (GUI.Log) for more information",
                    "Cannot open file", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #2
0
        /// <summary>
        ///     Compares the files
        /// </summary>
        public override void ExecuteWork()
        {
            // Open the dictionary but do not store it in the EFS System
            const bool        allowErrors       = true;
            OpenFileOperation openFileOperation = new OpenFileOperation(OtherFilePath, null, allowErrors, false);

            openFileOperation.ExecuteWork();

            // Compare the files
            if (openFileOperation.Dictionary != null)
            {
                VersionDiff versionDiff = new VersionDiff();
                Comparer.ensureGuidDictionary(Dictionary, openFileOperation.Dictionary);
                Comparer.compareDictionary(Dictionary, openFileOperation.Dictionary, versionDiff);
                versionDiff.MarkVersionChanges(Dictionary);
            }
            else
            {
                MessageBox.Show("Cannot open file, please see log file (GUI.Log) for more information",
                                "Cannot open file", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #3
0
        /// <summary>
        ///     Retrieves a specific version of a data dictionary
        /// </summary>
        /// <param name="commit">The specific version to be found</param>
        /// <returns>The specific version of the dictionary provided as parameter</returns>
        protected Dictionary DictionaryByVersion(Commit commit)
        {
            Dictionary retVal = null;

            if (commit != null)
            {
                string workingDir = Path.GetDirectoryName(Dictionary.FilePath);

                // Create the temp directory to store alternate version of the subset file
                string tempDirectory = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
                Directory.CreateDirectory(tempDirectory);
                try
                {
                    // Retrieve the archive of the selected version

                    ProcessStartInfo processStartInfo = new ProcessStartInfo
                    {
                        WorkingDirectory = workingDir,
                        FileName         = "git",
                        Arguments        = "archive -o " + tempDirectory + "\\specs.zip " + commit.Id.Sha + " .",
                        CreateNoWindow   = true,
                        WindowStyle      = ProcessWindowStyle.Hidden
                    };
                    Process myProcess = Process.Start(processStartInfo);
                    myProcess.WaitForExit();
                }
                catch (Exception exception)
                {
                    MessageBox.Show(
                        "Exception raised during operation " + exception.Message +
                        "\nPlease make sure that git is available in your path",
                        "Cannot perform operation", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                try
                {
                    // Unzip the archive
                    FastZip zip = new FastZip();
                    zip.ExtractZip(tempDirectory + "\\specs.zip", tempDirectory, null);
                }
                catch (Exception exception)
                {
                    MessageBox.Show("Exception raised during operation " + exception.Message, "Cannot perform operation",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                try
                {
                    // Open the dictionary but do not store it in the EFS System
                    const bool        allowErrors       = true;
                    const bool        updateGuid        = false;
                    OpenFileOperation openFileOperation =
                        new OpenFileOperation(tempDirectory + Path.DirectorySeparatorChar + DictionaryFileName, null,
                                              allowErrors, updateGuid)
                    {
                        PleaseLockFiles = false
                    };
                    openFileOperation.ExecuteWork();
                    retVal = openFileOperation.Dictionary;
                }
                catch (Exception exception)
                {
                    MessageBox.Show("Exception raised during operation " + exception.Message, "Cannot perform operation",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                try
                {
                    Directory.Delete(tempDirectory, true);
                }
                catch (Exception exception2)
                {
                    MessageBox.Show("Exception raised during operation " + exception2.Message,
                                    "Cannot perform operation", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            return(retVal);
        }
        /// <summary>
        ///     Retrieves a specific version of a data dictionary
        /// </summary>
        /// <param name="commit">The specific version to be found</param>
        /// <returns>The specific version of the dictionary provided as parameter</returns>
        protected Dictionary DictionaryByVersion(Commit commit)
        {
            Dictionary retVal = null;

            if (commit != null)
            {
                string workingDir = Path.GetDirectoryName(Dictionary.FilePath);

                // Create the temp directory to store alternate version of the subset file
                string tempDirectory = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
                Directory.CreateDirectory(tempDirectory);
                try
                {
                    // Retrieve the archive of the selected version

                    ProcessStartInfo processStartInfo = new ProcessStartInfo
                    {
                        WorkingDirectory = workingDir,
                        FileName = "git",
                        Arguments = "archive -o " + tempDirectory + "\\specs.zip " + commit.Id.Sha + " .",
                        CreateNoWindow = true,
                        WindowStyle = ProcessWindowStyle.Hidden
                    };
                    Process myProcess = Process.Start(processStartInfo);
                    myProcess.WaitForExit();
                }
                catch (Exception exception)
                {
                    MessageBox.Show(
                        "Exception raised during operation " + exception.Message +
                        "\nPlease make sure that git is available in your path",
                        "Cannot perform operation", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                try
                {
                    // Unzip the archive
                    FastZip zip = new FastZip();
                    zip.ExtractZip(tempDirectory + "\\specs.zip", tempDirectory, null);
                }
                catch (Exception exception)
                {
                    MessageBox.Show("Exception raised during operation " + exception.Message, "Cannot perform operation",
                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                try
                {
                    // Open the dictionary but do not store it in the EFS System
                    const bool allowErrors = true;
                    const bool updateGuid = false;
                    OpenFileOperation openFileOperation =
                        new OpenFileOperation(tempDirectory + Path.DirectorySeparatorChar + DictionaryFileName, null,
                            allowErrors, updateGuid) {PleaseLockFiles = false};
                    openFileOperation.ExecuteWork();
                    retVal = openFileOperation.Dictionary;
                }
                catch (Exception exception)
                {
                    MessageBox.Show("Exception raised during operation " + exception.Message, "Cannot perform operation",
                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                try
                {
                    Directory.Delete(tempDirectory, true);
                }
                catch (Exception exception2)
                {
                    MessageBox.Show("Exception raised during operation " + exception2.Message,
                        "Cannot perform operation", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            return retVal;
        }