Наследование: ConfigurationBase
Пример #1
0
        public static string CreateLocation(SystemConfiguration DiscoConfiguration, string SubLocation, DateTime? SubSubLocationTimestamp = null)
        {
            string SubSubLocation = string.Empty;
            if (SubSubLocationTimestamp.HasValue)
                SubSubLocation = SubSubLocationTimestamp.Value.ToString(@"yyyy\\MM");

            string storeDirectory = System.IO.Path.Combine(DiscoConfiguration.DataStoreLocation, SubLocation, SubSubLocation);
            if (!System.IO.Directory.Exists(storeDirectory))
                System.IO.Directory.CreateDirectory(storeDirectory);

            return storeDirectory;
        }
Пример #2
0
        public static IndexModel FromConfiguration(SystemConfiguration config)
        {
            var m = new IndexModel()
            {
                DiscoVersion = typeof(DiscoApplication).Assembly.GetName().Version,
                DataStoreLocation = config.DataStoreLocation,
                ProxyAddress = config.ProxyAddress,
                ProxyPort = config.ProxyPort,
                ProxyUsername = config.ProxyUsername,
                ProxyPassword = config.ProxyPassword,
                UpdateLatestResponse = config.UpdateLastCheckResponse,
                UpdateRunningStatus = UpdateQueryTask.RunningStatus,
                UpdateNextScheduled = UpdateQueryTask.NextScheduled,
                UpdateBetaDeployment = config.UpdateBetaDeployment
            };

            // Is an update available?
            m.UpdateAvailable = m.UpdateLatestResponse != null && (Version.Parse(m.UpdateLatestResponse.LatestVersion) > m.DiscoVersion);

            // AD
            m.ADDomains = ActiveDirectory.Context.Domains.ToList();
            m.ADPrimaryDomain = ActiveDirectory.Context.PrimaryDomain;
            m.ADSite = ActiveDirectory.Context.Site;
            m.ADServers = ActiveDirectory.Context.Domains.SelectMany(d => d.DomainControllers).ToList();
            m.ADSearchWildcardSuffixOnly = config.ActiveDirectory.SearchWildcardSuffixOnly;
            var configSearchContainers = config.ActiveDirectory.SearchContainers;
            m.ADSearchContainers = configSearchContainers == null ? null : configSearchContainers.SelectMany(d => d.Value, (k, c) =>
            {
                var domain = ActiveDirectory.Context.GetDomainByName(k.Key);
                return Tuple.Create(c, domain, domain.FriendlyDistinguishedNamePath(c));
            }).ToList();

            var loadForestServersTask = ADDiscoverForestServers.LoadForestServersAsync();
            if (loadForestServersTask.Wait(TimeSpan.FromSeconds(1)))
            {
                m.ADForestServers = loadForestServersTask.Result;
                var configValue = config.ActiveDirectory.SearchAllForestServers ?? true;
                m.ADSearchAllForestServers = configValue && m.ADForestServers.Count <= ActiveDirectory.MaxForestServerSearch;
            }
            else
            {
                m.ADForestServers = null;
                m.ADSearchAllForestServers = config.ActiveDirectory.SearchAllForestServers ?? true;
            }

            return m;
        }