Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
0
 public void Update(Account account)
 {
     Logger.LoggingObject.Log(ELogType.Info,
         LanguageManager.Singleton.GetTranslation(ETranslations.KillWorkerStoppingProcess),
         account.PID);
     account.SetLastStopTime(DateTime.Now);
 }
Ejemplo n.º 3
0
 public ViewStateObject(Account account, DateTime time, Process process, EViewState viewstate)
 {
     Account = account;
     Time = time;
     Process = process;
     ViewState = viewstate;
 }
Ejemplo n.º 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;
        }
Ejemplo n.º 5
0
 public bool IsReady(Account account)
 {
     return
         Config.Singleton.AccountSettings.Any(
             acc =>
                 (DateTime.Now - acc.LastStart).TotalSeconds < Config.Singleton.GeneralSettings.LaunchDelay);
 }
Ejemplo n.º 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;
     }
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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();
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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;
     }
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 20
0
 public bool Check(Account account)
 {
     return Config.Singleton.GeneralSettings.CheckForIP;
 }
Ejemplo n.º 21
0
 public void Update(Account account)
 {
 }
Ejemplo n.º 22
0
 public Form ShowSettingsForm(Account account = null)
 {
     return new SettingsForm();
 }
Ejemplo n.º 23
0
 public void PostWork(Account account)
 {
 }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 25
0
 public void OpenSettingsForm(IRelogComponent componentToCall, Account account = null)
 {
     componentToCall.ShowSettingsForm(account).ShowDialog();
 }
Ejemplo n.º 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();
 }
Ejemplo n.º 27
0
 public bool Check(Account account)
 {
     return !account.Running;
 }
Ejemplo n.º 28
0
 public void Update(Account account)
 {
     account.SetRestartDelayActive(false);
     account.SetPID(_newPID);
     account.SetLastStartTime(DateTime.Now);
 }
Ejemplo n.º 29
0
 public bool IsReady(Account account)
 {
     return !GetMyIP.ListContainsMyIPAddress(Config.Singleton.GeneralSettings.AllowedIPAddresses);
 }
Ejemplo n.º 30
0
 public bool PostWork(Account account)
 {
     return _newPID < uint.MaxValue;
 }