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/>
[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[] {
itemId,
searchPath,
searchPaths,
searchText,
userPrincipalName,
recursive});
@ -1040,10 +1040,10 @@ namespace WebsitePanel.EnterpriseServer {
}
/// <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[] {
itemId,
searchPath,
searchPaths,
searchText,
userPrincipalName,
recursive}, callback, asyncState);
@ -1056,18 +1056,18 @@ namespace WebsitePanel.EnterpriseServer {
}
/// <remarks/>
public void SearchFilesAsync(int itemId, string searchPath, string searchText, string userPrincipalName, bool recursive) {
this.SearchFilesAsync(itemId, searchPath, searchText, userPrincipalName, recursive, null);
public void SearchFilesAsync(int itemId, string[] searchPaths, string searchText, string userPrincipalName, bool recursive) {
this.SearchFilesAsync(itemId, searchPaths, searchText, userPrincipalName, recursive, null);
}
/// <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)) {
this.SearchFilesOperationCompleted = new System.Threading.SendOrPostCallback(this.OnSearchFilesOperationCompleted);
}
this.InvokeAsync("SearchFiles", new object[] {
itemId,
searchPath,
searchPaths,
searchText,
userPrincipalName,
recursive}, this.SearchFilesOperationCompleted, userState);

View file

@ -172,7 +172,7 @@ namespace WebsitePanel.EnterpriseServer
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
{
@ -192,23 +192,7 @@ namespace WebsitePanel.EnterpriseServer
EnterpriseStorage es = GetEnterpriseStorage(serviceId);
var rootFolders = GetRootFolders(userPrincipalName).ToList();
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();
return es.Search(org.OrganizationId, searchPaths, searchText, userPrincipalName, recursive);
}
catch (Exception ex)
{

View file

@ -171,9 +171,9 @@ namespace WebsitePanel.EnterpriseServer
}
[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

View file

@ -46,6 +46,6 @@ namespace WebsitePanel.Providers.EnterpriseStorage
bool SetFolderWebDavRules(string organizationId, string folder, WebDavSetting setting, WebDavFolderRule[] rules);
WebDavFolderRule[] GetFolderWebDavRules(string organizationId, string folder, WebDavSetting setting);
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
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 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 (var conn = new OleDbConnection("Provider=Search.CollatorDSO;Extended Properties='Application=Windows';"))
{
var searchDirectory = Path.Combine(settings.LocationDrive + ":\\", settings.HomeFolder);
searchDirectory = Path.Combine(searchDirectory, searchPath);
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 rootFolder = Path.Combine(settings.LocationDrive + ":\\", settings.HomeFolder);
rootFolder = Path.Combine(rootFolder, organizationId);
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();
@ -325,7 +329,19 @@ namespace WebsitePanel.Providers.EnterpriseStorage
}
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);
}

View file

@ -410,9 +410,10 @@ namespace WebsitePanel.Providers.EnterpriseStorage {
/// <remarks/>
[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)]
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[] {
searchPath,
organizationId,
searchPaths,
searchText,
userPrincipalName,
recursive});
@ -420,9 +421,10 @@ namespace WebsitePanel.Providers.EnterpriseStorage {
}
/// <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[] {
searchPath,
organizationId,
searchPaths,
searchText,
userPrincipalName,
recursive}, callback, asyncState);
@ -435,17 +437,18 @@ namespace WebsitePanel.Providers.EnterpriseStorage {
}
/// <remarks/>
public void SearchAsync(string searchPath, string searchText, string userPrincipalName, bool recursive) {
this.SearchAsync(searchPath, searchText, userPrincipalName, recursive, null);
public void SearchAsync(string organizationId, string[] searchPaths, string searchText, string userPrincipalName, bool recursive) {
this.SearchAsync(organizationId, searchPaths, searchText, userPrincipalName, recursive, null);
}
/// <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)) {
this.SearchOperationCompleted = new System.Threading.SendOrPostCallback(this.OnSearchOperationCompleted);
}
this.InvokeAsync("Search", new object[] {
searchPath,
organizationId,
searchPaths,
searchText,
userPrincipalName,
recursive}, this.SearchOperationCompleted, userState);

View file

@ -176,12 +176,12 @@ namespace WebsitePanel.Server
}
[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
{
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);
return searchResults;
}

View file

@ -80,28 +80,23 @@ namespace WebsitePanel.WebDav.Core.Managers
{
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))
{
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);
}
else
{
var rootItem = rootItems.FirstOrDefault(x => x.Name == resource.DisplayName);
if (rootItem == null)
{
continue;
items = WspContext.Services.EnterpriseStorage.SearchFiles(itemId, new []{pathPart}, searchValue, uesrPrincipalName, recursive);
}
resource.ContentLength = rootItem.Size;
resource.AllocatedSpace = rootItem.FRSMQuotaMB;
resource.IsRootItem = true;
}
}
var resources = Convert(items, new Uri(WebDavAppConfigManager.Instance.WebdavRoot).Append(WspContext.User.OrganizationId, pathPart));
return FilterResult(resources);
}

View file

@ -81,7 +81,7 @@ WspFileBrowser.prototype = {
initDataTable: function (tableId, ajaxUrl) {
this.table = $(tableId).dataTable({
"ajax": ajaxUrl,
"processing": true,
"processing": false,
"serverSide": true,
"columnDefs": [
{
@ -113,6 +113,15 @@ WspFileBrowser.prototype = {
],
"createdRow": function(row, data, index) {
$(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();
}
});