public override void Execute() { ThreadExecuter threadExecuter = new ThreadExecuter() { subscribe = this.subscribe, Observers = observers, Scheduler = this.Scheduler }; Scheduler.Schedule(threadExecuter.Execute); }
public override void Execute() { ThreadExecuter threadExecuter = new ThreadExecuter() { Value = value, Observers = observers, XTime = xtime, Scheduler = this.Scheduler }; Scheduler.Schedule(threadExecuter.Execute); }
public override void Execute() { ThreadExecuter <T> threadExecuter = new ThreadExecuter <T>() { Value = value, Observers = observers, RepeatCount = repeatCount, RepeatEndless = repeatEndless, Scheduler = this.Scheduler }; Scheduler.Schedule(threadExecuter.Execute); }
public override void Execute() { ThreadExecuter threadExecuter = new ThreadExecuter() { Value = initValue, Observers = observers, Condition = condition, Iterate = iterate, ResultSelector = resultSelector, Scheduler = this.Scheduler }; Scheduler.Schedule(threadExecuter.Execute); }
public override void Execute() { try { threadExecuter = new ThreadExecuter <T>() { Value = this.value, Source = this.source, Accumulator = this.accumulator, Observers = observers, Scheduler = this.Scheduler }; Scheduler.Schedule(threadExecuter.StartExecute); subject.Execute(); WaitHandle.WaitAll(new WaitHandle[] { threadExecuter.autoResetEvent }); NotifyObservers(threadExecuter.Value); } catch (Exception exception) { NotifyErrorObservers(exception); } }
private static void Main(string[] args) { if (Thread.CurrentThread.Name == null) { Thread.CurrentThread.Name = "Main"; } Logger.Info("Starting IA:GD.."); ExceptionReporter.UrlCrashreport = "http://ribbs.dreamcrash.org/iagd/crashreport.php"; ExceptionReporter.UrlStats = "http://ribbs.dreamcrash.org/iagd/stats.php"; #if !DEBUG ExceptionReporter.LogExceptions = true; #endif Logger.Info("Starting exception monitor for bug reports.."); // Phrased this way since people took it as a 'bad' thing. Logger.Debug("Crash reports can be seen at http://ribbs.dreamcrash.org/iagd/logs.html"); ExceptionReporter.EnableLogUnhandledOnThread(); #if DEBUG AzureUris.Initialize(AzureUris.EnvAzure); //AzureUris.Initialize(AzureUris.EnvDev); #else AzureUris.Initialize(AzureUris.EnvAzure); #endif StartupService.Init(); #if DEBUG Test(); #endif // Prevent running in RELEASE mode by accident // And thus risking the live database #if !DEBUG if (Debugger.IsAttached) { Logger.Fatal("Debugger attached, please run in DEBUG mode"); return; } #endif //ParsingUIBackgroundWorker tmp = new ParsingUIBackgroundWorker(); ItemHtmlWriter.CopyMissingFiles(); Guid guid = new Guid("{F3693953-C090-4F93-86A2-B98AB96A9368}"); using (SingleInstance singleInstance = new SingleInstance(guid)) { if (singleInstance.IsFirstInstance) { Logger.Info("Calling run.."); singleInstance.ArgumentsReceived += singleInstance_ArgumentsReceived; singleInstance.ListenForArgumentsFromSuccessiveInstances(); using (ThreadExecuter threadExecuter = new ThreadExecuter()) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Logger.Info("Visual styles enabled.."); Run(args, threadExecuter); } } else { if (args != null && args.Length > 0) { singleInstance.PassArgumentsToFirstInstance(args); } else { singleInstance.PassArgumentsToFirstInstance(new string[] { "--ignore" }); } } } Logger.Info("IA Exited"); LogManager.Shutdown(); }
private static void Run(string[] args, ThreadExecuter threadExecuter) { var factory = new SessionFactory(); // Settings should be upgraded early, it contains the language pack etc and some services depends on settings. var settingsService = StartupService.LoadSettingsService(); IPlayerItemDao playerItemDao = new PlayerItemRepo(threadExecuter, factory); IDatabaseItemDao databaseItemDao = new DatabaseItemRepo(threadExecuter, factory); RuntimeSettings.InitializeLanguage(settingsService.GetLocal().LocalizationFile, databaseItemDao.GetTagDictionary()); DumpTranslationTemplate(); threadExecuter.Execute(() => new MigrationHandler(factory).Migrate()); IDatabaseSettingDao databaseSettingDao = new DatabaseSettingRepo(threadExecuter, factory); LoadUuid(databaseSettingDao); var azurePartitionDao = new AzurePartitionRepo(threadExecuter, factory); IDatabaseItemStatDao databaseItemStatDao = new DatabaseItemStatRepo(threadExecuter, factory); IItemTagDao itemTagDao = new ItemTagRepo(threadExecuter, factory); IBuddyItemDao buddyItemDao = new BuddyItemRepo(threadExecuter, factory); IBuddySubscriptionDao buddySubscriptionDao = new BuddySubscriptionRepo(threadExecuter, factory); IRecipeItemDao recipeItemDao = new RecipeItemRepo(threadExecuter, factory); IItemSkillDao itemSkillDao = new ItemSkillRepo(threadExecuter, factory); AugmentationItemRepo augmentationItemRepo = new AugmentationItemRepo(threadExecuter, factory, new DatabaseItemStatDaoImpl(factory)); var grimDawnDetector = new GrimDawnDetector(settingsService); Logger.Debug("Updating augment state.."); augmentationItemRepo.UpdateState(); // TODO: GD Path has to be an input param, as does potentially mods. ParsingService parsingService = new ParsingService(itemTagDao, null, databaseItemDao, databaseItemStatDao, itemSkillDao, settingsService.GetLocal().LocalizationFile); StartupService.PrintStartupInfo(factory, settingsService); if (RuntimeSettings.Language is EnglishLanguage language) { foreach (var tag in itemTagDao.GetClassItemTags()) { language.SetTagIfMissing(tag.Tag, tag.Name); } } if (args != null && args.Any(m => m.Contains("-logout"))) { Logger.Info("Started with -logout specified, logging out of online backups."); settingsService.GetPersistent().AzureAuthToken = null; } using (CefBrowserHandler browser = new CefBrowserHandler()) { _mw = new MainWindow(browser, databaseItemDao, databaseItemStatDao, playerItemDao, azurePartitionDao, databaseSettingDao, buddyItemDao, buddySubscriptionDao, recipeItemDao, itemSkillDao, itemTagDao, parsingService, augmentationItemRepo, settingsService, grimDawnDetector ); Logger.Info("Checking for database updates.."); StartupService.PerformIconCheck(databaseSettingDao, grimDawnDetector); playerItemDao.DeleteDuplidates(); _mw.Visible = false; if (new DonateNagScreen(settingsService).CanNag) { Application.Run(new DonateNagScreen(settingsService)); } Logger.Info("Running the main application.."); StartupService.PerformGrimUpdateCheck(settingsService); Application.Run(_mw); } Logger.Info("Application ended."); }
public static ServiceProvider Initialize(ThreadExecuter threadExecuter, SqlDialect dialect) { Logger.Debug("Creating services"); var factory = new SessionFactory(dialect); // Settings should be upgraded early, it contains the language pack etc and some services depends on settings. var settingsService = StartupService.LoadSettingsService(); var grimDawnDetector = new GrimDawnDetector(settingsService); IPlayerItemDao playerItemDao; IDatabaseItemDao databaseItemDao; IDatabaseSettingDao databaseSettingDao; IDatabaseItemStatDao databaseItemStatDao; IItemTagDao itemTagDao; IBuddyItemDao buddyItemDao; IBuddySubscriptionDao buddySubscriptionDao; IRecipeItemDao recipeItemDao; IItemSkillDao itemSkillDao; IAugmentationItemDao augmentationItemRepo; IItemCollectionDao itemCollectionRepo; if (dialect == SqlDialect.Sqlite) { playerItemDao = new PlayerItemRepo(threadExecuter, factory, dialect); databaseItemDao = new DatabaseItemRepo(threadExecuter, factory, dialect); databaseSettingDao = new DatabaseSettingRepo(threadExecuter, factory, dialect); databaseItemStatDao = new DatabaseItemStatRepo(threadExecuter, factory, dialect); itemTagDao = new ItemTagRepo(threadExecuter, factory, dialect); buddyItemDao = new BuddyItemRepo(threadExecuter, factory, dialect); buddySubscriptionDao = new BuddySubscriptionRepo(threadExecuter, factory, dialect); recipeItemDao = new RecipeItemRepo(threadExecuter, factory, dialect); itemSkillDao = new ItemSkillRepo(threadExecuter, factory); augmentationItemRepo = new AugmentationItemRepo(threadExecuter, factory, new DatabaseItemStatDaoImpl(factory, dialect), dialect); itemCollectionRepo = new ItemCollectionRepo(threadExecuter, factory, dialect); } else { databaseItemStatDao = new DatabaseItemStatDaoImpl(factory, dialect); playerItemDao = new PlayerItemDaoImpl(factory, databaseItemStatDao, dialect); databaseItemDao = new DatabaseItemDaoImpl(factory, dialect); databaseSettingDao = new DatabaseSettingDaoImpl(factory, dialect); itemTagDao = new ItemTagDaoImpl(factory, dialect); buddyItemDao = new BuddyItemDaoImpl(factory, databaseItemStatDao, dialect); buddySubscriptionDao = new BuddySubscriptionDaoImpl(factory, dialect); recipeItemDao = new RecipeItemDaoImpl(factory, dialect); itemSkillDao = new ItemSkillDaoImpl(factory); augmentationItemRepo = new AugmentationItemDaoImpl(factory, databaseItemStatDao, dialect); itemCollectionRepo = new ItemCollectionDaoImpl(factory, dialect); } // Chicken and the egg.. var itemStatService = new ItemStatService(databaseItemStatDao, itemSkillDao, settingsService); SearchController searchController = new SearchController( databaseItemDao, playerItemDao, itemStatService, buddyItemDao, augmentationItemRepo, settingsService, itemCollectionRepo ); List <object> services = new List <object>(); services.Add(itemTagDao); services.Add(databaseItemDao); services.Add(databaseItemStatDao); services.Add(playerItemDao); services.Add(databaseSettingDao); services.Add(buddyItemDao); services.Add(buddySubscriptionDao); services.Add(itemSkillDao); services.Add(augmentationItemRepo); //services.Add(userFeedbackService); services.Add(settingsService); services.Add(grimDawnDetector); services.Add(recipeItemDao); services.Add(itemCollectionRepo); services.Add(searchController); services.Add(itemStatService); var cacher = new TransferStashServiceCache(databaseItemDao); services.Add(cacher); Logger.Debug("All services created"); return(new ServiceProvider(services)); }
private static void Main(string[] args) { if (Thread.CurrentThread.Name == null) { Thread.CurrentThread.Name = "Main"; } Logger.Info("Starting IA:GD.."); ExceptionReporter.UrlCrashreport = "http://ribbs.dreamcrash.org/iagd/crashreport.php"; ExceptionReporter.UrlStats = "http://ribbs.dreamcrash.org/iagd/stats.php"; #if !DEBUG ExceptionReporter.LogExceptions = true; #endif Logger.Info("Starting exception monitor for bug reports.."); // Phrased this way since people took it as a 'bad' thing. Logger.Debug("Crash reports can be seen at http://ribbs.dreamcrash.org/iagd/logs.html"); ExceptionReporter.EnableLogUnhandledOnThread(); #if DEBUG AzureUris.Initialize(AzureUris.EnvAzure); //AzureUris.Initialize(AzureUris.EnvDev); #else AzureUris.Initialize(AzureUris.EnvAzure); #endif var version = Assembly.GetExecutingAssembly().GetName().Version; DateTime buildDate = new DateTime(2000, 1, 1) .AddDays(version.Build) .AddSeconds(version.Revision * 2); Logger.InfoFormat("Running version {0}.{1}.{2}.{3} from {4}", version.Major, version.Minor, version.Build, version.Revision, buildDate.ToString("dd/MM/yyyy")); if (!DependencyChecker.CheckNet452Installed()) { MessageBox.Show("It appears .Net Framework 4.5.2 is not installed.\nIA May not function correctly", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } if (!DependencyChecker.CheckVs2013Installed()) { MessageBox.Show("It appears VS 2013 (x86) redistributable is not installed.\nPlease install it to continue using IA", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } if (!DependencyChecker.CheckVs2010Installed()) { MessageBox.Show("It appears VS 2010 (x86) redistributable is not installed.\nPlease install it to continue using IA", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } #if DEBUG Test(); #endif // Prevent running in RELEASE mode by accident // And thus risking the live database #if !DEBUG if (Debugger.IsAttached) { Logger.Fatal("Debugger attached, please run in DEBUG mode"); return; } #endif //ParsingUIBackgroundWorker tmp = new ParsingUIBackgroundWorker(); ItemHtmlWriter.CopyMissingFiles(); Guid guid = new Guid("{F3693953-C090-4F93-86A2-B98AB96A9368}"); using (SingleInstance singleInstance = new SingleInstance(guid)) { if (singleInstance.IsFirstInstance) { Logger.Info("Calling run.."); singleInstance.ArgumentsReceived += singleInstance_ArgumentsReceived; singleInstance.ListenForArgumentsFromSuccessiveInstances(); using (ThreadExecuter threadExecuter = new ThreadExecuter()) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Logger.Info("Visual styles enabled.."); Run(args, threadExecuter); } } else { if (args != null && args.Length > 0) { singleInstance.PassArgumentsToFirstInstance(args); } else { singleInstance.PassArgumentsToFirstInstance(new string[] { "--ignore" }); } } } Logger.Info("IA Exited"); }
private static void Run(string[] args, ThreadExecuter threadExecuter) { var factory = new SessionFactory(); // Settings should be upgraded early, it contains the language pack etc and some services depends on settings. IPlayerItemDao playerItemDao = new PlayerItemRepo(threadExecuter, factory); var statUpgradeNeeded = UpgradeSettings(); // X IDatabaseItemDao databaseItemDao = new DatabaseItemRepo(threadExecuter, factory); GlobalSettings.InitializeLanguage(Properties.Settings.Default.LocalizationFile, databaseItemDao.GetTagDictionary()); DumpTranslationTemplate(); // Prohibited for now Properties.Settings.Default.InstaTransfer = false; Properties.Settings.Default.Save(); threadExecuter.Execute(() => new MigrationHandler(factory).Migrate()); IDatabaseSettingDao databaseSettingDao = new DatabaseSettingRepo(threadExecuter, factory); LoadUuid(databaseSettingDao); var azurePartitionDao = new AzurePartitionRepo(threadExecuter, factory); IDatabaseItemStatDao databaseItemStatDao = new DatabaseItemStatRepo(threadExecuter, factory); IItemTagDao itemTagDao = new ItemTagRepo(threadExecuter, factory); #if !DEBUG if (statUpgradeNeeded) { // If we don't also update item stats, a lot of whining will ensue. // This accounts for most database updates (new fields added that needs to get populated etc) UpdatingPlayerItemsScreen x = new UpdatingPlayerItemsScreen(playerItemDao); x.ShowDialog(); } #endif IBuddyItemDao buddyItemDao = new BuddyItemRepo(threadExecuter, factory); IBuddySubscriptionDao buddySubscriptionDao = new BuddySubscriptionRepo(threadExecuter, factory); IRecipeItemDao recipeItemDao = new RecipeItemRepo(threadExecuter, factory); IItemSkillDao itemSkillDao = new ItemSkillRepo(threadExecuter, factory); ArzParser arzParser = new ArzParser(databaseSettingDao); AugmentationItemRepo augmentationItemRepo = new AugmentationItemRepo(threadExecuter, factory, new DatabaseItemStatDaoImpl(factory)); Logger.Debug("Updating augment state.."); augmentationItemRepo.UpdateState(); // TODO: GD Path has to be an input param, as does potentially mods. ParsingService parsingService = new ParsingService(itemTagDao, null, databaseItemDao, databaseItemStatDao, itemSkillDao, Properties.Settings.Default.LocalizationFile); PrintStartupInfo(factory); if (GlobalSettings.Language is EnglishLanguage language) { foreach (var tag in itemTagDao.GetClassItemTags()) { language.SetTagIfMissing(tag.Tag, tag.Name); } } if (args != null && args.Any(m => m.Contains("-logout"))) { Logger.Info("Started with -logout specified, logging out of online backups."); Settings.Default.AzureAuthToken = null; Settings.Default.Save(); } // TODO: Urgent, introduce DI and have MainWindow receive premade objects, not create them itself. using (CefBrowserHandler browser = new CefBrowserHandler()) { _mw = new MainWindow(browser, databaseItemDao, databaseItemStatDao, playerItemDao, azurePartitionDao, databaseSettingDao, buddyItemDao, buddySubscriptionDao, arzParser, recipeItemDao, itemSkillDao, itemTagDao, parsingService, augmentationItemRepo ); Logger.Info("Checking for database updates.."); // Load the GD database (or mod, if any) string GDPath = databaseSettingDao.GetCurrentDatabasePath(); if (string.IsNullOrEmpty(GDPath) || !Directory.Exists(GDPath)) { GDPath = GrimDawnDetector.GetGrimLocation(); } if (!string.IsNullOrEmpty(GDPath) && Directory.Exists(GDPath)) { var numFiles = Directory.GetFiles(GlobalPaths.StorageFolder).Length; int numFilesExpected = 2100; if (Directory.Exists(Path.Combine(GDPath, "gdx2"))) { numFilesExpected += 580; } if (Directory.Exists(Path.Combine(GDPath, "gdx1"))) { numFilesExpected += 890; } if (numFiles < numFilesExpected) { Logger.Debug($"Only found {numFiles} in storage, expected ~{numFilesExpected}+, parsing item icons."); ThreadPool.QueueUserWorkItem((m) => ArzParser.LoadIconsOnly(GDPath)); } } else { Logger.Warn("Could not find the Grim Dawn install location"); } playerItemDao.UpdateHardcoreSettings(); _mw.Visible = false; if (DonateNagScreen.CanNag) { Application.Run(new DonateNagScreen()); } Logger.Info("Running the main application.."); Application.Run(_mw); } Logger.Info("Application ended."); }
private static void Main(string[] args) { if (Thread.CurrentThread.Name == null) { Thread.CurrentThread.Name = "Main"; Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US"); } Logger.Info("Starting IA:GD.."); ExceptionReporter.UrlStats = "https://webstats.evilsoft.net/report/iagd"; Logger.Info("Starting exception monitor for bug reports.."); Logger.Debug("Anonymous usage statistics can be seen at https://webstats.evilsoft.net/iagd"); ExceptionReporter.EnableLogUnhandledOnThread(); Uris.Initialize(Uris.EnvCloud); StartupService.Init(); #if DEBUG Test(); Uris.Initialize(Uris.EnvLocalDev); #endif // Prevent running in RELEASE mode by accident // And thus risking the live database #if !DEBUG if (Debugger.IsAttached) { Logger.Fatal("Debugger attached, please run in DEBUG mode"); return; } #endif //ParsingUIBackgroundWorker tmp = new ParsingUIBackgroundWorker(); ItemHtmlWriter.CopyMissingFiles(); Guid guid = new Guid("{F3693953-C090-4F93-86A2-B98AB96A9368}"); using (SingleInstance singleInstance = new SingleInstance(guid)) { if (singleInstance.IsFirstInstance) { Logger.Info("Calling run.."); singleInstance.ArgumentsReceived += singleInstance_ArgumentsReceived; singleInstance.ListenForArgumentsFromSuccessiveInstances(); using (ThreadExecuter threadExecuter = new ThreadExecuter()) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Logger.Info("Visual styles enabled.."); Run(args, threadExecuter); } } else { if (args != null && args.Length > 0) { singleInstance.PassArgumentsToFirstInstance(args); } else { singleInstance.PassArgumentsToFirstInstance(new string[] { "--ignore" }); } Logger.Info("Already has an instance of IA Running, exiting.."); } } Logger.Info("IA Exited"); LogManager.Shutdown(); }
private static void Run(string[] args, ThreadExecuter threadExecuter) { var dialect = SqlDialect.Sqlite; var factory = new SessionFactory(dialect); var serviceProvider = ServiceProvider.Initialize(threadExecuter, dialect); var settingsService = serviceProvider.Get <SettingsService>(); var databaseItemDao = serviceProvider.Get <IDatabaseItemDao>(); var augmentationItemRepo = serviceProvider.Get <IAugmentationItemDao>(); RuntimeSettings.InitializeLanguage(settingsService.GetLocal().LocalizationFile, databaseItemDao.GetTagDictionary()); DumpTranslationTemplate(); Logger.Debug("Executing DB migrations.."); threadExecuter.Execute(() => new MigrationHandler(factory).Migrate()); Logger.Debug("Loading UUID"); LoadUuid(settingsService); Logger.Debug("Updating augment state.."); augmentationItemRepo.UpdateState(); var itemTagDao = serviceProvider.Get <IItemTagDao>(); var databaseItemStatDao = serviceProvider.Get <IDatabaseItemStatDao>(); var itemSkillDao = serviceProvider.Get <IItemSkillDao>(); ParsingService parsingService = new ParsingService(itemTagDao, null, databaseItemDao, databaseItemStatDao, itemSkillDao, settingsService.GetLocal().LocalizationFile); StartupService.PrintStartupInfo(factory, settingsService, dialect); // TODO: Offload to the new language loader if (RuntimeSettings.Language is EnglishLanguage language) { foreach (var tag in itemTagDao.GetClassItemTags()) { language.SetTagIfMissing(tag.Tag, tag.Name); } } using (CefBrowserHandler browser = new CefBrowserHandler(settingsService)) { _mw = new MainWindow( serviceProvider, browser, parsingService ); Logger.Info("Checking for database updates.."); var grimDawnDetector = serviceProvider.Get <GrimDawnDetector>(); StartupService.PerformIconCheck(grimDawnDetector, settingsService); try { var playerItemDao = serviceProvider.Get <IPlayerItemDao>(); playerItemDao.DeleteDuplicates(); } catch (Exception ex) { Logger.Warn("Something went terribly wrong trying to ensure no duplicate items are found, however we'll just ignore it instead of blocking you access to your items.. sigh..", ex); } _mw.Visible = false; if (new DonateNagScreen(settingsService).CanNag) { Application.Run(new DonateNagScreen(settingsService)); } Logger.Info("Running the main application.."); StartupService.PerformGrimUpdateCheck(settingsService); Application.Run(_mw); } Logger.Info("Application ended."); }
private static void Test() { string bracket = "["; var splitted = bracket.Split('['); List <int> xl = new List <int>(); xl.Add(1); xl.Add(5); xl.Add(2); var t = xl.Take(50).ToList(); int x = 9; /* * var json = "hello_world"; * using (var stream = new MemoryStream()) { * using (GZipStream gz = new GZipStream(stream, CompressionMode.Compress, true)) { * var encoding = new ASCIIEncoding(); * byte[] data123 = encoding.GetBytes(json); * gz.Write(data123, 0, data123.Length); * } * var c = Convert.ToBase64String(stream.ToArray()); * var s = new Synchronizer().UploadBuddyData($"json={c}", "http://grimdawn.dreamcrash.org/buddyitems/v2/test"); * * int x123 = 9; * } * * * * using (ThreadExecuter threadExecuter = new ThreadExecuter()) { * var factory = new SessionFactory(); * * * var repo = new BuddyItemRepo(threadExecuter, factory); * var allItems = repo.ListAll(); * var items = repo.ListItemsWithMissingRarity(); * repo.UpdateRarity(items); * * repo.UpdateNames(allItems); * repo.UpdateLevelRequirements(allItems); * * }*/ return; using (ThreadExecuter threadExecuter = new ThreadExecuter()) { var factory = new SessionFactory(); string arcTagfile = @"D:\SteamLibrary\steamapps\common\Grim Dawn\resources\text_en.arc"; var arcItemsFile = @"D:\SteamLibrary\steamapps\common\Grim Dawn\resources\items.arc"; var databaseFile = @"D:\SteamLibrary\steamapps\common\Grim Dawn\database\database.arz"; List <IItemTag> _tags = Parser.Arz.ArzParser.ParseArcFile(arcTagfile); var mappedTags = _tags.ToDictionary(item => item.Tag, item => item.Name); List <IItem> _items = Parser.Arz.ArzParser.LoadItemRecords(databaseFile, true); // TODO var skillParser = new ComplexItemParser(_items, mappedTags); skillParser.Generate(); var _itemSkillDao = new ItemSkillRepo(threadExecuter, factory); //_itemSkillDao.Save(skillParser.Skills); //_itemSkillDao.Save(skillParser.SkillItemMapping); IPlayerItemDao playerItemDao = new PlayerItemRepo(threadExecuter, factory); IDatabaseItemDao databaseItemDao = new DatabaseItemRepo(threadExecuter, factory); IDatabaseItemStatDao databaseItemStatDao = new DatabaseItemStatRepo(threadExecuter, factory); /* * var xys = databaseItemDao.GetValidClassItemTags(); * Parser.Arc.Decompress c = new Parser.Arc.Decompress(@"D:\SteamLibrary\steamapps\common\Grim Dawn\resources\Items.arc", true); * c.decompress(); */ } }
private static void Run(ThreadExecuter threadExecuter) { var factory = new SessionFactory(); // Prohibited for now Properties.Settings.Default.InstaTransfer = false; Properties.Settings.Default.Save(); new MigrationHandler(factory).Migrate(); IDatabaseSettingDao databaseSettingDao = new DatabaseSettingRepo(threadExecuter, factory); LoadUuid(databaseSettingDao); IPlayerItemDao playerItemDao = new PlayerItemRepo(threadExecuter, factory); IDatabaseItemDao databaseItemDao = new DatabaseItemRepo(threadExecuter, factory); IDatabaseItemStatDao databaseItemStatDao = new DatabaseItemStatRepo(threadExecuter, factory); IBuddyItemDao buddyItemDao = new BuddyItemRepo(threadExecuter, factory); IBuddySubscriptionDao buddySubscriptionDao = new BuddySubscriptionRepo(threadExecuter, factory); IRecipeItemDao recipeItemDao = new RecipeItemRepo(threadExecuter, factory); IItemSkillDao itemSkillDao = new ItemSkillRepo(threadExecuter, factory); ArzParser arzParser = new ArzParser(databaseItemDao, databaseItemStatDao, databaseSettingDao, itemSkillDao); PrintStartupInfo(factory); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Logger.Info("Visual styles enabled.."); UpgradeSettings(playerItemDao); var language = GlobalSettings.Language as StatTranslator.EnglishLanguage; if (language != null) { foreach (var tag in databaseItemDao.GetClassItemTags()) { language.SetTagIfMissing(tag.Tag, tag.Name); } } using (CefBrowserHandler browser = new CefBrowserHandler()) { _mw = new MainWindow(browser, databaseItemDao, databaseItemStatDao, playerItemDao, databaseSettingDao, buddyItemDao, buddySubscriptionDao, arzParser, recipeItemDao, itemSkillDao ); Logger.Info("Checking for database updates.."); // Load the GD database (or mod, if any) string GDPath = databaseSettingDao.GetCurrentDatabasePath(); bool isVanilla; if (string.IsNullOrEmpty(GDPath) || !Directory.Exists(GDPath)) { GDPath = GrimDawnDetector.GetGrimLocation(); isVanilla = true; } else { isVanilla = GDPath.Equals(GrimDawnDetector.GetGrimLocation()); } if (!string.IsNullOrEmpty(GDPath) && Directory.Exists(GDPath)) { if (arzParser.NeedUpdate(GDPath)) { ParsingDatabaseScreen parserUI = new ParsingDatabaseScreen( databaseSettingDao, arzParser, GDPath, Properties.Settings.Default.LocalizationFile, false, !isVanilla); parserUI.ShowDialog(); } if (playerItemDao.RequiresStatUpdate()) { UpdatingPlayerItemsScreen x = new UpdatingPlayerItemsScreen(playerItemDao); x.ShowDialog(); } var numFiles = Directory.GetFiles(GlobalPaths.StorageFolder).Length; if (numFiles < 2000) { Logger.Debug($"Only found {numFiles} in storage, expected ~3200+, parsing item icons."); ThreadPool.QueueUserWorkItem((m) => ArzParser.LoadIconsOnly(GDPath)); } } else { Logger.Warn("Could not find the Grim Dawn install location"); } playerItemDao.UpdateHardcoreSettings(); _mw.Visible = false; if (DonateNagScreen.CanNag) { Application.Run(new DonateNagScreen()); } Logger.Info("Running the main application.."); Application.Run(_mw); } Logger.Info("Application ended."); }
private static void Run(string[] args, ThreadExecuter threadExecuter) { var factory = new SessionFactory(); // Settings should be upgraded early, it contains the language pack etc and some services depends on settings. IPlayerItemDao playerItemDao = new PlayerItemRepo(threadExecuter, factory); UpgradeSettings(playerItemDao); // X IDatabaseItemDao databaseItemDao = new DatabaseItemRepo(threadExecuter, factory); GlobalSettings.InitializeLanguage(Properties.Settings.Default.LocalizationFile, databaseItemDao.GetTagDictionary()); // Prohibited for now Properties.Settings.Default.InstaTransfer = false; Properties.Settings.Default.Save(); threadExecuter.Execute(() => new MigrationHandler(factory).Migrate()); IDatabaseSettingDao databaseSettingDao = new DatabaseSettingRepo(threadExecuter, factory); LoadUuid(databaseSettingDao); var azurePartitionDao = new AzurePartitionRepo(threadExecuter, factory); IDatabaseItemStatDao databaseItemStatDao = new DatabaseItemStatRepo(threadExecuter, factory); IItemTagDao itemTagDao = new ItemTagRepo(threadExecuter, factory); IBuddyItemDao buddyItemDao = new BuddyItemRepo(threadExecuter, factory); IBuddySubscriptionDao buddySubscriptionDao = new BuddySubscriptionRepo(threadExecuter, factory); IRecipeItemDao recipeItemDao = new RecipeItemRepo(threadExecuter, factory); IItemSkillDao itemSkillDao = new ItemSkillRepo(threadExecuter, factory); ArzParser arzParser = new ArzParser(databaseSettingDao); AugmentationItemRepo augmentationItemRepo = new AugmentationItemRepo(threadExecuter, factory, new DatabaseItemStatDaoImpl(factory)); Logger.Debug("Updating augment state.."); augmentationItemRepo.UpdateState(); // TODO: GD Path has to be an input param, as does potentially mods. ParsingService parsingService = new ParsingService(itemTagDao, null, databaseItemDao, databaseItemStatDao, itemSkillDao, Properties.Settings.Default.LocalizationFile); PrintStartupInfo(factory); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Logger.Info("Visual styles enabled.."); if (GlobalSettings.Language is EnglishLanguage language) { foreach (var tag in itemTagDao.GetClassItemTags()) { language.SetTagIfMissing(tag.Tag, tag.Name); } } bool showDevtools = args != null && args.Any(m => m.Contains("-devtools")); // TODO: Urgent, introduce DI and have MainWindow receive premade objects, not create them itself. using (CefBrowserHandler browser = new CefBrowserHandler()) { _mw = new MainWindow(browser, databaseItemDao, databaseItemStatDao, playerItemDao, azurePartitionDao, databaseSettingDao, buddyItemDao, buddySubscriptionDao, arzParser, recipeItemDao, itemSkillDao, itemTagDao, parsingService, showDevtools, augmentationItemRepo ); Logger.Info("Checking for database updates.."); // Load the GD database (or mod, if any) string GDPath = databaseSettingDao.GetCurrentDatabasePath(); if (string.IsNullOrEmpty(GDPath) || !Directory.Exists(GDPath)) { GDPath = GrimDawnDetector.GetGrimLocation(); } if (!string.IsNullOrEmpty(GDPath) && Directory.Exists(GDPath)) { var numFiles = Directory.GetFiles(GlobalPaths.StorageFolder).Length; if (numFiles < 2000) { Logger.Debug($"Only found {numFiles} in storage, expected ~3200+, parsing item icons."); ThreadPool.QueueUserWorkItem((m) => ArzParser.LoadIconsOnly(GDPath)); } } else { Logger.Warn("Could not find the Grim Dawn install location"); } playerItemDao.UpdateHardcoreSettings(); _mw.Visible = false; if (DonateNagScreen.CanNag) { Application.Run(new DonateNagScreen()); } Logger.Info("Running the main application.."); Application.Run(_mw); } Logger.Info("Application ended."); }
private static void Main(string[] args) { if (Thread.CurrentThread.Name == null) { Thread.CurrentThread.Name = "Main"; } Logger.Info("Starting IA:GD.."); //ExceptionReporter.UrlCrashreport = "http://ribbs.dreamcrash.org/iagd/crashreport.php"; //ExceptionReporter.UrlStats = "http://ribbs.dreamcrash.org/iagd/stats.php"; #if !DEBUG ExceptionReporter.LogExceptions = true; #endif Logger.Info("Starting exception monitor for bug reports.."); // Phrased this way since people took it as a 'bad' thing. Logger.Debug("Crash reports can be seen at http://ribbs.dreamcrash.org/iagd/logs.html"); //ExceptionReporter.EnableLogUnhandledOnThread(); var version = Assembly.GetExecutingAssembly().GetName().Version; DateTime buildDate = new DateTime(2000, 1, 1) .AddDays(version.Build) .AddSeconds(version.Revision * 2); Logger.InfoFormat("Running version {0}.{1}.{2}.{3} from {4}", version.Major, version.Minor, version.Build, version.Revision, buildDate.ToString("dd/MM/yyyy")); if (!DependencyChecker.CheckNet452Installed()) { MessageBox.Show("It appears .Net Framework 4.5.2 is not installed.\nIA May not function correctly", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } if (!DependencyChecker.CheckVS2013Installed()) { MessageBox.Show("It appears VS 2013 (x86) redistributable is not installed.\nPlease install it to continue using IA", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } if (!DependencyChecker.CheckVS2010Installed()) { MessageBox.Show("It appears VS 2010 (x86) redistributable is not installed.\nPlease install it to continue using IA", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } #if DEBUG Test(); #endif // Prevent running in RELEASE mode by accident // And thus risking the live database #if !DEBUG if (Debugger.IsAttached) { Logger.Fatal("Debugger attached, please run in DEBUG mode"); return; } #endif //ParsingUIBackgroundWorker tmp = new ParsingUIBackgroundWorker(); Guid guid = new Guid("{F3693953-C090-4F93-86A2-B98AB96A9368}"); using (SingleInstance singleInstance = new SingleInstance(guid)) { if (singleInstance.IsFirstInstance) { Logger.Info("Calling run.."); using (ThreadExecuter threadExecuter = new ThreadExecuter()) { Run(threadExecuter); } } else { //singleInstance_ArgumentsReceived(null, null); } } }