diff --git a/WebsitePanel/Database/update_db.sql b/WebsitePanel/Database/update_db.sql index 2638ea89..a875f37b 100644 --- a/WebsitePanel/Database/update_db.sql +++ b/WebsitePanel/Database/update_db.sql @@ -1069,17 +1069,6 @@ END GO -ALTER VIEW [dbo].[UsersDetailed] -AS -SELECT U.UserID, U.RoleID, U.StatusID, U.LoginStatusId, U.SubscriberNumber, U.FailedLogins, U.OwnerID, U.Created, U.Changed, U.IsDemo, U.Comments, U.IsPeer, U.Username, U.FirstName, U.LastName, U.Email, - U.CompanyName, U.FirstName + ' ' + U.LastName AS FullName, UP.Username AS OwnerUsername, UP.FirstName AS OwnerFirstName, - UP.LastName AS OwnerLastName, UP.RoleID AS OwnerRoleID, UP.FirstName + ' ' + UP.LastName AS OwnerFullName, UP.Email AS OwnerEmail, UP.RoleID AS Expr1, - (SELECT COUNT(PackageID) AS Expr1 - FROM dbo.Packages AS P - WHERE (UserID = U.UserID)) AS PackagesNumber, U.EcommerceEnabled -FROM dbo.Users AS U LEFT OUTER JOIN - dbo.Users AS UP ON U.OwnerID = UP.UserID -GO ALTER PROCEDURE [dbo].[AddDnsRecord] @@ -1830,6 +1819,19 @@ END GO +ALTER VIEW [dbo].[UsersDetailed] +AS +SELECT U.UserID, U.RoleID, U.StatusID, U.LoginStatusId, U.SubscriberNumber, U.FailedLogins, U.OwnerID, U.Created, U.Changed, U.IsDemo, U.Comments, U.IsPeer, U.Username, U.FirstName, U.LastName, U.Email, + U.CompanyName, U.FirstName + ' ' + U.LastName AS FullName, UP.Username AS OwnerUsername, UP.FirstName AS OwnerFirstName, + UP.LastName AS OwnerLastName, UP.RoleID AS OwnerRoleID, UP.FirstName + ' ' + UP.LastName AS OwnerFullName, UP.Email AS OwnerEmail, UP.RoleID AS Expr1, + (SELECT COUNT(PackageID) AS Expr1 + FROM dbo.Packages AS P + WHERE (UserID = U.UserID)) AS PackagesNumber, U.EcommerceEnabled +FROM dbo.Users AS U LEFT OUTER JOIN + dbo.Users AS UP ON U.OwnerID = UP.UserID +GO + + /****** Object: Table [dbo].[ExchangeOrganizations] ******/ ALTER TABLE [dbo].[ExchangeOrganizations] ALTER COLUMN [OrganizationID] [nvarchar](128) COLLATE Latin1_General_CI_AS NOT NULL GO @@ -2533,6 +2535,54 @@ GO +ALTER PROCEDURE [dbo].[GetUserByExchangeOrganizationIdInternally] +( + @ItemID int +) +AS + SELECT + U.UserID, + U.RoleID, + U.StatusID, + U.SubscriberNumber, + U.LoginStatusId, + U.FailedLogins, + U.OwnerID, + U.Created, + U.Changed, + U.IsDemo, + U.Comments, + U.IsPeer, + U.Username, + U.Password, + U.FirstName, + U.LastName, + U.Email, + U.SecondaryEmail, + U.Address, + U.City, + U.State, + U.Country, + U.Zip, + U.PrimaryPhone, + U.SecondaryPhone, + U.Fax, + U.InstantMessenger, + U.HtmlMail, + U.CompanyName, + U.EcommerceEnabled, + U.[AdditionalParams] + FROM Users AS U + WHERE U.UserID IN (SELECT UserID FROM Packages WHERE PackageID IN ( + SELECT PackageID FROM ServiceItems WHERE ItemID = @ItemID)) + +RETURN +GO + + + + + diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/ExchangeServer/ExchangeServerController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/ExchangeServer/ExchangeServerController.cs index ef3f49e3..e49216d7 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/ExchangeServer/ExchangeServerController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/ExchangeServer/ExchangeServerController.cs @@ -156,16 +156,44 @@ namespace WebsitePanel.EnterpriseServer try { - Organization org = (Organization)PackageController.GetPackageItem(itemId); - if (org == null) - return null; + Organization org = (Organization)PackageController.GetPackageItem(itemId); + if (org == null) + return null; - OrganizationStatistics stats = ObjectUtils.FillObjectFromDataReader( - DataProvider.GetExchangeOrganizationStatistics(itemId)); + OrganizationStatistics stats = new OrganizationStatistics(); + UserInfo user = ObjectUtils.FillObjectFromDataReader(DataProvider.GetUserByExchangeOrganizationIdInternally(itemId)); + + List Packages = PackageController.GetPackages(user.UserId); + + if ((Packages != null) & (Packages.Count > 0)) + { + foreach (PackageInfo Package in Packages) + { + List orgs = null; + + orgs = GetExchangeOrganizations(Package.PackageId, false); + + if ((orgs != null) & (orgs.Count > 0)) + { + foreach (Organization o in orgs) + { + OrganizationStatistics tempStats = ObjectUtils.FillObjectFromDataReader(DataProvider.GetExchangeOrganizationStatistics(o.Id)); + + stats.CreatedMailboxes += tempStats.CreatedMailboxes; + stats.CreatedContacts += tempStats.CreatedContacts; + stats.CreatedDistributionLists += tempStats.CreatedDistributionLists; + stats.CreatedDomains += tempStats.CreatedDomains; + stats.CreatedPublicFolders += tempStats.CreatedPublicFolders; + stats.UsedDiskSpace += tempStats.UsedDiskSpace; + } + } + } + } // disk space //stats.UsedDiskSpace = org.DiskSpace; + // allocated quotas PackageContext cntx = PackageController.GetPackageContext(org.PackageId); stats.AllocatedMailboxes = cntx.Quotas[Quotas.EXCHANGE2007_MAILBOXES].QuotaAllocatedValue; diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/HostedSolution/OrganizationController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/HostedSolution/OrganizationController.cs index 4d1901d3..973ea39f 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/HostedSolution/OrganizationController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/HostedSolution/OrganizationController.cs @@ -891,45 +891,91 @@ namespace WebsitePanel.EnterpriseServer if (org == null) return null; - OrganizationStatistics stats = ObjectUtils.FillObjectFromDataReader( - DataProvider.GetOrganizationStatistics(itemId)); + OrganizationStatistics stats = new OrganizationStatistics(); + UserInfo user = ObjectUtils.FillObjectFromDataReader(DataProvider.GetUserByExchangeOrganizationIdInternally(itemId)); + + List Packages = PackageController.GetPackages(user.UserId); + + if ((Packages != null) & (Packages.Count > 0)) + { + foreach (PackageInfo Package in Packages) + { + List orgs = null; + + orgs = ExchangeServerController.GetExchangeOrganizations(Package.PackageId, false); + + if ((orgs != null) & (orgs.Count > 0)) + { + foreach (Organization o in orgs) + { + OrganizationStatistics tempStats = ObjectUtils.FillObjectFromDataReader(DataProvider.GetOrganizationStatistics(o.Id)); + + stats.CreatedUsers += tempStats.CreatedUsers; + stats.CreatedDomains += tempStats.CreatedDomains; + + PackageContext cntxTmp = PackageController.GetPackageContext(org.PackageId); + + if (cntxTmp.Groups.ContainsKey(ResourceGroups.HostedSharePoint)) + { + SharePointSiteCollectionListPaged sharePointStats = HostedSharePointServerController.GetSiteCollectionsPaged(org.PackageId, org.Id, string.Empty, string.Empty, string.Empty, 0, 0); + stats.CreatedSharePointSiteCollections += sharePointStats.TotalRowCount; + } + + if (cntxTmp.Groups.ContainsKey(ResourceGroups.HostedCRM)) + { + stats.CreatedCRMUsers += CRMController.GetCRMUsersCount(org.Id, string.Empty, string.Empty).Value; + } + + if (cntxTmp.Groups.ContainsKey(ResourceGroups.BlackBerry)) + { + stats.CreatedBlackBerryUsers += BlackBerryController.GetBlackBerryUsersCount(org.Id, string.Empty, string.Empty).Value; + } + + if (cntxTmp.Groups.ContainsKey(ResourceGroups.OCS)) + { + stats.CreatedOCSUsers += OCSController.GetOCSUsersCount(org.Id, string.Empty, string.Empty).Value; + } + + if (cntxTmp.Groups.ContainsKey(ResourceGroups.Lync)) + { + stats.CreatedLyncUsers += LyncController.GetLyncUsersCount(org.Id).Value; + } + } + } + } + } // disk space // allocated quotas - PackageContext cntx = PackageController.GetPackageContext(org.PackageId); + PackageContext cntx = PackageController.GetPackageContext(org.PackageId); stats.AllocatedUsers = cntx.Quotas[Quotas.ORGANIZATION_USERS].QuotaAllocatedValue; stats.AllocatedDomains = cntx.Quotas[Quotas.ORGANIZATION_DOMAINS].QuotaAllocatedValue; if (cntx.Groups.ContainsKey(ResourceGroups.HostedSharePoint)) { SharePointSiteCollectionListPaged sharePointStats = HostedSharePointServerController.GetSiteCollectionsPaged(org.PackageId, org.Id, string.Empty, string.Empty, string.Empty, 0, 0); - stats.CreatedSharePointSiteCollections = sharePointStats.TotalRowCount; stats.AllocatedSharePointSiteCollections = cntx.Quotas[Quotas.HOSTED_SHAREPOINT_SITES].QuotaAllocatedValue; } if (cntx.Groups.ContainsKey(ResourceGroups.HostedCRM)) { - stats.CreatedCRMUsers = CRMController.GetCRMUsersCount(org.Id, string.Empty, string.Empty).Value; stats.AllocatedCRMUsers = cntx.Quotas[Quotas.CRM_USERS].QuotaAllocatedValue; } if (cntx.Groups.ContainsKey(ResourceGroups.BlackBerry)) { - stats.CreatedBlackBerryUsers = BlackBerryController.GetBlackBerryUsersCount(org.Id, string.Empty, string.Empty).Value; stats.AllocatedBlackBerryUsers = cntx.Quotas[Quotas.BLACKBERRY_USERS].QuotaAllocatedValue; } if (cntx.Groups.ContainsKey(ResourceGroups.OCS)) { - stats.CreatedOCSUsers = OCSController.GetOCSUsersCount(org.Id, string.Empty, string.Empty).Value; stats.AllocatedOCSUsers = cntx.Quotas[Quotas.OCS_USERS].QuotaAllocatedValue; } if (cntx.Groups.ContainsKey(ResourceGroups.Lync)) { - stats.CreatedLyncUsers = LyncController.GetLyncUsersCount(org.Id).Value; stats.AllocatedLyncUsers = cntx.Quotas[Quotas.LYNC_USERS].QuotaAllocatedValue; } diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationCreateOrganization.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationCreateOrganization.ascx index 9f2fc04a..17ce99c2 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationCreateOrganization.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationCreateOrganization.ascx @@ -33,7 +33,7 @@ - diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/Organizations.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/Organizations.ascx.cs index 072d101f..f462d0a7 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/Organizations.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/Organizations.ascx.cs @@ -48,8 +48,16 @@ namespace WebsitePanel.Portal.ExchangeServer gvOrgs.Columns[2].Visible = gvOrgs.Columns[3].Visible = gvOrgs.Columns[4].Visible = false; btnCreate.Enabled = false; } - else - if (gvOrgs.Rows.Count > 0) btnCreate.Enabled = false; + + + PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId); + if (cntx.Quotas.ContainsKey(Quotas.ORGANIZATIONS)) + { + btnCreate.Enabled = !(cntx.Quotas[Quotas.ORGANIZATIONS].QuotaAllocatedValue <= gvOrgs.Rows.Count); + } + + //else + //if (gvOrgs.Rows.Count > 0) btnCreate.Enabled = false; } @@ -103,6 +111,13 @@ namespace WebsitePanel.Portal.ExchangeServer gvOrgs.DataBind(); orgsQuota.BindQuota(); + + PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId); + if (cntx.Quotas.ContainsKey(Quotas.ORGANIZATIONS)) + { + btnCreate.Enabled = !(cntx.Quotas[Quotas.ORGANIZATIONS].QuotaAllocatedValue <= gvOrgs.Rows.Count); + } + } catch (Exception ex) { diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SettingsExchangeMailboxPlansPolicy.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SettingsExchangeMailboxPlansPolicy.ascx.cs index 5b2e65a1..0fff13a0 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SettingsExchangeMailboxPlansPolicy.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SettingsExchangeMailboxPlansPolicy.ascx.cs @@ -276,10 +276,10 @@ namespace WebsitePanel.Portal break; case "RestampItem": - RestampMailboxes(mailboxPlanId); + RestampMailboxes(mailboxPlanId, mailboxPlanId); break; case "StampUnassigned": - StampUnAssigned(mailboxPlanId); + RestampMailboxes(-1, mailboxPlanId); break; } @@ -420,7 +420,7 @@ namespace WebsitePanel.Portal } - private void RestampMailboxes(int mailboxPlanId) + private void RestampMailboxes(int sourceMailboxPlanId, int destinationMailboxPlanId) { UserInfo[] UsersInfo = ES.Services.Users.GetUsers(PanelSecurity.SelectedUserId, true); @@ -444,12 +444,12 @@ namespace WebsitePanel.Portal { if (!string.IsNullOrEmpty(org.GlobalAddressList)) { - ExchangeAccount[] Accounts = ES.Services.ExchangeServer.GetExchangeAccountByMailboxPlanId(org.Id, mailboxPlanId); + ExchangeAccount[] Accounts = ES.Services.ExchangeServer.GetExchangeAccountByMailboxPlanId(org.Id, sourceMailboxPlanId); foreach (ExchangeAccount a in Accounts) { txtStatus.Text = "Completed"; - int result = ES.Services.ExchangeServer.SetExchangeMailboxPlan(org.Id, a.AccountId, mailboxPlanId); + int result = ES.Services.ExchangeServer.SetExchangeMailboxPlan(org.Id, a.AccountId, destinationMailboxPlanId); if (result < 0) { BindMailboxPlans(); @@ -475,61 +475,6 @@ namespace WebsitePanel.Portal } - - private void StampUnAssigned(int mailboxPlanId) - { - UserInfo[] UsersInfo = ES.Services.Users.GetUsers(PanelSecurity.SelectedUserId, true); - - try - { - foreach (UserInfo ui in UsersInfo) - { - PackageInfo[] Packages = ES.Services.Packages.GetPackages(ui.UserId); - - if ((Packages != null) & (Packages.GetLength(0) > 0)) - { - foreach (PackageInfo Package in Packages) - { - Providers.HostedSolution.Organization[] orgs = null; - - orgs = ES.Services.ExchangeServer.GetExchangeOrganizations(Package.PackageId, false); - - if ((orgs != null) & (orgs.GetLength(0) > 0)) - { - foreach (Organization org in orgs) - { - if (!string.IsNullOrEmpty(org.GlobalAddressList)) - { - ExchangeAccount[] Accounts = ES.Services.ExchangeServer.GetExchangeAccountByMailboxPlanId(org.Id, -1); - - foreach (ExchangeAccount a in Accounts) - { - txtStatus.Text = "Completed"; - int result = ES.Services.ExchangeServer.SetExchangeMailboxPlan(org.Id, a.AccountId, mailboxPlanId); - if (result < 0) - { - BindMailboxPlans(); - txtStatus.Text = "Error: " + a.AccountName; - messageBox.ShowErrorMessage("EXCHANGE_FAILED_TO_STAMP"); - return; - } - } - } - } - } - } - } - } - messageBox.ShowSuccessMessage("EXCHANGE_STAMPMAILBOXES"); - } - catch (Exception ex) - { - messageBox.ShowErrorMessage("EXCHANGE_FAILED_TO_STAMP", ex); - } - - BindMailboxPlans(); - } - } } \ No newline at end of file