private void ExecuteLookupLoad() { ShowInputError = false; //TODO VALIDATE TICKET LOAD NUMBER EXISTS if (string.IsNullOrEmpty(GinTicketLoadNumber)) { ShowInputError = true; InputErrorMessage = "Please enter a gin ticket load number."; } else { using (var dp = SimpleIoc.Default.GetInstance <IUnitOfWorkFactory>().CreateUnitOfWork()) { if (!dp.LoadScanRepository.FindMatching(m => m.GinTagLoadNumber == GinTicketLoadNumber).Any()) { ShowInputError = true; InputErrorMessage = "Load not found."; } } } if (!ShowInputError) { var vm = new LoadViewModel(NavService); NavService.ShowPage(PageType.LOAD_PAGE, false, (BasePageViewModel)vm); vm.Initialize(GinTicketLoadNumber.Trim().TrimStart('0'), false, true); } }
private void ExecuteOpenCommand() { var vm = new LoadViewModel(NavService); NavService.ShowPage(PageType.LOAD_PAGE, true, (BasePageViewModel)vm); vm.Initialize(SelectedItem.GinTicketLoadNumber, false, true, true, SelectedItem.Id); }
private void ExecuteLookupLoad() { try { if (_loadCreated) { return; } _canceled = true; timer.Stop(); autoSaveTimer.Stop(); Logging.Logger.Log("INFO", "Entering ExecuteLookupLoad"); //lock (_dataLocker) //{ bool newLoad = false; if (string.IsNullOrWhiteSpace(GinTicketLoadNumber)) { HasLookupError = true; return; } else { HasLookupError = false; } Logging.Logger.Log("INFO", "CREATE LOAD FROM LOAD LOOKUP"); if (!_loadCreated) { CreateLoad(ref newLoad); } TagDataProvider.SetGPOState(1, false); TagDataProvider.SetGPOState(2, false); TagDataProvider.SetGPOState(3, false); var vm = new LoadViewModel(NavService); NavService.ShowPage(PageType.LOAD_PAGE, false, (BasePageViewModel)vm); vm.Initialize(GinTicketLoadNumber, newLoad); //} } catch (Exception exc) { Logging.Logger.Log(exc); Logging.Logger.WriteBuffer(); } }
private void ExecuteCopyLoad() { ShowInputError = false; //TODO VALIDATE TICKET LOAD NUMBER EXISTS if (string.IsNullOrEmpty(GinTicketLoadNumber)) { ShowInputError = true; InputErrorMessage = "Please enter a gin ticket load number."; } else { using (var dp = SimpleIoc.Default.GetInstance <IUnitOfWorkFactory>().CreateUnitOfWork()) { if (!dp.LoadScanRepository.FindMatching(m => m.GinTagLoadNumber == GinTicketLoadNumber).Any()) { ShowInputError = true; InputErrorMessage = "Load not found."; } } } if (!ShowInputError) { using (var dp = SimpleIoc.Default.GetInstance <IUnitOfWorkFactory>().CreateUnitOfWork()) { dp.LoadScanRepository.DisableChangeTracking(); var existingLoad = dp.LoadScanRepository.FindSingle(l => l.GinTagLoadNumber == GinTicketLoadNumber); existingLoad.Id = Guid.NewGuid().ToString(); existingLoad.BridgeLoadNumber = dp.LoadScanRepository.LastLoadNumber() + 1; existingLoad.GinTagLoadNumber = GinTicketLoadNumber + "COPY"; existingLoad.Created = DateTime.UtcNow; existingLoad.Updated = null; dp.LoadScanRepository.Add(existingLoad); dp.SaveChanges(); var vm = new LoadViewModel(NavService); NavService.ShowPage(PageType.LOAD_PAGE, false, (BasePageViewModel)vm); vm.Initialize(existingLoad.GinTagLoadNumber.Trim().TrimStart('0'), false, true); } } }
private void ExecuteCreateLoad() { ShowInputError = false; //TODO VALIDATE TICKET LOAD NUMBER EXISTS if (string.IsNullOrEmpty(GinTicketLoadNumber)) { ShowInputError = true; InputErrorMessage = "Please enter a gin ticket load number."; } if (!ShowInputError) { using (var dp = SimpleIoc.Default.GetInstance <IUnitOfWorkFactory>().CreateUnitOfWork()) { var hasLoad = dp.LoadScanRepository.FindMatching(x => x.GinTagLoadNumber == GinTicketLoadNumber).Any(); if (hasLoad) { this.ExecuteLookupLoad(); return; } var bridgeID = dp.SettingsRepository.GetSettingWithDefault(BridgeSettingKeys.BRIDGE_ID, ""); var lastLoadScan = new LoadScanEntity(); lastLoadScan.SubmittedBy = "attendant"; //always use a new load number otherwise a previous load //could get overwritten lastLoadScan.BridgeLoadNumber = dp.LoadScanRepository.LastLoadNumber() + 1; var scanData = new ModuleScanData(); scanData.Scans = new List <LoadModuleScan>(); lastLoadScan.SetSerializedModuleScanData(scanData); lastLoadScan.BridgeID = bridgeID; lastLoadScan.TruckID = ""; lastLoadScan.GinTagLoadNumber = GinTicketLoadNumber; lastLoadScan.GrossWeight = 0.00M; lastLoadScan.NetWeight = 0.00M; lastLoadScan.SplitWeight1 = 0.00M; lastLoadScan.SplitWeight2 = 0.00M; lastLoadScan.Latitude = dp.SettingsRepository.GetSettingDoubleValue(BridgeSettingKeys.LATITUDE); lastLoadScan.Longitude = dp.SettingsRepository.GetSettingDoubleValue(BridgeSettingKeys.LONGITUDE); lastLoadScan.TrailerNumber = ""; lastLoadScan.Variety = ""; lastLoadScan.YardRow = "IN FIELD"; lastLoadScan.PickedBy = ""; lastLoadScan.Client = ""; lastLoadScan.Farm = ""; lastLoadScan.Field = ""; var status = dp.SettingsRepository.GetSettingWithDefault(BridgeSettingKeys.TARGET_STATUS, "AT GIN"); if (status == "AT GIN") { lastLoadScan.TargetStatus = ModuleStatus.AT_GIN; } else { lastLoadScan.TargetStatus = ModuleStatus.ON_FEEDER; } lastLoadScan.SubmittedBy = "attendant"; //lastLoadScan.SetSerializedModuleScanData(scanData); dp.LoadScanRepository.Save(lastLoadScan); dp.SaveChanges(); var vm = new LoadViewModel(NavService); NavService.ShowPage(PageType.LOAD_PAGE, false, (BasePageViewModel)vm); vm.Initialize(GinTicketLoadNumber, false, true); } } }