public IActionResult AddtoOrder(CustomOrder details) { int Id = details.ProdId; var query = from u in prods where u.ProdId == Id select u; if (query.Count() != 0) { return(RedirectToAction("PlaceOrder")); } prods.Add(details); var querylocal = db.LocalInventory.ToList(); int id = Convert.ToInt32(User.FindFirst(claim => claim.Type == System.Security.Claims.ClaimTypes.Actor)?.Value); List <LocalInventory> lo = new List <LocalInventory>(); querylocal.ForEach(x => { if (x.OutletId == id) { lo.Add(x); } }); var products = db.Product.ToList(); var spec = db.Spec.ToList(); ViewBag.LocalProducts = querylocal; ViewBag.Product = products; ViewBag.Spec = spec; ViewBag.prods = prods; return(RedirectToAction("PlaceOrder")); }
public bool OrderCancel(CustomOrder order, out string errMsg) { if (order == null || string.IsNullOrEmpty(order.InstrumentID)) { errMsg = "CTP撤单时Order参数不能为空,InstrumentID信息也不能为空"; return(false); } ThostFtdcInputOrderActionField inAction = new ThostFtdcInputOrderActionField(); inAction.BrokerID = BROKER_ID; inAction.InvestorID = INVESTOR_ID; inAction.FrontID = FRONT_ID; inAction.SessionID = SESSION_ID; inAction.InstrumentID = order.InstrumentID; inAction.OrderRef = order.OrderNo.ToString(); inAction.ActionFlag = EnumActionFlagType.Delete; // 撤单 var ret = trader.ReqOrderAction(inAction, iRequestID++); errMsg = (ret == 0) ? "-" : "CTP撤单失败,返回值:" + ret; return(ret == 0); }
///报单通知 private void OnRtnOrder(ThostFtdcOrderField pOrder) { //__DEBUGPF__(); System.Diagnostics.Debug.WriteLine(string.Format("{2} OnRtnOrder: {0}, {1}, {3}", pOrder.OrderRef, pOrder.InstrumentID, DateTime.Now.ToString("HH:mm:ss"), pOrder.OrderStatus)); if (IsMyOrder(pOrder)) { var customOrder = new CustomOrder(); // 原始报单信息 customOrder.OrderNo = int.Parse(pOrder.OrderRef); customOrder.InstrumentID = pOrder.InstrumentID; customOrder.Direction = (pOrder.Direction == EnumDirectionType.Buy) ? BS_CODE.Buy : BS_CODE.Sell; customOrder.OffsetFlag = (pOrder.CombOffsetFlag_0 == EnumOffsetFlagType.Open) ? OC_CODE.Open : OC_CODE.Close; customOrder.Price = pOrder.LimitPrice; customOrder.Volume = pOrder.VolumeTotalOriginal; // 更新委托回报信息 customOrder.tradeRef = pOrder.ExchangeID + "_" + pOrder.OrderSysID; // 查找对应成交回报的依据 customOrder.TradedVol = pOrder.VolumeTotalOriginal - pOrder.VolumeTotal; // 已成交数量 customOrder.OrderStatus = ConvertStatus(pOrder.OrderStatus); // 处理委托回报 if (HandleRtnOrderDel != null) { HandleRtnOrderDel(customOrder); //HandleRtnOrderDel.BeginInvoke(customOrder, null, null); } } }
public ActionResult DeleteConfirmed(int id) { CustomOrder customOrder = db.CustomOrders.Find(id); db.CustomOrders.Remove(customOrder); db.SaveChanges(); return(RedirectToAction("Index")); }
public IHttpActionResult Post(CustomOrder value) { CustomOrder createdValue = value; var uri1 = Url.Link("ValidId", new { orderNumber = createdValue.Order }); var uri2 = Url.Link("ParamId", new { orderNumber = createdValue.Order }); return(Created(new Uri(uri1), createdValue)); }
public ActionResult Edit([Bind(Include = "Id,OrderId,CustomerID,RequestDescription")] CustomOrder customOrder) { if (ModelState.IsValid) { db.Entry(customOrder).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(customOrder)); }
public IHttpActionResult GetByAttributeRouting([FromUri] OrderNumber orderNumber) { var v = new CustomOrder() { ComputerName = "TestPC", Order = "Test" }; OrderNumber number = "Test"; string t = number; return(Ok(v)); }
public ActionResult Create([Bind(Include = "Id,CustomerID,RequestDescription")] CustomOrder customOrder) { if (ModelState.IsValid) { customOrder.CustomerID = User.Identity.GetUserId(); db.CustomOrders.Add(customOrder); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(customOrder)); }
private void UpdateOrder(CustomOrder order) { lock (orderLocker) { foreach (var f in formList) { // 推送委托回报 if (!f.IsDisposed) { f.OnRtnOrder(order); } } } }
// GET: CustomOrders/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CustomOrder customOrder = db.CustomOrders.Find(id); if (customOrder == null) { return(HttpNotFound()); } return(View(customOrder)); }
private void HandleErrRtnOrderCancel(CustomOrder order, string errorMsg) { lock (errRtnLocker) { foreach (var f in formList) { // 推送委托回报 if (!f.IsDisposed) { f.OnErrRtnOrderCancel(order, errorMsg); } } } }
public ActionResult Create([Bind(Include = "Id,CustomerID,Description,Price,EstimatedTimeOfCompletion,SellersNotes")] CustomOrderItem customOrderItem) { CustomOrder passedModel = db.CustomOrders.Find(Convert.ToInt32(RouteData.Values["id"])); customOrderItem.Id = Convert.ToInt32(RouteData.Values["id"]); customOrderItem.CustomerID = passedModel.CustomerID; if (ModelState.IsValid) { db.CustomItems.Add(customOrderItem); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(customOrderItem)); }
public ActionResult Save(CustomOrder customOrder) { db.CustomOrders.Add(customOrder); db.SaveChanges(); if (Request.IsAjaxRequest()) { string jsonStr = PubFunction.BuildResult("OK"); return(Content(jsonStr)); } else { return(View()); } }
/* * -------------------------------------------------------------- * 帮助函数 * -------------------------------------------------------------- */ private bool CheckOrder(CustomOrder order, out string errorMsg) { if (order == null) { errorMsg = "CTP报单参数不能为空!"; return(false); } if (string.IsNullOrEmpty(order.InstrumentID)) { errorMsg = "CTP报单时InstrumentID不能为空"; return(false); } errorMsg = "-"; return(true); }
bool UpdateOrderPrice(CustomOrder order) { var m = (order.InstrumentID == inParam.InIF1) ? latestM1 : latestM2; if (m == null || m.Buy == null || m.Sell == null) { errorMsg = order.InstrumentID + "当前无行情数据"; return(false); } var basePrice = (order.Direction == BS_CODE.Buy) ? m.Sell[0] : m.Buy[0]; var append = (order.Direction == BS_CODE.Buy) ? inParam.InReorderAppend : (-1 * inParam.InReorderAppend); order.Price = basePrice + append; return(true); }
private void OnRspOrderAction(ThostFtdcInputOrderActionField pInputOrderAction, ThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast) { __DEBUGPF__(); //IsErrorRspInfo(pRspInfo); if (HandleErrRtnOrderCancelDel != null) { var customOrder = new CustomOrder(); // 原始报单信息 customOrder.OrderNo = int.Parse(pInputOrderAction.OrderRef); customOrder.InstrumentID = pInputOrderAction.InstrumentID; customOrder.Price = pInputOrderAction.LimitPrice; // 更新委托回报信息 customOrder.tradeRef = pInputOrderAction.ExchangeID + "_" + pInputOrderAction.OrderSysID; HandleErrRtnOrderCancelDel(customOrder, pRspInfo.ErrorMsg); } }
/* * -------------------------------------------------------------- * 报单/撤单,委托回报/成交回报 * -------------------------------------------------------------- */ public bool OrderInsert(CustomOrder order, out string errMsg) { if (!CheckOrder(order, out errMsg)) { return(false); } // 构造下单参数 ThostFtdcInputOrderField inOrder = new ThostFtdcInputOrderField(); inOrder.BrokerID = BROKER_ID; inOrder.InvestorID = INVESTOR_ID; inOrder.OrderPriceType = EnumOrderPriceTypeType.LimitPrice; inOrder.InstrumentID = order.InstrumentID; inOrder.OrderRef = iOrderRef.ToString(); inOrder.LimitPrice = order.Price; inOrder.Direction = (order.Direction == BS_CODE.Buy) ? EnumDirectionType.Buy : EnumDirectionType.Sell; inOrder.CombOffsetFlag_0 = (order.OffsetFlag == OC_CODE.Open) ? EnumOffsetFlagType.Open : EnumOffsetFlagType.Close; inOrder.VolumeTotalOriginal = order.Volume; inOrder.VolumeCondition = EnumVolumeConditionType.AV; inOrder.MinVolume = 0; // ?? inOrder.ContingentCondition = EnumContingentConditionType.Immediately; inOrder.CombHedgeFlag_0 = HedgeFlagType; inOrder.TimeCondition = EnumTimeConditionType.GFD; inOrder.ForceCloseReason = EnumForceCloseReasonType.NotForceClose; inOrder.IsAutoSuspend = 0; inOrder.UserForceClose = 0; // 更新 order.OrderNo = iOrderRef; iOrderRef++; // 下单 var ret = trader.ReqOrderInsert(inOrder, iRequestID++); errMsg = (ret == 0) ? "-" : "CTP报单录入失败,返回值:" + ret; return(ret == 0); }
public IActionResult Cart(CustomOrder details) { var querylocal = db.LocalInventory.ToList(); int id = Convert.ToInt32(User.FindFirst(claim => claim.Type == System.Security.Claims.ClaimTypes.Actor)?.Value); List <LocalInventory> lo = new List <LocalInventory>(); querylocal.ForEach(x => { if (x.OutletId == id) { lo.Add(x); } }); var products = db.Product.ToList(); var spec = db.Spec.ToList(); ViewBag.LocalProducts = querylocal; ViewBag.Product = products; ViewBag.Spec = spec; ViewBag.prods = prods; return(View()); }
public ActionResult AddCustomOrder(CustomViewModel collection) { try { List <string> ScentIds = collection.ScentIds.Split(',').ToList <string>(); DBEntities db = new DBEntities(); string userId = User.Identity.GetUserId(); CustomOrder custom = new CustomOrder() { Name = collection.CustomName, BottleSize = collection.BottleSize, UserId = userId, Quantity = collection.Quantity }; db.CustomOrders.Add(custom); db.SaveChanges(); foreach (string i in ScentIds) { if (i != "") { CustomOrderScent cust = new CustomOrderScent() { ScentId = Convert.ToInt32(i), CustomOrderId = custom.Id }; db.CustomOrderScents.Add(cust); } } db.SaveChanges(); Alert.CustomAdded = true; return(RedirectToAction("CustomPerfume", "Client")); } catch (Exception exp) { return(Content(exp.Message)); } }
private void OnRtnOrderInternal(CustomOrder order) { spreadTrader.OnRtnOrder(order); }
private void OnErrRtnOrderCancelInternal(CustomOrder order, string errorMsg) { spreadTrader.OnErrRtnOrderCancel(order, errorMsg); }
public void OnRtnOrder(CustomOrder order) { var del = new HandleRtnOrderDelegate(OnRtnOrderInternal); this.BeginInvoke(del, new object[] { order }); }
public CustomOrder(CustomOrder copiedOrder) : base(copiedOrder) { this.CustomID = copiedOrder.CustomID; }
private void ExportOrders(int?orderId) { var orders = new List <CustomOrder>(); var products = new List <CustomProduct>(); var productExtras = new List <CustomProductExtra>(); var orderCust = AppLogic.GetString("CMD.StoreCustomerID", SkinID, LocaleSetting); var program = AppLogic.GetString("CMD.StoreProgramNumber", SkinID, LocaleSetting); var dateString = ""; //call sproc and get list of orders using (SqlConnection connection = new SqlConnection(ConfigurationManager.AppSettings["DBConn"])) { //string query = "exec custom_GetOrder @OrderID"; string query = orderId.HasValue ? "exec custom_GetOrdersForExport @OrderID" : "exec custom_GetOrdersForExport"; SqlCommand command = new SqlCommand(query, connection); if (orderId.HasValue) { command.Parameters.AddWithValue("@OrderID", orderId.Value); } connection.Open(); SqlDataReader reader = command.ExecuteReader(); try { while (reader.Read()) { //Orders var orderNumber = Convert.ToInt32(reader["OrderNumber"]); var orderDate = Convert.ToDateTime(reader["OrderDate"]); var email = reader["Email"].ToString(); var customerId = Convert.ToInt32(reader["CustomerID"]); var billingCompany = reader["BillingCompany"] != null ? reader["BillingCompany"].ToString() : ""; var billingFirstName = reader["BillingFirstName"] != null ? reader["BillingFirstName"].ToString() : ""; var billingLastName = reader["BillingLastName"] != null ? reader["BillingLastName"].ToString() : ""; var billingAddress1 = reader["BillingAddress1"] != null ? reader["BillingAddress1"].ToString() : ""; var billingAddress2 = reader["BillingAddress2"] != null ? reader["BillingAddress2"].ToString() : ""; var billingSuite = reader["BillingSuite"] != null ? reader["BillingSuite"].ToString() : ""; var billingCity = reader["BillingCity"] != null ? reader["BillingCity"].ToString() : ""; var billingState = reader["BillingState"] != null ? reader["BillingState"].ToString() : ""; var billingZip = reader["BillingZip"] != null ? reader["BillingZip"].ToString() : ""; var billingCountry = reader["BillingCountry"] != null ? reader["BillingCountry"].ToString() : ""; var billingPhone = reader["BillingPhone"] != null ? reader["BillingPhone"].ToString() : ""; var cardType = reader["CardType"] != null ? reader["CardType"].ToString() : ""; var cardName = reader["CardName"] != null ? reader["CardName"].ToString() : ""; var last4 = reader["Last4"] != null ? reader["Last4"].ToString() : ""; var cardExpirationMonth = reader["CardExpirationMonth"] != null ? reader["CardExpirationMonth"].ToString() : ""; var cardExpirationYear = reader["CardExpirationYear"] != null ? reader["CardExpirationYear"].ToString() : ""; var authorizationCode = reader["AuthorizationCode"] != null ? reader["AuthorizationCode"].ToString() : ""; var paymentGateway = reader["PaymentGateway"] != null ? reader["PaymentGateway"].ToString() : ""; var transactionState = reader["TransactionState"] != null ? reader["TransactionState"].ToString() : ""; var shippingCompany = reader["ShippingCompany"] != null ? reader["ShippingCompany"].ToString() : ""; var shippingFirstName = reader["ShippingFirstName"] != null ? reader["ShippingFirstName"].ToString() : ""; var shippingLastName = reader["ShippingLastName"] != null ? reader["ShippingLastName"].ToString() : ""; var shippingAddress1 = reader["ShippingAddress1"] != null ? reader["ShippingAddress1"].ToString() : ""; var shippingAddress2 = reader["ShippingAddress2"] != null ? reader["ShippingAddress2"].ToString() : ""; var shippingSuite = reader["ShippingSuite"] != null ? reader["ShippingSuite"].ToString() : ""; var shippingCity = reader["ShippingCity"] != null ? reader["ShippingCity"].ToString() : ""; var shippingState = reader["ShippingState"] != null ? reader["ShippingState"].ToString() : ""; var shippingZip = reader["ShippingZip"] != null ? reader["ShippingZip"].ToString() : ""; var shippingCountry = reader["ShippingCountry"] != null ? reader["ShippingCountry"].ToString() : ""; var shippingPhone = reader["ShippingPhone"] != null ? reader["ShippingPhone"].ToString() : ""; var shippingMethod = reader["ShippingMethod"] != null ? reader["ShippingMethod"].ToString() : ""; var orderSubTotal = Convert.ToDecimal(reader["OrderSubTotal"]); var orderTax = Convert.ToDecimal(reader["OrderTax"]); var orderShippingCosts = Convert.ToDecimal(reader["OrderShippingCosts"]); var orderTotal = Convert.ToDecimal(reader["OrderTotal"]); var taxRate = Convert.ToDecimal(reader["TaxRate"]); dateString = orderDate.ToShortDateString().Replace("/", "-"); cardExpirationYear = !String.IsNullOrEmpty(cardExpirationYear) ? cardExpirationYear.Substring(2) : cardExpirationYear; var order = new CustomOrder { OrderID = orderNumber, OrderDate = orderDate, Email = email, CustomerID = customerId, BillingCompany = billingCompany, BillingFirstName = billingFirstName, BillingLastName = billingLastName, BillingAddress1 = billingAddress1, BillingAddress2 = billingAddress2, BillingSuite = billingSuite, BillingCity = billingCity, BillingState = billingState, BillingZip = billingZip, BillingCountry = CustomOrder.ConvertCountryCode(billingCountry), BillingPhone = billingPhone, CardType = cardType, CardName = cardName, Last4 = last4, CardExpirationMonth = cardExpirationMonth, CardExpirationYear = cardExpirationYear, AuthorizationCode = authorizationCode, PaymentGateway = paymentGateway, TransactionState = transactionState, ShippingCompany = shippingCompany, ShippingFirstName = shippingFirstName, ShippingLastName = shippingLastName, ShippingAddress1 = shippingAddress1, ShippingAddress2 = shippingAddress2, ShippingSuite = shippingSuite, ShippingCity = shippingCity, ShippingState = shippingState, ShippingZip = shippingZip, ShippingCountry = CustomOrder.ConvertCountryCode(shippingCountry), ShippingPhone = shippingPhone, ShippingMethod = shippingMethod, OrderSubtotal = orderSubTotal, OrderTax = orderTax, OrderShippingCosts = orderShippingCosts, OrderTotal = orderTotal, TaxRate = taxRate }; orders.Add(order); } reader.NextResult(); while (reader.Read()) { //Products var orderNumber = Convert.ToInt32(reader["OrderNumber"]); var productId = Convert.ToInt32(reader["ProductID"]); var orderedProductName = reader["OrderedProductName"].ToString(); var quantity = Convert.ToInt32(reader["Quantity"]); var chosenColorSKUModifier = reader["ChosenColorSKUModifier"] != null ? reader["ChosenColorSKUModifier"].ToString() : ""; var chosenSizeSKUModifier = reader["ChosenSizeSKUModifier"] != null ? reader["ChosenSizeSKUModifier"].ToString() : ""; var orderedProductSKU = reader["OrderedProductSKU"] != null ? reader["OrderedProductSKU"].ToString() : ""; var orderedProductPrice = Convert.ToDecimal(reader["OrderedProductPrice"]); var orderedProductRegularPrice = Convert.ToDecimal(reader["OrderedProductRegularPrice"]); var product = new CustomProduct { OrderID = orderNumber, ProductID = productId, OrderedProductName = orderedProductName, Quantity = quantity, ChosenColorSKUModifier = chosenColorSKUModifier, ChosenSizeSKUModifier = chosenSizeSKUModifier, OrderedProductSKU = orderedProductSKU, OrderedProductPrice = orderedProductPrice, OrderedProductRegularPrice = orderedProductRegularPrice }; products.Add(product); } reader.NextResult(); while (reader.Read()) { //Product Extras var productId = Convert.ToInt32(reader["ProductID"]); var partId = Convert.ToInt32(reader["PartID"]); var kitId = reader["KitID"].ToString(); var quantity = Convert.ToInt32(reader["Quantity"]); var color = reader["Color"].ToString(); var productExtra = new CustomProductExtra { ProductID = productId, PartID = partId, KitID = kitId, Quantity = quantity, Color = color }; productExtras.Add(productExtra); } } finally { reader.Close(); } } StringWriter stringWriter = new StringWriter(); XmlTextWriter xmlTextWriter = new XmlTextWriter(stringWriter); xmlTextWriter.Formatting = Formatting.Indented; xmlTextWriter.WriteStartDocument(); xmlTextWriter.WriteStartElement("orders"); //loop thru and build xml foreach (var order in orders) { xmlTextWriter.WriteStartElement("order"); xmlTextWriter.WriteElementString("version", ""); xmlTextWriter.WriteElementString("rectype", "B"); xmlTextWriter.WriteElementString("seqno", "1"); xmlTextWriter.WriteElementString("ordno", order.OrderID.ToString()); xmlTextWriter.WriteElementString("webtrack", order.OrderID.ToString()); xmlTextWriter.WriteElementString("orddate", order.OrderDate.ToString("M/d/yy")); xmlTextWriter.WriteElementString("loginid", order.Email); xmlTextWriter.WriteElementString("email", order.Email); xmlTextWriter.WriteElementString("ordcust", orderCust); xmlTextWriter.WriteElementString("bcompany", order.BillingCompany); xmlTextWriter.WriteElementString("battn", (order.BillingFirstName + " " + order.BillingLastName).Trim()); xmlTextWriter.WriteElementString("baddr1", order.BillingAddress1); xmlTextWriter.WriteElementString("baddr2", (order.BillingAddress2 + " " + order.BillingSuite).Trim()); xmlTextWriter.WriteElementString("bcity", order.BillingCity); xmlTextWriter.WriteElementString("bstate", order.BillingState); xmlTextWriter.WriteElementString("bzip", order.BillingZip); xmlTextWriter.WriteElementString("bcountry", CustomOrder.ConvertCountryCode(order.BillingCountry)); xmlTextWriter.WriteElementString("bphone", order.BillingPhone); xmlTextWriter.WriteElementString("cctype", CustomOrder.ConvertCCType(order.CardType)); xmlTextWriter.WriteElementString("ccname", order.CardType); xmlTextWriter.WriteElementString("ccnum", order.Last4); xmlTextWriter.WriteElementString("ccexpire", String.Format("{0}{1}", order.CardExpirationMonth, order.CardExpirationYear)); xmlTextWriter.WriteElementString("ccauthzano", order.AuthorizationCode); xmlTextWriter.WriteElementString("ccauthrefer", order.PaymentGateway); xmlTextWriter.WriteElementString("ccsettled", order.TransactionState == "CAPTURED" ? "Y" : "N"); xmlTextWriter.WriteElementString("program", program); xmlTextWriter.WriteElementString("shipamt", order.OrderShippingCosts.ToString("F")); xmlTextWriter.WriteElementString("shipdesc", CustomOrder.ConvertShippingMethod(order.ShippingMethod)); xmlTextWriter.WriteElementString("taxamt", order.OrderTax.ToString("F")); xmlTextWriter.WriteElementString("grdtotal", order.OrderTotal.ToString("F")); List <string> alpha1 = new List <string>(); List <string> alpha2 = new List <string>(); List <string> alpha3 = new List <string>(); var items = products.Where(p => p.OrderID == order.OrderID); foreach (var item in items) { alpha1.Add(item.OrderedProductSKU); alpha2.Add(item.OrderedProductName); alpha3.Add(item.ChosenColorSKUModifier); } xmlTextWriter.WriteElementString("alpha1", String.Join(",", alpha1.ToArray())); xmlTextWriter.WriteElementString("alpha2", String.Join(",", alpha2.ToArray())); xmlTextWriter.WriteElementString("alpha3", String.Join(",", alpha3.ToArray())); xmlTextWriter.WriteElementString("num1", ""); xmlTextWriter.WriteElementString("num2", ""); xmlTextWriter.WriteElementString("num3", ""); xmlTextWriter.WriteElementString("date1", ""); xmlTextWriter.WriteElementString("date2", ""); xmlTextWriter.WriteElementString("date3", ""); //shiptos xmlTextWriter.WriteStartElement("shiptos"); xmlTextWriter.WriteStartElement("shipto"); xmlTextWriter.WriteElementString("rectype", "S"); xmlTextWriter.WriteElementString("ordno", order.OrderID.ToString()); xmlTextWriter.WriteElementString("webtrack", order.OrderID.ToString()); xmlTextWriter.WriteElementString("seqno", "1"); xmlTextWriter.WriteElementString("shipdate", ""); xmlTextWriter.WriteElementString("scompany", order.ShippingCompany); xmlTextWriter.WriteElementString("sname", (order.ShippingFirstName + " " + order.ShippingLastName).Trim()); xmlTextWriter.WriteElementString("saddr1", order.ShippingAddress1); xmlTextWriter.WriteElementString("saddr2", (order.ShippingAddress2 + " " + order.ShippingSuite).Trim()); xmlTextWriter.WriteElementString("scity", order.ShippingCity); xmlTextWriter.WriteElementString("sstate", order.ShippingState); xmlTextWriter.WriteElementString("szip", order.ShippingZip); xmlTextWriter.WriteElementString("scountry", CustomOrder.ConvertCountryCode(order.ShippingCountry)); xmlTextWriter.WriteElementString("sphone", order.ShippingPhone); xmlTextWriter.WriteElementString("shipdesc", CustomOrder.ConvertShippingMethod(order.ShippingMethod)); xmlTextWriter.WriteElementString("comres", "R"); xmlTextWriter.WriteElementString("shipamt", order.OrderShippingCosts.ToString("F")); xmlTextWriter.WriteElementString("taxcode1", ""); xmlTextWriter.WriteElementString("taxcode2", ""); xmlTextWriter.WriteEndElement(); xmlTextWriter.WriteEndElement(); foreach (var item in items) { xmlTextWriter.WriteStartElement("items"); var extras = productExtras.Where(x => x.ProductID == item.ProductID && x.Color == item.ChosenColorSKUModifier); //get quantity and use as multiplier for extras var multiplier = item.Quantity; var color = item.ChosenColorSKUModifier == null ? "" : item.ChosenColorSKUModifier; var size = item.ChosenSizeSKUModifier == null ? "" : item.ChosenSizeSKUModifier; var itemno = item.OrderedProductSKU; if (!String.IsNullOrEmpty(color)) { itemno = itemno.Replace(color, ""); } if (!String.IsNullOrEmpty(size)) { itemno = itemno.Replace(size, ""); } var subno = size + color; xmlTextWriter.WriteStartElement("item"); xmlTextWriter.WriteElementString("rectype", "I"); xmlTextWriter.WriteElementString("ordno", order.OrderID.ToString()); xmlTextWriter.WriteElementString("webtrack", order.OrderID.ToString()); xmlTextWriter.WriteElementString("seqno", "1"); xmlTextWriter.WriteElementString("itemno", itemno); xmlTextWriter.WriteElementString("subno", subno); xmlTextWriter.WriteElementString("itemcustno", "0"); xmlTextWriter.WriteElementString("qtyord", item.Quantity.ToString()); xmlTextWriter.WriteElementString("taxable", ""); //xmlTextWriter.WriteElementString("itemprice", item.OrderedProductPrice.ToString("F")); xmlTextWriter.WriteElementString("itemprice", item.OrderedProductRegularPrice.ToString("F")); xmlTextWriter.WriteElementString("pointqty", "0.0000"); xmlTextWriter.WriteElementString("personalization", "N"); xmlTextWriter.WriteEndElement(); foreach (var extra in extras) { xmlTextWriter.WriteStartElement("item"); xmlTextWriter.WriteElementString("rectype", "I"); xmlTextWriter.WriteElementString("ordno", order.OrderID.ToString()); xmlTextWriter.WriteElementString("webtrack", order.OrderID.ToString()); xmlTextWriter.WriteElementString("seqno", "1"); xmlTextWriter.WriteElementString("itemno", extra.PartID.ToString()); xmlTextWriter.WriteElementString("subno", ""); xmlTextWriter.WriteElementString("itemcustno", "0"); xmlTextWriter.WriteElementString("qtyord", (extra.Quantity * multiplier).ToString()); xmlTextWriter.WriteElementString("taxable", ""); xmlTextWriter.WriteElementString("itemprice", "0.00"); xmlTextWriter.WriteElementString("pointqty", "0.0000"); xmlTextWriter.WriteElementString("personalization", "N"); xmlTextWriter.WriteEndElement(); } xmlTextWriter.WriteEndElement(); } //instructions xmlTextWriter.WriteStartElement("instructions"); xmlTextWriter.WriteElementString("rectype", "C"); xmlTextWriter.WriteElementString("ordno", order.OrderID.ToString()); xmlTextWriter.WriteElementString("webtrack", order.OrderID.ToString()); xmlTextWriter.WriteElementString("impinst", ""); xmlTextWriter.WriteElementString("spclinst", ""); xmlTextWriter.WriteEndElement(); //taxes xmlTextWriter.WriteStartElement("taxes"); xmlTextWriter.WriteStartElement("tax"); xmlTextWriter.WriteElementString("rectype", "T"); xmlTextWriter.WriteElementString("ordno", order.OrderID.ToString()); xmlTextWriter.WriteElementString("webtrack", order.OrderID.ToString()); xmlTextWriter.WriteElementString("taxcode", (order.TaxRate / 100).ToString()); xmlTextWriter.WriteElementString("taxrate", order.TaxRate.ToString()); xmlTextWriter.WriteEndElement(); xmlTextWriter.WriteEndElement(); xmlTextWriter.WriteEndElement(); } xmlTextWriter.WriteEndElement(); xmlTextWriter.WriteEndDocument(); var fileName = orderId.HasValue ? dateString + "." + orderId.Value.ToString() + ".xml" : "export.orders.all.xml"; //write to screen Response.Clear(); Response.ContentType = "text/xml"; Response.AppendHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\""); Response.Write(stringWriter.ToString().Replace("<?xml version=\"1.0\" encoding=\"utf-16\"?>", "<?xml version=\"1.0\"?>")); Response.End(); }
public void UpdateOrder(CustomOrder order) { }
public void OnErrRtnOrderCancel(CustomOrder order, string errorMsg) { var del = new HandleErrRtnOrderCancelDelegate(OnErrRtnOrderCancelInternal); this.BeginInvoke(del, new object[] { order, errorMsg }); }