public RecipeReportViewModel() { Report = new StiReport(); _batchTasks = new ObservableCollection <BatchTask>(); _selectedTask = new BatchTask(); DateFrom = DateTime.Now.Date; DateTo = DateTime.Now.Date.AddDays(1); }
private void FindTasks() { if (_batchTasks == null) { _batchTasks = new ObservableCollection <BatchTask>(); } else { _batchTasks.Clear(); } using DbRbuContext db = new DbRbuContext(); foreach (var report in db.Reports.Where(x => x.StartDt >= DateTimeFrom && x.FinishDt <= DateTimeTo).Include(t => t.Task).Include(r => r.Task.Recipe).Include(c => c.Task.Customer).Include(rg => rg.Task.Recipe.Group)) { BatchTask batchTask = new BatchTask() { TaskId = report.TaskId.Value, RecipeId = report.Task.RecipeId.Value, RecipeName = report.Task.Recipe.Name, RecipeGroup = (report.Task != null && report.Task.Recipe != null && report.Task.Recipe.Group != null) ? report.Task.Recipe.Group.Name : "не указана", CustomerId = report.Task.CustomerId, Customer = report.Task.CustomerId != null ? report.Task.Customer.Name : "не указан", Volume = report.Task.Volume, BatchesCount = report.Task.BatchesAmount, BatchVolume = report.Task.BatchVolume, ReportId = report.Id, StartTime = report.StartDt, FinishTime = report.FinishDt }; batchTask.Description = $"Зад. №{batchTask.TaskId} {batchTask.StartTime}: {batchTask.RecipeName} ({batchTask.Volume} м3: {batchTask.BatchesCount} x {batchTask.BatchVolume} м3)"; _batchTasks.Add(batchTask); } }