bool IViolation.SubmitViolation() { IDBDataLoad iDataLoad = ((IDBDataLoad)DBDataLoadManager.GetInstance()); try { handHeldService.SubmitViolationResponseItem respItem = new VSDApp.handHeldService.SubmitViolationResponseItem(); handHeldService.Inspection inspection = new VSDApp.handHeldService.Inspection(); handHeldService.AuthHeader header = new VSDApp.handHeldService.AuthHeader(); inspection.time = System.DateTime.Now; inspection.timeSpecified = true; AppProperties.recordedViolation.ViolationIssueDate = inspection.time; string adr = iDataLoad.GetLocationCode(AppProperties.recordedViolation.InspectionArea.city, AppProperties.recordedViolation.InspectionArea.area, AppProperties.recordedViolation.InspectionArea.location); //Dubai,Deira,Dafza if (adr == "") { // string adr = iDataLoad.GetLocationCode(AppProperties.de, AppProperties.recordedViolation.InspectionArea.area, AppProperties.recordedViolation.InspectionArea.location); } inspection.address = (adr != null) ? adr : "247.00012"; // inspection.channelPartInspectionCode = "01"; Regex regExp = new Regex("[A-Za-z0-9]*"); bool isEng = regExp.IsMatch(AppProperties.empUserName); if (isEng) { header.userName = AppProperties.empUserName; header.password = AppProperties.empPassword; inspection.inspectorName = AppProperties.empUserName; } else { header.userName = AppProperties.empUserName; header.password = AppProperties.empPassword; inspection.inspectorNameArabic = AppProperties.empUserName; } string serialNumber = "39";// Schweers.Sys.Device.SerialNumber; //empUserName code inspection.inspectorEmployeeId = AppProperties.empID; inspection.channelPartInspectionCode = AppProperties.deviceCode; // isEng = regExp.IsMatch((AppProperties.recordedViolation.PlateCondition != null) ? AppProperties.recordedViolation.PlateCondition : (Resources.GetInstance().GetLocale().Equals(Resources.locale_EN)) ? "ENG" : "استعمال"); isEng = true; if (AppProperties.Selected_Resource == "English") { inspection.frontPlateConditionName = (AppProperties.recordedViolation.PlateCondition != null) ? AppProperties.recordedViolation.PlateCondition : "Good Condition"; inspection.rearPlateConditionName = (AppProperties.recordedViolation.PlateCondition != null) ? AppProperties.recordedViolation.PlateCondition : "Good Condition"; } else { inspection.frontPlateConditionName = (AppProperties.recordedViolation.PlateCondition != null) ? AppProperties.recordedViolation.PlateCondition : new CommonUtils().GetStringValue("Good Condition"); inspection.rearPlateConditionName = (AppProperties.recordedViolation.PlateCondition != null) ? AppProperties.recordedViolation.PlateCondition : new CommonUtils().GetStringValue("Good Condition"); } handHeldService.Vehicle veh = new VSDApp.handHeldService.Vehicle(); handHeldService.VehiclePlate plate = new VSDApp.handHeldService.VehiclePlate(); plate.source = ((IDBDataLoad)DBDataLoadManager.GetInstance()).GetPlateSourceCode((AppProperties.vehicle.Emirate == "") ? AppProperties.vehicle.Country : AppProperties.vehicle.Emirate).Trim(); if (plate.source == null || plate.source == "") { plate.source = AppProperties.vehicle.PlateSource; } plate.number = AppProperties.vehicle.PlateNumber.ToString(); plate.category = (AppProperties.vehicle.PlateCategory != "") ? AppProperties.vehicle.PlateCategory.Trim() : "NA"; plate.code = (AppProperties.vehicle.PlateCode != "") ? AppProperties.vehicle.PlateCode : "NA"; if (AppProperties.vehicle.Country == "") { veh.country = AppProperties.defaultCountry; } else { veh.country = AppProperties.vehicle.Country.Trim(); } veh.plateDetails = plate; veh.chassisNumber = AppProperties.vehicle.ChassisNumber; handHeldService.VehicleOwner owner = new VSDApp.handHeldService.VehicleOwner(); if (AppProperties.vehicle.Operator != null) owner.ownerName = AppProperties.vehicle.Operator.OperatorName; else owner.ownerName = ""; owner.ownerNameArabic = AppProperties.vehicle.Operator.OperatorNameAr; owner.trafficFileNumber = AppProperties.vehicle.Operator.TrafficFileNumber; veh.owner = owner; handHeldService.VehicleCategory vehCat = new VSDApp.handHeldService.VehicleCategory(); vehCat.code = ((IDBDataLoad)DBDataLoadManager.GetInstance()).GetVehicleCategoryCode((AppProperties.vehicle.VehicleCategory != null) ? AppProperties.vehicle.VehicleCategory : AppProperties.vehicle.VehicleCategoryAr).Trim(); veh.category = vehCat; VSDApp.handHeldService.VehicleManufacturer manu = new VSDApp.handHeldService.VehicleManufacturer(); manu.name = AppProperties.vehicle.Make; manu.model = AppProperties.vehicle.Model; veh.manufacturedYear = AppProperties.vehicle.Year; veh.manufacturer = manu; //create violation here if (null != AppProperties.recordedViolation.Defect && AppProperties.recordedViolation.Defect.Length > 0) { //create violation handHeldService.Violation violation = new VSDApp.handHeldService.Violation(); violation.comments = AppProperties.recordedViolation.ViolationComments; violation.commentsArabic = AppProperties.recordedViolation.ViolationCommentsAr; violation.provisionalTicketNumber = "?"; handHeldService.Defect[] defect = new VSDApp.handHeldService.Defect[AppProperties.recordedViolation.Defect.Length]; for (int i = 0; i < defect.Length; i++) { defect[i] = new VSDApp.handHeldService.Defect(); defect[i].comment = AppProperties.recordedViolation.Defect[i].DefectValue.Trim(); defect[i].code = iDataLoad.GetDefectCode(AppProperties.recordedViolation.Defect[i].DefectID).Trim(); } violation.defects = defect; inspection.violation = violation; if (AppProperties.recordedViolation.IsConfiscated) { inspection.plateConfiscatedReason = (null != AppProperties.recordedViolation.ConfiscationReason) ? AppProperties.recordedViolation.ConfiscationReason : "NA"; inspection.plateConfiscatedReasonArabic = (null != AppProperties.recordedViolation.ConfiscationReasonAr) ? AppProperties.recordedViolation.ConfiscationReasonAr : "NA"; } handHeldService.VehicleDriver driver = new VSDApp.handHeldService.VehicleDriver(); driver.name = ("" != AppProperties.vehicle.DriverName) ? AppProperties.vehicle.DriverName : "NA"; driver.nameArabic = ("" != AppProperties.vehicle.DriverNameAr) ? AppProperties.vehicle.DriverNameAr : "NA"; driver.licenseNumber = ("" != AppProperties.vehicle.DriverLicense) ? AppProperties.vehicle.DriverLicense : "NA"; veh.driver = driver; //To Do //inspection.isPlateConfiscated = (AppProperties.recordedViolation.IsConfiscated) ? "T" : "F"; inspection.isPlateConfiscated = "F"; inspection.isRegistrationExpired = "F"; } else { // inspection.isPlateConfiscated = (AppProperties.recordedViolation.IsConfiscated) ? "T" : "F"; inspection.isPlateConfiscated = "F"; inspection.isRegistrationExpired = "F"; } inspection.vehicle = veh; //inspection.time = AppProperties.recordedViolation.ViolationIssueDate; handHeldService.HandHeldService hh = new VSDApp.handHeldService.HandHeldService(); hh.authHeader = header; hh.Timeout = 180000; respItem = hh.submitViolation("RC123", inspection); if (respItem.response.code.Equals("1000")) { //create violation here if (null != AppProperties.recordedViolation.Defect && AppProperties.recordedViolation.Defect.Length > 0) { //System.Windows.Forms.MessageBox.Show("Violation Uploaded"); handHeldService.Inspection savedInspection = new VSDApp.handHeldService.Inspection(); savedInspection = respItem.savedInspection; AppProperties.recordedViolation.ViolationDueDays = (savedInspection.violation.dueDateSpecified) ? savedInspection.violation.dueDate : AppProperties.recordedViolation.ViolationDueDays; AppProperties.recordedViolation.ViolationSeverity = savedInspection.violation.severityLevel.value; AppProperties.recordedViolation.ViolationTicketCode = savedInspection.violation.ticketNumber; AppProperties.recordedViolation.ViolationTestType = savedInspection.violation.testTypeName; AppProperties.vehicle.VehicleSuspensionDate = (savedInspection.violation.vehicleSuspensionDateSpecified) ? savedInspection.violation.vehicleSuspensionDate : AppProperties.vehicle.VehicleSuspensionDate; AppProperties.vehicle.Operator.CompanySuspensionDate = (savedInspection.violation.ownerSuspensionDateSpecified) ? savedInspection.violation.ownerSuspensionDate : AppProperties.vehicle.Operator.CompanySuspensionDate; return true; } else { ///////////////////////// // Ispe ///// AppProperties.isInspectionUploaded = true; /* if (AppProperties.Selected_Resource == "English") System.Windows.MessageBox.Show("Inspection Uploaded") else System.Windows.MessageBox.Show("تم تسجيل عملية التفتيش بنجاح");*/ AppProperties.recordedViolation.ViolationTicketCode = respItem.response.message; return true; } } else if (respItem.response.code.Equals("2000")) { AppProperties.businessError = true; AppProperties.errorMessageFromBusiness = respItem.response.message; return true; } else { // System.Windows.MessageBox.Show(respItem.response.message); //return ((IDBManager)DBOfflineDataManager.GetInstance()).StoreOfflineData(); AppProperties.NotFoundError = true; AppProperties.errorMessageFromBusiness = respItem.response.message; AppProperties.vehicle = null; return false; } } catch (Exception e) { // CommonUtils.WriteLog(e.StackTrace); // System.Windows.MessageBox.Show("Unable to connect: " + e.Message); //and generate provisional id and rest of the information. if defects exists AppProperties.IsException = true; AppProperties.errorMessageFromBusiness = e.InnerException.Message; return ((IDBManager)DBOfflineDataManager.GetInstance()).StoreOfflineData(); } }