private bool SearchFiles( IMemberServices service, string memberId, ITextSearchModel model, string email, IMainPresenter presenter) { bool filesAdded = false; bool SuppressStatus = ApplicationResource.SuppressFilenamesInStatus; try { service.SearchFilesUrl = ApplicationResource.ActionFileSearch; service.UserAgentVersion = ApplicationResource.UserAgent; IDataResponse response = service.SearchFiles(new MemberData() { SearchText = model.QueryString, SearchLimit = ApplicationResource.SearchFileCountLimit,//model.SearchResultsLimit, SearchMode = model.GetSearchModeForService(), MemberId = memberId }, model.AccessToken); if (response.StatusCode == System.Net.HttpStatusCode.OK) { if (response.Data != null) { string data = response.Data.ToString(); dynamic jsonDataSearch = JsonConvert.DeserializeObject<dynamic>(data); if (jsonDataSearch["matches"] != null && jsonDataSearch["matches"].ToString() != "[]") { int matchCount = jsonDataSearch["matches"].Count; for (int j = 0; j < matchCount; j++) { string pathLower = jsonDataSearch["matches"][j]["metadata"]["path_lower"]; // update model MemberListViewItemModel item = new MemberListViewItemModel() { Email = email, Path = pathLower, MemberId = memberId }; // add searched members to list. model.MemberList.Add(item); SyncContext.Post(delegate { if (!SuppressStatus) { presenter.UpdateProgressInfo(string.Format("Member: {0} File : {1}", email, item.Path)); } else { presenter.UpdateProgressInfo(string.Format("Member: {0} File : Suppressing filename status...", email)); } }, null); } if (matchCount > 0) { filesAdded = true; } } } } } catch (Exception e) { Console.WriteLine(e.Message); } return filesAdded; }
private bool SearchFiles( IMemberServices service, string memberId, ITextSearchModel model, string email, IMainPresenter presenter) { bool filesAdded = false; bool SuppressStatus = ApplicationResource.SuppressFilenamesInStatus; try { service.SearchFilesUrl = ApplicationResource.ActionFileSearch; service.UserAgentVersion = ApplicationResource.UserAgent; IDataResponse response = service.SearchFiles(new MemberData() { SearchText = model.QueryString, SearchLimit = ApplicationResource.SearchFileCountLimit,//model.SearchResultsLimit, SearchMode = model.GetSearchModeForService(), MemberId = memberId }, model.AccessToken); if (response.StatusCode == System.Net.HttpStatusCode.OK) { if (response.Data != null) { string data = response.Data.ToString(); dynamic jsonDataSearch = JsonConvert.DeserializeObject <dynamic>(data); if (jsonDataSearch["matches"] != null && jsonDataSearch["matches"].ToString() != "[]") { int matchCount = jsonDataSearch["matches"].Count; for (int j = 0; j < matchCount; j++) { string pathLower = jsonDataSearch["matches"][j]["metadata"]["path_lower"]; // update model MemberListViewItemModel item = new MemberListViewItemModel() { Email = email, Path = pathLower, MemberId = memberId }; // add searched members to list. model.MemberList.Add(item); SyncContext.Post(delegate { if (!SuppressStatus) { presenter.UpdateProgressInfo(string.Format("Member: {0} File : {1}", email, item.Path)); } else { presenter.UpdateProgressInfo(string.Format("Member: {0} File : Suppressing filename status...", email)); } }, null); } if (matchCount > 0) { filesAdded = true; } } } } } catch (Exception e) { Console.WriteLine(e.Message); } return(filesAdded); }