private ServiceType GetService(PreliminaryDataRouteRoute _route) { if (_route.Equipment_Type__UoM.ToUpper().Contains("ESC")) { return(ServiceType.SecurityEscortProvider); } else { return(ServiceType.Forwarder); } }
internal void AddRoute(PreliminaryDataRouteRoute _route, bool _testData) { try { ServiceType _service = GetService(_route); Partner _prtnr = GetOrAddJTIPartner(_service, _route.Vendor.Trim(), _testData); FreightPayer _freightPayer = GetOrAdd <FreightPayer>(m_EDC.FreightPayer, m_FreightPayer, _route.Freight_Payer__I_C__MainLeg, _testData); CityType _CityType = GetOrAddCity(_route.Dest_City, _route.Dest_Country, null); Currency _Currency = GetOrAdd <Currency>(m_EDC.Currency, m_Currency, _route.Currency, false); ShipmentType _ShipmentType = GetOrAdd <ShipmentType>(m_EDC.ShipmentType, m_ShipmentType, _route.ShipmentType, false); CarrierType _CarrierCarrierType = GetOrAdd <CarrierType>(m_EDC.Carrier, m_CarrierCarrierType, _route.Carrier, false); TranspotUnit _TranspotUnit = GetOrAdd <TranspotUnit>(m_EDC.TransportUnitType, m_TranspotUnit, _route.Equipment_Type__UoM, false); SAPDestinationPlant _SAPDestinationPlant = GetOrAdd <SAPDestinationPlant>(m_EDC.SAPDestinationPlant, m_SAPDestinationPlant, _route.SAP_Dest_Plant, false); BusienssDescription _busnessDscrptn = GetOrAdd <BusienssDescription>(m_EDC.BusinessDescription, m_BusinessDescription, _route.Business_description, false); Commodity _cmdty = GetOrAdd <Commodity>(m_EDC.Commodity, m_CommodityCommodity, _route.Commodity, false); string _sku = _route.Material_Master__Reference; string _title = String.Format("To: {0}, by: {1}, of: {2}", _CityType.Title, _prtnr.Title, _route.Commodity); switch (_service) { case ServiceType.Forwarder: Route _rt = new Route() { Route2BusinessDescriptionTitle = _busnessDscrptn, CarrierTitle = _CarrierCarrierType, Route2CityTitle = _CityType, DepartureCity = _route.Dept_City, CurrencyTitle = _Currency, FreightPayerTitle = _freightPayer, GoodsHandlingPO = _route.PO_NUMBER, MaterialMaster = _sku, DeparturePort = _route.Port_of_Dept, RemarkMM = _route.Remarks, SAPDestinationPlantTitle = _SAPDestinationPlant, ShipmentTypeTitle = _ShipmentType, Title = _title, TransportCosts = _testData ? 4567.8 : _route.Total_Cost_per_UoM.String2Double(), TransportUnitTypeTitle = _TranspotUnit, PartnerTitle = _prtnr, Route2Commodity = _cmdty, Incoterm = _route.Selling_Incoterm }; m_EDC.Route.InsertOnSubmit(_rt); break; case ServiceType.SecurityEscortProvider: SecurityEscortCatalog _sec = new SecurityEscortCatalog() { SecurityEscortCatalog2BusinessDescriptionTitle = _busnessDscrptn, CurrencyTitle = _Currency, EscortDestination = _route.Dest_City, FreightPayerTitle = _freightPayer, MaterialMaster = _sku, RemarkMM = _route.Remarks, SecurityCost = _testData ? 345.6 : _route.Total_Cost_per_UoM.String2Double(), SecurityEscrotPO = _route.PO_NUMBER, Title = _title, PartnerTitle = _prtnr }; m_EDC.SecurityEscortRoute.InsertOnSubmit(_sec); break; case ServiceType.VendorAndForwarder: case ServiceType.None: case ServiceType.Invalid: case ServiceType.Vendor: default: break; } m_EDC.SubmitChanges(); } catch (Exception ex) { string _format = "Cannot add route data SKU={0} Description={1} because of import Error= {2}"; throw new ApplicationException(String.Format(_format, _route.Material_Master_Short_Text, _route.Business_description, ex.Message)); } }