示例#1
0
 private static void LogMessageAndExit(Exception ex)
 {
     // Since we can't prevent the app from terminating, log this to the event log.
     Logging.Fatal(ex, ErrorMsg);
     if (VixenSystem.IsSaving())
     {
         Logging.Fatal("Save was in progress during the fatal crash. Trying to pause 5 seconds to give it a chance to complete.");
         Thread.Sleep(5000);
     }
     if (_app != null)
     {
         _app.RemoveLockFile();
     }
     else
     {
         //try the failsafe to clean up the lock file.
         VixenApplication.RemoveLockFile(LockFilePath);
     }
     Environment.Exit(1);
 }
示例#2
0
        private async void VixenApp_FormClosing(object sender, FormClosingEventArgs e)
        {
            // close all open editors
            foreach (IEditorUserInterface editor in _openEditors.ToArray())
            {
                editor.CloseEditor();
            }

            while (VixenSystem.IsSaving())
            {
                Logging.Warn("Waiting for save to finish before closing.");
                Thread.Sleep(250);
            }

            stopping = true;
            await VixenSystem.Stop(false);

            _applicationData.SaveData();
            RemoveLockFile(LockFilePath);

            Application.Exit();
        }
示例#3
0
        private void watcher_FileSystemChanges(object sender, FileSystemEventArgs e)
        {
            Task.Factory.StartNew(() =>
            {
                try
                {
                    lock (fileLockObject)
                    {
                        //Wait for the file to fully save...
                        Thread.Sleep(1000);
                        while (VixenSystem.IsSaving())
                        {
                            Thread.Sleep(1);
                        }
                        Git git = new Git(_repo);

                        var status = git.Status().Call();

                        var changed = status.GetAdded().Count > 0 || status.GetChanged().Count > 0 || status.GetModified().Count > 0 ||
                                      status.GetRemoved().Count > 0 || status.GetUntracked().Count > 0 || status.GetMissing().Count > 0;

                        if (status.GetAdded().Count > 0 || status.GetUntracked().Count > 0 || status.GetModified().Count > 0 ||
                            status.GetChanged().Count > 0)
                        {
                            var add = git.Add();
                            status.GetAdded().ToList().ForEach(a =>
                            {
                                add.AddFilepattern(a);
                            });

                            status.GetModified().ToList().ForEach(a =>
                            {
                                add.AddFilepattern(a);
                            });

                            status.GetChanged().ToList().ForEach(a =>
                            {
                                add.AddFilepattern(a);
                            });

                            status.GetUntracked().ToList().ForEach(a =>
                            {
                                add.AddFilepattern(a);
                            });

                            add.Call();
                        }


                        if (status.GetMissing().Count > 0 || status.GetRemoved().Count > 0)
                        {
                            var removed = git.Rm();

                            status.GetRemoved().ToList().ForEach(a =>
                            {
                                removed.AddFilepattern(a);
                            });

                            status.GetMissing().ToList().ForEach(a =>
                            {
                                removed.AddFilepattern(a);
                            });

                            removed.Call();
                        }

                        if (changed)
                        {
                            git.Commit().SetMessage($"Profile changes {(restoringFile ? "restored." : "commited.")}").Call();
                        }
                    }
                }
                catch (Exception ex)
                {
                    Logging.Error(ex, ex.Message);
                }

                restoringFile = false;
            });
        }