This commit is contained in:
Virtuworks 2015-04-22 13:51:48 -04:00
commit 2eb71ad76e
5 changed files with 57 additions and 47 deletions

View file

@ -1650,12 +1650,12 @@ namespace WebsitePanel.EnterpriseServer
return result; return result;
} }
public static ResultObject DeleteMappedDrive(int itemId, string driveLetter) public static ResultObject DeleteMappedDrive(int itemId, string folderName)
{ {
return DeleteMappedDriveInternal(itemId, driveLetter); return DeleteMappedDriveInternal(itemId, folderName);
} }
protected static ResultObject DeleteMappedDriveInternal(int itemId, string driveLetter) protected static ResultObject DeleteMappedDriveInternal(int itemId, string folderName)
{ {
ResultObject result = TaskManager.StartResultTask<ResultObject>("ENTERPRISE_STORAGE", "DELETE_MAPPED_DRIVE", itemId); ResultObject result = TaskManager.StartResultTask<ResultObject>("ENTERPRISE_STORAGE", "DELETE_MAPPED_DRIVE", itemId);
@ -1670,9 +1670,13 @@ namespace WebsitePanel.EnterpriseServer
return result; return result;
} }
var webDavSetting = ObjectUtils.FillObjectFromDataReader<WebDavSetting>(DataProvider.GetEnterpriseFolder(itemId, folderName));
string path = string.Format(@"\\{0}@SSL\{1}\{2}", webDavSetting.Domain.Split('.')[0], org.OrganizationId, folderName);
Organizations orgProxy = OrganizationController.GetOrganizationProxy(org.ServiceId); Organizations orgProxy = OrganizationController.GetOrganizationProxy(org.ServiceId);
orgProxy.DeleteMappedDrive(org.OrganizationId, driveLetter); orgProxy.DeleteMappedDriveByPath(org.OrganizationId, path);
} }
catch (Exception ex) catch (Exception ex)
{ {

View file

@ -1680,12 +1680,46 @@ namespace WebsitePanel.Providers.HostedSolution
internal void DeleteMappedDriveByPathInternal(string organizationId, string path) internal void DeleteMappedDriveByPathInternal(string organizationId, string path)
{ {
MappedDrive drive = GetDriveMaps(organizationId).Where(x => x.Path == path).FirstOrDefault(); HostedSolutionLog.LogStart("DeleteMappedDriveInternal");
HostedSolutionLog.DebugInfo("path : {0}:", path);
HostedSolutionLog.DebugInfo("organizationId : {0}", organizationId);
if (drive != null) if (string.IsNullOrEmpty(organizationId))
{ throw new ArgumentNullException("organizationId");
DeleteMappedDriveInternal(organizationId, drive.DriveLetter);
} if (string.IsNullOrEmpty(path))
throw new ArgumentNullException("path");
string gpoId;
if (!CheckMappedDriveGpoExists(organizationId, out gpoId))
{
CreateAndLinkMappedDrivesGPO(organizationId, out gpoId);
}
if (!string.IsNullOrEmpty(gpoId))
{
string filePath = 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(filePath);
XmlNode drive = xml.SelectSingleNode(string.Format("./Drives/Drive[contains(Properties/@path,'{0}')]", path));
if (drive != null)
{
drive.ParentNode.RemoveChild(drive);
}
xml.Save(filePath);
IncrementGPOVersion(organizationId, gpoId);
}
HostedSolutionLog.LogEnd("DeleteMappedDriveInternal");
} }
public void DeleteMappedDrive(string organizationId, string drive) public void DeleteMappedDrive(string organizationId, string drive)

View file

@ -75,16 +75,16 @@ namespace WebsitePanel.Portal.ExchangeServer
ddlLetters.Items.Add(new ListItem(Convert.ToChar(i).ToString() + ":", Convert.ToChar(i).ToString()));// Add uppercase letters to possible drive letters ddlLetters.Items.Add(new ListItem(Convert.ToChar(i).ToString() + ":", Convert.ToChar(i).ToString()));// Add uppercase letters to possible drive letters
} }
string[] usedLetters = ES.Services.EnterpriseStorage.GetUsedDriveLetters(PanelRequest.ItemID); //string[] usedLetters = ES.Services.EnterpriseStorage.GetUsedDriveLetters(PanelRequest.ItemID);
foreach (string elem in usedLetters) //foreach (string elem in usedLetters)
{ //{
ListItem item = new ListItem(elem + ":", elem); // ListItem item = new ListItem(elem + ":", elem);
if (ddlLetters.Items.Contains(item)) // if (ddlLetters.Items.Contains(item))
{ // {
ddlLetters.Items.Remove(item); // ddlLetters.Items.Remove(item);
} // }
} //}
} }
protected void btnCreate_Click(object sender, EventArgs e) protected void btnCreate_Click(object sender, EventArgs e)

View file

@ -66,7 +66,7 @@
<asp:TemplateField> <asp:TemplateField>
<ItemTemplate> <ItemTemplate>
<asp:ImageButton ID="imgDelDriveMap" runat="server" Text="Delete" SkinID="ExchangeDelete" <asp:ImageButton ID="imgDelDriveMap" runat="server" Text="Delete" SkinID="ExchangeDelete"
CommandName="DeleteItem" CommandArgument='<%# Eval("DriveLetter") %>' CommandName="DeleteItem" CommandArgument='<%# Eval("Folder.Name") %>'
meta:resourcekey="cmdDelete" OnClientClick="return confirm('Are you sure you want to delete selected map drive?')"></asp:ImageButton> meta:resourcekey="cmdDelete" OnClientClick="return confirm('Are you sure you want to delete selected map drive?')"></asp:ImageButton>
</ItemTemplate> </ItemTemplate>
</asp:TemplateField> </asp:TemplateField>

View file

@ -1,31 +1,3 @@
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// - Neither the name of the Outercurve Foundation nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.