public List <GF.BrowserGame.Schema.Serializable.Community> GetUserCommunityList(Guid toolId, bool throwException)
        {
            List <GF.BrowserGame.Schema.Serializable.Community> communityList = new List <GF.BrowserGame.Schema.Serializable.Community>();
            Service myService = null;

            try
            {
                myService = new Service();
                GetValidWebServiceUrl(true);
                myService.Url             = _currentWebServiceUrl.Url;
                myService.AuthHeaderValue = _soapHeader;
                string retValue = myService.GetUserCommunityData(toolId);
                communityList = SerializeDeserializeObject.DeserializeObject <List <GF.BrowserGame.Schema.Serializable.Community> >(retValue);
            }
            catch (Exception ex)
            {
                if (throwException)
                {
                    throw ex;
                }
            }
            finally
            {
                if (myService != null)
                {
                    myService.Dispose();
                }
                myService = null;
            }
            return(communityList);
        }
        public SetupAppObj SetupApplication(string prevToolVersion, string newToolVersion, bool throwException)
        {
            SetupAppObj returnObj = new SetupAppObj();
            Service     myService = null;

            try
            {
                myService = new Service();
                GetValidWebServiceUrl(true);
                myService.Url             = _currentWebServiceUrl.Url;
                myService.AuthHeaderValue = _soapHeader;
                string retValue = myService.SetupApplication((Guid)_soapHeader.ToolId, (Guid)_soapHeader.ApplicationKey, prevToolVersion, newToolVersion);
                returnObj = SerializeDeserializeObject.DeserializeObject <SetupAppObj>(retValue);
            }
            catch (Exception ex)
            {
                if (throwException)
                {
                    throw ex;
                }
            }
            finally
            {
                if (myService != null)
                {
                    myService.Dispose();
                }
                myService = null;
            }
            return(returnObj);
        }
Exemple #3
0
 internal static T DeSerializeObjectFromString <T>(string encryptedString, string password)
 {
     try
     {
         //return SerializeDeserializeObject.DeserializeObject<T>(Encryption.DecryptString(encryptedString, password));
         return(SerializeDeserializeObject.DeserializeObject <T>(encryptedString));
     }
     catch (Exception ex)
     {
         return(default(T));
     }
 }
        internal WebServiceSettings GetLatestWebServiceSettings(bool throwException)
        {
            WebServiceSettings webServiceSettings    = null;
            WebBrowserClient   webClient             = new WebBrowserClient();
            string             webServiceSettingsUrl = GetCurrenWebServiceSettingsUrl();

            int retries = 1;

TryAgain:
            try
            {
                string webServiceSettingsString = webClient.GetPage(new Uri(webServiceSettingsUrl), "", true);

                if (!string.IsNullOrEmpty(webServiceSettingsString))
                {
                    try
                    {
                        webServiceSettingsString = SerializeDeserializeObject.DeserializeObject <String>(webServiceSettingsString);
                        webServiceSettingsString = Encryption.DecryptString(webServiceSettingsString);
                        webServiceSettings       = SerializeDeserializeObject.DeserializeObject <WebServiceSettings>(webServiceSettingsString);
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(Constants.Message.TRY_NEXT_URL);
                    }
                }
                else
                {
                    throw new Exception(Constants.Message.TRY_NEXT_URL);
                }
            }
            catch
            {
                if (retries < GetNumberOfWebServiceSettingsUrl())
                {
                    retries++;
                    webServiceSettingsUrl = GetNextWebServiceSettingsUrl();
                    goto TryAgain;
                }
                else if (throwException)
                {
                    throw new Exception(Constants.Message.WEBSERVICE_SETTINGS_NOT_FOUND);
                }
            }

            return(webServiceSettings);
        }
Exemple #5
0
        void bgw_DoWork(object sender, DoWorkEventArgs e)
        {
            bool knownException = false;

            _celestosUserName = CelestosLogintextBox.Text.Trim();
            _celestosPassword = CelestosPasswordtextBox.Text;
            OgameServiceV1Call webServiceCall = new OgameServiceV1Call(_toolId, "", _applicationId, _celestosUserName, _celestosPassword, null);

            try
            {
                SetupAppObj returnObj = webServiceCall.SetupApplication(_prevToolVersion, _newToolVersion, true);

                if (!returnObj.Error)
                {
                    // _celestosUserId = returnObj.UserId;

                    if (returnObj.IsToolValid && returnObj.IsUserAllowedToUseThisTool)
                    {
                        if (!string.IsNullOrEmpty(returnObj.CommunityData))
                        {
                            try
                            {
                                _userCommunityList = SerializeDeserializeObject.DeserializeObject <List <GF.BrowserGame.Schema.Serializable.Community> >(returnObj.CommunityData);
                            }
                            catch { }

                            if (_userCommunityList != null && _userCommunityList.Count > 0)
                            {
                                e.Result = "Valid credentials";
                                return;
                            }
                        }
                        knownException = true;
                        throw new Exception("Your credentials are valid but unfortunately you have not been allocated to any universes!\r\n\r\nContact your game administrator for more information.");
                    }
                    else if (!returnObj.IsToolValid)
                    {
                        knownException = true;
                        throw new Exception("Your credentials are valid but unfortunately this tool is not currently active or your version is expired!\r\n\r\nDownload a new version or contact an administrator for more information.");
                    }
                    else if (!returnObj.IsUserAllowedToUseThisTool)
                    {
                        knownException = true;
                        throw new Exception("Your credentials are valid but unfortunately you are not allowed to use this tool!\r\n\r\nContact an administrator for more information.");
                    }
                }
                else
                {
                    knownException = true;
                    throw new Exception("Your credentials are valid but unfortunately something went wrong while downloading your account details!\r\n\r\nContact an administrator for more information.");
                }
            }
            catch (SoapException soapEx)
            {
                if (soapEx.Message.Contains("account is not approved"))
                {
                    e.Result = "Authentication has failed because your account is not approved.\r\n\r\nContact an administrator for more information";
                }
                else if (soapEx.Message.Contains("account is locked"))
                {
                    e.Result = "Authentication has failed because your account is locked.\r\n\r\nContact an administrator for more information";
                }
                else if (soapEx.Message.Contains("database problem"))
                {
                    throw new Exception("Network");
                }
                else
                {
                    e.Result = "Wrong credentials";
                }
            }
            catch (Exception ex)
            {
                if (!knownException || ex.Message.Equals("all webservices are down"))
                {
                    throw new Exception("Network");
                }
                else
                {
                    throw ex;
                }
            }
        }