/// <summary> /// Handles the change of a dictionary on the file system /// </summary> /// <param name="dictionary"></param> private static void HandleInstanceDictionaryChangesOnFileSystem(Dictionary dictionary) { OpenFileOperation openFile = new OpenFileOperation(dictionary.FilePath, EfsSystem.Instance, false, true); openFile.ExecuteUsingProgressDialog("Refreshing dictionary " + Path.GetFileNameWithoutExtension(dictionary.FilePath), false); RefreshModel.Execute(); }
/// <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); } }
/// <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; }
private static void Main(string[] args) { try { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); XmlConfigurator.Configure(new FileInfo("logconfig.xml")); Options.Options.SetSettings(); EfsSystem.Instance.DictionaryChangesOnFileSystem += HandleInstanceDictionaryChangesOnFileSystem; MainWindow window = new MainWindow(); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; { // TRICKY SECTION // This thread is mandatory otherwise WCF does not create a new thread to handle the service requests. // Since the call to Cycle is blocking, creating such threads is mandatory Thread thread = ThreadUtil.CreateThread("EFS Service", HostEfsService); thread.Start(); } // Opens the Dictionary files and check them bool shouldPlace = true; foreach (string fileName in args) { const bool allowErrors = false; OpenFileOperation openFileOperation = new OpenFileOperation(fileName, EfsSystem.Instance, allowErrors, true); openFileOperation.ExecuteUsingProgressDialog("Opening file", false); window.SetupWindows(openFileOperation.Dictionary, shouldPlace); shouldPlace = false; } CheckModelOperation checkModel = new CheckModelOperation(); checkModel.ExecuteUsingProgressDialog("Checking model"); Application.Run(window); CloseEfsService(); } finally { Util.UnlockAllFiles(); } EfsSystem.Instance.Stop(); SynchronizerList.Stop(); }