public IActionResult SaveOrder() { var sessionusername = (int)HttpContext.Session.GetInt32("UserId"); var defaultAddress = AddressHelper.GetAddressByDefaultId(); var defaultPayment = PaymentHelper.GetPaymentByDefaultId(); var defaultUser = UserHelper.GetUserInfoById(sessionusername); dm.Orders user = new dm.Orders { User = defaultUser }; var getProduct = JsonConvert.DeserializeObject <List <OrderAndPaymentViewModel> >(HttpContext.Session.GetString("ProductTime")); List <dm.Orders> finalOrderModel = new List <dm.Orders>(); string guid = System.Guid.NewGuid().ToString(); foreach (var item in getProduct) { var model = new ConversionOrder(); finalOrderModel.Add(model.MappingOrders(item)); } foreach (var item in finalOrderModel) { var currentListing = ListingHelper.GetListingInfoByIdForOrder(item); item.OrderGroupNumber = guid; item.ShippingStatus = "Pending"; //item.Timestamp = GetTimestamp(DateTime.Now); item.User = defaultUser; item.Payment = defaultPayment; item.Payment.User = defaultUser; item.Listing = currentListing; item.Listing.User = defaultUser; item.Listing.ProductInfo = currentListing.ProductInfo; item.Listing.ProductInfo.Brand = currentListing.ProductInfo.Brand; item.Listing.ProductInfo.Type = currentListing.ProductInfo.Type; } foreach (var item in finalOrderModel) { var result = OrderHelper.AddOrderById(item); ListOfProducts.RemoveAll(p => p.ProductInfoId > 0); //if (result) //{ // ListingHelper.UpdateQuantityById(item.Listing); //} } return(RedirectToAction("Account", "Home")); }
public IActionResult OrderHistory() { var sessionusername = HttpContext.Session.GetString("Username"); ViewBag.Username = sessionusername; var AddressUsed = AddressHelper.GetAddressByDefaultId(); var sessionuserid = (int)HttpContext.Session.GetInt32("UserId"); var OrderList = OrderHelper.GetAllOrdersById(sessionuserid); ConversionOrder viewOrder = new ConversionOrder(); List <OrderAndPaymentViewModel> model = viewOrder.MappingView(OrderList); return(View("~/Views/User/OrderHistory.cshtml", model)); }
public void MakePdf(string inputHtmlPath, string outputPdfPath, string paperSizeName, bool landscape, Control owner, BackgroundWorker worker, DoWorkEventArgs doWorkEventArgs) { ConversionProgress progress = null; try { var tempOutput = TempFile.WithExtension(".pdf"); //we don't want to dispose of this (since we will move it) File.Delete(tempOutput.Path); var conversionOrder = new ConversionOrder() { BottomMarginInMillimeters = 0, TopMarginInMillimeters = 0, LeftMarginInMillimeters = 0, RightMarginInMillimeters = 0, EnableGraphite = true, Landscape = landscape, InputHtmlPath = inputHtmlPath, OutputPdfPath = tempOutput.Path, PageSizeName = paperSizeName }; using (var waitHandle = new AutoResetEvent(false)) { var mainThreadTask = (Action)(() => { progress = new ConversionProgress(conversionOrder); progress.Finished += (sender, args) => { if (!File.Exists(tempOutput.Path)) { throw new ApplicationException( string.Format("Bloom was not able to create the PDF.{0}{0}" + "Details: GeckofxHtmlToPdf (command line) did not produce the expected document.", Environment.NewLine)); } try { File.Move(tempOutput.Path, outputPdfPath); waitHandle.Set(); } catch (IOException e) { //I can't figure out how it happened (since GetPdfPath makes sure the file name is unique), //but we had a report (BL-211) of that move failing. throw new ApplicationException( string.Format( "Bloom tried to save the file to {0}, but Windows said that it was locked. Please try again.{2}{2}Details: {1}", outputPdfPath, e.Message, Environment.NewLine)); } }; progress.Show(owner); }); if (owner == null) // typically tests; should be the main UI thread. { mainThreadTask(); } else { owner.Invoke(mainThreadTask); } while (true) { // The background thread can't actually do any work...all happens in the gecko // component on the UI thread...but it must wait until we're done. if (waitHandle.WaitOne(100)) { break; // background thread signaled that it is finished } if (progress != null && worker != null && worker.CancellationPending) { owner.Invoke((Action)(progress.Cancel)); doWorkEventArgs.Cancel = true; break; } } } } finally { if (progress != null) { progress.Dispose(); } } }
/// <summary> /// handles conversions between how control bindings are displayed versus how mednafen stores them in its config file /// </summary> /// <param name="input"></param> /// <param name="conversionOrder"></param> /// <returns></returns> public static string ConvertText(string input, ConversionOrder conversionOrder) { // create the output string string output = input; switch (conversionOrder) { // Text is being loaded FROM mednafen config case ConversionOrder.Load: if (input.StartsWith("keyboard ")) { // keyboard binding output = KeyboardTranslation.SDLCodetoDx(input, KeyboardType.UK); } if (input.StartsWith("mouse ")) { // mouse binding if (input.Contains("mouse 0000000000000000 00000000")) { output = "LeftMouseButton"; } if (input.Contains("mouse 0000000000000000 00000001")) { output = "MiddleMouseButton"; } if (input.Contains("mouse 0000000000000000 00000002")) { output = "RightMouseButton"; } if (input.Contains("mouse 0000000000000000 00000003")) { output = "MouseScrollWheelUp"; } if (input.Contains("mouse 0000000000000000 00000004")) { output = "MouseScrollWheelDown"; } if (input.Contains("mouse 0000000000000000 00000005")) { output = "MouseButton3"; } if (input.Contains("mouse 0000000000000000 00000006")) { output = "MouseButton4"; } if (input.Contains("mouse 0000000000000000 00000007")) { output = "MouseButton5"; } if (input.Contains("mouse 0000000000000000 00008000")) { output = "MouseX-Axis"; } if (input.Contains("mouse 0000000000000000 00008001")) { output = "MouseY-Axis"; } } if (input.StartsWith("joystick ")) { // joystick binding - not currently used } break; // Text is being saved TO mednafen config case ConversionOrder.Save: if (input == "LeftMouseButton") { output = "mouse 0000000000000000 00000000"; return(output); } if (input == "MiddleMouseButton") { output = "mouse 0000000000000000 00000001"; return(output); } if (input == "RightMouseButton") { output = "mouse 0000000000000000 00000002"; return(output); } if (input == "MouseScrollWheelUp") { output = "mouse 0000000000000000 00000003"; return(output); } if (input == "MouseScrollWheelDown") { output = "mouse 0000000000000000 00000004"; return(output); } if (input == "MouseButton3") { output = "mouse 0000000000000000 00000005"; return(output); } if (input == "MouseButton4") { output = "mouse 0000000000000000 00000006"; return(output); } if (input == "MouseButton5") { output = "mouse 0000000000000000 00000007"; return(output); } if (input == "MouseX-Axis") { output = "mouse 0000000000000000 00008000"; return(output); } if (input == "MouseY-Axis") { output = "mouse 0000000000000000 00008001"; return(output); } if (!input.StartsWith("mouse ") && !input.StartsWith("joystick ")) { // assume keyboard output = KeyboardTranslation.DXtoSDLCode(input, KeyboardType.UK); } break; } return(output); }