public bool IsReady(Account account)
 {
     return !account.AttachBot2 &&
            ((DateTime.Now - account.LastCrash).TotalSeconds <= Config.Singleton.GeneralSettings.RestartDelay ||
             (DateTime.Now - account.LastStop).TotalSeconds <= Config.Singleton.GeneralSettings.RestartDelay ||
             (DateTime.Now - account.LastStart).TotalSeconds <= Config.Singleton.GeneralSettings.RestartDelay);
 }
Пример #2
0
 public void Update(Account account)
 {
     Logger.LoggingObject.Log(ELogType.Info,
         LanguageManager.Singleton.GetTranslation(ETranslations.KillWorkerStoppingProcess),
         account.PID);
     account.SetLastStopTime(DateTime.Now);
 }
Пример #3
0
 public ViewStateObject(Account account, DateTime time, Process process, EViewState viewstate)
 {
     Account = account;
     Time = time;
     Process = process;
     ViewState = viewstate;
 }
Пример #4
0
        private bool CheckIfProcessAlreadyExists(IEnumerable<Process> gw2Processes, Account account, bool attached,
            ref uint newPID)
        {
            foreach (Process p in gw2Processes)
            {
                if (GW2MinionLauncher.GetAccountName((uint) p.Id) == account.LoginName)
                {
                    Logger.LoggingObject.Log(ELogType.Verbose,
                        LanguageManager.Singleton.GetTranslation(
                            ETranslations.StartWorkerFoundWantedProcess),
                        account.LoginName);
                    try
                    {
                        Logger.LoggingObject.Log(ELogType.Verbose,
                            LanguageManager.Singleton.GetTranslation(
                                ETranslations.StartWorkerAttachingTo),
                            account.LoginName, account.BotPath + "\\GW2MinionLauncherDLL.dll");
                        attached = GW2MinionLauncher.AttachToPid((uint) p.Id, Config.Singleton.GeneralSettings.UseBeta);
                    }
                    catch (Exception ex)
                    {
                        Logger.LoggingObject.Log(ELogType.Critical, ex.Message);
                    }
                    newPID = (uint) p.Id;

                    account.SetLastStartTime(DateTime.Now);
                    account.SetShouldBeRunning(true);
                }
            }
            return attached;
        }
Пример #5
0
 public bool IsReady(Account account)
 {
     return
         Config.Singleton.AccountSettings.Any(
             acc =>
                 (DateTime.Now - acc.LastStart).TotalSeconds < Config.Singleton.GeneralSettings.LaunchDelay);
 }
Пример #6
0
 public AccountForm(EAccountManagementType type, Account account = null)
 {
     InitializeComponent();
     _account = account;
     _type = type;
        // metroToggle2.Checked = true;
     metroStyleManager.Theme = Config.Singleton.GeneralSettings.ThemeSetting;
     metroStyleManager.Style = Config.Singleton.GeneralSettings.StyleSetting;
     switch (type)
     {
         case EAccountManagementType.Add:
             btnDelete.Visible = false;
             Text = LanguageManager.Singleton.GetTranslation(ETranslations.AccountFormAddAccount);
             break;
         case EAccountManagementType.Edit:
             btnDelete.Visible = true;
             Text = LanguageManager.Singleton.GetTranslation(ETranslations.AccountFormEditAccount);
             break;
     }
     if (account != null)
     {
         txtBoxLoginName.Text = account.LoginName.Replace(@"""", "");
         txtBoxPassword.Text = account.Password;
         metroToggle1.Checked = account.NoSound;
         metroToggle2.Checked = account.AttachBot2;
         metroToggle3.Checked = account.UseCustomGW2Path;
         txtBoxCustomPath.Text = account.CustomGW2Path;
     }
 }
Пример #7
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;
 }
Пример #8
0
 internal AccountControl(MetroTabControl tabControl, int totalCount, int activeCount, int newSet,
     MetroStyleManager styleManager, Account account)
 {
     _account = account;
     FixControls(newSet, styleManager, account);
     AddControlsToForm(tabControl, styleManager, activeCount, newSet);
     ID = totalCount;
     BindEvents();
 }
Пример #9
0
 public SettingsForm(Account account)
 {
     InitializeComponent();
     metroStyleManager.Theme = Config.Singleton.GeneralSettings.ThemeSetting;
     metroStyleManager.Style = Config.Singleton.GeneralSettings.StyleSetting;
     _account = account;
     BindEvents();
     SetTimeFields();
     metroToggle1.Checked = _account.EnableScheduling;
 }
Пример #10
0
 public bool Check(Account account)
 {
     if (account.EnableScheduling)
     {
         double differenceFuture = (DateTime.Now - account.EndTime).TotalSeconds;
         double differencePast = (account.StartTime - DateTime.Now).TotalSeconds;
         return differenceFuture > 0 || differencePast > 0;
     }
     return false;
 }
Пример #11
0
 public IRelogWorker DoWork(Account account)
 {
     _attached = false;
     _newPID = uint.MaxValue;
     _gw2Processes = Process.GetProcessesByName("gw2");
     Logger.LoggingObject.Log(ELogType.Debug,
         LanguageManager.Singleton.GetTranslation(
             ETranslations.StartWorkerScanningForExisting));
     _attached = Check(account);
     _newPID = CreateNewProcess(_attached, account, ref _newPID);
     Update(account);
     return this;
 }
Пример #12
0
 public SettingsForm(Account account)
 {
     InitializeComponent();
     _account = account;
     metroStyleManager.Theme = Config.Singleton.GeneralSettings.ThemeSetting;
     metroStyleManager.Style = Config.Singleton.GeneralSettings.StyleSetting;
     if (account.BreakObject != null)
     {
         numericUpDown1.Value = account.BreakObject.Interval;
         numericUpDown2.Value = account.BreakObject.IntervalDelay;
         numericUpDown3.Value = account.BreakObject.BreakDuration;
         numericUpDown4.Value = account.BreakObject.BreakDurationDelay;
         metroToggle1.Checked = account.BreakObject.BreakEnabled;
     }
 }
Пример #13
0
 public IRelogWorker DoWork(Account account)
 {
     _attached = false;
     _newPID = uint.MaxValue;
     if (account.UseCustomGW2Path == true)
         _gw2Processes = Process.GetProcessesByName(System.IO.Path.GetFileNameWithoutExtension(account.CustomGW2Path).ToLower());
     else
         _gw2Processes = Process.GetProcessesByName(System.IO.Path.GetFileNameWithoutExtension(Config.Singleton.GeneralSettings.GW2Path).ToLower());
     Logger.LoggingObject.Log(ELogType.Debug,
         LanguageManager.Singleton.GetTranslation(
             ETranslations.StartWorkerScanningForExisting));
     _attached = Check(account);
     _newPID = CreateNewProcess(_attached, account, ref _newPID);
     Update(account);
     return this;
 }
Пример #14
0
 public IRelogWorker DoWork(Account account)
 {
     if (Check(account))
     {
         try
         {
             Process[] processes = Process.GetProcessesByName("GW2");
             if (processes.Any(p => p.Id == account.PID))
                 _done = GW2MinionLauncher.KillInstance(account.PID);
             Thread.Sleep(3000);
         }
         catch
         {
         }
     }
     return this;
 }
Пример #15
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;
 }
Пример #16
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;
 }
Пример #17
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;
 }
Пример #18
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;
 }
Пример #19
0
 public IRelogWorker DoWork(Account account)
 {
     if (Check(account))
     {
         try
         {
             Process[] processes;
             if (account.UseCustomGW2Path == true)
                 processes = Process.GetProcessesByName(System.IO.Path.GetFileNameWithoutExtension(account.CustomGW2Path));
             else
                 processes = Process.GetProcessesByName(System.IO.Path.GetFileNameWithoutExtension(Config.Singleton.GeneralSettings.GW2Path));
             if (processes.Any(p => p.Id == account.PID))
                 _done = GW2MinionLauncher.KillInstance(account.PID);
             Thread.Sleep(3000);
         }
         catch
         {
         }
     }
     return this;
 }
Пример #20
0
 public bool Check(Account account)
 {
     return Config.Singleton.GeneralSettings.CheckForIP;
 }
Пример #21
0
 public void Update(Account account)
 {
 }
Пример #22
0
 public Form ShowSettingsForm(Account account = null)
 {
     return new SettingsForm();
 }
Пример #23
0
 public void PostWork(Account account)
 {
 }
Пример #24
0
 public void OpenSettingsForm(string nameofComponentToCall, Account account = null)
 {
     ComponentClass first = _components.FirstOrDefault(c => c.Component.GetName() == nameofComponentToCall);
     if (first != null)
     {
         OpenSettingsForm(first.Component, account);
     }
 }
Пример #25
0
 public void OpenSettingsForm(IRelogComponent componentToCall, Account account = null)
 {
     componentToCall.ShowSettingsForm(account).ShowDialog();
 }
Пример #26
0
 private void BtnOkClick(object sender, EventArgs e)
 {
     switch (_type)
     {
         case EAccountManagementType.Add:
             if (!string.IsNullOrEmpty(txtBoxLoginName.Text) && !string.IsNullOrEmpty(txtBoxPassword.Text) &&
                 Config.Singleton.AccountSettings.All(account => account.LoginName != txtBoxLoginName.Text))
             {
                 var toAdd = new Account();
                 string pass = txtBoxPassword.Text;
                 if (!pass.Contains(@""""))
                     pass = @"""" + pass + @"""";
                 toAdd.SetLoginName(txtBoxLoginName.Text);
                 toAdd.SetPassword(pass);
                 toAdd.SetBotPath(AppDomain.CurrentDomain.BaseDirectory);
                 toAdd.SetEndTime(DateTime.Now.AddYears(1337));
                 toAdd.SetManuallyScheduled(false);
                 toAdd.SetNoSound(metroToggle1.Checked);
                 toAdd.SetAttachBot(metroToggle2.Checked);
                 toAdd.SetUseCostumGW2Path(metroToggle3.Checked);
                 toAdd.SetCostumGW2Path(txtBoxCustomPath.Text);
                 Config.Singleton.AddAccount(toAdd);
             }
             break;
         case EAccountManagementType.Edit:
             Account wanted =
                 Config.Singleton.AccountSettings.FirstOrDefault(
                     account => account.LoginName == _account.LoginName);
             if (wanted != null)
             {
                 string pass = txtBoxPassword.Text;
                 if (!pass.Contains(@""""))
                     pass = @"""" + pass + @"""";
                 wanted.SetPassword(pass);
                 wanted.SetNoSound(metroToggle1.Checked);
                 wanted.SetLoginName(txtBoxLoginName.Text);
                 wanted.SetAttachBot(metroToggle2.Checked);
                 try
                 {
                     wanted.SetUseCostumGW2Path(metroToggle3.Checked);
                     wanted.SetCostumGW2Path(txtBoxCustomPath.Text);
                 }
                 catch { }
             }
             break;
     }
     Close();
 }
Пример #27
0
 public bool Check(Account account)
 {
     return !account.Running;
 }
Пример #28
0
 public void Update(Account account)
 {
     account.SetRestartDelayActive(false);
     account.SetPID(_newPID);
     account.SetLastStartTime(DateTime.Now);
 }
Пример #29
0
 public bool IsReady(Account account)
 {
     return !GetMyIP.ListContainsMyIPAddress(Config.Singleton.GeneralSettings.AllowedIPAddresses);
 }
Пример #30
0
 public bool PostWork(Account account)
 {
     return _newPID < uint.MaxValue;
 }