public static Patte ConvertFromUwPate(uwPate uwPate) { Patte pate = new Patte(); pate.PatteSerial = uwPate.urbanWarehousePermitID; pate.ConsigneeNationalId = uwPate.consigneeNationalID; pate.Driver = Models.Driver.ConvertToDriver(uwPate.driver); pate.issuanceDate = uwPate.exitFromOriginDate; pate.Containers = Container.ConvertToContainers(uwPate.exitBills); pate.OperatorNationalId = uwPate.operatorNationalID; pate.CityOfOrigin = uwPate.permitPlaceOfIssueID; JsonResultWithObject <stock[]> stockInfos = BitaServices.GetStockInformation(uwPate.permitPlaceOfIssueID); if (stockInfos.isSuccess) { pate.CityOfOrigin = stockInfos.result[0].name + " (" + stockInfos.result[0].state + "-" + stockInfos.result[0].city + ")"; } pate.DestinationCity = uwPate.permitDestinationID.Equals("-")? "مقصد معرفی نشده است": uwPate.permitDestinationID; pate.PlaqueLeftTwoDigits = uwPate.vehicleInformation.plaqueLeftTwoDigits; pate.PlaqueMiddleCharacter = uwPate.vehicleInformation.plaqueMiddleCharacter; pate.PalqueMiddleThreeDigits = uwPate.vehicleInformation.palqueMiddleThreeDigits; pate.PlaqueCityCode = uwPate.vehicleInformation.plaqueSerial; return(pate); }
/// <summary> /// ErrorCode = 10004 /// </summary> /// <param name="pateNo"></param> /// <returns></returns> public static JsonResultWithObject <Patte> GetUrbanWarehousePate(string pateNo) { string pfxKeyPath = ""; string cerKeyPath = ""; JsonResultWithObject <Patte> response = new JsonResultWithObject <Patte>(); try { try { Patte existingPatte = PatteRepository.GetInstance().FindByPatteSerial(pateNo); response.isSuccess = true; response.messages = null; response.result = existingPatte; return(response); } catch (Exception) { //do nothing because it means that this patte not found in dataBase. } GetUrbanWarehousePermitClient client = (GetUrbanWarehousePermitClient)InitialClient(new GetUrbanWarehousePermitClient()); uwPate uwPate = client.getUrbanWarehousePermitByPermitNumber(pateNo); Patte pate = Patte.ConvertFromUwPate(uwPate); PatteRepository.GetInstance().Save(pate); response.isSuccess = true; response.result = pate; return(response); } catch (EndpointNotFoundException epe) { Log.Error("Service can not connect Bita."); response.messages = new object[] { "1003 خطا در ارتباط با سامانه های همکار." }; } catch (CryptographicException exx) { Log.Error("Public or Private Key Not Found; Path:" + pfxKeyPath + " OR " + cerKeyPath); Log.Error(exx.StackTrace); Log.Debug(exx.Message); if (exx.InnerException != null) { Log.Error(exx.InnerException.Message); if (exx.InnerException.InnerException != null) { Log.Error(exx.InnerException.InnerException.Message); } } response.messages = new object[] { "1002 خطای داخلی رخ داده است." }; } catch (Exception ex) { Log.Error("در هنگام دریافت پته انبارشهری خطای نامشخص رخ داده است. 10004"); Log.Error(ex.Message); response.messages = new object[] { "اطلاعات پته درخواستی نامعتبر و یا هنوز در گمرک دریافت نشده است." }; } response.isSuccess = false; return(response); }