Fixed bugs with adding new mapped drive and when rename folder. Added new functionality - change folder path for mapped drive, when rename folder.
This commit is contained in:
parent
5f412a78d3
commit
34f2d2bb4f
6 changed files with 175 additions and 33 deletions
|
@ -403,14 +403,20 @@ namespace WebsitePanel.EnterpriseServer
|
||||||
EnterpriseStorage es = GetEnterpriseStorage(GetEnterpriseStorageServiceID(org.PackageId));
|
EnterpriseStorage es = GetEnterpriseStorage(GetEnterpriseStorageServiceID(org.PackageId));
|
||||||
|
|
||||||
var webDavSetting = ObjectUtils.FillObjectFromDataReader<WebDavSetting>(
|
var webDavSetting = ObjectUtils.FillObjectFromDataReader<WebDavSetting>(
|
||||||
DataProvider.GetEnterpriseFolder(itemId, oldFolder));
|
DataProvider.GetEnterpriseFolder(itemId, newFolder));
|
||||||
|
|
||||||
if (webDavSetting == null)
|
bool folderExists = es.GetFolder(org.OrganizationId, newFolder, webDavSetting) != null;
|
||||||
|
|
||||||
|
if (!folderExists)
|
||||||
{
|
{
|
||||||
SystemFile folder = es.RenameFolder(org.OrganizationId, oldFolder, newFolder, webDavSetting);
|
SystemFile folder = es.RenameFolder(org.OrganizationId, oldFolder, newFolder, webDavSetting);
|
||||||
|
|
||||||
DataProvider.UpdateEnterpriseFolder(itemId, oldFolder, newFolder, folder.FRSMQuotaGB);
|
DataProvider.UpdateEnterpriseFolder(itemId, oldFolder, newFolder, folder.FRSMQuotaGB);
|
||||||
|
|
||||||
|
Organizations orgProxy = OrganizationController.GetOrganizationProxy(org.ServiceId);
|
||||||
|
|
||||||
|
orgProxy.ChangeDriveMapFolderPath(org.OrganizationId, oldFolder, newFolder);
|
||||||
|
|
||||||
return folder;
|
return folder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1247,10 +1253,9 @@ namespace WebsitePanel.EnterpriseServer
|
||||||
|
|
||||||
if (esServiceId != 0)
|
if (esServiceId != 0)
|
||||||
{
|
{
|
||||||
var webDavSetting = ObjectUtils.FillObjectFromDataReader<WebDavSetting>(
|
StringDictionary esSesstings = ServerController.GetServiceSettings(esServiceId);
|
||||||
DataProvider.GetEnterpriseFolder(itemId, folderName));
|
|
||||||
|
|
||||||
string path = string.Format(@"\\{0}@SSL\{1}\{2}", webDavSetting.Domain.Split('.')[0], org.OrganizationId, folderName);
|
string path = string.Format(@"\\{0}@SSL\{1}\{2}", esSesstings["UsersDomain"].Split('.')[0], org.OrganizationId, folderName);
|
||||||
|
|
||||||
Organizations orgProxy = OrganizationController.GetOrganizationProxy(org.ServiceId);
|
Organizations orgProxy = OrganizationController.GetOrganizationProxy(org.ServiceId);
|
||||||
|
|
||||||
|
|
|
@ -91,5 +91,7 @@ namespace WebsitePanel.Providers.HostedSolution
|
||||||
void DeleteMappedDrivesGPO(string organizationId);
|
void DeleteMappedDrivesGPO(string organizationId);
|
||||||
|
|
||||||
void SetDriveMapsTargetingFilter(string organizationId, ExchangeAccount[] accounts, string folderName);
|
void SetDriveMapsTargetingFilter(string organizationId, ExchangeAccount[] accounts, string folderName);
|
||||||
|
|
||||||
|
void ChangeDriveMapFolderPath(string organizationId, string oldFolder, string newFolder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1317,8 +1317,6 @@ namespace WebsitePanel.Providers.HostedSolution
|
||||||
{
|
{
|
||||||
runSpace = OpenRunspace();
|
runSpace = OpenRunspace();
|
||||||
|
|
||||||
//ImportGroupPolicyMolude(runSpace);
|
|
||||||
|
|
||||||
string gpoName = string.Format("{0}-mapped-drives", organizationId);
|
string gpoName = string.Format("{0}-mapped-drives", organizationId);
|
||||||
|
|
||||||
//create new gpo
|
//create new gpo
|
||||||
|
@ -1330,6 +1328,8 @@ namespace WebsitePanel.Providers.HostedSolution
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
CloseRunspace(runSpace);
|
CloseRunspace(runSpace);
|
||||||
|
|
||||||
|
throw;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -1362,9 +1362,6 @@ namespace WebsitePanel.Providers.HostedSolution
|
||||||
{
|
{
|
||||||
runSpace = OpenRunspace();
|
runSpace = OpenRunspace();
|
||||||
|
|
||||||
//import grouppolicy module
|
|
||||||
//ImportGroupPolicyMolude(runSpace);
|
|
||||||
|
|
||||||
Dictionary<string, ExchangeAccount> sidAccountPairs = new Dictionary<string, ExchangeAccount>();
|
Dictionary<string, ExchangeAccount> sidAccountPairs = new Dictionary<string, ExchangeAccount>();
|
||||||
|
|
||||||
Command cmd;
|
Command cmd;
|
||||||
|
@ -1445,7 +1442,9 @@ namespace WebsitePanel.Providers.HostedSolution
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
CloseRunspace(runSpace);
|
||||||
|
|
||||||
|
throw;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -1455,6 +1454,70 @@ namespace WebsitePanel.Providers.HostedSolution
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ChangeDriveMapFolderPath(string organizationId, string oldFolder, string newFolder)
|
||||||
|
{
|
||||||
|
ChangeDriveMapFolderPathInternal(organizationId, oldFolder, newFolder);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void ChangeDriveMapFolderPathInternal(string organizationId, string oldFolder, string newFolder)
|
||||||
|
{
|
||||||
|
HostedSolutionLog.LogStart("ChangeDriveMapFolderPathInternal");
|
||||||
|
HostedSolutionLog.DebugInfo("organizationId : {0}", organizationId);
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(organizationId))
|
||||||
|
throw new ArgumentNullException("organizationId");
|
||||||
|
|
||||||
|
Runspace runSpace = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
runSpace = OpenRunspace();
|
||||||
|
|
||||||
|
string gpoId;
|
||||||
|
|
||||||
|
if (!CheckMappedDriveGpoExists(organizationId, out gpoId))
|
||||||
|
{
|
||||||
|
CreateAndLinkMappedDrivesGPO(organizationId, out gpoId);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(gpoId))
|
||||||
|
{
|
||||||
|
string drivesXmlPath = string.Format("{0}\\{1}",
|
||||||
|
string.Format(GROUP_POLICY_MAPPED_DRIVES_FILE_PATH_TEMPLATE, RootDomain, gpoId),
|
||||||
|
"Drives.xml");
|
||||||
|
// open xml document
|
||||||
|
XmlDocument xml = new XmlDocument();
|
||||||
|
xml.Load(drivesXmlPath);
|
||||||
|
|
||||||
|
XmlNodeList drives = xml.SelectNodes(string.Format("./Drives/Drive[contains(Properties/@path,'{0}')]", oldFolder));
|
||||||
|
|
||||||
|
foreach (XmlNode driveNode in drives)
|
||||||
|
{
|
||||||
|
if (driveNode.ChildNodes.Count > 1)
|
||||||
|
{
|
||||||
|
string oldPath = driveNode.FirstChild.Attributes["path"].Value;
|
||||||
|
|
||||||
|
driveNode.FirstChild.Attributes["path"].Value = oldPath.Replace(oldFolder, newFolder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
xml.Save(drivesXmlPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
CloseRunspace(runSpace);
|
||||||
|
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
CloseRunspace(runSpace);
|
||||||
|
|
||||||
|
HostedSolutionLog.LogEnd("ChangeDriveMapFolderPathInternal");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void CreateAndLinkMappedDrivesGPO(string organizationId, out string gpoId)
|
private void CreateAndLinkMappedDrivesGPO(string organizationId, out string gpoId)
|
||||||
{
|
{
|
||||||
Runspace runSpace = null;
|
Runspace runSpace = null;
|
||||||
|
@ -1463,8 +1526,6 @@ namespace WebsitePanel.Providers.HostedSolution
|
||||||
{
|
{
|
||||||
runSpace = OpenRunspace();
|
runSpace = OpenRunspace();
|
||||||
|
|
||||||
//ImportGroupPolicyMolude(runSpace);
|
|
||||||
|
|
||||||
string gpoName = string.Format("{0}-mapped-drives", organizationId);
|
string gpoName = string.Format("{0}-mapped-drives", organizationId);
|
||||||
string pathOU = GetOrganizationTargetPath(organizationId);
|
string pathOU = GetOrganizationTargetPath(organizationId);
|
||||||
|
|
||||||
|
@ -1498,6 +1559,8 @@ namespace WebsitePanel.Providers.HostedSolution
|
||||||
{
|
{
|
||||||
gpoId = null;
|
gpoId = null;
|
||||||
CloseRunspace(runSpace);
|
CloseRunspace(runSpace);
|
||||||
|
|
||||||
|
throw;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -1513,8 +1576,6 @@ namespace WebsitePanel.Providers.HostedSolution
|
||||||
{
|
{
|
||||||
runSpace = OpenRunspace();
|
runSpace = OpenRunspace();
|
||||||
|
|
||||||
//ImportGroupPolicyMolude(runSpace);
|
|
||||||
|
|
||||||
string gpoName = string.Format("{0}-mapped-drives", organizationId);
|
string gpoName = string.Format("{0}-mapped-drives", organizationId);
|
||||||
|
|
||||||
Command cmd = new Command("Get-GPO");
|
Command cmd = new Command("Get-GPO");
|
||||||
|
@ -1530,6 +1591,13 @@ namespace WebsitePanel.Providers.HostedSolution
|
||||||
gpoId = ((Guid)GetPSObjectProperty(gpo, "Id")).ToString("B");
|
gpoId = ((Guid)GetPSObjectProperty(gpo, "Id")).ToString("B");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
gpoId = null;
|
||||||
|
CloseRunspace(runSpace);
|
||||||
|
|
||||||
|
throw;
|
||||||
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
CloseRunspace(runSpace);
|
CloseRunspace(runSpace);
|
||||||
|
@ -1558,22 +1626,6 @@ namespace WebsitePanel.Providers.HostedSolution
|
||||||
|
|
||||||
#region Drive Mapping Helpers
|
#region Drive Mapping Helpers
|
||||||
|
|
||||||
private void ImportGroupPolicyMolude(Runspace runSpace)
|
|
||||||
{
|
|
||||||
Command cmd = new Command("Import-Module");
|
|
||||||
cmd.Parameters.Add("Name", "grouppolicy");
|
|
||||||
|
|
||||||
ExecuteShellCommand(runSpace, cmd);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ImportActiveDirectoryMolude(Runspace runSpace)
|
|
||||||
{
|
|
||||||
Command cmd = new Command("Import-Module");
|
|
||||||
cmd.Parameters.Add("Name", "ActiveDirectory");
|
|
||||||
|
|
||||||
ExecuteShellCommand(runSpace, cmd);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CreateDrivesXmlEmpty(string path, string fileName)
|
private void CreateDrivesXmlEmpty(string path, string fileName)
|
||||||
{
|
{
|
||||||
DirectoryInfo drivesDirectory = new DirectoryInfo(path);
|
DirectoryInfo drivesDirectory = new DirectoryInfo(path);
|
||||||
|
@ -1747,6 +1799,22 @@ namespace WebsitePanel.Providers.HostedSolution
|
||||||
|
|
||||||
#region PowerShell integration
|
#region PowerShell integration
|
||||||
|
|
||||||
|
internal void ImportGroupPolicyMolude(Runspace runSpace)
|
||||||
|
{
|
||||||
|
Command cmd = new Command("Import-Module");
|
||||||
|
cmd.Parameters.Add("Name", "grouppolicy");
|
||||||
|
|
||||||
|
ExecuteShellCommand(runSpace, cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void ImportActiveDirectoryMolude(Runspace runSpace)
|
||||||
|
{
|
||||||
|
Command cmd = new Command("Import-Module");
|
||||||
|
cmd.Parameters.Add("Name", "ActiveDirectory");
|
||||||
|
|
||||||
|
ExecuteShellCommand(runSpace, cmd);
|
||||||
|
}
|
||||||
|
|
||||||
private static RunspaceConfiguration runspaceConfiguration = null;
|
private static RunspaceConfiguration runspaceConfiguration = null;
|
||||||
|
|
||||||
internal virtual Runspace OpenRunspace()
|
internal virtual Runspace OpenRunspace()
|
||||||
|
|
|
@ -118,6 +118,8 @@ namespace WebsitePanel.Providers.HostedSolution
|
||||||
|
|
||||||
private System.Threading.SendOrPostCallback SetDriveMapsTargetingFilterOperationCompleted;
|
private System.Threading.SendOrPostCallback SetDriveMapsTargetingFilterOperationCompleted;
|
||||||
|
|
||||||
|
private System.Threading.SendOrPostCallback ChangeDriveMapFolderPathOperationCompleted;
|
||||||
|
|
||||||
/// <remarks/>
|
/// <remarks/>
|
||||||
public Organizations()
|
public Organizations()
|
||||||
{
|
{
|
||||||
|
@ -202,6 +204,9 @@ namespace WebsitePanel.Providers.HostedSolution
|
||||||
/// <remarks/>
|
/// <remarks/>
|
||||||
public event SetDriveMapsTargetingFilterCompletedEventHandler SetDriveMapsTargetingFilterCompleted;
|
public event SetDriveMapsTargetingFilterCompletedEventHandler SetDriveMapsTargetingFilterCompleted;
|
||||||
|
|
||||||
|
/// <remarks/>
|
||||||
|
public event ChangeDriveMapFolderPathCompletedEventHandler ChangeDriveMapFolderPathCompleted;
|
||||||
|
|
||||||
/// <remarks/>
|
/// <remarks/>
|
||||||
[System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")]
|
[System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")]
|
||||||
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/OrganizationExists", RequestNamespace = "http://tempuri.org/", ResponseNamespace = "http://tempuri.org/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
|
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/OrganizationExists", RequestNamespace = "http://tempuri.org/", ResponseNamespace = "http://tempuri.org/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
|
||||||
|
@ -1758,6 +1763,60 @@ namespace WebsitePanel.Providers.HostedSolution
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <remarks/>
|
||||||
|
[System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")]
|
||||||
|
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/ChangeDriveMapFolderPath", RequestNamespace = "http://tempuri.org/", ResponseNamespace = "http://tempuri.org/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
|
||||||
|
public void ChangeDriveMapFolderPath(string organizationId, string oldFolder, string newFolder)
|
||||||
|
{
|
||||||
|
this.Invoke("ChangeDriveMapFolderPath", new object[] {
|
||||||
|
organizationId,
|
||||||
|
oldFolder,
|
||||||
|
newFolder});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <remarks/>
|
||||||
|
public System.IAsyncResult BeginChangeDriveMapFolderPath(string organizationId, string oldFolder, string newFolder, System.AsyncCallback callback, object asyncState)
|
||||||
|
{
|
||||||
|
return this.BeginInvoke("ChangeDriveMapFolderPath", new object[] {
|
||||||
|
organizationId,
|
||||||
|
oldFolder,
|
||||||
|
newFolder}, callback, asyncState);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <remarks/>
|
||||||
|
public void EndChangeDriveMapFolderPath(System.IAsyncResult asyncResult)
|
||||||
|
{
|
||||||
|
this.EndInvoke(asyncResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <remarks/>
|
||||||
|
public void ChangeDriveMapFolderPathAsync(string organizationId, string oldFolder, string newFolder)
|
||||||
|
{
|
||||||
|
this.ChangeDriveMapFolderPathAsync(organizationId, oldFolder, newFolder, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <remarks/>
|
||||||
|
public void ChangeDriveMapFolderPathAsync(string organizationId, string oldFolder, string newFolder, object userState)
|
||||||
|
{
|
||||||
|
if ((this.ChangeDriveMapFolderPathOperationCompleted == null))
|
||||||
|
{
|
||||||
|
this.ChangeDriveMapFolderPathOperationCompleted = new System.Threading.SendOrPostCallback(this.OnChangeDriveMapFolderPathOperationCompleted);
|
||||||
|
}
|
||||||
|
this.InvokeAsync("ChangeDriveMapFolderPath", new object[] {
|
||||||
|
organizationId,
|
||||||
|
oldFolder,
|
||||||
|
newFolder}, this.ChangeDriveMapFolderPathOperationCompleted, userState);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnChangeDriveMapFolderPathOperationCompleted(object arg)
|
||||||
|
{
|
||||||
|
if ((this.ChangeDriveMapFolderPathCompleted != null))
|
||||||
|
{
|
||||||
|
System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
|
||||||
|
this.ChangeDriveMapFolderPathCompleted(this, new System.ComponentModel.AsyncCompletedEventArgs(invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <remarks/>
|
/// <remarks/>
|
||||||
public new void CancelAsync(object userState)
|
public new void CancelAsync(object userState)
|
||||||
{
|
{
|
||||||
|
@ -2154,4 +2213,8 @@ namespace WebsitePanel.Providers.HostedSolution
|
||||||
/// <remarks/>
|
/// <remarks/>
|
||||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")]
|
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")]
|
||||||
public delegate void SetDriveMapsTargetingFilterCompletedEventHandler(object sender, System.ComponentModel.AsyncCompletedEventArgs e);
|
public delegate void SetDriveMapsTargetingFilterCompletedEventHandler(object sender, System.ComponentModel.AsyncCompletedEventArgs e);
|
||||||
|
|
||||||
|
/// <remarks/>
|
||||||
|
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")]
|
||||||
|
public delegate void ChangeDriveMapFolderPathCompletedEventHandler(object sender, System.ComponentModel.AsyncCompletedEventArgs e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -241,5 +241,11 @@ namespace WebsitePanel.Server
|
||||||
{
|
{
|
||||||
Organization.SetDriveMapsTargetingFilter(organizationId, accounts, folderName);
|
Organization.SetDriveMapsTargetingFilter(organizationId, accounts, folderName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[WebMethod, SoapHeader("settings")]
|
||||||
|
public void ChangeDriveMapFolderPath(string organizationId, string oldFolder, string newFolder)
|
||||||
|
{
|
||||||
|
Organization.ChangeDriveMapFolderPath(organizationId, oldFolder, newFolder);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,8 +143,6 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
|
||||||
ExchangeAccount[] accounts = ES.Services.EnterpriseStorage.SearchESAccounts(PanelRequest.ItemID,
|
ExchangeAccount[] accounts = ES.Services.EnterpriseStorage.SearchESAccounts(PanelRequest.ItemID,
|
||||||
ddlSearchColumn.SelectedValue, txtSearchValue.Text + "%", "");
|
ddlSearchColumn.SelectedValue, txtSearchValue.Text + "%", "");
|
||||||
|
|
||||||
//List<ExchangeAccount> newAccounts = new List<ExchangeAccount>();
|
|
||||||
|
|
||||||
accounts = accounts.Where(x => !GetPemissions().Select(p => p.Account).Contains(x.AccountName)).ToArray();
|
accounts = accounts.Where(x => !GetPemissions().Select(p => p.Account).Contains(x.AccountName)).ToArray();
|
||||||
Array.Sort(accounts, CompareAccount);
|
Array.Sort(accounts, CompareAccount);
|
||||||
if (Direction == SortDirection.Ascending)
|
if (Direction == SortDirection.Ascending)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue