Exemple #1
0
        public DataServer(params IDataSourceProvider[] providers)
        {
            _sources = new Dictionary <string, IDataSource>(StringComparer.InvariantCultureIgnoreCase);

            Providers = providers;
            Providers.ForEach(p => p.ConfigureDataServer(this));
        }
        public override void Initialize(IApp app)
        {
            base.Initialize(app);

            Providers.ForEach(b =>
            {
                var iface = default(Type);

                if ((iface = b.Type.GetInterface(typeof(ITaskProvider).FullName)) == null)
                {
                    throw new ElideException("Task provider '{0}' doesn't implement ITaskProvider interface.", b.Type);
                }

                ProviderInstances.Add(b.EditorKey, TypeCreator.New <ITaskProvider>(b.Type));
            });
        }
Exemple #3
0
    public string Check(List <string> arguments)
    {
        string      id      = arguments[0];
        string      message = string.Empty;
        List <Unit> allHarvestersAndProviders = new List <Unit>();

        Harvesters.ForEach(h => allHarvestersAndProviders.Add(h));
        Providers.ForEach(p => allHarvestersAndProviders.Add(p));
        Unit foundIIdentifiable = allHarvestersAndProviders.FirstOrDefault(i => i.Id == id);

        if (foundIIdentifiable == null)
        {
            message = $"No element found with id - {id}";
        }
        else
        {
            message = foundIIdentifiable.ToString();
        }
        return(message);
    }
        public DashboardModule(IConfiguration config, ILoggerFactory loggerFactory, PollingService poller, AddressCache addressCache) : base(config, poller)
        {
            AddressCache = addressCache;
            var providers = Settings.Providers;

            if (providers?.Any() != true)
            {
                Providers.Add(new EmptyDataProvider(this, "EmptyDataProvider"));
                return;
            }

            Enabled = true;
            foreach (var p in providers.All)
            {
                p?.Normalize();
            }

            // Add each provider type here
            if (providers.Bosun != null)
            {
                Providers.Add(new BosunDataProvider(this, providers.Bosun));
            }
            if (providers.Orion != null)
            {
                Providers.Add(new OrionDataProvider(this, providers.Orion));
            }
            if (providers.WMI != null && OperatingSystem.IsWindows())
            {
                Providers.Add(new WmiDataProvider(this, providers.WMI));
            }
            if (providers.SignalFx != null)
            {
                Providers.Add(new SignalFxDataProvider(this, providers.SignalFx, loggerFactory.CreateLogger <SignalFxDataProvider>()));
            }

            Providers.ForEach(p => p.TryAddToGlobalPollers());

            AllCategories = Settings.Categories
                            .Select(sc => new DashboardCategory(this, sc))
                            .ToList();
        }
Exemple #5
0
        public ImageProvider ChangeActive(ImageBackgroundType newType, string solution)
        {
            Providers.ForEach(x => x.IsActive = false);
            var ret = Providers.FirstOrDefault(x => x.SolutionConfigFile == solution && x.ProviderType == newType);

            if (!string.IsNullOrEmpty(solution))
            {
                ret = Providers.FirstOrDefault(x => x.SolutionConfigFile == solution);
                if (ret == null)
                {
                    ret = Providers.FirstOrDefault(x =>
                                                   x.SolutionConfigFile == null && x.ProviderType == newType);
                }
            }
            else
            {
                ret = Providers.FirstOrDefault(x =>
                                               x.SolutionConfigFile == null && x.ProviderType == newType);
            }
            ret.IsActive = true;
            return(ret);
        }
        internal IServiceCollection Configure(IServiceCollection services)
        {
            var authSchema = AuthenticationConfig.AuthenticationType == AuthenticationType.Token
                                ? JwtBearerDefaults.AuthenticationScheme
                                : CookieAuthenticationDefaults.AuthenticationScheme;

            var auth     = services.AddAuthentication(authSchema);
            var audience = ApplicationSettings.Name.IsEmpty() ? "XCommon" : ApplicationSettings.Name;

            if (AuthenticationConfig.AuthenticationType == AuthenticationType.Token)
            {
                auth.AddJwtBearer(JwtBearerDefaults.AuthenticationScheme, cfg =>
                {
                    cfg.RequireHttpsMetadata = false;
                    cfg.SaveToken            = true;

                    cfg.TokenValidationParameters = new TokenValidationParameters()
                    {
                        ValidIssuer      = audience,
                        ValidAudience    = audience,
                        IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(AuthenticationConfig.SecurityKey))
                    };
                });
            }

            if (AuthenticationConfig.AuthenticationType == AuthenticationType.Cookie)
            {
                auth.AddCookie(CookieAuthenticationDefaults.AuthenticationScheme, cfg =>
                {
                    cfg.SlidingExpiration = true;
                    cfg.Cookie.HttpOnly   = false;
                    cfg.Cookie.Name       = audience;
                });
            }

            Providers.ForEach(provider => provider.SetUp(auth));
            return(services);
        }
Exemple #7
0
        public DashboardModule(IOptions <DashboardSettings> settings) : base(settings)
        {
            var providers = settings.Value.Providers;

            if (providers?.Any() != true)
            {
                Providers.Add(new EmptyDataProvider(this, "EmptyDataProvider"));
                return;
            }

            Enabled = true;
            foreach (var p in providers.All)
            {
                p?.Normalize();
            }

            // Add each provider type here
            if (providers.Bosun != null)
            {
                Providers.Add(new BosunDataProvider(this, providers.Bosun));
            }
            if (providers.Orion != null)
            {
                Providers.Add(new OrionDataProvider(this, providers.Orion));
            }
            if (providers.WMI != null)
            {
                Providers.Add(new WmiDataProvider(this, providers.WMI));
            }

            Providers.ForEach(p => p.TryAddToGlobalPollers());

            AllCategories = settings.Value.Categories
                            .Select(sc => new DashboardCategory(this, sc))
                            .ToList();
        }
 public void CompleteScenario()
 {
     AtLeastOneScenarioCompleted = true;
     Providers.ForEach(x => x.MonthEndJobIdGenerated = false);
 }
        /// <summary>
        /// Writes the class diagram.
        /// </summary>
        /// <param name="class">The class.</param>
        /// <param name="useIncludes">if set to <c>true</c> [use includes].</param>
        /// <returns></returns>
        internal static string WriteClassDiagram(Models.Class @class, bool useIncludes = false)
        {
            string markup = Templates.Descriptor;

            if (@class.Module)
            {
                markup = markup.Replace(ProtoTypeElement, "").Replace(StereoTypeElement, string.Format(StereoType, "M", "application", "module "));
            }

            else if (@class.Static && @class.Abstract)
            {
                markup = markup.Replace(ProtoTypeElement, "").Replace(StereoTypeElement, string.Format(StereoType, "S", "orchid", "static "));
            }

            else if (@class.Abstract)
            {
                markup = markup.Replace(ProtoTypeElement, "abstract ").Replace(StereoTypeElement, "");
            }

            else
            {
                markup = markup.Replace(ProtoTypeElement, "").Replace(StereoTypeElement, "");
            }

            markup = markup.Replace(TypeElement, "class ").Replace(NameElement, @class.Name);

            markup = markup.Replace(BodyElement, WriteBody(@class));

            if (@class.Implements != null)
            {
                markup += Lollipop(@class.Name, @class.Implements.Name);
            }
            if (@class.Inherits != null)
            {
                markup += Extend(@class.Name, @class.Inherits.Name);
            }

            var aggregates = Aggregations.Distinct().ToList();

            Aggregations.Clear();
            var composites = Compositions.Distinct().ToList();

            Compositions.Clear();
            var consumption = Consumers.Distinct().ToList();

            Consumers.Clear();
            var provision = Providers.Distinct().ToList();

            Providers.Clear();

            aggregates.ForEach((n) =>
            {
                if (useIncludes)
                {
                    markup = ((IncludeDiagram(n).Length > 0) ? IncludeDiagram(n) : "") + markup;
                }
                markup += Aggregate(@class.Name, n);
                Relationships.Add(new Models.Relationship
                {
                    PrincipalObject = @class,
                    AncillaryObject = new Models.Generic {
                        Name = n
                    },
                    Type = Models.RelationshipType.Aggregation
                });
            });

            composites.ForEach((n) =>
            {
                if (useIncludes)
                {
                    markup = ((IncludeDiagram(n).Length > 0) ? IncludeDiagram(n) : "") + markup;
                }
                markup += Composite(@class.Name, n);
                Relationships.Add(new Models.Relationship
                {
                    PrincipalObject = @class,
                    AncillaryObject = new Models.Generic {
                        Name = n
                    },
                    Type = Models.RelationshipType.Composition
                });
            });

            consumption.ForEach((n) =>
            {
                if (useIncludes)
                {
                    markup = ((IncludeDiagram(n).Length > 0) ? IncludeDiagram(n) : "") + markup;
                }
                markup += Consumes(@class.Name, n);
                Relationships.Add(new Models.Relationship
                {
                    PrincipalObject = @class,
                    AncillaryObject = new Models.Generic {
                        Name = n
                    },
                    Type = Models.RelationshipType.Dependency
                });
            });

            Providers.ForEach((n) =>
            {
                if (useIncludes)
                {
                    markup = ((IncludeDiagram(n).Length > 0) ? IncludeDiagram(n) : "") + markup;
                }
                markup += Provides(@class.Name, n);
                Relationships.Add(new Models.Relationship
                {
                    PrincipalObject = @class,
                    AncillaryObject = new Models.Generic {
                        Name = n
                    },
                    Type = Models.RelationshipType.Association
                });
            });

            return(markup);
        }