Vehicle IVehicleProfile.GetVehicleProfileDetails(string country, string emirate, string plateCategory, string plateNumber, string plateCode) { try { AppProperties.isComprehensive = false; AppProperties.isSafety = true; handHeldService.HandHeldService service = new VSDApp.handHeldService.HandHeldService(); handHeldService.AuthHeader header = new VSDApp.handHeldService.AuthHeader(); header.password = AppProperties.empPassword; header.userName = AppProperties.empUserName; service.authHeader = header; handHeldService.VehiclePlate vehPlate = new VSDApp.handHeldService.VehiclePlate(); vehPlate.category = (plateCategory != "") ? plateCategory.Trim() : "NA"; vehPlate.code = (plateCode != "") ? plateCode.Trim() : "NA"; vehPlate.number = plateNumber.Trim(); vehPlate.source = ((IDBDataLoad)DBDataLoadManager.GetInstance()).GetPlateSourceCode((emirate == "") ? country : emirate).Trim(); if (AppProperties.vehicle == null) { AppProperties.vehicle = new Vehicle(); } AppProperties.vehicle.Country = country.Trim(); AppProperties.vehicle.Emirate = emirate.Trim(); AppProperties.vehicle.PlateCategory = vehPlate.category.Trim(); AppProperties.vehicle.PlateNumber = vehPlate.number.Trim(); AppProperties.vehicle.PlateCode = vehPlate.code.Trim(); handHeldService.InquireVehicleProfileResponseItem respItem = new VSDApp.handHeldService.InquireVehicleProfileResponseItem(); service.Timeout = 180000; respItem = service.inquireVehicleProfile("H-PS-IVP-1", vehPlate); if (respItem.response.code.Equals("1000")) { AppProperties.vehicle.ChassisNumber = respItem.vehicle.chassisNumber; AppProperties.vehicle.Year = respItem.vehicle.manufacturedYear; if (AppProperties.vehicle.Operator == null) { AppProperties.vehicle.Operator = new Operator(); } if (AppProperties.Selected_Resource == "English") { if (respItem.vehicle.manufacturer.name == null || respItem.vehicle.manufacturer.name == "") AppProperties.vehicle.Make = respItem.vehicle.manufacturer.nameArabic; else AppProperties.vehicle.Make = respItem.vehicle.manufacturer.name; if (respItem.vehicle.manufacturer.model == null || respItem.vehicle.manufacturer.model == "") AppProperties.vehicle.Model = respItem.vehicle.manufacturer.modelArabic; else AppProperties.vehicle.Model = respItem.vehicle.manufacturer.model; if (respItem.vehicle.owner.ownerName == null || respItem.vehicle.owner.ownerName == "") AppProperties.vehicle.Operator.OperatorName = respItem.vehicle.owner.ownerNameArabic; else AppProperties.vehicle.Operator.OperatorName = respItem.vehicle.owner.ownerName; } else { if (respItem.vehicle.manufacturer.name != null || respItem.vehicle.manufacturer.name != "") AppProperties.vehicle.Make = respItem.vehicle.manufacturer.nameArabic; else AppProperties.vehicle.Make = respItem.vehicle.manufacturer.name; if (respItem.vehicle.manufacturer.model != null || respItem.vehicle.manufacturer.model != "") AppProperties.vehicle.Model = respItem.vehicle.manufacturer.model; else AppProperties.vehicle.Model = respItem.vehicle.manufacturer.modelArabic; if (respItem.vehicle.owner.ownerName != null || respItem.vehicle.owner.ownerName != "") AppProperties.vehicle.Operator.OperatorName = respItem.vehicle.owner.ownerNameArabic; else AppProperties.vehicle.Operator.OperatorName = respItem.vehicle.owner.ownerName; } //AppProperties.vehicle.Operator.OperatorNameAr = respItem.vehicle.owner.ownerNameArabic; AppProperties.vehicle.Operator.TrafficFileNumber = respItem.vehicle.owner.trafficFileNumber; AppProperties.vehicle.PlateCategory = plateCategory; AppProperties.vehicle.PlateCode = plateCode; AppProperties.vehicle.PlateNumber = plateNumber; if (respItem.vehicle.category.code == null) { respItem.vehicle.category.code = "NA"; } AppProperties.vehicle.VehicleCategory = ((IDBDataLoad)DBDataLoadManager.GetInstance()).GetVehicleCategoryNameByCode(respItem.vehicle.category.code).Trim(); AppProperties.vehicle.VehicleCategoryAr = respItem.vehicle.category.nameArabic; AppProperties.vehicle.VehicleOVRRScore = (null != respItem.vehicle.riskRating) ? respItem.vehicle.riskRating.riskRatingName : ""; //AppProperties.vehicle.Recomendation = ((null != respItem.plateConfiscationInstruction) ? ((respItem.plateConfiscationInstruction.Equals("false", StringComparison.CurrentCultureIgnoreCase)) ? "" : Resources.GetInstance().GetString("Confiscate")) : ""); AppProperties.vehicle.Recomendation = ((null != respItem.plateConfiscationInstruction) ? ((respItem.plateConfiscationInstruction.Equals("false", StringComparison.CurrentCultureIgnoreCase)) ? "" : "Confiscate") : ""); AppProperties.vehicle.Instruction = (null != respItem.inspectionInstruction) ? respItem.inspectionInstruction : ""; if (null != respItem.violations) { Violation[] violations = new Violation[respItem.violations.Length]; for (int i = 0; i < respItem.violations.Length; i++) { violations[i] = new Violation(); violations[i].ConfiscationReason = respItem.violations[i].plateConfiscatedReason; violations[i].ConfiscationReasonAr = respItem.violations[i].plateConfiscatedReasonArabic; violations[i].Inspector = respItem.violations[i].inspectorName; violations[i].Inspection_location = respItem.violations[i].address; violations[i].Inspection_locationAr = respItem.violations[i].addressArabic; // violations[i].InspectionArea = respItem.violations[i].kloca; violations[i].IsConfiscated = (respItem.violations[i].isPlateConfiscated != null) ? true : false; violations[i].ViolationComments = respItem.violations[i].violation.comments; violations[i].ViolationCommentsAr = respItem.violations[i].violation.commentsArabic; violations[i].ViolationDueDays = respItem.violations[i].violation.dueDate; violations[i].ViolationIssueDate = respItem.violations[i].time; violations[i].ViolationID = (null == respItem.violations[i].violation.violationId) ? "0" : respItem.violations[i].violation.violationId.ToString(); violations[i].ViolationSeverity = respItem.violations[i].violation.severityLevel.name; violations[i].ViolationSeverityAr = respItem.violations[i].violation.severityLevel.nameArabic; //violations[i].ViolationSource = respItem.violations[i].violation.severityLevel.channel; violations[i].ViolationStatus = respItem.violations[i].violation.statusName; violations[i].ViolationTicketCode = respItem.violations[i].violation.ticketNumber; //Driver Lic No // violations[i]respItem.vehicle.driver.licenseNumber; violations[i].RtaEmpID = respItem.violations[i].inspectorEmployeeId; violations[i].DriverLicNo = respItem.violations[i].vehicle.driver.licenseNumber; if (null != respItem.violations[i].violation.testTypeName) { if (!AppProperties.isComprehensive) { AppProperties.isComprehensive = ((respItem.violations[i].violation.testTypeName.StartsWith("Comprehens", StringComparison.CurrentCultureIgnoreCase)) && !(violations[i].ViolationStatus.Equals("Closed", StringComparison.CurrentCultureIgnoreCase))) ? true : false; } } // if (Resources.GetInstance().GetLocale().Equals(Resources.locale_EN)) if (AppProperties.Selected_Resource == "English") { //checking if a major or severe violation already exists ((IDBManager)DBBusinessRuleManager.GetInstance()).GetRecommendation(violations[i].ViolationDueDays, violations[i].ViolationStatus, AppProperties.vehicle.Emirate, violations[i].ViolationSeverity); } else { //checking a major or severe violation already exists ((IDBManager)DBBusinessRuleManager.GetInstance()).GetRecommendation(violations[i].ViolationDueDays, violations[i].ViolationStatus, AppProperties.vehicle.Emirate, violations[i].ViolationSeverityAr); } if (respItem.violations[i].violation.defects.Length > 0) { Violation.Defects[] defects = new Violation.Defects[respItem.violations[i].violation.defects.Length]; for (int j = 0; j < defects.Length; j++) { int id; defects[j] = new Violation.Defects(); defects[j].DefectID = ((id = ((IDBDataLoad)DBDataLoadManager.GetInstance()).GetDefectIDByCode(respItem.violations[i].violation.defects[j].code)) != -1) ? id : 0; // string[][] cat = ((IDBDataLoad)DBDataLoadManager.GetInstance()).GetDefectMainCategory(); if (violations[i].ViolationStatus.StartsWith("Open", StringComparison.CurrentCultureIgnoreCase)) { AppProperties.previousDefectIDs.Add(defects[j].DefectID); } defects[j].DefectType = respItem.violations[i].violation.defects[j].type; defects[j].DefectName = ((IDBDataLoad)DBDataLoadManager.GetInstance()).GetDefectNameByID(respItem.violations[i].violation.defects[j].code); defects[j].DefectNameAr = ((IDBDataLoad)DBDataLoadManager.GetInstance()).GetDefectNameArByID(respItem.violations[i].violation.defects[j].code); defects[j].DefectCode = respItem.violations[i].violation.defects[j].code; defects[j].DefectValue = respItem.violations[i].violation.defects[j].comment; // defects[j].DefectCategory = respItem.violations[i].violation.defects[j].category; string[][] cat = ((IDBDataLoad)DBDataLoadManager.GetInstance()).GetDefectMainCategoryByID(defects[j].DefectCode.ToString()); if (cat.Length > 0) { defects[j].DefectCategory = cat[0][0].Trim(); } if (null != respItem.violations[i].violation.defects[j].vehicleCategories && respItem.violations[i].violation.defects[j].vehicleCategories.Length > 0) { defects[j].DefectSeverity = respItem.violations[i].violation.defects[j].vehicleCategories[0].defectSeverityLevel.name; defects[j].DefectSeverityAr = respItem.violations[i].violation.defects[j].vehicleCategories[0].defectSeverityLevel.nameArabic; } } violations[i].Defect = defects; } } AppProperties.vehicle.Violations = violations; } } else if (respItem.response.code.Equals("2000")) { AppProperties.businessError = true; AppProperties.errorMessageFromBusiness = respItem.response.message; } else { // System.Windows.Forms.MessageBox.Show(respItem.response.message); AppProperties.vehicle = null; return null; } } ////catch (NullReferenceException exNull) ////{ //// System.Windows.Forms.MessageBox.Show("Vehicle Info not found"); //// AppProperties.isOnline = false; //// return null; ////} catch (Exception e) { // CommonUtils.WriteLog(e.StackTrace); // System.Windows.Forms.MessageBox.Show(e.Message); // AppProperties.isOnline = false; AppProperties.IsException = true; return null; } return AppProperties.vehicle; }
Vehicle IViolationHistory.GetViolationHistoryByPlateNumber(string country, string emirate, string plateCategory, string plateNumber, string plateCode) { try { violationService.ViolationInformationServiceClient service = new violationService.ViolationInformationServiceClient(); //violationService.ViolationInformationService service = new violationService.ViolationInformationService(); // violationService.ViolationInformationService service = new violationService.ViolationBlockedService() violationService.Inspection[] inspection; violationService.AuthHeader header = new VSDApp.violationService.AuthHeader(); header.userName = AppProperties.empUserName; header.password = AppProperties.empPassword; // violationService. // service.authHeader = header; // service.Timeout = 180000; violationService.Response response = new VSDApp.violationService.Response(); violationService.VehiclePlate vehPlate = new violationService.VehiclePlate(); vehPlate.category = (plateCategory != "") ? plateCategory.Trim() : "NA"; vehPlate.code = (plateCode != "") ? plateCode.Trim() : "NA"; vehPlate.number = plateNumber.Trim(); vehPlate.source = ((IDBDataLoad)DBDataLoadManager.GetInstance()).GetPlateSourceCode((emirate == "") ? country : emirate).Trim(); //service.max // inspection = service.inquireViolationById("S-VI-IV-1", vioID, out response); inspection = service.inquireViolationByPlate(header, "S-VI-IV-1", vehPlate, out response); // service.inquireViolationByPlate(header,"", if (response.code.Equals("1000")) { // Resources res = Resources.GetInstance(); // bool isEng = (res.GetLocale().Equals(Resources.locale_EN)); bool isEng = true; AppProperties.vehicle = null; AppProperties.vehicle = new Vehicle(); AppProperties.vehicle.PlateCategory = inspection[0].vehicle.plateDetails.category; AppProperties.vehicle.PlateCode = inspection[0].vehicle.plateDetails.code; AppProperties.vehicle.Emirate = ((IDBDataLoad)DBDataLoadManager.GetInstance()).GetPlateEmirateByCode(inspection[0].vehicle.plateDetails.source).Trim(); AppProperties.vehicle.PlateNumber = inspection[0].vehicle.plateDetails.number; // AppProperties.vehicle.Country = inspection[0].vehicle.country; if (inspection[0].vehicle.country == null) AppProperties.vehicle.Country = country; else AppProperties.vehicle.Country = inspection[0].vehicle.country; AppProperties.vehicle.ChassisNumber = inspection[0].vehicle.chassisNumber; AppProperties.vehicle.Year = inspection[0].vehicle.manufacturedYear; if (AppProperties.vehicle.Operator == null) { AppProperties.vehicle.Operator = new Operator(); } if (AppProperties.Selected_Resource == "English") { if (inspection[0].vehicle.manufacturer.name == null || inspection[0].vehicle.manufacturer.name == "") AppProperties.vehicle.Make = inspection[0].vehicle.manufacturer.nameArabic; else AppProperties.vehicle.Make = inspection[0].vehicle.manufacturer.name; if (inspection[0].vehicle.manufacturer.model == null || inspection[0].vehicle.manufacturer.model == "") AppProperties.vehicle.Model = inspection[0].vehicle.manufacturer.modelArabic; else AppProperties.vehicle.Model = inspection[0].vehicle.manufacturer.model; if (inspection[0].vehicle.owner.ownerName == null || inspection[0].vehicle.owner.ownerName == "") AppProperties.vehicle.Operator.OperatorName = inspection[0].vehicle.owner.ownerNameArabic; else AppProperties.vehicle.Operator.OperatorName = inspection[0].vehicle.owner.ownerName; } else { if (inspection[0].vehicle.manufacturer.name != null || inspection[0].vehicle.manufacturer.name != "") AppProperties.vehicle.Make = inspection[0].vehicle.manufacturer.nameArabic; else AppProperties.vehicle.Make = inspection[0].vehicle.manufacturer.name; if (inspection[0].vehicle.manufacturer.model != null || inspection[0].vehicle.manufacturer.model != "") AppProperties.vehicle.Model = inspection[0].vehicle.manufacturer.model; else AppProperties.vehicle.Model = inspection[0].vehicle.manufacturer.modelArabic; if (inspection[0].vehicle.owner.ownerName != null || inspection[0].vehicle.owner.ownerName != "") AppProperties.vehicle.Operator.OperatorName = inspection[0].vehicle.owner.ownerNameArabic; else AppProperties.vehicle.Operator.OperatorName = inspection[0].vehicle.owner.ownerName; } // AppProperties.vehicle.Operator = new Operator(); AppProperties.vehicle.Operator.OperatorName = inspection[0].vehicle.owner.ownerName; AppProperties.vehicle.Operator.OperatorNameAr = inspection[0].vehicle.owner.ownerNameArabic; AppProperties.vehicle.Operator.TrafficFileNumber = inspection[0].vehicle.owner.trafficFileNumber; AppProperties.vehicle.VehicleOVRRScore = (null != inspection[0].vehicle.riskRating) ? inspection[0].vehicle.riskRating.riskRatingName : ""; //AppProperties.vehicle.Recomendation = ((null != respItem.plateConfiscationInstruction) ? ((respItem.plateConfiscationInstruction.Equals("false", StringComparison.CurrentCultureIgnoreCase)) ? "" : Resources.GetInstance().GetString("Confiscate")) : ""); // AppProperties.vehicle.Recomendation = ((null != inspection[0].plateConfiscationInstruction) ? ((inspection[0].plateConfiscationInstruction.Equals("false", StringComparison.CurrentCultureIgnoreCase)) ? "" : "Confiscate") : ""); // AppProperties.vehicle.Instruction = (null != inspection[0].inspectionInstruction) ? inspection[0].inspectionInstruction : ""; // Violation[] searchedViolation = new Violation[1]; if (null != inspection) { Violation[] searchedViolation = new Violation[inspection.Length]; for (int i = 0; i < inspection.Length; i++) { searchedViolation[i] = new Violation(); // searchedViolation[0] = new Violation(); searchedViolation[i].ViolationComments = inspection[i].violation.comments; searchedViolation[i].ViolationCommentsAr = inspection[i].violation.commentsArabic; searchedViolation[i].Inspection_location = inspection[i].locationName; searchedViolation[i].Inspection_locationAr = inspection[i].locationNameArabic; searchedViolation[i].ViolationDueDays = inspection[i].violation.dueDate; searchedViolation[i].ViolationIssueDate = inspection[i].time; searchedViolation[i].ViolationID = inspection[i].violation.ticketNumber; searchedViolation[i].ViolationTicketCode = inspection[i].violation.ticketNumber; searchedViolation[i].ViolationStatus = (isEng) ? inspection[i].violation.statusName : inspection[i].violation.statusNameArabic; searchedViolation[i].ViolationSeverity = inspection[i].violation.severityLevel.name; searchedViolation[i].ViolationSeverityAr = inspection[i].violation.severityLevel.nameArabic; searchedViolation[i].DriverLicNo = inspection[i].vehicle.driver.licenseNumber; searchedViolation[i].RtaEmpID = inspection[i].inspectorEmployeeId; Violation.Defects[] searchedDefects = new Violation.Defects[inspection[i].violation.defects.Length]; for (int j = 0; j < searchedDefects.Length; j++) { int id; searchedDefects[j] = new Violation.Defects(); searchedDefects[j].DefectID = ((id = ((IDBDataLoad)DBDataLoadManager.GetInstance()).GetDefectIDByCode(inspection[i].violation.defects[j].code)) != -1) ? id : 0; // searchedDefects[i].DefectName = ((IDBDataLoad)DBDataLoadManager.GetInstance()).GetDefectNameByID(inspection[0].violation.defects[i].code); searchedDefects[j].DefectName = ((IDBDataLoad)DBDataLoadManager.GetInstance()).GetDefectNameByID(inspection[i].violation.defects[j].code); searchedDefects[j].DefectNameAr = ((IDBDataLoad)DBDataLoadManager.GetInstance()).GetDefectNameArByID(inspection[i].violation.defects[j].code); searchedDefects[j].DefectCode = inspection[i].violation.defects[j].code; searchedDefects[j].DefectType = inspection[i].violation.defects[j].type; searchedDefects[j].DefectCategory = inspection[i].violation.defects[j].category; searchedDefects[j].DefectValue = inspection[i].violation.defects[j].comment; string[][] cat = ((IDBDataLoad)DBDataLoadManager.GetInstance()).GetDefectMainCategoryByID(searchedDefects[j].DefectCode.ToString()); if (cat.Length > 0) { searchedDefects[j].DefectCategory = cat[0][0].Trim(); } if (null != inspection[i].violation.defects[j].vehicleCategories && inspection[i].violation.defects[j].vehicleCategories.Length > 0) { searchedDefects[j].DefectSeverity = inspection[i].violation.defects[j].vehicleCategories[0].defectSeverityLevel.name; searchedDefects[j].DefectSeverityAr = inspection[i].violation.defects[j].vehicleCategories[0].defectSeverityLevel.nameArabic; } } searchedViolation[i].Defect = searchedDefects; AppProperties.vehicle.Violations = searchedViolation; } } } else if (response.code.Equals("2000")) { AppProperties.businessError = true; AppProperties.errorMessageFromBusiness = response.message; } else { AppProperties.NotFoundError = true; AppProperties.errorMessageFromBusiness = response.message; //System.Windows.Forms.MessageBox.Show(response.message); } } catch (Exception connectionEx) { // CommonUtils.WriteLog(connectionEx.StackTrace) AppProperties.IsException = true; AppProperties.errorMessageFromBusiness = connectionEx.InnerException.Message; // System.Windows.Forms.MessageBox.Show(connectionEx.Message); } return null; }
private void btnNext_Click_1(object sender, RoutedEventArgs e) { try { if (AppProperties.Selected_Resource == "English") { btnNextImage.Source = new BitmapImage(new Uri(@"/Images/Buttons/Small/Next.png", UriKind.Relative)); } else { btnNextImage.Source = new BitmapImage(new Uri(@"/Images/Buttons/Small/Next Arabic Up.png", UriKind.Relative)); } // if (cmboxIsPlateConfiscated.Text == "Yes") // { //if (MessageBox.Show("You want to submit violation ?", "Submit Violation", MessageBoxButton.YesNo) == MessageBoxResult.Yes) // { //this.m_mainWindow.MainContentControl.Content = null;// //this.m_mainWindow.MainContentControl.Content = new ucViolationSummary(this.m_mainWindow); //*************************************************************** //For Handling Defect Details on Next Button //******************************************************************* List<string[]> dataRows = AppProperties.selectedDefectsEn; if (null == AppProperties.recordedViolation) { AppProperties.recordedViolation = new Violation(); } Violation.Defects[] defects = new Violation.Defects[dataRows.Count]; int numberOfdays = 0; if (defects.Length > 0) { if (AppProperties.Selected_Resource == "Arabic") { _iValidate = (IValidation)new DriverInfoArValidation(); } else { _iValidate = (IValidation)new DriverInfoEnValidation(); } _validationResult = _iValidate.Validate(this); if (_validationResult != "Valid") { WPFMessageBox.Show(new CommonUtils().GetStringValue("DataValidation"), _validationResult); return; } for (int i = 0; i < defects.Length; i++) { string[] row = dataRows[i]; defects[i] = new Violation.Defects(); defects[i].DefectType = row[1].Trim(); defects[i].DefectName = row[4].Trim(); defects[i].DefectSeverity = row[5].Trim(); defects[i].DefectValue = row[7].Trim(); defects[i].DefectID = Int32.Parse(row[8].Trim()); if (defects[i].DefectType.Trim().Equals("Defect")) { AppProperties.isViolation = true; AppProperties.isSafety = false; } if (defects[i].DefectType.Trim().Equals("Defect") && !AppProperties.isViolation) { AppProperties.isSafety = false; } // AppProperties.recordedViolation.ViolationSeverity = ((IViolation)ViolationManager.GetInstance()).CalculateSeverity(AppProperties.recordedViolation.ViolationSeverity, row[5].Trim(), Resources.locale_EN); // AppProperties.recordedViolation.ViolationSeverityAr = ((IViolation)ViolationManager.GetInstance()).CalculateSeverity(AppProperties.recordedViolation.ViolationSeverityAr, row[6].Trim(), Resources.locale_AR); AppProperties.recordedViolation.ViolationSeverity = ((IViolation)ViolationManager.GetInstance()).CalculateSeverity(AppProperties.recordedViolation.ViolationSeverity, row[5].Trim(), ""); AppProperties.recordedViolation.ViolationSeverityAr = ((IViolation)ViolationManager.GetInstance()).CalculateSeverity(AppProperties.recordedViolation.ViolationSeverityAr, row[6].Trim(), ""); } AppProperties.recordedViolation.Defect = null; AppProperties.recordedViolation.Defect = defects; string[] info; //if (_resources.GetLocale().Equals(Resources.locale_EN)) //{ if (!AppProperties.isSafety) { info = ((IViolation)ViolationManager.GetInstance()).GetConfigurationDataForSeverity(AppProperties.recordedViolation.ViolationSeverity, defects.Length); } else { string[] calculation = ((IViolation)ViolationManager.GetInstance()).GetConfigurationDataForSeverity(AppProperties.recordedViolation.ViolationSeverity, defects.Length); if (calculation != null) { numberOfdays = Int32.Parse(calculation[0]); DateTime dt = DateTime.Now; AppProperties.recordedViolation.ViolationDueDays = dt.AddDays(numberOfdays); } //Confiscations Not Required // EnableDisableAddedDefectsOptions(false); // EnableConfiscateOptions(false); EnableDisableDriverInfoFields(false); SbmitViolation(); /* if (AppProperties.Selected_Resource == "English") MessageBox.Show("Safety Violation Submitted"); else MessageBox.Show("انتهاك سلامة نشره"); // SbmitViolation(); this.m_mainWindow.MainContentControl.Content = null; this.m_mainWindow.MainContentControl.Content = new ucLocationSelectionEn(this.m_mainWindow);*/ return; } //} //else //{ // info = ((IViolation)ViolationManager.GetInstance()).GetConfigurationDataForSeverity(AppProperties.recordedViolation.ViolationSeverityAr, defects.Length); //} if (null != info) { numberOfdays = Int32.Parse(info[0]); int numberOfVehServSuspDays = Int32.Parse(info[1]); int numberOfCompServSuspDays = Int32.Parse(info[2]); //if (AppProperties.recordedViolation.ViolationSeverity.Equals("Severe",StringComparison.CurrentCultureIgnoreCase)) //{ // AppProperties.confiscatePlates = true; //} DateTime currentDate = DateTime.Now; DateTime vehServSuspDays = currentDate; DateTime compServSuspDays = currentDate; if (info[3].Equals("T", StringComparison.CurrentCultureIgnoreCase) && Int32.Parse(info[6]) == 0) { AppProperties.confiscatePlates = true; } AppProperties.receiptTitle = info[4]; AppProperties.receiptTitleAr = info[5]; AppProperties.vehicle.VehicleSuspensionDate = vehServSuspDays.AddDays(numberOfVehServSuspDays); if (AppProperties.vehicle.Operator != null) AppProperties.vehicle.Operator.CompanySuspensionDate = compServSuspDays.AddDays(numberOfCompServSuspDays); // check if Emirate is null, don't go to confiscation screen IDBDataLoad iDataLoad = ((IDBDataLoad)DBDataLoadManager.GetInstance()); if (AppProperties.vehicle.Emirate == null || AppProperties.vehicle.Emirate == "") { iDataLoad.GetCountryProperties(AppProperties.vehicle.Country); } else { iDataLoad.GetCountryProperties(AppProperties.vehicle.Emirate); } if (!AppProperties.canConfiscatePlates) { AppProperties.confiscatePlates = false; } if (AppProperties.confiscatePlates) { DateTime dt = currentDate; AppProperties.recordedViolation.ViolationDueDays = dt.AddDays(numberOfdays); AppProperties.routeFromDefect = true; //Confiscate Option Enable EnableDisableDriverInfoFields(false); // EnableConfiscateOptions(true); // PopulateConfiscateOption(); // EnableDisableAddedDefectsOptions(false); // return; } else { DateTime dt = currentDate; AppProperties.recordedViolation.ViolationDueDays = dt.AddDays(numberOfdays); EnableDisableDriverInfoFields(false); // EnableConfiscateOptions(false); // PopulateConfiscateOption(); // EnableDisableAddedDefectsOptions(false); // RecordViolationConfirmationScreenEn RVConfirmation = new RecordViolationConfirmationScreenEn(); // _render.switchDisplay(form, RVConfirmation); // return; } } else { //throw custom exception to notify that no configuration data exists } SbmitViolation(); } else { //Its just an inspection if (AppProperties.Selected_Resource == "Arabic") { _iValidate = (IValidation)new DriverInfoArValidation(); } else { _iValidate = (IValidation)new DriverInfoEnValidation(); } _validationResult = _iValidate.Validate(this); if (_validationResult != "Valid") { WPFMessageBox.Show(new CommonUtils().GetStringValue("DataValidation"), _validationResult); return; } AppProperties.Is_SubmitVilation = false; if (WPFMessageBox.Show(new CommonUtils().GetStringValue("Confirmation"), new CommonUtils().GetStringValue("lblSubmitInspection"), WPFMessageBoxButtons.YesNo, WPFMessageBoxImage.Question) == WPFMessageBoxResult.Yes) { // ProgressDialogResult result = ProgressDialog.ProgressDialog.Execute(this.m_mainWindow, lblSubmitInspectionMessage.Content.ToString(), (bw, we) => // { // AppProperties.isOnline = ((IViolation)ViolationManager.GetInstance()).SubmitViolation(); // }); ProgressDialogResult result = ProgressDialog.ProgressDialog.Execute(this.m_mainWindow, new CommonUtils().GetStringValue("lblSubmitInspectionMessage"), (bw, we) => { AppProperties.isOnline = ((IViolation)ViolationManager.GetInstance()).SubmitViolation(); // So this check in order to avoid default processing after the Cancel button has been pressed. // This call will set the Cancelled flag on the result structure. ProgressDialog.ProgressDialog.CheckForPendingCancellation(bw, we); }, ProgressDialogSettings.WithSubLabelAndCancel); if (result.Cancelled) return; else if (result.OperationFailed) return; else { if (AppProperties.isInspectionUploaded) { if (AppProperties.Selected_Resource == "English") //System.Windows.MessageBox.Show("Inspection Uploaded"); WPFMessageBox.Show(new CommonUtils().GetStringValue("Confirmation"), "Inspection Uploaded"); else WPFMessageBox.Show(new CommonUtils().GetStringValue("Confirmation"), "تم تسجيل عملية التفتيش بنجاح"); } AppProperties.isInspectionUploaded = false; } // AppProperties.isOnline = ((IViolation)ViolationManager.GetInstance()).SubmitViolation(); if (AppProperties.businessError) { WPFMessageBox.Show(new CommonUtils().GetStringValue("DataValidation"), new CommonUtils().GetStringValue("ErrorBusiness")); AppProperties.businessError = false; } if (AppProperties.IsException) { WPFMessageBox.Show(new CommonUtils().GetStringValue("DataValidation"), new CommonUtils().GetStringValue("ErrorException")); AppProperties.IsException = false; return; } if (AppProperties.NotFoundError) { WPFMessageBox.Show(new CommonUtils().GetStringValue("DataValidation"), new CommonUtils().GetStringValue("ErrorNotFound")); AppProperties.NotFoundError = false; return; } AppProperties.recordedViolation = null; AppProperties.recordedViolation = new Violation(); AppProperties.recordedViolation.InspectionArea = AppProperties.location; AppProperties.vehicle = null; AppProperties.Total_Vehicle_Inspected = AppProperties.Total_Vehicle_Inspected + 1; if (AppProperties.Selected_Resource == "English") { if (AppProperties.Previous_Selected_LocationEn.Equals(AppProperties.Current_Selected_LocationEn)) { AppProperties.Selected_Location_Count = AppProperties.Selected_Location_Count + 1; AppProperties.Previous_Selected_LocationEn = AppProperties.Current_Selected_LocationEn; // AppProperties.Previous_Selected_AreaEn = AppProperties.Previous_Selected_AreaEn } else { AppProperties.Previous_Selected_LocationEn = AppProperties.Current_Selected_LocationEn; AppProperties.Selected_Location_Count = AppProperties.Selected_Location_Count + 1; // AppProperties.Previous_Selected_AreaEn = AppProperties.location.area; } } else { if (AppProperties.Previous_Selected_LocationAr.Equals(AppProperties.Current_Selected_LocationAr)) { AppProperties.Selected_Location_Count = AppProperties.Selected_Location_Count + 1; AppProperties.Previous_Selected_LocationAr = AppProperties.Current_Selected_LocationAr; // AppProperties.Previous_Selected_AreaAr = AppProperties.location.area; } else { AppProperties.Previous_Selected_LocationAr = AppProperties.Current_Selected_LocationAr; AppProperties.Selected_Location_Count = AppProperties.Selected_Location_Count + 1; // AppProperties.Previous_Selected_AreaAr = AppProperties.location.area; } } this.m_mainWindow.MainContentControl.Content = null; // this.m_mainWindow.MainContentControl.Content = new ucLocationSelectionEn(this.m_mainWindow); this.m_mainWindow.MainContentControl.Content = new ucLocationSelectionEn(this.m_mainWindow); return; } } //} //else //{ // System.Windows.Forms.MessageBox.Show("Select yes from the drop-down first"); //} // } // BtnNextDefectHandler(); } catch (Exception ex) { CommonUtils.WriteLog(ex.StackTrace); WPFMessageBox.Show(new CommonUtils().GetStringValue("Exception"), ex.Message, ex.StackTrace, WPFMessageBoxButtons.OK, WPFMessageBoxImage.Error); } }
Vehicle IViolationHistory.GetViolationHistoryByID(string vioID) { try { violationService.ViolationInformationServiceClient service = new violationService.ViolationInformationServiceClient(); //violationService.ViolationInformationService service = new violationService.ViolationInformationService(); // violationService.ViolationInformationService service = new violationService.ViolationBlockedService() violationService.Inspection[] inspection; violationService.AuthHeader header = new VSDApp.violationService.AuthHeader(); header.userName = AppProperties.empUserName; header.password = AppProperties.empPassword; // service.authHeader = header; // service.Timeout = 180000; violationService.Response response = new VSDApp.violationService.Response(); // inspection = service.inquireViolationById("S-VI-IV-1", vioID, out response); inspection = service.inquireViolationById(header, "S-VI-IV-1", vioID, out response); // service.inquireViolationByPlate( if (response.code.Equals("1000")) { // Resources res = Resources.GetInstance(); // bool isEng = (res.GetLocale().Equals(Resources.locale_EN)); bool isEng = true; AppProperties.vehicle = null; AppProperties.vehicle = new Vehicle(); AppProperties.vehicle.PlateCategory = inspection[0].vehicle.plateDetails.category; AppProperties.vehicle.PlateCode = inspection[0].vehicle.plateDetails.code; AppProperties.vehicle.Emirate = ((IDBDataLoad)DBDataLoadManager.GetInstance()).GetPlateEmirateByCode(inspection[0].vehicle.plateDetails.source).Trim(); AppProperties.vehicle.PlateNumber = inspection[0].vehicle.plateDetails.number; AppProperties.vehicle.Country = inspection[0].vehicle.country; AppProperties.vehicle.ChassisNumber = inspection[0].vehicle.chassisNumber; AppProperties.vehicle.Make = (isEng) ? inspection[0].vehicle.manufacturer.name : inspection[0].vehicle.manufacturer.nameArabic; AppProperties.vehicle.Model = (isEng) ? inspection[0].vehicle.manufacturer.model : inspection[0].vehicle.manufacturer.modelArabic; AppProperties.vehicle.Year = inspection[0].vehicle.manufacturedYear; AppProperties.vehicle.Operator = new Operator(); AppProperties.vehicle.Operator.OperatorName = inspection[0].vehicle.owner.ownerName; AppProperties.vehicle.Operator.OperatorNameAr = inspection[0].vehicle.owner.ownerNameArabic; AppProperties.vehicle.Operator.TrafficFileNumber = inspection[0].vehicle.owner.trafficFileNumber; Violation[] searchedViolation = new Violation[1]; searchedViolation[0] = new Violation(); searchedViolation[0].ViolationComments = inspection[0].violation.comments; searchedViolation[0].ViolationCommentsAr = inspection[0].violation.commentsArabic; searchedViolation[0].Inspection_location = inspection[0].locationName; searchedViolation[0].Inspection_locationAr = inspection[0].locationNameArabic; searchedViolation[0].ViolationDueDays = inspection[0].violation.dueDate; searchedViolation[0].ViolationIssueDate = inspection[0].time; searchedViolation[0].ViolationID = vioID; searchedViolation[0].ViolationTicketCode = vioID; searchedViolation[0].ViolationStatus = (isEng) ? inspection[0].violation.statusName : inspection[0].violation.statusNameArabic; searchedViolation[0].ViolationSeverity = inspection[0].violation.severityLevel.name; searchedViolation[0].ViolationSeverityAr = inspection[0].violation.severityLevel.nameArabic; searchedViolation[0].DriverLicNo = inspection[0].vehicle.driver.licenseNumber; searchedViolation[0].RtaEmpID = inspection[0].inspectorEmployeeId; Violation.Defects[] searchedDefects = new Violation.Defects[inspection[0].violation.defects.Length]; for (int i = 0; i < searchedDefects.Length; i++) { int id; searchedDefects[i] = new Violation.Defects(); searchedDefects[i].DefectID = ((id = ((IDBDataLoad)DBDataLoadManager.GetInstance()).GetDefectIDByCode(inspection[0].violation.defects[i].code)) != -1) ? id : 0; // searchedDefects[i].DefectName = ((IDBDataLoad)DBDataLoadManager.GetInstance()).GetDefectNameByID(inspection[0].violation.defects[i].code); searchedDefects[i].DefectName = ((IDBDataLoad)DBDataLoadManager.GetInstance()).GetDefectNameByID(inspection[0].violation.defects[i].code); searchedDefects[i].DefectNameAr = ((IDBDataLoad)DBDataLoadManager.GetInstance()).GetDefectNameArByID(inspection[0].violation.defects[i].code); searchedDefects[i].DefectCode = inspection[0].violation.defects[i].code; searchedDefects[i].DefectType = inspection[0].violation.defects[i].type; searchedDefects[i].DefectCategory = inspection[0].violation.defects[i].category; searchedDefects[i].DefectValue = inspection[0].violation.defects[i].comment; string[][] cat = ((IDBDataLoad)DBDataLoadManager.GetInstance()).GetDefectMainCategoryByID(searchedDefects[i].DefectCode.ToString()); if (cat.Length > 0) { searchedDefects[i].DefectCategory = cat[0][0].Trim(); } if (null != inspection[0].violation.defects[i].vehicleCategories && inspection[0].violation.defects[i].vehicleCategories.Length > 0) { searchedDefects[i].DefectSeverity = inspection[0].violation.defects[i].vehicleCategories[0].defectSeverityLevel.name; searchedDefects[i].DefectSeverityAr = inspection[0].violation.defects[i].vehicleCategories[0].defectSeverityLevel.name; } } searchedViolation[0].Defect = searchedDefects; AppProperties.vehicle.Violations = searchedViolation; } else if (response.code.Equals("2000")) { AppProperties.businessError = true; AppProperties.errorMessageFromBusiness = response.message; } else { AppProperties.NotFoundError = true; AppProperties.errorMessageFromBusiness = response.message; // System.Windows.Forms.MessageBox.Show(response.message); } } catch (Exception connectionEx) { CommonUtils.WriteLog(connectionEx.StackTrace); // System.Windows.Forms.MessageBox.Show(connectionEx.Message); AppProperties.IsException = true; AppProperties.errorMessageFromBusiness = connectionEx.InnerException.Message; } return null; }