예제 #1
0
        }         // RetrieveAndAggregate

        private void CheckTokenStatus(
            IDatabaseCustomerMarketPlace databaseCustomerMarketPlace,
            DataProviderCreationInfo info,
            MP_CustomerMarketplaceUpdatingHistory historyRecord
            )
        {
            Helper.CustomerMarketplaceUpdateAction(
                CustomerMarketplaceUpdateActionType.UpdateAccountInfo,
                databaseCustomerMarketPlace,
                historyRecord,
                () => {
                var elapsedTimeInfo = new ElapsedTimeInfo();

                var checker = new DataProviderCheckAuthenticationToken(info);

                var result = ElapsedTimeHelper.CalculateAndStoreElapsedTimeForCallInSeconds(
                    elapsedTimeInfo,
                    databaseCustomerMarketPlace.Id,
                    ElapsedDataMemberType.RetrieveDataFromExternalService,
                    () => checker.Check()
                    );

                return(new UpdateActionResultInfo {
                    Name = UpdateActionResultType.GetTokenStatus,
                    RequestsCounter = result == null ? null : result.RequestsCounter,
                    ElapsedTime = elapsedTimeInfo
                });
            }
                );
        }         // CheckTokenStatus
예제 #2
0
        }         // ConvertToBaseCurrency

        private MP_EBayOrderItemDetail FindEBayOrderItemInfo(
            IDatabaseCustomerMarketPlace databaseCustomerMarketPlace,
            DataProviderCreationInfo info,
            string itemID,
            RequestsCounterData requestCounter,
            ElapsedTimeInfo elapsedTimeInfo
            )
        {
            if (!this.settings.DownloadCategories)
            {
                return(null);
            }

            int mpID = databaseCustomerMarketPlace.Id;

            IMarketplaceType marketplace = databaseCustomerMarketPlace.Marketplace;

            var eBayItemInfoData = new eBayFindOrderItemInfoData(itemID);

            var eBayOrderItemInfo = Helper.FindEBayOrderItemInfo(eBayItemInfoData, elapsedTimeInfo, mpID);

            if (eBayOrderItemInfo == null)
            {
                var providerGetItemInfo = new DataProviderGetItemInfo(info);

                var req = new eBayRequestItemInfoData(eBayItemInfoData);

                ResultInfoEbayItemInfo ebayItemInfo = ElapsedTimeHelper.CalculateAndStoreElapsedTimeForCallInSeconds(
                    elapsedTimeInfo,
                    mpID,
                    ElapsedDataMemberType.RetrieveDataFromExternalService,
                    () => providerGetItemInfo.GetItem(req)
                    );

                requestCounter.Add(ebayItemInfo.RequestsCounter);

                var newEBayOrderItemInfo = new EbayDatabaseOrderItemInfo {
                    ItemID          = ebayItemInfo.ItemID,
                    PrimaryCategory = FindCategory(marketplace, ebayItemInfo.PrimaryCategory, elapsedTimeInfo, mpID),
                    // SecondaryCategory = FindCategory(marketplace, ebayItemInfo.SecondaryCategory, elapsedTimeInfo, mpID),
                    // FreeAddedCategory = FindCategory(marketplace, ebayItemInfo.FreeAddedCategory, elapsedTimeInfo, mpID),
                    Title = ebayItemInfo.Title,
                };

                eBayOrderItemInfo = Helper.SaveEBayOrderItemInfo(newEBayOrderItemInfo, elapsedTimeInfo, mpID);
            }             // if

            return(eBayOrderItemInfo);
        }         // FindEBayOrderItemInfo
예제 #3
0
        public static IGetOrdersExecutor Create(ParamsDataInfoGetOrdersBase param, DataProviderCreationInfo info)
        {
            switch (param.Type)
            {
            case ParamsDataInfoGetOrdersParamsType.Simple:
                return(new GetOrdersExecutorSimple(param as ParamsDataInfoGetOrdersSimple, info));

            case ParamsDataInfoGetOrdersParamsType.FromDateToDateCreated:
                return(new GetOrdersExecutorFromDateToDateCreated(param as ParamsDataInfoGetOrdersFromDateToDateBase, info));

            case ParamsDataInfoGetOrdersParamsType.FromDateToDateModified:
                return(new GetOrdersExecutorFromDateToDateModified(param as ParamsDataInfoGetOrdersFromDateToDateBase, info));

            default:
                throw new NotImplementedException();
            }
        }
예제 #4
0
        }         // UpdateAccountInfo

        private void UpdateFeedbackInfo(
            IDatabaseCustomerMarketPlace databaseCustomerMarketPlace,
            DataProviderCreationInfo info,
            MP_CustomerMarketplaceUpdatingHistory historyRecord
            )
        {
            Helper.CustomerMarketplaceUpdateAction(
                CustomerMarketplaceUpdateActionType.UpdateFeedbackInfo,
                databaseCustomerMarketPlace,
                historyRecord,
                () => {
                var elapsedTimeInfo = new ElapsedTimeInfo();

                var resultInfo = ElapsedTimeHelper.CalculateAndStoreElapsedTimeForCallInSeconds(
                    elapsedTimeInfo,
                    databaseCustomerMarketPlace.Id,
                    ElapsedDataMemberType.RetrieveDataFromExternalService,
                    () => DataProviderGetFeedback.GetFeedBack(info)
                    );

                ElapsedTimeHelper.CalculateAndStoreElapsedTimeForCallInSeconds(
                    elapsedTimeInfo,
                    databaseCustomerMarketPlace.Id,
                    ElapsedDataMemberType.StoreDataToDatabase,
                    () => SaveFeedbackInfo(databaseCustomerMarketPlace, resultInfo, historyRecord)
                    );

                var ebayRaitingInfo = resultInfo == null ? null : resultInfo.GetRaitingData(
                    FeedbackSummaryPeriodCodeType.FiftyTwoWeeks,
                    FeedbackRatingDetailCodeType.ShippingAndHandlingCharges
                    );

                return(new UpdateActionResultInfo {
                    Name = UpdateActionResultType.FeedbackRaiting,
                    Value = ebayRaitingInfo == null ? null : (object)ebayRaitingInfo.Value,
                    RequestsCounter = resultInfo == null ? null : resultInfo.RequestsCounter,
                    ElapsedTime = elapsedTimeInfo
                });
            }
                );
        }         // UpdateFeedbackInfo
예제 #5
0
        }         // SaveFeedbackInfo

        private void UpdateAccountInfo(
            IDatabaseCustomerMarketPlace databaseCustomerMarketPlace,
            DataProviderCreationInfo info,
            MP_CustomerMarketplaceUpdatingHistory historyRecord
            )
        {
            Helper.CustomerMarketplaceUpdateAction(
                CustomerMarketplaceUpdateActionType.UpdateAccountInfo,
                databaseCustomerMarketPlace,
                historyRecord,
                () => {
                var account = new DataProviderGetAccount(info);

                var elapsedTimeInfo = new ElapsedTimeInfo();

                var resultInfo = ElapsedTimeHelper.CalculateAndStoreElapsedTimeForCallInSeconds(
                    elapsedTimeInfo,
                    databaseCustomerMarketPlace.Id,
                    ElapsedDataMemberType.RetrieveDataFromExternalService,
                    () => account.GetAccount()
                    );

                ElapsedTimeHelper.CalculateAndStoreElapsedTimeForCallInSeconds(
                    elapsedTimeInfo,
                    databaseCustomerMarketPlace.Id,
                    ElapsedDataMemberType.StoreDataToDatabase,
                    () => Helper.StoreEbayUserAccountData(databaseCustomerMarketPlace, resultInfo, historyRecord)
                    );

                return(new UpdateActionResultInfo {
                    Name = UpdateActionResultType.CurrentBalance,
                    Value = resultInfo == null ? null : (object)resultInfo.CurrentBalance,
                    RequestsCounter = resultInfo == null ? null : resultInfo.RequestsCounter,
                    ElapsedTime = elapsedTimeInfo
                });
            }
                );
        }         // UpdateAccountInfo
예제 #6
0
 public InternalDataProviderGetOrders(DataProviderCreationInfo info)
     : base(info)
 {
 }
 public DataProviderGeteBayDetails(DataProviderCreationInfo info)
     : base(info)
 {
 }
예제 #8
0
 protected GetOrdersExecutorBase(DataProviderCreationInfo info)
 {
     DataProvider = new InternalDataProviderGetOrders(info);
 }
예제 #9
0
 public GetOrdersExecutorSimple(ParamsDataInfoGetOrdersSimple paramsDataInfoGetOrdersSimple, DataProviderCreationInfo info)
     : base(info)
 {
     _ParamsDataInfoGetOrdersSimple = paramsDataInfoGetOrdersSimple;
 }
예제 #10
0
 public GetOrdersExecutorFromDateToDateModified(ParamsDataInfoGetOrdersFromDateToDateBase param, DataProviderCreationInfo info)
     : base(param, info)
 {
 }
예제 #11
0
        }         // GetTopSealedProductItems

        public ResultInfoEbayUser GetCustomerUserInfo(eBaySecurityInfo data)
        {
            DataProviderCreationInfo info = CreateProviderCreationInfo(data);

            return(GetCustomerUserInfo(info));
        }         // GetCustomerUserInfo
예제 #12
0
 public DataProviderGetFeedback(DataProviderCreationInfo info)
     : base(info)
 {
 }
예제 #13
0
 public DataProviderGetItemInfo(DataProviderCreationInfo info)
     : base(info)
 {
 }
예제 #14
0
        }         // class FetchResultCounters

        private FetchResultCounters FetchOnePeriodTransactions(
            int mpID,
            IDatabaseCustomerMarketPlace databaseCustomerMarketPlace,
            ElapsedTimeInfo elapsedTimeInfo,
            DataProviderCreationInfo info,
            MP_CustomerMarketplaceUpdatingHistory historyRecord,
            FetchPeriod period
            )
        {
            this.log.Debug("Fetching eBay orders '{0}'@{1}...", mpID, period);

            ResultInfoOrders orders = ElapsedTimeHelper.CalculateAndStoreElapsedTimeForCallInSeconds(
                elapsedTimeInfo,
                mpID,
                ElapsedDataMemberType.RetrieveDataFromExternalService,
                () => DataProviderGetOrders.GetOrders(
                    info,
                    new ParamsDataInfoGetOrdersFromDateToDateCreated(period.From, period.To)
                    )
                );

            EbayDatabaseOrdersList databaseOrdersList = ParseOrdersInfo(orders);

            DateTime?max = null;
            DateTime?min = null;

            foreach (EbayDatabaseOrderItem o in databaseOrdersList.Where(x => x.CreatedTime != null))
            {
                DateTime c = o.CreatedTime.Value;

                if ((min == null) || (c < min.Value))
                {
                    min = c;
                }

                if ((max == null) || (c > max.Value))
                {
                    max = c;
                }
            }             // for each

            this.log.Debug(
                "Fetching eBay orders '{0}'@{1}: {2} are ready to be stored; " +
                "min order date is '{3}', max order date is '{4}'.",
                mpID,
                period,
                Grammar.Number(databaseOrdersList.Count, "order"),
                (min == null) ? "N/A" : min.Value.ToString("d/MMM/yyyy H:mm:ss", CultureInfo.InvariantCulture),
                (max == null) ? "N/A" : max.Value.ToString("d/MMM/yyyy H:mm:ss", CultureInfo.InvariantCulture)
                );

            ElapsedTimeHelper.CalculateAndStoreElapsedTimeForCallInSeconds(
                elapsedTimeInfo,
                mpID,
                ElapsedDataMemberType.StoreDataToDatabase,
                () => Helper.AddEbayOrdersData(databaseCustomerMarketPlace, databaseOrdersList, historyRecord)
                );

            this.log.Debug(
                "Fetching eBay orders '{0}'@{1}: {2} were stored.",
                mpID,
                period,
                Grammar.Number(databaseOrdersList.Count, "order")
                );

            EbayDatabaseOrdersList allEBayOrders = ElapsedTimeHelper.CalculateAndStoreElapsedTimeForCallInSeconds(
                elapsedTimeInfo,
                mpID,
                ElapsedDataMemberType.RetrieveDataFromDatabase,
                () => Helper.GetAllEBayOrders(orders.SubmittedDate, databaseCustomerMarketPlace)
                );

            this.log.Debug(
                "Fetching eBay orders '{0}'@{1}: {2} were loaded from DB.",
                mpID,
                period,
                Grammar.Number(allEBayOrders.Count, "order")
                );

            if (this.settings.DownloadCategories)
            {
                IEnumerable <string> topSealedProductItems = GetTopSealedProductItems(allEBayOrders);

                if (topSealedProductItems != null)
                {
                    List <MP_EBayOrderItemDetail> orderItemDetails = topSealedProductItems.Select(
                        item => FindEBayOrderItemInfo(
                            databaseCustomerMarketPlace,
                            info,
                            item,
                            databaseOrdersList.RequestsCounter,
                            elapsedTimeInfo
                            )
                        ).Where(d => d != null)
                                                                     .ToList();

                    Helper.UpdateOrderItemsInfo(orderItemDetails, elapsedTimeInfo, mpID);
                }         // if
            }             // if

            var frc = new FetchResultCounters(
                databaseOrdersList.RequestsCounter,
                (orders.Orders == null) ? 0 : orders.Orders.Count
                );

            this.log.Debug(
                "Done fetching eBay orders '{0}'@{1}: {2} fetched.",
                mpID,
                period,
                Grammar.Number(frc.OrderCount, "order")
                );

            return(frc);
        }         // FetchOnePeriodTransactions
예제 #15
0
 public DataProviderGetTokenStatus(DataProviderCreationInfo info)
     : base(info)
 {
 }
예제 #16
0
 public DataProviderUserInfo(DataProviderCreationInfo info)
     : base(info)
 {
 }
예제 #17
0
        }         // CreateProviderCreationInfo

        private ResultInfoEbayUser GetCustomerUserInfo(DataProviderCreationInfo info)
        {
            return(DataProviderUserInfo.GetDataAboutMySelf(info));
        }         // GetCustomerUserInfo
예제 #18
0
 public static ResultInfoEbayFeedBack GetFeedBack(DataProviderCreationInfo info)
 {
     return(new DataProviderGetFeedback(info).GetFeedBack());
 }
예제 #19
0
 public DataProviderCheckAuthenticationToken(DataProviderCreationInfo info)
     : base(info)
 {
 }
예제 #20
0
 public static ResultInfoOrders GetOrders(DataProviderCreationInfo info, ParamsDataInfoGetOrdersBase param)
 {
     return(new DataProviderGetOrders(info).GetOrders(param));
 }
 public GetOrdersExecutorFromDateToDateCreated(ParamsDataInfoGetOrdersFromDateToDateBase param, DataProviderCreationInfo info)
     : base(info)
 {
     FromDate = param.FromDate;
     ToDate   = param.ToDate;
 }
예제 #22
0
 public DataProviderGetAccount(DataProviderCreationInfo info)
     : base(info)
 {
 }
예제 #23
0
        }         // UpdateUserInfo

        private IUpdateActionResultInfo FetchTransactions(
            IDatabaseCustomerMarketPlace databaseCustomerMarketPlace,
            DataProviderCreationInfo info,
            MP_CustomerMarketplaceUpdatingHistory historyRecord
            )
        {
            int mpID = databaseCustomerMarketPlace.Id;

            DateTime toDate = DateTime.UtcNow.Date;

            var elapsedTimeInfo = new ElapsedTimeInfo();

            DateTime fromDate = Helper.FindLastKnownEbayTransactionTime(mpID);

            var periods = new Stack <FetchPeriod>();

            DateTime t = toDate;

            while (t >= fromDate)
            {
                DateTime f = t.AddDays(-90).Date;

                periods.Push(new FetchPeriod {
                    To   = t.Date.AddDays(1).AddSeconds(-1),                   // convert to 23:59:59
                    From = (f < fromDate ? fromDate : f).Date,
                });

                t = f.AddDays(-1).Date;
            }             // while

            this.log.Debug(
                "Fetching eBay orders for marketplace '{0}' using these date range list: {1}.",
                mpID,
                string.Join("; ", periods)
                );

            var frc = new FetchResultCounters();

            foreach (var period in periods)
            {
                frc.Add(FetchOnePeriodTransactions(
                            mpID,
                            databaseCustomerMarketPlace,
                            elapsedTimeInfo,
                            info,
                            historyRecord,
                            period
                            ));
            }             // for each

            this.log.Debug(
                "Done fetching eBay orders for marketplace '{0}' using these date range list: {1}.",
                mpID,
                string.Join("; ", periods)
                );

            return(new UpdateActionResultInfo {
                Name = UpdateActionResultType.eBayOrdersCount,
                Value = frc.OrderCount,
                RequestsCounter = frc.RequestCount.IsEmpty ? null : frc.RequestCount,
                ElapsedTime = elapsedTimeInfo
            });
        }         // FetchTransactions
예제 #24
0
 public static ResultInfoEbayUser GetDataAboutMySelf(DataProviderCreationInfo info)
 {
     return(new DataProviderUserInfo(info).GetDataAboutMySelf());
 }
 public DataProviderGetSiteCategories(DataProviderCreationInfo info)
     : base(info)
 {
 }