protected void lbtExport_Click(object sender, EventArgs e) { string startDate = txtStartDate.Value + " 00:00:00"; string endDate = txtEndDate.Value + " 23:59:59"; OrdersManager ordersManager = new OrdersManager(); dt = ordersManager.VehicleStatistics(startDate, endDate); if (dt != null && dt.Rows.Count > 0) { StringBuilder s = new StringBuilder(); s.AppendLine("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">"); s.AppendLine("<table cellspacing=\"0\" cellpadding=\"5\" rules=\"all\" border=\"1\">"); //写出列名 s.AppendLine("<tr>"); s.AppendLine("<td>日期</td><td>支付订单数</td><td>用车数</td>"); s.AppendLine("</tr>"); //写数据 foreach (DataRow row in dt.Rows) { s.Append("<tr>"); s.Append("<td>").Append(row["PayTime"].ToString()).Append("</td>"); s.Append("<td>").Append(row["OrderCount"].ToString()).Append("</td>"); s.Append("<td>").Append(row["VehicleCount"].ToString()).Append("</td>"); s.AppendLine("</tr>"); } s.AppendLine("</table>"); this.Page.Response.ContentType = "application/vnd.ms-excel"; this.Page.Response.ContentEncoding = System.Text.Encoding.UTF8; this.Page.Response.Charset = "Utf-8"; this.Page.Response.AppendHeader("Content-Disposition", "attachment;filename=小宝出行用车统计" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls"); this.Page.Response.Write(s.ToString()); this.Page.Response.End(); } }
public SelectManagerMenu(Form tMainForm, OrdersManager tOrdersManager) { MainForm = tMainForm; OrdersManager = tOrdersManager; InitializeComponent(); Initialize(); }
/// <summary> /// Saves the custom order field. /// </summary> /// /// <param name="cartId">The cart id.</param> /// <param name="name">The name.</param> /// <param name="value">The value.</param> public static void SaveCustomField(Guid cartId, string name, string value) { var ordersManager = OrdersManager.GetManager(); // Get a copy of the shopping cart order based on the evt.ShoppingCartId. var cartOrder = ordersManager.GetCartOrder(cartId); if (cartOrder == null) { return; } // Get all properties of the cartOrder object. var properties = TypeDescriptor.GetProperties(cartOrder); // Get the meta property with the name used when creating the field in the CreateCustomOrderFields() method. var property = properties[name]; var metaProperty = property as MetafieldPropertyDescriptor; // Safety check to make sure you have found the appropriately named property in the cartOrder object. if (metaProperty != null) { // Set the meta property of the cartOrder object using the value from the control. metaProperty.SetValue(cartOrder, value); // Save the new value to the database. ordersManager.SaveChanges(); } }
public void CustomerManager_GetOrderByCustomerId_InProcessorCacheTest() { var cache = new InProcessorCache.Cache <IEnumerable <Order> >(); var ordersManager = new OrdersManager(cache); long executionTimeWithoutCaching = 0; long executionTimeWithCaching = 0; var customerId = "THEBI"; _stopwatch.Start(); var inProcessorCacheResult1 = ordersManager.GetOrderByCustomerId(customerId); _stopwatch.Stop(); executionTimeWithoutCaching = _stopwatch.ElapsedMilliseconds; _stopwatch.Restart(); var inProcessorCacheResult2 = ordersManager.GetOrderByCustomerId(customerId); _stopwatch.Stop(); executionTimeWithCaching = _stopwatch.ElapsedMilliseconds; Assert.IsTrue(executionTimeWithoutCaching > executionTimeWithCaching); }
public string Execute(Hashtable params_ht) { Hashtable res = params_ht; if (res["OrderNum"] == null || res["UID"] == null || res["UID"].ToString().Trim().Length <= 0 || res["OrderNum"].ToString().Trim().Length <= 0) { return(SiteHelper.GetJsonFromHashTable(null, "faild", "参数不完整")); } else { uid = res["UID"].ToString().Trim(); ordernum = res["OrderNum"].ToString().Trim(); OrdersManager om = new OrdersManager(); Hashtable ht = om.GetOrderByNum(ordernum); if (ht != null) { return(SiteHelper.GetJsonFromHashTable(ht, "success", "获取订单数据成功", "OrderInfo")); } else { return(SiteHelper.GetJsonFromHashTable(null, "faild", "未找到相关订单数据")); } } }
public IActionResult Delete() { OrdersManager manager = new OrdersManager(configuration); manager.DeleteOrder(); return(Ok()); }
protected override void OnPreRender(EventArgs e) { var calc = new DiscountCalculatorCustom(); var ordersManager = OrdersManager.GetManager(); CartOrder shoppingCart = GetShoppingCartForUser(ordersManager); var items = new List <CartDiscount>(); if (shoppingCart.UserId != null && shoppingCart.UserId != Guid.Empty) { var user = UserManager.GetManager().GetUser((Guid)shoppingCart.UserId); var roles = RoleManager.GetManager().GetRolesForUser(user.Id).ToList(); items = calc.GetNotApplicableCartDiscounts(shoppingCart, shoppingCart.SubTotalDisplay, user, roles).ToList(); } else { items = calc.GetNotApplicableCartDiscounts(shoppingCart, shoppingCart.SubTotalDisplay, null, null).ToList(); } if (items != null && items.Count > 0) { var sb = new StringBuilder(); sb.Append("The following discounts are not applicable:"); foreach (var item in items) { sb.Append(item.Title); sb.Append(", "); } sb.Length -= 2; this.MessageLabel.Text = sb.ToString(); } base.OnPreRender(e); }
public string Execute(Hashtable params_ht) { Hashtable res = params_ht; if (res["UID"] == null || res["UID"].ToString().Trim().Length <= 0) { return(SiteHelper.GetJsonFromHashTable(null, "faild", "参数不完整")); } else { uid = res["UID"].ToString().Trim(); OrdersManager om = new OrdersManager(); VehicleManager vm = new VehicleManager(); Hashtable ht = om.GetUserCurrentOrderVehicleGPSNum(uid); if (ht == null) { return(SiteHelper.GetJsonFromHashTable(null, "faild", "您没有车辆无法寻车")); } else { string vid = SiteHelper.GetHashTableValueByKey(ht, "VID"); string gpsnum = SiteHelper.GetHashTableValueByKey(ht, "VehicleGPSNum"); bool isSuccess = vm.FindVehicle(vid); if (!isSuccess) { return(SiteHelper.GetJsonFromHashTable(null, "faild", "指令发送失败")); } else { return(SiteHelper.GetJsonFromHashTable(null, "success", "指令发送成功")); } } } }
private void BtnData() { this.LinkButton1.Text = "未付款(" + OrdersManager.GetOrderCountByStatu(0) + ")"; this.LinkButton6.Text = "未付款(" + OrdersManager.GetOrderCountByStatu(0) + ")"; this.LinkButton11.Text = "未付款(" + OrdersManager.GetOrderCountByStatu(0) + ")"; this.LinkButton16.Text = "未付款(" + OrdersManager.GetOrderCountByStatu(0) + ")"; this.LinkButton21.Text = "未付款(" + OrdersManager.GetOrderCountByStatu(0) + ")"; this.LinkButton2.Text = "未发货(" + OrdersManager.GetOrderCountByStatu(1) + ")"; this.LinkButton7.Text = "未发货(" + OrdersManager.GetOrderCountByStatu(1) + ")"; this.LinkButton12.Text = "未发货(" + OrdersManager.GetOrderCountByStatu(1) + ")"; this.LinkButton17.Text = "未发货(" + OrdersManager.GetOrderCountByStatu(1) + ")"; this.LinkButton22.Text = "未发货(" + OrdersManager.GetOrderCountByStatu(1) + ")"; this.LinkButton3.Text = "待收货(" + OrdersManager.GetOrderCountByStatu(2) + ")"; this.LinkButton8.Text = "待收货(" + OrdersManager.GetOrderCountByStatu(2) + ")"; this.LinkButton13.Text = "待收货(" + OrdersManager.GetOrderCountByStatu(2) + ")"; this.LinkButton18.Text = "待收货(" + OrdersManager.GetOrderCountByStatu(2) + ")"; this.LinkButton23.Text = "待收货(" + OrdersManager.GetOrderCountByStatu(2) + ")"; this.LinkButton4.Text = "已收货(" + OrdersManager.GetOrderCountByStatu(3) + ")"; this.LinkButton9.Text = "已收货(" + OrdersManager.GetOrderCountByStatu(3) + ")"; this.LinkButton14.Text = "已收货(" + OrdersManager.GetOrderCountByStatu(3) + ")"; this.LinkButton19.Text = "已收货(" + OrdersManager.GetOrderCountByStatu(3) + ")"; this.LinkButton24.Text = "已收货(" + OrdersManager.GetOrderCountByStatu(3) + ")"; this.LinkButton5.Text = "已退货(" + OrdersManager.GetOrderCountByStatu(4) + ")"; this.LinkButton10.Text = "已退货(" + OrdersManager.GetOrderCountByStatu(4) + ")"; this.LinkButton15.Text = "已退货(" + OrdersManager.GetOrderCountByStatu(4) + ")"; this.LinkButton20.Text = "已退货(" + OrdersManager.GetOrderCountByStatu(4) + ")"; this.LinkButton25.Text = "已退货(" + OrdersManager.GetOrderCountByStatu(4) + ")"; }
private void AddEventToCart(Event currentEvent) { CatalogManager catalog = new CatalogManager(); Product product = catalog.GetProduct(ProductId); HttpCookie cookie = HttpContext.Current.Request.Cookies.Get("shoppingCartId"); OrdersManager orderm = new OrdersManager(); OptionsDetails optionDetails = new OptionsDetails(); // Check if shopping cart cookie exists in the current request. if (cookie == null) //if it does not exist... { CartOrder cartItem = orderm.CreateCartOrder(); //create a new cart order var shoppingcartid = cartItem.Id; // that id is equal to the cookie value HttpCookie Cookie = new HttpCookie("shoppingCartId"); //create a new shopping cart cookie DateTime now = DateTime.Now; // Set the cookie value. Cookie.Value = shoppingcartid.ToString(); // Set the cookie expiration date. Cookie.Expires = now.AddYears(1); // Add the cookie. HttpContext.Current.Response.Cookies.Add(Cookie); //give cart item currency of USD because it cannot be null cartItem.Currency = "USD"; //add the product to the cart orderm.AddToCart(cartItem, product, optionDetails, 1); //save all changes orderm.SaveChanges(); } else //if the cookie does exist { Guid guid = new Guid(cookie.Value.ToString()); //get the cookie value as the guid CartOrder cartItem = orderm.GetCartOrder(guid); //get the cart based on the cookie value orderm.AddToCart(cartItem, product, optionDetails, 1); // add the item to the cart orderm.SaveChanges(); //save changes } }
/// <summary> /// Custom Payment method service, that just returns online payment provider when there is money /// associated with cart and removes offline from the list of payment methods that Ecommerce /// module shows. /// </summary> /// /// <param name="checkoutState">Current checkout state.</param> /// <param name="cartOrder">current cart order object.</param> /// /// <returns> /// List of applicable payment methods. /// </returns> public override IQueryable <PaymentMethod> GetApplicablePaymentMethods(CheckoutState checkoutState, CartOrder cartOrder) { var ordersManager = OrdersManager.GetManager(); if (cartOrder.Total == 0) { var offlinePaymentMethod = ordersManager.GetPaymentMethods().FirstOrDefault(pm => pm.PaymentMethodType == PaymentMethodType.Offline && pm.IsActive); if (offlinePaymentMethod != null) { return(new List <PaymentMethod> { offlinePaymentMethod }.AsQueryable()); } } else { var onlinePaymentMethod = ordersManager.GetPaymentMethods().FirstOrDefault(pm => pm.PaymentMethodType == PaymentMethodType.PaymentProcessor && pm.IsActive); if (onlinePaymentMethod != null) { return(new List <PaymentMethod> { onlinePaymentMethod }.AsQueryable()); } } //Fallback case, ideally should never happen if the data is intact return(base.GetApplicablePaymentMethods(checkoutState, cartOrder)); }
internal static CartOrder GetCartOrder(OrdersManager ordersManager, Guid shoppingCartId) { try { CartOrder order = ordersManager.GetCartOrder(shoppingCartId); decimal tTotal = 0; foreach (CartDetail de in order.Details) { if (order.Addresses.Count() > 0) { de.TaxRate = GetTaxList(order.Addresses[0].PostalCode); order.EffectiveTaxRate = de.TaxRate; var priceWithTax = de.Price * de.TaxRate; tTotal += priceWithTax; } } if (order.Details.Count() > 0) { order.ShippingTaxRate = order.Details[0].TaxRate; } order.Tax = tTotal; return order; } catch (Exception) { return new CartOrder(); } }
//余额 private string BalancePay(string uid, string ordernum) { OrdersManager om = new OrdersManager(); UserInfoManager uim = new UserInfoManager(); Hashtable order_ht = om.GetOrderInfoByNum(ordernum); if (order_ht != null) { string strPay = string.Empty; if (uim.UserOrderPay(ordernum, out strPay)) { order_ht = om.GetOrderInfoByNum(ordernum); Hashtable result_ht = new Hashtable(); result_ht["PayWay"] = payway; result_ht["OrderNum"] = ordernum; result_ht["PayMoney"] = SiteHelper.GetHashTableValueByKey(order_ht, "PayMoney"); return(SiteHelper.GetJsonFromHashTable(result_ht, "success", strPay, "OrderPay")); } else { return(SiteHelper.GetJsonFromHashTable(null, "faild", "生成支付订单失败")); } } else { return(""); } }
protected void orderButton_Click(object sender, EventArgs e) { if (ValidateFields()) { try { var newOrder = new Order { Size = sizeDropDownList.Text, Crust = crustDropDownList.Text, Sausage = sausageCheckBox.Checked, Pepperoni = pepperoniCheckBox.Checked, Onions = onionsCheckBox.Checked, GreenPeppers = greenPeppersCheckBox.Checked, Name = nameTextBox.Text, Address = addressTextBox.Text, ZipCode = zipTextBox.Text, PhoneNumber = phoneNumberTextBox.Text, PaymentType = paymentTypeRadioButtonList.SelectedValue, TotalCost = decimal.Parse(totalCostLabel.Text, NumberStyles.Currency) }; OrdersManager.AddOrder(newOrder); Response.Redirect("Success.html"); } catch (Exception ex) { errorLabel.Text = ex.Message; errorLabel.Visible = true; } } }
private void Initialize() { DecorCatalogOrder = new DecorCatalogOrder(); DecorCatalogOrder.Initialize(); OrdersManager = new OrdersManager(ref MainOrdersDataGrid, ref MainOrdersFrontsOrdersDataGrid, ref MegaOrdersDataGrid, ref MainOrdersDecorTabControl, ref MainOrdersTabControl, ref DecorCatalogOrder); OrdersCalculate = new OrdersCalculate(OrdersManager); Report = new Report(ref DecorCatalogOrder, ref OrdersCalculate.FrontsCalculate); DetailsReport = new DetailsReport(ref DecorCatalogOrder, ref OrdersCalculate.FrontsCalculate); SendEmail = new SendEmail(); FilterClientsDataGrid.DataSource = OrdersManager.FilterClientsBindingSource; FilterClientsDataGrid.Columns["ClientID"].Visible = false; GetCurrency(CurrencyDateTimePicker.Value.Date); OrdersManager.GetOrdersInMuttlements( true, true, true, true, true, true, true, true, true, true); OrdersManager.FilterMegaOrders( false, 0, true, true, true, true, true, true, true, true, true, false, true, true, true, true, true, true); }
public async void OrdersManager_SaveOrderAsync_DoesntFail() { var sut = new OrdersManager(_mockLog.Object, _mqPublisher.Object, _orderRepository.Object, _orderEntityService.Object); await sut.SaveOrderAsync(new Order(new OrderHeaderData())); // Assert.NotNull(retVal); }
public async void OrdersManager_GetOrderAsync_NotNull() { var sut = new OrdersManager(_mockLog.Object, _mqPublisher.Object, _orderRepository.Object, _orderEntityService.Object); var retVal = await sut.GetOrderAsync("TEST"); Assert.NotNull(retVal); }
public async void OrdersManager_GetOrdersAsync_IsEmpty() { var sut = new OrdersManager(_mockLog.Object, _mqPublisher.Object, _orderRepository.Object, _orderEntityService.Object); var retVal = await sut.GetOrdersAsync(); Assert.True(retVal.Count == 0); }
internal static BillingShippingUserInfo GetCustomerBillingAndShippingInfo(User user, OrdersManager ordersManager, UserProfileManager userProfileManager) { if (user == null) { return null; //don't do anything } CustomerRetriever customerRetriever = new CustomerRetriever(ordersManager, userProfileManager); Customer customer = customerRetriever.GetCustomerOfUser(user); if (customer == null) { return LoadDataFromSitefinityProfile(); } IQueryable<CustomerAddress> customerAddresses = ordersManager.GetPrimaryCustomerAddressesByCustomerId(customer.Id); if (customerAddresses.Count() == 0) { return LoadDataFromSitefinityProfile(); } var billingShippingInfo = new BillingShippingUserInfo(); CustomerAddress customerBillingAddress = GetPrimaryCustomerAddress(customerAddresses, AddressType.Billing); billingShippingInfo.BillingFirstName = customerBillingAddress.FirstName; billingShippingInfo.BillingLastName = customerBillingAddress.LastName; billingShippingInfo.BillingCompany = customerBillingAddress.Company; billingShippingInfo.BillingEmail = customerBillingAddress.Email; billingShippingInfo.BillingAddress1 = customerBillingAddress.Address; billingShippingInfo.BillingAddress2 = customerBillingAddress.Address2; billingShippingInfo.BillingCity = customerBillingAddress.City; billingShippingInfo.BillingCountry = customerBillingAddress.Country; billingShippingInfo.BillingState = customerBillingAddress.StateRegion; billingShippingInfo.BillingZip = customerBillingAddress.PostalCode; billingShippingInfo.BillingPhoneNumber = customerBillingAddress.Phone; CustomerAddress customerShippingAddress = GetPrimaryCustomerAddress(customerAddresses, AddressType.Shipping); if (customerShippingAddress == null) { customerShippingAddress = customerBillingAddress; } billingShippingInfo.ShippingFirstName = customerShippingAddress.FirstName; billingShippingInfo.ShippingLastName = customerShippingAddress.LastName; billingShippingInfo.ShippingCompany = customerShippingAddress.Company; billingShippingInfo.ShippingEmail = customerShippingAddress.Email; billingShippingInfo.ShippingAddress1 = customerShippingAddress.Address; billingShippingInfo.ShippingAddress2 = customerShippingAddress.Address2; billingShippingInfo.ShippingCity = customerShippingAddress.City; billingShippingInfo.ShippingCountry = customerShippingAddress.Country; billingShippingInfo.ShippingState = customerShippingAddress.StateRegion; billingShippingInfo.ShippingZip = customerShippingAddress.PostalCode; billingShippingInfo.ShippingPhoneNumber = customerShippingAddress.Phone; return billingShippingInfo; }
public TradingBotClient(IRestClient restClient, IModelConverter modelConverter) { this.Health = HealthManager.Create(restClient, modelConverter); this.Instance = InstanceManager.Create(restClient, modelConverter); this.Trading = TradingManager.Create(restClient, modelConverter); this.Markets = MarketsManager.Create(restClient, modelConverter); this.Account = AccountManager.Create(restClient, modelConverter); this.Orders = OrdersManager.Create(restClient, modelConverter); }
/// <summary> /// 绑定数据源 /// </summary> private void DataBindGrid(bool isQuery = false) { string startDate = txtStartDate.Value + " 00:00:00"; string endDate = txtEndDate.Value + " 23:59:59"; OrdersManager ordersManager = new OrdersManager(); dt = ordersManager.VehicleStatistics(startDate, endDate); ControlBindHelper.BindRepeaterList(dt, rp_Item); }
string PlaceMarketOrder(OrderSide side, double amount, ProductType productType) { OrderRequest request = new OrderRequest(OrderType.Market, InstrumentsManager.Current, AccountManager.Current, side, amount) { ProductType = productType, }; return(OrdersManager.Send(request).Id); }
private string ValidateOrder(string username, NewSingleOrder order) { if (OrdersManager.CallbackHasReqOrdID(order.RequesterOrderID)) { return("Requested Order ID already existed for this session."); } if (order.DateTime.Date != DateTime.Today.Date) { return("Invalid DateTime"); } if (DateTime.Now.Subtract(order.DateTime).Milliseconds > m_allowableOrderDelayInMilliSeconds) { return("Delayed Order"); } Dictionary <string, object> optionalParam = order.OptionalParam; if (optionalParam != null) { bool aon = false; if (optionalParam.ContainsKey("AON") && (optionalParam["AON"] == null || !bool.TryParse(optionalParam["AON"].ToString(), out aon))) { return("Invalid AON"); } if (aon) { if (!optionalParam.ContainsKey("MinQty")) { return("Missing Min. Qty"); } int minq = 0; if (optionalParam["MinQty"] == null || !int.TryParse(optionalParam["MinQty"].ToString(), out minq)) { return("Invalid Min. Qty"); } if (minq <= 0) { return("Invalid Min. Qty"); } if (minq > order.Quantity) { return("Min. quantity should be equal or less than order's quantity"); } } if (optionalParam.ContainsKey(ALLOC_REQ_FIELDS.ALLOC_TYPE) && order.OrderSide == "Buy") { bool isAllowBuyAllocation = Convert.ToBoolean(SystemConfigurations.GetAppSetting("AllowBuyAllocation")); if (isAllowBuyAllocation == false) { return("Mcsd Allocation for buy orders is not allowed"); } } } return("valid"); }
public IEnumerable <OrderLine> GetAllOrdersLines() { List <OrderLine> ret = new List <OrderLine>(); IEnumerable <OrderLine> lines = OrdersManager.GetOrders(OrderIds).SelectMany(o => o.Lines); ret.AddRange(lines); ret.AddRange(lines); return(ret); }
/// <summary> /// 初始化 /// </summary> private void InitData() { OrdersManager om = new OrdersManager(); Hashtable ht = om.GetLatestUserByVehicleID(_key); if (ht != null && ht.Count > 0) { ControlBindHelper.SetWebControls(this.Page, ht); } }
private void HandleUpdatedAllocation(AllocRes msg) { // update might be new,increase or decrease update // search order SingleOrder foundOrd = OrdersManager.GetOrder(msg.ReqID); if (foundOrd == null) { SystemLogger.WriteOnConsoleAsync(true, string.Format("Allocation Response not handled because Order ReqID [{0}] not found!"), ConsoleColor.Red, ConsoleColor.White, false); return; } lock (foundOrd) { // check status // switch btw // if PendingNew then send new order string actionOnAllocResponse = foundOrd.Data[SingleOrderProperties.ActionOnAllocResponse].ToString(); switch (actionOnAllocResponse) { case ActionOnAllocResponse.SendNewOrder: OrdersManager.HandleAllocationNewOrderAccepted(foundOrd, Fix.Entities.McsdSourceMessage.McsdAccepted); break; case ActionOnAllocResponse.ModifyOrder: OrdersManager.HandleAllocationUpdateOrderAccepted(foundOrd, Fix.Entities.McsdSourceMessage.McsdAccepted); break; case ActionOnAllocResponse.CancelOrder: OrdersManager.HandleAllocationCancelOrderAccepted(foundOrd); break; case ActionOnAllocResponse.DoNothing: SystemLogger.WriteOnConsoleAsync(true, string.Format("Do nothing Allocation Response not handled ReqID [{0}] ResponseType is {1}", msg.ReqID, msg.ResType), ConsoleColor.Red, ConsoleColor.White, false); break; default: SystemLogger.WriteOnConsoleAsync(true, string.Format("Allocation Response not handled ReqID [{0}] ResponseType is {1} ", msg.ReqID, msg.ResType), ConsoleColor.Red, ConsoleColor.White, false); break; } //if (status == ORD_STATUS.PendingNew) // OrdersManager.HandleAllocationNewOrderAccepted(foundOrd, Fix.Entities.McsdSourceMessage.McsdAccepted); //else if (status == ORD_STATUS.Canceled) // OrdersManager.HandleAllocationCancelOrderAccepted(foundOrd); //else if (isActive) // OrdersManager.HandleAllocationUpdateOrderAccepted(foundOrd, Fix.Entities.McsdSourceMessage.McsdAccepted); //else // SystemLogger.WriteOnConsoleAsync(true, string.Format("Allocation Response not handled ReqID [{0}] status [{1}] IsActive [{2}]", msg.ReqID, status, isActive), ConsoleColor.Red, ConsoleColor.White, false); } }
public string Execute(Hashtable params_ht) { Hashtable res = params_ht; if (res["UID"] == null || res["UID"].ToString().Trim().Length <= 0 || res["OrderID"] == null || res["OrderID"].ToString().Trim().Length <= 0 || res["Platform"] == null || res["Platform"].ToString().Trim().Length <= 0) { return(SiteHelper.GetJsonFromHashTable(null, "faild", "分享数据不完整")); } else { UserInfoManager uim = new UserInfoManager(); OrdersManager om = new OrdersManager(); SysSettingManager settingManager = new SysSettingManager(); UserCouponManager couponManager = new UserCouponManager(); uid = res["UID"].ToString().Trim(); orderid = res["OrderID"].ToString().Trim(); platform = res["Platform"].ToString().Trim(); Hashtable order_ht = om.GetOrderInfoByID(orderid); if (order_ht == null) { return(SiteHelper.GetJsonFromHashTable(null, "faild", "未找到订单数据,分享失败")); } string orderstate = SiteHelper.GetHashTableValueByKey(order_ht, "OrderState"); if (orderstate != OrderState.Finished.GetHashCode().ToString()) { return(SiteHelper.GetJsonFromHashTable(null, "faild", "订单未完成,分享失败")); } string sharestate = SiteHelper.GetHashTableValueByKey(order_ht, "ShareState"); bool result = true; if (sharestate == "0") { int couponNum = 0; int.TryParse(settingManager.GetValueByKey("OrderShareNum"), out couponNum); decimal couponMoney = 0.00m; decimal.TryParse(settingManager.GetValueByKey("OrderShareMoney"), out couponMoney); if (couponNum > 0 && couponMoney > 0) { result = couponManager.OrderShareGiveCoupons(uid, orderid, platform); } } if (result) { //响应数据到客户端 return(SiteHelper.GetJsonFromHashTable(null, "success", "订单分享成功", "UserInfo")); } else { return(SiteHelper.GetJsonFromHashTable(null, "faild", "订单分享失败")); } } }
private static string ReplaceValuesInTemplate(string template, CheckoutState checkoutSate, CartOrder cartOrder) { var order = OrdersManager.GetManager().GetOrder(cartOrder.Id); if (order != null) { var orderConfirmationEmailTemplateFormatter = new OrderConfirmationEmailTemplateFormatter(); return(orderConfirmationEmailTemplateFormatter.ReplaceValuesInTemplate(template, checkoutSate, order)); } return(string.Empty); }
public NewZOVOrderSelectMenu(Form tMainForm, ref OrdersManager tOrdersManager, ref OrdersCalculate tOrdersCalculate, ref NewOrderInfo tNewOrderInfo) { MainForm = tMainForm; NewOrderInfo = tNewOrderInfo; OrdersManager = tOrdersManager; OrdersCalculate = tOrdersCalculate; InitializeComponent(); Initialize(); }
private static void IncrementOrderNumber(OrdersManager ordersManager, Order order) { if (order.OrderNumber == 0) { lock (orderNumberLock) { NextOrderNumber orderNumber = ordersManager.GetNextOrderNumber(); order.OrderNumber = orderNumber.Next; ordersManager.IncrementNextOrderNumber(); } } }
private void btnSearchOrder_Click(object sender, EventArgs e) { if (!m_LoadDone) { return; } try { gridSearchOrder.DataSource = null; SingleOrder someOrder = null; if (rbSearchOrderByOrderID.Checked) { someOrder = OrdersManager.GetOrder(long.Parse(tbSearchOrder.Text)); } else if (rbSearchOrderByReqOrderID.Checked) { someOrder = OrdersManager.GetOrder(new Guid(tbSearchOrder.Text)); } else if (rbSearchByBourseOrdID.Checked) { someOrder = OrdersManager.GetOrder(tbSearchOrder.Text); } else if (rbSearchByClOrdID.Checked) { someOrder = OrdersManager.GetOrder(tbSearchOrder.Text, false); } if (someOrder != null) { lock (someOrder) { DataTable dt = new DataTable(); foreach (string probName in someOrder.Data.Keys) { dt.Columns.Add(probName); } DataRow row = dt.NewRow(); foreach (KeyValuePair <string, object> kvp in someOrder.Data) { row[kvp.Key] = kvp.Value; } dt.Rows.Add(row); gridSearchOrder.DataSource = dt; } } } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public static void ProcessOrder() { CatalogManager catalogManager = CatalogManager.GetManager(); OrdersManager ordersManager = OrdersManager.GetManager(); Product product = catalogManager.GetProducts().Where(p => p.Title == ExistingProductTitle && p.Status == ContentLifecycleStatus.Live).FirstOrDefault(); CartOrder cartOrder = ordersManager.CreateCartOrder(); cartOrder.OrderDate = DateTime.Now; cartOrder.OrderStatus = OrderStatus.Pending; int orderNumber = ordersManager.GetOrders().LastOrDefault().OrderNumber + 1; cartOrder.OrderNumber = orderNumber; cartOrder.OrderDate = DateTime.Now; cartOrder.LastModified = DateTime.Now; cartOrder.OrderAttempts = 0; var currency = Config.Get <EcommerceConfig>().DefaultCurrency; cartOrder.Currency = currency; Customer customer = ordersManager.GetCustomers().Where(c => c.CustomerFirstName == ExistingCustomerFirstName).FirstOrDefault(); cartOrder.UserId = customer.Id; CartDetail orderDetail = new CartDetail(); orderDetail.Id = Guid.NewGuid(); orderDetail.ProductId = product.Id; orderDetail.Quantity = 1; orderDetail.ProductAvailable = true; orderDetail.Price = product.Price; orderDetail.IsShippable = true; cartOrder.Details.Add(orderDetail); CheckoutState state = UpdateCheckoutState(customer, ordersManager, cartOrder); ordersManager.SaveChanges(); EcommerceOrderCalculator calculator = new EcommerceOrderCalculator(); calculator.CalculateAndSaveChanges(cartOrder); ordersManager.Checkout(cartOrder.Id, state, customer); ordersManager.SaveChanges(); catalogManager.SaveChanges(); }
internal static CartPayment GetCartPaymentFromCheckoutState(OrdersManager ordersManager, CheckoutState checkoutState) { CartPayment payment = ordersManager.CreateCartPayment(); payment.CreditCardCustomerName = checkoutState.CreditCardInfo.CreditCardCardholderName; payment.CreditCardExpireMonth = Convert.ToInt32(checkoutState.CreditCardInfo.CreditCardExpirationMonth); payment.CreditCardExpireYear = Convert.ToInt32(checkoutState.CreditCardInfo.CreditCardExpirationYear); payment.CreditCardNumberLastFour = string.Empty; payment.CreditCardNumber = string.Empty; payment.CreditCardType = checkoutState.CreditCardInfo.CreditCardType; payment.PaymentMethodId = checkoutState.PaymentMethodId; payment.PaymentMethodType = checkoutState.PaymentMethodType; return payment; }
internal static object GetShippingRates(ShippingManager shippingManager, OrdersManager ordersManager, Guid shoppingCartId, ShippingInfo shippingInfo) { //var availableShippingMethods = new List<IShippingResponse>(); //JMABase.WriteLogFile("SH Count: " + Config.Get<ShippingConfig>().ShippingCarrierProviders.Values.Count().ToString(), "/importErrorLog.txt"); //foreach (var shippingCarrier in Config.Get<ShippingConfig>().ShippingCarrierProviders.Values.Where(x => x.IsActive)) //{ // var carrierProvider = shippingManager.GetShippingCarrierProvider(shippingCarrier.Name); // JMABase.WriteLogFile("Carrier Name: " + shippingCarrier.Name, "/importErrorLog.txt"); // IShippingRequest genericShippingRequest = GenerateShippingRequest(shippingInfo); // JMABase.WriteLogFile("Shipping Country: " + shippingInfo.ShippingToCountry, "/importErrorLog.txt"); // JMABase.WriteLogFile("Shipping zip: " + shippingInfo.ShippingToZip, "/importErrorLog.txt"); // JMABase.WriteLogFile("Cart weight: " + shippingInfo.TotalCartWeight, "/importErrorLog.txt"); // //genericShippingRequest.CartOrder = CartHelper.GetCartOrder(ordersManager, shoppingCartId); // genericShippingRequest.CartOrder = ordersManager.GetCartOrder(shoppingCartId); // ShippingResponseContext shippingContext = carrierProvider.GetServiceRates(genericShippingRequest); // JMABase.WriteLogFile("Cart details: " + genericShippingRequest.CartOrder.Details.Count(), "/importErrorLog.txt"); // JMABase.WriteLogFile("Shipping context error: " + shippingContext.ErrorMessage, "/importErrorLog.txt"); // JMABase.WriteLogFile("Shipping responses: " + shippingContext.ShippingResponses.Count(), "/importErrorLog.txt"); // if (shippingContext.ShippingResponses != null) // { // availableShippingMethods.AddRange(shippingContext.ShippingResponses); // } //} // return availableShippingMethods.OrderBy(x => x.SortOrder).ToList(); List<ShippingMethod> methodsList = new List<ShippingMethod>(); var order = CartHelper.GetCartOrder(ordersManager, shoppingCartId); foreach (var a in shippingManager.GetShippingMethods().OrderBy(a => a.SortOrder)) { string[] sht = a.ShippingLimitToDisplay.Replace("total price:", "").Trim().Split('-'); decimal hLimit = 0; decimal.TryParse(sht[1], out hLimit); decimal lLimit = 0; decimal.TryParse(sht[0], out lLimit); if (hLimit <= order.Total && order.Total >= lLimit) { methodsList.Add(a); } } return methodsList; }
internal static CartAddress GetBillingAddressFromCheckoutState(OrdersManager ordersManager, CheckoutState checkoutState) { CartAddress billingAddress = ordersManager.CreateCartAddress(); billingAddress.FirstName = checkoutState.BillingFirstName; billingAddress.LastName = checkoutState.BillingLastName; billingAddress.Email = checkoutState.BillingEmail; billingAddress.Address = checkoutState.BillingAddress1; billingAddress.Address2 = checkoutState.BillingAddress2; billingAddress.AddressType = AddressType.Billing; billingAddress.City = checkoutState.BillingCity; billingAddress.PostalCode = checkoutState.BillingZip; billingAddress.StateRegion = checkoutState.BillingState; billingAddress.Country = checkoutState.BillingCountry; billingAddress.Phone = checkoutState.BillingPhoneNumber; billingAddress.Email = checkoutState.BillingEmail; billingAddress.Company = checkoutState.BillingCompany; return billingAddress; }
internal static Customer GetCustomerInfoOrCreateOneIfDoesntExsist(UserProfileManager userProfileManager, OrdersManager ordersManager, CheckoutState checkoutState) { var customerRetriever = new CustomerRetriever(ordersManager, userProfileManager); User customerUser = null; Customer customer = null; Guid userId = SecurityManager.CurrentUserId; if (userId != Guid.Empty) { customerUser = SecurityManager.GetUser(userId); if (customerUser != null) { customer = customerRetriever.GetCustomer(customerUser, checkoutState); } } return customer; }
internal static object GetShippingRates(ShippingManager shippingManager, OrdersManager ordersManager, Guid shoppingCartId,ShippingInfo shippingInfo) { var availableShippingMethods = new List<IShippingResponse>(); foreach (var shippingCarrier in Config.Get<ShippingConfig>().ShippingCarrierProviders.Values.Where(x => x.IsActive)) { var carrierProvider = shippingManager.GetShippingCarrierProvider(shippingCarrier.Name); IShippingRequest genericShippingRequest = GenerateShippingRequest(shippingInfo); genericShippingRequest.CartOrder = CartHelper.GetCartOrder(ordersManager, shoppingCartId); ShippingResponseContext shippingContext = carrierProvider.GetServiceRates(genericShippingRequest); if (shippingContext.ShippingResponses != null) { availableShippingMethods.AddRange(shippingContext.ShippingResponses); } } return availableShippingMethods.OrderBy(x => x.SortOrder).ToList(); }
public override void Confirm() { var args = new ConfirmEventArgs(); args.PaymentData = base.PaymentData; args.Success = true; args.TotalPaid = 0; string orderRef = HttpContext.Current.Request.Form["item_number"]; var man = new OrdersManager<Order, OrdersFilter, OrderRow, OrderRowsFilter>(); //new OM(); args.OrderToPay = man.GetByOrderRef(orderRef); if (args.OrderToPay.Id == 0) { args.Success = false; args.MessageName = "InvalidOrderRef"; OnPaymentConfirmed(args); return; } args.MessageName = "OK"; OnPaymentConfirmed(args); }
private void AddEventToCart(Event currentEvent) { CatalogManager catalog = new CatalogManager(); Product product = catalog.GetProduct(ProductId); HttpCookie cookie = HttpContext.Current.Request.Cookies.Get("shoppingCartId"); OrdersManager orderm = new OrdersManager(); OptionsDetails optionDetails = new OptionsDetails(); // Check if shopping cart cookie exists in the current request. if (cookie == null) //if it does not exist... { CartOrder cartItem = orderm.CreateCartOrder(); //create a new cart order var shoppingcartid = cartItem.Id; // that id is equal to the cookie value HttpCookie Cookie = new HttpCookie("shoppingCartId"); //create a new shopping cart cookie DateTime now = DateTime.Now; // Set the cookie value. Cookie.Value = shoppingcartid.ToString(); // Set the cookie expiration date. Cookie.Expires = now.AddYears(1);// Add the cookie. HttpContext.Current.Response.Cookies.Add(Cookie); //give cart item currency of USD because it cannot be null cartItem.Currency = "USD"; //add the product to the cart orderm.AddToCart(cartItem, product, optionDetails, 1); //save all changes orderm.SaveChanges(); } else //if the cookie does exist { Guid guid = new Guid(cookie.Value.ToString()); //get the cookie value as the guid CartOrder cartItem = orderm.GetCartOrder(guid); //get the cart based on the cookie value orderm.AddToCart(cartItem, product, optionDetails, 1); // add the item to the cart orderm.SaveChanges(); //save changes } }
internal static CartOrder GetCartOrder(OrdersManager ordersManager, Guid shoppingCartId) { return ordersManager.GetCart(shoppingCartId); }
public override void Confirm() { var args = new ConfirmEventArgs(); args.PaymentData = base.PaymentData; args.Success = true; string orderRef = HttpContext.Current.Request.Form["item_number"]; var man = new OrdersManager<Order, OrdersFilter, OrderRow, OrderRowsFilter>(); //new OM(); args.OrderToPay = man.GetByOrderRef(orderRef); if (args.OrderToPay.Id == 0) { args.Success = false; args.MessageName = "InvalidOrderRef"; OnPaymentConfirmed(args); return; } string strResponse = ""; try { HttpWebRequest req = (HttpWebRequest)WebRequest.Create(base.PaymentData.PaySubmitUrl); req.Method = "POST"; req.ContentType = "application/x-www-form-urlencoded"; byte[] param = HttpContext.Current.Request.BinaryRead(HttpContext.Current.Request.ContentLength); string strRequest = Encoding.ASCII.GetString(param); strRequest += "&cmd=_notify-validate"; req.ContentLength = strRequest.Length; StreamWriter streamOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII); streamOut.Write(strRequest); streamOut.Close(); StreamReader streamIn = new StreamReader(req.GetResponse().GetResponseStream()); strResponse = streamIn.ReadToEnd(); streamIn.Close(); } catch (Exception ex) { args.MessageName = "RequestErr"; args.Success = false; args.Exception = ex; OnPaymentConfirmed(args); return; } if (strResponse == "VERIFIED") { var allowedStatus = new List<string>(); allowedStatus.Add("completed"); if (base.PaymentData.IsDebug) allowedStatus.Add("pending"); args.TotalPaid = 0; Decimal.TryParse( HttpContext.Current.Request.Form["mc_gross"].Replace(',', '.'), NumberStyles.Any, new CultureInfo("en-US"), out args.TotalPaid); string payment_status = HttpContext.Current.Request.Form["payment_status"].ToString(); string receiver_email = HttpContext.Current.Request.Form["receiver_email"].ToString(); if (!allowedStatus.Contains(payment_status.ToLower())) { args.Success = false; args.MessageName = "InvalidPaymentStatus"; OnPaymentConfirmed(args); return; } if (base.PaymentData.PayAccount != receiver_email) { args.Success = false; args.MessageName = "InvalidReceiverEmail"; OnPaymentConfirmed(args); return; } } else { args.Success = false; args.MessageName = "InvalidRespone:["+ strResponse +"] "; OnPaymentConfirmed(args); return; } args.MessageName = "OK"; OnPaymentConfirmed(args); }
internal static Tuple<bool, IPaymentResponse> PlaceOrder(OrdersManager ordersManager, CatalogManager catalogManager, UserManager userManager, RoleManager roleManager, UserProfileManager userProfileManager, CheckoutState checkoutState, Guid cartOrderId) { CartOrder cartOrder = ordersManager.GetCartOrder(cartOrderId); cartOrder.Addresses.Clear(); cartOrder.Payments.Clear(); //set the default currency of the order string defaultCurrency = Config.Get<EcommerceConfig>().DefaultCurrency; cartOrder.Currency = defaultCurrency; // set the shipping address CartAddress shippingAddress = CartHelper.GetShippingAddressFromCheckoutState(ordersManager, checkoutState); cartOrder.Addresses.Add(shippingAddress); // set the billing address CartAddress billingAddress = CartHelper.GetBillingAddressFromCheckoutState(ordersManager, checkoutState); cartOrder.Addresses.Add(billingAddress); //Get the first payment method in the shop // set the payment CartPayment payment = CartHelper.GetCartPaymentFromCheckoutState(ordersManager, checkoutState); cartOrder.Payments.Add(payment); ordersManager.SaveChanges(); // Get current customer or create new one Customer customer = UserProfileHelper.GetCustomerInfoOrCreateOneIfDoesntExsist(userProfileManager,ordersManager, checkoutState); // Save the customer address CustomerAddressHelper.SaveCustomerAddressOfCurrentUser(checkoutState, customer); //Use the API to checkout IPaymentResponse paymentResponse = ordersManager.Checkout(cartOrderId, checkoutState, customer); // record the "success" state of the checkout checkoutState.IsPaymentSuccessful = paymentResponse.IsSuccess; Order order = ordersManager.GetOrder(cartOrderId); //Increment the order IncrementOrderNumber(ordersManager, order); // add the order to customer customer.Orders.Add(order); // Update the order order.Customer = customer; ordersManager.SaveChanges(); if (!paymentResponse.IsSuccess) { return new Tuple<bool, IPaymentResponse>(false, paymentResponse); } if (order.OrderStatus == OrderStatus.Paid) { UserProfileHelper.AssignCustomerToRoles(userManager, roleManager, catalogManager, SecurityManager.GetCurrentUserId(), order); EmailHelper.SendOrderPlacedEmailToClientAndMerchant(cartOrder, checkoutState, order.OrderNumber); } return new Tuple<bool, IPaymentResponse>(true, paymentResponse); }
internal static CartOrder GetCartOrder(OrdersManager ordersManager, Guid shoppingCartId, string zip) { CartOrder order = ordersManager.GetCartOrder(shoppingCartId); foreach (CartDetail de in order.Details) { if (!String.IsNullOrEmpty(zip)) { de.TaxRate = GetTaxList(zip); } else { if (order.Addresses.Count() > 0) { de.TaxRate = GetTaxList(order.Addresses[0].PostalCode); } } } return order; }
internal static bool DoesCartHaveAnyShippableItems(OrdersManager ordersManager, Guid shoppingCartId) { return GetCartOrder(ordersManager, shoppingCartId).Details.ToList().Where(od => od.IsShippable).Count() > 0; }
internal static double GetTotalWeightOfCart(OrdersManager ordersManager, Guid shoppingCartId) { return GetCartOrder(ordersManager, shoppingCartId).Details.ToList().Sum(od => od.Weight); }