예제 #1
0
        private string GetClientIpAddress()
        {
            string ipAddress = null;

            try
            {
                if (HttpContext.Current != null)
                {
                    try
                    {
                        ipAddress = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString();
                    }
                    catch
                    {
                    }
                    try
                    {
                        if (string.IsNullOrEmpty(ipAddress))
                        {
                            ipAddress = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString();
                        }
                    }
                    catch { }
                    if (string.IsNullOrEmpty(ipAddress))
                    {
                        ipAddress = HttpContext.Current.Request.UserHostAddress;
                    }
                }
            }
            catch (Exception ex) {
                WebServiceDAL.StoreException("Webservice", "GetClientIpAddress", ex);
            }

            return(ipAddress);
        }
예제 #2
0
        public bool EndApplicationSession(Guid applicationKey, Int64 applicationSessionId, DateTime lastActivity, DateTime endTime)
        {
            AuthHeaderValidation.CreateSoapHeaderLog("EndApplicationSession", Credentials.ToolId, Credentials.ApplicationKey, null, null, 10, null);

            WebServiceDAL.UpdateApplicationsSession(applicationKey, applicationSessionId, lastActivity, endTime);

            return(true);
        }
예제 #3
0
        public Guid?RegisterApplication(Guid toolId, string computerName)
        {
            //AuthHeaderValidation.CreateSoapHeaderLog("RegisterApplication", toolId, null, null, null, 10, null);

            Guid?applicationKey = WebServiceDAL.GetNewApplicationKey(toolId, computerName);

            AuthHeaderValidation.CreateSoapHeaderLog("RegisterApplication", toolId, applicationKey, null, null, 10, null);

            return(applicationKey);
        }
예제 #4
0
        public bool LinkUserAccountToUniverseAccount(Guid universeId, Int64 playerId, string playerName)
        {
            Guid userId = AuthenticateClient("LinkUserAccountToUniverseAccount");

            try
            {
                return(WebServiceDAL.LinkUserToUniverseAccount(userId, universeId, playerId, playerName, "DO_NOT_UPDATE_PASSWORD"));
            }
            catch (Exception ex)
            {
                // Log it
                WebServiceDAL.StoreException("Webservice", "LinkUserAccountToUniverseAccount", ex);
                return(false);
            }
        }
예제 #5
0
        public bool UpdateApplicationSessionUserId(Guid applicationKey, Int64 applicationSessionId, bool isPublicComputer)
        {
            try
            {
                Guid userId = AuthenticateClient("UpdateApplicationSessionUserId");
                WebServiceDAL.UpdateApplicationsSession(applicationKey, applicationSessionId, userId, isPublicComputer);
            }
            catch (Exception ex)
            {
                // Log it
                WebServiceDAL.StoreException("Webservice", "UpdateApplicationSessionUserId", ex);
                return(false);
            }

            return(true);
        }
예제 #6
0
        public bool UpgradeApplicationVersion(Guid toolId, Guid applicationKey, string prevToolVersion, string newToolVersion)
        {
            Guid userId = AuthenticateClient("UpgradeApplicationVersion");

            try
            {
                WebServiceDAL.UpgradeApplicationVersion(toolId, applicationKey, userId, prevToolVersion, newToolVersion);
            }
            catch (Exception ex)
            {
                // log it
                WebServiceDAL.StoreException("Webservice", "UpgradeApplicationVersion", ex);
                throw ex;
            }
            return(true);
        }
예제 #7
0
        public bool CreateApplicationExceptionLog(Guid applicationKey, Guid toolId, string type, string description, string message, string stack, string innerExceptionMessage)
        {
            try
            {
                try
                {
                    if (!string.IsNullOrEmpty(stack))
                    {
                        stack = Encryption.DecryptString(stack);
                    }
                }
                catch { }

                if (Credentials != null && !string.IsNullOrEmpty(Credentials.Username) && !string.IsNullOrEmpty(Credentials.Password))
                {
                    try
                    {
                        Guid userId = AuthenticateClient("CreateApplicationExceptionLog");
                        return(WebServiceDAL.InsertApplicationsExceptionLog(applicationKey, toolId, userId, type, description, message, stack, innerExceptionMessage));
                    }
                    catch (Exception ex)
                    {
                        WebServiceDAL.StoreException("Webservice", "CreateApplicationExceptionLog Inside 1st Try/Catch", ex);
                        AuthHeaderValidation.CreateSoapHeaderLog("CreateApplicationExceptionLog", toolId, applicationKey, null, null, 10, null);
                        return(WebServiceDAL.InsertApplicationsExceptionLog(applicationKey, toolId, null, type, description, message, stack, innerExceptionMessage));
                    }
                }
                else
                {
                    AuthHeaderValidation.CreateSoapHeaderLog("CreateApplicationExceptionLog", toolId, applicationKey, null, null, 10, null);
                    return(WebServiceDAL.InsertApplicationsExceptionLog(applicationKey, toolId, null, type, description, message, stack, innerExceptionMessage));
                }
            }
            catch (Exception ex)
            {
                // Log it
                WebServiceDAL.StoreException("Webservice", "CreateApplicationExceptionLog", ex);
                return(false);
            }
        }
예제 #8
0
 public Int64 StartApplicationSession(Guid applicationKey, Guid toolId, string toolVersion, string computerName)
 {
     try
     {
         if (Credentials != null && !string.IsNullOrEmpty(Credentials.Username) && !string.IsNullOrEmpty(Credentials.Password))
         {
             Guid userId = AuthenticateClient("StartApplicationSession");
             return(WebServiceDAL.ReCreateApplicationsSession(applicationKey, toolId, toolVersion, userId, computerName, DateTime.UtcNow, DateTime.UtcNow, null));
         }
         else
         {
             AuthHeaderValidation.CreateSoapHeaderLog("StartApplicationSession", toolId, applicationKey, null, null, 10, null);
             return(WebServiceDAL.CreateApplicationsSession(applicationKey, toolId, toolVersion, computerName, DateTime.UtcNow, DateTime.UtcNow, null));
         }
     }
     catch (Exception ex)
     {
         // Log it
         WebServiceDAL.StoreException("Webservice", "StartApplicationSession", ex);
         return(0);
     }
 }
        public static bool UpdateLastSoapHeaderLog(Guid toolId, Guid applicationKey, Guid userId, string userName, string action)
        {
            SqlDataConnector oDC = null;

            try
            {
                oDC = new SqlDataConnector();

                string sqlQuery = "UPDATE db_SoapHeaderLog SET ApplicationKey = @ApplicationKey, UserId = @UserId WHERE Id IN (SELECT TOP 1 Id FROM db_SoapHeaderLog WHERE Action = @Action AND UserName = @UserName AND ToolId = @ToolId ORDER BY Id DESC)";

                List <SqlParameter> cmdParameters = new List <SqlParameter>();
                cmdParameters.Add(oDC.CreateInputParam("@ApplicationKey", SqlDbType.UniqueIdentifier, applicationKey));
                cmdParameters.Add(oDC.CreateInputParam("@ToolId", SqlDbType.UniqueIdentifier, toolId));
                cmdParameters.Add(oDC.CreateInputParam("@UserId", SqlDbType.UniqueIdentifier, userId));
                cmdParameters.Add(oDC.CreateInputParam("@Action", SqlDbType.NVarChar, action));
                cmdParameters.Add(oDC.CreateInputParam("@UserName", SqlDbType.NVarChar, userName));

                int result = oDC.ExecNonQuerybyQuery(sqlQuery, cmdParameters.ToArray());

                if (result != 1)
                {
                    return(false);
                }
                return(true);
            }
            catch (Exception ex)
            {
                // log it
                WebServiceDAL.StoreException("Webservice", "UpdateLastSoapHeaderLog", ex);
                return(false);
            }
            finally
            {
                if (oDC != null)
                {
                    oDC.Dispose();
                }
            }
        }
예제 #10
0
        public bool SynchronizeCredentials(Guid universeId, Int64 playerId, string playerName, string password)
        {
            Guid userId = AuthenticateClient("SynchronizeCredentials");

            try
            {
                if (string.IsNullOrEmpty(password))
                {
                    return(WebServiceDAL.LinkUserToUniverseAccount(userId, universeId, playerId, playerName, password));
                }
                else
                {
                    Int64 encryptionKeyId = WebServiceDAL.GetUserEncryptionKeyId(userId);
                    if (encryptionKeyId != 0)
                    {
                        DataTable encryptionKeys = WebServiceDAL.GetUserEncryptionKeys(encryptionKeyId);

                        string serverKey = Encryption.DecryptString(UtilitiesBLL.DecryptEncryptionKeyHash(encryptionKeys.Rows[0]["ServerKey"].ToString()), Credentials.Password);
                        string clientKey = Encryption.DecryptString(UtilitiesBLL.DecryptEncryptionKeyHash(encryptionKeys.Rows[0]["ClientKey"].ToString()), Credentials.Password);

                        password = Encryption.EncryptString(Encryption.DecryptString(password, clientKey), serverKey);
                        return(WebServiceDAL.LinkUserToUniverseAccount(userId, universeId, playerId, playerName, password));
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                // Log it
                WebServiceDAL.StoreException("Webservice", "SynchronizeCredentials", ex);
                return(false);
            }
        }
예제 #11
0
        public int UpdateCouponStatus(string id, int couponStatus)
        {
            WebServiceDAL wsdal = new WebServiceDAL();

            return(wsdal.UpdateCouponStatus(id, couponStatus));
        }
예제 #12
0
        public DataSet GetACT_SiteActivityList(string siteActivityID)
        {
            WebServiceDAL wsdal = new WebServiceDAL();

            return(wsdal.GetACT_SiteActivityList(siteActivityID));
        }
예제 #13
0
        public string SetupApplication(Guid toolId, Guid applicationKey, string prevToolVersion, string newToolVersion)
        {
            Guid userId = AuthenticateClient("SetupApplication");

            SetupAppObj returnObj = new SetupAppObj();

            try
            {
                // Link user to the application
                WebServiceDAL.LinkUserToApplication(applicationKey, userId);
                WebServiceDAL.UpgradeApplicationVersion(toolId, applicationKey, userId, prevToolVersion, newToolVersion);

                returnObj.IsApplicationUserValid = WebServiceDAL.IsApplicationUserValid(applicationKey, userId);
                returnObj.ToolLatestVersion      = WebServiceDAL.GetLatestToolVersion(toolId);
                returnObj.IsToolValid            = WebServiceDAL.IsToolValid(toolId, newToolVersion);

                if (returnObj.IsApplicationUserValid && returnObj.IsToolValid)
                {
                    returnObj.IsUserAllowedToUseThisTool = WebServiceDAL.IsUserAllowedToUseThisTool(toolId, userId);
                }

                if (returnObj.IsApplicationUserValid && returnObj.IsToolValid && returnObj.IsUserAllowedToUseThisTool)
                {
                    returnObj.CommunityData = WebServiceDAL.GetUserCommunityData(toolId, userId);

                    Int64 encryptionKeyId = WebServiceDAL.GetUserEncryptionKeyId(userId);

                    if (encryptionKeyId == 0)
                    {
                        returnObj.EncryptionKeysExists = WebServiceDAL.CreateUserEncryptionKey(userId, Credentials.Password);
                        encryptionKeyId = WebServiceDAL.GetUserEncryptionKeyId(userId);
                    }
                    else
                    {
                        returnObj.EncryptionKeysExists = true;
                    }

                    if (encryptionKeyId != 0)
                    {
                        DataTable encryptionKeys = WebServiceDAL.GetUserEncryptionKeys(encryptionKeyId);
                        string    serverKey      = "";
                        string    clientKey      = "";
                        try
                        {
                            serverKey = Encryption.DecryptString(UtilitiesBLL.DecryptEncryptionKeyHash(encryptionKeys.Rows[0]["ServerKey"].ToString()), Credentials.Password);
                            clientKey = Encryption.DecryptString(UtilitiesBLL.DecryptEncryptionKeyHash(encryptionKeys.Rows[0]["ClientKey"].ToString()), Credentials.Password);
                        }
                        catch (Exception ex)
                        {
                            WebServiceDAL.StoreException("Webservice", "SetupApplication - Keys encryption", ex);
                            // ServerKey or ClientKey is null/empty or something else went wrong when decrypting
                            // Therefore, create new keys
                            serverKey = UtilitiesBLL.CreateEncryptionKeyHash(Encryption.EncryptString(RandomPassword.Generate(15, 20), Credentials.Password));
                            clientKey = RandomPassword.Generate(15, 20);
                            returnObj.EncryptionKeysExists = WebServiceDAL.UpdateEncryptionKey(encryptionKeyId, serverKey, UtilitiesBLL.CreateEncryptionKeyHash(Encryption.EncryptString(clientKey, Credentials.Password)));
                            // Delete all saved passwords
                            WebServiceDAL.DeleteUserUniverseCredentialsPassword(userId);
                            serverKey = null;
                        }
                        if (!string.IsNullOrEmpty(clientKey))
                        {
                            returnObj.ClientEncryptionKey = clientKey;
                        }
                        else
                        {
                            throw new Exception("ClientKey cannot be empty or null");
                        }

                        if (!string.IsNullOrEmpty(serverKey))
                        {
                            returnObj.CredentialsList = WebServiceDAL.GetUserUniversesAccounts(userId, serverKey, clientKey);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                WebServiceDAL.StoreException("Webservice", "SetupApplication", ex);
                returnObj.Error        = true;
                returnObj.ErrorMessage = ex.Message;
            }

            return(SerializeDeserializeObject.SerializeObject <SetupAppObj>(returnObj));;
        }
예제 #14
0
        public string GetUserCommunityData(Guid toolId)
        {
            Guid userId = AuthenticateClient("GetUserCommunityData");

            return(WebServiceDAL.GetUserCommunityData(toolId, userId));
        }
예제 #15
0
        public DataSet GetACT_CouponData(string siteCode, int couponStatus)
        {
            WebServiceDAL wsdal = new WebServiceDAL();

            return(wsdal.GetACT_CouponList(siteCode, couponStatus));
        }
        public static void CreateSoapHeaderLog(string action, Guid?toolId, Guid?applicationKey, Guid?userId, string userName, int status, string error)
        {
            // status = 0 -> credentials valid
            // status = 1 -> soapHeader == null
            // status = 2 -> soapHeader.Username == null
            // status = 3 -> soapHeader.Password == null
            // status = 4 -> invalid username
            // status = 5 -> account is not approved
            // status = 6 -> account is locked
            // status = 7 -> wrong password
            // status = 8 -> ValidateCredentials sql exception
            // status = 9 -> Could not find soap header
            // status = 10 -> soapheader not required

            SqlDataConnector oDC = null;

            try
            {
                bool   https     = false;
                string server    = null;
                string url       = null;
                string ipAddress = null;
                try
                {
                    if (HttpContext.Current != null)
                    {
                        try
                        {
                            https  = HttpContext.Current.Request.Url.Scheme.ToLower().Equals("https") ? true : false;
                            server = HttpContext.Current.Request.Url.Authority;
                            url    = HttpContext.Current.Request.Url.AbsoluteUri;
                        }
                        catch { }

                        try
                        {
                            ipAddress = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString();
                        }
                        catch
                        {
                        }

                        try
                        {
                            if (string.IsNullOrEmpty(ipAddress))
                            {
                                ipAddress = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString();
                            }
                        }
                        catch { }

                        if (string.IsNullOrEmpty(ipAddress))
                        {
                            ipAddress = HttpContext.Current.Request.UserHostAddress;
                        }
                    }
                }
                catch { }

                oDC = new SqlDataConnector();

                string sqlQuery = "INSERT INTO db_SoapHeaderLog " +
                                  "(DateTime, Https, Server, Url, Action, IpAddress, ToolId, ApplicationKey, UserId, UserName, Status, Error)" +
                                  "VALUES (GETUTCDATE(), @Https, @Server, @Url, @Action, @IpAddress, @ToolId, @ApplicationKey, @UserId, @UserName, @Status, @Error)";

                List <SqlParameter> cmdParameters = new List <SqlParameter>();
                cmdParameters.Add(oDC.CreateInputParam("@Https", SqlDbType.Bit, https));
                cmdParameters.Add(oDC.CreateInputParam("@Server", SqlDbType.NVarChar, server));
                cmdParameters.Add(oDC.CreateInputParam("@Url", SqlDbType.NVarChar, url));
                cmdParameters.Add(oDC.CreateInputParam("@Action", SqlDbType.NVarChar, action));
                cmdParameters.Add(oDC.CreateInputParam("@IpAddress", SqlDbType.NVarChar, ipAddress));
                cmdParameters.Add(oDC.CreateInputParam("@ToolId", SqlDbType.UniqueIdentifier, toolId));
                cmdParameters.Add(oDC.CreateInputParam("@ApplicationKey", SqlDbType.UniqueIdentifier, applicationKey));
                cmdParameters.Add(oDC.CreateInputParam("@UserId", SqlDbType.UniqueIdentifier, userId));
                cmdParameters.Add(oDC.CreateInputParam("@UserName", SqlDbType.NVarChar, userName));
                cmdParameters.Add(oDC.CreateInputParam("@Status", SqlDbType.Int, status));
                cmdParameters.Add(oDC.CreateInputParam("@Error", SqlDbType.NVarChar, error));

                int result = oDC.ExecNonQuerybyQuery(sqlQuery, cmdParameters.ToArray());

                if (result != 1)
                {
                    // log it
                }
            }
            catch (Exception ex)
            {
                // log it
                WebServiceDAL.StoreException("Webservice", "CreateSoapHeaderLog", ex);
            }
            finally
            {
                if (oDC != null)
                {
                    oDC.Dispose();
                }
            }
        }
예제 #17
0
        public DataSet GetSP_OrderDetailsData(string oderID)
        {
            WebServiceDAL wsdal = new WebServiceDAL();

            return(wsdal.GetSP_OrderDetailsList(oderID));
        }
예제 #18
0
        public DataSet GetSP_OrdersData(string strWhere)
        {
            WebServiceDAL wsdal = new WebServiceDAL();

            return(wsdal.GetSP_OrdersList(strWhere));
        }
예제 #19
0
 public bool IsToolValid(Guid toolId, string toolVersion)
 {
     AuthenticateClient("IsToolValid");
     return(WebServiceDAL.IsToolValid(toolId, toolVersion));
 }
예제 #20
0
        public int UpdateHasSendStatus(string oderID, int hasSend)
        {
            WebServiceDAL wsdal = new WebServiceDAL();

            return(wsdal.UpdateHasSendStatus(oderID, hasSend));
        }
예제 #21
0
        public bool IsUserAllowedToUseThisTool(Guid toolId)
        {
            Guid userId = AuthenticateClient("IsUserAllowedToUseThisTool");

            return(WebServiceDAL.IsUserAllowedToUseThisTool(toolId, userId));
        }
예제 #22
0
 public string GetLatestToolVersion(Guid toolId)
 {
     AuthenticateClient("GetLatestToolVersion");
     return(WebServiceDAL.GetLatestToolVersion(toolId));
 }
예제 #23
0
        public DataSet GetACT_CouponData(string strWhere)
        {
            WebServiceDAL wsdal = new WebServiceDAL();

            return(wsdal.GetACT_CouponList(strWhere));
        }