/// <summary> /// Constructs the requestRepository /// </summary> /// <param name="dbName"></param> /// <param name="dbPassword"></param> /// <param name="dbServerName"></param> /// <param name="isLocalTest"></param> public RequestRepository(IOdinContextFactory contextFactory) { if (contextFactory == null) { throw new ArgumentNullException("contextFactory"); } this.contextFactory = contextFactory; }
public static void WireUp() { ErrorLog.CreateFolder(); try { ConnectionManager connectionManager = new ConnectionManager(Odin.Properties.Settings.Default.DbServerName, Odin.Properties.Settings.Default.DbName); // ConnectionManager connectionManager = new ConnectionManager(@"(local)\SQLExpress", "Odin"); // connectionManager.SetUseTrustedConnection(true); connectionManager.SetUseTrustedConnection(false); connectionManager.SetPassword(Odin.Properties.Settings.Default.DbPassword); LogServiceFactory logServiceFactory = new LogServiceFactory("Odin"); OdinContextFactory = new OdinContextFactory(connectionManager, logServiceFactory); OdinContext context = OdinContextFactory.CreateContext(); if (!context.Database.Exists()) { DbSettingsView window = new DbSettingsView() { DataContext = new DbSettingsViewModel() }; window.ShowDialog(); OdinContextFactory.CreateContext(); } WorkbookReader = new WorkbookReader(); ItemRepository = new ItemRepository(OdinContextFactory); OptionRepository = new OptionRepository(OdinContextFactory); RequestRepository = new RequestRepository(OdinContextFactory); TemplateRepository = new TemplateRepository(OdinContextFactory); ItemService = new ItemService(WorkbookReader, ItemRepository, TemplateRepository); OptionService = new OptionService(OptionRepository, RequestRepository); ExcelService = new ExcelService(false, ItemService, OptionService, TemplateRepository, RequestRepository); EmailService = new EmailService(OptionService); } catch (Exception e) { // MessageBox.Show(e.ToString()); ErrorLog.LogError("Odin encountered an error with the database.", e.ToString()); Environment.Exit(1); } }
/// <summary> /// Constructs a Template Repository /// </summary> public TemplateRepository(IOdinContextFactory contextFactory) { this.contextFactory = contextFactory ?? throw new ArgumentNullException("contextFactory"); GlobalData.TemplateNames = RetrieveTemplateNameList(); }
/// <summary> /// Constructs the option repository /// </summary> /// <param name="dbName"></param> /// <param name="dbPassword"></param> /// <param name="dbServerName"></param> /// <param name="isLocalTest"></param> public OptionRepository(IOdinContextFactory contextFactory) { this.contextFactory = contextFactory ?? throw new ArgumentNullException("contextFactory"); GlobalData.NotificationNumber = RetrieveCurrentNotificationNumber(); }