/// <summary> /// ErrorCode = 10003 /// </summary> /// <param name="serial"></param> /// <returns></returns> public static JsonResultWithObject <List <Patte> > GetAllPateBySerial(string serial) { JsonResultWithObject <List <Patte> > response = new JsonResultWithObject <List <Patte> >(); try { GetCustomsPermitClient client = (GetCustomsPermitClient)InitialClient(new GetCustomsPermitClient()); customsPermit[] permitList = client.getCustomsPermitsBySerialNumber(serial); if (permitList.Length == 0) { throw new UserInterfaceException("پتهای دریافت نشد."); } List <Patte> pateList = new List <Patte>(); foreach (customsPermit permit in permitList) { pateList.Add(Patte.ConvertToPatte(permit)); } response.isSuccess = true; response.messages = null; response.result = pateList; return(response); } catch (EndpointNotFoundException epe) { Log.Error("Service can not connect Bita."); response.messages = new object[] { "1003 خطا در ارتباط با سامانه های همکار." }; } catch (UserInterfaceException ex) { Log.Error(ex.Message); response.messages = new[] { ex.Message }; } catch (Exception ex) { Log.Error("10003 خطای داخلی در دریافت همه پته های یک پروانه رخ داده است."); Log.Error(ex.Message); response.messages = new object[] { "اطلاعات پته درخواستی نامعتبر و یا هنوز در گمرک دریافت نشده است." }; } response.isSuccess = false; return(response); }
/// <summary> /// ErrorCode = 10001 /// </summary> /// <param name="patteNoOrPlaque"></param> /// <param name="byPlaque"></param> /// <returns></returns> public static JsonResultWithObject <Patte> GetPatte(string patteNoOrPlaque, bool byPlaque) { JsonResultWithObject <Patte> response = new JsonResultWithObject <Patte>(); try { try { if (!byPlaque) { Patte existingPatte = PatteRepository.GetInstance().FindByPatteSerial(patteNoOrPlaque); 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. } GetCustomsPermitClient client = (GetCustomsPermitClient)InitialClient(new GetCustomsPermitClient()); customsPermit resp; if (byPlaque) { resp = client.getCustomsPermitByPlaque(patteNoOrPlaque); } else { resp = client.getCustomsPermitByCustomsPermitNumber(patteNoOrPlaque.Trim()); } Patte patte = Patte.ConvertToPatte(resp); //GetBillOfLading(patte.Driver.NationalCode); if (!Configuration.GetInstance().IsLocalMachin()) { PatteRepository.GetInstance().Save(patte); } response.isSuccess = true; response.messages = null; response.result = patte; return(response); } catch (EndpointNotFoundException epe) { Log.Error("Service can not connect Bita."); response.messages = new object[] { "1003 خطا در ارتباط با سامانه های همکار." }; } catch (UserInterfaceException ex) { Log.Error(ex.Message); response.messages = new[] { ex.Message }; } catch (Exception ex) { Log.Error("خطای داخلی در دریافت پته 10001"); Log.Error(ex.Message); response.messages = new object[] { "اطلاعات پته درخواستی نامعتبر و یا هنوز در گمرک دریافت نشده است." }; } response.isSuccess = false; return(response); }