Example #1
0
 public PipelineCreator(
     IParserDefinition definition,
     WriterConfiguration config,
     VariantType variant
     )
 {
     _definition            = definition;
     _configuration         = config;
     _variant               = variant;
     _singleWriterExecution = new ExecutionDataflowBlockOptions {
         MaxDegreeOfParallelism = 1
     };
     _options = new ExecutionDataflowBlockOptions {
         MaxDegreeOfParallelism = Environment.ProcessorCount,
         BoundedCapacity        = 1000000,
         MaxMessagesPerTask     = 10000
     };
     _linkOptions = new DataflowLinkOptions {
         PropagateCompletion = true
     };
     _plDictionary     = new Dictionary <string, HierarchyNode>();
     _hierarchyRoot    = new HPEHierarchyNode();
     _csvOutputWriter  = new CsvOutputWriter(config);
     _jsonOutputWriter = new JsonOutputWriter(config);
 }
Example #2
0
        private static void WriteHierarchy2(HPEHierarchyNode root, CsvHierarchyOutputWriter2 fileWriter)
        {
            if (_writeLine2)
            {
                fileWriter.Write(root);
            }
            else
            {
                _writeLine2 = true;
            }

            foreach (var child in root.Children)
            {
                WriteHierarchy2(child.Value, fileWriter);
            }
        }
Example #3
0
        private static void OutputHierarchies(WriterConfiguration config,
                                              Dictionary <string, HierarchyNode> plDictionary,
                                              HPEHierarchyNode hierarchyRoot)
        {
            var pureHierarchyPath = Path.Combine(config.OutputPath, config.CsvDirectory, config.PureHierarchyFileName);

            Console.WriteLine($"Write hierarchies: {pureHierarchyPath}");
            var productLineHierarchyRoot = new HierarchyNode {
                Level = 1, CategoryName = "HPE PL Root", CategoryID = "Pl"
            };

            productLineHierarchyRoot.Children.AddRange(plDictionary.Values);
            FileHelpers.DeleteFile(FileTypes.Pure_Hierarchy, FileTypes.Pure_Hierarchy, pureHierarchyPath);
            using (var stream =
                       new StreamWriter(File.OpenWrite(pureHierarchyPath))) {
                using (var fileWriter = new CsvHierarchyOutputWriter(stream)) {
                    WriteHierarchy(productLineHierarchyRoot, fileWriter);
                }

                using (var fileWriter = new CsvHierarchyOutputWriter2(stream)) {
                    WriteHierarchy2(hierarchyRoot, fileWriter);
                }
            }
        }
Example #4
0
        private static void UpdateCategoryTree(HPEHierarchyNode hierarchyRoot, IReadOnlyList <Hierarchy> branch,
                                               string partnerHierarchyCode)
        {
            if (branch[0].CategoryID == null)
            {
                return;
            }

            var productTypeId = branch[0].CategoryID;
            var productType   = hierarchyRoot.Children.GetOrAdd(
                productTypeId,
                key => new HPEHierarchyNode {
                Id                   = key,
                Name                 = branch[0].CategoryName,
                ParentCategoryId     = null,
                Level                = 1,
                PartnerHierarchyCode = partnerHierarchyCode
            }
                );

            var marketingCategoryId = productTypeId + "|" + branch[1].CategoryID;
            var marketingCategory   = productType.Children.GetOrAdd(
                marketingCategoryId,
                key => new HPEHierarchyNode {
                Id                   = key,
                Name                 = branch[1].CategoryName,
                ParentCategoryId     = productTypeId,
                Level                = 2,
                PartnerHierarchyCode = partnerHierarchyCode
            }
                );

            var marketingSubCategoryId = marketingCategoryId + "|" + branch[2].CategoryID;
            var marketingSubCategory   = marketingCategory.Children.GetOrAdd(
                marketingSubCategoryId,
                key => new HPEHierarchyNode {
                Id                   = key,
                Name                 = branch[2].CategoryName,
                ParentCategoryId     = marketingCategoryId,
                Level                = 3,
                PartnerHierarchyCode = partnerHierarchyCode
            }
                );

            var bigSeriesId = marketingSubCategoryId + "|" + branch[3].CategoryID;
            var bigSeries   = marketingSubCategory.Children.GetOrAdd(
                bigSeriesId,
                key => new HPEHierarchyNode {
                Id                   = key,
                Name                 = branch[3].CategoryName,
                ParentCategoryId     = marketingSubCategoryId,
                Level                = 4,
                PartnerHierarchyCode = partnerHierarchyCode
            }
                );

            var smallSeriesId = bigSeriesId + "|" + branch[4].CategoryID;

            bigSeries.Children.GetOrAdd(
                smallSeriesId,
                key => new HPEHierarchyNode {
                Id                   = key,
                Name                 = branch[4].CategoryName,
                ParentCategoryId     = bigSeriesId,
                Level                = 5,
                PartnerHierarchyCode = partnerHierarchyCode
            }
                );
        }