Exchange archiving part 1

This commit is contained in:
dev_amdtel 2014-03-13 13:59:34 +04:00
parent fac1310362
commit eea7d1ce6a
36 changed files with 3581 additions and 4237 deletions

View file

@ -1,4 +1,4 @@
// Copyright (c) 2012, Outercurve Foundation.
// Copyright (c) 2012-2014, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
@ -2570,7 +2570,7 @@ namespace WebsitePanel.EnterpriseServer
public static void UpdateExchangeAccount(int accountId, string accountName, ExchangeAccountType accountType,
string displayName, string primaryEmailAddress, bool mailEnabledPublicFolder,
string mailboxManagerActions, string samAccountName, string accountPassword, int mailboxPlanId, string subscriberNumber)
string mailboxManagerActions, string samAccountName, string accountPassword, int mailboxPlanId, int archivePlanId, string subscriberNumber)
{
SqlHelper.ExecuteNonQuery(
ConnectionString,
@ -2586,6 +2586,7 @@ namespace WebsitePanel.EnterpriseServer
new SqlParameter("@Password", string.IsNullOrEmpty(accountPassword) ? (object)DBNull.Value : (object)accountPassword),
new SqlParameter("@SamAccountName", samAccountName),
new SqlParameter("@MailboxPlanId", (mailboxPlanId == 0) ? (object)DBNull.Value : (object)mailboxPlanId),
new SqlParameter("@ArchivingMailboxPlanId", (archivePlanId < 1) ? (object)DBNull.Value : (object)archivePlanId),
new SqlParameter("@SubscriberNumber", (string.IsNullOrEmpty(subscriberNumber) ? (object)DBNull.Value : (object)subscriberNumber))
);
}
@ -2709,7 +2710,7 @@ namespace WebsitePanel.EnterpriseServer
}
public static DataSet GetExchangeAccountsPaged(int actorId, int itemId, string accountTypes,
string filterColumn, string filterValue, string sortColumn, int startRow, int maximumRows)
string filterColumn, string filterValue, string sortColumn, int startRow, int maximumRows, bool archiving)
{
// check input parameters
string[] types = accountTypes.Split(',');
@ -2738,7 +2739,8 @@ namespace WebsitePanel.EnterpriseServer
new SqlParameter("@FilterValue", VerifyColumnValue(filterValue)),
new SqlParameter("@SortColumn", VerifyColumnName(sortColumn)),
new SqlParameter("@StartRow", startRow),
new SqlParameter("@MaximumRows", maximumRows)
new SqlParameter("@MaximumRows", maximumRows),
new SqlParameter("@Archiving", archiving)
);
}
@ -2782,7 +2784,8 @@ namespace WebsitePanel.EnterpriseServer
public static int AddExchangeMailboxPlan(int itemID, string mailboxPlan, bool enableActiveSync, bool enableIMAP, bool enableMAPI, bool enableOWA, bool enablePOP,
bool isDefault, int issueWarningPct, int keepDeletedItemsDays, int mailboxSizeMB, int maxReceiveMessageSizeKB, int maxRecipients,
int maxSendMessageSizeKB, int prohibitSendPct, int prohibitSendReceivePct, bool hideFromAddressBook, int mailboxPlanType,
bool enabledLitigationHold, long recoverabelItemsSpace, long recoverabelItemsWarning, string litigationHoldUrl, string litigationHoldMsg)
bool enabledLitigationHold, long recoverabelItemsSpace, long recoverabelItemsWarning, string litigationHoldUrl, string litigationHoldMsg,
bool archiving)
{
SqlParameter outParam = new SqlParameter("@MailboxPlanId", SqlDbType.Int);
outParam.Direction = ParameterDirection.Output;
@ -2814,7 +2817,8 @@ namespace WebsitePanel.EnterpriseServer
new SqlParameter("@RecoverableItemsWarningPct", recoverabelItemsWarning),
new SqlParameter("@RecoverableItemsSpace", recoverabelItemsSpace),
new SqlParameter("@LitigationHoldUrl", litigationHoldUrl),
new SqlParameter("@LitigationHoldMsg", litigationHoldMsg)
new SqlParameter("@LitigationHoldMsg", litigationHoldMsg),
new SqlParameter("@Archiving", archiving)
);
return Convert.ToInt32(outParam.Value);
@ -2881,13 +2885,14 @@ namespace WebsitePanel.EnterpriseServer
);
}
public static IDataReader GetExchangeMailboxPlans(int itemId)
public static IDataReader GetExchangeMailboxPlans(int itemId, bool archiving)
{
return SqlHelper.ExecuteReader(
ConnectionString,
CommandType.StoredProcedure,
"GetExchangeMailboxPlans",
new SqlParameter("@ItemID", itemId)
new SqlParameter("@ItemID", itemId),
new SqlParameter("@Archiving", archiving)
);
}
@ -2914,14 +2919,15 @@ namespace WebsitePanel.EnterpriseServer
);
}
public static void SetExchangeAccountMailboxPlan(int accountId, int mailboxPlanId)
public static void SetExchangeAccountMailboxPlan(int accountId, int mailboxPlanId, int archivePlanId)
{
SqlHelper.ExecuteNonQuery(
ConnectionString,
CommandType.StoredProcedure,
"SetExchangeAccountMailboxplan",
new SqlParameter("@AccountID", accountId),
new SqlParameter("@MailboxPlanId", (mailboxPlanId == 0) ? (object)DBNull.Value : (object)mailboxPlanId)
new SqlParameter("@MailboxPlanId", (mailboxPlanId == 0) ? (object)DBNull.Value : (object)mailboxPlanId),
new SqlParameter("@ArchivingMailboxPlanId", (archivePlanId < 1) ? (object)DBNull.Value : (object)archivePlanId)
);
}

View file

@ -950,7 +950,7 @@ namespace WebsitePanel.EnterpriseServer
public static ExchangeAccountsPaged GetAccountsPaged(int itemId, string accountTypes,
string filterColumn, string filterValue, string sortColumn,
int startRow, int maximumRows)
int startRow, int maximumRows, bool archiving)
{
#region Demo Mode
if (IsDemoMode)
@ -965,7 +965,7 @@ namespace WebsitePanel.EnterpriseServer
#endregion
DataSet ds = DataProvider.GetExchangeAccountsPaged(SecurityContext.User.UserId, itemId,
accountTypes, filterColumn, filterValue, sortColumn, startRow, maximumRows);
accountTypes, filterColumn, filterValue, sortColumn, startRow, maximumRows, archiving);
ExchangeAccountsPaged result = new ExchangeAccountsPaged();
result.RecordsCount = (int)ds.Tables[0].Rows[0][0];
@ -1223,7 +1223,7 @@ namespace WebsitePanel.EnterpriseServer
{
DataProvider.UpdateExchangeAccount(account.AccountId, account.AccountName, account.AccountType, account.DisplayName,
account.PrimaryEmailAddress, account.MailEnabledPublicFolder,
account.MailboxManagerActions.ToString(), account.SamAccountName, account.AccountPassword, account.MailboxPlanId,
account.MailboxManagerActions.ToString(), account.SamAccountName, account.AccountPassword, account.MailboxPlanId, account.ArchivingMailboxPlanId,
(string.IsNullOrEmpty(account.SubscriberNumber) ? null : account.SubscriberNumber.Trim()));
}
@ -1598,7 +1598,7 @@ namespace WebsitePanel.EnterpriseServer
private static void UpdateExchangeAccount(int accountId, string accountName, ExchangeAccountType accountType,
string displayName, string primaryEmailAddress, bool mailEnabledPublicFolder,
string mailboxManagerActions, string samAccountName, string accountPassword, int mailboxPlanId, string subscriberNumber)
string mailboxManagerActions, string samAccountName, string accountPassword, int mailboxPlanId, int archivePlanId, string subscriberNumber)
{
DataProvider.UpdateExchangeAccount(accountId,
accountName,
@ -1609,13 +1609,13 @@ namespace WebsitePanel.EnterpriseServer
mailboxManagerActions,
samAccountName,
CryptoUtils.Encrypt(accountPassword),
mailboxPlanId,
mailboxPlanId, archivePlanId,
(string.IsNullOrEmpty(subscriberNumber) ? null : subscriberNumber.Trim()));
}
public static int CreateMailbox(int itemId, int accountId, ExchangeAccountType accountType, string accountName,
string displayName, string name, string domain, string password, bool sendSetupInstructions, string setupInstructionMailAddress, int mailboxPlanId, string subscriberNumber)
string displayName, string name, string domain, string password, bool sendSetupInstructions, string setupInstructionMailAddress, int mailboxPlanId, int archivedPlanId, string subscriberNumber)
{
// check account
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
@ -1756,7 +1756,7 @@ namespace WebsitePanel.EnterpriseServer
| MailboxManagerActions.EmailAddresses;
UpdateExchangeAccount(accountId, accountName, accountType, displayName, email, false, pmmActions.ToString(), samAccount, password, mailboxPlanId, subscriberNumber);
UpdateExchangeAccount(accountId, accountName, accountType, displayName, email, false, pmmActions.ToString(), samAccount, password, mailboxPlanId, archivedPlanId, subscriberNumber);
@ -2600,7 +2600,7 @@ namespace WebsitePanel.EnterpriseServer
#region Mailbox plan
public static int SetExchangeMailboxPlan(int itemId, int accountId, int mailboxPlanId)
public static int SetExchangeMailboxPlan(int itemId, int accountId, int mailboxPlanId, int archivePlanId)
{
// check account
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
@ -2679,6 +2679,7 @@ namespace WebsitePanel.EnterpriseServer
int exchangeServiceId = GetExchangeServiceID(org.PackageId);
ExchangeServer exchange = GetExchangeServer(exchangeServiceId, org.ServiceId);
//TDMX
exchange.SetMailboxAdvancedSettings(
org.OrganizationId,
account.UserPrincipalName,
@ -2700,7 +2701,7 @@ namespace WebsitePanel.EnterpriseServer
plan.LitigationHoldUrl,
plan.LitigationHoldMsg);
DataProvider.SetExchangeAccountMailboxPlan(accountId, mailboxPlanId);
DataProvider.SetExchangeAccountMailboxPlan(accountId, mailboxPlanId, archivePlanId);
return 0;
}
@ -2714,7 +2715,7 @@ namespace WebsitePanel.EnterpriseServer
}
}
public static List<ExchangeMailboxPlan> GetExchangeMailboxPlans(int itemId)
public static List<ExchangeMailboxPlan> GetExchangeMailboxPlans(int itemId, bool archiving)
{
// place log record
TaskManager.StartTask("EXCHANGE", "GET_EXCHANGE_MAILBOXPLANS", itemId);
@ -2726,9 +2727,9 @@ namespace WebsitePanel.EnterpriseServer
UserInfo user = ObjectUtils.FillObjectFromDataReader<UserInfo>(DataProvider.GetUserByExchangeOrganizationIdInternally(itemId));
if (user.Role == UserRole.User)
ExchangeServerController.GetExchangeMailboxPlansByUser(itemId, user, ref mailboxPlans);
ExchangeServerController.GetExchangeMailboxPlansByUser(itemId, user, ref mailboxPlans, archiving);
else
ExchangeServerController.GetExchangeMailboxPlansByUser(0, user, ref mailboxPlans);
ExchangeServerController.GetExchangeMailboxPlansByUser(0, user, ref mailboxPlans, archiving);
ExchangeOrganization ExchangeOrg = ObjectUtils.FillObjectFromDataReader<ExchangeOrganization>(DataProvider.GetExchangeOrganization(itemId));
@ -2753,7 +2754,7 @@ namespace WebsitePanel.EnterpriseServer
}
}
private static void GetExchangeMailboxPlansByUser(int itemId, UserInfo user, ref List<ExchangeMailboxPlan> mailboxPlans)
private static void GetExchangeMailboxPlansByUser(int itemId, UserInfo user, ref List<ExchangeMailboxPlan> mailboxPlans, bool archiving)
{
if ((user != null))
{
@ -2780,7 +2781,7 @@ namespace WebsitePanel.EnterpriseServer
if (OrgId != -1)
{
List<ExchangeMailboxPlan> Plans = ObjectUtils.CreateListFromDataReader<ExchangeMailboxPlan>(DataProvider.GetExchangeMailboxPlans(OrgId));
List<ExchangeMailboxPlan> Plans = ObjectUtils.CreateListFromDataReader<ExchangeMailboxPlan>(DataProvider.GetExchangeMailboxPlans(OrgId, archiving));
foreach (ExchangeMailboxPlan p in Plans)
{
@ -2790,7 +2791,7 @@ namespace WebsitePanel.EnterpriseServer
UserInfo owner = UserController.GetUserInternally(user.OwnerId);
GetExchangeMailboxPlansByUser(0, owner, ref mailboxPlans);
GetExchangeMailboxPlansByUser(0, owner, ref mailboxPlans, archiving);
}
}
@ -2842,9 +2843,18 @@ namespace WebsitePanel.EnterpriseServer
if (mailboxPlan.KeepDeletedItemsDays > cntx.Quotas[Quotas.EXCHANGE2007_KEEPDELETEDITEMSDAYS].QuotaAllocatedValue)
mailboxPlan.KeepDeletedItemsDays = cntx.Quotas[Quotas.EXCHANGE2007_KEEPDELETEDITEMSDAYS].QuotaAllocatedValue;
if (cntx.Quotas[Quotas.EXCHANGE2007_DISKSPACE].QuotaAllocatedValue != -1)
if (mailboxPlan.MailboxSizeMB > cntx.Quotas[Quotas.EXCHANGE2007_DISKSPACE].QuotaAllocatedValue)
mailboxPlan.MailboxSizeMB = cntx.Quotas[Quotas.EXCHANGE2007_DISKSPACE].QuotaAllocatedValue;
if (mailboxPlan.Archiving)
{
if (cntx.Quotas[Quotas.EXCHANGE2013_ARCHIVINGSTORAGE].QuotaAllocatedValue != -1)
if (mailboxPlan.MailboxSizeMB > cntx.Quotas[Quotas.EXCHANGE2013_ARCHIVINGSTORAGE].QuotaAllocatedValue)
mailboxPlan.MailboxSizeMB = cntx.Quotas[Quotas.EXCHANGE2013_ARCHIVINGSTORAGE].QuotaAllocatedValue;
}
else
{
if (cntx.Quotas[Quotas.EXCHANGE2007_DISKSPACE].QuotaAllocatedValue != -1)
if (mailboxPlan.MailboxSizeMB > cntx.Quotas[Quotas.EXCHANGE2007_DISKSPACE].QuotaAllocatedValue)
mailboxPlan.MailboxSizeMB = cntx.Quotas[Quotas.EXCHANGE2007_DISKSPACE].QuotaAllocatedValue;
}
if (cntx.Quotas[Quotas.EXCHANGE2007_MAXRECEIVEMESSAGESIZEKB].QuotaAllocatedValue != -1)
if (mailboxPlan.MaxReceiveMessageSizeKB > cntx.Quotas[Quotas.EXCHANGE2007_MAXRECEIVEMESSAGESIZEKB].QuotaAllocatedValue)
@ -2871,7 +2881,7 @@ namespace WebsitePanel.EnterpriseServer
mailboxPlan.IsDefault, mailboxPlan.IssueWarningPct, mailboxPlan.KeepDeletedItemsDays, mailboxPlan.MailboxSizeMB, mailboxPlan.MaxReceiveMessageSizeKB, mailboxPlan.MaxRecipients,
mailboxPlan.MaxSendMessageSizeKB, mailboxPlan.ProhibitSendPct, mailboxPlan.ProhibitSendReceivePct, mailboxPlan.HideFromAddressBook, mailboxPlan.MailboxPlanType,
mailboxPlan.AllowLitigationHold, mailboxPlan.RecoverableItemsSpace, mailboxPlan.RecoverableItemsWarningPct,
mailboxPlan.LitigationHoldUrl, mailboxPlan.LitigationHoldMsg);
mailboxPlan.LitigationHoldUrl, mailboxPlan.LitigationHoldMsg, mailboxPlan.Archiving);
}
catch (Exception ex)
{

View file

@ -1314,7 +1314,7 @@ namespace WebsitePanel.EnterpriseServer
DataSet ds =
DataProvider.GetExchangeAccountsPaged(SecurityContext.User.UserId, itemId, accountTypes, filterColumn,
filterValue, sortColumn, startRow, maximumRows);
filterValue, sortColumn, startRow, maximumRows, false);
OrganizationUsersPaged result = new OrganizationUsersPaged();
result.RecordsCount = (int)ds.Tables[0].Rows[0][0];
@ -2078,7 +2078,7 @@ namespace WebsitePanel.EnterpriseServer
{
DataProvider.UpdateExchangeAccount(account.AccountId, account.AccountName, account.AccountType, account.DisplayName,
account.PrimaryEmailAddress, account.MailEnabledPublicFolder,
account.MailboxManagerActions.ToString(), account.SamAccountName, account.AccountPassword, account.MailboxPlanId,
account.MailboxManagerActions.ToString(), account.SamAccountName, account.AccountPassword, account.MailboxPlanId, account.ArchivingMailboxPlanId,
(string.IsNullOrEmpty(account.SubscriberNumber) ? null : account.SubscriberNumber.Trim()));
}
@ -2635,7 +2635,7 @@ namespace WebsitePanel.EnterpriseServer
DataSet ds =
DataProvider.GetExchangeAccountsPaged(SecurityContext.User.UserId, itemId, accountTypes, filterColumn,
filterValue, sortColumn, startRow, maximumRows);
filterValue, sortColumn, startRow, maximumRows, false);
ExchangeAccountsPaged result = new ExchangeAccountsPaged();
result.RecordsCount = (int)ds.Tables[0].Rows[0][0];