Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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);
        }