public static bool TurnOn(EngineOptions options) { StartTimer = Stopwatch.StartNew(); DebugHelper.WriteLine(""); DebugHelper.WriteLine(string.Format("{0} r{1} started", GetProductName(), Adapter.AppRevision)); DebugHelper.WriteLine("Operating system: " + Environment.OSVersion.VersionString); Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); DialogResult startEngine = DialogResult.OK; if (IsPortable) { ConfigApp.PreferSystemFolders = false; RootAppFolder = PortableRootFolder; } else { if (options.ShowConfigWizard && !File.Exists(AppSettings.AppSettingsFile)) { if (ConfigWorkflow == null) { ConfigWorkflow = Workflow.Read(Engine.WorkflowConfigPath); } ConfigWizard cw = new ConfigWizard(DocsAppFolder); startEngine = cw.ShowDialog(); if (startEngine == DialogResult.OK) { if (!cw.PreferSystemFolders) { Engine.ConfigApp.RootDir = cw.RootFolder; } Engine.ConfigApp.PreferSystemFolders = cw.PreferSystemFolders; Engine.ConfigApp.AppOutputs = cw.cwOutputs.Cast<int>().ToList(); Engine.ConfigApp.ClipboardContent = cw.cwClipboardContent.Cast<int>().ToList(); Engine.ConfigApp.ImageUploaders = cw.cwImageUploaders; Engine.ConfigApp.FileUploaders = cw.cwFileUploaders; Engine.ConfigApp.TextUploaders = cw.cwTextUploaders; Engine.ConfigApp.LinkUploaders = cw.cwLinkUploaders; ConfigWorkflow.Write(WorkflowConfigPath); // DestSelector in ConfigWizard automatically initializes MyUploadersConfig if null so no errors RunConfig = true; } } } ConfigApp.Write(); if (!ConfigApp.PreferSystemFolders && Directory.Exists(Engine.ConfigApp.RootDir)) { RootAppFolder = Engine.ConfigApp.RootDir; } else if (!IsPortable) // issue 613 { RootAppFolder = DocsAppFolder; } if (startEngine == DialogResult.OK) { DebugHelper.WriteLine("Core file: " + AppSettings.AppSettingsFile); if (!ConfigApp.PreferSystemFolders) { DebugHelper.WriteLine(string.Format("Root Folder: {0}", RootAppFolder)); } DebugHelper.WriteLine("Initializing Default folder paths..."); Engine.InitializeDefaultFolderPaths(); // happens before XMLSettings is readed bool bGrantedOwnership; try { Guid assemblyGuid = Guid.Empty; object[] assemblyObjects = System.Reflection.Assembly.GetEntryAssembly().GetCustomAttributes(typeof(System.Runtime.InteropServices.GuidAttribute), true); if (assemblyObjects.Length > 0) { assemblyGuid = new Guid(((System.Runtime.InteropServices.GuidAttribute)assemblyObjects[0]).Value); } Engine.mAppMutex = new Mutex(true, assemblyGuid.ToString(), out bGrantedOwnership); } catch (UnauthorizedAccessException) { bGrantedOwnership = false; } if (!bGrantedOwnership) { IsMultiInstance = true; } } return startEngine == DialogResult.OK; }
public static bool TurnOn(EngineOptions options) { StartTimer = Stopwatch.StartNew(); DebugHelper.WriteLine(""); DebugHelper.WriteLine(string.Format("{0} r{1} started", GetProductName(), Adapter.AppRevision)); DebugHelper.WriteLine("Operating system: " + Environment.OSVersion.VersionString); Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); DialogResult startEngine = DialogResult.OK; if (IsPortable) { ConfigApp.PreferSystemFolders = false; RootAppFolder = PortableRootFolder; } else { if (options.ShowConfigWizard && !File.Exists(AppSettings.AppSettingsFile)) { if (ConfigWorkflow == null) { ConfigWorkflow = Workflow.Read(Engine.WorkflowConfigPath); } ConfigWizard cw = new ConfigWizard(DocsAppFolder); startEngine = cw.ShowDialog(); if (startEngine == DialogResult.OK) { if (!cw.PreferSystemFolders) { Engine.ConfigApp.RootDir = cw.RootFolder; } Engine.ConfigApp.PreferSystemFolders = cw.PreferSystemFolders; Engine.ConfigApp.AppOutputs = cw.cwOutputs.Cast <int>().ToList(); Engine.ConfigApp.ClipboardContent = cw.cwClipboardContent.Cast <int>().ToList(); Engine.ConfigApp.ImageUploaders = cw.cwImageUploaders; Engine.ConfigApp.FileUploaders = cw.cwFileUploaders; Engine.ConfigApp.TextUploaders = cw.cwTextUploaders; Engine.ConfigApp.LinkUploaders = cw.cwLinkUploaders; ConfigWorkflow.Write(WorkflowConfigPath); // DestSelector in ConfigWizard automatically initializes MyUploadersConfig if null so no errors RunConfig = true; } } } ConfigApp.Write(); if (!ConfigApp.PreferSystemFolders && Directory.Exists(Engine.ConfigApp.RootDir)) { RootAppFolder = Engine.ConfigApp.RootDir; } else if (!IsPortable) // issue 613 { RootAppFolder = DocsAppFolder; } if (startEngine == DialogResult.OK) { DebugHelper.WriteLine("Core file: " + AppSettings.AppSettingsFile); if (!ConfigApp.PreferSystemFolders) { DebugHelper.WriteLine(string.Format("Root Folder: {0}", RootAppFolder)); } DebugHelper.WriteLine("Initializing Default folder paths..."); Engine.InitializeDefaultFolderPaths(); // happens before XMLSettings is readed bool bGrantedOwnership; try { Guid assemblyGuid = Guid.Empty; object[] assemblyObjects = System.Reflection.Assembly.GetEntryAssembly().GetCustomAttributes(typeof(System.Runtime.InteropServices.GuidAttribute), true); if (assemblyObjects.Length > 0) { assemblyGuid = new Guid(((System.Runtime.InteropServices.GuidAttribute)assemblyObjects[0]).Value); } Engine.mAppMutex = new Mutex(true, assemblyGuid.ToString(), out bGrantedOwnership); } catch (UnauthorizedAccessException) { bGrantedOwnership = false; } if (!bGrantedOwnership) { IsMultiInstance = true; } } return(startEngine == DialogResult.OK); }