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);
    }
Exemplo n.º 3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            DL_WEB.DAL.Client.AddressBook oAddressBook = new DL_WEB.DAL.Client.AddressBook();
            if (null != Request["action"] &&
                0 == Request["action"].CompareTo("delete") &&
                this.EntryID > 0)
            {
                oAddressBook.LoadByPrimaryKey(this.EntryID);

                string Name = oAddressBook.FirstName + " " + oAddressBook.LastName;

                oAddressBook.MarkAsDeleted();
                oAddressBook.Save();

                DL_WEB.DAL.Client.ActivityLog.Instance.RegisterActivity(ActivityTypes.AddressBookDeleted, "AddressBook " + Name + " deleted", ActivityObject.AddressBook, this.EntryID, UserGUID, Context.User.Identity.Name);
            }
            oAddressBook = new DL_WEB.DAL.Client.AddressBook();
            oAddressBook.LoadUserContacts(DL_WEB.DAL.Client.User.Instance.GetUserIDByGUID(UserGUID));
            gvAddressBookList.DataSource = oAddressBook.DefaultView;
            gvAddressBookList.DataBind();
        }
    }
Exemplo n.º 4
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);
    }
Exemplo n.º 5
0
 public AddressBook CopyTo(AddressBook oAddressBook)
 {
     return((AddressBook)BLL.Helpers.DoodadsHelper.CopyData(this, oAddressBook));
 }