private void ImportCompanies(List <Action <ValueBag> > actions, XElement dataSource)
        {
            // Prepare to read the source data
            int                 rowNumber = 0;
            DataReader          reader    = DataReader.Load(dataSource);
            List <LocationPath> locations = new List <LocationPath>();

            // collect each row in the data source using the defined let statements
            foreach (var row in reader.DataEnumerator())
            {
                //Equipment asset = assetFinder.Find(row);
                var sourceValues = new ValueBag(row);

                rowNumber++;

                var path         = new LocationPath();
                var targetValues = new ValueBag(path);

                var data = new ValueBag(new { Source = row, sourceValues = sourceValues, Target = path, targetValues = targetValues });

                foreach (var act in actions)
                {
                    try {
                        act(data);
                    } catch (Exception ex) {
                        this.log.Error(ex.Message);
                    }
                }

                locations.Add(path);
            }

            // reduce the collected company locations into a distinct set of data and import
            foreach (var location in locations.Select((loc) => loc.CompanyName).Distinct())
            {
                ;
            }
        }
        private void ImportLocations(List <Action <ValueBag> > actions, XElement dataSource)
        {
            // Prepare to read the source data
            int                 rowNumber = 0;
            DataReader          reader    = DataReader.Load(dataSource);
            List <LocationPath> locations = new List <LocationPath>();

            // collect each row in the data source using the defined let statements
            foreach (var row in reader.DataEnumerator())
            {
                //Equipment asset = assetFinder.Find(row);
                var sourceValues = new ValueBag(row);

                rowNumber++;

                var path         = new LocationPath();
                var targetValues = new ValueBag(path);

                var data = new ValueBag(new { Source = row, sourceValues = sourceValues, Target = path, targetValues = targetValues });

                foreach (var act in actions)
                {
                    try {
                        act(data);
                    } catch (Exception ex) {
                        this.log.Error(ex.Message);
                    }
                }

                locations.Add(path);
            }

            int          currentSiteID    = 0;
            int          currentRegionID  = 0;
            int          currentCompanyID = 0;
            LocationPath currentLocation  = new LocationPath();

            // reduce the collected locations into a distinct ordered set of data and import
            log.Info("Collected: {0} items into a distinct count of {1} items", locations.Count, locations.Distinct().Count());
            foreach (var location in locations.Distinct().OrderBy(x => x.CompanyName).ThenBy(x => x.RegionName).ThenBy(x => x.SiteName))
            {
                log.Info("{0} / {1} / {2}", location.CompanyName, location.RegionName, location.SiteName);

                if (!(currentLocation.CompanyName ?? "").Equals(location.CompanyName ?? "", StringComparison.CurrentCultureIgnoreCase))
                {
                    currentLocation.CompanyName = location.CompanyName ?? "";
                    // Location.OrganizationID = context.OrganizationID
                    // Location.LocationTypeID = COMPANY_LOCATION_TYPE    // (1)
                    // Location.Name = currentLocation.CompanyName
                    // currentCompanyID = ConfigurationSystem.SaveLocation(Location).LocationID
                }

                if (!(currentLocation.RegionName ?? "").Equals(location.RegionName ?? "", StringComparison.CurrentCultureIgnoreCase))
                {
                    currentLocation.RegionName = location.RegionName ?? "";
                    // Location.OrganizationID = context.OrganizationID
                    // Location.LocationTypeID = REGION_LOCATION_TYPE    // (2)
                    // Location.Name = currentLocation.RegionName
                    // Location.ParentLocations = new int[] { currentCompanyID }
                    // currentRegionID = ConfigurationSystem.SaveLocation(Location).LocationID
                }

                if (!(currentLocation.SiteName ?? "").Equals(location.SiteName ?? "", StringComparison.CurrentCultureIgnoreCase))
                {
                    currentLocation.SiteName = location.SiteName ?? "";
                    // Location.OrganizationID = context.OrganizationID
                    // Location.LocationTypeID = SITE_LOCATION_TYPE    // (4)
                    // Location.Name = currentLocation.SiteName
                    // Location.ParentLocations = new int[] { currentRegionID }
                    // currentSiteID = ConfigurationSystem.SaveLocation(Location).LocationID
                }
            }
        }