Exemplo n.º 1
0
 private void OnNewDeleteSelectedItemCommand()
 {
     if (SelectedDataGridItem != null)
     {
         ResponseCollection.Remove(SelectedDataGridItem);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Gets all objects from the endpoint
        /// </summary>
        /// <returns></returns>
        public ResponseCollection <T> GetAll()
        {
            string response = _reqManager.Get(_endPoint);
            ResponseCollection <T> results = JsonConvert.DeserializeObject <ResponseCollection <T> >(response);

            return(results);
        }
Exemplo n.º 3
0
        static void OutFuncDate(DateTime dataDa, DateTime dataA, List <FilterDefinition <BsonDocument> > listFilter, out int count)
        {
            count = 0;
            ResponseCollection <BsonDocument> response = new ResponseCollection <BsonDocument>();

            try
            {
                string dataDaString = String.Format("{0}-{1}-{2}", dataDa.Year.ToString("D2"), dataDa.Month.ToString("D2"), dataDa.Day.ToString("D2"));
                string dataAString  = String.Format("{0}-{1}-{2}", dataA.Year.ToString("D2"), dataA.Month.ToString("D2"), dataA.Day.ToString("D2"));
                var    builder      = Builders <BsonDocument> .Filter;
                if (dataDa.Year == 1)
                {
                    if (listFilter.Count > 0)
                    {
                        count = 0;
                        for (int i = 0; i < 3; i++)
                        {
                            IMongoDatabase myDB = mongoClient.GetDatabase(DatabaseName.BAM);
                            IMongoCollection <BsonDocument> collection = myDB.GetCollection <BsonDocument>(CollectionsName.Elab_Movimenti[i].ToString());
                            //var pippo = collection.Aggregate().Match(builder.And(listFilter.ToArray())).
                            //    Project(new BsonDocument { { DatabaseColumnsName._id, 0 }, { DatabaseColumnsName._idMovimento, 1 } });
                            response.collection = collection.Aggregate().Match(builder.And(listFilter.ToArray())).
                                                  Group(new BsonDocument {
                                { DatabaseColumnsName._id, 0 }, { DatabaseColumnsName.Count, new BsonDocument {
                                                                      { "$sum", 1 }
                                                                  } }
                            }).ToList();
                            count += response.collection[0].GetValue(DatabaseColumnsName.Count).ToInt32();
                        }
                    }
                }
                else
                {
                    if (dataDa > DateTime.Parse("01/01/" + dataDa.Year.ToString()))
                    {
                        listFilter.Add(builder.Gte(DatabaseColumnsName.DDATA, dataDaString));
                    }
                    if (dataA < DateTime.Parse("31/12/" + dataA.Year.ToString()))
                    {
                        listFilter.Add(builder.Lte(DatabaseColumnsName.DDATA, dataAString));
                    }
                    if (listFilter.Count > 0)
                    {
                        IMongoDatabase myDB = mongoClient.GetDatabase(DatabaseName.BAM);
                        IMongoCollection <BsonDocument> collection = myDB.GetCollection <BsonDocument>(CollectionsName.Elab_Movimenti + dataDa.Year.ToString());
                        response.collection = collection.Aggregate().Match(builder.And(listFilter.ToArray())).
                                              Group(new BsonDocument {
                            { DatabaseColumnsName._id, 0 }, { DatabaseColumnsName.Count, new BsonDocument {
                                                                  { "$sum", 1 }
                                                              } }
                        }).ToList();
                        count += response.collection[0].GetValue(DatabaseColumnsName.Count).ToInt32();
                    }
                }
            }
            catch (Exception ex)
            {
                response.result.AddError(ex);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Combo items
        /// </summary>
        /// <param name="data_param"></param>
        /// <param name="page"></param>
        /// <param name="pageSize"></param>
        /// <param name="sort_by"></param>
        /// <returns>Returns null if fails else object with or without data.</returns>
        public virtual ResponseCollection GetComboItems(DynamicDictionary data_param, int page = -1, int pageSize = 20, string sort_by = null)
        {
            IEnumerable <dynamic> items = null;
            ResponseCollection    resp  = new ResponseCollection(false, string.Empty);

            using (DbConnect con = new DbConnect())
            {
                items = SearchRepo.GetComboItems(con, data_param, page, pageSize, sort_by);
            }
            if (Errors.Count > 0)
            {
                resp.message = "Combo Data load failed.";
                resp.PushErrors(Errors);
            }
            else
            {
                if (items != null && items.Count() > 0)
                {
                    resp         = ServiceUtility.CaculatePaging(resp, items.Count(), page, pageSize);
                    resp.data    = items;
                    resp.message = "Combo items loaded successfully.";
                }
                else
                {
                    resp.message = "Combo data not found as per search condition";
                }
                resp.success = true;
            }
            return(resp);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Binds the <see cref="ReportExportGrid"/>.
        /// </summary>
        private void BindReport()
        {
            var reportReader            = ResponseCollection.LoadReport(DateTime.Now, null, this.CategoryIds);
            var categoryNameColumnIndex = reportReader.GetOrdinal("CategoryName");
            var eventTitleColumnIndex   = reportReader.GetOrdinal("EventTitle");
            var eventStartColumnIndex   = reportReader.GetOrdinal("EventStart");
            var eventEndColumnIndex     = reportReader.GetOrdinal("EventEnd");
            var firstNameColumnIndex    = reportReader.GetOrdinal("FirstName");
            var lastNameColumnIndex     = reportReader.GetOrdinal("LastName");
            var emailColumnIndex        = reportReader.GetOrdinal("Email");
            var responseDateColumnIndex = reportReader.GetOrdinal("ResponseDate");
            var statusColumnIndex       = reportReader.GetOrdinal("Status");

            this.ReportExportGrid.DataSource = reportReader.AsEnumerable().Select(row => new
            {
                CategoryName  = string.IsNullOrEmpty(row.GetString(categoryNameColumnIndex)) ? this.GetDefaultCategoryName() : row.GetString(categoryNameColumnIndex),
                EventTitle    = row.GetString(eventTitleColumnIndex),
                EventStart    = row.GetDateTime(eventStartColumnIndex),
                EventEnd      = row.GetDateTime(eventEndColumnIndex),
                ResponderName = row.GetString(firstNameColumnIndex) + " " + row.GetString(lastNameColumnIndex),
                Email         = row.GetString(emailColumnIndex),
                ResponseDate  = row.GetDateTime(responseDateColumnIndex),
                Status        = this.Localize(row.GetString(statusColumnIndex)),
            });
            this.ReportExportGrid.DataBind();
        }
Exemplo n.º 6
0
        public ResponseCollection <User> GetAssignedAssets(ICommonEndpointModel user)
        {
            string response = _reqManager.Get(string.Format("{0}/{1}/assets", _endPoint, user.Id));
            ResponseCollection <User> results = JsonConvert.DeserializeObject <ResponseCollection <User> >(response);

            return(results);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Binds the data.
        /// </summary>
        /// <param name="sortColumn">The sort column.</param>
        /// <param name="getAll">if set to <c>true</c> gets all responses, regardless of page size or number; otherwise only gets one page of responses.</param>
        private void BindData(string sortColumn, bool getAll)
        {
            int?eventId = this.EventId;

            if (!eventId.HasValue)
            {
                return;
            }

            var responseSummary = Engage.Events.ResponseSummary.Load(eventId.Value, this.EventStart);

            if (!this.CanShowEvent(responseSummary.Event))
            {
                return;
            }

            int pageIndex = getAll ? 0 : this.CurrentPageIndex - 1;
            int pageSize  = getAll ? 0 : this.ResponseDetailGrid.PageSize;
            ResponseCollection responses = ResponseCollection.Load(eventId.Value, this.EventStart, this.Status, sortColumn, pageIndex, pageSize, this.CategoryIds);

            this.ResponseDetailGrid.DataSource = responses;
            this.ResponseDetailGrid.DataBind();
            ////this.ResponseDetailGrid.Attributes.Add("SortColumn", sortColumn);

            this.ResponsePager.PageSize = this.ResponseDetailGrid.PageSize;
            this.SetupPagingControl(this.ResponsePager, responses.TotalRecords, "modId", "key", "status", "eventId", "start");

            this.responseDisplay.SetResponseSummary(responseSummary);
            this.responseDisplay.ModuleConfiguration = this.ModuleConfiguration;
        }
Exemplo n.º 8
0
        /// <summary>
        /// Search for Assets that match filters defined in an ISearchFilter object.
        /// </summary>
        /// <param name="filter"></param>
        /// <returns></returns>
        public ResponseCollection <T> FindAll(ISearchFilter filter)
        {
            string response = _reqManager.Get(_endPoint, filter);
            ResponseCollection <T> results = JsonConvert.DeserializeObject <ResponseCollection <T> >(response);

            return(results);
        }
Exemplo n.º 9
0
		public async Task<ActionResult> Category(string id)
		{
			CategoryResults retVal = new CategoryResults();

			var category = await SearchClient.GetCategoryByCodeAsync("MarketPlace", "en-US", id);

			if (category != null)
			{
				var query = new BrowseQuery();
				query.Filters = new Dictionary<string, string[]>();
				query.Outline = GetOutline(category);

				var products = await SearchClient.GetProductsAsync("MarketPlace", "en-Us", query, ItemResponseGroups.ItemLarge);
				retVal.Modules.AddRange(products.Items.Select(i => i.ToWebModel()));
				foreach (var module in retVal.Modules)
				{
					var reviews = new ResponseCollection<Review>(); //await ReviewsClient.GetReviewsAsync(module.Keyword);
					module.Reviews.AddRange(reviews.Items.Select(i => i.ToWebModel(module.Keyword)));
				}

				retVal.CategoryCode = category.Code;
				retVal.CategoryName = category.Name;
			}

			if(category.Seo.Any())
			{
				ViewBag.Title = category.Seo[0].Title;
				ViewBag.Description = category.Seo[0].MetaDescription;
			}

			return View(retVal);
		}
Exemplo n.º 10
0
 private void InitstrategyList(Hub hub, string incommingMessage)
 {
     ResponseCollection.Add("Hello", new HiResponse(incommingMessage, hub)); //one second delay
     ResponseCollection.Add("Bye", new ByeResponse(incommingMessage, hub));  //close connection
     ResponseCollection.Add("Ping", new PingResponse(incommingMessage, hub));
     //other should raise exception in client
 }
Exemplo n.º 11
0
        public ResponseCollection <StatusLabel> GetAssignedAssets(ICommonEndpointModel statusLabel)
        {
            string response = _reqManager.Get(string.Format("{0}/{1}/assetlist", _endPoint, statusLabel.Id));
            ResponseCollection <StatusLabel> results = JsonConvert.DeserializeObject <ResponseCollection <StatusLabel> >(response);

            return(results);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Finds all objects that match the filter and returns the first
        /// </summary>
        /// <param name="filter"></param>
        /// <returns></returns>
        public T FindOne(ISearchFilter filter)
        {
            string response = _reqManager.Get(_endPoint, filter);
            ResponseCollection <T> result = JsonConvert.DeserializeObject <ResponseCollection <T> >(response);

            return((result.Rows != null) ? result.Rows[0] : default(T));
        }
        public static string GridRows(
            SiteSettings ss,
            ResponseCollection res = null,
            int offset             = 0,
            bool clearCheck        = false,
            Message message        = null)
        {
            var view     = Views.GetBySession(ss);
            var gridData = GetGridData(ss, view, offset: offset);

            return((res ?? new ResponseCollection())
                   .Remove(".grid tr", _using: offset == 0)
                   .ClearFormData("GridCheckAll", _using: clearCheck)
                   .ClearFormData("GridUnCheckedItems", _using: clearCheck)
                   .ClearFormData("GridCheckedItems", _using: clearCheck)
                   .CloseDialog()
                   .ReplaceAll("#Aggregations", new HtmlBuilder().Aggregations(
                                   ss: ss,
                                   aggregations: gridData.Aggregations),
                               _using: offset == 0)
                   .Append("#Grid", new HtmlBuilder().GridRows(
                               ss: ss,
                               gridData: gridData,
                               view: view,
                               addHeader: offset == 0,
                               clearCheck: clearCheck))
                   .Val("#GridOffset", ss.GridNextOffset(
                            offset,
                            gridData.DataRows.Count(),
                            gridData.Aggregations.TotalCount))
                   .Paging("#Grid")
                   .Message(message)
                   .ToJson());
        }
Exemplo n.º 14
0
 protected override void Filter(IRequestBusContext context, TestRequest request,
                                ResponseCollection <TestResult> rspCollection)
 {
     rspCollection.AddResponse(Response.Ok(new TestResult
     {
         Message = $"{request.Name} filtered by {this.GetType().Name}"
     }));
 }
        protected NegotiatedContentResult <ResponseCollection <T> > GetResponse <T>(IEnumerable <Item <T> > results)
            where T : IBaseApiModel
        {
            HttpStatusCode statusCode         = HttpStatusCode.OK;
            var            responseCollection = new ResponseCollection <T>(Request.RequestUri.PathAndQuery, results);

            return(Content(statusCode, responseCollection));
        }
Exemplo n.º 16
0
    static void ReadResponses(ResponseCollection responses)
    {
        Response res;

        while (responses.TryTake(out res, -1))
        {
            Console.WriteLine(res);
        }
    }
Exemplo n.º 17
0
    static void ReadResponses(ResponseCollection responses)
    {
        Response res;

        while (responses.TryTake(out res, -1))
        {
            Console.WriteLine("sending event with metadata {0} took {1}ms and got response code {2} with message \"{3}\"",
                              res.Metadata, res.Duration.TotalMilliseconds, (int)res.StatusCode, res.Body);
        }
    }
Exemplo n.º 18
0
        /// <summary>
        /// Attempts to find a given object by it's name.
        /// </summary>
        /// <param name="name">The name of the object we want to find</param>
        /// <returns></returns>
        ///
        public T Get(string name)
        {
            T result;

            name = name.ToLower();
            ResponseCollection <T> everything = GetAll();

            result = everything.Rows.Where(i => i.Name.ToLower() == name).FirstOrDefault();

            return(result);
        }
Exemplo n.º 19
0
 /// <inheritdoc />
 protected sealed override void EmitResults(ResponseCollection <Asset> collection)
 {
     foreach (var asset in collection)
     {
         var assetObj = PSObject.AsPSObject(asset);
         foreach (var pair in asset.CustomFields.Friendly)
         {
             assetObj.Properties.Add(new PSAssetCustomFieldProperty(pair.Key, pair.Key));
         }
         WriteObject(assetObj);
     }
 }
Exemplo n.º 20
0
        public static ResponseCollection Links(
            this ResponseCollection res,
            Context context,
            SiteSettings ss,
            long id,
            BaseModel.MethodTypes?methodType)
        {
            var dataSet = DataSet(
                context: context,
                ss: ss,
                id: id);
            var links = HtmlLinkCreations.Links(
                context: context,
                ss: ss);

            new[] { ss.TabName(0) }
            .Concat(ss.Tabs?.Select(tab => ss.TabName(tab.Id)) ?? new List <string>())
            .Select((tabName, tabIndex) => new { tabName, tabIndex })
            .ForEach(data =>
            {
                ss.EditorColumnHash?.Get(data.tabName)?.ForEach(columnName =>
                {
                    var linkId = ss.LinkId(columnName);
                    if (linkId > 0)
                    {
                        var sourceSs      = TargetSiteSettings(ss.Sources, linkId);
                        var destinationSs = TargetSiteSettings(ss.Destinations, linkId);
                        var targetSs      = sourceSs ?? destinationSs;
                        if (targetSs != null)
                        {
                            var direction = sourceSs != null
                                    ? "Source"
                                    : "Destination";
                            var dataTableName = DataTableName(
                                ss: targetSs,
                                direction: direction);
                            res.Html("#" + dataTableName + "Field", new HtmlBuilder().Link(
                                         context: context,
                                         ss: ss,
                                         id: id,
                                         linkId: linkId,
                                         direction: direction,
                                         targetSs: targetSs,
                                         links: links,
                                         dataSet: dataSet,
                                         methodType: methodType,
                                         tabIndex: data.tabIndex));
                        }
                    }
                });
            });
            return(res);
        }
        public async Task <ResponseCollection <ContentItem> > GetCollectionItems(string collection, int startIndex, int pageSize)
        {
            var allFiles = await _client.Repository.Contents.GetForPath(_repository.Owner, _repository.Name, collection);

            var collectionItems = allFiles.Select(item => new ContentItem()
            {
                Id = item.Name, Status = "Published"
            });

            var response = new ResponseCollection <ContentItem>();

            response.Items.AddRange(collectionItems);
            return(response);
        }
Exemplo n.º 22
0
		// GET: Module
		private ModulesModel Modules(BrowseQuery query)
		{
			var products = Task.Run(() => SearchClient.GetProductsAsync("MarketPlace", "en-US", query, ItemResponseGroups.ItemLarge)).Result;

			var retVal = new ModulesModel();
			retVal.Items.AddRange(products.Items.Select(i => i.ToWebModel()));

			foreach (var item in retVal.Items)
			{
				var reviews = new ResponseCollection<Review>(); //Task.Run(() => ReviewsClient.GetReviewsAsync(item.Keyword)).Result;
				item.Reviews.AddRange(reviews.Items.Select(i => i.ToWebModel(item.Keyword)));
			}

			return retVal;
		}
        public async Task <ResponseCollection <CollectionItem> > GetCollections()
        {
            var root = await _client.Repository.Contents.GetRoot(_repository.Owner, _repository.Name);

            // convert to Collection Item
            var collectionItems = root.Where(item => item.Type == ContentType.Dir).Select(item => new CollectionItem()
            {
                Id = item.Name, Name = item.Path
            }).ToArray();

            var response = new ResponseCollection <CollectionItem>();

            response.Items.AddRange(collectionItems);
            return(response);
        }
Exemplo n.º 24
0
        public static ResponseCollection ClearItemDataResponse(
            Context context, SiteSettings ss, long id)
        {
            var formDataSet = new FormDataSet(
                context: context,
                ss: ss);
            var res = new ResponseCollection().ClearFormData("Id");

            formDataSet
            .Where(o => !o.Suffix.IsNullOrEmpty())
            .Where(o => o.Id == id)
            .ForEach(formData =>
                     formData.Data.Keys.ForEach(controlId =>
                                                res.ClearFormData(controlId + formData.Suffix)));
            return(res);
        }
Exemplo n.º 25
0
        private static WidgetGroupResponse BuildWidgetGroupResponse(ResponseCollection <WidgetResponse> rsp)
        {
            var units = new List <WidgetUnitResponse>();

            var mainRsp = rsp.MainResponse();

            if (mainRsp != null)
            {
                if (!mainRsp.IsSucceed)
                {
                    return(new WidgetGroupResponse
                    {
                        Errors = mainRsp.Errors,
                        StatusCode = mainRsp.StatusCode ?? 400,
                        StatusReason = mainRsp.StatusReason,
                        Widgets = BuildWidgetUnitResponse(mainRsp)
                    });
                }

                if (!string.IsNullOrWhiteSpace(mainRsp.Value?.RedirectAction?.Url))
                {
                    return(new WidgetGroupResponse
                    {
                        RedirectAction = mainRsp.Value.RedirectAction,
                        StatusCode = mainRsp.StatusCode ?? 302,
                        StatusReason = mainRsp.StatusReason,
                        Widgets = BuildWidgetUnitResponse(mainRsp)
                    });
                }


                units.AddRange(BuildWidgetUnitResponse(mainRsp));
            }

            var otherRsp = rsp.OtherResponses();

            foreach (var otherResponse in otherRsp)
            {
                units.AddRange(BuildWidgetUnitResponse(otherResponse));
            }

            return(new WidgetGroupResponse
            {
                StatusCode = mainRsp?.StatusCode ?? 200,
                Widgets = units
            });
        }
Exemplo n.º 26
0
        public void Consume2()
        {
            var coll = new ResponseCollection(new BlockingCollection <Response> ());

            coll.Responses.Add(new Response());
            coll.Responses.Add(new Response());

            Response response1, response2, response3;

            coll.TryTake(out response1, 100);
            coll.TryTake(out response2, -1);
            coll.TryTake(out response3, 0);

            Assert.NotNull(response1);
            Assert.NotNull(response2);
            Assert.Null(response3);
        }
Exemplo n.º 27
0
        internal void SendHeartbeat(HeartbeatInfo info)
        {
            List <Server> list = new List <Server>();

            if (_shard != null && _shard.ActiveChannelsList != null)
            {
                Message msg = new Message();
                msg.MessageType   = MessageType.Heartbeat;
                msg.Payload       = info;
                msg.NeedsResponse = false;

                ShardMulticastRequest <ResponseCollection <object>, object> request = _shard.CreateMulticastRequest <ResponseCollection <object>, object>(_shard.ActiveChannelsList, msg);
                IAsyncResult result = request.BeginExecute();

                ResponseCollection <Object> response = request.EndExecute(result);
            }
        }
Exemplo n.º 28
0
 private void OnNewAddOrEditResponseCommand()
 {
     if (!ResponseCollection.Contains(ResponseObjectModel))
     {
         if (ResponseObjectModel.HasConfiguration == true)
         {
             ResponseCollection.Add(ResponseObjectModel);
         }
         else
         {
             new MessageBoxViewModel {
                 Caption = resLoader.getResource("messageBoxMissingConfigCaption"),
                 Message = resLoader.getResource("messageBoxMissingConfigMessage"),
                 Buttons = MessageBoxButton.OK,
                 Image   = MessageBoxImage.Information
             }
         }
Exemplo n.º 29
0
        public async Task <ActionResult> GetSchedules()
        {
            var response = new ResponseCollection <ScheduleDto>();

            try
            {
                response.Objects = await _scheduleLogic.GetSchedules();
            }
            catch (Exception e)
            {
                response.IsError      = true;
                response.ErrorMessage = e.Message;
                _logger.LogError($"ScheduleController | Error | Error message : {e.Message}");
            }

            return(Ok(response));
        }
Exemplo n.º 30
0
        /// <summary>
        /// Fixed:
        /// </summary>
        public static string SearchJson(Context context)
        {
            var ss         = new SiteSettings();
            var offset     = QueryStrings.Int("offset");
            var searchText = QueryStrings.Data("text");
            var dataSet    = Get(
                context: context,
                searchText: searchText,
                dataTableName: "SearchResults",
                offset: offset,
                pageSize: Parameters.General.SearchPageSize);
            var dataRows = dataSet?.Tables["SearchResults"].AsEnumerable();
            var res      = new ResponseCollection();

            return(offset == 0
                ? res
                   .ReplaceAll(
                       "#MainContainer",
                       MainContainer(
                           context: context,
                           ss: ss,
                           text: searchText,
                           offset: 0,
                           results: dataRows,
                           count: Rds.Count(dataSet)))
                   .Focus("#Search")
                   .ToJson()
                : res
                   .Append(
                       "#SearchResults",
                       new HtmlBuilder().Results(
                           context: context,
                           ss: ss,
                           text: searchText,
                           offset: offset,
                           dataRows: dataRows))
                   .Val(
                       "#SearchOffset",
                       (dataRows != null &&
                        dataRows.Any() &&
                        dataRows.Count() == Parameters.General.SearchPageSize
                            ? offset + Parameters.General.SearchPageSize
                            : -1).ToString())
                   .ToJson());
        }
Exemplo n.º 31
0
 public static ResponseCollection CaculatePaging(ResponseCollection resp, int total, int page, int pageSize)
 {
     if (resp.success && total > 0)
     {
         resp.total = total;
         int totalpage = (int)Math.Ceiling((double)total / pageSize);
         page = page < 0 ? 0 : page;
         if (totalpage == 0)
         {
             totalpage = 1;
         }
         int previousPage = (page - 1) == 0 ? page : (page - 1);
         int nextPage     = (page + 1) > totalpage ? page : (page + 1);
         resp.page       = page;
         resp.totalPages = totalpage;
     }
     return(resp);
 }
Exemplo n.º 32
0
        public async Task <ActionResult> GetUsers(int itemPerPage, int page)
        {
            var response = new ResponseCollection <UserDto>();

            try
            {
                response.Objects = await _userService.GetUsers(itemPerPage, page);
            }
            catch (Exception e)
            {
                response.IsError      = true;
                response.ErrorMessage = e.Message;

                _logger.LogError($"UserController | Error | Error message : {e.Message}");
            }

            return(Ok(response));
        }
Exemplo n.º 33
0
		public async Task<ActionResult> DeveloperExtensions(string vendorId, string sort)
		{
			var query = new BrowseQuery();
			query.Filters = new Dictionary<string, string[]>();
			query.Filters.Add("vendorId", new[] { vendorId });
			query.Take = 1000;
			var results = await SearchClient.GetProductsAsync("MarketPlace", "en-US", query, ItemResponseGroups.ItemLarge);

			DeveloperSearchResult retVal = new DeveloperSearchResult();
			retVal.Results.AddRange(results.Items.Select(i => i.ToWebModel()));
			foreach (var module in retVal.Results)
			{
				var reviews = new ResponseCollection<Review>(); //await ReviewsClient.GetReviewsAsync(module.Keyword);
				module.Reviews.AddRange(reviews.Items.Select(i => i.ToWebModel(module.Keyword)));
			}

			var customer = await CustomerServiceClient.GetContactByIdAsync(vendorId);
			retVal.VenderName = customer.FullName;
			retVal.VendorId = vendorId;

			return View(retVal);
		}
Exemplo n.º 34
0
        public ActionResult Module(string keyword)
        {
            var sW = Stopwatch.StartNew();
            var product = Task.Run(() => SearchClient.GetProductByKeywordAsync("MarketPlace", "en-US", keyword, ItemResponseGroups.ItemLarge)).Result;
            var timePR = sW.ElapsedMilliseconds;

            var reviews = new ResponseCollection<Review>(); //Task.Run(() => ReviewsClient.GetReviewsAsync(product.Code)).Result;
            var timeRR = sW.ElapsedMilliseconds;

            var category = Task.Run(() => SearchClient.GetCategoryAsync("MarketPlace", "en-US", product.Categories.Last())).Result;
            var timeCR = sW.ElapsedMilliseconds;

            var module = product.ToWebModel();

            var vendor = Task.Run(() => CustomerServiceClient.GetContactByIdAsync(module.UserId)).Result;
            module.Vendor = vendor.ToWebModel();
            module.CategoryList.Add(category.Code, category.Name);
            var timeVR = sW.ElapsedMilliseconds;

            foreach (var review in reviews.Items.Select(x => x.ToWebModel(product.Id)))
            {
                module.Reviews.Add(review);
            }

            if (product.Seo.Any())
            {
                ViewBag.Title = product.Seo[0].Title;
                ViewBag.Description = product.Seo[0].MetaDescription;
            }
            var allTime = sW.ElapsedMilliseconds;

            sW.Stop();
            module.Time = new List<long>();
            module.Time.AddRange(new long[] { timePR, timeRR, timeCR, timeVR, allTime });
            return View(module);
        }