Exemplo n.º 1
0
        private void ThreadStart()
        {
            ExceptionReporter.EnableLogUnhandledOnThread();
            t.Name             = "ItemStatCache";
            t.CurrentUICulture = new System.Globalization.CultureInfo("en-US");
            // Sleeping a bit in the start, we don't wanna keep locking the DB (SQLite mode) on startup
            try {
                Thread.Sleep(1000 * 15);
            }
            catch (ThreadInterruptedException) {
                // Don't care
            }

            while (t?.IsAlive ?? false)
            {
                // Only perform action if we got plenty in the DB, otherwise we might not be parsed yet.
                bool result = false;
                if (_databaseItemDao.GetRowCount() > 20000)
                {
                    result = Tick();
                }

                try {
                    Thread.Sleep(result ? 1500 : 120 * 1000);
                }
                catch (ThreadInterruptedException) {
                    // Don't care
                }
            }
        }
Exemplo n.º 2
0
        private void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            if (Thread.CurrentThread.Name == null)
            {
                Thread.CurrentThread.Name             = "InjectionHelper";
                Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US");
            }
            ExceptionReporter.EnableLogUnhandledOnThread();

            try {
                BackgroundWorker worker = sender as BackgroundWorker;

                while (!worker.CancellationPending)
                {
                    if (!File.Exists("DllInjector64.exe") || !File.Exists("DllInjector32.exe"))
                    {
                        new AvastedWarning().ShowDialog();
                        Logger.Fatal("Shutting down injection helper. End user has been avasted and IA is now inoperational until reinstalled.");
                        return;
                    }
                    else
                    {
                        Process(worker, e.Argument as RunArguments);
                    }
                }
            }
            catch (Exception ex) {
                Logger.Fatal(ex.Message);
                Logger.Fatal(ex.StackTrace);
                throw;
            }
        }
Exemplo n.º 3
0
        private void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            if (Thread.CurrentThread.Name == null)
            {
                Thread.CurrentThread.Name             = "BackupServiceWorker";
                Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US");
            }
            ExceptionReporter.EnableLogUnhandledOnThread();

            try {
                Logger.Debug("Backup service started, waiting for 10 seconds before initializing..");
                Thread.Sleep(15000);
                Logger.Debug("Backup initializing..");
            }
            catch (Exception ex) {
                Logger.Error(ex.Message);
                Logger.Error(ex.StackTrace);
            }

            BackgroundWorker worker = sender as BackgroundWorker;

            while (!worker.CancellationPending)
            {
                try {
                    Thread.Sleep(1000);
                    _backupService.Execute();
                    _characterBackupService.Execute();
                }
                catch (Exception ex) {
                    Logger.Error(ex.Message);
                    Logger.Error(ex.StackTrace);
                }
            }
        }
Exemplo n.º 4
0
        private void Form1_Load(object sender, EventArgs e)
        {
            Logger.Debug("Starting..");
            if (Thread.CurrentThread.Name == null)
            {
                Thread.CurrentThread.Name = "UI";
                ExceptionReporter.EnableLogUnhandledOnThread();
            }

            this.Closing += Form1_Closing;

            {
                var webView = new WebView(_browser);
                webView.TopLevel = false;
                this.webViewPanel.Controls.Add(webView);
                webView.Show();
            }
            {
                var debugView = new DebugSettings(_appSettings);
                debugView.TopLevel = false;
                this.panelDebugView.Controls.Add(debugView);
                debugView.Show();
            }

            _messageProcessorCore.OnHookActivation += (_, __) => {
                this.labelHookStatus.Text      = "Hook activated";
                this.labelHookStatus.ForeColor = System.Drawing.Color.Green;
            };

            _autoUpdateUtility.StartReportUsageTimer();

            this.FormClosing += OnFormClosing;
            this.SizeChanged += Form1_SizeChanged;
        }
Exemplo n.º 5
0
        private void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            try {
                if (Thread.CurrentThread.Name == null)
                {
                    Thread.CurrentThread.Name             = "Backup";
                    Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US");
                }
                ExceptionReporter.EnableLogUnhandledOnThread();

                BackgroundWorker worker = sender as BackgroundWorker;
                ICloudBackup     b      = e.Argument as ICloudBackup;
                while (!worker.CancellationPending)
                {
                    Thread.Sleep(10);
                    b.Update();
                }
            }
            catch (Exception ex) {
                logger.Fatal(ex.Message);
                logger.Fatal(ex.StackTrace);
                ExceptionReporter.ReportException(ex);
                throw;
            }
        }
Exemplo n.º 6
0
        private void Run()
        {
            if (Thread.CurrentThread.Name == null)
            {
                Thread.CurrentThread.Name = "SQL";
            }

            ExceptionReporter.EnableLogUnhandledOnThread();

            while (!_isCancelled)
            {
                QueuedExecution elem;
                if (_queue.TryDequeue(out elem))
                {
                    try {
                        if (elem.Func != null)
                        {
                            _results[elem.Trigger] = elem.Func();
                        }
                        else
                        {
                            elem.Action();
                        }
                    }
                    catch (Exception ex) {
                        _results[elem.Trigger] = ex;
                    }
                    elem.Trigger.Set();
                }

                try {
                    Thread.Sleep(1);
                } catch (Exception) { }
            }
        }
Exemplo n.º 7
0
        private void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            try {
                if (Thread.CurrentThread.Name == null)
                {
                    Thread.CurrentThread.Name = "StatParserUI";
                }
                ExceptionReporter.EnableLogUnhandledOnThread();

                Logger.Info("Updating player stats");

                BackgroundWorker worker = sender as BackgroundWorker;


                // Update all stats
                IList <PlayerItem> items = _playerItemDao.ListAll();
                worker.ReportProgress(Math.Max(100, items.Count), 1);


                int total = 0;
                _playerItemDao.UpdateAllItemStats(items, (p) => {
                    worker.ReportProgress(total++, 0);
                });
                Logger.Info("Updated item stats");
            }
            catch (Exception ex) {
                Logger.Fatal(ex.Message);
                Logger.Fatal(ex.StackTrace);
                throw;
            }
        }
Exemplo n.º 8
0
        private void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            if (Thread.CurrentThread.Name == null)
            {
                Thread.CurrentThread.Name             = "TransferStashWorker";
                Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US");
            }

            ExceptionReporter.EnableLogUnhandledOnThread();

            BackgroundWorker worker = sender as BackgroundWorker;

            while (!worker.CancellationPending)
            {
                try {
                    Thread.Sleep(1000);
                }
                catch (ThreadInterruptedException) {
                }

                // Nothing queued for looting
                if (_queuedTransferFiles.Count == 0)
                {
                    continue;
                }

                List <UserFeedback> feedback;
                try {
                    var(isLootable, lootableFeedback) = _transferStashService.IsTransferStashLootable();
                    if (isLootable)
                    {
                        feedback = Execute();
                    }
                    else
                    {
                        feedback = lootableFeedback;
                    }
                }
                catch (NullReferenceException ex) {
                    Logger.Warn(ex.Message);
                    Logger.Warn(ex.StackTrace);
                    feedback = UserFeedback.FromTagSingleton("iatag_feedback_unable_to_loot_stash");
                }
                catch (IOException ex) {
                    Logger.Warn(ex.Message);
                    Logger.Warn(ex.StackTrace);
                    Logger.Info("Exception not reported, IOExceptions are bound to happen.");
                    feedback = UserFeedback.FromTagSingleton("iatag_feedback_unable_to_loot_stash");
                }
                catch (Exception ex) {
                    Logger.Warn(ex.Message);
                    Logger.Warn(ex.StackTrace);
                    feedback = UserFeedback.FromTagSingleton("iatag_feedback_unable_to_loot_stash");
                }

                _feedbackService.SetFeedback(feedback);
            }
        }
Exemplo n.º 9
0
        private void UpdateCollectionItems()
        {
            Thread thread = new Thread(() => {
                ExceptionReporter.EnableLogUnhandledOnThread();
                Browser.SetCollectionItems(_itemCollectionRepo.GetItemCollection());
            });

            thread.Start();
        }
Exemplo n.º 10
0
        private void buttonImport_Click(object sender, EventArgs e)
        {
            if (buttonImport.Enabled)
            {
                FileExporter io;

                if (radioIAStash.Checked)
                {
                    io = new IAFileExporter(_filename);
                }
                else if (radioGDStash.Checked)
                {
                    GDTransferFile settings = cbItemSelection.SelectedItem as GDTransferFile;
                    io = new GDFileExporter(_filename, settings?.Mod ?? string.Empty);
                }
                else
                {
                    _playerItemDao.Save(_sm.EmptyStash(_filename));

                    MessageBox.Show(
                        RuntimeSettings.Language.GetTag("iatag_ui_importexport_import_success"),
                        RuntimeSettings.Language.GetTag("iatag_ui_importexport_import_success"),
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Information
                        );
                    return;
                }

                var items = io.Read(Read(_filename));
                Logger.Debug($"Storing {items.Count} items to db");
                progressBar1.Maximum = items.Count;
                buttonImport.Enabled = false;
                Thread t = new Thread(() => {
                    ExceptionReporter.EnableLogUnhandledOnThread();
                    isLocked = true;

                    var batches = BatchUtil.ToBatches <PlayerItem>(items);
                    foreach (var batch in batches)
                    {
                        _playerItemDao.Import(batch);
                        Invoke((MethodInvoker) delegate { progressBar1.Value += batch.Count; });
                    }

                    isLocked = false;
                    MessageBox.Show(
                        RuntimeSettings.Language.GetTag("iatag_ui_importexport_import_success_body"),
                        RuntimeSettings.Language.GetTag("iatag_ui_importexport_import_success"),
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Information
                        );
                });

                t.Start();
            }
        }
Exemplo n.º 11
0
        private void UpdateCollectionItems(ItemSearchRequest query)
        {
            Thread thread = new Thread(() => {
                ExceptionReporter.EnableLogUnhandledOnThread();
                Browser.SetCollectionItems(_itemCollectionRepo.GetItemCollection(query));
            });

            thread.Start();


            Browser.SetCollectionAggregateData(_itemCollectionRepo.GetItemAggregateStats());
        }
Exemplo n.º 12
0
        private void Run()
        {
            if (Thread.CurrentThread.Name == null)
            {
                Thread.CurrentThread.Name             = "SQL";
                Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US");
            }

            ExceptionReporter.EnableLogUnhandledOnThread();

            while (!_isCancelled)
            {
                if (_queue.TryDequeue(out var elem))
                {
                    try {
                        elem.IsStarted = true;
                        if (elem.IsLongRunning)
                        {
                            _exceptionOverride = true;
                            Logger.Info("Initiating long running operation");
                        }

                        if (elem.Func != null)
                        {
                            _results[elem.Trigger] = elem.Func();
                        }
                        else
                        {
                            elem.Action();
                        }
                    }
                    catch (Exception ex) {
                        _results[elem.Trigger] = ex;
                    }

                    elem.Trigger.Set();

                    if (_exceptionOverride)
                    {
                        _exceptionOverride = false;
                        Logger.Info("Ending long running operation");
                    }
                }

                try {
                    Thread.Sleep(1);
                }
                catch (Exception) {
                }
            }
        }
Exemplo n.º 13
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            if (Thread.CurrentThread.Name == null)
            {
                Thread.CurrentThread.Name = "Main/UI";
                ExceptionReporter.EnableLogUnhandledOnThread();
            }

            ExceptionReporter.UrlCrashreport = "http://ribbs.dreamcrash.org/gddamage/crashreport.php";
            ExceptionReporter.UrlStats       = "http://ribbs.dreamcrash.org/gddamage/stats.php";
            ExceptionReporter.LogExceptions  = true;
            ExceptionReporter.Uuid           = GetUuid();
#if !DEBUG
#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:dd/MM/yyyy}", version.Major, version.Minor, version.Build, version.Revision, buildDate);

            Logger.Info("Anonymous usage statistics and crash reports will be collected.");
            Logger.Info("Statistics and crash reports can be found at http://ribbs.dreamcrash.org/gddamage/logs.html");

            if (!File.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Hook.dll")))
            {
                MessageBox.Show("Error - It appears that hook.dll is missing\nMost likely this installation has been corrupted.", "Error");
                return;
            }


            string url = Properties.Settings.Default.DarkModeEnabled
                    ? Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "content", "darkmode.html")
                    : Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "content", "index.html");

            if (!File.Exists(url))
            {
                MessageBox.Show("Error - It appears the stat view is missing", "Error");
            }

            bool showDevtools = args != null && args.Any(m => m.Contains("-devtools"));
            using (var browser = new CefBrowserHandler()) {
                WebViewJsPojo jsPojo = new WebViewJsPojo();
                browser.InitializeChromium(url, jsPojo, null);
                Application.Run(new Form1(browser, GetSettings(), showDevtools));
            }
        }
Exemplo n.º 14
0
        public ItemStatService(
            IDatabaseItemStatDao databaseItemStatDao,
            IItemSkillDao itemSkillDao,
            SettingsService settings)
        {
            this._databaseItemStatDao = databaseItemStatDao;
            this._itemSkillDao        = itemSkillDao;
            _settings = settings;

            Thread thread = new Thread(() => {
                ExceptionReporter.EnableLogUnhandledOnThread();
                _xpacSkills = _databaseItemStatDao.GetExpacSkillModifierSkills();
            });

            thread.Start();
        }
Exemplo n.º 15
0
        private void Run()
        {
            if (Thread.CurrentThread.Name == null)
            {
                Thread.CurrentThread.Name             = "SQL";
                Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US");
            }

            ExceptionReporter.EnableLogUnhandledOnThread();

            while (!_isCancelled)
            {
                if (_queue.TryDequeue(out var elem))
                {
                    try {
                        if (elem.Func != null)
                        {
                            _results[elem.Trigger] = elem.Func();
                        }
                        else
                        {
                            elem.Action();
                        }
                    }
                    catch (Exception ex) {
                        _results[elem.Trigger] = ex;
                    }

                    elem.Trigger.Set();
                }

                try {
                    Thread.Sleep(1);
                }
                catch (Exception) {
                }
            }
        }
Exemplo n.º 16
0
        public void Start()
        {
            if (_t != null)
            {
                throw new ArgumentException("Max one thread running per instance");
            }

            _t = new Thread(() => {
                ExceptionReporter.EnableLogUnhandledOnThread();

                while (!_isShuttingDown)
                {
                    if (_cooldown.IsReady)
                    {
                        Process();
                        _cooldown.Reset();
                    }

                    Thread.Sleep(1);
                }
            });

            _t.Start();
        }
Exemplo n.º 17
0
        public void Execute()
        {
            var form   = new ParsingDatabaseProgressView();
            var parser = new ArzParsingWrapper();


            List <string> tagfiles    = new List <string>();
            string        vanillaTags = GrimFolderUtility.FindArcFile(_grimdawnLocation, "text_en.arc");

            if (!string.IsNullOrEmpty(vanillaTags))
            {
                tagfiles.Add(vanillaTags);
            }

            foreach (string path in GrimFolderUtility.GetGrimExpansionFolders(_grimdawnLocation))
            {
                string expansionTags = GrimFolderUtility.FindArcFile(path, "text_en.arc");
                if (!string.IsNullOrEmpty(expansionTags))
                {
                    tagfiles.Add(expansionTags);
                }
            }

            string modTags = string.IsNullOrEmpty(_modLocation) ? "" : GrimFolderUtility.FindArcFile(_modLocation, "text_en.arc");

            if (!string.IsNullOrEmpty(modTags))
            {
                tagfiles.Add(modTags);
            }

            List <Action> actions = new List <Action>();


            actions.Add(() => parser.LoadTags(tagfiles, _localizationFile, new WinformsProgressBar(form.LoadingTags).Tracker));
            actions.Add(() => _itemTagDao.Save(parser.Tags, new WinformsProgressBar(form.SavingTags).Tracker));

            List <string> arzFiles = new List <string> {
                GrimFolderUtility.FindArzFile(_grimdawnLocation)
            };

            foreach (string path in GrimFolderUtility.GetGrimExpansionFolders(_grimdawnLocation))
            {
                string expansionItems = GrimFolderUtility.FindArzFile(path);

                if (!string.IsNullOrEmpty(expansionItems))
                {
                    arzFiles.Add(GrimFolderUtility.FindArzFile(expansionItems));
                }
            }

            if (!string.IsNullOrEmpty(_modLocation))
            {
                arzFiles.Add(GrimFolderUtility.FindArzFile(_modLocation));
            }

            actions.Add(() => parser.LoadItems(arzFiles, new WinformsProgressBar(form.LoadingItems).Tracker));
            actions.Add(() => parser.MapItemNames(new WinformsProgressBar(form.MappingItemNames).Tracker));
            actions.Add(() => parser.RenamePetStats(new WinformsProgressBar(form.MappingPetStats).Tracker));
            actions.Add(() => _databaseItemDao.Save(parser.Items, new WinformsProgressBar(form.SavingItems).Tracker));

            // TODO: This depends on the DB item name.. which is in english, not localized
            actions.Add(() => {
                var records = parser.GenerateSpecialRecords(new WinformsProgressBar(form.GeneratingSpecialStats).Tracker);
                _databaseItemStatDao.Save(records, new WinformsProgressBar(form.SavingSpecialStats).Tracker);
            });


            actions.Add(() => parser.ParseComplexItems(_itemSkillDao, new WinformsProgressBar(form.GeneratingSkills).Tracker));
            actions.Add(() => {
                var tracker      = new WinformsProgressBar(form.SkillCorrectnessCheck).Tracker;
                tracker.MaxValue = 1;
                _itemSkillDao.EnsureCorrectSkillRecords();
                tracker.MaxProgress();
            });

            // Invoke the background thread & show progress UI
            Thread t = new Thread(() => {
                ExceptionReporter.EnableLogUnhandledOnThread();
                foreach (var action in actions)
                {
                    action.Invoke();
                }

                Action close = () => form.OverrideClose();
                form.Invoke(close);
            });

            t.Start();
            form.ShowDialog();

            OnParseComplete?.Invoke(this, null);
        }
Exemplo n.º 18
0
        private void MainWindow_Load(object sender, EventArgs e)
        {
            if (Thread.CurrentThread.Name == null)
            {
                Thread.CurrentThread.Name = "UI";
            }

            ExceptionReporter.EnableLogUnhandledOnThread();
            SizeChanged += OnMinimizeWindow;

            _stashManager = new StashManager(_playerItemDao, _databaseItemStatDao, SetFeedback, ListviewUpdateTrigger);
            _stashFileMonitor.OnStashModified += (_, __) => {
                StashEventArg args = __ as StashEventArg;
                if (_stashManager != null && _stashManager.TryLootStashFile(args?.Filename))
                {
                    // STOP TIMER
                    _stashFileMonitor.CancelQueuedNotify();
                } // TODO: This logic should be changed to 're queue' but only trigger once, if its slow it triggers multiple times.
            };

            if (!_stashFileMonitor.StartMonitorStashfile(GlobalPaths.SavePath))
            {
                MessageBox.Show("Ooops!\nIt seems you are synchronizing your saves to steam cloud..\nThis tool is unfortunately not compatible.\n");
                Process.Start("http://www.grimdawn.com/forums/showthread.php?t=20752");

                if (!Debugger.IsAttached)
                {
                    Close();
                }
            }

            // Chicken and the egg..
            SearchController searchController = new SearchController(
                _databaseItemDao,
                _playerItemDao,
                _databaseItemStatDao,
                _itemSkillDao,
                _buddyItemDao,
                _stashManager,
                _augmentationItemRepo
                );

            _cefBrowserHandler.InitializeChromium(searchController.JsBind, Browser_IsBrowserInitializedChanged);
            searchController.Browser             = _cefBrowserHandler;
            searchController.JsBind.OnClipboard += SetItemsClipboard;

            // Load the grim database
            string gdPath = GrimDawnDetector.GetGrimLocation();

            if (!string.IsNullOrEmpty(gdPath))
            {
            }
            else
            {
                Logger.Warn("Could not find the Grim Dawn install location");
                statusLabel.Text = "Could not find the Grim Dawn install location";

                var timer = new System.Windows.Forms.Timer();
                timer.Tick    += TimerTickLookForGrimDawn;
                timer.Interval = 10000;
                timer.Start();
            }

            // Load recipes
            foreach (string file in GlobalPaths.FormulasFiles)
            {
                if (!string.IsNullOrEmpty(file))
                {
                    bool isHardcore = file.EndsWith("gsh");
                    Logger.InfoFormat("Reading recipes at \"{0}\", IsHardcore={1}", file, isHardcore);
                    _recipeParser.UpdateFormulas(file, isHardcore);
                }
            }

            var addAndShow = UIHelper.AddAndShow;

            // Create the tab contents
            _buddySettingsWindow = new BuddySettings(delegate(bool b) { BuddySyncEnabled = b; },
                                                     _buddyItemDao,
                                                     _buddySubscriptionDao
                                                     );

            addAndShow(_buddySettingsWindow, buddyPanel);

            _authAuthService = new AzureAuthService(_cefBrowserHandler, new AuthenticationProvider());
            var backupSettings = new BackupSettings(_playerItemDao, _authAuthService);

            addAndShow(backupSettings, backupPanel);
            addAndShow(new ModsDatabaseConfig(DatabaseLoadedTrigger, _playerItemDao, _parsingService), modsPanel);
            addAndShow(new HelpTab(), panelHelp);
            addAndShow(new LoggingWindow(), panelLogging);
            var backupService = new BackupService(_authAuthService, _playerItemDao, _azurePartitionDao, () => Settings.Default.UsingDualComputer);

            _backupServiceWorker            = new BackupServiceWorker(backupService);
            backupService.OnUploadComplete += (o, args) => _searchWindow.UpdateListView();
            searchController.OnSearch      += (o, args) => backupService.OnSearch();

            _searchWindow = new SplitSearchWindow(_cefBrowserHandler.BrowserControl, SetFeedback, _playerItemDao, searchController, _itemTagDao);
            addAndShow(_searchWindow, searchPanel);
            _stashManager.StashUpdated += (_, __) => {
                _searchWindow.UpdateListView();
            };

            addAndShow(
                new SettingsWindow(
                    _cefBrowserHandler,
                    _itemTagDao,
                    _tooltipHelper,
                    ListviewUpdateTrigger,
                    _databaseSettingDao,
                    _playerItemDao,
                    _arzParser,
                    _searchWindow.ModSelectionHandler.GetAvailableModSelection(),
                    _stashManager,
                    _parsingService
                    ),
                settingsPanel);

            new StashTabPicker(_stashManager.NumStashTabs).SaveStashSettingsToRegistry();

#if !DEBUG
            ThreadPool.QueueUserWorkItem(m => ExceptionReporter.ReportUsage());
            CheckForUpdates();
#endif

            int min  = 1000 * 60;
            int hour = 60 * min;
            _timerReportUsage = new Timer();
            _timerReportUsage.Start();
            _timerReportUsage.Elapsed += (a1, a2) => {
                if (Thread.CurrentThread.Name == null)
                {
                    Thread.CurrentThread.Name = "ReportUsageThread";
                }
                ReportUsage();
            };
            _timerReportUsage.Interval  = 12 * hour;
            _timerReportUsage.AutoReset = true;
            _timerReportUsage.Start();

            Shown += (_, __) => { StartInjector(); };

            //settingsController.Data.budd
            BuddySyncEnabled = (bool)Settings.Default.BuddySyncEnabled;

            // Start the backup task
            _backupBackgroundTask = new BackgroundTask(new FileBackup(_playerItemDao));

            LocalizationLoader.ApplyLanguage(Controls, GlobalSettings.Language);
            EasterEgg.Activate(this);

            // Initialize the "stash packer" used to find item positions for transferring items ingame while the stash is open
            {
                _dynamicPacker.Initialize(8, 16);

                var transferFiles = GlobalPaths.TransferFiles;
                if (transferFiles.Count > 0)
                {
                    var file  = transferFiles.MaxBy(m => m.LastAccess);
                    var stash = StashManager.GetStash(file.Filename);
                    if (stash != null)
                    {
                        _dynamicPacker.Initialize(stash.Width, stash.Height);
                        if (stash.Tabs.Count >= 3)
                        {
                            foreach (var item in stash.Tabs[2].Items)
                            {
                                byte[] bx = BitConverter.GetBytes(item.XOffset);
                                uint   x  = (uint)BitConverter.ToSingle(bx, 0);

                                byte[] by = BitConverter.GetBytes(item.YOffset);
                                uint   y  = (uint)BitConverter.ToSingle(by, 0);

                                _dynamicPacker.Insert(item.BaseRecord, item.Seed, x, y);
                            }
                        }
                    }
                }
            }

            _messageProcessors.Add(new ItemPositionFinder(_dynamicPacker));
            _messageProcessors.Add(new PlayerPositionTracker());
            _messageProcessors.Add(new StashStatusHandler());
            _messageProcessors.Add(new ItemReceivedProcessor(_searchWindow, _stashFileMonitor, _playerItemDao));
            _messageProcessors.Add(new ItemInjectCallbackProcessor(_searchWindow.UpdateListViewDelayed, _playerItemDao));
            _messageProcessors.Add(new ItemSpawnedProcessor());
            _messageProcessors.Add(new CloudDetectorProcessor(SetFeedback));
            _messageProcessors.Add(new GenericErrorHandler());
            //messageProcessors.Add(new LogMessageProcessor());
#if DEBUG
            //messageProcessors.Add(new DebugMessageProcessor());
#endif

            GlobalSettings.StashStatusChanged += GlobalSettings_StashStatusChanged;

            _transferController = new ItemTransferController(
                _cefBrowserHandler,
                SetFeedback,
                SetTooltipAtmouse,
                _settingsController,
                _searchWindow,
                _dynamicPacker,
                _playerItemDao,
                _stashManager,
                new ItemStatService(_databaseItemStatDao, _itemSkillDao)
                );
            Application.AddMessageFilter(new MousewheelMessageFilter());


            var titleTag = GlobalSettings.Language.GetTag("iatag_ui_itemassistant");
            if (!string.IsNullOrEmpty(titleTag))
            {
                this.Text += $" - {titleTag}";
            }


            // Popup login diag
            if (_authAuthService.CheckAuthentication() == AzureAuthService.AccessStatus.Unauthorized)
            {
                var t = new System.Windows.Forms.Timer {
                    Interval = 100
                };
                t.Tick += (o, args) => {
                    if (_cefBrowserHandler.BrowserControl.IsBrowserInitialized)
                    {
                        _authAuthService.Authenticate();
                        t.Stop();
                    }
                };
                t.Start();
            }


            _cefBrowserHandler.TransferSingleRequested += TransferSingleItem;
            _cefBrowserHandler.TransferAllRequested    += TransferAllItems;
            new WindowSizeManager(this);
        }
Exemplo n.º 19
0
        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();
        }
Exemplo n.º 20
0
        private void MainWindow_Load(object sender, EventArgs e)
        {
            if (Thread.CurrentThread.Name == null)
            {
                Thread.CurrentThread.Name = "UI";
            }
            Logger.Debug("Starting UI initialization");

            ExceptionReporter.EnableLogUnhandledOnThread();
            SizeChanged += OnMinimizeWindow;


            var cacher = new TransferStashServiceCache(_databaseItemDao);

            _parsingService.OnParseComplete += (o, args) => cacher.Refresh();

            var stashWriter = new SafeTransferStashWriter(_settingsService);

            _transferStashService = new TransferStashService(_databaseItemStatDao, _settingsService, stashWriter);
            var transferStashService2 = new TransferStashService2(_playerItemDao, cacher, _transferStashService, stashWriter, _settingsService);

            _transferStashWorker = new TransferStashWorker(transferStashService2, _userFeedbackService);

            _stashFileMonitor.OnStashModified += (_, __) => {
                StashEventArg args = __ as StashEventArg;
                _transferStashWorker.Queue(args?.Filename);
            };

            if (!_stashFileMonitor.StartMonitorStashfile(GlobalPaths.SavePath))
            {
                MessageBox.Show("Ooops!\nIt seems you are synchronizing your saves to steam cloud..\nThis tool is unfortunately not compatible.\n");
                HelpService.ShowHelp(HelpService.HelpType.CloudSavesEnabled);

                Logger.Warn("Shutting down IA, unable to monitor stash files.");

                if (!Debugger.IsAttached)
                {
                    Close();
                }
            }

            // Chicken and the egg..
            SearchController searchController = new SearchController(
                _databaseItemDao,
                _playerItemDao,
                _databaseItemStatDao,
                _itemSkillDao,
                _buddyItemDao,
                _augmentationItemRepo,
                _settingsService
                );

            searchController.JsBind.SetItemSetAssociations(_databaseItemDao.GetItemSetAssociations());
            _cefBrowserHandler.InitializeChromium(searchController.JsBind, Browser_IsBrowserInitializedChanged);
            searchController.Browser             = _cefBrowserHandler;
            searchController.JsBind.OnClipboard += SetItemsClipboard;

            // Load the grim database
            string gdPath = _grimDawnDetector.GetGrimLocation();

            if (!string.IsNullOrEmpty(gdPath))
            {
            }
            else
            {
                Logger.Warn("Could not find the Grim Dawn install location");
                statusLabel.Text = "Could not find the Grim Dawn install location";

                var timer = new System.Windows.Forms.Timer();
                timer.Tick    += TimerTickLookForGrimDawn;
                timer.Interval = 10000;
                timer.Start();
            }

            // Load recipes
            foreach (string file in GlobalPaths.FormulasFiles)
            {
                if (!string.IsNullOrEmpty(file))
                {
                    bool isHardcore = file.EndsWith("gsh");
                    Logger.InfoFormat("Reading recipes at \"{0}\", IsHardcore={1}", file, isHardcore);
                    _recipeParser.UpdateFormulas(file, isHardcore);
                }
            }

            var addAndShow = UIHelper.AddAndShow;

            // Create the tab contents
            _buddySettingsWindow = new BuddySettings(delegate(bool b) { BuddySyncEnabled = b; },
                                                     _buddyItemDao,
                                                     _buddySubscriptionDao,
                                                     _settingsService
                                                     );

            addAndShow(_buddySettingsWindow, buddyPanel);

            _authAuthService = new AzureAuthService(_cefBrowserHandler, new AuthenticationProvider(_settingsService));
            var backupSettings = new BackupSettings(_playerItemDao, _authAuthService, _settingsService);

            addAndShow(backupSettings, backupPanel);
            addAndShow(new ModsDatabaseConfig(DatabaseLoadedTrigger, _playerItemDao, _parsingService, _databaseSettingDao, _grimDawnDetector, _settingsService), modsPanel);
            addAndShow(new HelpTab(), panelHelp);
            addAndShow(new LoggingWindow(), panelLogging);
            var backupService = new BackupService(_authAuthService, _playerItemDao, _azurePartitionDao, () => _settingsService.GetPersistent().UsingDualComputer);

            _backupServiceWorker            = new BackupServiceWorker(backupService);
            backupService.OnUploadComplete += (o, args) => _searchWindow.UpdateListView();
            searchController.OnSearch      += (o, args) => backupService.OnSearch();

            _searchWindow = new SplitSearchWindow(_cefBrowserHandler.BrowserControl, SetFeedback, _playerItemDao, searchController, _itemTagDao, _settingsService);
            addAndShow(_searchWindow, searchPanel);

            transferStashService2.OnUpdate += (_, __) => {
                _searchWindow.UpdateListView();
            };

            var languagePackPicker = new LanguagePackPicker(_itemTagDao, _playerItemDao, _parsingService, _settingsService);

            addAndShow(
                new SettingsWindow(
                    _cefBrowserHandler,
                    _tooltipHelper,
                    ListviewUpdateTrigger,
                    _playerItemDao,
                    _searchWindow.ModSelectionHandler.GetAvailableModSelection(),
                    _transferStashService,
                    transferStashService2,
                    languagePackPicker,
                    _settingsService,
                    _grimDawnDetector
                    ),
                settingsPanel);

#if !DEBUG
            ThreadPool.QueueUserWorkItem(m => ExceptionReporter.ReportUsage());
            _automaticUpdateChecker.CheckForUpdates();
#endif

            Shown += (_, __) => { StartInjector(); };

            //settingsController.Data.budd

            BuddySyncEnabled = _settingsService.GetPersistent().BuddySyncEnabled;

            // Start the backup task
            _backupBackgroundTask = new BackgroundTask(new FileBackup(_playerItemDao, _settingsService));

            LocalizationLoader.ApplyLanguage(Controls, RuntimeSettings.Language);
            new EasterEgg(_settingsService).Activate(this);

            // Initialize the "stash packer" used to find item positions for transferring items ingame while the stash is open
            {
                _dynamicPacker.Initialize(8, 16);

                var transferFiles = GlobalPaths.TransferFiles;
                if (transferFiles.Count > 0)
                {
                    var file  = transferFiles.MaxBy(m => m.LastAccess);
                    var stash = TransferStashService.GetStash(file.Filename);
                    if (stash != null)
                    {
                        _dynamicPacker.Initialize(stash.Width, stash.Height);
                        if (stash.Tabs.Count >= 3)
                        {
                            foreach (var item in stash.Tabs[2].Items)
                            {
                                byte[] bx = BitConverter.GetBytes(item.XOffset);
                                uint   x  = (uint)BitConverter.ToSingle(bx, 0);

                                byte[] by = BitConverter.GetBytes(item.YOffset);
                                uint   y  = (uint)BitConverter.ToSingle(by, 0);

                                _dynamicPacker.Insert(item.BaseRecord, item.Seed, x, y);
                            }
                        }
                    }
                }
            }

            _messageProcessors.Add(new ItemPositionFinder(_dynamicPacker));
            _messageProcessors.Add(new PlayerPositionTracker(Debugger.IsAttached && false));
            _messageProcessors.Add(new StashStatusHandler());
            _messageProcessors.Add(new ItemSpawnedProcessor());
            _messageProcessors.Add(new CloudDetectorProcessor(SetFeedback));
            _messageProcessors.Add(new GenericErrorHandler());
            //messageProcessors.Add(new LogMessageProcessor());
#if DEBUG
            _messageProcessors.Add(new DebugMessageProcessor());
#endif

            RuntimeSettings.StashStatusChanged += GlobalSettings_StashStatusChanged;

            _transferController = new ItemTransferController(
                _cefBrowserHandler,
                SetFeedback,
                SetTooltipAtmouse,
                _settingsController,
                _searchWindow,
                _dynamicPacker,
                _playerItemDao,
                _transferStashService,
                new ItemStatService(_databaseItemStatDao, _itemSkillDao, _settingsService)
                );
            Application.AddMessageFilter(new MousewheelMessageFilter());


            var titleTag = RuntimeSettings.Language.GetTag("iatag_ui_itemassistant");
            if (!string.IsNullOrEmpty(titleTag))
            {
                this.Text += $" - {titleTag}";
            }


            // Popup login diag

            if (_authAuthService.CheckAuthentication() == AzureAuthService.AccessStatus.Unauthorized && !_settingsService.GetLocal().OptOutOfBackups)
            {
                var t = new System.Windows.Forms.Timer {
                    Interval = 100
                };
                t.Tick += (o, args) => {
                    if (_cefBrowserHandler.BrowserControl.IsBrowserInitialized)
                    {
                        _authAuthService.Authenticate();
                        t.Stop();
                    }
                };
                t.Start();
            }


            _cefBrowserHandler.TransferSingleRequested += TransferSingleItem;
            _cefBrowserHandler.TransferAllRequested    += TransferAllItems;
            new WindowSizeManager(this, _settingsService);


            // Suggest translation packs if available

            if (!string.IsNullOrEmpty(_settingsService.GetLocal().LocalizationFile) && !_settingsService.GetLocal().HasSuggestedLanguageChange)
            {
                if (LocalizationLoader.HasSupportedTranslations(_grimDawnDetector.GetGrimLocations()))
                {
                    Logger.Debug("A new language pack has been detected, informing end user..");
                    new LanguagePackPicker(_itemTagDao, _playerItemDao, _parsingService, _settingsService).Show(_grimDawnDetector.GetGrimLocations());

                    _settingsService.GetLocal().HasSuggestedLanguageChange = true;
                }
            }
            Logger.Debug("UI initialization complete");
        }
Exemplo n.º 21
0
        private void MainWindow_Load(object sender, EventArgs e) {
            if (Thread.CurrentThread.Name == null)
                Thread.CurrentThread.Name = "UI";


            ExceptionReporter.EnableLogUnhandledOnThread();
            SizeChanged += OnMinimizeWindow;

            buttonDevTools.Visible = Debugger.IsAttached;


            _stashManager = new StashManager(_playerItemDao, _databaseItemStatDao);
            if (!_stashManager.StartMonitorStashfile(SetFeedback, ListviewUpdateTrigger)) {
                MessageBox.Show("Ooops!\nIt seems you are synchronizing your saves to steam cloud..\nThis tool is unfortunately not compatible.\n");
                Process.Start("http://www.grimdawn.com/forums/showthread.php?t=20752");

                if (!Debugger.IsAttached)
                    Close();

            }

            //ItemHtmlWriter.Write(new List<PlayerHeldItem>());

            // Chicken and the egg..
            SearchController searchController = new SearchController(
                _databaseItemDao,
                _playerItemDao, 
                _databaseItemStatDao, 
                _itemSkillDao, 
                _buddyItemDao,
                _stashManager
                );
            _cefBrowserHandler.InitializeChromium(searchController.JsBind, Browser_IsBrowserInitializedChanged);
            searchController.Browser = _cefBrowserHandler;
            searchController.JsBind.OnTransfer += TransferItem;
            searchController.JsBind.OnClipboard += SetItemsClipboard;

            // Load the grim database
            string gdPath = GrimDawnDetector.GetGrimLocation();
            if (!string.IsNullOrEmpty(gdPath)) {
            } else {
                Logger.Warn("Could not find the Grim Dawn install location");
                statusLabel.Text = "Could not find the Grim Dawn install location";

                var timer = new System.Windows.Forms.Timer();
                timer.Tick += TimerTickLookForGrimDawn;
                timer.Interval = 10000;
                timer.Start();
            }

    

            var addAndShow = UIHelper.AddAndShow;


            // Create the tab contents
            _buddySettingsWindow = new BuddySettings(delegate (bool b) { BuddySyncEnabled = b; }, 
                _buddyItemDao, 
                _buddySubscriptionDao
                );

            addAndShow(_buddySettingsWindow, buddyPanel);

            var backupSettings = new BackupSettings(EnableOnlineBackups, _playerItemDao);
            tabControl1.Selected += ((s, ev) => {
                if (ev.TabPage == tabPageBackups)
                    backupSettings?.BackupSettings_GotFocus();
            });
            addAndShow(backupSettings, backupPanel);
            addAndShow(new ModsDatabaseConfig(DatabaseLoadedTrigger, _databaseSettingDao, _arzParser, _playerItemDao), modsPanel);
            addAndShow(new HelpTab(), panelHelp);            
            addAndShow(new LoggingWindow(), panelLogging);


            _searchWindow = new SearchWindow(_cefBrowserHandler.BrowserControl, SetFeedback, _playerItemDao, searchController, _databaseItemDao);
            addAndShow(_searchWindow, searchPanel);


            addAndShow(
                new SettingsWindow(_tooltipHelper,
                    ListviewUpdateTrigger,
                    _databaseSettingDao,
                    _databaseItemDao,
                    _playerItemDao,
                    _arzParser,
                    _searchWindow.ModSelectionHandler.GetAvailableModSelection(),
                    _stashManager
                ),
                settingsPanel);


            new StashTabPicker(_stashManager.NumStashTabs).SaveStashSettingsToRegistry();

#if !DEBUG
            ThreadPool.QueueUserWorkItem(m => ExceptionReporter.ReportUsage());
            CheckForUpdates();
#endif

            int min = 1000 * 60;
            int hour = 60 * min;
            _timerReportUsage = new Timer();
            _timerReportUsage.Start();
            _timerReportUsage.Elapsed += (a1, a2) => {
                if (Thread.CurrentThread.Name == null)
                    Thread.CurrentThread.Name = "ReportUsageThread";
                ReportUsage();
            };
            _timerReportUsage.Interval = 12 * hour;
            _timerReportUsage.AutoReset = true;
            _timerReportUsage.Start();


            Shown += (_, __) => { StartInjector(); };

            //settingsController.Data.budd
            BuddySyncEnabled = (bool)Settings.Default.BuddySyncEnabled;

            // Start the backup task
            _backupBackgroundTask = new BackgroundTask(new CloudBackup(_playerItemDao));



            LocalizationLoader.ApplyLanguage(Controls, GlobalSettings.Language);
            EasterEgg.Activate(this);
Exemplo n.º 22
0
        private void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            if (Thread.CurrentThread.Name == null)
            {
                Thread.CurrentThread.Name             = "BuddyBackground";
                Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US");
            }

            ExceptionReporter.EnableLogUnhandledOnThread();

            BackgroundWorker worker = sender as BackgroundWorker;

            while (!worker.CancellationPending)
            {
                try {
                    Thread.Sleep(5000);

                    var missingNames = _buddyItemDao.ListItemsWithMissingName();
                    _buddyItemDao.UpdateNames(missingNames);

                    if (_settings.GetLocal().OptOutOfBackups)
                    {
                        Logger.Info("User opted out of online features, disabling buddy items.");
                        return;
                    }

                    if (_authService.GetRestService() == null)
                    {
                        // Logger.Info("Not logged into online backups, skipping buddy sync");
                        _cooldowns.Clear();
                        continue;
                    }

                    var subscriptions = _subscriptionRepo.ListAll();
                    foreach (var subscription in subscriptions)
                    {
                        if (subscription.Id <= 9999)
                        {
                            // TODO: Delete legacy
                            continue;
                        }

                        // Cooldown per user (so that newly added ones gets fetched fairly fast)
                        if (!_cooldowns.ContainsKey(subscription.Id))
                        {
                            _cooldowns[subscription.Id] = new ActionCooldown(_defaultCooldown);
                        }
                        if (!_cooldowns[subscription.Id].IsReady)
                        {
                            continue;
                        }

                        Logger.Debug($"Downloading items for buddy {subscription.Nickname} ({subscription.Id}) with TS > {subscription.LastSyncTimestamp}");
                        SyncDown(subscription);
                        _cooldowns[subscription.Id].Reset();
                    }

                    // Fetch own buddy id, if missing.
                    var buddyId = _settings.GetPersistent().BuddySyncUserIdV3;
                    if (!buddyId.HasValue || buddyId <= 0)
                    {
                        Logger.Info("Fetching own buddy ID from cloud");
                        var id = _authService.GetRestService()?.Get <BuddyIdResult>(Uris.GetBuddyIdUrl);
                        _settings.GetPersistent().BuddySyncUserIdV3 = id.Id;
                    }
                }
                catch (NullReferenceException ex) {
                    Logger.Info("The following exception is logged, but can safely be ignored:");
                    Logger.Warn(ex.Message);
                    Logger.Warn(ex.StackTrace);
                }
                catch (Exception ex) {
                    Logger.Error(ex.Message);
                    Logger.Error(ex.StackTrace);
                }
            }
        }
Exemplo n.º 23
0
        public void Start()
        {
            // Queue any existing files
            foreach (var file in Directory.EnumerateFiles(GlobalPaths.CsvLocation))
            {
                _queue.Enqueue(new QueuedCsv {
                    Filename = file,
                    Cooldown = new ActionCooldown(0)
                });
            }


            // Process any newly added files. Threaded to ensure a proper delay between write and read.
            var t = new Thread(() => {
                ExceptionReporter.EnableLogUnhandledOnThread();

                while (!_isCancelled)
                {
                    Thread.Sleep(500);
                    if (!_queue.TryDequeue(out var entry))
                    {
                        continue;
                    }
                    try {
                        if (entry.Cooldown.IsReady)
                        {
                            PlayerItem item = Parse(File.ReadAllText(entry.Filename));
                            if (item == null)
                            {
                                continue;
                            }

                            // CSV probably wont have stackcount
                            item.StackCount   = Math.Max(item.StackCount, 1);
                            item.CreationDate = DateTime.UtcNow.ToTimestamp();

                            var classificationService = new ItemClassificationService(_cache, _playerItemDao);
                            classificationService.Add(item);

                            // Items to loot
                            if (classificationService.Remaining.Count > 0)
                            {
                                _playerItemDao.Save(item);
                                File.Delete(entry.Filename);

                                // Update replica reference
                                var hash = ItemReplicaService.GetHash(item);
                                _replicaItemDao.UpdatePlayerItemId(hash, item.Id);
                            }
                            else if (classificationService.Duplicates.Count > 0 && _settings.GetPersistent().DeleteDuplicates)
                            {
                                Logger.Info("Deleting duplicate item file");
                                File.Delete(entry.Filename);
                            }
                            else
                            {
                                // Transfer back in-game, should never have been looted.
                                // TODO: Separate transfer logic.. no delete-from-db etc..
                                if (RuntimeSettings.StashStatus == StashAvailability.CLOSED)
                                {
                                    string stashfile = _itemTransferController.GetTransferFile();
                                    _transferStashService.Deposit(stashfile, new List <PlayerItem> {
                                        item
                                    }, out string error);
                                    if (string.IsNullOrEmpty(error))
                                    {
                                        Logger.Info("Deposited item back in-game, did not pass item classification.");
                                        File.Delete(entry.Filename);
                                    }
                                    else
                                    {
                                        Logger.Warn("Failed re-depositing back into GD");
                                        _queue.Enqueue(entry);
                                    }
                                }
                                else
                                {
                                    _queue.Enqueue(entry);
                                }
                            }
                        }
                        else
                        {
                            _queue.Enqueue(entry);
                        }
                    }
                    catch (Exception ex) {
                        Logger.Warn("Error handling CSV item file", ex);
                    }
                }
            });

            t.Start();
        }
Exemplo n.º 24
0
        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");
        }
Exemplo n.º 25
0
        private void CustomWndProc(RegisterWindow.DataAndType bt)
        {
            if (Thread.CurrentThread.Name == null)
            {
                Thread.CurrentThread.Name = "Core";
                ExceptionReporter.EnableLogUnhandledOnThread();
            }

            if (_isFirstMessage)
            {
                Logger.Debug("Window message received");
                _isFirstMessage = false;
                OnHookActivation?.Invoke(null, null);
            }


            MessageType type = (MessageType)bt.Type;

            foreach (var processor in _processors)
            {
                if (processor.Process(type, bt.Data))
                {
                    if (_appSettings.LogProcessedMessages)
                    {
                        Logger.Debug($"Processor {processor.GetType().ToString()} handled message");
                    }
                    return;
                }
            }

            if (bt.Type == 999111)   // apply-damage experimental
            {
                Logger.Debug("CM:TakeAttack()");
            }
            else if (bt.Type == 929002)
            {
                Logger.Debug("CharacterBio::GetAllDefenseAttributes()");
            }
            else if (bt.Type == 929022)
            {
                //Logger.Debug("CharAttributeAccumulator::ExecuteDefense()");
            }
            else if (bt.Type == 929222)
            {
                int ptr = IOHelper.GetInt(bt.Data, 0);
                Logger.Fatal($"DECONSTRUCTION! {ptr}");
                Logger.Fatal($"DECONSTRUCTION! {ptr}");
                Logger.Fatal($"DECONSTRUCTION! {ptr}");
                Logger.Fatal($"DECONSTRUCTION! {ptr}");
                Logger.Fatal($"DECONSTRUCTION! {ptr}");
                Logger.Fatal($"DECONSTRUCTION! {ptr}");
                Logger.Fatal($"DECONSTRUCTION! {ptr}");
                Logger.Fatal($"DECONSTRUCTION! {ptr}");
                Logger.Fatal($"DECONSTRUCTION! {ptr}");
                Logger.Fatal($"DECONSTRUCTION! {ptr}");
                Logger.Fatal($"DECONSTRUCTION! {ptr}");
            }
            else if (bt.Type == 999001)
            {
                Logger.Debug("Character::TakeAttack()");
            }
            else if (bt.Type == 929003)
            {
                Logger.Debug("ItemEquipment::GetAllDefenseAttributes()");
            }
            else if (bt.Type == 929001)
            {
                int   entityId  = IOHelper.GetInt(bt.Data, 0);
                float fire      = IOHelper.GetFloat(bt.Data, 4);
                float cold      = IOHelper.GetFloat(bt.Data, 8);
                float lightning = IOHelper.GetFloat(bt.Data, 12);
                float poison    = IOHelper.GetFloat(bt.Data, 16);
                float pierce    = IOHelper.GetFloat(bt.Data, 20);
                float bleed     = IOHelper.GetFloat(bt.Data, 24);
                float vitality  = IOHelper.GetFloat(bt.Data, 28);
                float chaos     = IOHelper.GetFloat(bt.Data, 32);
                float aether    = IOHelper.GetFloat(bt.Data, 36);
                Logger.Debug($"CombatAttributeAccumulator::ProcessDefenseMethod() =>  {entityId} with Fire:{fire}, Cold:{cold}, Lightning:{lightning}, Poison:{poison}, Pierce:{pierce}, Bleed:{bleed}, Vitality:{vitality}, Chaos:{chaos}, Aether:{aether}");
            }
            else if (bt.Type == 10101012)   // apply-damage experimental
            // This produces exact matches to "^y    Damage 0,474187463521957 to Defender 0x101028 (Vitality)" // Just not the defender
            // ^bShield: Reduced (75,5949020385742) Damage by (5,33183132285327E-315%) percent, remaining damage (12)
            // Lists the 75, but not the 12
            {
                float f = IOHelper.GetFloat(bt.Data, 0);
                int   playStatsDamageType = IOHelper.GetInt(bt.Data, 4);
                int   combatAttributeType = IOHelper.GetInt(bt.Data, 8);
                Logger.Debug($"ApplyDamage({f}, {playStatsDamageType}, {combatAttributeType})");
            }
            else if (bt.Type == 999003)
            {
                //Logger.Debug($"SkillManager::GetDefenseAttributes called for {IOHelper.GetInt(bt.Data, 0)}");
                int   entityId  = IOHelper.GetInt(bt.Data, 0);
                float fire      = IOHelper.GetFloat(bt.Data, 4);
                float cold      = IOHelper.GetFloat(bt.Data, 8);
                float lightning = IOHelper.GetFloat(bt.Data, 12);
                float poison    = IOHelper.GetFloat(bt.Data, 16);
                float pierce    = IOHelper.GetFloat(bt.Data, 20);
                float bleed     = IOHelper.GetFloat(bt.Data, 24);
                float vitality  = IOHelper.GetFloat(bt.Data, 28);
                float chaos     = IOHelper.GetFloat(bt.Data, 32);
                float aether    = IOHelper.GetFloat(bt.Data, 36);
                Logger.Debug($"SkillManager::GetDefenseAttributes called for {entityId} with Fire:{fire}, Cold:{cold}, Lightning:{lightning}, Poison:{poison}, Pierce:{pierce}, Bleed:{bleed}, Vitality:{vitality}, Chaos:{chaos}, Aether:{aether}");
            }

            else if (bt.Type == 999002)
            {
                int   entityId  = IOHelper.GetInt(bt.Data, 0);
                float fire      = IOHelper.GetFloat(bt.Data, 4);
                float cold      = IOHelper.GetFloat(bt.Data, 8);
                float lightning = IOHelper.GetFloat(bt.Data, 12);
                float poison    = IOHelper.GetFloat(bt.Data, 16);
                float pierce    = IOHelper.GetFloat(bt.Data, 20);
                float bleed     = IOHelper.GetFloat(bt.Data, 24);
                float vitality  = IOHelper.GetFloat(bt.Data, 28);
                float chaos     = IOHelper.GetFloat(bt.Data, 32);
                float aether    = IOHelper.GetFloat(bt.Data, 36);
                Logger.Debug($"Character::GetAllDefenseAttributes called for {entityId} with Fire:{fire}, Cold:{cold}, Lightning:{lightning}, Poison:{poison}, Pierce:{pierce}, Bleed:{bleed}, Vitality:{vitality}, Chaos:{chaos}, Aether:{aether}");
            }
            else
            {
                Logger.Warn($"Got a message of type {bt.Type}");
            }
        }
Exemplo n.º 26
0
        private void MainWindow_Load(object sender, EventArgs e)
        {
            if (Thread.CurrentThread.Name == null)
            {
                Thread.CurrentThread.Name = "UI";
            }

            Logger.Debug("Starting UI initialization");


            // Set version number
            var      version   = Assembly.GetExecutingAssembly().GetName().Version;
            DateTime buildDate = new DateTime(2000, 1, 1)
                                 .AddDays(version.Build)
                                 .AddSeconds(version.Revision * 2);

            statusLabel.Text = statusLabel.Text + $" - {version.Major}.{version.Minor}.{version.Build}.{version.Revision} from {buildDate.ToString("dd/MM/yyyy")}";


            var settingsService = _serviceProvider.Get <SettingsService>();

            ExceptionReporter.EnableLogUnhandledOnThread();
            SizeChanged += OnMinimizeWindow;


            // Chicken and the egg.. search controller needs browser, browser needs search controllers var.
            var databaseItemDao  = _serviceProvider.Get <IDatabaseItemDao>();
            var searchController = _serviceProvider.Get <SearchController>();

            searchController.JsIntegration.OnRequestSetItemAssociations += (s, evvv) => { (evvv as GetSetItemAssociationsEventArgs).Elements = databaseItemDao.GetItemSetAssociations(); };

            _cefBrowserHandler.InitializeChromium(searchController.JsIntegration, Browser_IsBrowserInitializedChanged, tabControl1);
            searchController.Browser = _cefBrowserHandler;
            searchController.JsIntegration.OnClipboard += SetItemsClipboard;
            searchController.JsIntegration.OnRequestFeatureRecommendation += (o, args) => {
                var features = settingsService.GetPersistent().FeaturesNotShown;
                (args as FeatureSuggestionArgs).Feature    = features.FirstOrDefault();
                (args as FeatureSuggestionArgs).HasFeature = features.Count > 0;
            };
            searchController.JsIntegration.OnSeenFeatureRecommendation += (o, args) => settingsService.GetPersistent().AddShownFeature((args as FeatureSuggestionArgs).Feature);

            var playerItemDao = _serviceProvider.Get <IPlayerItemDao>();
            var cacher        = _serviceProvider.Get <TransferStashServiceCache>();

            _parsingService.OnParseComplete += (o, args) => cacher.Refresh();


            var stashWriter           = new SafeTransferStashWriter(settingsService, _cefBrowserHandler);
            var transferStashService  = new TransferStashService(_serviceProvider.Get <IDatabaseItemStatDao>(), settingsService, stashWriter);
            var transferStashService2 = new TransferStashService2(playerItemDao, cacher, transferStashService, stashWriter, settingsService, _cefBrowserHandler);

            _serviceProvider.Add(transferStashService2);

            _transferStashWorker = new TransferStashWorker(transferStashService2, _userFeedbackService);

            _stashFileMonitor.OnStashModified += (_, __) => {
                StashEventArg args = __ as StashEventArg;
                _transferStashWorker.Queue(args?.Filename);

                // May not minimize, but
                _usageStatisticsReporter.ResetLastMinimized();
                _automaticUpdateChecker.ResetLastMinimized();
            };

            if (!_stashFileMonitor.StartMonitorStashfile(GlobalPaths.SavePath))
            {
                MessageBox.Show("Ooops!\nIt seems you are synchronizing your saves to steam cloud..\nThis tool is unfortunately not compatible.\n");
                _cefBrowserHandler.ShowHelp(HelpService.HelpType.CloudSavesEnabled);

                Logger.Warn("Shutting down IA, unable to monitor stash files.");

                if (!Debugger.IsAttached)
                {
                    Close();
                }
            }

            // Load the grim database
            var    grimDawnDetector = _serviceProvider.Get <GrimDawnDetector>();
            string gdPath           = grimDawnDetector.GetGrimLocation();

            if (!string.IsNullOrEmpty(gdPath))
            {
            }
            else
            {
                Logger.Warn("Could not find the Grim Dawn install location");
                statusLabel.Text = "Could not find the Grim Dawn install location";

                var timer = new System.Windows.Forms.Timer();
                timer.Tick    += TimerTickLookForGrimDawn;
                timer.Interval = 10000;
                timer.Start();
            }

            // Load recipes
            foreach (string file in GlobalPaths.FormulasFiles)
            {
                if (!string.IsNullOrEmpty(file))
                {
                    bool isHardcore = file.EndsWith("gsh");
                    Logger.InfoFormat("Reading recipes at \"{0}\", IsHardcore={1}", file, isHardcore);
                    _recipeParser.UpdateFormulas(file, isHardcore);
                }
            }


            var buddyItemDao         = _serviceProvider.Get <IBuddyItemDao>();
            var buddySubscriptionDao = _serviceProvider.Get <IBuddySubscriptionDao>();



            var databaseSettingDao = _serviceProvider.Get <IDatabaseSettingDao>();

            _authService = new AuthService(_cefBrowserHandler, new AuthenticationProvider(settingsService), playerItemDao);
            var backupSettings = new BackupSettings(playerItemDao, settingsService, _cefBrowserHandler);

            UIHelper.AddAndShow(backupSettings, backupPanel);

            // TODO: buttonLogin.Visible = !BlockedLogsDetection.DreamcrashBlocked();
            var onlineSettings = new OnlineSettings(playerItemDao, _authService, settingsService, _cefBrowserHandler, buddyItemDao, buddySubscriptionDao);

            UIHelper.AddAndShow(onlineSettings, onlinePanel);
            _cefBrowserHandler.OnAuthSuccess += (_, __) => onlineSettings.UpdateUi();


            UIHelper.AddAndShow(new ModsDatabaseConfig(DatabaseLoadedTrigger, playerItemDao, _parsingService, databaseSettingDao, grimDawnDetector, settingsService, _cefBrowserHandler), modsPanel);

            if (!BlockedLogsDetection.DreamcrashBlocked())
            {
                UIHelper.AddAndShow(new LoggingWindow(), panelLogging);
            }

            var itemTagDao    = _serviceProvider.Get <IItemTagDao>();
            var backupService = new BackupService(_authService, playerItemDao, settingsService);

            _charBackupService   = new CharacterBackupService(settingsService, _authService);
            _backupServiceWorker = new BackupServiceWorker(backupService, _charBackupService);
            searchController.JsIntegration.OnRequestBackedUpCharacterList += (_, args) => {
                RequestCharacterListEventArg a = args as RequestCharacterListEventArg;
                a.Characters = _charBackupService.ListBackedUpCharacters();
            };
            searchController.JsIntegration.OnRequestCharacterDownloadUrl += (_, args) => {
                RequestCharacterDownloadUrlEventArg a = args as RequestCharacterDownloadUrlEventArg;
                a.Url = _charBackupService.GetDownloadUrl(a.Character);
            };

            backupService.OnUploadComplete += (o, args) => _searchWindow.UpdateListView();
            searchController.OnSearch      += (o, args) => backupService.OnSearch();

            _searchWindow = new SplitSearchWindow(_cefBrowserHandler.BrowserControl, SetFeedback, playerItemDao, searchController, itemTagDao, settingsService);
            UIHelper.AddAndShow(_searchWindow, searchPanel);

            searchPanel.Height = searchPanel.Parent.Height;
            searchPanel.Width  = searchPanel.Parent.Width;

            transferStashService2.OnUpdate += (_, __) => { _searchWindow.UpdateListView(); };

            var languagePackPicker = new LanguagePackPicker(itemTagDao, playerItemDao, _parsingService, settingsService);


            var dm = new DarkMode(this);

            UIHelper.AddAndShow(
                new SettingsWindow(
                    _cefBrowserHandler,
                    _tooltipHelper,
                    ListviewUpdateTrigger,
                    playerItemDao,
                    _searchWindow.ModSelectionHandler.GetAvailableModSelection(),
                    transferStashService,
                    transferStashService2,
                    languagePackPicker,
                    settingsService,
                    grimDawnDetector,
                    dm
                    ),
                settingsPanel);

#if !DEBUG
            if (!BlockedLogsDetection.DreamcrashBlocked())   // Uses dreamcrash server
            {
                ThreadPool.QueueUserWorkItem(m => ExceptionReporter.ReportUsage());
                _automaticUpdateChecker.CheckForUpdates();
            }
#endif

            Shown += (_, __) => { StartInjector(); };
            _buddyItemsService = new BuddyItemsService(
                buddyItemDao,
                3 * 60 * 1000,
                settingsService,
                _authService,
                buddySubscriptionDao
                );

            // Start the backup task
            _backupBackgroundTask = new BackgroundTask(new FileBackup(playerItemDao, settingsService));

            LocalizationLoader.ApplyLanguage(Controls, RuntimeSettings.Language);
            new EasterEgg(settingsService).Activate(this);

            // Initialize the "stash packer" used to find item positions for transferring items ingame while the stash is open
            {
                _dynamicPacker.Initialize(8, 16);

                var transferFiles = GlobalPaths.TransferFiles;
                if (transferFiles.Count > 0)
                {
                    var file  = transferFiles.MaxBy(m => m.LastAccess);
                    var stash = TransferStashService.GetStash(file.Filename);
                    if (stash != null)
                    {
                        _dynamicPacker.Initialize(stash.Width, stash.Height);
                        if (stash.Tabs.Count >= 3)
                        {
                            foreach (var item in stash.Tabs[2].Items)
                            {
                                byte[] bx = BitConverter.GetBytes(item.XOffset);
                                uint   x  = (uint)BitConverter.ToSingle(bx, 0);

                                byte[] by = BitConverter.GetBytes(item.YOffset);
                                uint   y  = (uint)BitConverter.ToSingle(by, 0);

                                _dynamicPacker.Insert(item.BaseRecord, item.Seed, x, y);
                            }
                        }
                    }
                }
            }

            _messageProcessors.Add(new ItemPositionFinder(_dynamicPacker));
            _messageProcessors.Add(new PlayerPositionTracker(Debugger.IsAttached && false));
            _messageProcessors.Add(new StashStatusHandler());
            _messageProcessors.Add(new CloudDetectorProcessor(SetFeedback));
            _messageProcessors.Add(new GenericErrorHandler());


            RuntimeSettings.StashStatusChanged += GlobalSettings_StashStatusChanged;

            _transferController = new ItemTransferController(
                _cefBrowserHandler,
                SetFeedback,
                SetTooltipAtmouse,
                _searchWindow,
                playerItemDao,
                transferStashService,
                _serviceProvider.Get <ItemStatService>(),
                settingsService
                );
            Application.AddMessageFilter(new MousewheelMessageFilter());


            var titleTag = RuntimeSettings.Language.GetTag("iatag_ui_itemassistant");
            if (!string.IsNullOrEmpty(titleTag))
            {
                this.Text += $" - {titleTag}";
            }


            // Popup login diag
            if (_authService.CheckAuthentication() == AuthService.AccessStatus.Unauthorized && !settingsService.GetLocal().OptOutOfBackups)
            {
                if (!BlockedLogsDetection.DreamcrashBlocked())
                {
                    // Backup login wont work
                    var t = new System.Windows.Forms.Timer {
                        Interval = 100
                    };
                    t.Tick += (o, args) => {
                        if (_cefBrowserHandler.BrowserControl.CanExecuteJavascriptInMainFrame)
                        {
                            _authService.Authenticate();
                            t.Stop();
                        }
                    };
                    t.Start();
                }
            }


            searchController.JsIntegration.ItemTransferEvent += TransferItem;
            new WindowSizeManager(this, settingsService);


            // Suggest translation packs if available
            if (string.IsNullOrEmpty(settingsService.GetLocal().LocalizationFile) && !settingsService.GetLocal().HasSuggestedLanguageChange)
            {
                if (LocalizationLoader.HasSupportedTranslations(grimDawnDetector.GetGrimLocations()))
                {
                    Logger.Debug("A new language pack has been detected, informing end user..");
                    new LanguagePackPicker(itemTagDao, playerItemDao, _parsingService, settingsService).Show(grimDawnDetector.GetGrimLocations());

                    settingsService.GetLocal().HasSuggestedLanguageChange = true;
                }
            }


            if (settingsService.GetPersistent().DarkMode)
            {
                dm.Activate(); // Needs a lot more work before its ready, for example custom components uses Draw and does not respect coloring.
                _cefBrowserHandler.SetDarkMode(settingsService.GetPersistent().DarkMode);
            }

            Logger.Debug("UI initialization complete");
        }
Exemplo n.º 27
0
        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();
        }