public void ProcessHouseHoldingRun() { HouseHoldingRunData houseHoldingRunData = _houseHoldingFileRepository.GetHouseHoldingData(); var houseHoldingRun = new HouseHoldingRun { Grid = houseHoldingRunData.Grid, StartDate = houseHoldingRunData.StartDate, EndDate = houseHoldingRunData.EndDate }; _houseHoldingRunRepository.Create(houseHoldingRun); foreach (var grid in houseHoldingRunData.ProcessingGridRun) { var gridRun = _gridRunService.GetGridRun(grid); _gridRunService.Update(gridRun.Id, gridRun.StartDate, gridRun.EndDate, gridRun.Status, gridRun.XmlFileId, houseHoldingRun.Id); } foreach (var documentData in houseHoldingRunData.DocumentRunData) { var document = _documentService.GetDocument(documentData.DocumentId); var houseHold = new HouseHold() { HouseHoldDate = DateTime.Now, DocumentId = document.Id }; _houseHoldRepository.Create(houseHold); _documentService.Update(document.Id, houseHoldingRun.Id); } }
public HouseHoldingRunData GetHouseHoldingData() { var houseHoldingRun = new HouseHoldingRunData(); int count = 1; foreach (var file in Entities) { string[] csvLines = File.ReadAllLines(file.FullName); var lines = (from l in csvLines let data = l.Split(',') select new Row { ColumnOne = data[0], ColumnTwo = data[1], ColumnThree = data[2] }).ToList(); foreach (var row in lines) { if (count == 1) { houseHoldingRun.Grid = row.ColumnOne; houseHoldingRun.StartDate = Convert.ToDateTime(row.ColumnTwo); houseHoldingRun.EndDate = Convert.ToDateTime(row.ColumnThree); } else { houseHoldingRun.DocumentRunData.Add(new DocumentRunData { DocumentId = row.ColumnTwo, HouseHoldDate = Convert.ToDateTime(row.ColumnThree) }); if (!houseHoldingRun.ProcessingGridRun.Contains(row.ColumnOne)) { houseHoldingRun.ProcessingGridRun.Add(row.ColumnOne); } } count++; } } return(houseHoldingRun); }