private static ServiceType GetService(RoutesCatalogRoute _route) { if (_route.Equipment_Type__UoM.ToUpper().Contains("ESC")) { return(ServiceType.SecurityEscortProvider); } else { return(ServiceType.Forwarder); } }
internal void ImportRow(Entities edc, RoutesCatalogRoute route, string routePrefix, bool testData, Action <ProgressChangedEventArgs> progress) { ServiceType _service = GetService(route); Partner _Partner = GetOrAddJTIPartner(edc, _service, route.Vendor.Trim(), testData); FreightPayer _freightPayer = GetOrAdd <FreightPayer>(edc.FreightPayer, m_FreightPayer, route.Freight_Payer__I_C__MainLeg.ToString(), testData, x => NewItemCreateNotification(x, progress)); CityType _CityType = GetOrAddCity(edc, route.Dest_City.Trim(), route.Dest_Country.Trim(), "Unknown", progress); Currency _Currency = GetOrAdd <Currency>(edc.Currency, m_Currency, route.Currency, false, x => NewItemCreateNotification(x, progress)); ShipmentType _ShipmentType = GetOrAdd <ShipmentType>(edc.ShipmentType, m_ShipmentType, route.ShipmentType, false, x => NewItemCreateNotification(x, progress)); CarrierType _CarrierCarrierType = GetOrAdd <CarrierType>(edc.Carrier, m_CarrierCarrierType, route.Carrier, false, x => NewItemCreateNotification(x, progress)); TranspotUnit _TransportUnit = GetOrAdd <TranspotUnit>(edc.TransportUnitType, m_TransportUnit, route.Equipment_Type__UoM, false, x => NewItemCreateNotification(x, progress)); SAPDestinationPlant _SAPDestinationPlant = GetOrAdd <SAPDestinationPlant>(edc.SAPDestinationPlant, m_SAPDestinationPlant, route.SAP_Dest_Plant, false, x => NewItemCreateNotification(x, progress)); BusienssDescription _businessDescription = GetOrAdd <BusienssDescription>(edc.BusinessDescription, m_BusinessDescription, route.Business_description, false, x => NewItemCreateNotification(x, progress)); Commodity _commodity = GetOrAdd <Commodity>(edc.Commodity, m_CommodityCommodity, route.Commodity, false, x => NewItemCreateNotification(x, progress)); string _sku = route.Material_Master__Reference; string _title = String.Format("{3} To: {0}, by: {1}, of: {2}", _CityType.Title, _Partner.Title, route.Commodity, routePrefix); switch (_service) { case ServiceType.Forwarder: Route _rt = new Route() { Route2BusinessDescriptionTitle = _businessDescription, 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 = _TransportUnit, PartnerTitle = _Partner, Route2Commodity = _commodity, Incoterm = route.Selling_Incoterm }; edc.Route.InsertOnSubmit(_rt); break; case ServiceType.SecurityEscortProvider: SecurityEscortCatalog _sec = new SecurityEscortCatalog() { SecurityEscortCatalog2BusinessDescriptionTitle = _businessDescription, 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 = _Partner }; edc.SecurityEscortRoute.InsertOnSubmit(_sec); break; case ServiceType.VendorAndForwarder: case ServiceType.None: case ServiceType.Invalid: case ServiceType.Vendor: default: break; } //TODO edc.SubmitChanges(); }