using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Threading.Tasks; using System.Windows; using System.Windows.Input; using System.Windows.Media.Imaging; using Comal.Classes; using InABox.Clients; using InABox.Configuration; using InABox.Core; using InABox.Integration.Awg; using InABox.Integration.Logikal; using InABox.WPF; using Microsoft.Xaml.Behaviors.Core; using PRSDesktop.Integrations.Logikal; namespace PRSDesktop.Integrations.Common; public class AWGMappingWindowViewModel : DependencyObject { private static readonly DependencyProperty SourceTypeProperty = DependencyProperty.Register( nameof(SourceType), typeof(IntegrationSourceType), typeof(AWGMappingWindowViewModel) ); public IntegrationSourceType SourceType { get => (IntegrationSourceType)GetValue(SourceTypeProperty); set => SetValue(SourceTypeProperty, value); } // public static DependencyProperty JobIDProperty = DependencyProperty.Register( // nameof(JobID), // typeof(Guid), // typeof(IntegrationBOMWindowViewModel) // ); // // public Guid JobID // { // get => (Guid)GetValue(JobIDProperty); // set => SetValue(JobIDProperty, value); // } // public static DependencyProperty BOMProperty = DependencyProperty.Register( // nameof(BOM), // typeof(IAwgBOM), // typeof(IntegrationBOMWindowViewModel), // new FrameworkPropertyMetadata(BOMChanged)); // // private static void BOMChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) // { // // if (d is not IntegrationBOMWindowViewModel model) // return; // // var bom = // e.NewValue as IAwgBOM; // // var styles = model.ExtractMappings( // bom?.Finishes, x => x.Code, x => x.Description, x => x.Code); // // var profiles = model.ExtractMappings( // bom?.Profiles, x => x.Code, x => x.Description, x => x.Code); // // var gaskets = model.ExtractMappings( // bom?.Gaskets, x => x.Code, x => x.Description, x => x.Code); // // var components = model.ExtractMappings( // bom?.Components, x => x.Code, x => x.Description, x => x.Code); // // var glass = model.ExtractMappings( // bom?.Glass, x => x.Code, x => x.Description, x => x.Code); // // var labour = model.ExtractMappings( // bom?.Labour, x => x.Code, x => x.Description, x => x.Code); // // Task.WaitAll(styles, profiles, gaskets, components, glass, labour); // model.Styles = styles.Result; // model.Profiles = profiles.Result; // model.Gaskets = gaskets.Result; // model.Components = components.Result; // model.Glass = glass.Result; // model.Labour = labour.Result; // model.CheckChanged(); // } // // public IAwgBOM? BOM // { // get => GetValue(BOMProperty) as IAwgBOM; // set => SetValue(BOMProperty, value); // } private static readonly DependencyProperty FinishesProperty = DependencyProperty.Register( nameof(Finishes), typeof(IEnumerable), typeof(AWGMappingWindowViewModel), new FrameworkPropertyMetadata(FinishesChanged) ); private static void FinishesChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is not AWGMappingWindowViewModel model || e.NewValue is not IEnumerable finishes) return; var mappings = model.ExtractMappings( finishes, x => x.Code, x => x.Description, x => x.Code); mappings.Wait(); model.FinishMappings = mappings.Result; model.CheckChanged(); } public IEnumerable? Finishes { get => GetValue(FinishesProperty) as IEnumerable; set => SetValue(FinishesProperty, value); } private static readonly DependencyProperty ProfilesProperty = DependencyProperty.Register( nameof(Profiles), typeof(IEnumerable), typeof(AWGMappingWindowViewModel), new FrameworkPropertyMetadata(ProfilesChanged) ); private static void ProfilesChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is not AWGMappingWindowViewModel model || e.NewValue is not IEnumerable profiles) return; var mappings = model.ExtractMappings( profiles, x => x.Code, x => x.Description, x => x.Code); mappings.Wait(); model.ProfileMappings = mappings.Result; model.CheckChanged(); } public IEnumerable? Profiles { get => GetValue(ProfilesProperty) as IEnumerable; set => SetValue(ProfilesProperty, value); } private static readonly DependencyProperty GasketsProperty = DependencyProperty.Register( nameof(Gaskets), typeof(IEnumerable), typeof(AWGMappingWindowViewModel), new FrameworkPropertyMetadata(GasketsChanged) ); private static void GasketsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is not AWGMappingWindowViewModel model || e.NewValue is not IEnumerable gaskets) return; var mappings = model.ExtractMappings( gaskets, x => x.Code, x => x.Description, x => x.Code); mappings.Wait(); model.GasketMappings = mappings.Result; model.CheckChanged(); } public IEnumerable? Gaskets { get => GetValue(GasketsProperty) as IEnumerable; set => SetValue(GasketsProperty, value); } private static readonly DependencyProperty ComponentsProperty = DependencyProperty.Register( nameof(Components), typeof(IEnumerable), typeof(AWGMappingWindowViewModel), new FrameworkPropertyMetadata(ComponentsChanged) ); private static void ComponentsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is not AWGMappingWindowViewModel model || e.NewValue is not IEnumerable components) return; var mappings = model.ExtractMappings( components, x => x.Code, x => x.Description, x => x.Code); mappings.Wait(); model.ComponentMappings = mappings.Result; model.CheckChanged(); } public IEnumerable? Components { get => GetValue(ComponentsProperty) as IEnumerable; set => SetValue(ComponentsProperty, value); } private static readonly DependencyProperty GlassProperty = DependencyProperty.Register( nameof(Glass), typeof(IEnumerable), typeof(AWGMappingWindowViewModel), new FrameworkPropertyMetadata(GlassChanged) ); private static void GlassChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is not AWGMappingWindowViewModel model || e.NewValue is not IEnumerable glass) return; var mappings = model.ExtractMappings( glass, x => x.Code, x => x.Description, x => x.Code); mappings.Wait(); model.GlassMappings = mappings.Result; model.CheckChanged(); } public IEnumerable? Glass { get => GetValue(GlassProperty) as IEnumerable; set => SetValue(GlassProperty, value); } private static readonly DependencyProperty LabourProperty = DependencyProperty.Register( nameof(Labour), typeof(IEnumerable), typeof(AWGMappingWindowViewModel), new FrameworkPropertyMetadata(LabourChanged) ); private static void LabourChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is not AWGMappingWindowViewModel model || e.NewValue is not IEnumerable labour) return; var mappings = model.ExtractMappings( labour, x => x.Code, x => x.Description, x => x.Code); mappings.Wait(); model.LabourMappings = mappings.Result; model.CheckChanged(); } public IEnumerable? Labour { get => GetValue(LabourProperty) as IEnumerable; set => SetValue(LabourProperty, value); } private static readonly DependencyProperty FinishMappingsProperty = DependencyProperty.Register( nameof(FinishMappings), typeof(List), typeof(AWGMappingWindowViewModel) ); public List? FinishMappings { get => GetValue(FinishMappingsProperty) as List; set => SetValue(FinishMappingsProperty, value); } private static readonly DependencyProperty FinishesCheckedProperty = DependencyProperty.Register( nameof(FinishesChecked), typeof(bool), typeof(AWGMappingWindowViewModel), new FrameworkPropertyMetadata(defaultValue: true, propertyChangedCallback:SectionCheckedChanged) ); private static void SectionCheckedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is AWGMappingWindowViewModel model) model.CheckChanged(); } public bool FinishesChecked { get => (bool)GetValue(FinishesCheckedProperty); set => SetValue(FinishesCheckedProperty, value); } private static readonly DependencyProperty ProfileMappingsProperty = DependencyProperty.Register( nameof(ProfileMappings), typeof(List), typeof(AWGMappingWindowViewModel) ); public List? ProfileMappings { get => GetValue(ProfileMappingsProperty) as List; set => SetValue(ProfileMappingsProperty, value); } private static readonly DependencyProperty ProfilesCheckedProperty = DependencyProperty.Register( nameof(ProfilesChecked), typeof(bool), typeof(AWGMappingWindowViewModel), new FrameworkPropertyMetadata(defaultValue: true, propertyChangedCallback:SectionCheckedChanged) ); public bool ProfilesChecked { get => (bool)GetValue(ProfilesCheckedProperty); set => SetValue(ProfilesCheckedProperty, value); } private static readonly DependencyProperty GasketMappingsProperty = DependencyProperty.Register( nameof(GasketMappings), typeof(List), typeof(AWGMappingWindowViewModel) ); public List? GasketMappings { get => GetValue(GasketMappingsProperty) as List; set => SetValue(GasketMappingsProperty, value); } private static readonly DependencyProperty GasketsCheckedProperty = DependencyProperty.Register( nameof(GasketsChecked), typeof(bool), typeof(AWGMappingWindowViewModel), new FrameworkPropertyMetadata(defaultValue: true, propertyChangedCallback:SectionCheckedChanged) ); public bool GasketsChecked { get => (bool)GetValue(GasketsCheckedProperty); set => SetValue(GasketsCheckedProperty, value); } private static readonly DependencyProperty ComponentMappingsProperty = DependencyProperty.Register( nameof(ComponentMappings), typeof(List), typeof(AWGMappingWindowViewModel) ); public List? ComponentMappings { get => GetValue(ComponentMappingsProperty) as List; set => SetValue(ComponentMappingsProperty, value); } private static readonly DependencyProperty ComponentsCheckedProperty = DependencyProperty.Register( nameof(ComponentsChecked), typeof(bool), typeof(AWGMappingWindowViewModel), new FrameworkPropertyMetadata(defaultValue: true, propertyChangedCallback:SectionCheckedChanged) ); public bool ComponentsChecked { get => (bool)GetValue(ComponentsCheckedProperty); set => SetValue(ComponentsCheckedProperty, value); } private static readonly DependencyProperty GlassMappingsProperty = DependencyProperty.Register( nameof(GlassMappings), typeof(List), typeof(AWGMappingWindowViewModel) ); public List? GlassMappings { get => GetValue(GlassMappingsProperty) as List; set => SetValue(GlassMappingsProperty, value); } private static readonly DependencyProperty GlassCheckedProperty = DependencyProperty.Register( nameof(GlassChecked), typeof(bool), typeof(AWGMappingWindowViewModel), new FrameworkPropertyMetadata(defaultValue: true, propertyChangedCallback:SectionCheckedChanged) ); public bool GlassChecked { get => (bool)GetValue(GlassCheckedProperty); set => SetValue(GlassCheckedProperty, value); } private static readonly DependencyProperty LabourMappingsProperty = DependencyProperty.Register( nameof(LabourMappings), typeof(List), typeof(AWGMappingWindowViewModel) ); public List? LabourMappings { get => GetValue(LabourMappingsProperty) as List; set => SetValue(LabourMappingsProperty, value); } private static readonly DependencyProperty LabourCheckedProperty = DependencyProperty.Register( nameof(LabourChecked), typeof(bool), typeof(AWGMappingWindowViewModel), new FrameworkPropertyMetadata(defaultValue: true, propertyChangedCallback:SectionCheckedChanged) ); public bool LabourChecked { get => (bool)GetValue(LabourCheckedProperty); set => SetValue(LabourCheckedProperty, value); } private static readonly DependencyProperty SectionsProperty = DependencyProperty.Register( nameof(Sections), typeof(CoreObservableCollection>), typeof(AWGMappingWindowViewModel), new PropertyMetadata(new CoreObservableCollection>()) ); public CoreObservableCollection> Sections { get => (CoreObservableCollection>)GetValue(SectionsProperty); set => SetValue(SectionsProperty, value); } private static readonly DependencyProperty SelectedSectionProperty = DependencyProperty.Register( nameof(SelectedSection), typeof(KeyValuePair?), typeof(AWGMappingWindowViewModel) ); public KeyValuePair? SelectedSection { get => (KeyValuePair?)GetValue(SelectedSectionProperty); set => SetValue(SelectedSectionProperty, value); } private static readonly DependencyProperty MappingsCompleteProperty = DependencyProperty.Register( nameof(MappingsComplete), typeof(bool), typeof(AWGMappingWindowViewModel) ); public bool MappingsComplete { get => (bool)GetValue(MappingsCompleteProperty); set => SetValue(MappingsCompleteProperty, value); } private LogikalSettings _settings; public AWGMappingWindowViewModel() { _settings = new GlobalConfiguration().Load(); } public Task> ExtractMappings( IEnumerable? items, Func logikalcode, Func logikaldescription, Expression> entitycode) where TType : IAwgBOMItem where TCode : BaseIntegrationSource, IRemotable, IPersistent, new() where TEntity : Entity, IRemotable,IPersistent, new() where TLink :EntityLink { return Task.Run(() => { var f = entitycode.Compile(); var results = new List(); if (items == null) return results; var sourceitems = new Dictionary(); foreach (var item in items) sourceitems[logikalcode(item) ?? ""] = logikaldescription(item) ?? ""; MultiQuery query = new(); query.Add( new Filter(entitycode).InList(sourceitems.Keys.ToArray()), Columns.Required().Add(x => x.ID).Add(entitycode) ); var entitycodecol = $"Entity.{CoreUtils.GetFullPropertyName(entitycode, ".")}"; query.Add( new Filter(x => x.Code).InList(sourceitems.Keys.ToArray()), Columns.Required() .Add(x => x.ID) .Add(x => x.Code) .Add(x=>x.Entity.ID) .Add(entitycodecol) ); query.Query(); var mappings = query.Get().ToObjects().ToArray(); var entities = query.Get(); foreach (var sourceitem in sourceitems) { var result = new TCode() { Code = sourceitem.Key, Description = sourceitem.Value }; var mapping = mappings.FirstOrDefault(x => string.Equals(x.Code, sourceitem.Key)); if (mapping != null) result.Entity.CopyFrom(mapping.Entity); else { var entity = entities.Rows.FirstOrDefault(r => string.Equals(sourceitem.Key,r.Get(entitycode))); if (entity != null) result.Entity.CopyFrom(entity.ToObject()); } results.Add(result); result.PropertyChanged += (s, e) => { // TMapping mapping = mappingtable.Rows.FirstOrDefault(r => // string.Equals(r.Get(c => c.Code), result.Code))?.ToObject(); // if (mapping == null) // mapping = new TMapping() { Code = result.Code }; // mapping.Entity.ID = result.Entity.ID; // new Client().Save(mapping, "Created from BOM Integration Window"); CheckChanged(); }; } return results; }); } private void CheckChanged() { Dispatcher.BeginInvoke(() => { var curSel = SelectedSection?.Key ?? ""; SelectedSection = null; Sections.Clear(); if (FinishesChecked && FinishMappings?.Any() == true) Sections.Add(new KeyValuePair("Finishes",PRSDesktop.Resources.palette.AsBitmapImage(64, 64))); if (ProfilesChecked && ProfileMappings?.Any() == true) Sections.Add(new KeyValuePair("Profiles",PRSDesktop.Resources.profile.AsBitmapImage(64, 64))); if (GasketsChecked && GasketMappings?.Any() == true) Sections.Add(new KeyValuePair("Gaskets",PRSDesktop.Resources.gasket.AsBitmapImage(64, 64))); if (ComponentsChecked && ComponentMappings?.Any() == true) Sections.Add(new KeyValuePair("Components",PRSDesktop.Resources.fixings.AsBitmapImage(64, 64))); if (GlassChecked && GlassMappings?.Any() == true) Sections.Add(new KeyValuePair("Glass",PRSDesktop.Resources.glass.AsBitmapImage(64, 64))); if (LabourChecked && LabourMappings?.Any() == true) Sections.Add(new KeyValuePair("Labour",PRSDesktop.Resources.quality.AsBitmapImage(64, 64))); SelectedSection = Sections.Any(x=>string.Equals(x.Key,curSel)) ? Sections.First(x=>string.Equals(x.Key,curSel)) : Sections.FirstOrDefault(); var styles = !FinishesChecked || (FinishMappings?.All(x => x.Entity.ID != Guid.Empty) ?? false); var profiles = !ProfilesChecked || (ProfileMappings?.All(x => x.Entity.ID != Guid.Empty) ?? false); var glass = !GlassChecked || (GlassMappings?.All(x => x.Entity.ID != Guid.Empty) ?? false); var components = !ComponentsChecked || (ComponentMappings?.All(x => x.Entity.ID != Guid.Empty) ?? false); var labour = !LabourChecked || (LabourMappings?.All(x => x.Entity.ID != Guid.Empty) ?? false); MappingsComplete = styles && profiles && glass && components && labour; }); } public ICommand CreateStyle => new ActionCommand( o => { if (o is IntegrationGridCreateEntityArgs args) { args.Entity.Code = args.Mapping.Code ?? ""; args.Entity.Description = args.Mapping.Description ?? ""; args.Entity.Problem.Notes = ["Created from BOM Integration Window"]; } } ); public ICommand CreateProfile => new ActionCommand( o => { if (o is IntegrationGridCreateEntityArgs args) { args.Entity.Code = args.Mapping.Code ?? ""; args.Entity.Name = args.Mapping.Description ?? ""; args.Entity.UnitOfMeasure.CopyFrom(_settings.ProfileUom); args.Entity.Problem.Notes = ["Created from BOM Integration Window"]; } } ); public ICommand CreateGasket => new ActionCommand( o => { if (o is IntegrationGridCreateEntityArgs args) { args.Entity.Code = args.Mapping.Code ?? ""; args.Entity.Name = args.Mapping.Description ?? ""; args.Entity.UnitOfMeasure.CopyFrom(_settings.GasketUom); args.Entity.Problem.Notes = ["Created from BOM Integration Window"]; } } ); public ICommand CreateComponent => new ActionCommand( o => { if (o is IntegrationGridCreateEntityArgs args) { args.Entity.Code = args.Mapping.Code ?? ""; args.Entity.Name = args.Mapping.Description ?? ""; args.Entity.UnitOfMeasure.CopyFrom(_settings.ComponentUom); args.Entity.Problem.Notes = ["Created from BOM Integration Window"]; } } ); public ICommand CreateGlass => new ActionCommand( o => { if (o is IntegrationGridCreateEntityArgs args) { args.Entity.Code = args.Mapping.Code ?? ""; args.Entity.Name = args.Mapping.Description ?? ""; args.Entity.UnitOfMeasure.CopyFrom(_settings.GlassUom); args.Entity.Problem.Notes = ["Created from BOM Integration Window"]; } } ); public ICommand CreateActivity => new ActionCommand( o => { if (o is IntegrationGridCreateEntityArgs args) { args.Entity.Code = args.Mapping.Code ?? ""; args.Entity.Description = args.Mapping.Description ?? ""; args.Entity.Problem.Notes = ["Created from BOM Integration Window"]; } } ); private class RawDimensions : IBaseDimensions { public double Quantity { get; set; } public double Length { get; set; } public double Width { get; set; } public double Height { get; set; } public double Weight { get; set; } } public void GetParts( Action? productCallback, Action? labourCallback) { GetParts(Profiles,Gaskets,Components,Glass,Labour,productCallback,labourCallback); } public void GetParts( IEnumerable? profiles, IEnumerable? gaskets, IEnumerable? components, IEnumerable? glasses, IEnumerable? labour, Action? productCallback, Action? labourCallback) where TProfile : IAwgProfile where TGasket : IAwgGasket where TComponent : IAwgComponent where TGlass : IAwgGlass where TLabour : IAwgLabour { if (ProfilesChecked && profiles != null) { foreach (var profile in profiles) { var profilemapping = ProfileMappings?.FirstOrDefault(x => x.Code == profile.Code); var stylemapping = FinishMappings?.FirstOrDefault(x => string.Equals(x.Code, profile.Finish)); if (profilemapping != null && productCallback is not null) { productCallback( profilemapping.Entity, stylemapping?.Entity, new RawDimensions() { Length = profile.Length }, profile.Quantity, profile.Cost); } } } if (GasketsChecked && gaskets != null) { foreach (var gasket in gaskets) { var gasketmapping = GasketMappings?.FirstOrDefault(x => x.Code == gasket.Code); if (gasketmapping != null && productCallback is not null) { productCallback( gasketmapping.Entity, null, new RawDimensions() { Length = 1.0 }, gasket.Quantity, gasket.Cost); } } } if (ComponentsChecked && components != null) { foreach (var component in components) { var componentmapping = ComponentMappings?.FirstOrDefault(x => string.Equals(x.Code, component.Code)); if (componentmapping != null && productCallback is not null) { productCallback( componentmapping.Entity, null, new RawDimensions() { Quantity = component.PackSize }, component.Quantity, component.Cost); } } } if (GlassChecked && glasses != null) { foreach (var glass in glasses) { var glassmapping = GlassMappings?.FirstOrDefault(x => string.Equals(x.Code, glass.Code)); if (glassmapping != null && productCallback is not null) { productCallback( glassmapping.Entity, null, new RawDimensions() { Height = glass.Height, Width = glass.Width }, glass.Quantity, glass.Cost); } } } if (LabourChecked && labour != null) { foreach (var activity in labour) { var activitymapping = LabourMappings?.FirstOrDefault(x => string.Equals(x.Code, activity.Code)); if (activitymapping != null && labourCallback is not null) { labourCallback( activitymapping.Entity, TimeSpan.FromHours(activity.Quantity), activity.Cost); } } } } // public void CreateBOM() // { // if (Finishes == null || Profiles == null || Gaskets == null || Components == null || Glass == null || Labour == null) // return; // // List items = new List(); // // foreach (var profile in Profiles) // { // var profilemapping = ProfileMappings?.FirstOrDefault(x => x.Code == profile.Code); // var stylemapping = FinishMappings?.FirstOrDefault(x => string.Equals(x.Code, profile.Finish)); // if (profilemapping != null) // { // JobBillOfMaterialsItem newitem = new JobBillOfMaterialsItem(); // newitem.Product.CopyFrom(profilemapping.Entity); // newitem.Dimensions.Unit.CopyFrom(profilemapping.Entity.UnitOfMeasure); // newitem.Dimensions.Length = profile.Length; // if (stylemapping != null) // newitem.Style.CopyFrom(stylemapping.Entity); // newitem.Quantity = profile.Quantity; // newitem.UnitCost = profile.Cost; // items.Add(newitem); // } // } // // foreach (var component in Components) // { // var componentmapping = ComponentMappings?.FirstOrDefault(x => string.Equals(x.Code, component.Code)); // if (componentmapping != null) // { // JobBillOfMaterialsItem newitem = new JobBillOfMaterialsItem(); // newitem.Product.CopyFrom(componentmapping.Entity); // newitem.Dimensions.Unit.CopyFrom(componentmapping.Entity.UnitOfMeasure); // newitem.Dimensions.Quantity = component.PackSize; // newitem.Quantity = component.Quantity; // newitem.UnitCost = component.Cost; // items.Add(newitem); // } // } // // foreach (var glass in Glass) // { // var glassmapping = GlassMappings?.FirstOrDefault(x => string.Equals(x.Code, glass.Code)); // if (glassmapping != null) // { // JobBillOfMaterialsItem newitem = new JobBillOfMaterialsItem(); // newitem.Product.CopyFrom(glassmapping.Entity); // newitem.Dimensions.Unit.CopyFrom(glassmapping.Entity.UnitOfMeasure); // newitem.Dimensions.Height = glass.Height; // newitem.Dimensions.Height = glass.Width; // newitem.Quantity = glass.Quantity; // newitem.UnitCost = glass.Cost; // items.Add(newitem); // } // } // // List activities = new List(); // // foreach (var activity in Labour) // { // var activitymapping = LabourMappings?.FirstOrDefault(x => string.Equals(x.Code, activity.Code)); // if (activitymapping != null) // { // JobBillOfMaterialsActivity newactivity = new JobBillOfMaterialsActivity(); // newactivity.ActivityLink.CopyFrom(activitymapping.Entity); // newactivity.Duration = TimeSpan.FromHours(activity.Quantity); // newactivity.HourlyCost = activity.Cost; // activities.Add(newactivity); // } // } // // var _jobbom = new JobBillOfMaterials(); // _jobbom.Job.ID = JobID; // _jobbom.Description = $"BOM Imported {DateTime.Now}"; // // Progress.ShowModal("Creating BOM...", progress => // { // Client.Save(_jobbom, "Imported From Logikal"); // // progress.Report("Updating Items"); // foreach (var item in items) // { // item.BillOfMaterials.ID = _jobbom.ID; // item.Job.ID = _jobbom.Job.ID; // } // // Client.Save(items, "Imported From Logikal"); // // progress.Report("Updating Labour"); // foreach (var activity in activities) // { // activity.BillOfMaterials.ID = _jobbom.ID; // activity.JobLink.ID = _jobbom.Job.ID; // } // // Client.Save(activities, "Imported From Logikal"); // // // }); // } }