public void RunApplication(string[] args) { var commandLine = new CommandLine(); try { commandLine.Parse(args); } catch (Exception e) { Platform.Log(LogLevel.Info, e); Console.WriteLine(e.Message); commandLine.PrintUsage(Console.Out); Environment.Exit(-1); } try { DicomServer.DicomServer.UpdateConfiguration(new DicomServerConfiguration { HostName = commandLine.HostName, AETitle = commandLine.AETitle, Port = commandLine.Port }); } catch (Exception e) { Console.WriteLine(e.Message); Platform.Log(LogLevel.Warn, e); Environment.Exit(-1); } try { if (!String.IsNullOrEmpty(commandLine.FileStoreDirectory)) StudyStore.UpdateConfiguration(new StorageConfiguration { FileStoreDirectory = commandLine.FileStoreDirectory, MinimumFreeSpacePercent = commandLine.MinimumFreeSpacePercent != null ? double.Parse(commandLine.MinimumFreeSpacePercent) : StorageConfiguration.AutoMinimumFreeSpace }); } catch (Exception e) { Console.WriteLine(e.Message); Platform.Log(LogLevel.Warn, e); Environment.Exit(-1); } }
public void RunApplication(string[] args) { CommandLine cmdLine = new CommandLine(); try { cmdLine.Parse(args); if (cmdLine.Switches.ContainsKey("storedprocedures") && cmdLine.Switches["storedprocedures"]) { Console.WriteLine("Upgrading the stored procedures."); if (!RunEmbeddedScript("ClearCanvas.ImageServer.Model.SqlServer.Scripts.ImageServerStoredProcedures.sql")) Environment.ExitCode = -1; else Environment.ExitCode = 0; } if (cmdLine.Switches.ContainsKey("defaultdata") && cmdLine.Switches["defaultdata"]) { Console.WriteLine("Upgrading the stored procedures."); if (!RunEmbeddedScript("ClearCanvas.ImageServer.Model.SqlServer.Scripts.ImageServerDefaultData.sql")) Environment.ExitCode = -1; else Environment.ExitCode = 0; } foreach (string script in cmdLine.Positional) { if (!RunScript(script)) { Console.WriteLine("Upgrading to execute script: {0}", script); Environment.ExitCode = -1; return; } } } catch (CommandLineException e) { Console.WriteLine(e.Message); cmdLine.PrintUsage(Console.Out); Environment.ExitCode = -1; } catch (Exception e) { Console.WriteLine("Unexpected exception when executing script: {0}", e.Message); Environment.ExitCode = -1; } }
public void RunApplication(string[] args) { var cmdLine = new CommandLine(); try { cmdLine.Parse(args); var persistentStoreVersion = LoadPersistentStoreVersion(); var assemblyVersion = LoadAssemblyVersion(); if (cmdLine.Switches.ContainsKey("check") && cmdLine.Switches["check"]) { CheckPersistentStoreStatus(persistentStoreVersion, assemblyVersion); return; } Console.WriteLine("The current database version is {0} and assembly version is {1}", persistentStoreVersion.ToString(4), assemblyVersion.ToString(4)); if (persistentStoreVersion.Equals(assemblyVersion)) { Console.WriteLine("Database version is up-to-date."); Environment.ExitCode = 0; return; } if (!UpdatePersistentStore(persistentStoreVersion, assemblyVersion)) Environment.ExitCode = -1; else { Environment.ExitCode = 0; } } catch (CommandLineException e) { Console.WriteLine(e.Message); cmdLine.PrintUsage(Console.Out); Environment.ExitCode = -1; } catch (Exception e) { Console.WriteLine("Unexpected exception when upgrading database: {0}", e.Message); Environment.ExitCode = -1; } }
public void RunApplication(string[] args) { var cmd = new CommandLine(); try { cmd.Parse(args); } catch (Exception) { cmd.PrintUsage(Console.Out); Environment.Exit(-1); } //Hack to redirect local shared settings to a different exe's config file. ExtendedLocalFileSettingsProvider.ExeConfigFileName = cmd.Target; foreach (var settingsClass in _applicationSettingsClasses) { var settingsType = Type.GetType(settingsClass); SettingsMigrator.MigrateSharedSettings(settingsType, cmd.Source); } try { if (!String.IsNullOrEmpty(cmd.DicomServersFileName) && File.Exists(cmd.DicomServersFileName)) { var existingServerTree = new ServerTree.ServerTree(); if (existingServerTree.RootServerGroup.GetAllServers().Count == 0) { //Settings NOT from an old xml file were just migrated, so //if there's still no servers defined, import from old xml file. var serverTree = new ServerTree.ServerTree(cmd.DicomServersFileName); serverTree.Save(); } } } catch (Exception e) { Platform.Log(LogLevel.Warn, e, "Failed to import legacy server tree '{0}'.", cmd.DicomServersFileName); } }