/// <summary>
        ///  ErrorCode = 10060 , 10061
        /// </summary>
        /// <param name="nationalId"></param>
        /// <returns></returns>
        public static JsonResultWithObject <BillOfLading> GetBillOfLading(string nationalId)
        {
            JsonResultWithObject <BillOfLading> result = new JsonResultWithObject <BillOfLading>();
            BillOfLadingInformationClient       client = (BillOfLadingInformationClient)InitialClient(new BillOfLadingInformationClient());

            try
            {
                BillOfLading bol = client.getBOLByDriverNationalId(nationalId);
                result.result    = bol;
                result.isSuccess = true;
                return(result);
            }
            catch (EndpointNotFoundException ex)
            {
                Log.Error("10060 Service can not connect Bita.");
                Log.Error(ex);
                result.messages = new object[] { "10060 در هنگام دریافت بارنامه از سامانه همکار خطا رخ داده است." };
            }
            catch (Exception ex)
            {
                Log.Error("10061 BillOfLading Exception.");
                Log.Error(ex);
                result.messages = new object[] { "10061 خطا نامشخص در فرآیند دریافت بارنامه از مرکز." };
            }
            result.isSuccess = false;
            return(result);
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        // GET api/patteinforequest/patteNo/username/password/type
        public JsonResultWithObject <JPatte> Get(string patteNo, string username, string password, string type)
        {
            Log.Debug("Service Getting Patte started!");
            JsonResultWithObject <JPatte> Jresponse = new JsonResultWithObject <JPatte>();

            try
            {
                if (!UserRepository.GetInstance().CheckUsernamePassword(username.Trim(), password.Trim()))
                {
                    throw new EntityNotFoundException(74401, "کاربر مورد نظر در سیستم ثبت نگردیده است");
                }
                var response = Logics.BitaServices.GetPatte(patteNo, type.Equals("plq"));
                Jresponse.isSuccess = response.isSuccess;
                Jresponse.messages  = response.messages;
                if (response.isSuccess)
                {
                    Jresponse.result = JPatte.ConvertToJPatte(response.result);
                    return(Jresponse);
                }
                return(Jresponse);
            }
            catch (UserInterfaceException ex)
            {
                Log.Error(ex.Message);
                Jresponse.messages = new[] { "نام کاربری یا رمز عبور اشتباه است" };
            }
            Jresponse.isSuccess = false;
            return(Jresponse);
        }
        /// <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);
        }
Exemple #5
0
        public ActionResult Index(string n)
        {
            //TODO REFACTOR get element in post data should be refactored
            pTwoLeft  = Request.Form.Get(CommonUtilities.CorrectPostedElement("UUPlaque$txtTwoLeft"));
            pAlphabet = Request.Form.Get(CommonUtilities.CorrectPostedElement("UUPlaque$txtAlphabet"));
            pThree    = Request.Form.Get(CommonUtilities.CorrectPostedElement("UUPlaque$txtThree"));
            pCityCode = Request.Form.Get(CommonUtilities.CorrectPostedElement("UUPlaque$txtCityCode"));
            patteNo   = Request.Form.Get(CommonUtilities.CorrectPostedElement("UUPlaque$txtPatteNo"));

            if (!IsPlaqueEnterd() && patteNo.IsNullOrWhiteSpace())
            {
                Session["Error"] = "برای دریافت اطلاعات پته، پلاک و یا شماره سریال پته را وارد نمایید.";
                return(RedirectToAction("Index", "Patte"));
            }

            JsonResultWithObject <Patte> response;

            if (IsPlaqueEnterd())
            {
                response = Logics.BitaServices.GetPatte(GetPlaqueCorrectFormat(), true);
            }
            else
            {
                if (patteNo.StartsWith("uwp"))
                {
                    JsonResultWithObject <Patte> uwPateResponse = Logics.BitaServices.GetUrbanWarehousePate(patteNo);
                    if (uwPateResponse.isSuccess)
                    {
                        Session["uwPate"] = uwPateResponse.result;
                        return(RedirectToAction("ShowUwPate", "Patte"));
                    }
                    Session["Error"] = uwPateResponse.messages[0];
                    return(RedirectToAction("Index", "Patte"));
                }
                response = Logics.BitaServices.GetPatte(patteNo, false);
            }
            if (response.isSuccess)
            {
                Session["patte"] = response.result;
//                JsonResultWithObject<customsValueDeclaration[]> result = Logics.BitaServices.CustomsValueDeclarationInformation(response.result.KotajNos.Split('*')[0]);
//                if (result.isSuccess)
//                {
//                    ICollection<Commodity> pateCommodities = response.result.Containers.ToList()[0].Commoditys;
//                    IQueryable<customsValueDeclaration> arzesh = result.result.ToList().AsQueryable().Where(v => pateCommodities.Any(c => c.CommodityHsCode.Equals(v.commodityHSCode)));
//                    arzesh.ForEach(a => a.commodityItemQuantity = pateCommodities.First(c => c.CommodityHsCode.Equals(a.commodityHSCode)).CommodityItemQuantity);
//                    arzesh.ForEach(a => a.commodityDescription = pateCommodities.First(c => c.CommodityHsCode.Equals(a.commodityHSCode)).CommodityTariffDescription);
//                    List<customsValueDeclaration> listArzesh = arzesh.DistinctBy(d=> d.commodityHSCode).ToList();
//                    Session["ValueDeclaration"] = listArzesh;
//                }
                return(RedirectToAction("ShowPatte", "Patte"));
            }
            else
            {
                Session["Error"] = response.messages[0];
                return(RedirectToAction("Index", "Patte"));
            }
        }
Exemple #6
0
        public JsonResultWithObject <Patte> Get(string hexPelaq, string hexPasgah)
        {
            string plaq       = CommonUtilities.HexStringToString(hexPelaq, Encoding.UTF8);
            string pasgahName = CommonUtilities.HexStringToString(hexPasgah, Encoding.UTF8);
            Pasgah pasgah     = PasgahRepository.GetInstance().FindByName(pasgahName);
            JsonResultWithObject <Patte> response = Logics.BitaServices.GetPatte(plaq, true);

            if (!response.isSuccess)
            {
                return(response);
            }
            try
            {
                bool isSucceed =
                    ConfirmedPatteRepository.GetInstance()
                    .CheckIfNotRedundant(pasgah.Id, response.result.Id);
                if (isSucceed)
                {
                    isSucceed = ConfirmedPatteRepository.GetInstance().Save(new ConfirmedPatte()
                    {
                        PasgahID = pasgah.Id, PatteID = response.result.Id, UserID = pasgah.Users.FirstOrDefault().Id, ConfirmationIp = "WEB SERVICE"
                    });
                    if (isSucceed)
                    {
                        response.messages = new [] { "پته با موفقیت تایید شد." };
                    }
                    else
                    {
                        response.messages  = new[] { "در ذخیره سازی تاییدیه پته خطا رخ داده است." };
                        response.isSuccess = false;
                    }
                }
                else
                {
                    response.messages  = new[] { "این پته قبلا در این مرکز ثبت شده است و امکان تایید مجدد آن وجود ندارد." };
                    response.isSuccess = false;
                }
            }
            catch (Exception ex)
            {
                Log.Error(String.Format("Uknown Error occured during saving patteConfirm with plaq {0}", plaq));
                Log.Error(ex.Message);

                response.messages  = new[] { "این پته قبلا در این مرکز ثبت شده است و امکان تایید مجدد آن وجود ندارد" };
                response.isSuccess = false;
            }

            return(response);
        }
Exemple #7
0
        public ActionResult ShowAllPateBySerialSerach()
        {
            string parvaneSerial = Request.Form["parvaneSerial"];
            JsonResultWithObject <List <Patte> > result = Logics.BitaServices.GetAllPateBySerial(parvaneSerial);

            if (result.isSuccess)
            {
                Session["ListPate"] = result.result;
            }
            else
            {
                Session["Error"] = result.messages[0];
            }
            return(RedirectToAction("ShwoAllPateBySerial", "Patte"));
        }
Exemple #8
0
        public ActionResult ShowBillOfLading()
        {
            string driverNationalID = Request.Form["driverNationalID"];
            JsonResultWithObject <BillOfLading> bol = Logics.BitaServices.GetBillOfLading(driverNationalID);

            if (bol.isSuccess)
            {
                if (bol.result.billOfLadingNumber.Equals("چنين بارنامه اي يافت نشد"))
                {
                    Session["infoException"] = "بارنامه ای با شماره ملی راننده مورد نظر یافت نشد.";
                    return(RedirectToAction("ShowPatte", "Patte"));
                }
                Session["BOL"] = bol.result;
                return(RedirectToAction("ShowBillOfLading", "BillOfLading"));
            }
            Session["infoException"] = bol.messages[0];
            return(RedirectToAction("ShowPatte", "Patte"));
        }
        /// <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);
        }
Exemple #10
0
        // GET api/authentication/username/password
        public JsonResultWithObject <bool> Get(string username, string password)
        {
            JsonResultWithObject <bool> result = new JsonResultWithObject <bool>();

            try
            {
                result.result    = UserRepository.GetInstance().CheckUsernamePassword(username.Trim(), password.Trim());
                result.isSuccess = true;
                result.messages  = null;
                return(result);
            }
            catch (Exception ex)
            {
                Log.Error("1201 خطای داخلی رخ داده است.");
                Log.Error(ex.Message);
                result.messages = new object[] { "در دریافت اطلاعاتی خطا رخ داده است." };
            }
            result.isSuccess = false;
            result.result    = false;
            return(result);
        }
        /// <summary>
        /// ErrorCode = 10060 , 10061
        /// </summary>
        /// <param name="stockId"></param>
        /// <returns></returns>
        public static JsonResultWithObject <stock[]> GetStockInformation(string stockId)
        {
            JsonResultWithObject <stock[]> result = new JsonResultWithObject <stock[]>();
            StockInformationClient         client = (StockInformationClient)InitialClient(new StockInformationClient());

            try
            {
                stock[] stockInformation = client.getStockInformationByStockId(new string[] { stockId });
                result.result    = stockInformation;
                result.isSuccess = true;
                return(result);
            }
            catch (Exception ex)
            {
                Log.Debug(ex);
                // انبار مورد نظر یافت نشد
                result.messages = new[] { ex.Message };
            }
            result.isSuccess = false;
            return(result);
        }
Exemple #12
0
 public ActionResult GetValueDeclearation()
 {
     try
     {
         string parvaneSerial = Request.Form["parvaneSerial"];
         JsonResultWithObject <customsValueDeclaration[]> result =
             Logics.BitaServices.CustomsValueDeclarationInformation(parvaneSerial);
         if (result.isSuccess)
         {
             Session["ValueDeclaration"] = result.result.ToList();
             return(RedirectToAction("ShowValueDeclearation", "ValueDeclearation"));
         }
         Session["Error"] = result.messages[0];
         return(RedirectToAction("SearchValueDeclearation", "ValueDeclearation"));
     }
     catch (Exception ex)
     {
         Session["Error"] = "ارتباط با گمرک برقرار نشد.";
         return(RedirectToAction("SearchValueDeclearation", "ValueDeclearation"));
     }
 }
        /// <summary>
        /// ErrorCode = 10005
        /// </summary>
        /// <param name="serial"></param>
        /// <returns></returns>
        public static JsonResultWithObject <customsValueDeclaration[]> CustomsValueDeclarationInformation(string serial)
        {
            string pfxKeyPath = "";
            string cerKeyPath = "";
            JsonResultWithObject <customsValueDeclaration[]> result = new JsonResultWithObject <customsValueDeclaration[]>();

            try
            {
                CustomsValueDeclarationInformationClient client = (CustomsValueDeclarationInformationClient)InitialClient(new CustomsValueDeclarationInformationClient());
                //99000-21318340
                customsValueDeclaration[] customsValueDeclarations = client.getCustomsValueDeclarationBySerialNumber(serial);
                result.isSuccess = true;
                result.result    = customsValueDeclarations;
                return(result);
            }
            catch (CryptographicException ex)
            {
                Log.Error("Public or Private Key Not Found; Path:" + pfxKeyPath + " OR " + cerKeyPath);
                Log.Error(ex.StackTrace);
                Log.Debug(ex.Message);
                if (ex.InnerException != null)
                {
                    Log.Error(ex.InnerException.Message);
                    if (ex.InnerException.InnerException != null)
                    {
                        Log.Error(ex.InnerException.InnerException.Message);
                    }
                }
                result.messages = new object[] { "1002 خطای داخلی رخ داده است." };
            }
            catch (Exception ex)
            {
                Log.Error("هنگام دریافت اظهارنامه ارزش خطای نامشخص رخ داده است. 10005");
                Log.Error(ex.Message);
                result.messages = new object[] { "اطلاعات اظهارنامه ارزش درخواستی نامعتبر و یا برقراری ارتباط با مشکل مواجه شده است." };
            }
            result.isSuccess = false;
            return(result);
        }
        /// <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);
        }
Exemple #15
0
        public static Patte ConvertToPatte(customsPermit customsPermit)
        {
            Patte pate = new Patte();

            pate.PatteSerial = customsPermit.iranUniqueConsignmentReference.Replace("-", "");
            if (customsPermit.iranUniqueConsignmentReference.Split('-').Length > 1)
            {
                pate.CustomsGateCode = customsPermit.iranUniqueConsignmentReference.Split('-')[0];
                try
                {
                    pate.CityOfOrigin = EnumHelper.ToEnumString((CustomsCode)Int32.Parse(pate.CustomsGateCode));
                }
                catch (Exception)
                {
                    pate.CityOfOrigin = pate.CustomsGateCode;
                }
            }
            pate.ForeignPlaque           = customsPermit.vehicleInformation.foreignPlaque;
            pate.IsToUrbanWarehouse      = (customsPermit.destinationStocksIDs != null) && customsPermit.destinationStocksIDs.Length > 0;
            pate.PlaqueLeftTwoDigits     = customsPermit.vehicleInformation.plaqueLeftTwoDigits;
            pate.PlaqueMiddleCharacter   = customsPermit.vehicleInformation.plaqueMiddleCharacter;
            pate.PalqueMiddleThreeDigits = customsPermit.vehicleInformation.palqueMiddleThreeDigits;
            pate.PlaqueCityCode          = customsPermit.vehicleInformation.plaqueSerial;
            pate.Weight              = customsPermit.weightInKg;
            pate.Containers          = Models.Container.ConvertToContainers(customsPermit.container);
            pate.issuanceDate        = customsPermit.issuanceDate;
            pate.ConsigneeNationalId = customsPermit.consigneeNationalID;

            if (customsPermit.destinationStocksIDs != null && customsPermit.destinationStocksIDs.Length > 0)
            {
                pate.DestinationCode = customsPermit.destinationStocksIDs[0];
                if (customsPermit.destinationStocksIDs[0].Length == 5)
                {
                    try
                    {
                        pate.DestinationCity = EnumHelper.ToEnumString((CustomsCode)Int32.Parse(customsPermit.destinationStocksIDs[0]));
                    }
                    catch (Exception)
                    {
                        pate.CityOfOrigin = customsPermit.destinationStocksIDs[0];
                    }
                }
                if (Regex.IsMatch(customsPermit.destinationStocksIDs[0], @"\p{IsArabic}"))
                {
                    pate.DestinationCity    = customsPermit.destinationStocksIDs[0];
                    pate.IsToUrbanWarehouse = false;
                }
                else if (customsPermit.destinationStocksIDs[0].Equals("unknown"))
                {
                    pate.DestinationCity = "نامشخص";
                    pate.DestinationName = "نامشخص";
                }
                else
                {
                    JsonResultWithObject <stock[]> stockInfos = BitaServices.GetStockInformation(customsPermit.destinationStocksIDs[0]);
                    try
                    {
                        if (stockInfos.isSuccess)
                        {
                            pate.DestinationName        = stockInfos.result[0].name;
                            pate.DestinationCity        = stockInfos.result[0].city;
                            pate.DestinationState       = stockInfos.result[0].state;
                            pate.DestinationAddress     = stockInfos.result[0].address;
                            pate.DestinationBossPhoneNo = stockInfos.result[0].manager != null
                                ? stockInfos.result[0].manager.phoneNo
                                : "";
                            pate.DestinationBossName = stockInfos.result[0].manager != null
                                ? stockInfos.result[0].manager.name
                                : "";
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }


            foreach (string serial in customsPermit.orderCode)
            {
                //                if (!serial.Contains("99000"))
                //                    pate.KotajNos += pate.CustomsGateCode + "-" + serial + "*";
                //                else
                {
                    pate.KotajNos += serial + "*";
                }
            }
            pate.Driver = Driver.ConvertToDriver(customsPermit.driver);
            return(pate);
        }