static void Main(string[] args) { XmlSerializer deserializer = new XmlSerializer(typeof(ProductionReport)); using (FileStream fileStream = new FileStream(@"D:\Projekty_Wakacje\ExportXMLtoCSV\ExportXMLtoCSV\ExportXMLtoCSV\ProductionResults.xml", FileMode.Open)) { ProductionReport result = (ProductionReport)deserializer.Deserialize(fileStream); SerializedCars serializedCars = new SerializedCars(); serializedCars.Manufacturer = result.Manufacturer; serializedCars.Date = result.Date; foreach (Factory factory in result.Factories) { foreach (Car car in factory.Cars) { serializedCars.Cars.Add(car); } } XmlSerializer serializer = new XmlSerializer(typeof(SerializedCars)); var textWriter = new StreamWriter(@"D:\Projekty_Wakacje\ExportXMLtoCSV\ExportXMLtoCSV\ExportXMLtoCSV\config.xml"); serializer.Serialize(textWriter, serializedCars); textWriter.Close(); var reportDate = result.Date.Replace(':', ';'); var reportName = $@"D:\Projekty_Wakacje\ExportXMLtoCSV\ExportXMLtoCSV\ExportXMLtoCSV\{result.Manufacturer}_{reportDate.Substring(0,19)}.csv"; XslCompiledTransform transform = new XslCompiledTransform(); transform.Load(@"D:\Projekty_Wakacje\ExportXMLtoCSV\ExportXMLtoCSV\ExportXMLtoCSV\TransformToCsv.xslt"); transform.Transform(@"D:\Projekty_Wakacje\ExportXMLtoCSV\ExportXMLtoCSV\ExportXMLtoCSV\config.xml", reportName); } }
public async Task <IActionResult> Edit(int id, [Bind("ID,BidCost,EstCost,TotalCost,ActualMtlCost,EstMtlCost,ActualLabourProdCost,EstLabourProdCost,ActualDesignCost,EstDesignCost,ProjectID")] ProductionReport productionReport) { if (id != productionReport.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(productionReport); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductionReportExists(productionReport.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ProjectID"] = new SelectList(_context.Projects, "ID", "Desc", productionReport.ProjectID); return(View(productionReport)); }
public async Task <bool> Post(ProductionReport productionReport) { if (productionReport?.ReportPictures.Count == 0) { return(false); } using (var db = Connection) { const string sql = @"INSERT INTO ProductionReports(Date, ItemName, ItemNumber, OrderId, TimeCode) VALUES(@Date, @ItemName, @ItemNumber, @OrderId, @TimeCode) SELECT CAST(SCOPE_IDENTITY() as int)"; const string picturesSql = @"INSERT INTO ReportPictures(SectionName, PictureUrl ,ReportId) VALUES(@SectionName, @PictureUrl, @ReportId)"; var id = await db.QuerySingleAsync <int>(sql, new { productionReport.Date, ItemName = productionReport.ItemName, ItemNumber = productionReport.ItemNumber, OrderId = productionReport.OrderId, TimeCode = productionReport.TimeCode }).ConfigureAwait(false); var results = new List <int>(); foreach (var item in productionReport.ReportPictures) { var result = await db.ExecuteAsync(picturesSql, new { SectionName = item.SectionName, PictureUrl = item.PictureUrl, ReportId = id }).ConfigureAwait(false); results.Add(result); } return(results.All(x => x == 1)); } }
public void introducingToListTest() { ProductionReport report = new ProductionReport() { Factories = new Factories() { Factory = new Factory() { ProducedCars = new ProducedCars() { Car = new List <Car>() { } } } } }; int count = 1; report.Factories.Factory.ProducedCars.Car.Add(new Car("XXXX", "YYYY", "MMMM")); SerializationClass serialization = new SerializationClass(); List <Car> list = serialization.introducingToList(count, report); Assert.AreEqual(list[0].Model, report.Factories.Factory.ProducedCars.Car[0].Model); Assert.AreEqual(list[0].Vin, report.Factories.Factory.ProducedCars.Car[0].Vin); Assert.AreEqual(list[0].ProductionYear, report.Factories.Factory.ProducedCars.Car[0].ProductionYear); }
public RegFile(Building build, Rect dimOnMap, Ca category, Vector3 iniPosition, Inventory InventoryP, List <string> peopleDict, List <VectorLand> LandZone1, Rect dimOnMapHor = new Rect(), List <Vector3> tilePosVert = null, List <Vector3> tilePosHor = null, List <Vector3> planesOnAirPos = null, Vector3 tileScale = new Vector3(), List <int> partsOnAir = null, H dominantSide = H.None, H startingStage = H.None, int rotationFacerIndex = -1, string materialKey = "", List <Vector3> planesOnSoilPos = null, List <int> partsOnSoil = null, Vector3 min = new Vector3(), Vector3 max = new Vector3(), H instructionP = H.None, BookedHome bookedHome = null, Dispatch dispatch = null, Family[] familes = null, int dollarsPay = 0, List <Vector3> anchors = null, Dock dock = null, string root = "", BuildersManager buildersManager = null ) { MyId = build.MyId; HType = build.HType; _dimOnMap = dimOnMap; Category = category; _iniPos = iniPosition; _dimOnMapHor = dimOnMapHor; _tilePosVert = tilePosVert; _tilePosHor = tilePosHor; _tileScale = tileScale; //bridge stuff _partsOnAir = partsOnAir; _dominantSide = dominantSide; _planeOnAirPos = planesOnAirPos; _planesOnSoil = planesOnSoilPos; _partsOnSoil = partsOnSoil; _startingStage = startingStage; _rotationFacerIndex = rotationFacerIndex; _materialKey = materialKey; _min = min; _max = max; Instruction = instructionP; Inventory = InventoryP; PeopleDict = peopleDict; this.LandZone1 = LandZone1; BookedHome1 = bookedHome; Dispatch1 = dispatch; Familes = familes; DollarsPay = dollarsPay; Anchors = anchors.ToArray(); Dock1 = dock; Root = root; ProductionReport = build.ProductionReport; MaxPeople = build.MaxPeople; Decoration = build.Decoration1; Name = build.NameBuilding(); BuildersManager = buildersManager; }
internal void AddToExpirationThisYear(P p, float amt) { if (_expirationReport == null) { _expirationReport = new ProductionReport(); } _expirationReport.AddProductionThisYear(p, amt); }
internal void AddConsumeThisYear(P p, float amt) { if (_productionReport == null) { _productionReport = new ProductionReport(); } _productionReport.AddConsumeThisYear(p, amt); }
public void DeserializeProductionReport_EqualObjects_ReturnTrue() { string reportXML = "TestFiles/SampleProductionResults.xml"; ProductionReport productionReport = CreateSampleProductionReport(); ProductionReport deserializedProductionReport = ProductionReport.DeserializeProductionReport(reportXML); Assert.True(productionReport.Equals(deserializedProductionReport)); }
public ReportingController() { _db = new DistilDBContext(); _dl = new DataLayer(_db); _productionR = new ProductionReport(_db, _dl); _processingR = new ProcessingReport(_db, _dl); _storageR = new StorageReport(_db, _dl); _reportRepository = new ReportRepository(_db, _dl); }
public void DeserializeProductionReport_NotEqualObjects_ReturnFalse() { string reportXML = "TestFiles/SampleProductionResults.xml"; ProductionReport productionReport = CreateSampleProductionReport(); productionReport.Manufacturer = "Auudi"; ProductionReport deserializedProductionReport = ProductionReport.DeserializeProductionReport(reportXML); Assert.False(productionReport.Equals(deserializedProductionReport)); }
public async Task <byte[]> GeneratePdfReport(ProductionReport productionReport) { var pdf = await _reportingService.RenderByNameAsync("ProductionReport", productionReport).ConfigureAwait(false); using (var ms = new MemoryStream()) { await pdf.Content.CopyToAsync(ms).ConfigureAwait(false); return(ms.ToArray()); } }
public void CarSerialize_EqualOutput_ReturnTrue() { string fileName = Path.Combine(AppContext.BaseDirectory.Substring(0, AppContext.BaseDirectory.IndexOf("bin")), "TestFiles/SampleCars.xml"); string expectedCars = File.ReadAllText(fileName); ProductionReport productionReport = CreateSampleProductionReport(); List <Car> cars = productionReport.GetProducedCarsList(); string serializedCars = Car.Serialize(cars, " ", false); Assert.Equal(serializedCars, expectedCars); }
public async Task <IActionResult> Create([Bind("ID,BidCost,EstCost,TotalCost,ActualMtlCost,EstMtlCost,ActualLabourProdCost,EstLabourProdCost,ActualDesignCost,EstDesignCost,ProjectID")] ProductionReport productionReport) { if (ModelState.IsValid) { _context.Add(productionReport); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ProjectID"] = new SelectList(_context.Projects, "ID", "Desc", productionReport.ProjectID); return(View(productionReport)); }
public async Task UpdateReport(ProductionReport report) { if (report == null) { return; } var sql = $@" UPDATE ProductionReports SET {nameof(ProductionReport.Date)} = @{nameof(ProductionReport.Date)}, {nameof(ProductionReport.ItemName)} = @{nameof(ProductionReport.ItemName)}, {nameof(ProductionReport.ItemNumber)} = @{nameof(ProductionReport.ItemNumber)}, {nameof(ProductionReport.TimeCode)} = @{nameof(ProductionReport.TimeCode)} WHERE {nameof(ProductionReport.Id)} = @{nameof(ProductionReport.Id)}"; using (var db = Connection) { await db.ExecuteAsync(sql, new { Date = report.Date, ItemName = report.ItemName, ItemNumber = report.ItemNumber, TimeCode = report.TimeCode, Id = report.Id }).ConfigureAwait(false); } }
static void Main(string[] args) { const string XML_FILE = "BmwOriginal.xml"; XmlSerializationHelper xmlSerializerHelper = new XmlSerializationHelper(); ProductionReport deserializedObject = xmlSerializerHelper.DeserializeXml(XML_FILE); foreach (var items in deserializedObject.Factories.Factory.ProducedCars.Car) { Console.WriteLine($"\n{items.VIN}\n"); foreach (var item in items.Features.Feature) { Console.WriteLine($"{item.Code} + {item.Text}"); } } xmlSerializerHelper.SerializeObject(deserializedObject.Factories.Factory.ProducedCars); CsvHelper csvHelper = new CsvHelper(); csvHelper.TransformToCsv("serializedXml.xml"); using (StreamReader sr = new StreamReader("output.csv")) { Console.WriteLine("\n\n Csv file opening ...\n\n"); sr.ReadLine(); string csvLine; while ((csvLine = sr.ReadLine()) != null) { Console.WriteLine(csvLine); } } Console.ReadLine(); }
private ProductionReport CreateSampleProductionReport() { List <Feature> firstCarFeatures = new List <Feature> { new Feature("SZW", "Sportowe zawieszenie"), new Feature("SZD", "Szyberdach") }; List <Feature> secondCarFeatures = new List <Feature> { new Feature("ASB", "Automatyczna skrzynia biegow") }; List <Car> cars = new List <Car> { new Car("321ZAYC024", "2017", "TT", firstCarFeatures), new Car("YC024321ZA", "2018", "A4", secondCarFeatures) }; List <Factory> factories = new List <Factory> { new Factory("Neckersulm Fab", cars) }; ProductionReport productionReport = new ProductionReport("Audi", "2017-14-13T12:32:02.8036669+01:00", factories); return(productionReport); }
public async Task <bool> PostReport(ProductionReport productionReport) { return(await _reportsRepo.Post(productionReport).ConfigureAwait(false)); }