Exemplo n.º 1
0
    private void SaveClientUserInfo(int iUserID, Guid oUserGUID)
    {
        UserRole oUserRoles = new UserRole();

        oUserRoles.Where.UserID.Value = iUserID;
        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)
                {
                    #region Saving user into the client database

                    DL_WEB.DAL.Client.User oClientUser = new DL_WEB.DAL.Client.User();
                    oClientUser.Where.GUID.Value = oUserGUID;
                    oClientUser.ConnectionString = sConnectionString;
                    oClientUser.Query.Load();

                    oClientUser.AddressBookEntry.ConnectionString = sConnectionString;
                    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.MiddleName      = this.tbMiddleName.Text;
                    oAddressBook.JobTitle        = this.tbJobTitle.Text;
                    oAddressBook.HomePhone       = this.tbHomePhone.Text;
                    oAddressBook.WorkPhone       = this.tbWorkPhone.Text;
                    oClientUser.AddressBookEntry = oAddressBook;
                    oClientUser.AddressBookEntry.Save();

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

                    #endregion
                }
            }
        }
    }
Exemplo n.º 2
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);
    }