async Task Initialize()
        {
            try
            {
                LogSearchData lgs = new LogSearchData();
                lgs.SetSearchCriteria(
                    PlayerName,
                    GameLogTypes.Event,
                    DateTime.Now - TimeSpan.FromDays(5),
                    DateTime.Now,
                    "",
                    SearchTypes.RegexEscapedCaseIns);

                lgs = await WurmLogSearcherAPI.SearchWurmLogsAsync(lgs);

                foreach (string line in lgs.AllLines)
                {
                    ProcessLogLine(line, false);
                }
 
                ServerGroupEstablished = true;
            }
            catch (Exception _e)
            {
                Logger.LogError("Something went wrong when trying to establish server group for player: " + PlayerName, this, _e);
            }
        }
Beispiel #2
0
 async Task GetSearchResults()
 {
     LogSearchData searchdata = new LogSearchData();
     searchdata.SetSearchCriteria(
         "Aldur",
         GameLogTypes.Alliance,
         DateTime.Now - TimeSpan.FromDays(2),
         DateTime.Now,
         "",
         SearchTypes.RegexEscapedCaseIns);
     LogSearchData results = await WurmLogSearcherAPI.SearchWurmLogsAsync(searchdata);
     textBox2.Lines = results.AllLines.ToArray();
 }
        private async Task PerformAsyncInits(DateTime lastCheckup)
        {
            try
            {
                TimeSpan timeToCheck = DateTime.Now - lastCheckup;
                if (timeToCheck > TimeSpan.FromDays(120)) timeToCheck = TimeSpan.FromDays(120);
                if (timeToCheck < TimeSpan.FromDays(7)) timeToCheck = TimeSpan.FromDays(7);

                LogSearchData lgs = new LogSearchData();
                lgs.SetSearchCriteria(
                    Player,
                    GameLogTypes.Event,
                    DateTime.Now - timeToCheck,
                    DateTime.Now,
                    "",
                    SearchTypes.RegexEscapedCaseIns);

                lgs = await WurmLogSearcherAPI.SearchWurmLogsAsync(lgs);

                ServerInfo.ServerGroup mostRecentGroup = ServerInfo.ServerGroup.Unknown;
                string mostRecentServerName = null;

                foreach (string line in lgs.AllLines)
                {
                    if (line.Contains("You are on"))
                    {
                        string serverName;
                        ServerInfo.ServerGroup group = WurmLogSearcherAPI.GetServerGroupFromLine(line, out serverName);
                        if (group != ServerInfo.ServerGroup.Unknown)
                        {
                            if (!String.IsNullOrEmpty(serverName)) Settings.Value.GroupToServerMap[group] = serverName;
                            mostRecentServerName = serverName;
                            mostRecentGroup = group;
                        }
                    }
                }

                if (mostRecentGroup != ServerInfo.ServerGroup.Unknown && !currentServerGroupFound)
                {
                    CurrentServerGroup = mostRecentGroup;
                    if (mostRecentServerName != null) Settings.Value.CurrentServerName = mostRecentServerName;
                    currentServerGroupFound = true;
                    Settings.Value.LastServerGroupCheckup = DateTime.Now;
                }

                //init timers here!
                InitTimers(Settings.Value.ActiveTimers);

                LayoutControl.EnableAddingTimers();
                Settings.DelayedSave();
            }
            catch (Exception _e)
            {
                Logger.LogError("problem updating current server group", this, _e);
            }
        }
Beispiel #4
0
        /// <summary>
        /// returns null on error, filters out other server groups,
        /// min/max search date is unbound using this overload
        /// </summary>
        /// <param name="logType"></param>
        /// <param name="since">amount of time to look back, will accept any value</param>
        /// <returns></returns>
        protected async Task<List<string>> GetLogLinesFromLogHistoryAsync(GameLogTypes logType, TimeSpan since)
        {
            LogSearchData lgs = new LogSearchData();
            lgs.SetSearchCriteria(
                Player,
                logType,
                DateTime.Now - since,
                DateTime.Now,
                "",
                SearchTypes.RegexEscapedCaseIns);

            lgs = await WurmLogSearcherAPI.SearchWurmLogsFilteredByServerGroupAsync(lgs, TargetServerGroup);

            return lgs.AllLines;
        }
 void PerformSearch()
 {
     try
     {
         // create new search data container
         LogSearchData logSearchData = new LogSearchData();
         HandleToCurrentLogSearchData = logSearchData;
         // enable cancel button
         buttonCancelSearch.Visible = true;
         // clear old results
         richTextBoxAllLines.Clear();
         listBoxAllResults.Items.Clear();
         // write container with return address
         logSearchData.CallerControl = this;
         // adjust timeto if necessary (monitor)
         dateTimePickerTimeFrom.Value = new DateTime(
             dateTimePickerTimeFrom.Value.Year,
             dateTimePickerTimeFrom.Value.Month,
             dateTimePickerTimeFrom.Value.Day,
             0, 0, 0);
         dateTimePickerTimeTo.Value = new DateTime(
             dateTimePickerTimeTo.Value.Year,
             dateTimePickerTimeTo.Value.Month,
             dateTimePickerTimeTo.Value.Day,
             23, 59, 59);
         Debug.WriteLine("Search begin");
         Debug.WriteLine("from " + dateTimePickerTimeFrom.Value + " to " + dateTimePickerTimeTo.Value);
         // drop all search criteria into the container
         logSearchData.SetSearchCriteria(
             comboBoxPlayerName.Text,
             GameLogTypesEX.GetLogTypeForName(comboBoxLogType.Text),
             dateTimePickerTimeFrom.Value,
             dateTimePickerTimeTo.Value,
             textBoxSearchKey.Text,
             SearchTypesEX.GetSearchTypeForName(comboBoxSearchType.Text)
             );
         // add pm player if applies
         if (comboBoxLogType.Text == GameLogTypesEX.GetNameForLogType(GameLogTypes.PM))
         {
             logSearchData.SetPM_Player(textBoxPM.Text);
         }
         // pass the container further
         DoSearch(logSearchData);
     }
     catch (Exception _e)
     {
         MessageBox.Show("Error while starting search, this is a bug please report!");
         Logger.LogError("LogSearcher: Error while performing search", this, _e);
     }
 }