Ejemplo n.º 1
0
 public IRelogComponent DoWork(Account account, ref ComponentResult result)
 {
     if (Check(account))
     {
         result = new ComponentResult
         {
             Result = EComponentResult.Continue,
         };
         if (IsReady(account))
         {
             result = new ComponentResult
             {
                 Result = EComponentResult.Halt,
                 LogMessage = LanguageManager.Singleton.GetTranslation(ETranslations.IPCheckComponentHalt),
             };
             if (account.Running)
                 result = new ComponentResult
                 {
                     Result = EComponentResult.Kill,
                     LogMessage =
                         LanguageManager.Singleton.GetTranslation(ETranslations.IPCheckComponentKill),
                 };
         }
     }
     else
     {
         result = new ComponentResult
         {
             Result = EComponentResult.Ignore,
         };
     }
     return this;
 }
Ejemplo n.º 2
0
 public IRelogComponent DoWork(Account account, ref ComponentResult result)
 {
     if (Check(account))
     {
         Update(account);
         result = new ComponentResult
         {
             Result = EComponentResult.Start,
         };
     }
     else
     {
         result = new ComponentResult
         {
             Result = EComponentResult.Ignore,
         };
     }
     return this;
 }
Ejemplo n.º 3
0
 public IRelogComponent DoWork(Account account, ref ComponentResult result)
 {
     if (!account.RestartDelayActive && Check(account))
     {
         account.SetRestartDelayActive(true);
         account.SetLastStopTime(DateTime.Now);
     }
     result = IsReady(account)
         ? new ComponentResult
         {
             Result = EComponentResult.Halt,
             LogMessage =
                 LanguageManager.Singleton.GetTranslation(ETranslations.RestartDelayComponentHalt),
         }
         : new ComponentResult
         {
             Result = EComponentResult.Ignore,
         };
     return this;
 }
Ejemplo n.º 4
0
 public IRelogComponent DoWork(Account account, ref ComponentResult result)
 {
     if (Check(account))
     {
         result = new ComponentResult
         {
             Result = EComponentResult.Halt,
             LogMessage = LanguageManager.Singleton.GetTranslation(ETranslations.BasicStopComponentHalt),
         };
         if (IsReady(account))
         {
             if (!account.PerformedCheck)
             {
                 account.PerformedCheck = true;
                 if (account.Running)
                     account.SetShouldBeRunning(true);
                 result = new ComponentResult
                 {
                     Result = EComponentResult.ContinueForced,
                 };
             }
             else
             {
                 result = new ComponentResult
                 {
                     Result = EComponentResult.Kill,
                     LogMessage = LanguageManager.Singleton.GetTranslation(ETranslations.BasicStopComponentStop),
                 };
             }
             Update(account);
         }
     }
     else
     {
         result = new ComponentResult
         {
             Result = EComponentResult.Ignore,
         };
     }
     return this;
 }
Ejemplo n.º 5
0
 public IRelogComponent DoWork(Account account, ref ComponentResult result)
 {
     if (account.BreakObject != null && account.BreakObject.Check())
     {
         if (account.BreakObject.IsReady())
         {
             result = Check(account)
                 ? new ComponentResult
                 {
                     Result = EComponentResult.Kill,
                     LogMessage =
                         LanguageManager.Singleton.GetTranslation(ETranslations.BreakComponentKill),
                 }
                 : new ComponentResult
                 {
                     Result = EComponentResult.Halt,
                     LogMessage =
                         LanguageManager.Singleton.GetTranslation(ETranslations.BreakComponentHalt),
                 };
         }
         else
         {
             result = new ComponentResult
             {
                 Result = EComponentResult.Continue,
             };
         }
     }
     else
     {
         result = new ComponentResult
         {
             Result = EComponentResult.Ignore,
         };
     }
     if (IsReady(account))
     {
         Update(account);
     }
     return this;
 }
Ejemplo n.º 6
0
        public void DoWork()
        {
            while (_keepAlive)
            {
                while (_isRunning)
                {
                    try
                    {
                        if (_needDelay)
                        {
                            Thread.Sleep(_delay);
                        }

                        foreach (Account account in Config.Singleton.AccountSettings.ToArray())
                        {
                            var results = new List<ComponentResult>();
                            foreach (
                                ComponentClass component in
                                    ComponentManager.Singleton.GetComponents().ToArray().Where(c => c.IsEnabled))
                            {
                                var result = new ComponentResult();
                                component.Component.DoWork(account, ref result);
                                results.Add(result);
                            }
                            if (results.Any(r => r.Result == EComponentResult.KillForced))
                            {
                                if (Config.Singleton.GeneralSettings.ExtensiveLogging)
                                {
                                    foreach (
                                        ComponentResult componentResult in
                                            results.Where(r => r.Result == EComponentResult.KillForced))
                                    {
                                        Logger.LoggingObject.Log(ELogType.Debug, componentResult.LogMessage,
                                            account.LoginName);
                                    }
                                }
                                new KillWorker().DoWork(account).Update(account);
                            }
                            else if (results.Any(r => r.Result == EComponentResult.HaltForced))
                            {
                                if (Config.Singleton.GeneralSettings.ExtensiveLogging)
                                {
                                    foreach (
                                        ComponentResult componentResult in
                                            results.Where(r => r.Result == EComponentResult.HaltForced))
                                    {
                                        Logger.LoggingObject.Log(ELogType.Debug, componentResult.LogMessage,
                                            account.LoginName);
                                    }
                                }
                                account.SetLastStopTime(DateTime.Now);
                            }
                            else if (results.Any(r => r.Result == EComponentResult.StartForced))
                            {
                                if (Config.Singleton.GeneralSettings.ExtensiveLogging)
                                {
                                    foreach (
                                        ComponentResult componentResult in
                                            results.Where(r => r.Result == EComponentResult.StartForced))
                                    {
                                        Logger.LoggingObject.Log(ELogType.Debug, componentResult.LogMessage,
                                            account.LoginName);
                                    }
                                }
                                new StartWorker().DoWork(account);
                            }
                            else if (results.Any(r => r.Result == EComponentResult.ContinueForced))
                            {
                            }
                            else if (results.Any(r => r.Result == EComponentResult.Kill))
                            {
                                if (Config.Singleton.GeneralSettings.ExtensiveLogging)
                                {
                                    foreach (
                                        ComponentResult componentResult in
                                            results.Where(r => r.Result == EComponentResult.Kill))
                                    {
                                        Logger.LoggingObject.Log(ELogType.Debug, componentResult.LogMessage,
                                            account.LoginName);
                                    }
                                }
                                new KillWorker().DoWork(account).Update(account);
                            }
                            else if (results.Any(r => r.Result == EComponentResult.Halt))
                            {
                                if (Config.Singleton.GeneralSettings.ExtensiveLogging)
                                {
                                    foreach (
                                        ComponentResult componentResult in
                                            results.Where(r => r.Result == EComponentResult.Halt))
                                    {
                                        Logger.LoggingObject.Log(ELogType.Debug, componentResult.LogMessage,
                                            account.LoginName);
                                    }
                                }
                            }
                            else if (results.Any(r => r.Result == EComponentResult.Start))
                            {
                                if (VersionControl.CheckVersionBot())
                                    new StartWorker().DoWork(account).Update(account);
                                else
                                    VersionControl.Update();
                            }
                            else if (results.Any(r => r.Result == EComponentResult.Continue))
                            {
                            }
                            else if (results.Any(r => r.Result == EComponentResult.Ignore))
                            {
                            }
                            else if (results.Any(r => r.Result == EComponentResult.Default))
                            {
                            }
                        }
                        User32.EnumWindows(EnumTheWindows, IntPtr.Zero);

                        IEnumerable<Process> gw2Processes = UpdateListWithRemainingGW2Processes();

                        if (_checkAll || Config.Singleton.GeneralSettings.PollingDelay >= 60)
                        {
                            Process[] enumerable = gw2Processes as Process[] ?? gw2Processes.ToArray();
                            foreach (Process gw2Process in enumerable)
                            {
                                UpdateProcessIdForMatchingScheduler(gw2Process);
                                if (!gw2Process.Responding)
                                {
                                    if (FrozenGW2Windows.All(p => p.Key.Id != gw2Process.Id))
                                    {
                                        AddUnresponsiveProcessToTheList(gw2Process);
                                    }
                                    else
                                    {
                                        GetRidOfProcessesThatHaveBeenFrozenForLong(gw2Process);
                                    }
                                }
                                else
                                {
                                    if (_enableViewStateChecks)
                                    {
                                        var viewState = (EViewState) GW2MinionLauncher.ViewState((uint) gw2Process.Id);
                                        //GetViewState(gw2Process);
                                        if (viewState != EViewState.ViewGameplay &&
                                            DeadGW2Windows.All(p => p.Key.Id != gw2Process.Id))
                                        {
                                            AddDeadProcessToTheList(gw2Process, viewState);
                                        }
                                        else if (viewState != EViewState.ViewGameplay)
                                        {
                                            GetRidOfProcessesThatHaveBeenIdleForLong(gw2Process, viewState);
                                        }
                                        else
                                        {
                                            RemoveWorkingWindowsFromTheList(gw2Process);
                                        }
                                    }
                                    RemoveRespondingWindowsFromTheList(gw2Process);
                                    MinimizeGW2Windows(gw2Process);
                                }
                            }
                            //if (_buildNumberNeedUpdate == 0)
                            //{
                            //    try
                            //    {
                            //        _buildNumber = GW2MinionLauncher.BuildNumberFromApi();
                            //        //VersionChecker.CheckForUpdates();
                            //    }
                            //    catch
                            //    {
                            //        _buildNumber = 0;
                            //    }
                            //    _buildNumberNeedUpdate = 0;
                            //    try
                            //    {
                            //        if (enumerable.Any())
                            //            _enableViewStateChecks =
                            //                GW2MinionLauncher.BuildNumber((uint) enumerable.First().Id) == _buildNumber;
                            //        && _buildNumber == Pointers.BuildNumber;
                            //    }
                            //    catch
                            //    {
                            //        _enableViewStateChecks = false;
                            //    }
                            //}
                            //_buildNumberNeedUpdate++;
                            //if (_buildNumberNeedUpdate > 30)
                            //    _buildNumberNeedUpdate = 0;
                        }
                        _checkAll = !_checkAll;
                    }
                    catch (Exception)
                    {
                    }
                    Thread.Sleep(Config.Singleton.GeneralSettings.PollingDelay*1000);
                }
                Thread.Sleep(10000);
            }
        }
Ejemplo n.º 7
0
 public IRelogComponent DoWork(Account account, ref ComponentResult result)
 {
     Logger.LoggingObject.Log("[TestComponent] DoWork");
     return this;
 }
 public IRelogComponent DoWork(Account account, ref ComponentResult result)
 {
     if (Check(account))
     {
         result = new ComponentResult
             {
                 Result = EComponentResult.Halt,
                 LogMessage = "Halting due to alternative scheduler component settings for {0}.",
             };
         if (IsReady(account))
         {
             Update(account);
             result = new ComponentResult
                 {
                     Result = EComponentResult.Kill,
                     LogMessage = "Stopping due to alternative scheduler component settings for {0}.",
                 };
         }
     }
     else
     {
         result = new ComponentResult
             {
                 Result = EComponentResult.Ignore,
             };
     }
     return this;
 }