示例#1
0
        /// <summary>
        /// Метод пагинации всех заданий аукциона.
        /// </summary>
        /// <param name="pageNumber">Номер страницы.</param>
        /// <param name="countRows">Кол-во строк.</param>
        /// <returns>Данные пагинации.</returns>
        public async Task <IndexOutput> GetPaginationAuction(int pageNumber, int countRows)
        {
            try
            {
                var aAuctionTasks = (from tasks in _postgre.Tasks
                                     join categories in _postgre.TaskCategories on tasks.CategoryCode equals categories.CategoryCode
                                     join statuses in _postgre.TaskStatuses on tasks.StatusCode equals statuses.StatusCode
                                     join users in _postgre.Users on tasks.OwnerId equals users.Id
                                     where statuses.StatusName.Equals(StatusTask.AUCTION)
                                     select new
                {
                    tasks.CategoryCode,
                    tasks.CountOffers,
                    tasks.CountViews,
                    tasks.OwnerId,
                    tasks.SpecCode,
                    categories.CategoryName,
                    tasks.StatusCode,
                    statuses.StatusName,
                    taskBegda = string.Format("{0:f}", tasks.TaskBegda),
                    taskEndda = string.Format("{0:f}", tasks.TaskEndda),
                    tasks.TaskTitle,
                    tasks.TaskDetail,
                    tasks.TaskId,
                    taskPrice = string.Format("{0:0,0}", tasks.TaskPrice),
                    tasks.TypeCode,
                    users.UserName
                })
                                    .OrderBy(o => o.TaskId)
                                    .AsQueryable();

                var count = await aAuctionTasks.CountAsync();

                var items = await aAuctionTasks.Skip((pageNumber - 1) *countRows).Take(countRows).ToListAsync();

                var pageData       = new PaginationOutput(count, pageNumber, countRows);
                var paginationData = new IndexOutput
                {
                    PageData            = pageData,
                    Tasks               = items,
                    TotalCount          = count,
                    IsLoadAll           = count < countRows,
                    IsVisiblePagination = count > 10
                };

                if (paginationData.IsLoadAll)
                {
                    var difference = countRows - count;
                    paginationData.TotalCount += difference;
                }

                return(paginationData);
            }

            catch (Exception ex)
            {
                throw new Exception(ex.Message.ToString());
            }
        }
        internal static findItemsAdvancedResponse ParseResponse(XmlDocument Response)
        {
            findItemsAdvancedResponse fir = new findItemsAdvancedResponse();


            XmlNode xver = Response.GetElementsByTagName("version")[0];

            XmlNode xtim = Response.GetElementsByTagName("timestamp")[0];
            XmlNode xurl = Response.GetElementsByTagName("itemSearchURL")[0];



            XmlNodeList childs = Response.GetElementsByTagName("findItemsAdvancedResponse")[0].ChildNodes;

            foreach (XmlNode child in childs)
            {
                switch (child.Name)
                {
                case "paginationOutput":

                    PaginationOutput po = new PaginationOutput();

                    foreach (XmlNode pag in child)
                    {
                        if (pag.Name == "pageNumber")
                        {
                            po.PageNumber = int.Parse(pag.InnerText);
                        }

                        if (pag.Name == "entriesPerPage")
                        {
                            po.EntriesPerPage = int.Parse(pag.InnerText);
                        }


                        if (pag.Name == "totalPages")
                        {
                            po.TotalPages = int.Parse(pag.InnerText);
                        }


                        if (pag.Name == "totalEntries")
                        {
                            po.TotalEntries = int.Parse(pag.InnerText);
                        }
                    }

                    fir.Pagination = po;
                    break;

                case "aspectHistogramContainer":

                    AspectHistogramContainer ahp = new AspectHistogramContainer();
                    ahp.Aspects = new List <eBayAspect>();

                    foreach (XmlNode ahc in child.ChildNodes)
                    {
                        // eBayAspect asp = new eBayAspect();

                        switch (ahc.Name)
                        {
                        case "domainName":
                            ahp.DomainName = ahc.InnerText;
                            break;

                        case "domainDisplayName":
                            ahp.DomainDisplayName = ahc.InnerText;
                            break;


                        case "aspect":

                            eBayAspect es = new eBayAspect();
                            es.Name            = ahc.Attributes["name"].InnerText;
                            es.ValueHistograms = new List <eBayAspect.AspectValueHistogram>();

                            // .GetNamedItem("aspect", "http://www.ebay.com/marketplace/search/v1/services");
                            //es.Name = atts.Attributes["name"].InnerText;

                            foreach (XmlNode aspect in ahc.ChildNodes)
                            {
                                switch (aspect.Name)
                                {
                                case "valueHistogram":

                                    eBayAspect.AspectValueHistogram avh = new eBayAspect.AspectValueHistogram();
                                    avh.ValueName = aspect.Attributes["valueName"].InnerText;
                                    avh.Count     = long.Parse(aspect.FirstChild.InnerText);

                                    es.ValueHistograms.Add(avh);

                                    break;
                                }
                            }

                            ahp.Aspects.Add(es);



                            break;
                        }
                    }

                    fir.AspectHistogram = ahp;
                    break;

                case "searchResult":

                    List <eBayItem> ebs = new List <eBayItem>();

                    foreach (XmlNode item in child.ChildNodes)
                    {
                        eBayItem eb = new eBayItem();

                        foreach (XmlNode ebItem in item.ChildNodes)
                        {
                            switch (ebItem.Name)
                            {
                            case "autoPay":

                                eb.AutoPay = bool.Parse(ebItem.InnerText);

                                break;


                            case "charityId":

                                eb.CharityID = ebItem.InnerText;

                                break;


                            case "compatibility":

                                eb.Compatibility = ebItem.InnerText;

                                break;

                            case "country":

                                eb.Country = ebItem.InnerText;

                                break;

                            case "discountPriceInfo":

                                DiscountPriceInfo dpi = new DiscountPriceInfo();

                                break;

                            case "distance":

                                DistanceType d = new DistanceType();
                                d.Distance = decimal.Parse(ebItem.InnerText);

                                d.Unit = ebItem.Attributes["unit"].InnerText;

                                eb.Distance = d;

                                break;

                            case "galleryInfoContainer":



                                eb.GalleryInfoContainer = new List <GalleryUrl>();

                                foreach (XmlNode ga in ebItem)
                                {
                                    GalleryUrl gal = new GalleryUrl();
                                    gal.Url         = ga.InnerText;
                                    gal.GallerySize = ga.Attributes["gallerySize"].InnerText;


                                    eb.GalleryInfoContainer.Add(gal);
                                }



                                break;

                            case "galleryPlusPictureURL":

                                eb.GalleryPlusPictureURL = new List <string>();

                                foreach (XmlNode pp in ebItem.ChildNodes)
                                {
                                    eb.GalleryPlusPictureURL.Add(pp.InnerText);
                                }

                                break;

                            case "galleryURL":

                                eb.GalleryURL = ebItem.InnerText;

                                break;


                            case "globalId":

                                eb.GlobalID = ebItem.InnerText;

                                break;

                            case "itemId":

                                eb.ItemId = ebItem.InnerText;

                                break;


                            case "listingInfo":

                                eBayListingInfo leb = new eBayListingInfo();

                                foreach (XmlNode hu in ebItem.ChildNodes)
                                {
                                    switch (hu.Name)
                                    {
                                    case "bestOfferEnabled":

                                        leb.BestOfferEnabled = bool.Parse(hu.InnerText);

                                        break;

                                    case "buyItNowAvailable":

                                        leb.BuyItNowAvailable = bool.Parse(hu.InnerText);

                                        break;


                                    case "buyItNowPrice":

                                        eBayListingInfo.AmountType at = new eBayListingInfo.AmountType();
                                        at.Amount     = double.Parse(hu.InnerText);
                                        at.CurrencyID = hu.Attributes["currencyId"].InnerText;

                                        leb.BuyItNowPrice = at;

                                        break;

                                    case "convertedBuyItNowPrice":

                                        eBayListingInfo.AmountType cat = new eBayListingInfo.AmountType();
                                        cat.Amount                 = double.Parse(hu.InnerText);
                                        cat.CurrencyID             = hu.Attributes["currencyId"].InnerText;
                                        leb.ConvertedBuyItNowPrice = cat;

                                        break;

                                    case "endTime":

                                        leb.EndTime = DateTime.Parse(hu.InnerText);

                                        break;

                                    case "startTime":

                                        leb.startTime = DateTime.Parse(hu.InnerText);

                                        break;


                                    case "gift":

                                        leb.Gift = bool.Parse(hu.InnerText);

                                        break;


                                    case "listingType":

                                        leb.ListingType = (findItemsAdvanced.ItemFilters.eBayListingType)Enum.Parse(typeof(findItemsAdvanced.ItemFilters.eBayListingType), hu.InnerText);
                                        break;
                                    }
                                }


                                eb.ListingInfo = leb;

                                break;


                            case "location":

                                eb.Location = ebItem.InnerText;

                                break;


                            case "paymentMethod":

                                eb.PaymentMethods = new List <eBayPaymentMethod>();

                                foreach (XmlNode pp in ebItem.ChildNodes)
                                {
                                    eb.PaymentMethods.Add((eBayPaymentMethod)Enum.Parse(typeof(eBayPaymentMethod), pp.InnerText));
                                }

                                break;


                            case "pictureURLLarge":

                                eb.PictureURLLarge = ebItem.InnerText;

                                break;

                            case "pictureURLSuperSize":

                                eb.PictureURLSuperSize = ebItem.InnerText;

                                break;


                            case "postalCode":

                                eb.PostalCode = ebItem.InnerText;

                                break;


                            case "primaryCategory":

                                Category sf = new Category();

                                foreach (XmlNode n in ebItem.ChildNodes)
                                {
                                    switch (n.Name)
                                    {
                                    case "categoryName":
                                        sf.CategoryName = n.InnerText;
                                        break;

                                    case "categoryId":
                                        sf.CategoryID = n.InnerText;
                                        break;
                                    }
                                }

                                eb.PrimaryCategory = sf;


                                break;


                            case "secondaryCategory":

                                Category cf = new Category();

                                foreach (XmlNode n in ebItem.ChildNodes)
                                {
                                    switch (n.Name)
                                    {
                                    case "categoryName":
                                        cf.CategoryName = n.InnerText;
                                        break;

                                    case "categoryId":
                                        cf.CategoryID = n.InnerText;
                                        break;
                                    }
                                }

                                eb.SecondaryCategory = cf;


                                break;


                            case "productId":

                                eb.ProductID = ebItem.InnerText;

                                break;

                            case "returnsAccepted":

                                eb.ReturnsAccepted = bool.Parse(ebItem.InnerText);

                                break;


                            case "sellerInfo":


                                eb.SellerInfo = new eBaySellerInfo();

                                foreach (XmlNode no in ebItem.ChildNodes)
                                {
                                    switch (no.Name)
                                    {
                                    case "feedbackRatingStar":

                                        eb.SellerInfo.FeedbackRatingStar = no.InnerText;

                                        break;


                                    case "feedbackScore":

                                        eb.SellerInfo.FeedbackScore = long.Parse(no.InnerText);

                                        break;


                                    case "positiveFeedbackPercent":

                                        eb.SellerInfo.PositiveFeedbackPercent = double.Parse(no.InnerText);

                                        break;

                                    case "sellerUserName":

                                        eb.SellerInfo.SellerUserName = no.InnerText;

                                        break;

                                    case "topRatedSeller":

                                        eb.SellerInfo.TopRatedSeller = bool.Parse(no.InnerText);

                                        break;
                                    }
                                }


                                break;

                            case "sellingStatus":

                                eBaySellingStatus sel = new eBaySellingStatus();

                                foreach (XmlNode sod in ebItem.ChildNodes)
                                {
                                    switch (sod.Name)
                                    {
                                    case "bidCount":

                                        sel.BidCount = int.Parse(sod.InnerText);

                                        break;


                                    case "convertedCurrentPrice":

                                        eBayListingInfo.AmountType ccp = new eBayListingInfo.AmountType();
                                        ccp.Amount     = double.Parse(sod.InnerText);
                                        ccp.CurrencyID = sod.Attributes["currencyId"].InnerText;

                                        sel.ConvertedCurrentPrice = ccp;

                                        break;


                                    case "currentPrice":

                                        eBayListingInfo.AmountType cp = new eBayListingInfo.AmountType();
                                        cp.Amount     = double.Parse(sod.InnerText);
                                        cp.CurrencyID = sod.Attributes["currencyId"].InnerText;

                                        sel.CurrentPrice = cp;

                                        break;


                                    case "sellingState":

                                        sel.SellingState = (eBaySellingStatus.SellingStateType)Enum.Parse(typeof(eBaySellingStatus.SellingStateType), sod.InnerText);


                                        break;


                                    case "timeLeft":

                                        sel.TimeLeft = getTimeLeft(sod.InnerText);

                                        break;
                                    }
                                }


                                eb.SellingStatus = sel;

                                break;


                            case "shippingInfo":

                                ShippingInfo si = new ShippingInfo();

                                foreach (XmlNode s in ebItem.ChildNodes)
                                {
                                    switch (s.Name)
                                    {
                                    case "shippingServiceCost":

                                        si.ShippingServiceCost            = new eBayListingInfo.AmountType();
                                        si.ShippingServiceCost.Amount     = double.Parse(s.InnerText);
                                        si.ShippingServiceCost.CurrencyID = s.Attributes["currencyId"].InnerText;

                                        break;

                                    case "shippingType":

                                        si.ShippingType = (ShippingInfo.ShippingTypes)Enum.Parse(typeof(ShippingInfo.ShippingTypes), s.InnerText);

                                        break;

                                    case "shipToLocations":

                                        si.ShipToLocations = new List <string>();

                                        foreach (XmlNode pp in s.ChildNodes)
                                        {
                                            si.ShipToLocations.Add(pp.InnerText);
                                        }

                                        break;


                                    case "expeditedShipping":

                                        si.ExpeditedShipping = bool.Parse(s.InnerText);

                                        break;

                                    case "handlingTime":

                                        si.HandlingTime = int.Parse(s.InnerText);

                                        break;
                                    }
                                }

                                eb.ShippingInfo = si;

                                break;


                            case "storeInfo":

                                eBayStoreInfo esi = new eBayStoreInfo();

                                foreach (XmlNode es in ebItem.ChildNodes)
                                {
                                    switch (es.Name)
                                    {
                                    case "storeName":

                                        esi.StoreName = es.InnerText;

                                        break;

                                    case "storeURL":

                                        esi.StoreURL = es.InnerText;

                                        break;
                                    }
                                }

                                eb.StoreInfo = esi;

                                break;

                            case "subtitle":

                                eb.SubTitle = ebItem.InnerText;

                                break;

                            case "title":

                                eb.Title = ebItem.InnerText;

                                break;

                            case "viewItemURL":

                                eb.ViewItemURL = ebItem.InnerText;

                                break;



                            case "condition":

                                Condition c = new Condition();

                                foreach (XmlNode co in ebItem)
                                {
                                    switch (co.Name)
                                    {
                                    case "conditionId":

                                        c.ConditionID = co.InnerText;

                                        break;

                                    case "conditionDisplayName":

                                        c.ConditionDisplayName = co.InnerText;

                                        break;
                                    }
                                }



                                eb.Condition = c;



                                break;
                            }
                        }


                        ebs.Add(eb);
                    }

                    fir.SearchResults = ebs;

                    break;
                }
            }


            fir.Version       = xver.InnerText;
            fir.ItemSearchURL = xurl.InnerText;
            fir.TimeStamp     = DateTime.Parse(xtim.InnerText);



            return(fir);
        }
示例#3
0
        /// <summary>
        /// Метод пагинации страницы мои задания у заказчика.
        /// </summary>
        /// <param name="pageNumber">Номер страницы.</param>
        /// <param name="countRows">Кол-во строк.</param>
        /// <param name="account">Логин пользователя.</param>
        /// <returns>Данные пагинации.</returns>
        public async Task <IndexOutput> GetMyCustomerPaginationAsync(int pageNumber, int countRows, string account)
        {
            try
            {
                var userId = await _userService.GetUserIdByLogin(account);

                var getTasks = (from tasks in _postgre.Tasks
                                join categories in _postgre.TaskCategories on tasks.CategoryCode equals categories.CategoryCode
                                join statuses in _postgre.TaskStatuses on tasks.StatusCode equals statuses.StatusCode
                                join users in _postgre.Users on tasks.OwnerId equals users.Id
                                where (statuses.StatusName.Equals(StatusTask.AUCTION) ||
                                       statuses.StatusName.Equals(StatusTask.IN_WORK)) &&
                                tasks.OwnerId.Equals(userId)
                                select new
                {
                    tasks.CategoryCode,
                    tasks.CountOffers,
                    tasks.CountViews,
                    tasks.OwnerId,
                    tasks.SpecCode,
                    categories.CategoryName,
                    tasks.StatusCode,
                    statuses.StatusName,
                    taskBegda = string.Format("{0:f}", tasks.TaskBegda),
                    taskEndda = string.Format("{0:f}", tasks.TaskEndda),
                    tasks.TaskTitle,
                    tasks.TaskDetail,
                    tasks.TaskId,
                    taskPrice = string.Format("{0:0,0}", tasks.TaskPrice),
                    tasks.TypeCode,
                    users.UserName
                })
                               .OrderBy(o => o.TaskId)
                               .AsQueryable();

                var count = await getTasks.CountAsync();

                var items = await getTasks.Skip((pageNumber - 1) *countRows).Take(countRows).ToListAsync();

                var pageData       = new PaginationOutput(count, pageNumber, countRows);
                var paginationData = new IndexOutput
                {
                    PageData            = pageData,
                    Tasks               = items,
                    TotalCount          = count,
                    IsLoadAll           = count < countRows,
                    IsVisiblePagination = count > 10
                };

                if (paginationData.IsLoadAll)
                {
                    var difference = countRows - count;
                    paginationData.TotalCount += difference;
                }

                return(paginationData);
            }

            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
示例#4
0
 public PaginationModel(PaginationOutput <TDto> output, dynamic parameter)
 {
     TotalSize = output.TotalSize;
     Items     = output.Items;
     Parameter = parameter;
 }