public void StoreAmazonFeedbackData(IDatabaseCustomerMarketPlace databaseCustomerMarketPlace, DatabaseAmazonFeedbackData data, MP_CustomerMarketplaceUpdatingHistory historyRecord) { if (data == null) { WriteToLog("StoreAmazonUserData: invalid data to store", WriteLogType.Error); return; } MP_CustomerMarketPlace customerMarketPlace = GetCustomerMarketPlace(databaseCustomerMarketPlace.Id); var feedBack = new MP_AmazonFeedback { CustomerMarketPlace = customerMarketPlace, Created = data.Submitted, UserRaining = data.UserRaining, HistoryRecord = historyRecord }; if (data.FeedbackByPeriod != null && data.FeedbackByPeriod.Count > 0) { feedBack.FeedbackByPeriodItems.AddAll(data.FeedbackByPeriod.Values.Select(f => new MP_AmazonFeedbackItem { AmazonFeedback = feedBack, Count = f.Count, Negative = f.Negative, Positive = f.Positive, Neutral = f.Neutral, TimePeriod = GetTimePeriod(TimePeriodFactory.Create(f.TimePeriod)) }).ToList()); } customerMarketPlace.AmazonFeedback.Add(feedBack); _CustomerMarketplaceRepository.Update(customerMarketPlace); }
public void StoreEbayFeedbackData(IDatabaseCustomerMarketPlace databaseCustomerMarketPlace, DatabaseEbayFeedbackData data, MP_CustomerMarketplaceUpdatingHistory historyRecord) { if (data == null) { WriteToLog("StoreEbayUserData: invalid data to store", WriteLogType.Error); return; } MP_CustomerMarketPlace customerMarketPlace = GetCustomerMarketPlace(databaseCustomerMarketPlace.Id); var feedBack = new MP_EbayFeedback { CustomerMarketPlace = customerMarketPlace, Created = data.Submitted, RepeatBuyerCount = data.RepeatBuyerCount, RepeatBuyerPercent = data.RepeatBuyerPercent, TransactionPercent = data.TransactionPercent, UniqueBuyerCount = data.UniqueBuyerCount, UniqueNegativeCount = data.UniqueNegativeCount, UniqueNeutralCount = data.UniqueNeutralCount, UniquePositiveCount = data.UniquePositiveCount, HistoryRecord = historyRecord }; if (data.FeedbackByPeriod != null && data.FeedbackByPeriod.Count > 0) { feedBack.FeedbackByPeriodItems.AddAll(data.FeedbackByPeriod.Values.Select(f => new MP_EbayFeedbackItem { EbayFeedback = feedBack, Negative = f.Negative, Positive = f.Positive, Neutral = f.Neutral, TimePeriod = GetTimePeriod(TimePeriodFactory.Create(f.TimePeriod)) }).ToList()); } if (data.RaitingByPeriod != null && data.RaitingByPeriod.Count > 0) { feedBack.RaitingByPeriodItems.AddAll(data.RaitingByPeriod.Values.Select(r => new MP_EbayRaitingItem { EbayFeedback = feedBack, Communication = r.Communication, ItemAsDescribed = r.ItemAsDescribed, ShippingAndHandlingCharges = r.ShippingAndHandlingCharges, ShippingTime = r.ShippingTime, TimePeriod = GetTimePeriod(TimePeriodFactory.Create(r.TimePeriod)) }).ToList()); } customerMarketPlace.EbayFeedback.Add(feedBack); _CustomerMarketplaceRepository.Update(customerMarketPlace); }
protected IEnumerable <IAnalysisDataParameterInfo> GetFeedbacks(MP_CustomerMarketPlace mp, DateTime?history) { MP_AmazonFeedback feedbacks; if (history == null) { feedbacks = mp.AmazonFeedback .OrderByDescending(x => x.Created) .FirstOrDefault(); } else { feedbacks = mp.AmazonFeedback .Where(x => x.Created <= history) .OrderByDescending(x => x.Created) .FirstOrDefault(); } //if var feedBackParams = new List <IAnalysisDataParameterInfo>(); if (feedbacks == null) { return(feedBackParams); } feedBackParams.Add(new AnalysisDataParameterInfo(TimePeriodFactory.Create(TimePeriodEnum.Zero), feedbacks.UserRaining, AggregationFunction.UserRating)); foreach (MP_AmazonFeedbackItem afp in feedbacks.FeedbackByPeriodItems) { var timePeriod = TimePeriodFactory.CreateById(afp.TimePeriod.InternalId); var c = new AnalysisDataParameterInfo(timePeriod, afp.Count, AggregationFunction.NumberOfReviews); var g = new AnalysisDataParameterInfo(timePeriod, afp.Negative, AggregationFunction.NegativeFeedbackRate); var n = new AnalysisDataParameterInfo(timePeriod, afp.Neutral, AggregationFunction.NeutralFeedbackRate); var p = new AnalysisDataParameterInfo(timePeriod, afp.Positive, AggregationFunction.PositiveFeedbackRate); var sum = afp.Positive + afp.Neutral + afp.Negative; decimal positivePercent = sum != 0 ? ((afp.Positive ?? 0)) / (decimal)sum.Value : 0M; decimal neutralPercent = sum != 0 ? ((afp.Neutral ?? 0)) / (decimal)sum.Value : 0M; decimal negativePercent = sum != 0 ? ((afp.Negative ?? 0)) / (decimal)sum.Value : 0M; var pp = new AnalysisDataParameterInfo(timePeriod, positivePercent, AggregationFunction.PositiveFeedbackPercentRate); var np = new AnalysisDataParameterInfo(timePeriod, neutralPercent, AggregationFunction.NeutralFeedbackPercentRate); var gp = new AnalysisDataParameterInfo(timePeriod, negativePercent, AggregationFunction.NegativeFeedbackPercentRate); feedBackParams.AddRange(new[] { c, n, g, p, pp, np, gp }); } // for each return(feedBackParams); } // GetFeedbacks
public override IEnumerable <IAnalysisDataParameterInfo> GetAggregations(MP_CustomerMarketPlace mp, DateTime?history) { DateTime relevantDate = GetRelevantDate(history); List <EkmAggregation> aggregations = Library.Instance.DB.Fill <EkmAggregation>( "LoadActiveEkmAggregations", CommandSpecies.StoredProcedure, new QueryParameter("MpID", mp.Id), new QueryParameter("RelevantDate", relevantDate) ); var calculatedAggregations = new List <IAnalysisDataParameterInfo>(); if (!aggregations.Any()) { return(calculatedAggregations); } if (history.HasValue) { aggregations = aggregations.Where(x => x.TheMonth < history).ToList(); } DateTime firstOfMonth = new DateTime(relevantDate.Year, relevantDate.Month, 1); var month = TimePeriodFactory.Create(TimePeriodEnum.Month); var month3 = TimePeriodFactory.Create(TimePeriodEnum.Month3); var month6 = TimePeriodFactory.Create(TimePeriodEnum.Month6); var year = TimePeriodFactory.Create(TimePeriodEnum.Year); var month15 = TimePeriodFactory.Create(TimePeriodEnum.Month15); var month18 = TimePeriodFactory.Create(TimePeriodEnum.Month18); var year2 = TimePeriodFactory.Create(TimePeriodEnum.Year2); var all = TimePeriodFactory.Create(TimePeriodEnum.Lifetime); calculatedAggregations.AddRange(GetAnalysisDataParameters(aggregations, month, firstOfMonth)); calculatedAggregations.AddRange(GetAnalysisDataParameters(aggregations, month3, firstOfMonth)); calculatedAggregations.AddRange(GetAnalysisDataParameters(aggregations, month6, firstOfMonth)); calculatedAggregations.AddRange(GetAnalysisDataParameters(aggregations, year, firstOfMonth)); calculatedAggregations.AddRange(GetAnalysisDataParameters(aggregations, month15, firstOfMonth)); calculatedAggregations.AddRange(GetAnalysisDataParameters(aggregations, month18, firstOfMonth)); calculatedAggregations.AddRange(GetAnalysisDataParameters(aggregations, year2, firstOfMonth)); calculatedAggregations.AddRange(GetAnalysisDataParameters(aggregations, all, firstOfMonth)); return(calculatedAggregations); } //GetAggregations
private int GetFeedbackByPeriod(FeedbackPeriodType[] feedbackPeriodType, TimePeriodEnum period) { if (feedbackPeriodType == null || feedbackPeriodType.Length == 0) { return(0); } var tp = TimePeriodFactory.Create(period); int days = tp.DaysInPeriod; FeedbackPeriodType rez = feedbackPeriodType.FirstOrDefault(p => p.PeriodInDays == days); Debug.Assert(rez != null); if (rez == null) { return(0); } return(rez.Count); }
} // UWPriority public override IEnumerable <IAnalysisDataParameterInfo> GetAggregations(MP_CustomerMarketPlace mp, DateTime?history) { DateTime relevantDate = GetRelevantDate(history); DateTime firstOfMonth = new DateTime(relevantDate.Year, relevantDate.Month, 1); var month = TimePeriodFactory.Create(TimePeriodEnum.Month); var month3 = TimePeriodFactory.Create(TimePeriodEnum.Month3); var month6 = TimePeriodFactory.Create(TimePeriodEnum.Month6); var year = TimePeriodFactory.Create(TimePeriodEnum.Year); var month15 = TimePeriodFactory.Create(TimePeriodEnum.Month15); var month18 = TimePeriodFactory.Create(TimePeriodEnum.Month18); var year2 = TimePeriodFactory.Create(TimePeriodEnum.Year2); var all = TimePeriodFactory.Create(TimePeriodEnum.Lifetime); var calculatedAggregations = new List <IAnalysisDataParameterInfo>(); if (InternalId == new Guid("AE85D6FC-DBDB-4E01-839A-D5BD055CBAEA")) { List <HmrcAggregation> aggregations = Library.Instance.DB.Fill <HmrcAggregation>( "LoadActiveHmrcAggregations", CommandSpecies.StoredProcedure, new QueryParameter("MpID", mp.Id), new QueryParameter("RelevantDate", relevantDate) ); if (!aggregations.Any()) { return(calculatedAggregations); } calculatedAggregations.AddRange(GetAnalysisDataParametersHmrc(aggregations, month, firstOfMonth)); calculatedAggregations.AddRange(GetAnalysisDataParametersHmrc(aggregations, month3, firstOfMonth)); calculatedAggregations.AddRange(GetAnalysisDataParametersHmrc(aggregations, month6, firstOfMonth)); calculatedAggregations.AddRange(GetAnalysisDataParametersHmrc(aggregations, year, firstOfMonth)); calculatedAggregations.AddRange(GetAnalysisDataParametersHmrc(aggregations, month15, firstOfMonth)); calculatedAggregations.AddRange(GetAnalysisDataParametersHmrc(aggregations, month18, firstOfMonth)); calculatedAggregations.AddRange(GetAnalysisDataParametersHmrc(aggregations, year2, firstOfMonth)); calculatedAggregations.AddRange(GetAnalysisDataParametersHmrc(aggregations, all, firstOfMonth)); } else { List <ChannelGrabberAggregation> aggregations = Library.Instance.DB.Fill <ChannelGrabberAggregation>( "LoadActiveChanngelGrabberAggregations", CommandSpecies.StoredProcedure, new QueryParameter("MpID", mp.Id), new QueryParameter("RelevantDate", relevantDate) ); if (!aggregations.Any()) { return(calculatedAggregations); } calculatedAggregations.AddRange(GetAnalysisDataParametersCG(aggregations, month, firstOfMonth)); calculatedAggregations.AddRange(GetAnalysisDataParametersCG(aggregations, month3, firstOfMonth)); calculatedAggregations.AddRange(GetAnalysisDataParametersCG(aggregations, month6, firstOfMonth)); calculatedAggregations.AddRange(GetAnalysisDataParametersCG(aggregations, year, firstOfMonth)); calculatedAggregations.AddRange(GetAnalysisDataParametersCG(aggregations, month15, firstOfMonth)); calculatedAggregations.AddRange(GetAnalysisDataParametersCG(aggregations, month18, firstOfMonth)); calculatedAggregations.AddRange(GetAnalysisDataParametersCG(aggregations, year2, firstOfMonth)); calculatedAggregations.AddRange(GetAnalysisDataParametersCG(aggregations, all, firstOfMonth)); } return(calculatedAggregations); } //GetAggregations
} // GetAggregations private void AppendAggregations( List <IAnalysisDataParameterInfo> target, List <EbayAggregation> ag, TimePeriodEnum timePeriod, DateTime firstOfMonth ) { ITimePeriod time = TimePeriodFactory.Create(timePeriod); if (time.TimePeriodType != TimePeriodEnum.Lifetime) { ag = ag.Where(x => x.TheMonth > firstOfMonth.AddMonths(-time.MonthsInPeriod)).ToList(); } var parameterInfos = new List <IAnalysisDataParameterInfo>(); AddAnalysisItem(parameterInfos, time, AggregationFunction.Turnover, ag.Sum(x => x.Turnover)); AddAnalysisItem( parameterInfos, time, AggregationFunction.AverageSumOfOrder, ag.Sum(x => x.AverageSumOfOrderNumerator), ag.Sum(x => x.AverageSumOfOrderDenominator) ); AddAnalysisItem( parameterInfos, time, AggregationFunction.AverageItemsPerOrder, ag.Sum(x => x.AverageItemsPerOrderNumerator), ag.Sum(x => x.AverageItemsPerOrderDenominator) ); AddAnalysisItem( parameterInfos, time, AggregationFunction.CancelledOrdersCount, ag.Sum(x => x.CancelledOrdersCount) ); AddAnalysisItem(parameterInfos, time, AggregationFunction.NumOfOrders, ag.Sum(x => x.NumOfOrders)); AddAnalysisItem( parameterInfos, time, AggregationFunction.OrdersCancellationRate, ag.Sum(x => x.OrdersCancellationRateNumerator), ag.Sum(x => x.OrdersCancellationRateDenominator) ); AddAnalysisItem(parameterInfos, time, AggregationFunction.TotalItemsOrdered, ag.Sum(x => x.TotalItemsOrdered)); AddAnalysisItem(parameterInfos, time, AggregationFunction.TotalSumOfOrders, ag.Sum(x => x.TotalSumOfOrders)); if (time.MonthsInPeriod <= MonthsInYear) { AddAnalysisItem( parameterInfos, time, AggregationFunction.TotalSumOfOrdersAnnualized, ag.Sum(x => x.TotalSumOfOrders) * (MonthsInYear / (decimal)time.MonthsInPeriod) ); } // if target.AddRange(parameterInfos); } // AppendAggregations