public void CreateXMLScenario(CSVScenarioFilePath cSVScenarioFilePath) { XmlDocument doc = new XmlDocument(); XmlDeclaration xmlDeclaration = doc.CreateXmlDeclaration("1.0", "UTF-8", null); XmlElement root = doc.CreateElement(LoadData.XMLMainCategories.dataset.ToString()); doc.InsertBefore(xmlDeclaration, doc.DocumentElement); doc.AppendChild(root); doc = InitDataParser.InitDataCSVToXML(doc, cSVScenarioFilePath.InitData); doc = ToolTypeParser.ToolTypeCSVToXML(doc, cSVScenarioFilePath.ToolTypeList); doc = ProductParser.ProductClassCSVToXML(doc, cSVScenarioFilePath.ProductsList); doc = WarehouseInitInventoryParser.WarehouseInitInventoryCSVToXML(doc, cSVScenarioFilePath.WarehouseInitInventory); doc = SuppliersParser.SuppliersCSVToXML(doc, cSVScenarioFilePath.SuppliersList); doc = OrderParser.OrderCSVToXML(doc, cSVScenarioFilePath.CustomersOrderList, XMLMainCategories.CustomersOrderList); doc = OrderParser.OrderCSVToXML(doc, cSVScenarioFilePath.FutureCustomersOrderList, XMLMainCategories.FutureCustomersOrderList); doc = OrderParser.OrderCSVToXML(doc, cSVScenarioFilePath.SuppliersOrderList, XMLMainCategories.SuppliersOrderList); FileManager fileManager = new FileManager(); string fileResultpath = fileManager.saveFilePathXML(); if (!string.IsNullOrEmpty(fileResultpath)) { using (var writer = new XmlTextWriter(fileResultpath, Encoding.UTF8) { Formatting = Formatting.Indented }) { doc.WriteTo(writer); } } }
public InitDataLoad LoadInitData(string filePath) { InitDataLoad initDataLoad = new InitDataLoad(); XmlDocument xmldoc = getXmldoc(filePath); XmlNodeList initNodeList = getXmlNodeList(xmldoc, XMLMainCategories.InitData); XmlNodeList productsNodeList = getXmlNodeList(xmldoc, XMLMainCategories.ProductsList); XmlNodeList suppliersNodeList = getXmlNodeList(xmldoc, XMLMainCategories.SuppliersList); XmlNodeList customerOrderNodeList = getXmlNodeList(xmldoc, XMLMainCategories.CustomersOrderList); XmlNodeList fucureCustomerOrderNodeList = getXmlNodeList(xmldoc, XMLMainCategories.FutureCustomersOrderList); XmlNodeList supploersOrderNodeList = getXmlNodeList(xmldoc, XMLMainCategories.SuppliersOrderList); XmlNodeList WarehouseInitInventoryNodeList = getXmlNodeList(xmldoc, XMLMainCategories.WarehouseInitInventory); XmlNodeList tooltypeyNodeList = getXmlNodeList(xmldoc, XMLMainCategories.ToolTypeList); initDataLoad.InitParameters = InitDataParser.Parse(initNodeList); initDataLoad.MetaData.ToolTypeMetaData = ToolTypeParser.parse(tooltypeyNodeList); initDataLoad.MetaData.ProductsMetaData = ProductParser.Parse(productsNodeList, initDataLoad); initDataLoad.MetaData.SuppliersMetaData = SuppliersParser.Parse(suppliersNodeList, initDataLoad); initDataLoad.InitLists.InitCustomersOrderList = OrderParser.Parse(customerOrderNodeList, initDataLoad, Order.OrderTypeEnum.CustomerOrder); initDataLoad.InitLists.InitFutureCustomersOrderList = OrderParser.Parse(fucureCustomerOrderNodeList, initDataLoad, Order.OrderTypeEnum.CustomerOrder); initDataLoad.InitLists.InitPurchaseOrders = OrderParser.Parse(supploersOrderNodeList, initDataLoad, Order.OrderTypeEnum.SupplierOrder); initDataLoad.InitParameters.InitWarehouseInventory = WarehouseInitInventoryParser.Parse(WarehouseInitInventoryNodeList, initDataLoad); ///rebuild parser initDataLoad.InitLists.InitToolsList = loadTool(initDataLoad); initDataLoad.InitLists.InitProductionOrderList = generateProductionOrderList(initDataLoad); //// return(initDataLoad); }
protected void UploadButton_Click(object sender, EventArgs e) { var path = @"C:\Temp\Upload"; if (FileUpload.HasFile) { var filename = FileUpload.FileName; path += filename; FileUpload.SaveAs(path); UploadStatusLabel.Text = "File saved as " + filename; var reader = new XmlReader(); string orderXml = reader.Read(path); var parser = new OrderParser(); var orderItems = parser.Parse(orderXml); GridView.DataSource = new List <Order>(orderItems); GridView.DataBind(); } else { UploadStatusLabel.Text = "You did not specify a file to upload."; } }
Initialize(DependencyResolver container) { var parser = new OrderParser(container.Resolve <IOrderRepository>()); parser.DoWork(); }
private OrderBusinessModel OrderModelBllToOrderModelContract(BusinessLogic.BusinessModels.OrderModel from) { return(new OrderBusinessModel { PurchasedSeats = from.PurchasedSeats?.Select(x => SeatModelBllToSeatModelContract(x)).ToList(), Order = OrderParser.ToOrderContract(from.Order) }); }
public void Parse_RecordIsReturned() { // Given OrderParser orderParser = new OrderParser(); // When List <Order> orders = orderParser.Parse(new List <string>() { "123,2020-08-17,100" }); // Then orders.Count.Should().Be(1); orders[0].Amount.Should().Be(100); orders[0].DateSubmitted.Should().Be(DateTime.Parse("2020-08-17")); orders[0].OrderId.Should().Be(123); }
public void SetUp() { OrderParser = new OrderParser(); XmlTest1 = "<orders>" + "<order>" + "<customer>" + "<title>Mr</title>" + "<firstname>Canabrana</firstname>" + "<lastname>Lammer</lastname>" + "</customer>" + "<orderitem>" + "<id>26</id>" + "<journal>Splinter Removal Weekly</journal>" + "<start>2009-01-01</start>" + "<currency>GBP</currency>" + "</orderitem>" + "</order>" + "</orders>"; }
public void CanParseSimpleFile() { const string filePath = FILE_PATH_BASE + "orders.txt"; var orders = new OrderParser(filePath).Parse(); Assert.Equal(5, orders.Count); var expectedOrders = new[] { new Order { Id = 181, CreationDate = Convert.ToDateTime("2019-01-08T14:07:53Z"), ItemId = 5432, CustomerId = 1002, NumberItemInOrder = 12, SingleItemPrice = 25.67m }, new Order { Id = 182, CreationDate = Convert.ToDateTime("2019-01-08T15:53:11Z"), ItemId = 6987, CustomerId = 1003, NumberItemInOrder = 110, SingleItemPrice = 0.99m, Comment = "Nice!" }, new Order { Id = 183, CreationDate = Convert.ToDateTime("2019-01-09T02:11:07Z"), ItemId = 4569, CustomerId = 1005, NumberItemInOrder = 1, SingleItemPrice = 9m }, new Order { Id = 184, CreationDate = Convert.ToDateTime("2019-01-09T21:54:45Z"), ItemId = 5432, CustomerId = 1001, NumberItemInOrder = 1, SingleItemPrice = 25.75m, Comment = "Well done, good service." }, new Order { Id = 185, CreationDate = Convert.ToDateTime("2019-01-10T11:45:29Z"), ItemId = 965, CustomerId = 1002, NumberItemInOrder = 10, SingleItemPrice = 101.99m, Comment = "good" }, }; for (var index = 0; index < orders.Count; index++) { var order = orders[index]; var expectedOrder = expectedOrders[index]; Assert.Equal(expectedOrder.Id, order.Id); Assert.Equal(expectedOrder.CreationDate, order.CreationDate); Assert.Equal(expectedOrder.ItemId, order.ItemId); Assert.Equal(expectedOrder.CustomerId, order.CustomerId); Assert.Equal(expectedOrder.NumberItemInOrder, order.NumberItemInOrder); Assert.Equal(expectedOrder.SingleItemPrice, order.SingleItemPrice); Assert.Equal(expectedOrder.Comment, order.Comment); } }
public Form1() { InitializeComponent(); InitializeDropdownsAndSettings(); InitializeAPI(); InitializeSymbolInfromation(); OrdersOnlineSubject orderSubject = new OrdersOnlineSubject(); orderDTO = new OrdersOnlineDTO(orderSubject); OrderParser orderParser = new OrderParser(orderDTO); BSocket socket = new BSocket(orderParser); System.Threading.Thread thread1 = new Thread(socket.HearthBeat); OrdersOnlineSubscriber sb = new OrdersOnlineSubscriber(SocketGetOrders); SocketGetOrders.DataSource = orderDTO.orderList; candleRetriever = CandleRetriever.Instance; bot = new Bot(orderDTO); orderSubject.Subscribe(sb); orderSubject.Subscribe(bot); thread1.Start(); //Action hearthbeat = () => BSocket.Hearthbeat(); // Task task = Task.Run(hearthbeat); }
protected void loadData() { string currentFilter ; if (IsPostBack == false) { Session["ord_filter"] = ""; currentFilter = ""; } else currentFilter = (string)Session["ord_filter"]; //this.scriptLb.Text = currentFilter; OrderParser newParser = new OrderParser(); this._dataModel = new OrderModel (this.gvOrders, @".\SQL2008", 1433, "TSQLFundamentals2008","sa", "123456", "Sales.Orders", "Sales.OrderDetails", newParser); newParser.DataModel = this._dataModel; try { this._dataModel.resetControl(currentFilter); //if (this.IsPostBack == false) // this.loadEmpIDS(); } catch(Exception ex) { Session["current_error"] = ex.Message; Response.Redirect("serverError.aspx"); } custList = new List<object>(); empList = new List<object>(); shipperList = new List<object>(); custList.Add(""); empList.Add(""); shipperList.Add(""); custList.AddRange(_dataModel.getIDItemList("Sales.Customers", 0, 1, "").ToArray()); empList.AddRange(_dataModel.getIDItemList("HR.Employees", 0, 1, " jobStatus=1").ToArray()); shipperList.AddRange(_dataModel.getIDItemList("Sales.Shippers", 0, 1, " deactive=0").ToArray()); if (IsPostBack == false) { this.cbCustID.DataSource = custList; this.cbEmpID.DataSource = empList; this.cbShipper.DataSource = shipperList; cbCustID.DataBind(); cbEmpID.DataBind(); cbShipper.DataBind(); } }
private static void PrintParsedBeverage(Beverage beverage) { string decription = OrderParser.parse(beverage.Description); Console.WriteLine(decription + ": £" + $"{beverage.Cost():F2}"); }
static void Main(string[] args) { /* * This is the engine for a begin style space battle. You write commands (or on phone pick actions) and each turn those commands (and those of the bad guys) are executed. * * parts: * * reactors provide power * shields provide protection * guns shoot * engines move * crewDecks provide repairs ( i guess crew would be the hit points here?) * * TODO: * Sensors scan * Transporters Beam * * * * Commands to implement: * Report * fire * helm * load * unload * destruct * lock * status * * TODo: How should parts consume power? * I guess there are two ways.... an upkeep step and a per use charge.. * for example, shields need some power just to keep running... but they need lots of power to regenerate * and crew decks need some power to keep the lights and life support on.. but they need more to do repairs * and engines would use energy proportional to their throttle... but not much when idle * guns would probably not use power unless shooting. * reactors provide power, of course.... if we anted to model them after fusion reactors, we could make them require some power as well, but that's going to far. :>) * * Right now we have an upkeep power requirement... if you consume too much power, you don't have enough energy to do per-use things * for example, shields won't charge if there isn't enough power. For now, that's the only problem. Needs more fleshing out though. * * Weapons need more work. Accuracy on some weapons should fall off with distance, damage with distance for others. * Projectile weapons also need to be implemented. Also, the concept of loading. * Also, firing with a specific weapon. * * TODO: Status effects on ships and shipparts * for example, reimplement destroyed as a status, and create derelict status for dead but functional ships. * * Idea: what about a "repulser drive" aka antigravity... it would counteract the effects of gravits so that gravity scanners wouldn't detect a ship.... but it would * need to disable the engines... otherwise you could travel light speed immididiately... * * */ setConsoleSize(); var radarPanel = Window.Open(1, 1, 25, 15, "Radar", LineThickNess.Single, ConsoleColor.Green, ConsoleColor.Black); radarPanel.WriteLine("Radar"); var ScanPanel = Window.Open(27, 1, 95, 9, "Scanner", LineThickNess.Single, ConsoleColor.Yellow, ConsoleColor.Black); var StatusPanel = Window.Open(27, 8, 95, 9, "Status", LineThickNess.Single, ConsoleColor.Yellow, ConsoleColor.Black); output = Window.Open(1, 16, 60, 24, "Output", LineThickNess.Double, ConsoleColor.White, ConsoleColor.Black); var input = new Window(1, 40, 60, 1, ConsoleColor.DarkGray, ConsoleColor.DarkMagenta); var shipList = Window.Open(62, 16, 60, 24, "Ships In Range", LineThickNess.Single, ConsoleColor.Cyan, ConsoleColor.Black); var game = new GameEngine(); game.FlavourTextEventHandler += OnFlavourText; game.ViewEventHandler += OnViewEvent; var startingEntities = new List <Ship>(). Concat(ReadTeamFromFile(1)). Concat(ReadTeamFromFile(2)). Concat(ReadTeamFromFile(3)). Concat(ReadTeamFromFile(4)). Concat(ReadTeamFromFile(5)). Concat(ReadTeamFromFile(6)). Concat(ReadTeamFromFile(7)). Concat(ReadTeamFromFile(8)). ToList(); flagship = startingEntities.First(X => X.Team == 0); game.StartNewGame(flagship, startingEntities, 1000); UpdateDisplay(scannedShip, flagship, game.Entities, ScanPanel, StatusPanel, radarPanel, shipList); while (!game.IsGameFinished()) { input.Clear(); input.WriteLine(ConsoleColor.Green, "Your orders, Sir?"); Console.SetCursorPosition(20, 40); var order = OrderParser.ParseOrder(Console.ReadLine(), game.Entities.Where(entity => entity is IDamageableEntity).Select(entity => entity as IDamageableEntity).ToList()); AlterViewForOrder(order); if (order.Type == Order.OrderType.SCAN || order.Type == Order.OrderType.STATUS) // scanning doesn't cost a turn. { UpdateDisplay(scannedShip, flagship, game.Entities, ScanPanel, StatusPanel, radarPanel, shipList); continue; } OnFlavourText(game, new FlavourTextEventArgs() { name = "debug", level = FlavourTextEventArgs.LEVEL_DEBUG, message = $"Starting Round {game.CurrentRound}", team = -1 }); game.RunOneRound(order); flagship = game.Flagship; UpdateDisplay(scannedShip, flagship, game.Entities, ScanPanel, StatusPanel, radarPanel, shipList); } if (game.GetWhichTeamWon() == -1) { output.WriteLine("It was a tie!"); } else { output.WriteLine("Team " + game.GetWhichTeamWon() + " Won!!"); } while (Console.ReadKey().Key != ConsoleKey.Escape) { } }
public OrderParsingRunner(OrderParser orderParser) { this.orderParser = orderParser; }
public BSocket(OrderParser _orderParser) { orderParser = _orderParser; }