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