示例#1
0
        public override bool ValidateUser(string name, string password)
        {
            try
            {
                DAL.Master.User oUser = new DL_WEB.DAL.Master.User();

                oUser.Where.Login.Operator = MyGeneration.dOOdads.WhereParameter.Operand.Equal;
                oUser.Where.Login.Value    = name;

                oUser.Where.Password.Operator = MyGeneration.dOOdads.WhereParameter.Operand.Equal;
                oUser.Where.Password.Value    = password;

                oUser.Query.Load();
                if (oUser.RowCount > 0)
                {
                    AuthorizedUser      = oUser;
                    oUser.LastLoginDate = DateTime.Now;
                    oUser.Save();
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception)
            {
                return(false);
            }
        }
示例#2
0
    private void LoadUser()
    {
        if (this.UserID > 0)
        {
            DL_WEB.DAL.Master.User oMasterUser = LoadMasterUserInfo();

            if (null == oMasterUser)
            {
                return;
            }

            DL_WEB.DAL.Client.User oClientUser = LoadClientUserInfo(oMasterUser.UserID, oMasterUser.GUID);

            if (null != oClientUser &&
                null != oClientUser.AddressBookEntry)
            {
                this.tbFirstName.Text  = oClientUser.AddressBookEntry.FirstName;
                this.tbLastName.Text   = oClientUser.AddressBookEntry.LastName;
                this.tbMiddleName.Text = oClientUser.AddressBookEntry.MiddleName;
                this.tbJobTitle.Text   = oClientUser.AddressBookEntry.JobTitle;
                this.tbHomePhone.Text  = oClientUser.AddressBookEntry.HomePhone;
                this.tbWorkPhone.Text  = oClientUser.AddressBookEntry.WorkPhone;
            }
        }
    }
示例#3
0
        public override MembershipUser GetUser(string name, bool userIsOnline)
        {
            DAL.Master.User oUser = new DL_WEB.DAL.Master.User();

            oUser.Where.Login.Operator = MyGeneration.dOOdads.WhereParameter.Operand.Equal;
            oUser.Where.Login.Value    = name;

            oUser.Query.Load();

            return(new MembershipUser(this.Name, oUser.Login, oUser.UserID, oUser.Email, oUser.PasswordQuestion, string.Empty, oUser.IsApproved, oUser.IsLockedOut, oUser.CreationDate,
                                      (oUser.IsColumnNull(DL_WEB.DAL.Master.User.ColumnNames.LastLoginDate) ? new DateTime() : oUser.LastLoginDate),
                                      (oUser.IsColumnNull(DL_WEB.DAL.Master.User.ColumnNames.LastActivityDate) ? new DateTime() : oUser.LastActivityDate),
                                      (oUser.IsColumnNull(DL_WEB.DAL.Master.User.ColumnNames.LastPasswordChangedDate) ? new DateTime() : oUser.LastPasswordChangedDate),
                                      (oUser.IsColumnNull(DL_WEB.DAL.Master.User.ColumnNames.LastLockoutDate) ? new DateTime() : oUser.LastLockoutDate)));
        }
示例#4
0
    private DL_WEB.DAL.Client.User FillClientUser(DL_WEB.DAL.Master.User oMasterUser)
    {
        DL_WEB.DAL.Client.User oClientUser = new DL_WEB.DAL.Client.User();

        if (0 != UserID)
        {
            oClientUser.Where.GUID.Value = oMasterUser.GUID;
            oClientUser.Query.Load();
        }

        if (oClientUser.RowCount == 0)
        {
            oClientUser.AddNew();
        }

        oClientUser.Login            = oMasterUser.Email;
        oClientUser.Password         = oMasterUser.Password;
        oClientUser.PasswordQuestion = oMasterUser.PasswordQuestion;
        oClientUser.PasswordAnswer   = oMasterUser.PasswordAnswer;
        oClientUser.IsApproved       = oMasterUser.IsApproved;
        oClientUser.IsLockedOut      = oMasterUser.IsLockedOut;
        oClientUser.CreationDate     = oMasterUser.CreationDate;
        oClientUser.GUID             = oMasterUser.GUID;

        DL_WEB.DAL.Client.AddressBook oAddressBook = oClientUser.AddressBookEntry;
        if (null == oAddressBook)
        {
            oAddressBook = new DL_WEB.DAL.Client.AddressBook();
            oAddressBook.AddNew();
        }

        oAddressBook.FirstName    = this.tbFirstName.Text;
        oAddressBook.LastName     = this.tbLastName.Text;
        oAddressBook.PrimaryEmail = oMasterUser.Email;
        oAddressBook.MiddleName   = this.tbMiddleName.Text;
        oAddressBook.JobTitle     = this.tbJobTitle.Text;
        oAddressBook.HomePhone    = this.tbHomePhone.Text;
        oAddressBook.WorkPhone    = this.tbWorkPhone.Text;

        oClientUser.AddressBookEntry = oAddressBook;

        return(oClientUser);
    }
示例#5
0
    private void StoreUserInfo()
    {
        DL_WEB.DAL.Master.User oMasterUser = new DL_WEB.DAL.Master.User();

        if (0 != UserID)
        {
            oMasterUser.LoadByPrimaryKey(UserID);

            if (0 != oMasterUser.RowCount)
            {
                oMasterUser.IsInactive = cbIsInactive.Checked;
                oMasterUser.IsApproved = cbIsApproved.Checked;
                oMasterUser.Login      = tbLogin.Text;
                oMasterUser.Email      = tbLogin.Text;
            }
        }
        else
        {
            oMasterUser.AddNew();
            oMasterUser.IsInactive       = cbIsInactive.Checked;
            oMasterUser.IsApproved       = cbIsApproved.Checked;
            oMasterUser.Login            = tbLogin.Text;
            oMasterUser.Email            = tbLogin.Text;
            oMasterUser.GUID             = Guid.NewGuid();
            oMasterUser.Password         = oMasterUser.GUID.ToString();
            oMasterUser.PasswordQuestion = "?";
            oMasterUser.IsLockedOut      = false;
            oMasterUser.CreationDate     = DateTime.Now;
        }

        Session["MasterUser"] = oMasterUser;

        DL_WEB.DAL.Client.User oClientUser = FillClientUser(oMasterUser);

        Session.Add("ClientUser", oClientUser);
    }
示例#6
0
    private DL_WEB.DAL.Master.User LoadMasterUserInfo()
    {
        DL_WEB.DAL.Master.User oMasterUser = null;
        if (null != Session["MasterUser"])
        {
            oMasterUser = Session["MasterUser"] as DL_WEB.DAL.Master.User;
        }
        else
        {
            oMasterUser = new DL_WEB.DAL.Master.User();
            oMasterUser.LoadByPrimaryKey(UserID);

            if (oMasterUser.RowCount == 0)
            {
                return(null);
            }
        }

        this.tbLogin.Text         = oMasterUser.Login;
        this.cbIsApproved.Checked = oMasterUser.IsApproved;

        if (this.UserID > 0)
        {
            if (!oMasterUser.IsColumnNull(DL_WEB.DAL.Master.User.ColumnNames.IsInactive))
            {
                this.cbIsInactive.Checked = oMasterUser.IsInactive;
            }
        }
        else
        {
            cbIsInactive.Checked = true;
            cbIsInactive.Enabled = false;
        }

        return(oMasterUser);
    }
示例#7
0
        public override MembershipUser CreateUser(string username,
                                                  string password,
                                                  string email,
                                                  string passwordQuestion,
                                                  string passwordAnswer,
                                                  bool isApproved,
                                                  object providerUserKey,
                                                  out MembershipCreateStatus status)
        {
            try
            {
                #region Checking if user with specified username exists

                DAL.Master.User oUser = new DL_WEB.DAL.Master.User();
                BusinessEntity.PushStaticConnectionString();

                //oUser.ConnectionString = ConfigurationManager.AppSettings[MyGeneration.dOOdads.BusinessEntity.DefaultConnectionStringConfig];
                oUser.Where.Login.Value = username;
                oUser.Query.Load();

                #endregion

                if (oUser.RowCount > 0)
                {
                    status = MembershipCreateStatus.DuplicateUserName;
                    return(null);
                }
                else
                {
                    oUser = new DL_WEB.DAL.Master.User();
                    oUser.AddNew();
                    oUser.Login            = email;
                    oUser.Password         = password;
                    oUser.Email            = email;
                    oUser.PasswordQuestion = null == passwordQuestion ? "?" : passwordQuestion;
                    oUser.PasswordAnswer   = null == passwordAnswer ? string.Empty : passwordAnswer;
                    oUser.IsApproved       = false;
                    oUser.IsLockedOut      = false;
                    oUser.GUID             = Guid.NewGuid();
                    oUser.CreationDate     = DateTime.Now;

                    oUser.Save();
                    status = MembershipCreateStatus.Success;
                    return(new MembershipUser(this.Name, oUser.Login, oUser.UserID, oUser.Email, oUser.PasswordQuestion, string.Empty, oUser.IsApproved, oUser.IsLockedOut, oUser.CreationDate, oUser.LastLoginDate, oUser.LastActivityDate, oUser.LastPasswordChangedDate, oUser.LastLockoutDate));
                }
            }
            catch (SqlException ex)
            {
                if (ex.Number == 2627) // unique key constraints
                {
                    status = MembershipCreateStatus.DuplicateEmail;
                }
                else
                {
                    status = MembershipCreateStatus.ProviderError;
                }
                return(null);
            }
            catch (Exception ex)
            {
                status = MembershipCreateStatus.ProviderError;
                return(null);
            }
            finally
            {
                BusinessEntity.PopStaticConnectionString();
            }
        }
示例#8
0
        public override bool ChangePassword(string name, string oldPassword, string newPassword)
        {
            try
            {
                if (newPassword.Length < MinRequiredPasswordLength)
                {
                    return(false);
                }

                int  UserID   = DL_WEB.DAL.Master.User.GetUserID(name);
                Guid UserGuid = DL_WEB.DAL.Master.User.GetUserGUID(name);

                DL_WEB.DAL.Master.User oMasterUser = new DL_WEB.DAL.Master.User();
                oMasterUser = new DL_WEB.DAL.Master.User();
                oMasterUser.LoadByPrimaryKey(UserID);

                if (oldPassword != null && oldPassword != oMasterUser.Password)
                {
                    return(false);
                }

                oMasterUser.Password = newPassword;
                oMasterUser.Save();

                UserRole oUserRoles = new DL_WEB.DAL.Master.UserRole();
                oUserRoles.Where.UserID.Value = UserID;
                oUserRoles.Query.Load();

                foreach (DataRowView oUserRole in oUserRoles.DefaultView)
                {
                    DataRow[] drOrg = Organization.Instance.Organizations.Select("OrganizationID = " + oUserRole["OrganizationID"]);

                    if (drOrg.Length > 0)
                    {
                        int iDatabaseID = ConvertHelper.o2i(drOrg[0]["DatabaseID"]);

                        DataRow[] drDbs             = Database.Instance.Databases.Select("DatabaseID = " + iDatabaseID);
                        string    sConnectionString = ConvertHelper.o2s(drDbs[0]["DBConnectionString"]);

                        if (drDbs.Length > 0)
                        {
                            DL_WEB.DAL.Client.User oClientUser = new DL_WEB.DAL.Client.User();
                            oClientUser.Where.GUID.Value = UserGuid;
                            oClientUser.ConnectionString = sConnectionString;
                            oClientUser.Query.Load();

                            if (oClientUser.RowCount > 0)
                            {
                                oClientUser.Password = newPassword;
                                oClientUser.Save();
                            }
                        }
                    }
                }

                return(true);
            }
            catch
            {
                return(false);
            }
        }
示例#9
0
    protected void linkbtnSave_Click(object sender, EventArgs e)
    {
        // save user to the multidatabase structure
        DL_WEB.DAL.Master.User oMasterUser = Session["MasterUser"] as DL_WEB.DAL.Master.User;
        DL_WEB.DAL.Client.User oClientUser = Session["ClientUser"] as DL_WEB.DAL.Client.User;
        oMasterUser.Save();

        Database     oDatabase     = new Database();
        Organization oOrganization = new Organization();

        ArrayList oUserRoles          = Session["UserRoles"] as ArrayList;
        ArrayList oProcessedDatabases = new ArrayList();

        if (0 != UserID)
        {
            OrganizationUserRole oExistingUserRoles = new OrganizationUserRole();
            oExistingUserRoles.LoadUserOrganizationRole(UserID);

            foreach (DataRow dr in oExistingUserRoles.DefaultView.Table.Rows)
            {
                int       iCurrentOrgID  = ConvertHelper.o2i(dr["OrganizationID"]);
                int       iCurrentRoleID = ConvertHelper.o2i(dr["RoleID"]);
                DataRow[] drsDB          = Database.Instance.Databases.Select("DatabaseID = " + dr["DatabaseID"]);
                if (drsDB.Length > 0)
                {
                    string sConnectionString = ConvertHelper.o2s(drsDB[0]["DBConnectionString"]);

                    bool bShouldBeDeleted = false;

                    if (oUserRoles != null)
                    {
                        foreach (OrganizationRoleEntry oEntry in oUserRoles)
                        {
                            if (oEntry.ActionType == ActionTypes.Delete &&
                                oEntry.OrganizationID == iCurrentOrgID &&
                                oEntry.RoleID == iCurrentRoleID)
                            {
                                bShouldBeDeleted = true;
                                break;
                            }
                        }
                    }

                    DL_WEB.DAL.Client.User oClientUserRetrieved = new DL_WEB.DAL.Client.User();
                    oClientUserRetrieved.ConnectionString = sConnectionString;
                    oClientUserRetrieved.Where.GUID.Value = oMasterUser.GUID;
                    oClientUserRetrieved.Query.Load();
                    DL_WEB.DAL.Client.AddressBook oAddressBookRetrieved = oClientUserRetrieved.AddressBookEntry;

                    if (bShouldBeDeleted)
                    {
                        #region Deleting existing client database data

                        oClientUserRetrieved.MarkAsDeleted();
                        oClientUserRetrieved.Save();

                        oAddressBookRetrieved.MarkAsDeleted();
                        oAddressBookRetrieved.Save();

                        #endregion

                        #region Deleting assignment table (UserRole) data row

                        UserRole oUserRole = new UserRole();
                        oUserRole.Where.UserID.Value            = UserID;
                        oUserRole.Where.UserID.Operator         = MyGeneration.dOOdads.WhereParameter.Operand.Equal;
                        oUserRole.Where.RoleID.Value            = iCurrentRoleID;
                        oUserRole.Where.RoleID.Operator         = MyGeneration.dOOdads.WhereParameter.Operand.Equal;
                        oUserRole.Where.OrganizationID.Value    = iCurrentOrgID;
                        oUserRole.Where.OrganizationID.Operator = MyGeneration.dOOdads.WhereParameter.Operand.Equal;

                        oUserRole.Query.Load();

                        if (oUserRole.RowCount > 0)
                        {
                            oUserRole.MarkAsDeleted();
                            oUserRole.Save();
                        }

                        #endregion
                    }
                    else
                    {
                        #region Updating existing client database data

                        DL_WEB.BLL.Helpers.DoodadsHelper.CopyData(oClientUser.AddressBookEntry, oAddressBookRetrieved);
                        oAddressBookRetrieved.Save();

                        DL_WEB.BLL.Helpers.DoodadsHelper.CopyData(oClientUser, oClientUserRetrieved);
                        oClientUser.UserID = oClientUserRetrieved.UserID;

                        oClientUserRetrieved.Save();

                        #endregion
                    }
                }
            }
        }

        if (oUserRoles != null)
        {
            foreach (OrganizationRoleEntry oUserRole in oUserRoles)
            {
                if (oUserRole.ActionType == ActionTypes.Delete)
                {
                    continue;
                }

                DataRow[] drOrg = Organization.Instance.Organizations.Select("OrganizationID = " + oUserRole.OrganizationID);

                if (drOrg.Length > 0)
                {
                    int iDatabaseID = ConvertHelper.o2i(drOrg[0]["DatabaseID"]);

                    DataRow[] drDbs             = Database.Instance.Databases.Select("DatabaseID = " + iDatabaseID);
                    string    sConnectionString = ConvertHelper.o2s(drDbs[0]["DBConnectionString"]);

                    #region Adding assigning info into the UserRole table

                    UserRole oAddingUserRole = new UserRole();
                    oAddingUserRole.AddNew();
                    oAddingUserRole.UserID         = oMasterUser.UserID;
                    oAddingUserRole.RoleID         = oUserRole.RoleID;
                    oAddingUserRole.OrganizationID = oUserRole.OrganizationID;

                    oAddingUserRole.Save();

                    #endregion

                    if (oProcessedDatabases.Contains(iDatabaseID))
                    {
                        continue;
                    }

                    if (drDbs.Length > 0)
                    {
                        #region Saving user into the client database

                        DL_WEB.DAL.Client.User oClientUserClone = new DL_WEB.DAL.Client.User();
                        oClientUserClone.AddNew();
                        DL_WEB.BLL.Helpers.DoodadsHelper.CopyData(oClientUser, oClientUserClone);
                        oClientUserClone.CreationDate = oClientUser.CreationDate;
                        oClientUserClone.IsApproved   = oClientUser.IsApproved;
                        oClientUserClone.IsLockedOut  = oClientUser.IsLockedOut;

                        oClientUserClone.AddressBookEntry = new DL_WEB.DAL.Client.AddressBook();
                        oClientUserClone.AddressBookEntry.AddNew();
                        DL_WEB.BLL.Helpers.DoodadsHelper.CopyData(oClientUser.AddressBookEntry, oClientUserClone.AddressBookEntry);

                        oClientUser.ConnectionString = sConnectionString;
                        oClientUser.AddressBookEntry.ConnectionString = sConnectionString;

                        oClientUserClone.AddressBookEntry.Save();
                        oClientUserClone.AddressBookEntryID = oClientUserClone.AddressBookEntry.EntryID;

                        oClientUserClone.Save();

                        #endregion

                        #region Updating processed databases list

                        oProcessedDatabases.Add(iDatabaseID);

                        #endregion
                    }
                }
            }
        }

        CancelLink_Click(sender, e);
    }