Пример #1
0
        protected string GetTargetSiteCollectionUrl()
        {
            if (!EnableParallelMode)
            {
                return(SiteUrls.First());
            }

            var scopeHash = GetScopeHash();

            if (string.IsNullOrEmpty(scopeHash))
            {
                return(SiteUrls.First());
            }

            var mappings       = RestoreMappings();
            var currentMapping = mappings.FirstOrDefault(m => m.Contains(scopeHash));

            if (currentMapping == null)
            {
                var lastMappingIndex = GetLastIndex();

                if (lastMappingIndex == 9)
                {
                    lastMappingIndex = 0;
                }
                else
                {
                    lastMappingIndex++;
                }

                SaveLastIndex(lastMappingIndex);


                var url         = string.Format("http://DEV42:31416/sites/r-{0}", lastMappingIndex);
                var fullMapping = string.Format("{0}|{1}", scopeHash, url);

                mappings.Add(fullMapping);

                SaveMappings(mappings);
                mappings = RestoreMappings();

                currentMapping = mappings.FirstOrDefault(m => m.Contains(scopeHash));
            }


            return(currentMapping.Split(new string[] { "|" }, StringSplitOptions.None)[1]);
        }