Пример #1
1
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Request[WebConstants.Request.USER_UID] != null && Request[WebConstants.Request.VERIFICATION_CODE] != null)
     {
         SimplicityCommLib.DataSets.Common.Users.UsersRow user = DatabaseUtility.Instance.GetUserByUID(Request[WebConstants.Request.USER_UID]);
         if (user != null)
         {
             string verificationCode = Utility.GetMd5Sum(user.VerificationCode);
             if (verificationCode.Equals(Request[WebConstants.Request.VERIFICATION_CODE]))
             {
                 SimplicityCommLib.DataSets.Common.UsersTableAdapters.UsersTableAdapter userTA = new SimplicityCommLib.DataSets.Common.UsersTableAdapters.UsersTableAdapter();
                 userTA.VerifyUser(user.UserId);
                 SetInfoMessage(WebConstants.Messages.Information.ACCOUNT_VERIFIED);
             }
             else
             {
                 SetErrorMessage(WebConstants.Messages.Error.CANNOT_VERIFY);
             }
         }
         else
         {
             SetErrorMessage(WebConstants.Messages.Error.CANNOT_VERIFY);
         }
     }
     else
     {
         SetErrorMessage(WebConstants.Messages.Error.CANNOT_VERIFY);
     }
 }
 protected void btnContinue_Click(object sender, ImageClickEventArgs e)
 {
     //mjaved.sim.CommonLib Verifying Answer and updating password
     SimplicityCommLib.DataSets.Common.Users.UsersRow user = DatabaseUtility.Instance.GetUserByEmail(txtEmail.Text);
     if (user != null)
     {
         if (user.ReminderQuestionId == byte.Parse(listForgotPasswordQuestion.SelectedValue)
             && user.ReminderQuestionAnswer.Equals(Utility.GetMd5Sum(txtForgotPasswordAnswer.Text)))
         {
             string password = Utility.RandomString(8, true);
             SimplicityCommLib.DataSets.Common.UsersTableAdapters.UsersTableAdapter userTA = new SimplicityCommLib.DataSets.Common.UsersTableAdapters.UsersTableAdapter();
             userTA.UpdatePassword(Utility.GetMd5Sum(password), user.UserId, user.UserId);
             EmailUtility.SendPasswordEmail(user.Email, password);
             Response.Redirect("~/pages/Login.aspx?" + WebConstants.Request.FROM_PAGE + "=ForgotPassword");
         }
         else
         {
             SetErrorMessage();
         }
     }
     else
     {
         SetErrorMessage();
     }
 }
 public SimplicityCommLib.DataSets.Common.Users.UsersRow GetUserByUID(string uid)
 {
     SimplicityCommLib.DataSets.Common.UsersTableAdapters.UsersTableAdapter userTA = new SimplicityCommLib.DataSets.Common.UsersTableAdapters.UsersTableAdapter();
     IEnumerator<SimplicityCommLib.DataSets.Common.Users.UsersRow> ieUsers = userTA.GetUserByUID(uid).GetEnumerator();
     if (ieUsers.MoveNext())
     {
         return ieUsers.Current;
     }
     return null;
 }
Пример #4
0
    protected void imgBtnLogin_Click(object sender, ImageClickEventArgs e)
    {
        //mjaved.sim.CommonLib Verifying User and creat its cookie

        SimplicityCommLib.DataSets.Common.UsersTableAdapters.UsersTableAdapter userTA = new SimplicityCommLib.DataSets.Common.UsersTableAdapters.UsersTableAdapter();
        IEnumerator<SimplicityCommLib.DataSets.Common.Users.UsersRow> ieUser = userTA.GetUserByEmail(txtEmail.Text).GetEnumerator();
        if (ieUser.MoveNext())
        {
            if (ieUser.Current.Password.Equals(Utility.GetMd5Sum(txtPassword.Text)) && ieUser.Current.FlgVerified)
            {
                // Cookie Implementation
                HttpCookie Cookie = new HttpCookie(WebConstants.Cookies.UserLoginSession);
                Cookie.Value = System.Guid.NewGuid().ToString();
                Cookie.Expires = DateTime.Now.AddMinutes(Constants.Configuration.SessionTimeoutInMinutes);
                Response.Cookies.Add(Cookie);

                SimplicityCommLib.DataSets.Common.SessionsTableAdapters.SessionsTableAdapter sessionTA = new SimplicityCommLib.DataSets.Common.SessionsTableAdapters.SessionsTableAdapter();
                sessionTA.Insert(System.Guid.NewGuid().ToString(), ieUser.Current.UserId, DateTime.Now, DateTime.Now.AddMinutes(Constants.Configuration.SessionTimeoutInMinutes), Request.UserHostAddress);

                //Cache.Insert("UserLoginSession", iEnumUser.Current.UserId, null, System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(20));

                if (Session[WebConstants.Session.RETURN_URL] != null)
                {
                    Response.Redirect((string)Session[WebConstants.Session.RETURN_URL]);
                }
                else
                {
                    Response.Redirect("~/pages/UserHome.aspx");
                }
            }
            else
            {
                SetErrorMessage();
            }
        }
        else
        {
            SetErrorMessage();
        }
    }
 public SimplicityCommLib.DataSets.Common.Users.UsersRow GetLoggedInCustomer()
 {
     if (HttpContext.Current.Request.Cookies[WebConstants.Cookies.UserLoginSession] != null)
     {
         string sessionId = HttpContext.Current.Request.Cookies[WebConstants.Cookies.UserLoginSession].Value;
         if (sessionId != null && sessionId.Length > 0)
         {
             SimplicityCommLib.DataSets.Common.SessionsTableAdapters.SessionsTableAdapter sessionTA = new SimplicityCommLib.DataSets.Common.SessionsTableAdapters.SessionsTableAdapter();
             IEnumerator<SimplicityCommLib.DataSets.Common.Sessions.SessionsRow> ieSession = sessionTA.GetSessionByUID(sessionId).GetEnumerator();
             if (ieSession.MoveNext())
             {
                 SimplicityCommLib.DataSets.Common.UsersTableAdapters.UsersTableAdapter userTA = new SimplicityCommLib.DataSets.Common.UsersTableAdapters.UsersTableAdapter();
                 IEnumerator<SimplicityCommLib.DataSets.Common.Users.UsersRow> ieUser = userTA.GetUserById(ieSession.Current.UserId).GetEnumerator();
                 if (ieUser.MoveNext())
                 {
                     return ieUser.Current;
                 }
             }
         }
     }
     return null;
 }
    protected void btnSave_Click(object sender, ImageClickEventArgs e)
    {
        if (ValidateFields())
        {
            try
            {
                //CustomerTableAdapters.CustomerTableAdapter customerTA = new CustomerTableAdapters.CustomerTableAdapter();
                //IEnumerator ieCustomer = customerTA.InsertAndReturn(false, false, false, 0, 0, GetFullName(), null, null, txtSurname.Text, txtFirstName.Text, txtJobTitle.Text, txtEmail.Text,
                //    Utility.GetMd5Sum(txtPassword.Text), byte.Parse(listForgotPasswordQuestion.SelectedValue), listForgotPasswordQuestion.SelectedItem.Text, Utility.GetMd5Sum(txtForgotPasswordAnswer.Text), null, false, false, 0,
                //    false, null, null, DateTime.Now, null, DateTime.Now, Enum.GetName(typeof(ShoppingTrolley.Web.utils.Enums.ENTITY_TYPE), ShoppingTrolley.Web.utils.Enums.ENTITY_TYPE.USER)).GetEnumerator();

                //mjaved.sim.CommonLib Insert User
                /*CommLibController userOBJ = new CommLibController();
                IEnumerator<UserInsertResult> ieUser = userOBJ.InsertAndReturnUser(cbEmails.Selected, false, false, 0, 0, GetFullName(), null, null, txtSurname.Text, txtFirstName.Text, txtJobTitle.Text, txtEmail.Text,
                    Utility.GetMd5Sum(txtPassword.Text), byte.Parse(listForgotPasswordQuestion.SelectedValue), listForgotPasswordQuestion.SelectedItem.Text, Utility.GetMd5Sum(txtForgotPasswordAnswer.Text), false, false, 0,
                    false, null, 0, DateTime.Now, 0, DateTime.Now, Enum.GetName(typeof(ShoppingTrolley.Web.utils.Enums.ENTITY_TYPE), ShoppingTrolley.Web.utils.Enums.ENTITY_TYPE.USER));*/

                SimplicityCommLib.DataSets.Common.UsersTableAdapters.UsersTableAdapter userTA = new SimplicityCommLib.DataSets.Common.UsersTableAdapters.UsersTableAdapter();
                IEnumerator<SimplicityCommLib.DataSets.Common.Users.UsersRow> ieUsers = userTA.InsertAndReturn(System.Guid.NewGuid().ToString(), System.Guid.NewGuid().ToString(), cbEmails.Selected, false, false, 0, null, GetFullName(), "",
                    GetInitials(), txtFirstName.Text, txtSurname.Text, txtJobTitle.Text, txtEmail.Text, txtPassword.Text, byte.Parse(listForgotPasswordQuestion.SelectedValue),
                    "", txtForgotPasswordAnswer.Text, false, false, 0, false, "", null, DateTime.Now, null, DateTime.Now, SimplicityCommLib.Constants.Roles.User).GetEnumerator();

                if (ieUsers.MoveNext())
                {

                    SimplicityCommLib.DataSets.Common.CompanyTableAdapters.CompanyTableAdapter companyTA = new SimplicityCommLib.DataSets.Common.CompanyTableAdapters.CompanyTableAdapter();
                    IEnumerator<SimplicityCommLib.DataSets.Common.Company.CompanyRow> ieCompany = companyTA.InsertAndReturn(false, txtCompanyName.Text, txtCompanyName.Text, txtJobTitle.Text, GetInitials(), txtFirstName.Text, txtSurname.Text,
                        "", false, ieUsers.Current.UserId, DateTime.Now, ieUsers.Current.UserId, DateTime.Now).GetEnumerator();

                    if (ieCompany.MoveNext())
                    {
                        SimplicityCommLib.DataSets.Common.DepartmentsTableAdapters.DepartmentsTableAdapter deptTA = new SimplicityCommLib.DataSets.Common.DepartmentsTableAdapters.DepartmentsTableAdapter();
                        IEnumerator<SimplicityCommLib.DataSets.Common.Departments.DepartmentsRow> ieDepts = deptTA.InsertAndReturn(ieCompany.Current.CompanyId, false, txtCompanyName.Text, txtCompanyName.Text, txtJobTitle.Text, GetInitials(), txtFirstName.Text, txtSurname.Text, "",
                            ieUsers.Current.UserId, DateTime.Now, ieUsers.Current.UserId, DateTime.Now).GetEnumerator();

                        if (ieDepts.MoveNext())
                        {
                            SimplicityCommLib.DataSets.Common.AddressTableAdapters.AddressTableAdapter addressTA = new SimplicityCommLib.DataSets.Common.AddressTableAdapters.AddressTableAdapter();
                            addressTA.Insert(false, SimplicityCommLib.Constants.AddressCategories.UserAddress, ieCompany.Current.CompanyId, false, false, Enum.GetName(typeof(ShoppingTrolley.Web.utils.Enums.ADDRESS_TYPE), ShoppingTrolley.Web.utils.Enums.ADDRESS_TYPE.PERSONAL), txtCompanyName.Text,
                                txtAddressNo.Text, txtAddressLine1.Text, txtAddressLine2.Text, txtAddressLine3.Text, txtAddressLine4.Text, txtAddressLine5.Text, txtPostCode.Text,
                                GetFullAddress(), txtTele1.Text, txtTele2.Text, txtFax.Text, txtMobile.Text, ieUsers.Current.UserId, DateTime.Now, ieUsers.Current.UserId, DateTime.Now,
                                txtTown.Text, txtCounty.Text, txtCounty.Text);

                            addressTA.Insert(false, SimplicityCommLib.Constants.AddressCategories.UserAddress, ieUsers.Current.UserId, false, false, Enum.GetName(typeof(ShoppingTrolley.Web.utils.Enums.ADDRESS_TYPE), ShoppingTrolley.Web.utils.Enums.ADDRESS_TYPE.PERSONAL), txtCompanyName.Text,
                                txtAddressNo.Text, txtAddressLine1.Text, txtAddressLine2.Text, txtAddressLine3.Text, txtAddressLine4.Text, txtAddressLine5.Text, txtPostCode.Text,
                                GetFullAddress(), txtTele1.Text, txtTele2.Text, txtFax.Text, txtMobile.Text, ieUsers.Current.UserId, DateTime.Now, ieUsers.Current.UserId, DateTime.Now,
                                txtTown.Text, txtCounty.Text, txtCounty.Text);

                            addressTA.Insert(false, SimplicityCommLib.Constants.AddressCategories.DepartmentAddress, ieDepts.Current.DepartmentId, false, false, Enum.GetName(typeof(ShoppingTrolley.Web.utils.Enums.ADDRESS_TYPE), ShoppingTrolley.Web.utils.Enums.ADDRESS_TYPE.PERSONAL), txtCompanyName.Text,
                                txtAddressNo.Text, txtAddressLine1.Text, txtAddressLine2.Text, txtAddressLine3.Text, txtAddressLine4.Text, txtAddressLine5.Text, txtPostCode.Text,
                                GetFullAddress(), txtTele1.Text, txtTele2.Text, txtFax.Text, txtMobile.Text, ieUsers.Current.UserId, DateTime.Now, ieUsers.Current.UserId, DateTime.Now,
                                txtTown.Text, txtCounty.Text, txtCounty.Text);

                            EmailUtility.SendAccountCreationEmail(txtEmail.Text, ieUsers.Current.UserUid, ieUsers.Current.VerificationCode);
                            Response.Redirect("~/pages/ConfirmMail.aspx");
                        }
                    }
                }
            }
            catch
            {
                SetErrorMessage("Unable to process your transaction, please contact the administrator");
            }
        }
    }
    private bool ValidateFields()
    {
        if (txtEmail.Text.ToLower().Equals(txtConfirmEmail.Text.ToLower()) == false)
        {
            SetErrorMessage("Email Addresses do not match");
            return false;
        }
        if (txtPassword.Text.Equals(txtConfirmPassword.Text) == false)
        {
            SetErrorMessage("Passwords do not match");
            return false;
        }

        //mjaved.sim.CommonLib Verifying Email Add
        SimplicityCommLib.DataSets.Common.UsersTableAdapters.UsersTableAdapter userTA = new SimplicityCommLib.DataSets.Common.UsersTableAdapters.UsersTableAdapter();
        if (userTA.GetUserByEmail(txtEmail.Text).GetEnumerator().MoveNext())
        {
            SetErrorMessage("Email address already resgistered with Simplicity");
            return false;
        }

        SimplicityCommLib.DataSets.Common.CompanyTableAdapters.CompanyTableAdapter coTA = new SimplicityCommLib.DataSets.Common.CompanyTableAdapters.CompanyTableAdapter();
        if (coTA.GetCompanyByName(txtCompanyName.Text).GetEnumerator().MoveNext())
        {
            SetErrorMessage("Company already registered with Simplicity");
            return false;
        }
        //We do not need this
        /*
        UserTableAdapters.un_co_user_detailsTableAdapter userTA = new UserTableAdapters.un_co_user_detailsTableAdapter();
        if (userTA.GetUserByLogonName(txtEmail.Text,null).GetEnumerator().MoveNext())
        {
            SetErrorMessage("Email address already resgistered with Health&Safety");
            return false;
        }
         */
        return true;
    }