示例#1
0
        //===============================================================
        // Function: AddIntegerValue
        //===============================================================
        public void AddIntegerValue(string keyName, int value)
        {
            SqlConnection conn = new SqlConnection(GlobalSettings.connectionString);
            try
            {
                conn.Open();

                SqlCommand cmd = new SqlCommand("spGlobalDataAddIntegerValue", conn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@KeyName", SqlDbType.NVarChar, 50).Value = keyName;
                cmd.Parameters.Add("@Value", SqlDbType.Int).Value = value;
                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                ErrorLog errorLog = new ErrorLog();
                errorLog.WriteLog("GlobalData", "AddIntegerValue", ex.Message, logMessageLevel.errorMessage);
                throw ex;
            }
            finally
            {
                conn.Close();
            }
        }
示例#2
0
        //===============================================================
        // Function: GetAllEnableUserDetails
        //===============================================================
        public DataTable GetAllEnableUserDetails()
        {
            DbConnection conn = new SqlConnection(GlobalSettings.connectionString);
            try
            {
                conn.Open();
                DataTable dtUsers = new DataTable();
                DbCommand cmd = conn.CreateCommand();
                //cmd.CommandType = CommandType.StoredProcedure;
                //cmd.CommandText = "spGetAllEnableUserDetails";
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = "SELECT top 24 userid,[guid],(select count(*) as gcount from events where deleted = 0 and userid = u.userid group by userid)gcount,(select count(*) as mcount from Users WHERE LoginEnabled = 1 and deleted = 0)mcount, "
                + "EmailAddress, FirstName, LastName, Gender, Deleted, DeletedDate,"
            + "HomeTown, Birthday, ProfilePicFilename, ProfilePicThumbnail, ProfilePicPreview,"
            + "ProfileText, CountryID, LanguageID, TimezoneID, EnableSendEmails,"
            + "LoginEnabled, UserPassword, FailedLoginCount, PasswordExpiryDate, LastLoginDate,"
            + "CreatedDate, CreatedByFullName, LastUpdatedDate, LastUpdatedByFullName "
            + "FROM Users u"
            + " WHERE LoginEnabled = 1 and deleted = 0 order by createddate desc";

                DbDataAdapter adp = new SqlDataAdapter();
                adp.SelectCommand = cmd;
                adp.Fill(dtUsers);
                return dtUsers;
            }
            catch (Exception ex)
            {
                ErrorLog errorLog = new ErrorLog();
                errorLog.WriteLog("SedogoUser", "GetAllEnableUserDetails", ex.Message, logMessageLevel.errorMessage);
                throw ex;
            }
            finally
            {
                conn.Close();
            }
        }
示例#3
0
        //===============================================================
        // Function: Update
        //===============================================================
        public void Update()
        {
            SqlConnection conn = new SqlConnection(GlobalSettings.connectionString);
            try
            {
                conn.Open();

                SqlCommand cmd = new SqlCommand("spUpdateCountry", conn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@CountryID", SqlDbType.Int).Value = m_countryID;
                cmd.Parameters.Add("@CountryCode", SqlDbType.NVarChar, 10).Value = m_countryCode;
                cmd.Parameters.Add("@CountryName", SqlDbType.NVarChar, 150).Value = m_countryName;
                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                ErrorLog errorLog = new ErrorLog();
                errorLog.WriteLog("Country", "Update", ex.Message, logMessageLevel.errorMessage);
                throw ex;
            }
            finally
            {
                conn.Close();
            }
        }
示例#4
0
        //===============================================================
        // Function: Delete
        //===============================================================
        public void Delete()
        {
            SqlConnection conn = new SqlConnection(GlobalSettings.connectionString);
            try
            {
                conn.Open();

                SqlCommand cmd = new SqlCommand("spDeleteUser", conn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@UserID", SqlDbType.Int).Value = m_userID;
                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                ErrorLog errorLog = new ErrorLog();
                errorLog.WriteLog("SedogoUser", "Delete", ex.Message, logMessageLevel.errorMessage);
                throw ex;
            }
            finally
            {
                conn.Close();
            }
        }
示例#5
0
        //===============================================================
        // Function: GetUserIDFromGUID
        //===============================================================
        public static int GetUserIDFromGUID(string GUID)
        {
            int userID = -1;

            DbConnection conn = new SqlConnection(GlobalSettings.connectionString);

            try
            {
                conn.Open();

                DbCommand cmd = conn.CreateCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "spGetUserIDFromGUID";
                DbParameter param = cmd.CreateParameter();
                param.ParameterName = "@GUID";
                param.Value = GUID;
                cmd.Parameters.Add(param);
                DbDataReader rdr = cmd.ExecuteReader();
                if (rdr.HasRows != false)
                {
                    rdr.Read();
                    userID = (int)rdr["UserID"];
                    rdr.Close();
                }
            }
            catch (Exception ex)
            {
                ErrorLog errorLog = new ErrorLog();
                errorLog.WriteLog("SedogoUser", "GetUserIDFromGUID", ex.Message, logMessageLevel.errorMessage);
                throw ex;
            }
            finally
            {
                conn.Close();
            }

            return userID;
        }
示例#6
0
        //===============================================================
        // Function: VerifyLogin
        //===============================================================
        public loginResults VerifyLogin(string emailAddress, string testPassword,
            Boolean passwordIsEncrypted, Boolean recordInLoginHistory, string source)
        {
            loginResults returnValue = loginResults.loginFailed;

            DbConnection conn = new SqlConnection(GlobalSettings.connectionString);

            try
            {
                conn.Open();

                // Get contact info
                DbCommand cmd = conn.CreateCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "spVerifyUserLogin";
                DbParameter param = cmd.CreateParameter();
                param.ParameterName = "@EmailAddress";
                param.Value = emailAddress.Trim();
                cmd.Parameters.Add(param);
                DbDataReader rdr = cmd.ExecuteReader();
                if (rdr.HasRows == false)
                {
                    // Update the DB with a failed login attempt (email address not recognised)
                    UpdateLoginHistory(-1, "U", source);     // Unknown user
                    returnValue = loginResults.loginFailed;
                }
                else
                {
                    // Email address exists, now check the password is OK
                    int userID;
                    Boolean loginEnabled = false;
                    string userPassword = "";
                    int failedLoginCount = 0;
                    DateTime passwordExpiryDate = DateTime.MinValue;

                    rdr.Read();
                    userID = (int)rdr["UserID"];
                    if (!rdr.IsDBNull(rdr.GetOrdinal("LoginEnabled")))
                    {
                        loginEnabled = (Boolean)rdr["LoginEnabled"];
                    }
                    if (!rdr.IsDBNull(rdr.GetOrdinal("UserPassword")))
                    {
                        userPassword = (string)rdr["UserPassword"];
                    }
                    if (!rdr.IsDBNull(rdr.GetOrdinal("FailedLoginCount")))
                    {
                        failedLoginCount = (int)rdr["FailedLoginCount"];
                    }
                    if (!rdr.IsDBNull(rdr.GetOrdinal("PasswordExpiryDate")))
                    {
                        passwordExpiryDate = (DateTime)rdr["PasswordExpiryDate"];
                    }
                    rdr.Close();

                    if (DateTime.Compare(passwordExpiryDate, DateTime.Now) > 0)
                    {
                        // Update the DB with a failed login attempt (password expired)
                        if (recordInLoginHistory == true)
                        {
                            UpdateLoginHistory(userID, "E", source);     // Password expired
                        }
                        returnValue = loginResults.passwordExpired;

                        m_userID = userID;
                        ReadUserDetails();
                    }

                    PasswordEncrypt pe = new PasswordEncrypt();
                    string encryptedTestPassword = "";
                    if (passwordIsEncrypted == false)
                    {
                        encryptedTestPassword = pe.EncryptPassword(testPassword);
                    }
                    else
                    {
                        encryptedTestPassword = testPassword;
                    }

                    if ((userPassword != encryptedTestPassword) || (loginEnabled == false))
                    {
                        // Update the DB with a failed login attempt (invalid password)
                        UpdateLoginHistory(userID, "P", source);     // Invalid Password
                        if (loginEnabled == false)
                        {
                            returnValue = loginResults.loginNotActivated;
                        }
                        else
                        {
                            returnValue = loginResults.loginFailed;
                        }
                    }
                    else
                    {
                        // Update the DB with a successful login attempt
                        if (recordInLoginHistory == true)
                        {
                            UpdateLoginHistory(userID, "S", source);      // Success
                        }
                        returnValue = loginResults.loginSuccess;

                        m_userID = userID;
                        ReadUserDetails();
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorLog errorLog = new ErrorLog();
                errorLog.WriteLog("SedogoUser", "VerifyLogin", ex.Message, logMessageLevel.errorMessage);
                throw ex;
            }
            finally
            {
                conn.Close();
            }

            return returnValue;
        }
示例#7
0
        //===============================================================
        // Function: UpdatePassword
        //===============================================================
        public void UpdatePassword(string newPassword)
        {
            PasswordEncrypt pe = new PasswordEncrypt();
            string encryptedPassword = pe.EncryptPassword(newPassword);

            SqlConnection conn = new SqlConnection(GlobalSettings.connectionString);
            try
            {
                conn.Open();

                // Update users password
                SqlCommand cmd = new SqlCommand("spUpdateUserPassword", conn);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.Add("@UserID", SqlDbType.Int).Value = m_userID;
                cmd.Parameters.Add("@UserPassword", SqlDbType.NVarChar, 50).Value = encryptedPassword;
                cmd.Parameters.Add("@LastUpdatedDate", SqlDbType.DateTime).Value = DateTime.Now;
                cmd.Parameters.Add("@LastUpdatedByFullName", SqlDbType.NVarChar, 200).Value = m_loggedInUser;

                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                ErrorLog errorLog = new ErrorLog();
                errorLog.WriteLog("SedogoUser", "UpdatePassword", ex.Message, logMessageLevel.errorMessage);
                throw ex;
            }
            finally
            {
                conn.Close();
            }
        }
示例#8
0
        //===============================================================
        // Function: Update
        //===============================================================
        public void Update()
        {
            SqlConnection conn = new SqlConnection(GlobalSettings.connectionString);
            try
            {
                conn.Open();

                SqlCommand cmd = new SqlCommand("spUpdateUser", conn);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.Add("@UserID", SqlDbType.Int).Value = m_userID;
                cmd.Parameters.Add("@EmailAddress", SqlDbType.NVarChar, 200).Value = m_emailAddress;
                cmd.Parameters.Add("@FirstName", SqlDbType.NVarChar, 200).Value = m_firstName;
                cmd.Parameters.Add("@LastName", SqlDbType.NVarChar, 200).Value = m_lastName;
                cmd.Parameters.Add("@HomeTown", SqlDbType.NVarChar, 200).Value = m_homeTown;
                if (m_birthday == DateTime.MinValue)
                {
                    cmd.Parameters.Add("@Birthday", SqlDbType.DateTime).Value = DBNull.Value;
                }
                else
                {
                    cmd.Parameters.Add("@Birthday", SqlDbType.DateTime).Value = m_birthday;
                }
                cmd.Parameters.Add("@Gender", SqlDbType.NChar, 1).Value = m_gender;
                cmd.Parameters.Add("@CountryID", SqlDbType.Int).Value = m_countryID;
                cmd.Parameters.Add("@LanguageID", SqlDbType.Int).Value = m_languageID;
                cmd.Parameters.Add("@TimezoneID", SqlDbType.Int).Value = m_timezoneID;
                cmd.Parameters.Add("@LoginEnabled", SqlDbType.Bit).Value = m_loginEnabled;
                cmd.Parameters.Add("@EnableSendEmails", SqlDbType.Bit).Value = m_enableSendEmails;
                cmd.Parameters.Add("@AvatarNumber", SqlDbType.Int).Value = m_avatarNumber;
                cmd.Parameters.Add("@ProfileText", SqlDbType.NVarChar, 200).Value = m_profileText;
                cmd.Parameters.Add("@LastUpdatedDate", SqlDbType.DateTime).Value = DateTime.Now;
                cmd.Parameters.Add("@LastUpdatedByFullName", SqlDbType.NVarChar, 200).Value = m_loggedInUser;
                cmd.Parameters.Add("@FacebookUserID", SqlDbType.BigInt).Value = (m_facebookUserID == -1 ? (object)DBNull.Value : (object)m_facebookUserID);

                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                ErrorLog errorLog = new ErrorLog();
                errorLog.WriteLog("SedogoUser", "Update", ex.Message, logMessageLevel.errorMessage);
                throw ex;
            }
            finally
            {
                conn.Close();
            }
        }
示例#9
0
        //===============================================================
        // Function: GetEventInviteIDFromUserIDEventID
        //===============================================================
        public static int GetEventInviteIDFromUserIDEventID(int eventID, int userID)
        {
            int eventInviteID = 0;

            SqlConnection conn = new SqlConnection(GlobalSettings.connectionString);
            try
            {
                conn.Open();

                SqlCommand cmd = new SqlCommand("", conn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "spGetEventInviteIDFromUserIDEventID";
                cmd.Parameters.Add("@EventID", SqlDbType.Int).Value = eventID;
                cmd.Parameters.Add("@UserID", SqlDbType.Int).Value = userID;
                DbDataReader rdr = cmd.ExecuteReader();
                if (rdr.HasRows == true)
                {
                    rdr.Read();
                    eventInviteID = int.Parse(rdr[0].ToString());
                }
                rdr.Close();
            }
            catch (Exception ex)
            {
                ErrorLog errorLog = new ErrorLog();
                errorLog.WriteLog("EventInvite", "CheckUserEventInviteExists", ex.Message, logMessageLevel.errorMessage);
                throw ex;
            }
            finally
            {
                conn.Close();
            }

            return eventInviteID;
        }
示例#10
0
        //===============================================================
        // Function: GetEventInviteIDFromGUID
        //===============================================================
        public static int GetEventInviteIDFromGUID(string eventInviteGUID)
        {
            int eventInviteID = -1;

            SqlConnection conn = new SqlConnection(GlobalSettings.connectionString);
            try
            {
                conn.Open();

                SqlCommand cmd = new SqlCommand("", conn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "spSelectEventInviteIDFromGUID";
                cmd.Parameters.Add("@GUID", SqlDbType.NVarChar, 50).Value = eventInviteGUID;
                DbDataReader rdr = cmd.ExecuteReader();
                if (rdr.HasRows == true)
                {
                    rdr.Read();
                    eventInviteID = int.Parse(rdr["EventInviteID"].ToString());
                }
                rdr.Close();
            }
            catch (Exception ex)
            {
                ErrorLog errorLog = new ErrorLog();
                errorLog.WriteLog("EventInvite", "GetEventInviteIDFromGUID", ex.Message, logMessageLevel.errorMessage);
                throw ex;
            }
            finally
            {
                conn.Close();
            }

            return eventInviteID;
        }
示例#11
0
        //===============================================================
        // Function: GetProfileGoalPicsDetails
        //===============================================================
        public DataTable GetProfileGoalPicsDetails(int userID, Boolean showPrivate)
        {
            DbConnection conn = new SqlConnection(GlobalSettings.connectionString);
            try
            {
                conn.Open();
                DataTable dtUsers = new DataTable();
                DbCommand cmd = conn.CreateCommand();
                //cmd.CommandType = CommandType.StoredProcedure;
                //cmd.CommandText = "spGetAllEnableUserDetails";
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = "SELECT top 16 EventID,EventName, EventPicThumbnail, EventPicPreview "
                    + "FROM Events "
                    + " WHERE UserID = " + userID.ToString() + " and Deleted = 0 ";
                if( showPrivate == false )
                {
                    cmd.CommandText += "and PrivateEvent = 0 ";
                }
                cmd.CommandText += "order by CreatedDate desc ";

                DbDataAdapter adp = new SqlDataAdapter();
                adp.SelectCommand = cmd;
                adp.Fill(dtUsers);
                return dtUsers;
            }
            catch (Exception ex)
            {
                ErrorLog errorLog = new ErrorLog();
                errorLog.WriteLog("SedogoUser", "GetProfileGoalPicsDetails", ex.Message, logMessageLevel.errorMessage);
                throw ex;
            }
            finally
            {
                conn.Close();
            }
        }
示例#12
0
        //===============================================================
        // Function: Update
        //===============================================================
        public void Update()
        {
            SqlConnection conn = new SqlConnection(GlobalSettings.connectionString);
            try
            {
                conn.Open();

                SqlCommand cmd = new SqlCommand("spUpdateAdministrator", conn);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.Add("@AdministratorID", SqlDbType.Int).Value = m_administratorID;
                cmd.Parameters.Add("@EmailAddress", SqlDbType.NVarChar, 200).Value = m_emailAddress;
                cmd.Parameters.Add("@AdministratorName", SqlDbType.NVarChar, 200).Value = m_administratorName;
                cmd.Parameters.Add("@LoginEnabled", SqlDbType.Bit).Value = m_loginEnabled;
                cmd.Parameters.Add("@LastUpdatedDate", SqlDbType.DateTime).Value = DateTime.Now;
                cmd.Parameters.Add("@LastUpdatedByFullName", SqlDbType.NVarChar, 200).Value = m_loggedInUser;

                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                ErrorLog errorLog = new ErrorLog();
                errorLog.WriteLog("Administrator", "Update", ex.Message, logMessageLevel.errorMessage);
                throw ex;
            }
            finally
            {
                conn.Close();
            }
        }
示例#13
0
        //===============================================================
        // Function: ReadAdministratorDetails
        //===============================================================
        public void ReadAdministratorDetails()
        {
            DbConnection conn = new SqlConnection(GlobalSettings.connectionString);
            try
            {
                conn.Open();

                DbCommand cmd = conn.CreateCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "spSelectAdministratorDetails";
                DbParameter param = cmd.CreateParameter();
                param.ParameterName = "@AdministratorID";
                param.Value = m_administratorID;
                cmd.Parameters.Add(param);
                DbDataReader rdr = cmd.ExecuteReader();
                rdr.Read();
                if (!rdr.IsDBNull(rdr.GetOrdinal("EmailAddress")))
                {
                    m_emailAddress = (string)rdr["EmailAddress"];
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("AdministratorName")))
                {
                    m_administratorName = (string)rdr["AdministratorName"];
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("Deleted")))
                {
                    m_deleted = (Boolean)rdr["Deleted"];
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("DeletedDate")))
                {
                    m_deletedDate = (DateTime)rdr["DeletedDate"];
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("LoginEnabled")))
                {
                    m_loginEnabled = (Boolean)rdr["LoginEnabled"];
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("AdministratorPassword")))
                {
                    m_administratorPassword = (string)rdr["AdministratorPassword"];
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("FailedLoginCount")))
                {
                    m_failedLoginCount = int.Parse(rdr["FailedLoginCount"].ToString());
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("PasswordExpiryDate")))
                {
                    m_passwordExpiryDate = (DateTime)rdr["PasswordExpiryDate"];
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("LastLoginDate")))
                {
                    m_lastLoginDate = (DateTime)rdr["LastLoginDate"];
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("CreatedDate")))
                {
                    m_createdDate = (DateTime)rdr["CreatedDate"];
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("CreatedByFullName")))
                {
                    m_createdByFullName = (string)rdr["CreatedByFullName"];
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("LastUpdatedDate")))
                {
                    m_lastUpdatedDate = (DateTime)rdr["LastUpdatedDate"];
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("LastUpdatedByFullName")))
                {
                    m_lastUpdatedByFullName = (string)rdr["LastUpdatedByFullName"];
                }
                rdr.Close();
            }
            catch (Exception ex)
            {
                ErrorLog errorLog = new ErrorLog();
                errorLog.WriteLog("Administrator", "ReadAdministratorDetails", ex.Message, logMessageLevel.errorMessage);
                throw ex;
            }
            finally
            {
                conn.Close();
            }
        }
示例#14
0
        //===============================================================
        // Function: Add
        //===============================================================
        public void Add()
        {
            SqlConnection conn = new SqlConnection(GlobalSettings.connectionString);
            try
            {
                conn.Open();

                SqlCommand cmd = new SqlCommand("spAddAdministrator", conn);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.Add("@EmailAddress", SqlDbType.NVarChar, 200).Value = m_emailAddress;
                cmd.Parameters.Add("@AdministratorName", SqlDbType.NVarChar, 200).Value = m_administratorName;
                cmd.Parameters.Add("@CreatedDate", SqlDbType.DateTime).Value = DateTime.Now;
                cmd.Parameters.Add("@CreatedByFullName", SqlDbType.NVarChar, 200).Value = m_loggedInUser;
                cmd.Parameters.Add("@LastUpdatedDate", SqlDbType.DateTime).Value = DateTime.Now;
                cmd.Parameters.Add("@LastUpdatedByFullName", SqlDbType.NVarChar, 200).Value = m_loggedInUser;

                SqlParameter paramAdministratorID = cmd.CreateParameter();
                paramAdministratorID.ParameterName = "@AdministratorID";
                paramAdministratorID.SqlDbType = SqlDbType.Int;
                paramAdministratorID.Direction = ParameterDirection.Output;
                cmd.Parameters.Add(paramAdministratorID);

                cmd.ExecuteNonQuery();
                m_administratorID = (int)paramAdministratorID.Value;
            }
            catch (Exception ex)
            {
                ErrorLog errorLog = new ErrorLog();
                errorLog.WriteLog("Administrator", "Add", ex.Message, logMessageLevel.errorMessage);
                throw ex;
            }
            finally
            {
                conn.Close();
            }
        }
示例#15
0
        //===============================================================
        // Function: CheckValueExists
        //===============================================================
        public Boolean CheckValueExists(string keyName)
        {
            Boolean returnValue = false;

            DbConnection conn = new SqlConnection(GlobalSettings.connectionString);
            try
            {
                conn.Open();

                DbCommand cmd = conn.CreateCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "spGlobalDataGetStringValue";
                DbParameter param = cmd.CreateParameter();
                param.ParameterName = "@KeyName";
                param.Value = keyName;
                cmd.Parameters.Add(param);
                DbDataReader rdr = cmd.ExecuteReader();
                if (rdr.HasRows == true)
                {
                    returnValue = true;
                }
                rdr.Close();
            }
            catch (Exception ex)
            {
                ErrorLog errorLog = new ErrorLog();
                errorLog.WriteLog("GlobalData", "CheckValueExists", ex.Message, logMessageLevel.errorMessage);
                throw ex;
            }
            finally
            {
                conn.Close();
            }
            return returnValue;
        }
示例#16
0
        //===============================================================
        // Function: GetInviteCount
        //===============================================================
        public static int GetInviteCount(int eventID)
        {
            int inviteCount = 0;

            SqlConnection conn = new SqlConnection(GlobalSettings.connectionString);
            try
            {
                conn.Open();

                SqlCommand cmd = new SqlCommand("", conn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "spSelectEventInviteCountByEventID";
                cmd.Parameters.Add("@EventID", SqlDbType.Int).Value = eventID;
                DbDataReader rdr = cmd.ExecuteReader();
                rdr.Read();
                inviteCount = int.Parse(rdr[0].ToString());
                rdr.Close();
            }
            catch (Exception ex)
            {
                ErrorLog errorLog = new ErrorLog();
                errorLog.WriteLog("EventInvite", "GetInviteCount", ex.Message, logMessageLevel.errorMessage);
                throw ex;
            }
            finally
            {
                conn.Close();
            }

            return inviteCount;
        }
示例#17
0
        //===============================================================
        // Function: GetStringValue
        //===============================================================
        public string GetStringValue(string keyName)
        {
            string returnString = "";

            DbConnection conn = new SqlConnection(GlobalSettings.connectionString);
            try
            {
                conn.Open();

                DbCommand cmd = conn.CreateCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "spGlobalDataGetStringValue";
                DbParameter param = cmd.CreateParameter();
                param.ParameterName = "@KeyName";
                param.Value = keyName;
                cmd.Parameters.Add(param);
                DbDataReader rdr = cmd.ExecuteReader();
                if (rdr.HasRows == false)
                {
                    // GlobalData value not found - throw an exception
                    GlobalDataMissingException ex = new GlobalDataMissingException();
                    throw ex;
                }
                else
                {
                    rdr.Read();
                    if (rdr.IsDBNull(rdr.GetOrdinal("StringValue")))
                    {
                        // GlobalData value is null - throw an exception
                        GlobalDataNullException ex = new GlobalDataNullException();
                        throw ex;
                    }
                    else
                    {
                        returnString = (string)rdr["StringValue"];
                    }
                    rdr.Close();
                }
            }
            catch (Exception ex)
            {
                ErrorLog errorLog = new ErrorLog();
                errorLog.WriteLog("GlobalData", "GetStringValue", "Keyname: " + keyName + ", Error: " + ex.Message, logMessageLevel.errorMessage);
                throw ex;
            }
            finally
            {
                conn.Close();
            }

            return returnString;
        }
示例#18
0
        //===============================================================
        // Function: GetPendingInviteCountForUser
        //===============================================================
        public static int GetPendingInviteCountForUser(int userID)
        {
            int inviteCount = 0;

            SedogoUser sedogoUser = new SedogoUser("", userID);

            SqlConnection conn = new SqlConnection(GlobalSettings.connectionString);
            try
            {
                conn.Open();

                SqlCommand cmd = new SqlCommand("", conn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "spSelectPendingInviteCountForUser";
                cmd.Parameters.Add("@UserID", SqlDbType.Int).Value = userID;
                cmd.Parameters.Add("@EmailAddress", SqlDbType.NVarChar, 200).Value = sedogoUser.emailAddress;

                DbDataReader rdr = cmd.ExecuteReader();
                rdr.Read();
                inviteCount = int.Parse(rdr[0].ToString());
                rdr.Close();
            }
            catch (Exception ex)
            {
                ErrorLog errorLog = new ErrorLog();
                errorLog.WriteLog("EventInvite", "GetPendingInviteCountForUser", ex.Message, logMessageLevel.errorMessage);
                throw ex;
            }
            finally
            {
                conn.Close();
            }

            return inviteCount;
        }
示例#19
0
        //===============================================================
        // Function: ResetUserPassword
        //===============================================================
        public Boolean ResetUserPassword(string emailAddress, ref string newPassword)
        {
            // Lookup the Contact ID of the supplied email address
            SqlConnection conn = new SqlConnection(GlobalSettings.connectionString);
            try
            {
                conn.Open();

                SqlCommand cmd = new SqlCommand("spVerifyUserLogin", conn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@EmailAddress", SqlDbType.NVarChar, 200).Value = emailAddress.Trim();
                DbDataReader rdr = cmd.ExecuteReader();
                if (rdr.HasRows == false)
                {
                    // Email address supplied not found
                    return false;
                }
                else
                {
                    // Email address exists, now check the password is OK
                    int userID;
                    Boolean loginEnabled;

                    rdr.Read();
                    userID = (int)rdr["UserID"];
                    loginEnabled = (Boolean)rdr["LoginEnabled"];
                    rdr.Close();

                    m_userID = userID;
                    ReadUserDetails();
                    GenerateNewPassword(ref newPassword);
                }
            }
            catch (Exception ex)
            {
                ErrorLog errorLog = new ErrorLog();
                errorLog.WriteLog("SedogoUser", "ResetUserPassword", ex.Message, logMessageLevel.errorMessage);
                throw ex;
            }
            finally
            {
                conn.Close();
            }

            return true;
        }
示例#20
0
        //===============================================================
        // Function: Add
        //===============================================================
        public void Add()
        {
            m_eventInviteGUID = System.Guid.NewGuid().ToString();

            SqlConnection conn = new SqlConnection(GlobalSettings.connectionString);
            try
            {
                conn.Open();

                SqlCommand cmd = new SqlCommand("spAddEventInvite", conn);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.Add("@EventID", SqlDbType.Int).Value = m_eventID;
                cmd.Parameters.Add("@GUID", SqlDbType.NVarChar, 50).Value = m_eventInviteGUID;
                if (m_userID > 0)
                {
                    cmd.Parameters.Add("@UserID", SqlDbType.Int).Value = m_userID;
                }
                else
                {
                    cmd.Parameters.Add("@UserID", SqlDbType.Int).Value = DBNull.Value;
                }
                cmd.Parameters.Add("@EmailAddress", SqlDbType.NVarChar, 200).Value = m_emailAddress;
                cmd.Parameters.Add("@InviteAdditionalText", SqlDbType.NVarChar, -1).Value = m_inviteAdditionalText;
                cmd.Parameters.Add("@InviteEmailSent", SqlDbType.Bit).Value = m_inviteEmailSent;
                cmd.Parameters.Add("@InviteEmailSentEmailAddress", SqlDbType.NVarChar, 200).Value = m_inviteEmailSentEmailAddress;
                if (m_inviteAcceptedDate > DateTime.MinValue)
                {
                    cmd.Parameters.Add("@InviteEmailSentDate", SqlDbType.DateTime).Value = m_inviteEmailSentDate;
                }
                else
                {
                    cmd.Parameters.Add("@InviteEmailSentDate", SqlDbType.DateTime).Value = DBNull.Value;
                }
                cmd.Parameters.Add("@CreatedDate", SqlDbType.DateTime).Value = DateTime.Now;
                cmd.Parameters.Add("@CreatedByFullName", SqlDbType.NVarChar, 200).Value = m_loggedInUser;
                cmd.Parameters.Add("@LastUpdatedDate", SqlDbType.DateTime).Value = DateTime.Now;
                cmd.Parameters.Add("@LastUpdatedByFullName", SqlDbType.NVarChar, 200).Value = m_loggedInUser;

                SqlParameter paramEventInviteID = cmd.CreateParameter();
                paramEventInviteID.ParameterName = "@EventInviteID";
                paramEventInviteID.SqlDbType = SqlDbType.Int;
                paramEventInviteID.Direction = ParameterDirection.Output;
                cmd.Parameters.Add(paramEventInviteID);

                cmd.ExecuteNonQuery();
                m_eventInviteID = (int)paramEventInviteID.Value;
            }
            catch (Exception ex)
            {
                ErrorLog errorLog = new ErrorLog();
                errorLog.WriteLog("EventInvite", "Add", ex.Message, logMessageLevel.errorMessage);
                throw ex;
            }
            finally
            {
                conn.Close();
            }
        }
示例#21
0
        //===============================================================
        // Function: UpdateLoginHistory
        //===============================================================
        public void UpdateLoginHistory(int userID, string status, string source)
        {
            DbConnection conn = new SqlConnection(GlobalSettings.connectionString);
            try
            {
                conn.Open();

                // Update the DB with a failed login attempt (email address not recognised)
                DbCommand cmdLoginHistory = conn.CreateCommand();
                cmdLoginHistory.CommandType = CommandType.StoredProcedure;
                cmdLoginHistory.CommandText = "spInsertUserLoginHistory";
                DbParameter paramLoginHistory1 = cmdLoginHistory.CreateParameter();
                paramLoginHistory1.ParameterName = "@UserID";
                if (userID < 0)
                {
                    paramLoginHistory1.Value = DBNull.Value;
                }
                else
                {
                    paramLoginHistory1.Value = userID;
                }
                cmdLoginHistory.Parameters.Add(paramLoginHistory1);

                DbParameter paramLoginHistory2 = cmdLoginHistory.CreateParameter();
                paramLoginHistory2.ParameterName = "@LoginStatus";
                paramLoginHistory2.Value = status;
                cmdLoginHistory.Parameters.Add(paramLoginHistory2);

                DbParameter paramLoginHistorySource = cmdLoginHistory.CreateParameter();
                paramLoginHistorySource.ParameterName = "@Source";
                paramLoginHistorySource.Value = source;
                cmdLoginHistory.Parameters.Add(paramLoginHistorySource);

                cmdLoginHistory.ExecuteNonQuery();

                if ((status == "L") || (status == "P") && userID > 0)
                {
                    DbCommand cmdIncrementFailedLoginCount = conn.CreateCommand();
                    cmdIncrementFailedLoginCount.CommandType = CommandType.StoredProcedure;
                    cmdIncrementFailedLoginCount.CommandText = "spIncrementFailedLoginCount";
                    DbParameter paramIncrementFailedLoginCount = cmdIncrementFailedLoginCount.CreateParameter();
                    paramIncrementFailedLoginCount.ParameterName = "@UserID";
                    paramIncrementFailedLoginCount.Value = userID;
                    cmdIncrementFailedLoginCount.Parameters.Add(paramIncrementFailedLoginCount);

                    cmdIncrementFailedLoginCount.ExecuteNonQuery();
                }
            }
            catch (Exception ex)
            {
                ErrorLog errorLog = new ErrorLog();
                errorLog.WriteLog("SedogoUser", "UpdateLoginHistory", ex.Message, logMessageLevel.errorMessage);
                throw ex;
            }
            finally
            {
                conn.Close();
            }
        }
示例#22
0
        //===============================================================
        // Function: Delete
        //===============================================================
        public void Delete()
        {
            SqlConnection conn = new SqlConnection(GlobalSettings.connectionString);
            try
            {
                conn.Open();

                SqlCommand cmd = new SqlCommand("spDeleteEventInvite", conn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@EventInviteID", SqlDbType.Int).Value = m_eventInviteID;
                cmd.Parameters.Add("@LastUpdatedDate", SqlDbType.DateTime).Value = DateTime.Now;
                cmd.Parameters.Add("@LastUpdatedByFullName", SqlDbType.NVarChar, 200).Value = m_loggedInUser;
                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                ErrorLog errorLog = new ErrorLog();
                errorLog.WriteLog("EventInvite", "Delete", ex.Message, logMessageLevel.errorMessage);
                throw ex;
            }
            finally
            {
                conn.Close();
            }
        }
示例#23
0
        //===============================================================
        // Function: UpdateUserProfilePic
        //===============================================================
        public void UpdateUserProfilePic()
        {
            SqlConnection conn = new SqlConnection(GlobalSettings.connectionString);
            try
            {
                conn.Open();

                SqlCommand cmd = new SqlCommand("spUpdateUserProfilePic", conn);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.Add("@UserID", SqlDbType.Int).Value = m_userID;
                cmd.Parameters.Add("@ProfilePicFilename", SqlDbType.NVarChar, 200).Value = m_profilePicFilename;
                cmd.Parameters.Add("@ProfilePicThumbnail", SqlDbType.NVarChar, 200).Value = m_profilePicThumbnail;
                cmd.Parameters.Add("@ProfilePicPreview", SqlDbType.NVarChar, 200).Value = m_profilePicPreview;
                cmd.Parameters.Add("@LastUpdatedDate", SqlDbType.DateTime).Value = DateTime.Now;
                cmd.Parameters.Add("@LastUpdatedByFullName", SqlDbType.NVarChar, 200).Value = m_loggedInUser;

                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                ErrorLog errorLog = new ErrorLog();
                errorLog.WriteLog("SedogoUser", "UpdateUserProfilePic", ex.Message, logMessageLevel.errorMessage);
                throw ex;
            }
            finally
            {
                conn.Close();
            }
        }
示例#24
0
        //===============================================================
        // Function: ReadEventInviteDetails
        //===============================================================
        public void ReadEventInviteDetails()
        {
            DbConnection conn = new SqlConnection(GlobalSettings.connectionString);
            try
            {
                conn.Open();

                DbCommand cmd = conn.CreateCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "spSelectEventInviteDetails";
                DbParameter param = cmd.CreateParameter();
                param.ParameterName = "@EventInviteID";
                param.Value = m_eventInviteID;
                cmd.Parameters.Add(param);
                DbDataReader rdr = cmd.ExecuteReader();
                rdr.Read();
                if (!rdr.IsDBNull(rdr.GetOrdinal("EventID")))
                {
                    m_eventID = int.Parse(rdr["EventID"].ToString());
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("GUID")))
                {
                    m_eventInviteGUID = rdr["GUID"].ToString();
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("EmailAddress")))
                {
                    m_emailAddress = (string)rdr["EmailAddress"];
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("UserID")))
                {
                    m_userID = int.Parse(rdr["UserID"].ToString());
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("InviteAdditionalText")))
                {
                    m_inviteAdditionalText = (string)rdr["InviteAdditionalText"];
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("InviteEmailSent")))
                {
                    m_inviteEmailSent = (Boolean)rdr["InviteEmailSent"];
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("InviteEmailSentEmailAddress")))
                {
                    m_inviteEmailSentEmailAddress = (string)rdr["InviteEmailSentEmailAddress"];
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("InviteEmailSentDate")))
                {
                    m_inviteEmailSentDate = (DateTime)rdr["InviteEmailSentDate"];
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("InviteAccepted")))
                {
                    m_inviteAccepted = (Boolean)rdr["InviteAccepted"];
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("InviteAcceptedDate")))
                {
                    m_inviteAcceptedDate = (DateTime)rdr["InviteAcceptedDate"];
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("InviteDeclined")))
                {
                    m_inviteDeclined = (Boolean)rdr["InviteDeclined"];
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("InviteDeclinedDate")))
                {
                    m_inviteDeclinedDate = (DateTime)rdr["InviteDeclinedDate"];
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("Deleted")))
                {
                    m_deleted = (Boolean)rdr["Deleted"];
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("CreatedDate")))
                {
                    m_createdDate = (DateTime)rdr["CreatedDate"];
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("CreatedByFullName")))
                {
                    m_createdByFullName = (string)rdr["CreatedByFullName"];
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("LastUpdatedDate")))
                {
                    m_lastUpdatedDate = (DateTime)rdr["LastUpdatedDate"];
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("LastUpdatedByFullName")))
                {
                    m_lastUpdatedByFullName = (string)rdr["LastUpdatedByFullName"];
                }
                rdr.Close();
            }
            catch (Exception ex)
            {
                ErrorLog errorLog = new ErrorLog();
                errorLog.WriteLog("EventInvite", "ReadEventInviteDetails", ex.Message, logMessageLevel.errorMessage);
                throw ex;
            }
            finally
            {
                conn.Close();
            }
        }
示例#25
0
        //===============================================================
        // Function: VerifyPassword
        //===============================================================
        public Boolean VerifyPassword(string testPassword)
        {
            Boolean returnStatus = false;

            DbConnection conn = new SqlConnection(GlobalSettings.connectionString);
            try
            {
                conn.Open();

                DbCommand cmd = conn.CreateCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "spSelectUserPassword";
                DbParameter param = cmd.CreateParameter();
                param.ParameterName = "@UserID";
                param.Value = m_userID;
                cmd.Parameters.Add(param);
                DbDataReader rdr = cmd.ExecuteReader();
                if (rdr.HasRows != false)
                {
                    string userPassword;

                    rdr.Read();
                    userPassword = (string)rdr["UserPassword"];
                    rdr.Close();

                    PasswordEncrypt pe = new PasswordEncrypt();
                    string encryptedTestPassword = pe.EncryptPassword(testPassword);

                    // note that passwords are case sensitive
                    if (userPassword == encryptedTestPassword)
                    {
                        returnStatus = true;
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorLog errorLog = new ErrorLog();
                errorLog.WriteLog("SedogoUser", "VerifyPassword", ex.Message, logMessageLevel.errorMessage);
                throw ex;
            }
            finally
            {
                conn.Close();
            }

            return returnStatus;
        }
示例#26
0
        //===============================================================
        // Function: Update
        //===============================================================
        public void Update()
        {
            SqlConnection conn = new SqlConnection(GlobalSettings.connectionString);
            try
            {
                conn.Open();

                SqlCommand cmd = new SqlCommand("spUpdateEventInvite", conn);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.Add("@EventInviteID", SqlDbType.Int).Value = m_eventInviteID;
                cmd.Parameters.Add("@EmailAddress", SqlDbType.NVarChar, 200).Value = m_emailAddress;
                if (m_userID > 0)
                {
                    cmd.Parameters.Add("@UserID", SqlDbType.Int).Value = m_userID;
                }
                else
                {
                    cmd.Parameters.Add("@UserID", SqlDbType.Int).Value = DBNull.Value;
                }
                cmd.Parameters.Add("@InviteAdditionalText", SqlDbType.NVarChar, -1).Value = m_inviteAdditionalText;
                cmd.Parameters.Add("@InviteEmailSent", SqlDbType.Bit).Value = m_inviteEmailSent;
                cmd.Parameters.Add("@InviteEmailSentEmailAddress", SqlDbType.NVarChar, 200).Value = m_inviteEmailSentEmailAddress;
                if (m_inviteEmailSentDate > DateTime.MinValue)
                {
                    cmd.Parameters.Add("@InviteEmailSentDate", SqlDbType.DateTime).Value = m_inviteEmailSentDate;
                }
                else
                {
                    cmd.Parameters.Add("@InviteEmailSentDate", SqlDbType.DateTime).Value = DBNull.Value;
                }
                cmd.Parameters.Add("@InviteAccepted", SqlDbType.Bit).Value = m_inviteAccepted;
                if (m_inviteAcceptedDate > DateTime.MinValue)
                {
                    cmd.Parameters.Add("@InviteAcceptedDate", SqlDbType.DateTime).Value = m_inviteAcceptedDate;
                }
                else
                {
                    cmd.Parameters.Add("@InviteAcceptedDate", SqlDbType.DateTime).Value = DBNull.Value;
                }
                cmd.Parameters.Add("@InviteDeclined", SqlDbType.Bit).Value = m_inviteDeclined;
                if (m_inviteDeclinedDate > DateTime.MinValue)
                {
                    cmd.Parameters.Add("@InviteDeclinedDate", SqlDbType.DateTime).Value = m_inviteDeclinedDate;
                }
                else
                {
                    cmd.Parameters.Add("@InviteDeclinedDate", SqlDbType.DateTime).Value = DBNull.Value;
                }
                cmd.Parameters.Add("@LastUpdatedDate", SqlDbType.DateTime).Value = DateTime.Now;
                cmd.Parameters.Add("@LastUpdatedByFullName", SqlDbType.NVarChar, 200).Value = m_loggedInUser;

                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                ErrorLog errorLog = new ErrorLog();
                errorLog.WriteLog("EventInvite", "Update", ex.Message, logMessageLevel.errorMessage);
                throw ex;
            }
            finally
            {
                conn.Close();
            }
        }
示例#27
0
        //===============================================================
        // Function: Add
        //===============================================================
        public void Add()
        {
            m_GUID = System.Guid.NewGuid().ToString();

            SqlConnection conn = new SqlConnection(GlobalSettings.connectionString);
            try
            {
                conn.Open();

                SqlCommand cmd = new SqlCommand("spAddUser", conn);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.Add("@GUID", SqlDbType.NVarChar, 50).Value = m_GUID;
                cmd.Parameters.Add("@EmailAddress", SqlDbType.NVarChar, 200).Value = m_emailAddress;
                cmd.Parameters.Add("@FirstName", SqlDbType.NVarChar, 200).Value = m_firstName;
                cmd.Parameters.Add("@LastName", SqlDbType.NVarChar, 200).Value = m_lastName;
                cmd.Parameters.Add("@HomeTown", SqlDbType.NVarChar, 200).Value = m_homeTown;
                if (m_birthday == DateTime.MinValue)
                {
                    cmd.Parameters.Add("@Birthday", SqlDbType.DateTime).Value = DBNull.Value;
                }
                else
                {
                    cmd.Parameters.Add("@Birthday", SqlDbType.DateTime).Value = m_birthday;
                }
                cmd.Parameters.Add("@Gender", SqlDbType.NChar, 1).Value = m_gender;
                cmd.Parameters.Add("@CountryID", SqlDbType.Int).Value = m_countryID;
                cmd.Parameters.Add("@LanguageID", SqlDbType.Int).Value = m_languageID;
                cmd.Parameters.Add("@TimezoneID", SqlDbType.Int).Value = m_timezoneID;
                cmd.Parameters.Add("@AvatarNumber", SqlDbType.Int).Value = m_avatarNumber;
                cmd.Parameters.Add("@ProfileText", SqlDbType.NVarChar, 200).Value = m_profileText;
                cmd.Parameters.Add("@CreatedDate", SqlDbType.DateTime).Value = DateTime.Now;
                cmd.Parameters.Add("@CreatedByFullName", SqlDbType.NVarChar, 200).Value = m_loggedInUser;
                cmd.Parameters.Add("@LastUpdatedDate", SqlDbType.DateTime).Value = DateTime.Now;
                cmd.Parameters.Add("@LastUpdatedByFullName", SqlDbType.NVarChar, 200).Value = m_loggedInUser;
                cmd.Parameters.Add("@FacebookUserID", SqlDbType.BigInt).Value = (m_facebookUserID == -1 ? (object)DBNull.Value : (object)m_facebookUserID);

                SqlParameter paramUserID = cmd.CreateParameter();
                paramUserID.ParameterName = "@UserID";
                paramUserID.SqlDbType = SqlDbType.Int;
                paramUserID.Direction = ParameterDirection.Output;
                cmd.Parameters.Add(paramUserID);

                cmd.ExecuteNonQuery();
                m_userID = (int)paramUserID.Value;

                //ReadUserDetails();
            }
            catch (Exception ex)
            {
                ErrorLog errorLog = new ErrorLog();
                errorLog.WriteLog("SedogoUser", "Add", ex.Message, logMessageLevel.errorMessage);
                throw ex;
            }
            finally
            {
                conn.Close();
            }
        }
示例#28
0
        //===============================================================
        // Function: Add
        //===============================================================
        public void Add()
        {
            SqlConnection conn = new SqlConnection(GlobalSettings.connectionString);
            try
            {
                conn.Open();

                SqlCommand cmd = new SqlCommand("spAddSentEmailHistory", conn);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.Add("@SentFrom", SqlDbType.NVarChar, 200).Value = m_sentFrom;
                cmd.Parameters.Add("@SentTo", SqlDbType.NVarChar, 200).Value = m_sentTo;
                cmd.Parameters.Add("@Subject", SqlDbType.NVarChar, 200).Value = m_subject;
                cmd.Parameters.Add("@Body", SqlDbType.NVarChar, -1).Value = m_body;
                cmd.Parameters.Add("@SentDate", SqlDbType.DateTime).Value = DateTime.Now;
                cmd.Parameters.Add("@LoggedInUserName", SqlDbType.NVarChar, 200).Value = m_loggedInUser;

                SqlParameter paramSentEmailHistoryID = cmd.CreateParameter();
                paramSentEmailHistoryID.ParameterName = "@SentEmailHistoryID";
                paramSentEmailHistoryID.SqlDbType = SqlDbType.Int;
                paramSentEmailHistoryID.Direction = ParameterDirection.Output;
                cmd.Parameters.Add(paramSentEmailHistoryID);

                cmd.ExecuteNonQuery();
                m_sentEmailHistoryID = (int)paramSentEmailHistoryID.Value;
            }
            catch (Exception ex)
            {
                ErrorLog errorLog = new ErrorLog();
                errorLog.WriteLog("SentEmailHistory", "Add", ex.Message, logMessageLevel.errorMessage);
                throw ex;
            }
            finally
            {
                conn.Close();
            }
        }
示例#29
0
        //===============================================================
        // Function: ReadUserDetailsByFacebookID
        //===============================================================
        public bool ReadUserDetailsByFacebookUserID(long facebookUserId)
        {
            DbConnection conn = new SqlConnection(GlobalSettings.connectionString);
            try
            {
                conn.Open();

                DbCommand cmd = conn.CreateCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "spSelectUserDetailsByFacebookID";
                DbParameter param = cmd.CreateParameter();
                param.ParameterName = "@FacebookUserID";
                param.Value = facebookUserId;
                cmd.Parameters.Add(param);
                DbDataReader rdr = cmd.ExecuteReader();
                if (!rdr.HasRows)
                    return false;
                rdr.Read();
                if (!rdr.IsDBNull(rdr.GetOrdinal("UserID")))
                {
                    m_userID = int.Parse(rdr["UserID"].ToString());
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("GUID")))
                {
                    m_GUID = rdr["GUID"].ToString();
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("EmailAddress")))
                {
                    m_emailAddress = (string)rdr["EmailAddress"];
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("FirstName")))
                {
                    m_firstName = (string)rdr["FirstName"];
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("LastName")))
                {
                    m_lastName = (string)rdr["LastName"];
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("HomeTown")))
                {
                    m_homeTown = (string)rdr["HomeTown"];
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("Birthday")))
                {
                    m_birthday = (DateTime)rdr["Birthday"];
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("ProfilePicFilename")))
                {
                    m_profilePicFilename = (string)rdr["ProfilePicFilename"];
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("ProfilePicThumbnail")))
                {
                    m_profilePicThumbnail = (string)rdr["ProfilePicThumbnail"];
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("ProfilePicPreview")))
                {
                    m_profilePicPreview = (string)rdr["ProfilePicPreview"];
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("AvatarNumber")))
                {
                    m_avatarNumber = int.Parse(rdr["AvatarNumber"].ToString());
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("Gender")))
                {
                    m_gender = (string)rdr["Gender"];
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("Deleted")))
                {
                    m_deleted = (Boolean)rdr["Deleted"];
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("DeletedDate")))
                {
                    m_deletedDate = (DateTime)rdr["DeletedDate"];
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("CountryID")))
                {
                    m_countryID = int.Parse(rdr["CountryID"].ToString());
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("LanguageID")))
                {
                    m_languageID = int.Parse(rdr["LanguageID"].ToString());
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("TimezoneID")))
                {
                    m_timezoneID = int.Parse(rdr["TimezoneID"].ToString());
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("ProfileText")))
                {
                    m_profileText = (string)rdr["ProfileText"];
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("LoginEnabled")))
                {
                    m_loginEnabled = (Boolean)rdr["LoginEnabled"];
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("EnableSendEmails")))
                {
                    m_enableSendEmails = (Boolean)rdr["EnableSendEmails"];
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("UserPassword")))
                {
                    m_userPassword = (string)rdr["UserPassword"];
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("FailedLoginCount")))
                {
                    m_failedLoginCount = int.Parse(rdr["FailedLoginCount"].ToString());
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("PasswordExpiryDate")))
                {
                    m_passwordExpiryDate = (DateTime)rdr["PasswordExpiryDate"];
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("LastLoginDate")))
                {
                    m_lastLoginDate = (DateTime)rdr["LastLoginDate"];
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("CreatedDate")))
                {
                    m_createdDate = (DateTime)rdr["CreatedDate"];
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("CreatedByFullName")))
                {
                    m_createdByFullName = (string)rdr["CreatedByFullName"];
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("LastUpdatedDate")))
                {
                    m_lastUpdatedDate = (DateTime)rdr["LastUpdatedDate"];
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("LastUpdatedByFullName")))
                {
                    m_lastUpdatedByFullName = (string)rdr["LastUpdatedByFullName"];
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("FacebookUserID")))
                {
                    m_facebookUserID = long.Parse(rdr["FacebookUserID"].ToString());
                }
                if (!rdr.IsDBNull(rdr.GetOrdinal("FirstLogin")))
                {
                    m_firstLogin = (Boolean)rdr["FirstLogin"];
                }
                rdr.Close();
            }
            catch (Exception ex)
            {
                ErrorLog errorLog = new ErrorLog();
                errorLog.WriteLog("SedogoUser", "ReadUserDetailsByFacebookUserID", ex.Message, logMessageLevel.errorMessage);
                throw ex;
            }
            finally
            {
                conn.Close();
            }
            return true;
        }
示例#30
0
        //===============================================================
        // Function: ReadCountryDetails
        //===============================================================
        public void ReadCountryDetails()
        {
            DbConnection conn = new SqlConnection(GlobalSettings.connectionString);
            try
            {
                conn.Open();

                DbCommand cmdCountryDetails = conn.CreateCommand();
                cmdCountryDetails.CommandType = CommandType.StoredProcedure;
                cmdCountryDetails.CommandText = "spSelectCountryDetails";
                DbParameter param = cmdCountryDetails.CreateParameter();
                param.ParameterName = "@CountryID";
                param.Value = m_countryID;
                cmdCountryDetails.Parameters.Add(param);
                DbDataReader rdrCountryDetails = cmdCountryDetails.ExecuteReader();
                rdrCountryDetails.Read();
                if (!rdrCountryDetails.IsDBNull(rdrCountryDetails.GetOrdinal("CountryCode")))
                {
                    m_countryCode = (string)rdrCountryDetails["CountryCode"];
                }
                if (!rdrCountryDetails.IsDBNull(rdrCountryDetails.GetOrdinal("CountryName")))
                {
                    m_countryName = (string)rdrCountryDetails["CountryName"];
                }
                if (!rdrCountryDetails.IsDBNull(rdrCountryDetails.GetOrdinal("DefaultCountry")))
                {
                    m_defaultCountry = (Boolean)rdrCountryDetails["DefaultCountry"];
                }
                rdrCountryDetails.Close();
            }
            catch (Exception ex)
            {
                ErrorLog errorLog = new ErrorLog();
                errorLog.WriteLog("Country", "ReadCountryDetails", ex.Message, logMessageLevel.errorMessage);
                throw ex;
            }
            finally
            {
                conn.Close();
            }
        }