public void RaiseCallbackEvent(string eventArgument) { string type = eventArgument; string param = string.Empty; if (type.Split('|').Length > 1) { param = type.Split('|')[1]; type = type.Split('|')[0]; } switch (type) { case "charge_failed": int failedChargeCount = OrderService.GetOrderCountByOrderStatusAndIssueCode( OrderStatusCode.ON_HOLD, OrderIssueCode.FAILED_TO_CHARGE); message = failedChargeCount.ToString(); break; case "otc_order_system_check": int otcOrderSystemCheckCount = OrderService.GetOrderCountByOrderStatusAndIssueCode( OrderStatusCode.ON_HOLD, OrderIssueCode.OTC_ORDER_AND_SYSTEM_CHECK_FAILED); message = otcOrderSystemCheckCount.ToString(); break; case "otc_order": int otcOrderCount = OrderService.GetOrderCountByOrderStatusAndIssueCode( OrderStatusCode.ON_HOLD, OrderIssueCode.OTC_ORDER); message = otcOrderCount.ToString(); break; case "system_check": int systemCheckCount = OrderService.GetOrderCountByOrderStatusAndIssueCode( OrderStatusCode.ON_HOLD, OrderIssueCode.SYSTEM_CHECK_FAILED); message = systemCheckCount.ToString(); break; case "order_placed": int orderPlacedCount = OrderService.GetOrderCountByOrderStatus(OrderStatusCode.ORDER_PLACED); message = orderPlacedCount.ToString(); break; case "cancel": int cancelCount = OrderService.GetRefundCountByTypeAndStatus(true, true); message = cancelCount.ToString(); break; case "refund": int refundCount = OrderService.GetRefundCountByTypeAndStatus(false, true); message = refundCount.ToString(); break; case "line_items": int lineItemcount = 0; string inLineStatusXml = AdminStoreUtility.BuildXmlString("status", new string[] { LineStatusCode.ORDERED, LineStatusCode.PENDING }); string inOrderStatusXml = AdminStoreUtility.BuildXmlString("status", new string[] { OrderStatusCode.ORDER_PLACED, OrderStatusCode.PARTIAL_SHIPPING }); DataTable pendingOrderTable = OrderService.GetOrderCountGroupByDate(inLineStatusXml, inOrderStatusXml); for (int i = 0; i < pendingOrderTable.Rows.Count; i++) { lineItemcount += Convert.ToInt32(pendingOrderTable.Rows[i][1]); } message = lineItemcount.ToString(); break; case "picking": int pickingItemCount = 0; message = pickingItemCount.ToString(); break; case "packing": int packingCount = OrderService.GetOrderCountForPacking(); message = packingCount.ToString(); break; case "despatch": int despatchCount = OrderService.GetOrderCountByOrderStatus(OrderStatusCode.SHIPPING); message = despatchCount.ToString(); break; case "complete": int completeCount = OrderService.GetOrderCountByOrderStatus(OrderStatusCode.INVOICED); message = completeCount.ToString(); break; case "awaiting_reply": int awaitingReplyCount = OrderService.GetOrderCountByOrderStatus(OrderStatusCode.AWAITING_REPLY); message = awaitingReplyCount.ToString(); break; case "cancel_value_chart": DateTime chosenCancelDate = ParseDate(param); string inOrderStatusXmlForCancelValueChart = AdminStoreUtility.BuildXmlString("status", new string[] { OrderStatusCode.CANCELLED, OrderStatusCode.SCHEDULED_FOR_CANCEL }); int count1 = ReportService.GetOrderCountSumByDate(inOrderStatusXmlForCancelValueChart, false, 1, 0, 1, 0, 1, 0, 0, chosenCancelDate.Day, 0, chosenCancelDate.Month, 0, chosenCancelDate.Year); message = count1.ToString(); break; case "cancel_other_value_chart": DateTime chosenCancelOtherDate = ParseDate(param); string inOrderStatusXmlForCancelOtherValueChart = AdminStoreUtility.BuildXmlString("status", new string[] { OrderStatusCode.ORDER_PLACED, OrderStatusCode.PARTIAL_SHIPPING, OrderStatusCode.SHIPPING, OrderStatusCode.STOCK_WARNING, OrderStatusCode.INVOICED, OrderStatusCode.ON_HOLD }); int count2 = ReportService.GetOrderCountSumByDate(inOrderStatusXmlForCancelOtherValueChart, false, 1, 0, 1, 0, 1, 0, 0, chosenCancelOtherDate.Day, 0, chosenCancelOtherDate.Month, 0, chosenCancelOtherDate.Year); message = count2.ToString(); break; case "refund_value_chart": int refundValueChartCount = OrderService.GetRefundCountByTypeAndStatus(false, true, param, param); message = refundValueChartCount.ToString(); break; case "refund_other_value_chart": DateTime chosenRefundOtherDate = ParseDate(param); string inOrderStatusXmlForRefundOtherValueChart = AdminStoreUtility.BuildXmlString("status", new string[] { OrderStatusCode.ORDER_PLACED, OrderStatusCode.PARTIAL_SHIPPING, OrderStatusCode.SHIPPING, OrderStatusCode.STOCK_WARNING, OrderStatusCode.INVOICED, OrderStatusCode.ON_HOLD }); int count3 = ReportService.GetOrderCountSumByDate(inOrderStatusXmlForRefundOtherValueChart, false, 1, 0, 1, 0, 1, 0, 0, chosenRefundOtherDate.Day, 0, chosenRefundOtherDate.Month, 0, chosenRefundOtherDate.Year); message = count3.ToString(); break; case "as_value_chart": var asList = OrderService.GetLineItemListByStatusCodeAndDate(DateTime.Now.AddYears(-3), DateTime.MaxValue, new string[] { LineStatusCode.AWAITING_STOCK }, new string[] { OrderStatusCode.ORDER_PLACED, OrderStatusCode.PARTIAL_SHIPPING }); message = asList.Count.ToString(); break; case "sw_value_chart": var swList = OrderService.GetLineItemListByStatusCodeAndDate(DateTime.Now.AddYears(-3), DateTime.MaxValue, new string[] { LineStatusCode.GOODS_ALLOCATED }, new string[] { OrderStatusCode.ORDER_PLACED, OrderStatusCode.PARTIAL_SHIPPING }); message = swList.Count.ToString(); break; case "ga_value_chart": var gaList = OrderService.GetLineItemListByStatusCodeAndDate(DateTime.Now.AddYears(-3), DateTime.MaxValue, new string[] { LineStatusCode.GOODS_ALLOCATED }, new string[] { OrderStatusCode.ORDER_PLACED, OrderStatusCode.PARTIAL_SHIPPING }); message = gaList.Count.ToString(); break; case "pp_value_chart": var ppList = OrderService.GetLineItemListByStatusCodeAndDate(DateTime.Now.AddYears(-3), DateTime.MaxValue, new string[] { LineStatusCode.PICK_IN_PROGRESS }, new string[] { OrderStatusCode.ORDER_PLACED, OrderStatusCode.PARTIAL_SHIPPING }); message = ppList.Count.ToString(); break; case "o_value_chart": var oList = OrderService.GetLineItemListByStatusCodeAndDate(DateTime.Now.AddYears(-3), DateTime.MaxValue, new string[] { LineStatusCode.ORDERED }, new string[] { OrderStatusCode.ORDER_PLACED, OrderStatusCode.PARTIAL_SHIPPING }); message = oList.Count.ToString(); break; case "shipment_value_chart": DateTime chosenDate = new DateTime(); DateTime.TryParseExact(param, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out chosenDate); StringBuilder sb = new StringBuilder(); // Loop each day for (int i = -3; i < 4; i++) { DateTime loopDate = chosenDate.AddDays(i); string dateInString = loopDate.ToString("dd/MM/yyyy"); sb.Append(dateInString).Append(","); // Get rate for same day sb.Append(OrderService.GetShipmentRate(dateInString, 0, 3)).Append(","); // Get rate for > 3 days sb.Append(OrderService.GetShipmentRate(dateInString, 3, 7)).Append(","); // Get rate for > 1 week sb.Append(OrderService.GetShipmentRate(dateInString, 7, 14)).Append(","); // Get rate for > 2 weeks sb.Append(OrderService.GetShipmentRate(dateInString, 14, 999)).Append(","); } sb = sb.Remove(sb.Length - 1, 1); message = sb.ToString(); break; } }
void ICallbackEventHandler.RaiseCallbackEvent(string eventArgument) { string[] args = eventArgument.Split(splitter); int hourFlag = 0; int dayFlag = 0; int weekFlag = 0; int monthFlag = 0; int quarterFlag = 0; int yearFlag = 0; int hour; int day; int week; int month; int quarter; int year; hour = Convert.ToInt32(args[1]); day = Convert.ToInt32(args[2]); week = Convert.ToInt32(args[3]); month = Convert.ToInt32(args[4]); quarter = Convert.ToInt32(args[5]); year = Convert.ToInt32(args[6]); string typeFlag = args[8]; switch (typeFlag) { case "hour": weekFlag = 1; quarterFlag = 1; break; case "day": hourFlag = 1; weekFlag = 1; quarterFlag = 1; break; case "week": hourFlag = 1; dayFlag = 1; monthFlag = 1; quarterFlag = 1; break; case "month": hourFlag = 1; dayFlag = 1; weekFlag = 1; quarterFlag = 1; break; case "quarter": hourFlag = 1; dayFlag = 1; weekFlag = 1; monthFlag = 1; break; case "year": hourFlag = 1; dayFlag = 1; weekFlag = 1; monthFlag = 1; quarterFlag = 1; break; } bool noneu = Convert.ToBoolean(args[7]); int count = 0; switch (args[0]) { case "noOrders": count = ReportService.GetOrderCountSumByDate(AdminStoreUtility.BuildXmlString("status", ValidOrderStatus.VALID_STATUSES), noneu, hourFlag, dayFlag, weekFlag, monthFlag, quarterFlag, yearFlag, hour, day, week, month, quarter, year); message = count.ToString(); break; case "promoDiscount": decimal promoDiscount = ReportService.GetOrderDiscountSumByDate( AdminStoreUtility.BuildXmlString(AppConstant.XML_ROOT_STATUS, ValidOrderStatus.VALID_STATUSES), noneu, hourFlag, dayFlag, weekFlag, monthFlag, quarterFlag, yearFlag, hour, day, week, month, quarter, year); message = AdminStoreUtility.GetFormattedPrice(promoDiscount, CurrencySettings.PrimaryStoreCurrencyCode, CurrencyType.HtmlEntity); break; case "loyaltyDiscount": decimal loyaltyDiscount = ReportService.GetOrderLoyaltyDiscountSumByDate(AdminStoreUtility.BuildXmlString(AppConstant.XML_ROOT_STATUS, ValidOrderStatus.VALID_STATUSES), noneu, hourFlag, dayFlag, weekFlag, monthFlag, quarterFlag, yearFlag, hour, day, week, month, quarter, year); message = AdminStoreUtility.GetFormattedPrice(loyaltyDiscount, CurrencySettings.PrimaryStoreCurrencyCode, CurrencyType.HtmlEntity); break; case "lineCostPrice": decimal lineCostPrice = ReportService.GetLineCostSumByDate(AdminStoreUtility.BuildXmlString(AppConstant.XML_ROOT_STATUS, ValidOrderStatus.VALID_STATUSES), AdminStoreUtility.BuildXmlString(AppConstant.XML_ROOT_STATUS, ValidLineStatus.VALID_LINE_STATUSES), noneu, hourFlag, dayFlag, weekFlag, monthFlag, quarterFlag, yearFlag, hour, day, week, month, quarter, year); message = AdminStoreUtility.GetFormattedPrice(lineCostPrice, CurrencySettings.PrimaryStoreCurrencyCode, CurrencyType.HtmlEntity); break; case "margin": decimal margin = ReportService.GetMarginValueSumByDate(AdminStoreUtility.BuildXmlString(AppConstant.XML_ROOT_STATUS, ValidOrderStatus.VALID_STATUSES), AdminStoreUtility.BuildXmlString(AppConstant.XML_ROOT_STATUS, ValidLineStatus.VALID_LINE_STATUSES), noneu, 20, hourFlag, dayFlag, weekFlag, monthFlag, quarterFlag, yearFlag, hour, day, week, month, quarter, year); message = margin.ToString() + "%"; break; case "shipping": decimal shipping = ReportService.GetShippingValueSumByDate( AdminStoreUtility.BuildXmlString(AppConstant.XML_ROOT_STATUS, ValidOrderStatus.VALID_STATUSES), AdminStoreUtility.BuildXmlString(AppConstant.XML_ROOT_STATUS, ValidLineStatus.VALID_LINE_STATUSES), noneu, 20, hourFlag, dayFlag, weekFlag, monthFlag, quarterFlag, yearFlag, hour, day, week, month, quarter, year); message = AdminStoreUtility.GetFormattedPrice(shipping, CurrencySettings.PrimaryStoreCurrencyCode, CurrencyType.HtmlEntity); break; case "orderValue": decimal orderValue = ReportService.GetOrderValueSumByDate(AdminStoreUtility.BuildXmlString(AppConstant.XML_ROOT_STATUS, ValidOrderStatus.VALID_STATUSES), AdminStoreUtility.BuildXmlString(AppConstant.XML_ROOT_STATUS, ValidLineStatus.VALID_LINE_STATUSES), noneu, 20, hourFlag, dayFlag, weekFlag, monthFlag, quarterFlag, yearFlag, hour, day, week, month, quarter, year); message = AdminStoreUtility.GetFormattedPrice(orderValue, CurrencySettings.PrimaryStoreCurrencyCode, CurrencyType.HtmlEntity); decimal nonTaxableOrderValue = ReportService.GetNonTaxableOrderValueSumByDate(AdminStoreUtility.BuildXmlString(AppConstant.XML_ROOT_STATUS, ValidOrderStatus.VALID_STATUSES), AdminStoreUtility.BuildXmlString(AppConstant.XML_ROOT_STATUS, ValidLineStatus.VALID_LINE_STATUSES), noneu, 20, hourFlag, dayFlag, weekFlag, monthFlag, quarterFlag, yearFlag, hour, day, week, month, quarter, year); decimal vatDiscount = nonTaxableOrderValue / (120M) * 20M; decimal netOrderValue = AdminStoreUtility.RoundPrice(orderValue) - AdminStoreUtility.RoundPrice(vatDiscount); message = AdminStoreUtility.GetFormattedPrice(netOrderValue, CurrencySettings.PrimaryStoreCurrencyCode, CurrencyType.HtmlEntity); break; case "productDiscount": decimal productDiscount = ReportService.GetProductDiscountSumByDate( AdminStoreUtility.BuildXmlString(AppConstant.XML_ROOT_STATUS, ValidOrderStatus.VALID_STATUSES), AdminStoreUtility.BuildXmlString(AppConstant.XML_ROOT_STATUS, ValidLineStatus.VALID_LINE_STATUSES), noneu, hourFlag, dayFlag, weekFlag, monthFlag, quarterFlag, yearFlag, hour, day, week, month, quarter, year); message = AdminStoreUtility.GetFormattedPrice(productDiscount, CurrencySettings.PrimaryStoreCurrencyCode, CurrencyType.HtmlEntity); break; case "orderAverageValue": decimal totalOrderValue = ReportService.GetOrderValueSumByDate(AdminStoreUtility.BuildXmlString(AppConstant.XML_ROOT_STATUS, ValidOrderStatus.VALID_STATUSES), AdminStoreUtility.BuildXmlString(AppConstant.XML_ROOT_STATUS, ValidLineStatus.VALID_LINE_STATUSES), noneu, 20, hourFlag, dayFlag, weekFlag, monthFlag, quarterFlag, yearFlag, hour, day, week, month, quarter, year); decimal totalNonTaxableOrderValue = ReportService.GetNonTaxableOrderValueSumByDate(AdminStoreUtility.BuildXmlString(AppConstant.XML_ROOT_STATUS, ValidOrderStatus.VALID_STATUSES), AdminStoreUtility.BuildXmlString(AppConstant.XML_ROOT_STATUS, ValidLineStatus.VALID_LINE_STATUSES), noneu, 20, hourFlag, dayFlag, weekFlag, monthFlag, quarterFlag, yearFlag, hour, day, week, month, quarter, year); decimal totalVatDiscount = totalNonTaxableOrderValue / (120M) * 20M; decimal totalNetOrderValue = AdminStoreUtility.RoundPrice(totalOrderValue) - AdminStoreUtility.RoundPrice(totalVatDiscount); int totalOrder = ReportService.GetOrderCountSumByDate(AdminStoreUtility.BuildXmlString("status", ValidOrderStatus.VALID_STATUSES), noneu, hourFlag, dayFlag, weekFlag, monthFlag, quarterFlag, yearFlag, hour, day, week, month, quarter, year); if (totalNetOrderValue != 0M && totalOrder != 0) { message = AdminStoreUtility.GetFormattedPrice(totalNetOrderValue / totalOrder, CurrencySettings.PrimaryStoreCurrencyCode, CurrencyType.HtmlEntity); } else { message = AdminStoreUtility.GetFormattedPrice(0M, CurrencySettings.PrimaryStoreCurrencyCode, CurrencyType.HtmlEntity); } break; } }