/// <summary> /// Initialize LogSearcher with optional directory path, where cache database will be stored. /// </summary> /// <param name="dirPath">Absolute directory path, default null will use CodeBase</param> /// <param name="wipeExistingDb">Clears any existing database at dirPath location</param> /// <exception cref="InvalidOperationException">LogSearcher was already initialized</exception> /// <exception cref="Exception">There was an error while trying to initialize</exception> /// <returns></returns> public static void Initialize(string dirPath = null, bool wipeExistingDb = false) { if (isInitialized) throw new InvalidOperationException("LogSearcher already initialized"); try { Logger.LogInfo("Initializing API", THIS); LogSearchMan = new LogSearchManager(); LogSearchMan.CreateCacheDB(dirPath, wipeExistingDb); //wipeExistingDb); //exc here stop the init and allow recovery LogSearchMan.Initialize(); LogSearchMan.UpdateCache(); //ensure updates before first search SearcherUI = new FormLogSearcher(LogSearchMan); SearcherUI.WindowState = System.Windows.Forms.FormWindowState.Minimized; SearcherUI.Show(); //need to create window handle SearcherUI.Hide(); SearcherUI.StartUpdateLoop(); Logger.LogInfo("Init completed", THIS); isInitialized = true; _tcs.SetResult(true); } catch (Exception _e) { Logger.LogError("API init error", THIS, _e); throw; } }
internal FormLogSearcher(LogSearchManager logsearchman) { InitializeComponent(); this.LogSearchMan = logsearchman; //init all search boxes and choose default values for them dateTimePickerTimeFrom.Value = DateTime.Now; dateTimePickerTimeTo.Value = DateTime.Now; comboBoxPlayerName.Items.AddRange(WurmState.WurmClient.WurmPaths.GetAllPlayersNames()); //comboBoxPlayerName.Text = parentModule.GetCurrentPlayer(); //TODO comboBoxLogType.Items.AddRange(GameLogTypesEX.GetAllNames()); comboBoxLogType.Text = GameLogTypesEX.GetNameForLogType(GameLogTypes.Event); comboBoxSearchType.Items.AddRange(SearchTypesEX.GetAllNames()); comboBoxSearchType.Text = SearchTypesEX.GetNameForSearchType(SearchTypes.RegexEscapedCaseIns); }