private void SaveUser()
        {
            if (!Page.IsValid)
            {
                return;
            }

            // gather data from form
            UserInfo user = new UserInfo();

            user.UserId   = 0;
            user.Role     = (UserRole)Enum.Parse(typeof(UserRole), role.SelectedValue);
            user.StatusId = Int32.Parse(status.SelectedValue);
            user.OwnerId  = PanelSecurity.SelectedUserId;
            user.IsDemo   = chkDemo.Checked;
            user.IsPeer   = false;
            //
            if (chkEcommerceEnbl.Visible)
            {
                user.EcommerceEnabled = chkEcommerceEnbl.Checked;
            }

            // account info
            user.FirstName      = txtFirstName.Text;
            user.LastName       = txtLastName.Text;
            user.Email          = txtEmail.Text;
            user.SecondaryEmail = txtSecondaryEmail.Text;
            user.HtmlMail       = ddlMailFormat.SelectedIndex == 1;
            user.Username       = txtUsername.Text.Trim();
            user.Password       = userPassword.Password;

            // contact info
            user.CompanyName      = contact.CompanyName;
            user.Address          = contact.Address;
            user.City             = contact.City;
            user.Country          = contact.Country;
            user.State            = contact.State;
            user.Zip              = contact.Zip;
            user.PrimaryPhone     = contact.PrimaryPhone;
            user.SecondaryPhone   = contact.SecondaryPhone;
            user.Fax              = contact.Fax;
            user.InstantMessenger = contact.MessengerId;


            // add a new user
            List <string> log = new List <string>();

            try
            {
                //int userId = UsersHelper.AddUser(log, PortalId, user);
                int userId = PortalUtils.AddUserAccount(log, user, chkAccountLetter.Checked);

                if (userId == BusinessErrorCodes.ERROR_INVALID_USER_NAME)
                {
                    ShowResultMessage(BusinessErrorCodes.ERROR_INVALID_USER_NAME);
                    return;
                }

                if (userId < 0)
                {
                    ShowResultMessage(userId);
                    return;
                }

                // show log records if any
                if (log.Count > 0)
                {
                    blLog.Items.Clear();
                    foreach (string error in log)
                    {
                        blLog.Items.Add(error);
                    }

                    return;
                }

                // go to user home
                Response.Redirect(PortalUtils.GetUserHomePageUrl(userId));
            }
            catch (Exception ex)
            {
                ShowErrorMessage("USER_ADD_USER", ex);
                return;
            }
        }
Beispiel #2
0
 public string GetUserHomePageUrl(int userId)
 {
     return(PortalUtils.GetUserHomePageUrl(userId));
 }
        public string GetItemPageUrl(string fullType, string itemType, int itemId, int spaceId, int accountId, string textSearch = "")
        {
            string res = "";

            if (fullType.Equals("AccountHome"))
            {
                res = PortalUtils.GetUserHomePageUrl(itemId);
            }
            else
            {
                switch (itemType)
                {
                case TYPE_WEBSITE:
                    res = PortalUtils.NavigatePageURL(PID_SPACE_WEBSITES, "ItemID", itemId.ToString(),
                                                      PortalUtils.SPACE_ID_PARAM + "=" + spaceId, DefaultPage.CONTROL_ID_PARAM + "=" + "edit_item",
                                                      "moduleDefId=websites");
                    break;

                case TYPE_DOMAIN:
                    res = PortalUtils.NavigatePageURL(PID_SPACE_DIMAINS, "DomainID", itemId.ToString(),
                                                      PortalUtils.SPACE_ID_PARAM + "=" + spaceId, DefaultPage.CONTROL_ID_PARAM + "=" + "edit_item",
                                                      "moduleDefId=domains");
                    break;

                case TYPE_ORGANIZATION:
                    res = PortalUtils.NavigatePageURL(PID_SPACE_EXCHANGESERVER, "ItemID", itemId.ToString(),
                                                      PortalUtils.SPACE_ID_PARAM + "=" + spaceId, DefaultPage.CONTROL_ID_PARAM + "=" + "organization_home",
                                                      "moduleDefId=ExchangeServer");
                    break;

                case TYPE_EXCHANGEACCOUNT:
                    if (fullType.Equals("Mailbox"))
                    {
                        res = PortalUtils.NavigatePageURL(PID_SPACE_EXCHANGESERVER, "ItemID", itemId.ToString(),
                                                          PortalUtils.SPACE_ID_PARAM + "=" + spaceId, "ctl=mailbox_settings",
                                                          "AccountID=" + accountId, "moduleDefId=ExchangeServer");
                    }
                    else
                    {
                        res = PortalUtils.NavigatePageURL(PID_SPACE_EXCHANGESERVER, "ItemID", itemId.ToString(),
                                                          PortalUtils.SPACE_ID_PARAM + "=" + spaceId, "ctl=edit_user",
                                                          "AccountID=" + accountId, "moduleDefId=ExchangeServer");
                    }
                    break;

                case TYPE_RDSCOLLECTION:
                    res = PortalUtils.NavigatePageURL(PID_SPACE_EXCHANGESERVER, "ItemID", itemId.ToString(),
                                                      PortalUtils.SPACE_ID_PARAM + "=" + spaceId, "ctl=rds_edit_collection",
                                                      "CollectionId=" + accountId, "moduleDefId=ExchangeServer");
                    break;

                case TYPE_LYNC:
                    res = PortalUtils.NavigatePageURL(PID_SPACE_EXCHANGESERVER, "ItemID", itemId.ToString(),
                                                      PortalUtils.SPACE_ID_PARAM + "=" + spaceId.ToString(), "ctl=edit_lync_user",
                                                      "AccountID=" + accountId, "moduleDefId=ExchangeServer");
                    break;

                case TYPE_FOLDER:
                    res = PortalUtils.NavigatePageURL(PID_SPACE_EXCHANGESERVER, "ItemID", itemId.ToString(),
                                                      PortalUtils.SPACE_ID_PARAM + "=" + spaceId.ToString(), "ctl=enterprisestorage_folder_settings",
                                                      "FolderID=" + textSearch, "moduleDefId=ExchangeServer");
                    break;

                case TYPE_SHAREPOINT:
                case TYPE_SHAREPOINTENTERPRISE:
                    res = PortalUtils.NavigatePageURL(PID_SPACE_EXCHANGESERVER, "ItemID", itemId.ToString(),
                                                      PortalUtils.SPACE_ID_PARAM + "=" + spaceId, "ctl=" + (itemType == TYPE_SHAREPOINT ? "sharepoint_edit_sitecollection" : "sharepoint_enterprise_edit_sitecollection"),
                                                      "SiteCollectionID=" + accountId, "moduleDefId=ExchangeServer");
                    break;

                default:
                    res = PortalUtils.GetSpaceHomePageUrl(spaceId);
                    break;
                }
            }

            return(res);
        }