Merge of latest revision

This commit is contained in:
VoosW 2012-11-01 11:03:10 +01:00
commit 2eea4614ce
33 changed files with 592 additions and 54 deletions

View file

@ -431,7 +431,12 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution
}
public static LyncUsersPagedResult GetLyncUsers(int itemId, string sortColumn, string sortDirection, int startRow, int count)
public static LyncUsersPagedResult GetLyncUsers(int itemId)
{
return GetLyncUsersPaged(itemId, string.Empty, string.Empty, 0, int.MaxValue);
}
public static LyncUsersPagedResult GetLyncUsersPaged(int itemId, string sortColumn, string sortDirection, int startRow, int count)
{
LyncUsersPagedResult res = TaskManager.StartResultTask<LyncUsersPagedResult>("LYNC", "GET_LYNC_USERS");

View file

@ -517,7 +517,7 @@ namespace WebsitePanel.EnterpriseServer
try
{
LyncUsersPagedResult res = LyncController.GetLyncUsers(itemId, string.Empty, string.Empty, 0, int.MaxValue);
LyncUsersPagedResult res = LyncController.GetLyncUsers(itemId);
if (res.IsSuccess)
{

View file

@ -123,8 +123,22 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution
delegate(CRMOrganizationStatistics stats) { return stats.OrganizationID == org.OrganizationId; });
item.TotalCRMUsers = crmOrganizationStatistics.Count;
}
if (report.LyncReport != null)
{
List<LyncUserStatistics> lyncOrganizationStatistics =
report.LyncReport.Items.FindAll(
delegate(LyncUserStatistics stats) { return stats.OrganizationID == org.OrganizationId; });
foreach (LyncUserStatistics current in lyncOrganizationStatistics)
{
if (current.EnterpriseVoice) item.TotalLyncEVUsers++;
}
item.TotalLyncUsers = lyncOrganizationStatistics.Count;
}
report.OrganizationReport.Items.Add(item);
}
@ -308,7 +322,20 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution
{
TaskManager.WriteError(ex);
}
}
if (report.LyncReport != null)
{
try
{
PopulateLyncReportItems(org, report, topReseller);
}
catch (Exception ex)
{
TaskManager.WriteError(ex);
}
}
}
private static int GetExchangeServiceID(int packageId)
@ -316,6 +343,10 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution
return PackageController.GetPackageServiceId(packageId, ResourceGroups.Exchange);
}
private static int GetLyncServiceID(int packageId)
{
return PackageController.GetPackageServiceId(packageId, ResourceGroups.Lync);
}
private static void PopulateSharePointItem(Organization org, EnterpriseSolutionStatisticsReport report, string topReseller)
@ -422,7 +453,13 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution
{
PopulateBaseItem(stats, org, topReseller);
stats.MailboxType = mailbox.AccountType;
if (mailbox.AccountType == ExchangeAccountType.Mailbox)
{
ExchangeAccount a = ExchangeServerController.GetAccount(mailbox.ItemId, mailbox.AccountId);
stats.MailboxPlan = a.MailboxPlan;
}
stats.BlackberryEnabled = BlackBerryController.CheckBlackBerryUserExists(mailbox.AccountId);
report.ExchangeReport.Items.Add(stats);
}
@ -436,6 +473,74 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution
}
private static void PopulateLyncReportItems(Organization org, EnterpriseSolutionStatisticsReport report, string topReseller)
{
//Check if lync organization
if (string.IsNullOrEmpty(org.LyncTenantId))
return;
LyncUser[] lyncUsers = null;
try
{
LyncUsersPagedResult res = LyncController.GetLyncUsers(org.Id);
if (res.IsSuccess) lyncUsers = res.Value.PageUsers;
}
catch (Exception ex)
{
throw new ApplicationException(
string.Format("Could not get lync users for current organization {0}", org.Id), ex);
}
if (lyncUsers == null)
return;
foreach (LyncUser lyncUser in lyncUsers)
{
try
{
LyncUserStatistics stats = new LyncUserStatistics();
try
{
stats.SipAddress = lyncUser.PrimaryEmailAddress;
if (string.IsNullOrEmpty(lyncUser.LineUri)) stats.PhoneNumber = string.Empty; else stats.PhoneNumber = lyncUser.LineUri;
LyncUserPlan plan = LyncController.GetLyncUserPlan(org.Id, lyncUser.LyncUserPlanId);
stats.Conferencing = plan.Conferencing;
stats.EnterpriseVoice = plan.EnterpriseVoice;
stats.Federation = plan.Federation;
stats.InstantMessaing = plan.IM;
stats.MobileAccess = plan.Mobility;
stats.LyncUserPlan = plan.LyncUserPlanName;
}
catch (Exception ex)
{
TaskManager.WriteError(ex, "Could not get lync statistics. AccountName: {0}",
lyncUser.DisplayName);
}
if (stats != null)
{
PopulateBaseItem(stats, org, topReseller);
report.LyncReport.Items.Add(stats);
}
}
catch (Exception ex)
{
TaskManager.WriteError(ex);
}
}
}
private static void PopulateSpaceData(int packageId, EnterpriseSolutionStatisticsReport report, string topReseller)
{
List<Organization> organizations;
@ -489,8 +594,8 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution
}
}
private static void GetUsersData(EnterpriseSolutionStatisticsReport report, int userId, bool generateExchangeReport, bool generateSharePointReport, bool generateCRMReport, bool generateOrganizationReport, string topReseller)
private static void GetUsersData(EnterpriseSolutionStatisticsReport report, int userId, bool generateExchangeReport, bool generateSharePointReport, bool generateCRMReport, bool generateOrganizationReport, bool generateLyncReport, string topReseller)
{
List<UserInfo> users;
try
@ -514,6 +619,7 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution
GetUsersData(report, user.UserId, generateExchangeReport, generateSharePointReport,
generateCRMReport,
generateOrganizationReport,
generateLyncReport,
string.IsNullOrEmpty(topReseller) ? user.Username : topReseller);
}
}
@ -523,8 +629,8 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution
}
}
}
public static EnterpriseSolutionStatisticsReport GetEnterpriseSolutionStatisticsReport(int userId, bool generateExchangeReport, bool generateSharePointReport, bool generateCRMReport, bool generateOrganizationReport)
public static EnterpriseSolutionStatisticsReport GetEnterpriseSolutionStatisticsReport(int userId, bool generateExchangeReport, bool generateSharePointReport, bool generateCRMReport, bool generateOrganizationReport, bool generateLyncReport)
{
EnterpriseSolutionStatisticsReport report = new EnterpriseSolutionStatisticsReport();
@ -534,17 +640,20 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution
if (generateSharePointReport || generateOrganizationReport)
report.SharePointReport = new SharePointStatisticsReport();
if (generateLyncReport || generateOrganizationReport)
report.LyncReport = new LyncStatisticsReport();
if (generateCRMReport || generateOrganizationReport)
report.CRMReport = new CRMStatisticsReport();
if (generateOrganizationReport)
report.OrganizationReport = new OrganizationStatisticsReport();
try
{
GetUsersData(report, userId, generateExchangeReport, generateSharePointReport, generateCRMReport,
generateOrganizationReport, null);
generateOrganizationReport, generateLyncReport, null);
}
catch(Exception ex)
{

View file

@ -42,6 +42,7 @@ namespace WebsitePanel.EnterpriseServer
private static readonly string EXCHANGE_REPORT = "EXCHANGE_REPORT";
private static readonly string ORGANIZATION_REPORT = "ORGANIZATION_REPORT";
private static readonly string SHAREPOINT_REPORT = "SHAREPOINT_REPORT";
private static readonly string LYNC_REPORT = "LYNC_REPORT";
private static readonly string CRM_REPORT = "CRM_REPORT";
private static readonly string EMAIL = "EMAIL";
@ -52,6 +53,7 @@ namespace WebsitePanel.EnterpriseServer
{
bool isExchange = Utils.ParseBool(TaskManager.TaskParameters[EXCHANGE_REPORT], false);
bool isSharePoint = Utils.ParseBool(TaskManager.TaskParameters[SHAREPOINT_REPORT], false);
bool isLync = Utils.ParseBool(TaskManager.TaskParameters[LYNC_REPORT], false);
bool isCRM = Utils.ParseBool(TaskManager.TaskParameters[CRM_REPORT], false);
bool isOrganization = Utils.ParseBool(TaskManager.TaskParameters[ORGANIZATION_REPORT], false);
@ -61,13 +63,14 @@ namespace WebsitePanel.EnterpriseServer
UserInfo user = PackageController.GetPackageOwner(TaskManager.PackageId);
EnterpriseSolutionStatisticsReport report =
ReportController.GetEnterpriseSolutionStatisticsReport(user.UserId, isExchange, isSharePoint, isCRM,
isOrganization);
isOrganization, isLync);
SendMessage(user, email, isExchange && report.ExchangeReport != null ? report.ExchangeReport.ToCSV() : string.Empty,
isSharePoint && report.SharePointReport != null ? report.SharePointReport.ToCSV() : string.Empty,
isCRM && report.CRMReport != null ? report.CRMReport.ToCSV() : string.Empty,
isOrganization && report.OrganizationReport != null ? report.OrganizationReport.ToCSV() : string.Empty);
isOrganization && report.OrganizationReport != null ? report.OrganizationReport.ToCSV() : string.Empty,
isLync && report.LyncReport != null ? report.LyncReport.ToCSV() : string.Empty);
}
catch(Exception ex)
{
@ -90,11 +93,12 @@ namespace WebsitePanel.EnterpriseServer
}
}
private void SendMessage(UserInfo user,string email, string exchange_csv, string sharepoint_csv, string crm_csv, string organization_csv)
private void SendMessage(UserInfo user,string email, string exchange_csv, string sharepoint_csv, string crm_csv, string organization_csv, string lync_csv)
{
List<Attachment> attacments = new List<Attachment>();
PrepareAttament("exchange.csv", exchange_csv, attacments);
PrepareAttament("sharepoint.csv", sharepoint_csv, attacments);
PrepareAttament("lync.csv", lync_csv, attacments);
PrepareAttament("crm.csv", crm_csv, attacments);
PrepareAttament("organization.csv", organization_csv, attacments);

View file

@ -29,6 +29,7 @@
using System;
using System.IO;
using System.Data;
using System.Linq;
using System.Collections.Specialized;
using System.Collections.Generic;
using System.Text;
@ -1213,6 +1214,17 @@ namespace WebsitePanel.EnterpriseServer
DNSServer dns = new DNSServer();
ServiceProviderProxy.Init(dns, zone.ServiceId);
DnsRecord[] domainRecords = dns.GetZoneRecords(zone.Name);
var duplicateRecords = (from zoneRecord in domainRecords
from resRecord in resourceRecords
where zoneRecord.RecordName == resRecord.RecordName
where zoneRecord.RecordType == resRecord.RecordType
select zoneRecord).ToArray();
if (duplicateRecords != null && duplicateRecords.Count() > 0)
{
dns.DeleteZoneRecords(zone.Name, duplicateRecords);
}
// add new resource records
dns.AddZoneRecords(zone.Name, resourceRecords.ToArray());
}
@ -2478,7 +2490,7 @@ namespace WebsitePanel.EnterpriseServer
WebServer server = GetWebServer(item.ServiceId);
StringDictionary webSettings = ServerController.GetServiceSettings(item.ServiceId);
if (webSettings["WmSvc.NETBIOS"] != null)
if (!String.IsNullOrEmpty(webSettings["WmSvc.NETBIOS"]))
{
accountName = webSettings["WmSvc.NETBIOS"].ToString() + "\\" + accountName;
}
@ -3246,7 +3258,7 @@ namespace WebsitePanel.EnterpriseServer
WebServer server = GetWebServer(item.ServiceId);
StringDictionary webSettings = ServerController.GetServiceSettings(item.ServiceId);
if (webSettings["WmSvc.NETBIOS"] != null)
if (!String.IsNullOrEmpty(webSettings["WmSvc.NETBIOS"]))
{
accountName = webSettings["WmSvc.NETBIOS"].ToString() + "\\" + accountName;
}
@ -3716,6 +3728,7 @@ Please ensure the space has been allocated {0} IP address as a dedicated one and
DomainInfo newDomain = new DomainInfo();
newDomain.DomainName = b.Host.ToLower();
newDomain.PackageId = domain.PackageId;
newDomain.IsDomainPointer = true;
int newDomainID = ServerController.AddDomain(newDomain, domain.IsInstantAlias, false);
if (newDomainID > 0)
@ -3726,7 +3739,6 @@ Please ensure the space has been allocated {0} IP address as a dedicated one and
newDomain.WebSiteId = siteId;
newDomain.ZoneItemId = domain.ZoneItemId;
newDomain.DomainItemId = domain.DomainId;
newDomain.IsDomainPointer = true;
ServerController.UpdateDomain(newDomain);
}
}
@ -3760,19 +3772,21 @@ Please ensure the space has been allocated {0} IP address as a dedicated one and
private static int FindDomainForHeader(string header, List<DomainInfo> domains)
{
int domainId = 0;
while (header.IndexOf(".") != -1)
int counter = 0;
while ((header.IndexOf(".") != -1) & (counter < 2))
{
header = header.Substring(header.IndexOf(".") + 1);
foreach (DomainInfo d in domains)
{
if ((header == d.DomainName.ToLower()) && (!d.IsDomainPointer))
{
domainId = d.DomainId;
break;
return d.DomainId;
}
}
header = header.Substring(header.IndexOf(".") + 1);
counter++;
}
return domainId;

View file

@ -434,7 +434,7 @@
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<UseIIS>True</UseIIS>
<UseIIS>False</UseIIS>
<AutoAssignPort>False</AutoAssignPort>
<DevelopmentServerPort>9002</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>

View file

@ -59,7 +59,7 @@ namespace WebsitePanel.EnterpriseServer
[WebMethod]
public LyncUsersPagedResult GetLyncUsersPaged(int itemId, string sortColumn, string sortDirection, int startRow, int maximumRows)
{
return LyncController.GetLyncUsers(itemId, sortColumn, sortDirection, startRow, maximumRows);
return LyncController.GetLyncUsersPaged(itemId, sortColumn, sortDirection, startRow, maximumRows);
}
[WebMethod]