/// <summary> /// This should return the fields from ActivityLibraries and StoreActivities tables /// to match the MarketplaceAssetDetails data contract /// </summary> /// <param name="request"></param> /// <returns>MarketplaceAssetDetails object</returns> public static MarketplaceAssetDetails GetMarketplaceAssetDetails(MarketplaceSearchDetail request) { MarketplaceAssetDetails reply = null; List<ActivityQuickInfo> activities = new List<ActivityQuickInfo>(); try { Database database = DatabaseFactory.CreateDatabase(); DbCommand command = database.GetStoredProcCommand("[dbo].[Marketplace_GetAssetDetails]"); database.AddParameter(command, StoredProcParamNames.Id, DbType.Int64, ParameterDirection.Input, null, DataRowVersion.Default, request.Id); database.AddParameter(command, "@AssetType", DbType.Int16, ParameterDirection.Input, null, DataRowVersion.Default, request.AssetType); using (IDataReader reader = database.ExecuteReader(command)) { if (reader.Read()) { reply = new MarketplaceAssetDetails(); reply.Id = Convert.ToInt64(reader["Id"]); reply.Name = Convert.ToString(reader["Name"]); reply.Description = Convert.ToString(reader["Description"]); reply.MetaTages = Convert.ToString(reader["MetaTags"]); reply.CategoryName = Convert.ToString(reader["CategoryName"]); reply.ThumbnailUrl = Convert.ToString(reader["ThumbnailUrl"]); if (request.AssetType == AssetType.Activities) { reader.NextResult(); while (reader.Read()) { ActivityQuickInfo activity = new ActivityQuickInfo(); activity.Version = Convert.ToString(reader["Version"]); activity.Id = Convert.ToInt64(reader["ActivityId"]); activity.Name = Convert.ToString(reader["ActivityName"]); activities.Add(activity); } reply.Activities = activities; } } } } catch (SqlException e) { e.HandleException(); } return reply; }
/// <summary> /// load marketplace details data for UI displaying /// </summary> /// <param name="client"></param> public void SearchMarketplaceAssertDetails(IWorkflowsQueryService client) { if (assetItem == null) return; MarketplaceSearchDetail search = new MarketplaceSearchDetail(); search.AssetType = assetItem.AssetType; search.Id = assetItem.Id; details = client.GetMarketplaceAssetDetails(search); RaisePropertyChanged(() => MetaDataVisible); RaisePropertyChanged(() => ActivitiesVisible); if (details != null) { this.MarketplaceAssetFieldValues.Clear(); AssetName = this.details.Name; this.MarketplaceAssetFieldValues.Add(new FieldValue() { Field = "Type", Value = this.assetItem.AssetType.ToString() }); this.MarketplaceAssetFieldValues.Add(new FieldValue() { Field = "Version", Value = this.assetItem.Version, }); if (assetItem.AssetType == AssetType.Activities) { this.MarketplaceAssetFieldValues.Add(new FieldValue() { Field = "Category", Value = details.CategoryName, }); if (details.Activities != null && details.Activities.Count > 0) { this.MarketplaceAssetFieldValues.Add(new FieldValue() { Field = "Activities", Value = details.Activities.Count.ToString(), }); this.IncludedActivities = new ObservableCollection<ActivityQuickInfo>(details.Activities); this.RightPaneTitle = "INCLUDED ACTIVITIES(" + this.IncludedActivities.Count + ")"; } else { this.RightPaneTitle = "INCLUDED ACTIVITIES(0)"; this.MarketplaceAssetFieldValues.Add(new FieldValue() { Field = "Activities", Value = "None", }); } } this.MarketplaceAssetFieldValues.Add(new FieldValue() { Field = "Description", Value = details.Description, }); this.MarketplaceAssetFieldValues.Add(new FieldValue() { Field = "Tags", Value = details.MetaTages, }); this.IconUrl = details.ThumbnailUrl; } }