public async Task GivenMultiplePages_WhenWeSearchByRegionThatMatches_ThenWeReturnOnlyTheSelectedPage(int schemeId, string region) { using (var trans = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { var list = new List <CreateAssetRequest>(); for (var i = 0; i < 15; i++) { var createAssetRequest = CreateAsset(schemeId + i, null, region); list.Add(createAssetRequest); } var responses = await _createAssetRegisterVersionUseCase.ExecuteAsync(list, CancellationToken.None).ConfigureAwait(false); var assetSearch = new SearchAssetRequest { Region = region, Page = 2, PageSize = 10, AssetRegisterVersionId = responses.GetAssetRegisterVersionId() }; var response = await _classUnderTest.ExecuteAsync(assetSearch, CancellationToken.None) .ConfigureAwait(false); response.Should().NotBeNull(); response.Assets.Count.Should().Be(5); response.Pages.Should().Be(2); response.TotalCount.Should().Be(15); trans.Dispose(); } }
public async Task GivenAnAssetHasBeenCreated_WhenWeSearchViaSchemeIdThatHasntBeenSet_ThenWeReturnNullOrEmptyList(int schemeId) { //arrange using (var trans = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { var list = new List <CreateAssetRequest> { CreateAsset() }; var responses = await _createAssetRegisterVersionUseCase.ExecuteAsync(list, CancellationToken.None).ConfigureAwait(false); var assetSearch = new SearchAssetRequest { SchemeId = schemeId, AssetRegisterVersionId = responses.GetAssetRegisterVersionId() }; //act //assert var response = await _classUnderTest.ExecuteAsync(assetSearch, CancellationToken.None) .ConfigureAwait(false); response.Should().NotBeNull(); response.Assets.Should().BeNullOrEmpty(); trans.Dispose(); } }
public async Task GivenThatMultipleAssetsHaveBeenCreated_WhenWeSearchViaSchemeIdThatHasBeenSet_ThenWeCanFindTheSameAssetAnd(int schemeId, int schemeId2, int schemeId3, string address) { //arrange using (var trans = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { List <CreateAssetRequest> list = new List <CreateAssetRequest> { CreateAsset(schemeId, address), CreateAsset(schemeId2, address), CreateAsset(schemeId3, address), }; IList <CreateAssetResponse> responses = await _createAssetRegisterVersionUseCase.ExecuteAsync(list, CancellationToken.None).ConfigureAwait(false); var assetSearch = new SearchAssetRequest { SchemeId = schemeId2, AssetRegisterVersionId = responses.GetAssetRegisterVersionId() }; //act var useCaseResponse = await _classUnderTest.ExecuteAsync(assetSearch, CancellationToken.None) .ConfigureAwait(false); //assert useCaseResponse.Assets.Count.Should().Be(1); useCaseResponse.Assets.ElementAtOrDefault(0).AssetOutputModelIsEqual(responses[1].Asset); trans.Dispose(); } }
public async Task <SearchAssetResponse> ExecuteAsync(SearchAssetRequest requests, CancellationToken cancellationToken) { var foundAssets = await SearchAssets(requests, cancellationToken); var response = new SearchAssetResponse { Assets = foundAssets.Results?.Select(s => new AssetOutputModel(s)).ToList(), Pages = foundAssets.NumberOfPages, TotalCount = foundAssets.TotalCount }; return(response); }
private async Task <SearchAssetResponse> SearchForAssetAsync(int?schemeId, string address, int assetRegisterVersionId, string region, string developer = null) { var searchForAsset = new SearchAssetRequest { SchemeId = schemeId, Address = address, AssetRegisterVersionId = assetRegisterVersionId, Region = region, Developer = developer }; var useCaseResponse = await _classUnderTest.ExecuteAsync(searchForAsset, CancellationToken.None) .ConfigureAwait(false); return(useCaseResponse); }
public async Task GivenValidRequest_WhenSearchResultsAreNull_ThenUseCaseThrowsAssetNotFoundException(int id, string address) { //arrange _mockGateway.Search(Arg.Any <IAssetPagedSearchQuery>(), CancellationToken.None) .Returns((IPagedResults <IAsset>)null); var searchAssetRequest = new SearchAssetRequest { SchemeId = id, Address = address }; //act //act var response = await _classUnderTest.ExecuteAsync(searchAssetRequest, CancellationToken.None); //assert response.Should().NotBeNull(); response.Assets.Should().BeNullOrEmpty(); }
public async Task <IActionResult> Get([FromQuery] SearchAssetApiRequest request) { if (!request.IsValid()) { return(StatusCode(400)); } var assetRegisterVersionId = await GetLatestAssetRegisterVersionIdIfNull(request); var searchAssetUseCaseRequest = new SearchAssetRequest { SchemeId = request.SchemeId, Address = request.Address, Page = request.Page, PageSize = request.PageSize, AssetRegisterVersionId = assetRegisterVersionId, }; SearchAssetResponse result = await _useCase .ExecuteAsync(searchAssetUseCaseRequest, this.GetCancellationToken()).ConfigureAwait(false); return(this.StandardiseResponse <SearchAssetResponse, AssetOutputModel>(result)); }
private async Task <IPagedResults <IAsset> > SearchAssets(SearchAssetRequest request, CancellationToken cancellationToken) { var assetSearch = new AssetPagedSearchQuery { SchemeId = request.SchemeId, Address = request.Address, Region = request.Region, AssetRegisterVersionId = request.AssetRegisterVersionId, Developer = request.Developer, }; if (request.Page != null) { assetSearch.Page = request.Page; } if (request.PageSize != null) { assetSearch.PageSize = request.PageSize; } var foundAssets = await _assetSearcher.Search(assetSearch, cancellationToken).ConfigureAwait(false); if (foundAssets == null) { foundAssets = new PagedResults <IAsset> { Results = new List <IAsset>(), NumberOfPages = 0, TotalCount = 0 } } ; return(foundAssets); } }
// Create HTML for Graphical (fractionally-zoomed iframes of URL) Library search results: private void BuildGraphicalResults_WorkareaLibrary(SearchAssetRequest sar) { // Not implemented yet, throw error! throw (new Exception("[iSearch.asx.vb->BuildGraphicalResults] Functionality is Not Yet Supported!")); }
private void PostBack_DoFindLibrary() { SearchAssetRequest sar = new SearchAssetRequest(); string strViewMode = ""; pagedata = new Collection(); pagedata.Add(Request.Form["frm_library_title"], "SearchTerm", null, null); pagedata.Add(System.Convert.ToInt32(Request.Form["frm_libtype_id"]), "LibTypeID", null, null); if (Request.Form["frm_library_link"] == "1") { pagedata.Add(1, "SearchLink", null, null); } else { pagedata.Add(0, "SearchLink", null, null); } if (Request.Form["frm_user_only_content"] == "1") { pagedata.Add(1, "UserOnlyAssets", null, null); } else { pagedata.Add(0, "UserOnlyAssets", null, null); } if (Request.Form["frm_library_description"] == "1") { pagedata.Add(1, "SearchTeaser", null, null); } else { pagedata.Add(0, "SearchTeaser", null, null); } if (Request.Form["frm_library_tags"] == "1") { pagedata.Add(1, "SearchTags", null, null); } else { pagedata.Add(0, "SearchTags", null, null); } sar = CustomFields.Populate_AssetRequestObjectFromForm(null); sar.isWorkareaSearch = true; search_result_lib = m_refContentApi.InternalLibrarySearch(pagedata, sar); //If there is no dropdown on the page ie. clicked on a page link in results, //use old value of dropdown from the hidden field pageMode //else use dropdown value and, update pageMode if (!(Request.Form["selLibDisplayMode"] == null)) { strViewMode = (string)(Request.Form["selLibDisplayMode"].ToLower()); pageMode.Value = strViewMode; } else { strViewMode = (string)pageMode.Value; } //Since viewstate is false for the page, ensure the active tab is set correctly. if (Convert.ToInt32(hdnSelectedTab.Value) == 0) uxSearchTabs.SetActiveTab(uxTabBasic); else uxSearchTabs.SetActiveTab(uxTabAdvanced); hmenuSelected.Value = hdnSelectedTab.Value; if ((Request["source"] == "edit") || (Request["source"] == "libinsert") || (Request["source"] == "mediainsert")) { Populate_SearchResultGrid_Library(); preview_type.Value = m_strLibType; } else { if ("graphical" == strViewMode) { BuildGraphicalResults_WorkareaLibrary(sar); } else { Populate_SearchResultGrid(System.Convert.ToBoolean("text" == strViewMode)); } } PostBack_DoFindLibraryToolBar(search_result_lib); }
private void PostBack_DoFindContent() { pagedata = new Collection(); try { SearchAssetRequest sar = new SearchAssetRequest(); Ektron.Cms.Content.EkContent ekc; Ektron.Cms.UrlAliasing.UrlAliasManualApi _manualAliasApi; Ektron.Cms.UrlAliasing.UrlAliasAutoApi _autoAliasApi; System.Collections.Generic.List<UrlAliasManualData> manualAliasList; System.Collections.Generic.List<UrlAliasAutoData> autoAliasList; string tempURL; string strLibPath = ""; string strContentID = ""; long contentID = 0; string strFormID = ""; string strAssetName = ""; string strLibtype = ""; PagingInfo page; int index = 0; int contentType = 0; ekc = m_refContentApi.EkContentRef; strLibPath = (string)((!(Request.QueryString["libpath"] == null)) ? (Request.QueryString["libpath"]) : ""); strContentID = (string)((!(Request.QueryString["content_id"] == null)) ? (Request.QueryString["content_id"]) : ""); strFormID = (string)((!(Request.QueryString["form_id"] == null)) ? (Request.QueryString["form_id"]) : ""); strAssetName = (string)((!(Request.QueryString["asset_name"] == null)) ? (Request.QueryString["asset_name"]) : ""); strLibtype = (string)((!(Request.QueryString["libtype"] == null)) ? (Request.QueryString["libtype"]) : ""); contentID = EkFunctions.ReadDbLong(strContentID); contentType = Convert.ToInt32(m_refContentApi.EkContentRef.GetContentType(contentID)); if (strLibPath != "") { m_refContentApi.ContentLanguage = Ektron.Cms.Common.EkConstants.ALL_CONTENT_LANGUAGES; } // Fixed #13770, search links from a form if ((strLibPath != "") || (strContentID != "") || (strFormID != "") || (strAssetName != "")) { // Checking links from known content block sar = new SearchAssetRequest(); sar.FolderID = 0; sar.Recursive = true; sar.SearchContent = true; sar.AllowFragments = true; sar.SearchInHTML = true; sar.SearchForms = true; sar.SearchCatalog = System.Convert.ToBoolean(contentType == EkConstants.CMSContentType_CatalogEntry); string domain; domain = ""; if ((strFormID != "") || (strContentID != "")) { // see if content is in a domain folder which always uses linkit.aspx string id; if (strFormID != "") { id = strFormID; } else { id = strContentID; } domain = m_refContentApi.GetDomainByContentId(Convert.ToInt64(id)); } if (strAssetName != "" && !m_refContentApi.RequestInformationRef.LinkManagement) { sar.SearchText = strAssetName.Replace("\'", "\'"); sar.SearchType = EkEnumeration.SearchTypes.AndWords; } else if ((strAssetName != "") && (strLibtype != "images")) { sar.SearchType = EkEnumeration.SearchTypes.OrWords; //AndWords sar.SearchText = (string)("linkit.aspx?LinkIdentifier=id&ItemId=" + strContentID + ",showcontent.aspx?id=" + strContentID); //If searching for content linked to DMS image (from library) } else if ((strAssetName != "") && (strLibtype == "images")) { sar.SearchType = EkEnumeration.SearchTypes.OrWords; //AndWords sar.SearchText = strAssetName; } else if (strLibPath != "") { if ((m_refContentApi.RequestInformationRef.LinkManagement || (domain != null)) && ((strLibtype != "images") && strLibtype != "files") && (strLibtype != "hyperlinks")) { //This is only for quicklink search //if content is in a domain folder, linkit.aspx will redirect to the proper domain if (strFormID != "") { sar.SearchText = (string)("linkit.aspx?LinkIdentifier=ekfrm&ItemId=" + strFormID); } else { sar.SearchText = (string)("linkit.aspx?LinkIdentifier=id&ItemId=" + strContentID); } } else { sar.SearchText = strLibPath; } sar.SearchType = EkEnumeration.SearchTypes.AndWords; } else if ((m_refContentApi.RequestInformationRef.LinkManagement || (domain != null)) && (strFormID != "")) { // if content is in a domain folder, linkit.aspx will redirect to the proper domain sar.SearchText = (string)("linkit.aspx?LinkIdentifier=ekfrm&ItemId=" + strFormID); sar.SearchType = EkEnumeration.SearchTypes.AndWords; } else if (strContentID != "") { _manualAliasApi = new Ektron.Cms.UrlAliasing.UrlAliasManualApi(); _autoAliasApi = new Ektron.Cms.UrlAliasing.UrlAliasAutoApi(); page = new Ektron.Cms.PagingInfo(); long.TryParse(strContentID, out contentID); manualAliasList = _manualAliasApi.GetList(page, contentID, true, EkEnumeration.UrlAliasingOrderBy.None); autoAliasList = _autoAliasApi.GetListForContent(contentID); tempURL = string.Empty; for (index = 0; index <= manualAliasList.Count - 1; index++) { tempURL += (string)(manualAliasList[index].DisplayAlias + " "); } for (index = 0; index <= autoAliasList.Count - 1; index++) { tempURL += (string)(autoAliasList[index].AliasName + " "); } // We check the alias and add that as the or phrase. sar.SearchText = (string)("id=" + strContentID); if (tempURL != "" && domain != "") { sar.SearchText += (string)(" " + domain + "/" + tempURL); } else if (tempURL != "" && domain == "") { sar.SearchText += (string)(" " + m_refContentApi.SitePath + tempURL); } sar.SearchType = EkEnumeration.SearchTypes.OrWords; } else { // Not sure if GetAllAliasedPageNameByCID needs form id or content id, // but all we've got at this point is form id. // We check the alias and add that as the or phrase. _manualAliasApi = new Ektron.Cms.UrlAliasing.UrlAliasManualApi(); _autoAliasApi = new Ektron.Cms.UrlAliasing.UrlAliasAutoApi(); page = new Ektron.Cms.PagingInfo(); long.TryParse(strContentID, out contentID); manualAliasList = _manualAliasApi.GetList(page, contentID, true, EkEnumeration.UrlAliasingOrderBy.None); autoAliasList = _autoAliasApi.GetListForContent(contentID); tempURL = string.Empty; for (index = 0; index <= manualAliasList.Count - 1; index++) { tempURL += (string)(manualAliasList[index].DisplayAlias + " "); } for (index = 0; index <= autoAliasList.Count - 1; index++) { tempURL += (string)(autoAliasList[index].AliasName + " "); } sar.SearchText = (string)("ekfrm=" + strFormID); if (tempURL != "" && domain != "") { sar.SearchText += (string)(" " + domain + "/" + tempURL); } else if (tempURL != "" && domain == "") { sar.SearchText += (string)(" " + m_refContentApi.SitePath + tempURL); } sar.SearchType = EkEnumeration.SearchTypes.OrWords; } } else { sar = CustomFields.Populate_AssetRequestObjectFromForm(null); } sar.isWorkareaSearch = true; sar.ItemLanguageID = this.ContentLanguage; SearchContentItem[] sic; sar.CurrentPage = m_intCurrentPage; string cacheKey; if (sar.SearchText != "") { cacheKey = sar.SearchText + sar.SearchType.ToString() + sar.SearchAssets.ToString() + sar.Teaser_SearchText + sar.Title_SearchText + sar.FolderID.ToString(); } else { cacheKey = (string)("Blank" + sar.SearchType.ToString() + sar.SearchAssets.ToString() + sar.Teaser_SearchText + sar.Title_SearchText + sar.FolderID.ToString()); } if (!(Cache[cacheKey] == null)) { sar.SearchResults = (SearchCacheData[])Cache[cacheKey]; } //cms_LoadSearchResult stored proc doesn't return SearchAssetRequest.RecordsAffected value if we do not pass pagesize: Defect:46642 if ((!(Request.Form[isPostData.UniqueID] == null)) || (m_strPageAction == "dofindcontent")) { sar.PageSize = m_refContentApi.RequestInformationRef.PagingSize; } sic = ekc.SearchAssets(ref sar); if ((Cache[cacheKey] == null) && sar.SearchResults != null) { Cache.Add(cacheKey, sar.SearchResults, null, DateTime.Now.AddSeconds(120), TimeSpan.Zero, CacheItemPriority.Normal, null); } m_intTotalPages = sar.TotalPages; m_intTotalRecords = sar.RecordsAffected; PageSettings(); search_result = sic; StringBuilder strHiddenText = new StringBuilder(); if (!((Request.Form[isPostData.UniqueID] == null)) && m_intTotalPages > 1) { foreach (object AvailableItem in Request.Form) { if (AvailableItem.ToString().ToLower().IndexOf("ecm", 0, 3) != -1) { strHiddenText.Append("<input type=\"hidden\" id=\"" + AvailableItem + "\" name=\"" + AvailableItem + "\" value=\"" + Request.Form[AvailableItem.ToString()] + "\">"); } } HiddenData.Text = strHiddenText.ToString(); } //Since viewstate is false for the page, ensure the active tab is set correctly. //mvSearch.ActiveViewIndex = Convert.ToInt32(hdnSelectedTab.Value); if (Convert.ToInt32(hdnSelectedTab.Value) == 0) uxSearchTabs.SetActiveTab(uxTabBasic); else uxSearchTabs.SetActiveTab(uxTabAdvanced); hmenuSelected.Value = hdnSelectedTab.Value; string strViewMode; //If there is no dropdown on the page ie. clicked on a page link in results, //use old value of dropdown from the hidden field pageMode //else use dropdown value and, update pageMode if (!(Request.Form["selDisplayMode"] == null)) { strViewMode = (string)(Request.Form["selDisplayMode"].ToLower()); pageMode.Value = strViewMode; } else { strViewMode = (string)pageMode.Value; } if ((strViewMode != null) && (strViewMode.CompareTo("graphical") == 0)) { iconListOutputLit.Text = " Processing..."; BuildGraphicalResults(sar); } else if ((strViewMode != null) && (strViewMode.CompareTo("mixed") == 0)) { Populate_SearchResultGrid_Content_Mixed(sar); } else { // Default to text mode: Populate_SearchResultGrid_Content(sar); } if (strLibPath != "") { m_refContentApi.ContentLanguage = ContentLanguage; } //mvSearch.SetActiveView(vwSearchAdvanced); uxSearchTabs.SetActiveTab(uxTabAdvanced); } catch (Exception ex) { throw (new Exception("[iSearch.asx.vb->Postback_DoFindContent] " + ex.Message)); } }
// Create HTML for Graphical (fractionally-zoomed iframes of URL) Content search results: private void BuildGraphicalResults(SearchAssetRequest sar) { long idx; string linkStr; string imageStr; System.Text.StringBuilder result; string firstPartStr = ""; long itemsCount = 0; string dimStr; TemplateData templateDataObj; string templateStr; try { // obtain template to use for rendering into iframe: templateDataObj = m_refContentApi.GetTemplatesByFolderId(sar.FolderID); if (Convert.ToString(templateDataObj.FileName).IndexOf("?") >= 0) { templateStr = m_refContentApi.SitePath + templateDataObj.FileName + "&"; } else { templateStr = m_refContentApi.SitePath + templateDataObj.FileName + "?"; } SearchStyleSheet = "<link rel=\'stylesheet\' type=\'text/css\' href=\'csslib/worksearch.css\'>" + "\r\n"; result = new System.Text.StringBuilder(); result.Append("<script language=\"javascript\" src=\"java//jfunct.js\"></script>" + "\r\n"); result.Append("<script language=\"javascript\" src=\"java//com.ektron.ui.mod_iconlist.js\"></script>" + "\r\n"); result.Append("<script language=\"javascript\" src=\"java/com.ektron.utils.string.js\"></script>" + "\r\n"); result.Append("<script language=\"javascript\" type=\"text/javascript\">" + "\r\n"); result.Append("var g_searchResult;" + "\r\n"); result.Append("var g_retryDisplayResultsTimer;" + "\r\n"); result.Append("function displayResults( searchResult )" + "\r\n"); result.Append("{" + "\r\n"); result.Append(" if( searchResult ) {" + "\r\n"); result.Append(" var resultContainer = document.getElementById( \'iconListOutput\' );" + "\r\n"); result.Append(" if( resultContainer ) {" + "\r\n"); result.Append(" var iconList = new IconList( searchResult.assets );" + "\r\n"); result.Append(" iconList.setResultContainer( resultContainer );" + "\r\n"); result.Append(" iconList.display();" + "\r\n"); result.Append(" } else {" + "\r\n"); result.Append(" g_searchResult = searchResult;" + "\r\n"); result.Append(" if (g_retryDisplayResultsTimer){" + "\r\n"); result.Append(" clearTimeout(g_retryDisplayResultsTimer);" + "\r\n"); result.Append(" }" + "\r\n"); result.Append(" setTimeout(retryDisplayResults, 500);" + "\r\n"); result.Append(" }" + "\r\n"); result.Append(" }" + "\r\n"); result.Append(" document.body.style.cursor = \'default\';" + "\r\n"); result.Append("}" + "\r\n"); result.Append("function retryDisplayResults(){" + "\r\n"); result.Append(" if (g_searchResult){" + "\r\n"); result.Append(" displayResults(g_searchResult);" + "\r\n"); result.Append(" }" + "\r\n"); result.Append("}" + "\r\n"); result.Append("function myAssets(){" + "\r\n"); result.Append(" this.type = null;" + "\r\n"); result.Append(" this.quickLink = null;" + "\r\n"); result.Append(" this.imageLink = null;" + "\r\n"); result.Append(" this.__previewurl = null;" + "\r\n"); result.Append(" this.lastEditorFirstName = null;" + "\r\n"); result.Append(" this.lastEditorLastName = null;" + "\r\n"); result.Append(" this.dateModified = null;" + "\r\n"); result.Append(" this.teaser = null;" + "\r\n"); result.Append(" this.content = null;" + "\r\n"); result.Append(" this.lastModified = null;" + "\r\n"); result.Append(" this.editorFirstName = null;" + "\r\n"); result.Append(" this.editorLastName = null;" + "\r\n"); result.Append(" this.title = null;" + "\r\n"); result.Append(" this.thumbnailUrl = null;" + "\r\n"); result.Append("}" + "\r\n"); if (search_result == null) { iconListOutputLit.Text = ""; } else { result.Append("function goDisplay(){" + "\r\n"); result.Append(" var testResult = new mySearchResult;" + "\r\n"); result.Append(" displayResults(testResult);" + "\r\n"); result.Append("}" + "\r\n"); result.Append("function mySearchResult(){" + "\r\n"); firstPartStr = result.ToString(); result.Length = 0; for (idx = 0; idx <= search_result.Length - 1; idx++) { if (search_result[idx].ContentType == EkEnumeration.CMSContentType.LibraryItem) { result.Append("this.assets[" + idx.ToString() + "] = new myAssets;" + "\r\n"); result.Append("this.assets[" + idx.ToString() + "].type = \'c\'; // if value is numerical, signals type is a document otherwise content." + "\r\n"); result.Append("this.assets[" + idx.ToString() + "].thumbnailUrl = \'\';" + "\r\n"); imageStr = m_refContentApi.AppPath + "/DisplayResult.aspx?libid=" + search_result[idx].LibraryID + "&parent_id=" + search_result[idx].LibraryParentID + "&backpage=history"; result.Append("this.assets[" + idx.ToString() + "].imageLink = " + PrepTextForJava(imageStr)); linkStr = m_refContentApi.AppPath + "library.aspx?action=ViewLibraryItem&id=" + search_result[idx].LibraryID + "&parent_id=" + search_result[idx].LibraryParentID + "&backpage=history"; result.Append("this.assets[" + idx.ToString() + "].quickLink = " + PrepTextForJava(linkStr)); result.Append("this.assets[" + idx.ToString() + "].__previewurl = null;" + "\r\n"); result.Append("this.assets[" + idx.ToString() + "].lastEditorFirstName = " + PrepTextForJava((string)(search_result[idx].LastEditorFname))); result.Append("this.assets[" + idx.ToString() + "].lastEditorLastName = " + PrepTextForJava(search_result[idx].LastEditorLname)); result.Append("this.assets[" + idx.ToString() + "].dateModified = " + PrepTextForJava((string)(search_result[idx].DisplayDateModified))); result.Append("this.assets[" + idx.ToString() + "].teaser = " + PrepTextForJava(CleanText(search_result[idx].Teaser))); result.Append("this.assets[" + idx.ToString() + "].content = \'\';" + "\r\n"); result.Append("this.assets[" + idx.ToString() + "].lastModified = \'\';" + "\r\n"); result.Append("this.assets[" + idx.ToString() + "].editorFirstName = " + PrepTextForJava(search_result[idx].LastEditorFname)); result.Append("this.assets[" + idx.ToString() + "].editorLastName = " + PrepTextForJava(search_result[idx].LastEditorLname)); result.Append("this.assets[" + idx.ToString() + "].title = " + PrepTextForJava(search_result[idx].LibraryTitle)); itemsCount++; } else { // Non library items (also filter out duplicates from the library): if (search_result[idx].LibraryTypeID == 0) { result.Append("this.assets[" + idx.ToString() + "] = new myAssets;" + "\r\n"); if (EkConstants.IsAssetContentType(Convert.ToInt64(search_result[idx].ContentType), true) || (search_result[idx].ContentType == EkEnumeration.CMSContentType.Assets)) { result.Append("this.assets[" + idx.ToString() + "].type = \'1\'; // value is numerical, signals type is a document." + "\r\n"); result.Append("this.assets[" + idx.ToString() + "].thumbnailUrl = " + PrepTextForJava(GetThumbnailUrl(search_result[idx].ContentText))); } else { result.Append("this.assets[" + idx.ToString() + "].type = \'c\'; // value non-numerical, signals type is content." + "\r\n"); result.Append("this.assets[" + idx.ToString() + "].thumbnailUrl = \'\';" + "\r\n"); } //don't use standard quicklink, db may point to wrong template... result.Append("this.assets[" & idx.ToString & "].quickLink = '" & search_result(idx).QuickLink & "';" & vbCrLf) linkStr = GetLink(search_result[idx]); if (templateStr.Length > 0) { imageStr = templateStr + "id=" + search_result[idx].ID + "&folder=" + search_result[idx].FolderID; } else { imageStr = ""; } result.Append("this.assets[" + idx.ToString() + "].quickLink = " + PrepTextForJava(linkStr)); result.Append("this.assets[" + idx.ToString() + "].imageLink = " + PrepTextForJava(imageStr)); result.Append("this.assets[" + idx.ToString() + "].__previewurl = null;" + "\r\n"); result.Append("this.assets[" + idx.ToString() + "].lastEditorFirstName = " + PrepTextForJava(search_result[idx].LastEditorFname)); result.Append("this.assets[" + idx.ToString() + "].lastEditorLastName = " + PrepTextForJava(search_result[idx].LastEditorLname)); result.Append("this.assets[" + idx.ToString() + "].dateModified = " + PrepTextForJava(search_result[idx].DisplayDateModified)); result.Append("this.assets[" + idx.ToString() + "].teaser = " + PrepTextForJava(CleanText(search_result[idx].Teaser))); result.Append("this.assets[" + idx.ToString() + "].content = \'\';" + "\r\n"); result.Append("this.assets[" + idx.ToString() + "].lastModified = \'\';" + "\r\n"); result.Append("this.assets[" + idx.ToString() + "].editorFirstName = " + PrepTextForJava((string)(search_result[idx].LastEditorFname))); result.Append("this.assets[" + idx.ToString() + "].editorLastName = " + PrepTextForJava((string)(search_result[idx].LastEditorLname))); result.Append("this.assets[" + idx.ToString() + "].title = " + PrepTextForJava(search_result[idx].Title)); itemsCount++; } } } result.Append("}" + "\r\n"); result.Append("goDisplay();"); } result.Append("</script>"); if (itemsCount > 0) { dimStr = "this.assets = new Array(" + itemsCount.ToString() + ");" + "\r\n"; resultLit.Text = firstPartStr + dimStr + result.ToString(); } else { resultLit.Text = m_refMsg.GetMessage("lbl search results"); } PostBack_DoFindContentToolBar(Convert.ToInt32(itemsCount)); } catch (Exception ex) { throw (new Exception("[iSearch.asx.vb->BuildGraphicalResults] " + ex.Message)); } }
// Display Mixed-Mode content search results: private void Populate_SearchResultGrid_Content_Mixed(SearchAssetRequest sar) { try { bool bIsDms; long itemsCount = 0; string strDestLoc = ""; string strFileName = ""; string strImageFile = ""; string strNewImageFile = ""; string strExtn = ""; string[] arrFilePath; FileInfo fs = null; long contentId; DataTable dt = new DataTable(); DataRow dr; int idx = 0; int iDR; bIsDms = false;//sar.SearchAssets; System.Web.UI.WebControls.BoundColumn colBound = new System.Web.UI.WebControls.BoundColumn(); colBound.DataField = "TITLE"; colBound.HeaderText = m_refMsg.GetMessage("generic title"); colBound.ItemStyle.Wrap = false; colBound.HeaderStyle.CssClass = "title-header"; SearchResultGrid.Columns.Add(colBound); colBound = new System.Web.UI.WebControls.BoundColumn(); colBound.DataField = "LastEditDate"; colBound.HeaderText = m_refMsg.GetMessage("lbl last edit date"); colBound.ItemStyle.Wrap = false; colBound.HeaderStyle.CssClass = "title-header"; SearchResultGrid.Columns.Add(colBound); colBound = new System.Web.UI.WebControls.BoundColumn(); colBound.DataField = "VALUE"; colBound.HeaderText = m_refMsg.GetMessage("lbl folder name"); colBound.ItemStyle.Wrap = false; colBound.HeaderStyle.CssClass = "title-header"; SearchResultGrid.Columns.Add(colBound); if (bIsDms) { colBound = new System.Web.UI.WebControls.BoundColumn(); colBound.DataField = "Size"; colBound.HeaderText = m_refMsg.GetMessage("lbl size"); colBound.HeaderStyle.HorizontalAlign = HorizontalAlign.Right; colBound.ItemStyle.HorizontalAlign = HorizontalAlign.Right; colBound.ItemStyle.Wrap = false; colBound.HeaderStyle.HorizontalAlign = HorizontalAlign.Right; colBound.ItemStyle.HorizontalAlign = HorizontalAlign.Right; colBound.HeaderStyle.CssClass = "title-header"; SearchResultGrid.Columns.Add(colBound); colBound = new System.Web.UI.WebControls.BoundColumn(); colBound.DataField = "DMSRank"; colBound.HeaderText = m_refMsg.GetMessage("lbl dms rank"); colBound.HeaderStyle.HorizontalAlign = HorizontalAlign.Right; colBound.ItemStyle.HorizontalAlign = HorizontalAlign.Right; colBound.ItemStyle.Wrap = false; colBound.HeaderStyle.CssClass = "title-header"; SearchResultGrid.Columns.Add(colBound); } colBound = new System.Web.UI.WebControls.BoundColumn(); colBound.DataField = "Language"; colBound.HeaderText = m_refMsg.GetMessage("generic language"); colBound.ItemStyle.Wrap = false; colBound.HeaderStyle.CssClass = "title-header"; SearchResultGrid.Columns.Add(colBound); colBound = new System.Web.UI.WebControls.BoundColumn(); colBound.DataField = "Status"; colBound.HeaderText = m_refMsg.GetMessage("generic status"); colBound.ItemStyle.Wrap = false; colBound.HeaderStyle.CssClass = "title-header"; SearchResultGrid.Columns.Add(colBound); dt.Columns.Add(new DataColumn("TITLE", typeof(string))); dt.Columns.Add(new DataColumn("LastEditDate", typeof(string))); dt.Columns.Add(new DataColumn("VALUE", typeof(string))); if (bIsDms) { dt.Columns.Add(new DataColumn("Size", typeof(string))); dt.Columns.Add(new DataColumn("DMSRank", typeof(string))); } dt.Columns.Add(new DataColumn("Language", typeof(string))); dt.Columns.Add(new DataColumn("Status", typeof(string))); if (!(search_result == null)) { // first show all image-items: for (idx = 0; idx <= search_result.Length - 1; idx++) { if (search_result[idx].ContentType == EkEnumeration.CMSContentType.LibraryItem) { if (search_result[idx].LibraryTypeID == 1) { dr = dt.NewRow(); strDestLoc = search_result[idx].LibraryFileName; // Link strFileName = strDestLoc; arrFilePath = strDestLoc.Split('/'); strImageFile = (string)(arrFilePath[arrFilePath.Length - 1]); strExtn = strImageFile.Substring(strImageFile.Length - 3, 3); if ("gif" == strExtn) { strExtn = "png"; strNewImageFile = "thumb_" + strImageFile.Substring(0, strImageFile.Length - 3) + "png"; } else { strNewImageFile = (string)("thumb_" + strImageFile); } strDestLoc = strDestLoc.Replace(strImageFile, strNewImageFile); fs = new FileInfo(Server.MapPath(strDestLoc)); if ((fs.Exists) == true) { dr[0] = "<a href=\"library.aspx?action=ViewLibraryItem&id=" + search_result[idx].LibraryID + "&parent_id=" + search_result[idx].LibraryParentID + "&backpage=history\" title=\"" + search_result[idx].LibraryTitle + "\">"; dr[0] += "<img src=\"" + strDestLoc + "\" border=\"0\" width=\"125\"></a>"; } else { dr[0] = "<a href=\"library.aspx?action=ViewLibraryItem&id=" + search_result[idx].LibraryID + "&parent_id=" + search_result[idx].LibraryParentID + "&backpage=history\">" + search_result[idx].LibraryTitle + "</a>"; } if (search_result[idx].ID > 0) { contentId = search_result[idx].ID; if (contentId > 0) { dr[1] = search_result[idx].Teaser; } } dt.Rows.Add(dr); itemsCount++; dr = dt.NewRow(); dt.Rows.Add(dr); } } } // now do non-images: for (idx = 0; idx <= search_result.Length - 1; idx++) { if (search_result[idx].ContentType == EkEnumeration.CMSContentType.LibraryItem) { if (search_result[idx].LibraryTypeID != 1) { dr = dt.NewRow(); dr[0] = "<a href=\"library.aspx?action=ViewLibraryItem&id=" + search_result[idx].LibraryID + "&parent_id=" + search_result[idx].LibraryParentID + "&backpage=history\">" + search_result[idx].LibraryTitle + "</a>"; dr[1] = m_strLibType + " " + search_result[idx].LibraryFileName; //.Link dt.Rows.Add(dr); itemsCount++; dr = dt.NewRow(); dt.Rows.Add(dr); } } else { // filter out duplicates from the library: if (search_result[idx].LibraryTypeID == 0) { dr = dt.NewRow(); string link = GetLink(search_result[idx]); dr[0] = "<a href=\"" + link + "\">" + search_result[idx].Title + "</a>"; dr[1] = search_result[idx].DisplayDateModified; dr[2] = search_result[idx].FolderPath; if (bIsDms) { dr[3] = search_result[idx].Size; dr[4] = search_result[idx].Rank; iDR = 5; } else { iDR = 3; } dr[iDR] = search_result[idx].LanguageID; iDR++; dr[iDR] = search_result[idx].ItemStatus; iDR++; dt.Rows.Add(dr); itemsCount++; dr = dt.NewRow(); dt.Rows.Add(dr); } } } } else { dr = dt.NewRow(); dr[0] = m_refMsg.GetMessage("lbl search results"); dr[1] = "REMOVE-ITEM"; dr[2] = "REMOVE-ITEM"; dr[3] = "REMOVE-ITEM"; dr[4] = "REMOVE-ITEM"; if (bIsDms) { dr[5] = "REMOVE-ITEM"; dr[6] = "REMOVE-ITEM"; } dt.Rows.Add(dr); } DataView dv = new DataView(dt); SearchResultGrid.DataSource = dv; SearchResultGrid.DataBind(); PostBack_DoFindContentToolBar(Convert.ToInt32(itemsCount)); } catch (Exception ex) { throw (new Exception("[iSearch.asx.vb->Populate_SearchResultGrid_Content_Mixed] " + ex.Message)); } }