Jump to content

Quering Spotfire for a folder's childItems takes too long


Georgi Koemdzhiev

Recommended Posts

Our Index page displays a list of the analysis files located in a folder (each user has a folder in the Spotfire's Library). The problem is performance. It takes ~5 seconds to get 50 library items and because that happens in our landing page, the whole page takes too long to load. I am wondering if I am doing anything wrong when querying the server.

We have a method `GetWorkbooks()` (see below) in our service which is called when the landing page loads. It uses a `WcfClient` which exposes the `LibraryService` so we can query Spotfire.

public IList GetWorkbooks(string email, bool isBufferFolder = false){

var targetFolderPath = isBufferFolder _sharingBufferFolderPath : _userFolderPath;

var userFolderId = _spotfireUserDataService._libraryService.Invoke(x => x.pathToId(new pathToId($"{targetFolderPath}/{email}", SpotfireLibraryItemType.Folder))).@return;

var workBooks = new List();

// only retrieve workbooks if there is a user folder

if (userFolderId != null){

var libraryItems = _spotfireUserDataService._libraryService.Invoke(x => x.getChildItems(new getChildItems(userFolderId))).@return;

// check if there are any items in the folder, if not return the above empty list

if (libraryItems != null){// get all analysis/workbook ('dxp') files for the user

workBooks = libraryItems

.Where(i => i.type == SpotfireLibraryItemType.DXP)

.OrderByDescending(j => j.accessed.Date)

.Select(x => new Workbook {

Name = x.title,

Id = x.id,

ModifiedDate = x.modified,

Metadata = new {

SharedBy = x.properties.Where(i => i.key == "SharedBy").FirstOrDefault().values[0],

SharedDate = new DateTime(Convert.ToInt64(x.properties.Where(i => i.key == "SharedDate").FirstOrDefault().values[0]))

}

}).ToList();

}

}

return workBooks;

}

 

This is a screenshot of the call:

 

This is the Spotfire's Library hierarchy:

-DNA

----UserFolder

--------user.name@company.com

This is my `WcfClient.cs`:

public class WcfClient : IDisposable{

private T _wrappedChannel;

private static readonly object _channelLock = new object();

private readonly ChannelFactory _factory;

private readonly ITokenProvider _tokenProvider;

 

public WcfClient(ChannelFactory factory, ITokenProvider tokenProvider){

_factory = factory;

_tokenProvider = tokenProvider;

}

 

protected T WrappedChannel{

get{

lock (_channelLock){

if (!Equals(_wrappedChannel, default(T))){

var state = ((ICommunicationObject)_wrappedChannel).State;

if (state == CommunicationState.Faulted){

_wrappedChannel = default(T);

}

}

if (Equals(_wrappedChannel, default(T))){

_wrappedChannel = _factory.CreateChannel();

}

}

return _wrappedChannel;

}

}

 

public void Invoke(Action action){

try{

action(WrappedChannel);

}

catch (FaultException){

throw;

}

}

 

public TResult Invoke(Func action){

try{

return action(WrappedChannel);

}

}

}

Could anyone please provide any tips on how I can improve the performance

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...