Esempio n. 1
0
    private DL_WEB.DAL.Client.User LoadClientUserInfo(int iUserID, Guid oUserGUID)
    {
        DL_WEB.DAL.Client.User oClientUser = new DL_WEB.DAL.Client.User();
        oClientUser.Where.GUID.Value = oUserGUID;

        UserRole oUserRole = new UserRole();

        oUserRole.Where.UserID.Value = iUserID;
        oUserRole.Query.Load();

        if (oUserRole.RowCount > 0)
        {
            DataRow[] drOrgs = Organization.Instance.Organizations.Select("OrganizationID = " + oUserRole.OrganizationID);
            if (drOrgs.Length > 0)
            {
                DataRow[] drsDBs = Database.Instance.Databases.Select("DatabaseID = " + drOrgs[0]["DatabaseID"]);
                if (drsDBs.Length > 0)
                {
                    oClientUser.ConnectionString = ConvertHelper.o2s(drsDBs[0]["DBConnectionString"]);
                    oClientUser.Query.Load();
                }
            }
        }

        return(oClientUser);
    }
Esempio n. 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;
            }
        }
    }
Esempio n. 3
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
                }
            }
        }
    }
Esempio n. 4
0
    private void LoadUser()
    {
        DL_WEB.DAL.Client.User oClientUser = LoadClientUserInfo(this.UserID, this.UserGUID);

        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;
        }
    }
Esempio n. 5
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);
    }
Esempio n. 6
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);
    }
Esempio n. 7
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);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.Page.IsPostBack)
        {
            switch (this.Type)
            {
            case "role":
                ObjectNameLabel.Text = "Role";
                ProjectNotificationItemList.DataSourceID   = "RoleDataSource";
                ProjectNotificationItemList.DataValueField = "RoleID";
                ProjectNotificationItemList.DataTextField  = "Name";
                break;

            case "user":
                ObjectNameLabel.Text = "User";

                ProjectNotification oProjectNotification = new ProjectNotification();
                oProjectNotification.Where.ProjectID.Value             = this.ProjectID;
                oProjectNotification.Where.ProjectID.Operator          = MyGeneration.dOOdads.WhereParameter.Operand.Equal;
                oProjectNotification.Where.NotificationTypeID.Value    = this.NotificationTypeID;
                oProjectNotification.Where.NotificationTypeID.Operator = MyGeneration.dOOdads.WhereParameter.Operand.Equal;
                oProjectNotification.Where.UserID.Operator             = MyGeneration.dOOdads.WhereParameter.Operand.IsNotNull;
                oProjectNotification.Query.Distinct = true;
                oProjectNotification.Query.Load();

                string UserIdList = string.Empty;
                while (!oProjectNotification.EOF)
                {
                    UserIdList += "," + oProjectNotification.UserID.ToString();
                    oProjectNotification.MoveNext();
                }
                if (UserIdList.Length > 0)
                {
                    UserIdList = UserIdList.Remove(0, 1);
                }

                DL_WEB.DAL.Client.User oUser = new DL_WEB.DAL.Client.User();
                oUser.Where.UserID.Value    = UserIdList;
                oUser.Where.UserID.Operator = MyGeneration.dOOdads.WhereParameter.Operand.NotIn;
                oUser.Query.Load();

                ProjectNotificationItemList.DataSource     = oUser.DefaultView;
                ProjectNotificationItemList.DataValueField = "UserID";
                ProjectNotificationItemList.DataTextField  = "Login";
                ProjectNotificationItemList.DataBind();
                break;

            case "addressbook":
                ObjectNameLabel.Text = "Contact";

                DL_DAL.Client.AddressBookView view = new DL_DAL.Client.AddressBookView();
                view.Where.UserID.Value        = DL_WEB.DAL.Client.User.Instance.GetUserIDByGUID(this.UserGUID);
                view.Where.UserID.Operator     = MyGeneration.dOOdads.WhereParameter.Operand.Equal;
                view.Where.IsShared.Value      = true;
                view.Where.IsShared.Operator   = MyGeneration.dOOdads.WhereParameter.Operand.Equal;
                view.Where.IsShared.Conjuction = MyGeneration.dOOdads.WhereParameter.Conj.Or;
                view.LoadAll();
                ProjectNotificationItemList.DataSource     = view.DefaultView;
                ProjectNotificationItemList.DataValueField = "EntryID";
                ProjectNotificationItemList.DataTextField  = "Name";
                ProjectNotificationItemList.DataBind();
                break;
            }
        }
    }