Fixed: Exchange and Lync plans not listed properly with multiple

hosted organizations.

Plans now listed with hosted organizations they belong to
This commit is contained in:
robvde 2012-09-02 07:34:08 +04:00
parent 82e0b5e59c
commit 5717d66fb2
2 changed files with 26 additions and 16 deletions

View file

@ -2537,7 +2537,10 @@ namespace WebsitePanel.EnterpriseServer
UserInfo user = ObjectUtils.FillObjectFromDataReader<UserInfo>(DataProvider.GetUserByExchangeOrganizationIdInternally(itemId)); UserInfo user = ObjectUtils.FillObjectFromDataReader<UserInfo>(DataProvider.GetUserByExchangeOrganizationIdInternally(itemId));
ExchangeServerController.GetExchangeMailboxPlansByUser(user, ref mailboxPlans); if (user.Role == UserRole.User)
ExchangeServerController.GetExchangeMailboxPlansByUser(itemId, user, ref mailboxPlans);
else
ExchangeServerController.GetExchangeMailboxPlansByUser(0, user, ref mailboxPlans);
return mailboxPlans; return mailboxPlans;
} }
@ -2551,7 +2554,7 @@ namespace WebsitePanel.EnterpriseServer
} }
} }
private static void GetExchangeMailboxPlansByUser(UserInfo user, ref List<ExchangeMailboxPlan>mailboxPlans) private static void GetExchangeMailboxPlansByUser(int itemId, UserInfo user, ref List<ExchangeMailboxPlan>mailboxPlans)
{ {
if ((user != null)) if ((user != null))
{ {
@ -2571,9 +2574,14 @@ namespace WebsitePanel.EnterpriseServer
orgs = GetExchangeOrganizationsInternal(1, false); orgs = GetExchangeOrganizationsInternal(1, false);
} }
if ((orgs != null) &(orgs.Count > 0)) int OrgId = -1;
if (itemId > 0) OrgId = itemId;
else if ((orgs != null) & (orgs.Count > 0)) OrgId = orgs[0].Id;
if (OrgId != -1)
{ {
List<ExchangeMailboxPlan> Plans = ObjectUtils.CreateListFromDataReader<ExchangeMailboxPlan>(DataProvider.GetExchangeMailboxPlans(orgs[0].Id)); List<ExchangeMailboxPlan> Plans = ObjectUtils.CreateListFromDataReader<ExchangeMailboxPlan>(DataProvider.GetExchangeMailboxPlans(OrgId));
foreach (ExchangeMailboxPlan p in Plans) foreach (ExchangeMailboxPlan p in Plans)
{ {
@ -2583,7 +2591,7 @@ namespace WebsitePanel.EnterpriseServer
UserInfo owner = UserController.GetUserInternally(user.OwnerId); UserInfo owner = UserController.GetUserInternally(user.OwnerId);
GetExchangeMailboxPlansByUser(owner, ref mailboxPlans); GetExchangeMailboxPlansByUser(0, owner, ref mailboxPlans);
} }
} }

View file

@ -543,14 +543,12 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution
UserInfo user = ObjectUtils.FillObjectFromDataReader<UserInfo>(DataProvider.GetUserByExchangeOrganizationIdInternally(itemId)); UserInfo user = ObjectUtils.FillObjectFromDataReader<UserInfo>(DataProvider.GetUserByExchangeOrganizationIdInternally(itemId));
LyncController.GetLyncUserPlansByUser(user, ref plans); if (user.Role == UserRole.User)
LyncController.GetLyncUserPlansByUser(itemId, user, ref plans);
else
LyncController.GetLyncUserPlansByUser(0, user, ref plans);
return plans; return plans;
return ObjectUtils.CreateListFromDataReader<LyncUserPlan>(
DataProvider.GetLyncUserPlans(itemId));
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -562,7 +560,7 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution
} }
} }
private static void GetLyncUserPlansByUser(UserInfo user, ref List<LyncUserPlan> plans) private static void GetLyncUserPlansByUser(int itemId, UserInfo user, ref List<LyncUserPlan> plans)
{ {
if ((user != null)) if ((user != null))
{ {
@ -582,9 +580,13 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution
orgs = ExchangeServerController.GetExchangeOrganizations(1, false); orgs = ExchangeServerController.GetExchangeOrganizations(1, false);
} }
if ((orgs != null) & (orgs.Count > 0)) int OrgId = -1;
if (itemId > 0) OrgId = itemId;
else if ((orgs != null) & (orgs.Count > 0)) OrgId = orgs[0].Id;
if (OrgId != -1)
{ {
List<LyncUserPlan> Plans = ObjectUtils.CreateListFromDataReader<LyncUserPlan>(DataProvider.GetLyncUserPlans(orgs[0].Id)); List<LyncUserPlan> Plans = ObjectUtils.CreateListFromDataReader<LyncUserPlan>(DataProvider.GetLyncUserPlans(OrgId));
foreach (LyncUserPlan p in Plans) foreach (LyncUserPlan p in Plans)
{ {
@ -594,7 +596,7 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution
UserInfo owner = UserController.GetUserInternally(user.OwnerId); UserInfo owner = UserController.GetUserInternally(user.OwnerId);
GetLyncUserPlansByUser(owner, ref plans); GetLyncUserPlansByUser(0, owner, ref plans);
} }
} }