public void LoadApplicationStacks_Test() { StackHierarchy hierarchy = new StackHierarchy(); using (DataTransactionBase dt = new OracleDataTransaction(Configuration.StacksConnectionString)) { StackGatewayBase gateway = new ApplicationStackGateway(dt.Transaction); gateway.Load(hierarchy); } Assert.IsNotNull(hierarchy); Assert.IsNotNull(hierarchy.Stacks); Assert.IsTrue(hierarchy.Stacks.Count > 0); Debug.WriteLine("ApplicationStacks:{0}", hierarchy.Stacks.Count); Assert.IsNotNull(hierarchy.MajorFilters); Assert.IsTrue(hierarchy.MajorFilters.Count > 0); Debug.WriteLine("MajorFilters:{0}", hierarchy.MajorFilters.Count); Assert.IsNotNull(hierarchy.MinorFilters); Assert.IsTrue(hierarchy.MinorFilters.Count > 0); Debug.WriteLine("MinorFilters:{0}", hierarchy.MinorFilters.Count); Assert.IsNotNull(hierarchy.StackLookups); Assert.IsTrue(hierarchy.StackLookups.Count > 0); Debug.WriteLine("ApplicationStackLookups:{0}", hierarchy.StackLookups.Count); Assert.AreEqual(hierarchy.MajorFilters.Count, hierarchy.MajorFilters.Count((item) => item.IsLoaded)); Assert.AreEqual(hierarchy.MinorFilters.Count, hierarchy.MinorFilters.Count((item) => item.IsLoaded)); Assert.AreEqual(hierarchy.Stacks.Count, hierarchy.StackLookups.Count((item) => item.IsLoaded)); }
protected override void PopulateHierarchy(IDataReader pReader, StackHierarchy pHierarchy) { if (pReader == null || pHierarchy == null) { return; } PlatformStackHierarchy hierarchy = pHierarchy as PlatformStackHierarchy; if (hierarchy == null) { return; } Task <FilterLookup> platformTask; Task <FilterLookup> versionTask; Task <FilterLookup> architectureTask; Task <FilterLookup> buildTask; Task <StackLookup> stackTask; using (EventWaitHandle synchronizer = new AutoResetEvent(false)) { platformTask = Task.Factory.StartNew <FilterLookup>(base.LoadMajorFilter, new HierarchyParallelHelper(pReader, pHierarchy)); versionTask = Task.Factory.StartNew <FilterLookup>(base.LoadMinorFilter, new HierarchyParallelHelper(pReader, pHierarchy)); architectureTask = Task.Factory.StartNew <FilterLookup>(LoadArchitectureFilter, new HierarchyParallelHelper(pReader, pHierarchy)); buildTask = Task.Factory.StartNew <FilterLookup>(LoadBuildFilter, new HierarchyParallelHelper(pReader, pHierarchy)); stackTask = Task.Factory.StartNew <StackLookup>(base.LoadPlatformStack, new HierarchyParallelHelper(pReader, pHierarchy)); Task.Factory.ContinueWhenAll(new Task[] { platformTask, versionTask, stackTask }, (obj) => { synchronizer.Set(); }); synchronizer.WaitOne(); } hierarchy.AddPlatformStack(platformTask.Result, versionTask.Result, architectureTask.Result, buildTask.Result, stackTask.Result); }
public void Load(StackHierarchy pHierarchy) { if (pHierarchy == null) { return; } using (IDataReader reader = DbHelper.ExecuteReader(_transaction, this.SelectAllQuery)) { while (reader.Read()) { PopulateHierarchy(reader, pHierarchy); } } }
protected void Page_Init(object sender, EventArgs e) { _hierarchy = new StackHierarchy(); try { using (DataTransactionBase dt = new OracleDataTransaction(Configuration.StacksConnectionString)) { StackGatewayBase gateway = new ApplicationStackGateway(dt.Transaction); gateway.Load(_hierarchy); } } catch (Exception ex) { _exception = ex; } }
protected override void PopulateHierarchy(IDataReader pReader, StackHierarchy pHierarchy) { if (pReader == null || pHierarchy == null) { return; } Task <FilterLookup> majorTask; Task <FilterLookup> minorTask; Task <StackLookup> stackTask; using (EventWaitHandle synchronizer = new AutoResetEvent(false)) { majorTask = Task.Factory.StartNew <FilterLookup>(base.LoadMajorFilter, new HierarchyParallelHelper(pReader, pHierarchy)); minorTask = Task.Factory.StartNew <FilterLookup>(base.LoadMinorFilter, new HierarchyParallelHelper(pReader, pHierarchy)); stackTask = Task.Factory.StartNew <StackLookup>(base.LoadPlatformStack, new HierarchyParallelHelper(pReader, pHierarchy)); Task.Factory.ContinueWhenAll(new Task[] { majorTask, minorTask, stackTask }, (obj) => { synchronizer.Set(); }); synchronizer.WaitOne(); } pHierarchy.AddStack(majorTask.Result, minorTask.Result, stackTask.Result); }
protected abstract void PopulateHierarchy(IDataReader pReader, StackHierarchy pHierarchy);
public HierarchyParallelHelper(IDataReader pReader, StackHierarchy pHierarchy) { this.Reader = pReader; this.Hierarchy = pHierarchy; }