internal static void StartService() { Journal = new LogJournal(); try { var path = String.Format(Settings.Default.LogPathTemplate, DateTime.Now.ToString(CultureInfo.CurrentCulture).Replace('/', '_').Replace(':', '_')); if (!Path.IsPathRooted(path)) { path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, path); } Journal.Open(path, true, true); } catch (Exception ex) { LogCriticalErrorMessage(ex); return; } try { ms_ServiceHost = new ServiceHost(typeof(PrintingServer)); ms_ServiceHost.Open(); } catch (Exception ex) { Journal.AppendLog("SystemHost", LogJournalMessageType.Error, String.Format("Error starting network printing service: {0}", ex.Message)); return; } Journal.AppendLog("SystemHost", LogJournalMessageType.Info, String.Format("SCME Network printing service started on {0}", ms_ServiceHost.BaseAddresses.FirstOrDefault())); }
internal static void StartService() { Journal = new LogJournal(); try { var path = String.Format(Settings.Default.LogPathTemplate, DateTime.Now.ToString(CultureInfo.CurrentCulture).Replace('/', '_').Replace(':', '_')); if (!Path.IsPathRooted(path)) { path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, path); } Journal.Open(path, true, true); } catch (Exception ex) { LogCriticalErrorMessage(ex); return; } // try // { // SQLDatabaseService dbForMigration = new SQLDatabaseService(SQLCentralDatabaseService.GetConnectionStringFromSettings(Settings.Default)); // dbForMigration.Open(); // dbForMigration.Migrate(); // dbForMigration.Close(); // } // catch (Exception ex) // { // Journal.AppendLog("Central DB SQL SERVER migration", LogJournalMessageType.Error, String.Format("Migrate database error: {0}", ex.Message)); // return; // } try { var service = new SQLCentralDatabaseService(Settings.Default); ms_ServiceHost = new ServiceHost(service); var behaviour = ms_ServiceHost.Description.Behaviors.Find <ServiceBehaviorAttribute>(); behaviour.InstanceContextMode = InstanceContextMode.Single; ms_ServiceHost.Open(); } catch (Exception ex) { Journal.AppendLog("SystemHost", LogJournalMessageType.Error, $"Error starting database service: {ex.Message}"); return; } try { MSSQLDbService mssqlDbService; _databaseServiceHost = new ServiceHost(mssqlDbService = new MSSQLDbService(new SqlConnection(new SqlConnectionStringBuilder() { DataSource = Settings.Default.DbPath, InitialCatalog = Settings.Default.DBName, IntegratedSecurity = Settings.Default.DBIntegratedSecurity, UserID = Settings.Default.DBUser, Password = Settings.Default.DBPassword, ConnectTimeout = 5 }.ToString()), false)); var behaviour = _databaseServiceHost.Description.Behaviors.Find <ServiceBehaviorAttribute>(); behaviour.InstanceContextMode = InstanceContextMode.Single; mssqlDbService.Migrate(); _databaseServiceHost.Open(); } catch (Exception ex) { Journal.AppendLog("SystemHost", LogJournalMessageType.Error, $"Error starting database service: {ex?.InnerException?.ToString() ?? ex.ToString()}"); return; } Journal.AppendLog("SystemHost", LogJournalMessageType.Info, $"SCME database service started on {_databaseServiceHost.BaseAddresses.FirstOrDefault()}"); }