This commit is contained in:
Virtuworks 2015-05-13 09:47:27 -04:00
commit 2220eba8c9

View file

@ -4479,7 +4479,7 @@ namespace WebsitePanel.Providers.HostedSolution
{ {
ExchangeLog.LogStart("CheckOrganizationPublicFolderMailbox"); ExchangeLog.LogStart("CheckOrganizationPublicFolderMailbox");
Collection<PSObject> result = GetPublicFolderMailbox(runSpace, orgCanonicalName, GetPublicFolderMailboxName(organizationId)); Collection<PSObject> result = GetPublicFolderMailbox(runSpace, orgCanonicalName, GetPublicFolderMailboxName(organizationId), true);
if (result == null || result.Count == 0) if (result == null || result.Count == 0)
{ {
ExchangeTransaction transaction = StartTransaction(); ExchangeTransaction transaction = StartTransaction();
@ -4501,7 +4501,7 @@ namespace WebsitePanel.Providers.HostedSolution
{ {
ExchangeLog.LogStart("CheckOrganizationRootFolder"); ExchangeLog.LogStart("CheckOrganizationRootFolder");
Collection<PSObject> result = GetPublicFolderObject(runSpace, orgCanonicalName+"/"+GetPublicFolderMailboxName(organizationId), "\\" + folder); Collection<PSObject> result = GetPublicFolderObject(runSpace, orgCanonicalName+"/"+GetPublicFolderMailboxName(organizationId), "\\" + folder, true);
if (result == null || result.Count == 0) if (result == null || result.Count == 0)
{ {
ExchangeTransaction transaction = StartTransaction(); ExchangeTransaction transaction = StartTransaction();
@ -4617,22 +4617,22 @@ namespace WebsitePanel.Providers.HostedSolution
ExchangeLog.LogEnd("DeletePublicFolderInternal"); ExchangeLog.LogEnd("DeletePublicFolderInternal");
} }
private Collection<PSObject> GetPublicFolderObject(Runspace runSpace, string mailbox, string id) private Collection<PSObject> GetPublicFolderObject(Runspace runSpace, string mailbox, string id, bool checkExist = false)
{ {
Command cmd = new Command("Get-PublicFolder"); Command cmd = new Command("Get-PublicFolder");
cmd.Parameters.Add("Identity", id); cmd.Parameters.Add("Identity", id);
//cmd.Parameters.Add("Mailbox", mailbox); //cmd.Parameters.Add("Mailbox", mailbox);
Collection<PSObject> result = ExecuteShellCommand(runSpace, cmd); Collection<PSObject> result = ExecuteShellCommand(runSpace, cmd, true, !checkExist);
return result; return result;
} }
private Collection<PSObject> GetPublicFolderMailbox(Runspace runSpace, string organizationDistinguishedName, string name) private Collection<PSObject> GetPublicFolderMailbox(Runspace runSpace, string organizationDistinguishedName, string name, bool checkExist)
{ {
Command cmd = new Command("Get-Mailbox"); Command cmd = new Command("Get-Mailbox");
cmd.Parameters.Add("Identity", name); cmd.Parameters.Add("Identity", name);
cmd.Parameters.Add("PublicFolder"); cmd.Parameters.Add("PublicFolder");
cmd.Parameters.Add("OrganizationalUnit", organizationDistinguishedName); cmd.Parameters.Add("OrganizationalUnit", organizationDistinguishedName);
Collection<PSObject> result = ExecuteShellCommand(runSpace, cmd); Collection<PSObject> result = ExecuteShellCommand(runSpace, cmd, true, !checkExist);
return result; return result;
} }
@ -5369,7 +5369,7 @@ namespace WebsitePanel.Providers.HostedSolution
string resultObjectDN = null; string resultObjectDN = null;
Command cmd = new Command("Get-AddressList"); Command cmd = new Command("Get-AddressList");
cmd.Parameters.Add("Identity", id); cmd.Parameters.Add("Identity", id);
Collection<PSObject> result = this.ExecuteShellCommand(runSpace, cmd); Collection<PSObject> result = this.ExecuteShellCommand(runSpace, cmd, true, false);
if ((result != null) && (result.Count > 0)) if ((result != null) && (result.Count > 0))
{ {
resultObjectDN = this.GetResultObjectDN(result); resultObjectDN = this.GetResultObjectDN(result);
@ -6242,13 +6242,19 @@ namespace WebsitePanel.Providers.HostedSolution
internal Collection<PSObject> ExecuteShellCommand(Runspace runSpace, Command cmd) internal Collection<PSObject> ExecuteShellCommand(Runspace runSpace, Command cmd)
{ {
return ExecuteShellCommand(runSpace, cmd, true); return ExecuteShellCommand(runSpace, cmd, true, true);
} }
internal Collection<PSObject> ExecuteShellCommand(Runspace runSpace, Command cmd, bool useDomainController) internal Collection<PSObject> ExecuteShellCommand(Runspace runSpace, Command cmd, bool useDomainController)
{ {
object[] errors; object[] errors;
return ExecuteShellCommand(runSpace, cmd, useDomainController, out errors); return ExecuteShellCommand(runSpace, cmd, useDomainController, out errors, true);
}
internal Collection<PSObject> ExecuteShellCommand(Runspace runSpace, Command cmd, bool useDomainController, bool writeErrorExchangeLog)
{
object[] errors;
return ExecuteShellCommand(runSpace, cmd, useDomainController, out errors, writeErrorExchangeLog);
} }
internal Collection<PSObject> ExecuteShellCommand(Runspace runSpace, Command cmd, ResultObject res) internal Collection<PSObject> ExecuteShellCommand(Runspace runSpace, Command cmd, ResultObject res)
@ -6272,10 +6278,10 @@ namespace WebsitePanel.Providers.HostedSolution
internal Collection<PSObject> ExecuteShellCommand(Runspace runSpace, Command cmd, out object[] errors) internal Collection<PSObject> ExecuteShellCommand(Runspace runSpace, Command cmd, out object[] errors)
{ {
return ExecuteShellCommand(runSpace, cmd, true, out errors); return ExecuteShellCommand(runSpace, cmd, true, out errors, true);
} }
internal Collection<PSObject> ExecuteShellCommand(Runspace runSpace, Command cmd, bool useDomainController, out object[] errors) internal Collection<PSObject> ExecuteShellCommand(Runspace runSpace, Command cmd, bool useDomainController, out object[] errors, bool writeErrorExchangeLog)
{ {
ExchangeLog.LogStart("ExecuteShellCommand"); ExchangeLog.LogStart("ExecuteShellCommand");
List<object> errorList = new List<object>(); List<object> errorList = new List<object>();
@ -6309,11 +6315,15 @@ namespace WebsitePanel.Providers.HostedSolution
foreach (object item in pipeLine.Error.ReadToEnd()) foreach (object item in pipeLine.Error.ReadToEnd())
{ {
errorList.Add(item); errorList.Add(item);
if (writeErrorExchangeLog)
{
string errorMessage = string.Format("Invoke error: {0}", item); string errorMessage = string.Format("Invoke error: {0}", item);
ExchangeLog.LogWarning(errorMessage); ExchangeLog.LogWarning(errorMessage);
} }
} }
} }
}
pipeLine = null; pipeLine = null;
errors = errorList.ToArray(); errors = errorList.ToArray();
ExchangeLog.LogEnd("ExecuteShellCommand"); ExchangeLog.LogEnd("ExecuteShellCommand");