Esempio n. 1
0
        //protected override void InitializeCulture()
        //{

        //    if (HttpContext.Current.Request.Cookies["CultureCookie"] != null)
        //    {
        //        if (HttpContext.Current.Request.Cookies["CultureCookie"]["UICulture"] != null &&
        //            HttpContext.Current.Request.Cookies["CultureCookie"]["Culture"] != null)
        //        {
        //            Thread.CurrentThread.CurrentCulture =
        //                new CultureInfo(HttpContext.Current.Request.Cookies["CultureCookie"]["Culture"]);
        //            Thread.CurrentThread.CurrentUICulture =
        //                new CultureInfo(HttpContext.Current.Request.Cookies["CultureCookie"]["UICulture"]);
        //        }
        //        else
        //        {
        //            Utils.SetCulture("en-US", "en-US");
        //        }
        //    }
        //    else
        //    {
        //        Utils.SetCulture("en-US", "en-US");
        //    }

        //    base.InitializeCulture();
        //}

        public BaseControl()
        {

            currentUserInfo = new UserInfo(GetLogonUser());
            //if (currentUserInfo.UserId <= 0)
            //{
            //    HttpContext.Current.Response.Redirect("/default.aspx");
            //}
            LoginMemberId = currentUserInfo.UserId;
            //InitializeCulture();
        }
Esempio n. 2
0
        public static void GetAuthenticationTicket(UserInfo info, bool rememberMe,string CatId="",string CatName="")
        {
            System.Web.Security.FormsAuthentication.Initialize();
            StringBuilder builder = new StringBuilder(200);
            builder.Append(Encryption.Encrypt(Conversion.ParseString( info.UserId)));
            builder.Append("_!_");
            builder.Append(Encryption.Encrypt(Conversion.ParseString(info.FullName)));
            builder.Append("_!_");
            builder.Append(Encryption.Encrypt(Conversion.ParseString(info.RoleId)));
            builder.Append("_!_");
            builder.Append(Encryption.Encrypt(Conversion.ParseString(info.Login)));
            builder.Append("_!_");
            builder.Append(Encryption.Encrypt(Conversion.ParseString(info.UserRolesCommaSeprated)));
            builder.Append("_!_");
            builder.Append(Encryption.Encrypt(Conversion.ParseString(info.LastLoginDate)));
            builder.Append("_!_");
            builder.Append(Encryption.Encrypt(Conversion.ParseString(info.OrganizationId)));
            builder.Append("_!_");
            builder.Append(Encryption.Encrypt(Conversion.ParseString(info.UserOrganizationRoleId)));
            builder.Append("_!_");
            builder.Append(Encryption.Encrypt(Conversion.ParseString(info.UserGroupsCommaSeprated)));
            builder.Append("_!_");
            builder.Append(Encryption.Encrypt(Conversion.ParseString(info.UserOrganizationSubTypeId)));
            builder.Append("_!_");
            builder.Append(Encryption.Encrypt(Conversion.ParseString(CatName)));
            builder.Append("_!_");
            builder.Append(Encryption.Encrypt(Conversion.ParseString(CatId)));

            System.Web.Security.FormsAuthenticationTicket ticket = new System.Web.Security.FormsAuthenticationTicket(1, builder.ToString(), DateTime.Now, DateTime.Now.AddDays(5.0), rememberMe, "");
            string str = System.Web.Security.FormsAuthentication.Encrypt(ticket);
            System.Web.HttpCookie cookie = new System.Web.HttpCookie(System.Web.Security.FormsAuthentication.FormsCookieName, str);
            if (rememberMe)
            {
                cookie.Expires = ticket.Expiration;
            }
            cookie.Path = System.Web.Security.FormsAuthentication.FormsCookiePath;
            cookie.Domain = SiteCookie.DomainCookie;
            if (System.Web.HttpContext.Current.Request.Url.Host.ToLower().Equals(UserDomain))
            {
                cookie.Domain = UserDomain;
            }
            else if (System.Web.HttpContext.Current.Request.Url.Host.ToLower().Equals("stage." + UserDomain))
            {
                cookie.Domain = "stage." + UserDomain;
            }
            else
            {
                cookie.Domain = SiteCookie.DomainCookie;
            }
            System.Web.HttpContext.Current.Response.Cookies.Add(cookie);
            SiteCookie.Update("TireTraxRndm", Guid.NewGuid().ToString(), 0,5);
        }
Esempio n. 3
0
 public static UserInfo GetCurrentUserInfo()
 {
     UserInfo info = new UserInfo();
     if ((System.Web.HttpContext.Current.User.Identity.Name != null) && (System.Web.HttpContext.Current.User.Identity.Name.Length > 0))
     {
         info.GetUserFromCookie(System.Web.HttpContext.Current.User.Identity.Name);
     }
     return info;
 }
Esempio n. 4
0
 public static int InsertMemberonly(UserInfo User)
 {
     List<SqlParameter> prams = new List<SqlParameter>();
     try
     {
         using (DbManager db = DbManager.GetDbManager())
         {
             //prams.Add(db.MakeInParam("@login", SqlDbType.VarChar, 0, member.LoginId));
             //prams.Add(db.MakeInParam("@Password", SqlDbType.VarChar, 0, member.Password));
             //prams.Add(db.MakeInParam("@DateCreated", SqlDbType.DateTime, 0, member.DateCreated));
             //prams.Add(db.MakeInParam("@BitActive", SqlDbType.Bit, 0, member.IsActive));
             //prams.Add(db.MakeInParam("@intCreatedBy", SqlDbType.Int, 0, member.UserId));
             //prams.Add(db.MakeInParam("@intPositionId", SqlDbType.Int, 0, member.PositionId));
             //prams.Add(db.MakeInParam("@intResponsibilityId", SqlDbType.Int, 0, member.ResponsiblityId));
             //prams.Add(db.MakeInParam("@intIndustryId", SqlDbType.Int, 0, member.IndustryId));
             //prams.Add(db.MakeInParam("@BitIsConfirmterm", SqlDbType.Bit, 0, member.IsConfirmTerms));
             //prams.Add(db.MakeInParam("@bitIsProductUpdate", SqlDbType.Bit, 0, member.IsProductUpdates));
             //prams.Add(db.MakeInParam("@bitIsfeaturebyEmail", SqlDbType.Bit, 0, member.IsFeaturesByEmail));
             //prams.Add(db.MakeInParam("@bitIsfeaturebyPost", SqlDbType.Bit, 0, member.IsFeatureByPost));
             //prams.Add(db.MakeReturnParam(SqlDbType.Int, 0));
             //int exec = db.RunProc("UP_member_InsertUpdate", prams.ToArray());
             return Conversion.ParseDBNullInt(prams.Last<SqlParameter>().Value);
         }
     }
     catch (Exception ex)
     {
         new SqlLog().InsertSqlLog(0, "MemberInfo.InsertMember", ex);
     }
     return -1;
 }
Esempio n. 5
0
        public static UserInfo AuthenticateAdminMember(string login, string password)
        {
            UserInfo User = null;
            try
            {
                using (DbManager db = DbManager.GetDbManager())
                {
                    var prams = new SqlParameter[2];
                    prams[0] = db.MakeInParam("@login", SqlDbType.NVarChar, 150, login);
                    prams[1] = db.MakeInParam("@pasword", SqlDbType.NVarChar, 180, password);

                    using (IDataReader reader = db.GetDataReader("[up_authenticateAdminMember]", prams))
                    {
                        if (reader.Read())
                        {
                            User = new UserInfo();
                            User.UserId = reader["UserId"] == DBNull.Value ? 0 : Conversion.ParseDBNullInt(reader["UserId"]);
                            User.FirstName = Conversion.ParseDBNullString(reader["FirstName"]);
                            User.CrypID = reader["IsOrganization"] == DBNull.Value ? "" : Conversion.ParseDBNullString(reader["vchCrypId"]);
                            User.MiddleName = Conversion.ParseDBNullString(reader["MiddleName"]);
                            User.LastName = Conversion.ParseDBNullString(reader["LastName"]);
                            User.FullName = User.FirstName + User.MiddleName + User.LastName;
                            User.IsOrganization = reader["IsOrganization"] == DBNull.Value ? false : Conversion.ParseDBNullBool(reader["IsOrganization"]);
                            User.Login = Conversion.ParseDBNullString(reader["Login"]);
                            User.TX_UserId = Conversion.ParseDBNullString(reader["TX-UserId"]);
                            User.LastLoginDate = reader["LastLoginDate"] == DBNull.Value ? DateTime.MinValue : Convert.ToDateTime(reader["LastLoginDate"], System.Globalization.CultureInfo.InvariantCulture);
                            User.OrganizationId = reader["OrganizationId"] == DBNull.Value ? 0 : Conversion.ParseDBNullInt(reader["OrganizationId"]);
                            User.UserOrganizationRoleId = reader["OrganizationRoleID"] == DBNull.Value ? 0 : Conversion.ParseDBNullInt(reader["OrganizationRoleID"]);
                            User.GroupID = reader["intGroupID"] == DBNull.Value ? 0 : Conversion.ParseDBNullInt(reader["intGroupID"]);
                            User.UserRolesCommaSeprated = reader["UserRolesCommaSeprated"] == DBNull.Value ? "" : Conversion.ParseDBNullString(reader["UserRolesCommaSeprated"]);
                            User.UserGroupsCommaSeprated = reader["UserGroupsCommaSeprated"] == DBNull.Value ? "" : Conversion.ParseDBNullString(reader["UserGroupsCommaSeprated"]);
                            User.RoleId = reader["RoleId"] == DBNull.Value ? 0 : Conversion.ParseDBNullInt(reader["RoleId"]);
                            User.UserOrganizationSubTypeId = reader["OrganizationSubTypeID"] == DBNull.Value ? 0 : Conversion.ParseDBNullInt(reader["OrganizationSubTypeID"]);
                            
                            //User.UserId = reader["UserId"] == DBNull.Value ? 0 : Convert.ToInt32(reader["UserId"]);
                            //User.FirstName = reader["FirstName"].ToString();
                            //User.CrypID = reader["IsOrganization"] == DBNull.Value ? "" : Convert.ToString(reader["vchCrypId"]);
                            //User.MiddleName = reader["MiddleName"].ToString();
                            //User.LastName = reader["LastName"].ToString();
                            //User.FullName = User.FirstName + User.MiddleName + User.LastName;
                            //User.IsOrganization = reader["IsOrganization"] == DBNull.Value ? false : Conversion.ParseDBNullBool(reader["IsOrganization"]);
                            //User.Login = reader["Login"].ToString();
                            //User.TX_UserId = reader["TX-UserId"].ToString();
                            //User.LastLoginDate = reader["LastLoginDate"] == DBNull.Value ? DateTime.MinValue : Convert.ToDateTime(reader["LastLoginDate"], System.Globalization.CultureInfo.InvariantCulture);
                            //User.OrganizationId = 0;
                            //User.UserOrganizationRoleId = 0;
                        }

                        //if (User != null && reader.NextResult())
                        //{
                        //    User.UserRolesCommaSeprated = "";
                        //    while (reader.Read())
                        //    {
                        //        User.UserRolesCommaSeprated = User.UserRolesCommaSeprated + Convert.ToString(reader["RoleId"]) + ",";
                        //    }
                        //    User.UserRolesCommaSeprated = User.UserRolesCommaSeprated.TrimEnd(',');
                        //}

                        //if (User != null && reader.NextResult() && reader.Read())
                        //{
                        //    User.OrganizationId = reader["OrganizationId"] == DBNull.Value ? 0 : Convert.ToInt32(reader["OrganizationId"]);
                        //    User.UserOrganizationRoleId = reader["RoleId"] == DBNull.Value ? 0 : Convert.ToInt32(reader["RoleId"]);
                        //}

                        if (reader != null)
                            reader.Close();
                    }

                    if (User != null)
                    {
                        UpdateLastLoginDate(User.UserId);
                    }
                }
            }
            catch (Exception ex)
            {
                new SqlLog().InsertSqlLog(0, "UserInfo.AuthenticateAdminMember", ex);
                return null;
            }
            return User;
        }
Esempio n. 6
0
        public static UserInfo UserTopRole(int memberId)
        {
            UserInfo member = null;
            try
            {
                using (DbManager db = DbManager.GetDbManager())
                {
                    var prams = new SqlParameter[1];
                    prams[0] = db.MakeInParam("@intUserId", SqlDbType.Int, 0, memberId);


                    using (IDataReader reader = db.GetDataReader("up_UserTopRole", prams))
                    {
                        if (reader.Read())
                        {
                            member = new UserInfo();
                            member.UserId = reader["UserId"] == DBNull.Value ? 0 : Convert.ToInt32(reader["UserId"]);
                            member.FirstName = reader["FirstName"].ToString();
                            member.MiddleName = reader["MiddleName"].ToString();
                            member.LastName = reader["LastName"].ToString();
                            member.FullName = member.FirstName + " " + member.MiddleName + " " + member.LastName;
                            member.RoleId = reader["RoleId"] == DBNull.Value ? 0 : Convert.ToInt32(reader["RoleId"]);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                new SqlLog().InsertSqlLog(0, "UserInfo.UserTopRole", e);
                return null;
            }
            return member;
        }
Esempio n. 7
0
        public static bool UpdateUserProfile(UserInfo objUser)
        {
            bool UpdateSuccessfull = false;
            try
            {
                using (DbManager db = DbManager.GetDbManager())
                {
                    List<SqlParameter> prams = new List<SqlParameter>();
                    prams.Add(db.MakeInParam("@UserId", SqlDbType.Int, 4, objUser.UserId));
                    if (objUser.Pwd == "")
                        prams.Add(db.MakeInParam("@Password", SqlDbType.NVarChar, 90, DBNull.Value));
                    else
                        prams.Add(db.MakeInParam("@Password", SqlDbType.NVarChar, 90, objUser.Pwd));
                    prams.Add(db.MakeInParam("@FirstName", SqlDbType.NVarChar, 30, objUser.FirstName));
                    prams.Add(db.MakeInParam("@MiddleName", SqlDbType.NVarChar, 10, objUser.MiddleName));
                    prams.Add(db.MakeInParam("@LastName", SqlDbType.NVarChar, 30, objUser.LastName));
                    prams.Add(db.MakeInParam("@Number", SqlDbType.NVarChar, 15, objUser.Number));
                    prams.Add(db.MakeInParam("@Email", SqlDbType.NVarChar, 90, objUser.Email));
                    prams.Add(db.MakeInParam("@profileimage", SqlDbType.VarBinary, 5000, objUser.UserProfileImage));

                    db.RunProc("up_user_updateprofile", prams.ToArray());

                    UpdateSuccessfull = true;

                }
            }
            catch (Exception ex)
            {
                new SqlLog().InsertSqlLog(0, "UserInfo.UpdateUserProfile", ex);
            }

            return UpdateSuccessfull;
        }
Esempio n. 8
0
 public static bool UpdateUserInfo(UserInfo objUserInfo)
 {
     try
     {
         List<SqlParameter> List = new List<SqlParameter>();
         using (DbManager DB = DbManager.GetDbManager())
         {
             
             List.Add(DB.MakeInParam("@UserId", SqlDbType.Int, 4, objUserInfo.UserId));
             List.Add(DB.MakeInParam("@OrganizationId", SqlDbType.Int, 4, objUserInfo.OrganizationId));
             List.Add(DB.MakeInParam("@Login", SqlDbType.NVarChar, 75, objUserInfo.Login));
             List.Add(DB.MakeInParam("@Pwd", SqlDbType.NVarChar, 90, objUserInfo.Pwd));
             List.Add(DB.MakeInParam("@PwdSalt", SqlDbType.NVarChar, 90, objUserInfo.PwdSalt));
             List.Add(DB.MakeInParam("@IsActive", SqlDbType.Bit, 1, objUserInfo.IsActive));
             List.Add(DB.MakeInParam("@TX_UserId", SqlDbType.NVarChar, 20, objUserInfo.TX_UserId));
             List.Add(DB.MakeInParam("@LanguageId", SqlDbType.Int, 4, objUserInfo.LanguageId));
             List.Add(DB.MakeInParam("@TimeZoneID", SqlDbType.Int, 4, objUserInfo.TimeZoneID));
             List.Add(DB.MakeInParam("@ContactId", SqlDbType.Int, 4, objUserInfo.ContactId));
             List.Add(DB.MakeInParam("@IsApproved", SqlDbType.Bit, 1, objUserInfo.IsApproved));
             List.Add(DB.MakeInParam("@RoleId", SqlDbType.Int, 4, objUserInfo.RoleId));
             List.Add(DB.MakeInParam("@bitIsOrgAdmin", SqlDbType.Bit, 1, objUserInfo.IsOrgAdmin));
             List.Add(DB.MakeInParam("@DateCreated", SqlDbType.DateTime, 0, objUserInfo.DateCreated));
             List.Add(DB.MakeInParam("@bitIsSetPassword", SqlDbType.Bit, 1, objUserInfo.bitSetPassword));
             objUserInfo.UserId = DB.RunProc("up_UpdateUserInfo", List.ToArray());
             return true;
         }
     }
     catch (Exception ex)
     {
         new SqlLog().InsertSqlLog(0, "UserInfo.UpdateUserInfo", ex);
         return false;
     }
 }
Esempio n. 9
0
        public static int InsertUser(UserInfo objUser, int OrganizationId, string RoleIDs,Boolean bitIsSuperAdmin=false)
        {
            int userId = 0;
            List<SqlParameter> prams = new List<SqlParameter>();
            try
            {
                using (DbManager db = DbManager.GetDbManager())
                {
                    prams.Add(db.MakeInParam("@OrganizationId", SqlDbType.Int, 4, OrganizationId));
                    prams.Add(db.MakeInParam("@Login", SqlDbType.NVarChar, 75, objUser.Login));
                    prams.Add(db.MakeInParam("@Password", SqlDbType.NVarChar, 90, objUser.Pwd));
                    prams.Add(db.MakeInParam("@DateCreated", SqlDbType.DateTime, 8, objUser.DateCreated));
                    prams.Add(db.MakeInParam("@CreatedByUserId", SqlDbType.Int, 4, objUser.CreatedByUserId));
                    prams.Add(db.MakeInParam("@FirstName", SqlDbType.NVarChar, 30, objUser.FirstName));
                    prams.Add(db.MakeInParam("@MiddleName", SqlDbType.NVarChar, 10, objUser.MiddleName));
                    prams.Add(db.MakeInParam("@LastName", SqlDbType.NVarChar, 30, objUser.LastName));
                    prams.Add(db.MakeInParam("@Number", SqlDbType.NVarChar, 15, objUser.Number));
                    prams.Add(db.MakeInParam("@Email", SqlDbType.NVarChar, 90, objUser.Email));
                    prams.Add(db.MakeInParam("@LanguageId", SqlDbType.Int, 4, objUser.LanguageId));
                    prams.Add(db.MakeInParam("@IsApproved", SqlDbType.Bit, 1, objUser.IsApproved));
                    prams.Add(db.MakeInParam("@RoleIDs", SqlDbType.NVarChar, -1, RoleIDs));
                    prams.Add(db.MakeInParam("@bitIsSuperAdmin", SqlDbType.Bit, 1, bitIsSuperAdmin));
                   
                    objUser.UserId = db.RunProc("up_Users_Insert", prams.ToArray());
                    userId = objUser.UserId;
                    
                }
            }
            catch (Exception ex)
            {
                new SqlLog().InsertSqlLog(0, "UserInfo.up_Users_Insert", ex);
            }

            return userId;
        }
Esempio n. 10
0
        public static UserInfo GetMemberInfo(string login)
        {
            UserInfo member = null;
            try
            {
                using (DbManager db = DbManager.GetDbManager())
                {
                    var prams = new SqlParameter[1];
                    prams[0] = db.MakeInParam("@vchLogin", SqlDbType.VarChar, 0, login);

                    using (IDataReader reader = db.GetDataReader("up_Member_getByName", prams))
                    {
                        if (reader.Read())
                        {

                            member = new UserInfo();
                            //member.Gender = Conversion.ParseDBNullInt(reader["bitGender"]);
                            //member.Pwd = Conversion.ParseDBNullstring(reader["vchPassword"]);
                            //member.FullName = Conversion.ParseDBNullstring(reader["FullName"]);
                            //member.IsActive = Conversion.ParseDBNullBool(reader["BitActive"]);
                            //member.Email = Conversion.ParseDBNullstring(reader["vchEmail"]);
                            //member.City = Conversion.ParseDBNullstring(reader["vchCity"]);
                            //member.StateName = Conversion.ParseDBNullstring(reader["StateName"]);
                            //member.StateId = Conversion.ParseDBNullInt(reader["intStateId"]);
                            //member.ZipCode = Conversion.ParseDBNullstring(reader["vchZipCode"]);
                            //member.CountryID = Conversion.ParseDBNullInt(reader["CountryID"]);
                            //member.CountyId = Conversion.ParseDBNullInt(reader["CountyID"]);
                            //member.AddressTypeId = Conversion.ParseDBNullInt(reader["AddressTypeID"]);
                            //member.DateOfBirth = Conversion.ParseDBNullDateTime(reader["dtmDateofBirth"]);
                            //member.HomeAddress = Conversion.ParseDBNullstring(reader["vchHomeAddress"]);
                            //member.fltLat = Conversion.ParseDBNullDouble(reader["fltLat"]);
                            //member.fltLng = Conversion.ParseDBNullDouble(reader["fltLng"]);
                            //member.Phone = Conversion.ParseDBNullstring(reader["vchPhone"]);
                            //member.MobilePhone = Conversion.ParseDBNullstring(reader["vchMobilePhone"]);
                            //member.BusinessAddress = Conversion.ParseDBNullstring(reader["vchBusinessAddress"]);
                            //member.IsActive = Conversion.ParseDBNullBool(reader["bitactive"]);
                            //member.DateCreated = Conversion.ParseDBNullDateTime(reader["dtmDateCreated"]);
                            //member.DateLastModified = Conversion.ParseDBNullDateTime(reader["dtmDateLastModified"]);
                            //member.LastModifiedBy = Conversion.ParseDBNullInt(reader["intLastModifiedBy"]);
                            //member.IsAdmin = Conversion.ParseDBNullBool(reader["isadmin"]);
                        }
                        if (reader != null)
                            reader.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                new SqlLog().InsertSqlLog(0, "MemberInfo.GetMemberInfo", ex);
                return null;
            }
            return member;
        }