/// <summary> /// Opens a window for a new record /// </summary> private void ShowNewRecordDialog() { var viewModel = new NewRecordDialogViewModel(); bool?result = dialogService.ShowDialog(viewModel); if (result.HasValue && result.Value) { NewRecordSimulation = new NewRecordSimulation(BulkFile, viewModel.NewPerson); NextStepMessage = "Kliknite sledeći korak radi početka simulacije"; Messages.Enqueue("Uspešno ste pokrenuli simulaciju unosa novog sloga"); } }
/// <summary> /// Performs a next step in active simulation /// </summary> private void NextStep() { if (NewRecordSimulation != null) { bool result = NewRecordSimulation.NextStep(); NextStepMessage = NewRecordSimulation.Message; MemoryRecordControls.Clear(); MemoryVisibility = Visibility.Visible; MemoryBucketControlViewModel = null; MemoryBucketVisibility = Visibility.Visible; if (NewRecordSimulation.KeyTransformation != -1 && !NewRecordSimulation.OverrunZone) { MemoryBucketControlViewModel = new BucketControlViewModel(BulkFile.PrimaryZone[NewRecordSimulation.KeyTransformation]); if (NewRecordSimulation.Column != -1) { MemoryBucketControlViewModel.RecordControlViewModels.ElementAt(NewRecordSimulation.Column).Select(); } } else if (NewRecordSimulation.Column != -1) { MemoryRecordControls.Add(new RecordControlViewModel() { Record = BulkFile.OverrunZone[NewRecordSimulation.Column] }); MemoryBucketVisibility = Visibility.Collapsed; } else { MemoryVisibility = Visibility.Collapsed; } if (NewRecordSimulation.Changed) { if (!NewRecordSimulation.OverrunZone) { PrimaryZoneControlViewModel.BucketControlViewModels.ElementAt(NewRecordSimulation.KeyTransformation).RecordControlViewModels.ElementAt(NewRecordSimulation.Column).ResetColor(); } else { PrimaryZoneControlViewModel.BucketControlViewModels.ElementAt(NewRecordSimulation.KeyTransformation).OverrunedRecords++; OverrunZoneRecordControls.ElementAt(NewRecordSimulation.Column).ResetColor(); OverrunZoneRecordControls.ElementAt(NewRecordSimulation.Column).Visibility = Visibility.Visible; OverrunZoneVisibility = Visibility.Visible; } } if (result == false) { NewRecordSimulation = null; MemoryRecordControls.Clear(); MemoryVisibility = Visibility.Collapsed; } } else if (EditRecordSimulation != null) { bool result = EditRecordSimulation.NextStep(); NextStepMessage = EditRecordSimulation.Message; MemoryRecordControls.Clear(); MemoryVisibility = Visibility.Visible; MemoryBucketControlViewModel = null; MemoryBucketVisibility = Visibility.Visible; if (EditRecordSimulation.Row != -1 && !EditRecordSimulation.OverrunZone) { MemoryBucketControlViewModel = new BucketControlViewModel(BulkFile.PrimaryZone[EditRecordSimulation.Row]); if (EditRecordSimulation.Column != -1) { MemoryBucketControlViewModel.RecordControlViewModels.ElementAt(EditRecordSimulation.Column).Select(); } } else if (EditRecordSimulation.Column != -1) { MemoryRecordControls.Add(new RecordControlViewModel() { Record = BulkFile.OverrunZone[EditRecordSimulation.Column] }); MemoryBucketVisibility = Visibility.Collapsed; } else { MemoryVisibility = Visibility.Collapsed; } if (result == false) { EditRecordSimulation = null; MemoryRecordControls.Clear(); MemoryVisibility = Visibility.Collapsed; } } else if (DeleteRecordSimulation != null) { bool oldDeletedInPrimary = DeleteRecordSimulation.DeletedInPrimary; bool oldDeleted = DeleteRecordSimulation.Deleted; bool result = DeleteRecordSimulation.NextStep(); NextStepMessage = DeleteRecordSimulation.Message; MemoryVisibility = Visibility.Visible; MemoryBucketVisibility = Visibility.Visible; MemoryRecordControls.Clear(); if (DeleteRecordSimulation.KeyTransformation != -1) { if (!DeleteRecordSimulation.OverrunZone) { MemoryBucketControlViewModel = new BucketControlViewModel(PrimaryZoneControlViewModel.BucketControlViewModels.ElementAt(DeleteRecordSimulation.KeyTransformation)); } else { if (DeleteRecordSimulation.DeletedInPrimary || oldDeletedInPrimary != DeleteRecordSimulation.DeletedInPrimary) { MemoryBucketControlViewModel = new BucketControlViewModel(PrimaryZoneControlViewModel.BucketControlViewModels.ElementAt(DeleteRecordSimulation.KeyTransformation)); if (DeleteRecordSimulation.Column != -1) { MemoryRecordControls.Add(new RecordControlViewModel() { Record = OverrunZoneRecordControls.ElementAt(DeleteRecordSimulation.Column).Record, }); } } else if (DeleteRecordSimulation.DeletedInOverrun) { if (DeleteRecordSimulation.Column != -1 && DeleteRecordSimulation.Column != BulkFile.NumberOfRecordsInOverrunZone) { MemoryRecordControls.Add(new RecordControlViewModel() { Record = OverrunZoneRecordControls.ElementAt(DeleteRecordSimulation.Column).Record, }); if (!oldDeletedInPrimary && oldDeleted == DeleteRecordSimulation.Deleted) { MemoryRecordControls.Add(new RecordControlViewModel() { Record = OverrunZoneRecordControls.ElementAt(DeleteRecordSimulation.Column - 1).Record, }); } MemoryBucketVisibility = Visibility.Collapsed; MemoryBucketControlViewModel = null; } } else { if (DeleteRecordSimulation.Column != -1) { MemoryRecordControls.Add(new RecordControlViewModel() { Record = OverrunZoneRecordControls.ElementAt(DeleteRecordSimulation.Column).Record, }); } MemoryBucketVisibility = Visibility.Collapsed; MemoryBucketControlViewModel = null; } } if (MemoryBucketControlViewModel != null) { if (!DeleteRecordSimulation.OverrunZone) { if (!DeleteRecordSimulation.Deleted || oldDeleted != DeleteRecordSimulation.Deleted) { if (DeleteRecordSimulation.Column != -1) { MemoryBucketControlViewModel.RecordControlViewModels.ElementAt(DeleteRecordSimulation.Column).Select(); } } else if (oldDeleted == DeleteRecordSimulation.Deleted) { MemoryBucketControlViewModel.RecordControlViewModels.ElementAt(DeleteRecordSimulation.Column - 1).Select(); MemoryBucketControlViewModel.RecordControlViewModels.ElementAt(DeleteRecordSimulation.Column).Select(); } } else { MemoryBucketControlViewModel.RecordControlViewModels.ElementAt(BulkFile.Factor - 1).Select(); } } else if (DeleteRecordSimulation.DeletedInPrimary) { MemoryBucketControlViewModel.RecordControlViewModels.ElementAt(BulkFile.Factor - 1).Select(); } foreach (RecordControlViewModel record in MemoryRecordControls) { record.Select(); } } if (DeleteRecordSimulation.Changed) { //MemoryZoneControlViewModel.BucketControlViewModels.First().RecordControlViewModels.ElementAt(DeleteRecordSimulation.Column).ResetColor(); if (!DeleteRecordSimulation.OverrunZone) { if (DeleteRecordSimulation.Logical) { PrimaryZoneControlViewModel.BucketControlViewModels.ElementAt(DeleteRecordSimulation.KeyTransformation).RecordControlViewModels.ElementAt(DeleteRecordSimulation.Column).ResetColor(); } else { if (DeleteRecordSimulation.Column != 0) { PrimaryZoneControlViewModel.BucketControlViewModels.ElementAt(DeleteRecordSimulation.KeyTransformation).RecordControlViewModels.ElementAt(DeleteRecordSimulation.Column - 1).ResetColor(); } PrimaryZoneControlViewModel.BucketControlViewModels.ElementAt(DeleteRecordSimulation.KeyTransformation).RecordControlViewModels.ElementAt(DeleteRecordSimulation.Column).ResetColor(); } } else { if (DeleteRecordSimulation.Logical) { OverrunZoneRecordControls.ElementAt(DeleteRecordSimulation.Column).ResetColor(); } else { if (MemoryBucketControlViewModel != null) { PrimaryZoneControlViewModel.BucketControlViewModels.ElementAt(DeleteRecordSimulation.KeyTransformation).RecordControlViewModels.ElementAt(BulkFile.Factor - 1).ResetColor(); } else { if (DeleteRecordSimulation.Column == BulkFile.NumberOfRecordsInOverrunZone && DeleteRecordSimulation.Deleted) { OverrunZoneRecordControls.ElementAt(DeleteRecordSimulation.Column - 1).ResetColor(); OverrunZoneRecordControls.ElementAt(DeleteRecordSimulation.Column - 1).Visibility = Visibility.Hidden; if (OverrunZoneRecordControls.Count == 0) { OverrunZoneVisibility = Visibility.Hidden; } } else { if (DeleteRecordSimulation.Column == BulkFile.NumberOfRecordsInOverrunZone) { OverrunZoneRecordControls.ElementAt(DeleteRecordSimulation.Column).ResetColor(); } OverrunZoneRecordControls.ElementAt(DeleteRecordSimulation.Column - 1).ResetColor(); MemoryBucketVisibility = Visibility.Collapsed; if (OverrunZoneRecordControls.ElementAt(DeleteRecordSimulation.Column - 1).Record.Status == Status.empty) { OverrunZoneRecordControls.ElementAt(DeleteRecordSimulation.Column - 1).Visibility = Visibility.Collapsed; MemoryVisibility = Visibility.Collapsed; } } } } } } if (MemoryBucketControlViewModel == null) { MemoryBucketVisibility = Visibility.Collapsed; } if (result == false) { if (!result) { DeleteRecordSimulation = null; } MemoryBucketControlViewModel = null; MemoryBucketVisibility = Visibility.Collapsed; MemoryVisibility = Visibility.Collapsed; MemoryRecordControls.Clear(); for (int i = 0; i < BulkFile.NumberOfBuckets; i++) { PrimaryZoneControlViewModel.BucketControlViewModels.ElementAt(i).OverrunedRecords = BulkFile.PrimaryZone[i].OverrunedRecords; } } } else { throw new Exception(); } #endregion #endregion }