public void VerifySearchMarketplaceForActivities() { string searchText = "Publishing"; //Create request searchRequest = GenerateSearchRequest(searchText, MarketplaceFilter.Activities); //Send request MarketplaceSearchResult result = SearchMarketplace(searchRequest); //Verification Assert.AreEqual(result.Items.Count, 2, "Search result incorrect."); Assert.AreEqual(result.Items[0].Name, "Publishing", "Failed to search Marketplace."); Assert.AreEqual(result.Items[1].Name, "PublishingInfo", "Failed to search Marketplace."); }
private static MarketplaceSearchQuery CreateMarketplaceGetRequest() { MarketplaceSearchQuery request=new MarketplaceSearchQuery(); request.SearchText = "microsoft"; request.FilterType = CWF.DataContracts.Marketplace.MarketplaceFilter.Activities; request.PageSize = 15; request.PageNumber = 1; request.UserRole = "Admin"; request.SortCriteria = new List<CWF.DataContracts.Marketplace.SortCriterion> { new CWF.DataContracts.Marketplace.SortCriterion() { FieldName="Name", IsAscending=true, }}; return request; }
private static Tuple<int, bool?, bool?> ConvertSearchQueryToStoredProc(MarketplaceSearchQuery request) { return (from rule in marketplaceSearchRules where rule.FilterType == request.FilterType && rule.UserRole == request.UserRole select new Tuple<int, bool?, bool?>(rule.AssetType, rule.IsGetTemplates, rule.IsGetPublishingWorkflows)) .FirstOrDefault(); }
/// <summary> /// Find Executable items /// Find XAML items /// Union Executable items and XAML items if the union is needed. /// Union happens only when the filter in the UI is set to “All” which means no filtering is applied. /// In all other filter values we either search for XAML items or for Executable items. /// Apply filtering Apply sorting /// Select the requested page /// </summary> /// <param name="request"></param> /// <returns>MarketplaceSearchResult object</returns> public static MarketplaceSearchResult SearchMarketplace(MarketplaceSearchQuery request) { MarketplaceSearchResult result = null; var resultCollection = new List<MarketplaceAsset>(); MarketplaceAsset sab = null; try { var spInputParam = ConvertSearchQueryToStoredProc(request); if (spInputParam == null) throw new ArgumentException(string.Format("Marketplace Search Query is error. Filter: {0} or UserRole: {1}", request.FilterType,request.UserRole)); //This is an invalid operation since the author is not allowed to view templates or publishing workflows. if (request.UserRole == Author && (request.FilterType == MarketplaceFilter.Templates || request.FilterType == MarketplaceFilter.PublishingWorkflows)) return null; if (request.SortCriteria == null) request.SortCriteria = new List<SortCriterion>() { new SortCriterion() { FieldName = "UpdatedDate", IsAscending = false } }; Database database = DatabaseFactory.CreateDatabase(); DbCommand command = database.GetStoredProcCommand("[dbo].[Marketplace_Search]"); database.AddParameter(command, "@SearchText", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.SearchText); database.AddParameter(command, "@AssetType", DbType.Int16, ParameterDirection.Input, null, DataRowVersion.Default, spInputParam.Item1); database.AddParameter(command, "@GetTemplates", DbType.Byte, ParameterDirection.Input, null, DataRowVersion.Default, spInputParam.Item2); database.AddParameter(command, "@GetPublishingWorkflows", DbType.Byte, ParameterDirection.Input, null, DataRowVersion.Default, spInputParam.Item3); database.AddParameter(command, "@PageSize", DbType.Int32, ParameterDirection.Input, null, DataRowVersion.Default, request.PageSize); database.AddParameter(command, "@PageNumber", DbType.Int32, ParameterDirection.Input, null, DataRowVersion.Default, request.PageNumber); database.AddParameter(command, "@SortColumn", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.SortCriteria[0].FieldName); database.AddParameter(command, "@SortAscending", DbType.Byte, ParameterDirection.Input, null, DataRowVersion.Default, request.SortCriteria[0].IsAscending); database.AddParameter(command, "@FilterOlder", DbType.Byte, ParameterDirection.Input, null, DataRowVersion.Default, request.IsNewest); using (IDataReader reader = database.ExecuteReader(command)) { while (reader.Read()) { result = new MarketplaceSearchResult(); sab = new MarketplaceAsset(); sab.Id = Convert.ToInt64(reader["Id"]); sab.Name = Convert.ToString(reader["Name"]); sab.CreatedBy = Convert.ToString(reader["InsertedByUserAlias"]); sab.UpdatedBy = Convert.ToString(reader["UpdatedByUserAlias"]); sab.UpdatedDate = Convert.ToDateTime(reader["UpdatedDateTime"]); sab.Version = Convert.ToString(reader["Version"]); if (Convert.ToString(reader["AssetType"]) == "XAML") sab.AssetType = AssetType.Project; else sab.AssetType = AssetType.Activities; sab.IsTemplate = reader["IsTemplate"] == DBNull.Value ? (bool?)null : Convert.ToBoolean(reader["IsTemplate"]); sab.IsPublishingWorkflow = reader["IsPublishingWorkflow"] == DBNull.Value ? (bool?)null : Convert.ToBoolean(reader["IsPublishingWorkflow"]); resultCollection.Add(sab); } reader.NextResult(); if (reader.Read()) { result.PageNumber = Convert.ToInt32(reader["PageNumber"]); result.PageCount = Convert.ToInt32(reader["PageCount"]); } if (result != null) { result.Items = resultCollection; result.PageSize = request.PageSize; } } } catch (SqlException ex) { ex.HandleException(); } return result; }
public MarketplaceSearchResult SearchMarketplace(MarketplaceSearchQuery request) { return MarketplaceRepositoryService.SearchMarketplace(request); }
public void VerifySearchMarketplaceForNotExist() { string searchText = "Not_Exist_Workflow"; //Create request searchRequest = GenerateSearchRequest(searchText, MarketplaceFilter.PublishingWorkflows); //Send request MarketplaceSearchResult result = SearchMarketplace(searchRequest); //Verification Assert.IsNull(result, "Search result incorrect."); }
/// <summary> /// Calling Query service for searching marketplace /// </summary> /// <param name="request">MarketplaceSearchQuery</param> /// <returns>MarketplaceSearchResult</returns> private MarketplaceSearchResult SearchMarketplace(MarketplaceSearchQuery request) { return devBranchProxy.SearchMarketplace(request); }
/// <summary> /// Generate MarketplaceSearch Query instance /// </summary> /// <param name="searchText">Text for searching</param> /// <param name="filterType">Filter type</param> /// <param name="userRole">User Role (Admin / Author)</param> /// <param name="pageNumber">Page Number</param> /// <param name="pageSize">Page Size</param> /// <returns>MarketplaceSearchQuery</returns> private MarketplaceSearchQuery GenerateSearchRequest(string searchText, MarketplaceFilter filterType, string userRole = "Admin", int pageNumber = 1, int pageSize = 15) { MarketplaceSearchQuery query = new MarketplaceSearchQuery(); SortCriterion sortCriterion = new SortCriterion(); sortCriterion.FieldName = "Name"; sortCriterion.IsAscending = true; query.UserRole = userRole; query.FilterType = filterType; query.SearchText = searchText; query.PageNumber = pageNumber; query.PageSize = pageSize; query.IsNewest = true; query.SortCriteria = new List<SortCriterion>() { sortCriterion }; return query; }
public void VerifySearchMarketplaceForTemplates() { string searchText = "PageTemplate_WorkflowLibrary"; //Create request searchRequest = GenerateSearchRequest(searchText, MarketplaceFilter.Templates); //Send request MarketplaceSearchResult result = SearchMarketplace(searchRequest); //Verification Assert.AreEqual(result.Items.Count, 1, "Search result incorrect."); Assert.AreEqual(result.Items[0].Name, "PageTemplate_WorkflowLibrary", "Failed to search Marketplace."); Assert.AreEqual(result.Items[0].IsTemplate, true, "Search result incorrect."); }
public void VerifySearchMarketplaceForProjects() { string searchText = "Publishing"; //Create request searchRequest = GenerateSearchRequest(searchText, MarketplaceFilter.Projects); //Send request MarketplaceSearchResult result = SearchMarketplace(searchRequest); //Verification Assert.AreEqual(result.Items[0].Name, "PublishingWorkflow_WorkflowLibrary", "Failed to search Marketplace."); }
public static MarketplaceSearchResult SearchMarketplace(MarketplaceSearchQuery request) { return Microsoft.Support.Workflow.Service.DataAccessServices.MarketplaceRepositoryService.SearchMarketplace(request); }