コード例 #1
0
        private static bool IsEnumerableCollectionGroupFounded(EnumerableRowCollection <DataRow> collection,
                                                               string type,
                                                               ref string topLevel,
                                                               ref string siteService)
        {
            int rowsBySubgroupCount = collection.Count();

            if (rowsBySubgroupCount == 1)
            {
                DataRow dataRowBySubgroup = collection.First();
                string  typeByGroup       = dataRowBySubgroup[3].ToString();
                if (string.IsNullOrEmpty(typeByGroup) ||
                    typeByGroup.ToLower().Equals(type))
                {
                    SetupTopLevelAndSiteServiceValue(dataRowBySubgroup, ref topLevel, ref siteService);
                    return(true);
                }
            }
            else if (rowsBySubgroupCount == 2)
            {
                DataRow dataRowBySubgroupFirst = collection.First();
                DataRow dataRowBySubgroupLast  = collection.Last();
                string  typeBySubgroupFirst    = dataRowBySubgroupFirst[3].ToString();
                string  typeBySubgroupLast     = dataRowBySubgroupLast[3].ToString();

                if (typeBySubgroupFirst.ToLower().Equals(type))
                {
                    SetupTopLevelAndSiteServiceValue(dataRowBySubgroupFirst, ref topLevel, ref siteService);
                    return(true);
                }
                else if (typeBySubgroupLast.ToLower().Equals(type))
                {
                    SetupTopLevelAndSiteServiceValue(dataRowBySubgroupLast, ref topLevel, ref siteService);
                    return(true);
                }
                else if (string.IsNullOrEmpty(typeBySubgroupFirst))
                {
                    SetupTopLevelAndSiteServiceValue(dataRowBySubgroupFirst, ref topLevel, ref siteService);
                    return(true);
                }
                else if (string.IsNullOrEmpty(typeBySubgroupLast))
                {
                    SetupTopLevelAndSiteServiceValue(dataRowBySubgroupLast, ref topLevel, ref siteService);
                    return(true);
                }
            }
            else if (rowsBySubgroupCount > 2)
            {
                Logging.ToLog("Результат поиска группировки по подгруппе более 3, пропуск");
            }

            return(false);
        }