예제 #1
0
        private async Task CheckAndRun(string profileId, ProfileData profile)
        {
            if (_ui.OfflineMode)
            {
                await Run(profileId, profile);

                return;
            }

            if (profile.CheckVersionFiles && !await CheckProfile(profile))
            {
                return;
            }

            try {
                _profiles.UpdateInstalledFiles(profileId, profile.FullVersion);
            }
            catch {
                _ui.ShowErrorMessage(_tr._("Failed to update selected profile! Try to enable a version checking."));
                return;
            }

            LoginResultData tokens;

            try {
                tokens = await _ttyhClient.Login(_ui.UserName, _ui.Password);
            }
            catch (ErrorAnswerException e) {
                _ui.ShowErrorMessage(_tr._("Failed to login! Are your nickname and password correct?"), e.Message);
                return;
            }
            catch (Exception) {
                _ui.ShowErrorMessage(_tr._("Failed to login! Are your nickname and password correct?"));
                return;
            }

            await Run(profileId, profile, tokens);
        }