コード例 #1
0
        /// <summary>
        /// Get information about all factor trees.
        /// Only factors that are in the factor cache are returned.
        /// This is done in order to avoid problem where cached
        /// factor data differ from factor data in database.
        /// </summary>
        /// <param name="context">Web service request context.</param>
        /// <param name="factors">Factor list where factors are added.</param>
        /// <param name="factorTreeNodes">All factor tree nodes.</param>
        /// <param name="dataReader">An open DataReader with information about factors.</param>
        private static void GetFactors(WebServiceContext context,
                                       List <WebFactor> factors,
                                       WebFactorTreeNodeList factorTreeNodes,
                                       DataReader dataReader)
        {
            WebFactor factor;

            while (dataReader.Read())
            {
                factor = new WebFactor(dataReader);
                if (factorTreeNodes.Contains(factor.Id))
                {
                    factors.Add(factorTreeNodes.Get(factor.Id).Factor);
                }
            }
        }
コード例 #2
0
            /// <summary>
            /// Create a FactorInformation instance.
            /// </summary>
            /// <param name='dataReader'>An open data reader.</param>
            public FactorInformation(DataReader dataReader)
            {
                WebFactorTreeNode childTreeNode, factorTreeNode, parentTreeNode;

                // Get all factors and factor tree nodes.
                _factorTreeNodes = new WebFactorTreeNodeList();
                _factors         = new List <WebFactor>();
                while (dataReader.Read())
                {
                    factorTreeNode = new WebFactorTreeNode(dataReader);
                    _factorTreeNodes.Merge(factorTreeNode);
                    _factors.Add(factorTreeNode.Factor);
                }

                // Get next result set.
                if (!dataReader.NextResultSet())
                {
                    throw new ApplicationException("No information about factors relations when getting factor tree");
                }

                // Get factor relations and build factor trees.
                while (dataReader.Read())
                {
                    parentTreeNode = _factorTreeNodes.Get(dataReader.GetInt32(FactorTreeData.PARENT_FACTOR_ID));
                    childTreeNode  = _factorTreeNodes.Get(dataReader.GetInt32(FactorTreeData.CHILD_FACTOR_ID));
                    parentTreeNode.AddChild(childTreeNode);
                }

                // Extract all factor tree nodes that
                // are not child tree nodes.
                _factorTrees = new List <WebFactorTreeNode>();
                foreach (WebFactorTreeNode factorTree in _factorTreeNodes)
                {
                    if (!factorTree.IsChild)
                    {
                        _factorTrees.Add(factorTree);
                    }
                }
            }