/// <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);
        }
        /// <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);
        }