webdav portal search fixes

This commit is contained in:
vfedosevich 2015-02-25 04:25:33 -08:00
parent 346059195e
commit e006009b1b
9 changed files with 72 additions and 65 deletions

View file

@ -1029,10 +1029,10 @@ namespace WebsitePanel.EnterpriseServer {
/// <remarks/> /// <remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/enterpriseserver/SearchFiles", RequestNamespace="http://smbsaas/websitepanel/enterpriseserver", ResponseNamespace="http://smbsaas/websitepanel/enterpriseserver", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/enterpriseserver/SearchFiles", RequestNamespace="http://smbsaas/websitepanel/enterpriseserver", ResponseNamespace="http://smbsaas/websitepanel/enterpriseserver", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public SystemFile[] SearchFiles(int itemId, string searchPath, string searchText, string userPrincipalName, bool recursive) { public SystemFile[] SearchFiles(int itemId, string[] searchPaths, string searchText, string userPrincipalName, bool recursive) {
object[] results = this.Invoke("SearchFiles", new object[] { object[] results = this.Invoke("SearchFiles", new object[] {
itemId, itemId,
searchPath, searchPaths,
searchText, searchText,
userPrincipalName, userPrincipalName,
recursive}); recursive});
@ -1040,10 +1040,10 @@ namespace WebsitePanel.EnterpriseServer {
} }
/// <remarks/> /// <remarks/>
public System.IAsyncResult BeginSearchFiles(int itemId, string searchPath, string searchText, string userPrincipalName, bool recursive, System.AsyncCallback callback, object asyncState) { public System.IAsyncResult BeginSearchFiles(int itemId, string[] searchPaths, string searchText, string userPrincipalName, bool recursive, System.AsyncCallback callback, object asyncState) {
return this.BeginInvoke("SearchFiles", new object[] { return this.BeginInvoke("SearchFiles", new object[] {
itemId, itemId,
searchPath, searchPaths,
searchText, searchText,
userPrincipalName, userPrincipalName,
recursive}, callback, asyncState); recursive}, callback, asyncState);
@ -1056,18 +1056,18 @@ namespace WebsitePanel.EnterpriseServer {
} }
/// <remarks/> /// <remarks/>
public void SearchFilesAsync(int itemId, string searchPath, string searchText, string userPrincipalName, bool recursive) { public void SearchFilesAsync(int itemId, string[] searchPaths, string searchText, string userPrincipalName, bool recursive) {
this.SearchFilesAsync(itemId, searchPath, searchText, userPrincipalName, recursive, null); this.SearchFilesAsync(itemId, searchPaths, searchText, userPrincipalName, recursive, null);
} }
/// <remarks/> /// <remarks/>
public void SearchFilesAsync(int itemId, string searchPath, string searchText, string userPrincipalName, bool recursive, object userState) { public void SearchFilesAsync(int itemId, string[] searchPaths, string searchText, string userPrincipalName, bool recursive, object userState) {
if ((this.SearchFilesOperationCompleted == null)) { if ((this.SearchFilesOperationCompleted == null)) {
this.SearchFilesOperationCompleted = new System.Threading.SendOrPostCallback(this.OnSearchFilesOperationCompleted); this.SearchFilesOperationCompleted = new System.Threading.SendOrPostCallback(this.OnSearchFilesOperationCompleted);
} }
this.InvokeAsync("SearchFiles", new object[] { this.InvokeAsync("SearchFiles", new object[] {
itemId, itemId,
searchPath, searchPaths,
searchText, searchText,
userPrincipalName, userPrincipalName,
recursive}, this.SearchFilesOperationCompleted, userState); recursive}, this.SearchFilesOperationCompleted, userState);

View file

@ -172,7 +172,7 @@ namespace WebsitePanel.EnterpriseServer
return ObjectUtils.FillObjectFromDataReader<WebDavAccessToken>(DataProvider.GetWebDavAccessTokenByAccessToken(accessToken)); return ObjectUtils.FillObjectFromDataReader<WebDavAccessToken>(DataProvider.GetWebDavAccessTokenByAccessToken(accessToken));
} }
public static SystemFile[] SearchFiles(int itemId, string searchPath, string searchText, string userPrincipalName, bool recursive) public static SystemFile[] SearchFiles(int itemId, string[] searchPaths, string searchText, string userPrincipalName, bool recursive)
{ {
try try
{ {
@ -192,23 +192,7 @@ namespace WebsitePanel.EnterpriseServer
EnterpriseStorage es = GetEnterpriseStorage(serviceId); EnterpriseStorage es = GetEnterpriseStorage(serviceId);
var rootFolders = GetRootFolders(userPrincipalName).ToList(); return es.Search(org.OrganizationId, searchPaths, searchText, userPrincipalName, recursive);
var searchResult = es.Search(Path.Combine(org.OrganizationId, searchPath ?? string.Empty), searchText, userPrincipalName, recursive);
var result = new List<SystemFile>();
foreach (var systemFile in searchResult)
{
if (rootFolders.All(x => !systemFile.FullName.Contains(x.FullName)))
{
continue;
}
result.Add(systemFile);
}
return result.ToArray();
} }
catch (Exception ex) catch (Exception ex)
{ {

View file

@ -171,9 +171,9 @@ namespace WebsitePanel.EnterpriseServer
} }
[WebMethod] [WebMethod]
public SystemFile[] SearchFiles(int itemId, string searchPath, string searchText, string userPrincipalName, bool recursive) public SystemFile[] SearchFiles(int itemId, string[] searchPaths, string searchText, string userPrincipalName, bool recursive)
{ {
return EnterpriseStorageController.SearchFiles(itemId, searchPath, searchText, userPrincipalName, recursive); return EnterpriseStorageController.SearchFiles(itemId, searchPaths, searchText, userPrincipalName, recursive);
} }
#region Directory Browsing #region Directory Browsing

View file

@ -46,6 +46,6 @@ namespace WebsitePanel.Providers.EnterpriseStorage
bool SetFolderWebDavRules(string organizationId, string folder, WebDavSetting setting, WebDavFolderRule[] rules); bool SetFolderWebDavRules(string organizationId, string folder, WebDavSetting setting, WebDavFolderRule[] rules);
WebDavFolderRule[] GetFolderWebDavRules(string organizationId, string folder, WebDavSetting setting); WebDavFolderRule[] GetFolderWebDavRules(string organizationId, string folder, WebDavSetting setting);
bool CheckFileServicesInstallation(); bool CheckFileServicesInstallation();
SystemFile[] Search(string searchPath, string searchText, string userPrincipalName, bool recursive); SystemFile[] Search(string organizationId, string[] searchPaths, string searchText, string userPrincipalName, bool recursive);
} }
} }

View file

@ -285,23 +285,27 @@ namespace WebsitePanel.Providers.EnterpriseStorage
#endregion #endregion
public SystemFile[] Search(string searchPath, string searchText, string userPrincipalName, bool recursive) public SystemFile[] Search(string organizationId, string[] searchPaths, string searchText, string userPrincipalName, bool recursive)
{ {
var settings = GetWebDavSetting(null); var settings = GetWebDavSetting(null);
var result = new List<SystemFile>(); var result = new List<SystemFile>();
var isRootSearch = false;
if (searchPaths.Any(string.IsNullOrEmpty))
{
isRootSearch = true;
searchPaths = searchPaths.Where(x => !string.IsNullOrEmpty(x)).ToArray();
}
using (new WindowsIdentity(userPrincipalName).Impersonate()) using (new WindowsIdentity(userPrincipalName).Impersonate())
{ {
using (var conn = new OleDbConnection("Provider=Search.CollatorDSO;Extended Properties='Application=Windows';")) using (var conn = new OleDbConnection("Provider=Search.CollatorDSO;Extended Properties='Application=Windows';"))
{ {
var searchDirectory = Path.Combine(settings.LocationDrive + ":\\", settings.HomeFolder); var rootFolder = Path.Combine(settings.LocationDrive + ":\\", settings.HomeFolder);
searchDirectory = Path.Combine(searchDirectory, searchPath); rootFolder = Path.Combine(rootFolder, organizationId);
var searchDirectoryUrl = new Uri(searchDirectory).AbsoluteUri;
var wsSql = string.Format(@"SELECT System.FileName, System.DateModified, System.Size, System.Kind, System.ItemPathDisplay, System.ItemType FROM SYSTEMINDEX WHERE System.FileName LIKE '%{0}%' AND {1} = '{2}'",
searchText, recursive ? "SCOPE" : "DIRECTORY", searchDirectoryUrl);
var wsSql = string.Format(@"SELECT System.FileName, System.DateModified, System.Size, System.Kind, System.ItemPathDisplay, System.ItemType FROM SYSTEMINDEX WHERE System.FileName LIKE '%{0}%' AND ({1})",
searchText, string.Join(" OR ", searchPaths.Select(x => string.Format("{0} = '{1}'", recursive ? "SCOPE" : "DIRECTORY", Path.Combine(rootFolder, x))).ToArray()));
conn.Open(); conn.Open();
@ -325,7 +329,19 @@ namespace WebsitePanel.Providers.EnterpriseStorage
} }
file.FullName = (reader[4] as string ?? string.Empty); file.FullName = (reader[4] as string ?? string.Empty);
file.RelativeUrl = file.FullName.Replace(searchDirectory, string.Empty).Trim('\\');
if (isRootSearch)
{
file.RelativeUrl = file.FullName.Replace(rootFolder, "").Trim('\\');
}
else
{
foreach (var searchPath in searchPaths)
{
file.RelativeUrl = file.FullName.Replace(Path.Combine(rootFolder, searchPath), "").Trim('\\');
}
}
result.Add(file); result.Add(file);
} }

View file

@ -410,9 +410,10 @@ namespace WebsitePanel.Providers.EnterpriseStorage {
/// <remarks/> /// <remarks/>
[System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")] [System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")]
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/Search", RequestNamespace="http://smbsaas/websitepanel/server/", ResponseNamespace="http://smbsaas/websitepanel/server/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/Search", RequestNamespace="http://smbsaas/websitepanel/server/", ResponseNamespace="http://smbsaas/websitepanel/server/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public SystemFile[] Search(string searchPath, string searchText, string userPrincipalName, bool recursive) { public SystemFile[] Search(string organizationId, string[] searchPaths, string searchText, string userPrincipalName, bool recursive) {
object[] results = this.Invoke("Search", new object[] { object[] results = this.Invoke("Search", new object[] {
searchPath, organizationId,
searchPaths,
searchText, searchText,
userPrincipalName, userPrincipalName,
recursive}); recursive});
@ -420,9 +421,10 @@ namespace WebsitePanel.Providers.EnterpriseStorage {
} }
/// <remarks/> /// <remarks/>
public System.IAsyncResult BeginSearch(string searchPath, string searchText, string userPrincipalName, bool recursive, System.AsyncCallback callback, object asyncState) { public System.IAsyncResult BeginSearch(string organizationId, string[] searchPaths, string searchText, string userPrincipalName, bool recursive, System.AsyncCallback callback, object asyncState) {
return this.BeginInvoke("Search", new object[] { return this.BeginInvoke("Search", new object[] {
searchPath, organizationId,
searchPaths,
searchText, searchText,
userPrincipalName, userPrincipalName,
recursive}, callback, asyncState); recursive}, callback, asyncState);
@ -435,17 +437,18 @@ namespace WebsitePanel.Providers.EnterpriseStorage {
} }
/// <remarks/> /// <remarks/>
public void SearchAsync(string searchPath, string searchText, string userPrincipalName, bool recursive) { public void SearchAsync(string organizationId, string[] searchPaths, string searchText, string userPrincipalName, bool recursive) {
this.SearchAsync(searchPath, searchText, userPrincipalName, recursive, null); this.SearchAsync(organizationId, searchPaths, searchText, userPrincipalName, recursive, null);
} }
/// <remarks/> /// <remarks/>
public void SearchAsync(string searchPath, string searchText, string userPrincipalName, bool recursive, object userState) { public void SearchAsync(string organizationId, string[] searchPaths, string searchText, string userPrincipalName, bool recursive, object userState) {
if ((this.SearchOperationCompleted == null)) { if ((this.SearchOperationCompleted == null)) {
this.SearchOperationCompleted = new System.Threading.SendOrPostCallback(this.OnSearchOperationCompleted); this.SearchOperationCompleted = new System.Threading.SendOrPostCallback(this.OnSearchOperationCompleted);
} }
this.InvokeAsync("Search", new object[] { this.InvokeAsync("Search", new object[] {
searchPath, organizationId,
searchPaths,
searchText, searchText,
userPrincipalName, userPrincipalName,
recursive}, this.SearchOperationCompleted, userState); recursive}, this.SearchOperationCompleted, userState);

View file

@ -176,12 +176,12 @@ namespace WebsitePanel.Server
} }
[WebMethod, SoapHeader("settings")] [WebMethod, SoapHeader("settings")]
public SystemFile[] Search(string searchPath, string searchText, string userPrincipalName, bool recursive) public SystemFile[] Search(string organizationId, string[] searchPaths, string searchText, string userPrincipalName, bool recursive)
{ {
try try
{ {
Log.WriteStart("'{0}' Search", ProviderSettings.ProviderName); Log.WriteStart("'{0}' Search", ProviderSettings.ProviderName);
var searchResults = EnterpriseStorageProvider.Search(searchPath, searchText, userPrincipalName, recursive); var searchResults = EnterpriseStorageProvider.Search(organizationId, searchPaths, searchText, userPrincipalName, recursive);
Log.WriteEnd("'{0}' Search", ProviderSettings.ProviderName); Log.WriteEnd("'{0}' Search", ProviderSettings.ProviderName);
return searchResults; return searchResults;
} }

View file

@ -80,28 +80,23 @@ namespace WebsitePanel.WebDav.Core.Managers
{ {
pathPart = (pathPart ?? string.Empty).Replace("/","\\"); pathPart = (pathPart ?? string.Empty).Replace("/","\\");
var items = WspContext.Services.EnterpriseStorage.SearchFiles(itemId, pathPart, searchValue, uesrPrincipalName, recursive); SystemFile[] items;
var resources = Convert(items, new Uri(WebDavAppConfigManager.Instance.WebdavRoot).Append(WspContext.User.OrganizationId, pathPart));
if (string.IsNullOrWhiteSpace(pathPart)) if (string.IsNullOrWhiteSpace(pathPart))
{ {
var rootItems = ConnectToWebDavServer().ToArray(); var rootItems = ConnectToWebDavServer().Select(x => x.Name).ToList();
rootItems.Insert(0, string.Empty);
foreach (var resource in resources) items = WspContext.Services.EnterpriseStorage.SearchFiles(itemId, rootItems.ToArray(), searchValue, uesrPrincipalName, recursive);
{
var rootItem = rootItems.FirstOrDefault(x => x.Name == resource.DisplayName);
if (rootItem == null)
{
continue;
}
resource.ContentLength = rootItem.Size;
resource.AllocatedSpace = rootItem.FRSMQuotaMB;
resource.IsRootItem = true;
}
} }
else
{
items = WspContext.Services.EnterpriseStorage.SearchFiles(itemId, new []{pathPart}, searchValue, uesrPrincipalName, recursive);
}
var resources = Convert(items, new Uri(WebDavAppConfigManager.Instance.WebdavRoot).Append(WspContext.User.OrganizationId, pathPart));
return FilterResult(resources); return FilterResult(resources);
} }

View file

@ -81,7 +81,7 @@ WspFileBrowser.prototype = {
initDataTable: function (tableId, ajaxUrl) { initDataTable: function (tableId, ajaxUrl) {
this.table = $(tableId).dataTable({ this.table = $(tableId).dataTable({
"ajax": ajaxUrl, "ajax": ajaxUrl,
"processing": true, "processing": false,
"serverSide": true, "serverSide": true,
"columnDefs": [ "columnDefs": [
{ {
@ -113,6 +113,15 @@ WspFileBrowser.prototype = {
], ],
"createdRow": function(row, data, index) { "createdRow": function(row, data, index) {
$(row).addClass('element-container'); $(row).addClass('element-container');
},
"fnPreDrawCallback": function () {
// gather info to compose a message
wsp.dialogs.showProcessDialog();
return true;
},
"fnDrawCallback": function () {
// in case your overlay needs to be put away automatically you can put it here
wsp.dialogs.hideProcessDialog();
} }
}); });