Пример #1
0
 public void Update(Account account)
 {
     account.SetRestartDelayActive(false);
     account.SetPID(_newPID);
     account.SetLastStartTime(DateTime.Now);
 }
Пример #2
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;
        }
Пример #3
0
 private uint CreateNewProcess(bool attached, Account account, ref uint newPID)
 {
     if (!attached)
     {
         try
         {
             try
             {
                 Logger.LoggingObject.Log(ELogType.Verbose,
                     LanguageManager.Singleton.GetTranslation(
                         ETranslations.StartWorkerLaunchingInstance),
                     account.LoginName,
                     account.BotPath + "\\MinionFiles\\GW2MinionLauncherDLL.dll");
                 string directory = string.Empty;
                 if (account.UseCustomGW2Path == true)
                     directory = System.IO.Path.GetDirectoryName(account.CustomGW2Path);
                 else
                     directory = System.IO.Path.GetDirectoryName(Config.Singleton.GeneralSettings.GW2Path);
                 if (Directory.Exists(directory))
                 {
                     if (File.Exists(directory + "ArenaNet.log"))
                     {
                         File.Delete(directory + "ArenaNet.log");
                     }
                     if (File.Exists(directory + "Crash.dmp"))
                     {
                         File.Delete(directory + "Crash.dmp");
                     }
                 }
                 if (Directory.Exists(directory))
                 {
                     if (File.Exists(directory + "ArenaNet.log"))
                     {
                         File.Delete(directory + "ArenaNet.log");
                     }
                     if (File.Exists(directory + "Crash.dmp"))
                     {
                         File.Delete(directory + "Crash.dmp");
                     }
                 }
                 string mydocuments = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                 if (Directory.Exists(mydocuments))
                 {
                     if (Directory.Exists(mydocuments + "\\Guild Wars 2"))
                     {
                         if (File.Exists(mydocuments + "\\Guild Wars 2\\" + "ArenaNet.log"))
                         {
                             File.Delete(mydocuments + "\\Guild Wars 2\\" + "ArenaNet.log");
                         }
                         const string filesToDelete = @"*Corrupt*.dat";
                         string[] fileList = Directory.GetFiles(mydocuments + "\\Guild Wars 2", filesToDelete);
                         foreach (string file in fileList)
                         {
                             File.Delete(file);
                         }
                     }
                 }
                 string pwd = account.Password;
                 if (!pwd.Contains(@""""))
                     pwd = @"""" + pwd + @"""";
                 string gw2path = string.Empty;
                 if (account.UseCustomGW2Path)
                     gw2path = account.CustomGW2Path;
                 else
                     gw2path = Config.Singleton.GeneralSettings.GW2Path;
                 if (!account.AttachBot2)
                     newPID = GW2MinionLauncher.LaunchAccount(gw2path,
                         account.LoginName, pwd, account.NoSound,
                         Config.Singleton.GeneralSettings.UseBeta);
                 else
                     newPID = GW2MinionLauncher.LaunchGW(gw2path,
                         account.LoginName, pwd, false, account.NoSound);
             }
             catch (Exception ex)
             {
                 Logger.LoggingObject.Log(ELogType.Error, ex.Message);
             }
             account.SetLastStartTime(DateTime.Now);
             account.SetShouldBeRunning(true);
         }
         catch (DllNotFoundException ex)
         {
             Logger.LoggingObject.Log(ELogType.Error, ex.Message);
         }
         catch (BadImageFormatException ex)
         {
             Logger.LoggingObject.Log(ELogType.Error, ex.Message);
         }
     }
     return newPID;
 }