Пример #1
0
 public AnaForm()
 {
     InitializeComponent();
     _anaFormCon = new AnaFormCon();
     _ozellikAta = new GörselOzellikleriAta();
     compo       = ComponentConfiguration.getInstance();
 }
        private static bool ReadyToInstantiate(ComponentConfiguration config, IReadOnlyList <ComponentEnvironment> instantiatedEnvs)
        {
            var instantiatedConfigs = instantiatedEnvs.Select(e => e.Configuration).ToArray();

            //check input
            foreach (var inputConfig in config.Inputs)
            {
                var inputMeta = config.FindPortMetadata(inputConfig.LocalPort);
                var dataType  = config.FindInputPortDataType(inputMeta, instantiatedConfigs);
                if (dataType is null)
                {
                    return(false);
                }
                //check whether remote is instantiated
                if (!instantiatedEnvs.Any(e => e.Configuration.Id == inputConfig.RemoteId))
                {
                    return(false);
                }
            }
            //check output
            foreach (var remote in instantiatedConfigs)
            {
                foreach (var remoteInputConfig in remote.Inputs.Where(i => i.RemoteId == config.Id))
                {
                    var outputMeta = config.FindPortMetadata(remoteInputConfig.RemotePort);
                    var dataType   = config.FindOutputPortDataType(outputMeta, instantiatedConfigs);
                    if (dataType is null)
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
        private static IBuildQueueJob CreateNewBuildJob(
            ComponentConfiguration componentConfiguration,
            CancellationTokenSource <CompileCancellationToken> cancellationTokenSource,
            ProgressToken progressToken,
            IJobCollection jobCollection)
        {
            IBuildableComponentSubtype buildableComponentSubtype = (IBuildableComponentSubtype)componentConfiguration.ComponentSubtype;

            string outputFilePath = buildableComponentSubtype.GetOutputTopLevelFilePath(componentConfiguration);

            if (jobCollection.JobInProgress(outputFilePath))
            {
                throw new CommandLineOperationException($"Build at {outputFilePath} is already in progress.");
            }

            BuildId         currentBuildId  = buildableComponentSubtype.CreateBuildId(componentConfiguration);
            BuildQueueJobId buildQueueJobId = BuildQueueJobExtension.CreateBuildQueueJobId(currentBuildId);
            IBuildQueueJob  job             = jobCollection.CreateNewJob(
                buildQueueJobId,
                componentConfiguration.ComponentDefinition.ReferencingEnvoy,
                buildableComponentSubtype.XmlName,
                outputFilePath,
                cancellationTokenSource,
                progressToken);

            return(job);
        }
Пример #4
0
        private static ComponentConfiguration ReadConfigurationNode(XElement configurationElement, ComponentDescription description)
        {
            string configName       = configurationElement.Attribute("name").Value;
            string configValue      = configurationElement.Attribute("value").Value;
            string configImplements = null;

            if (configurationElement.Attribute("implements") != null)
            {
                configImplements = configurationElement.Attribute("implements").Value;
            }

            ComponentConfiguration newConfiguration = new ComponentConfiguration(configImplements, configName, new Dictionary <string, PropertyUnion>());

            string[] setters = configValue.Split(new char[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string setter in setters)
            {
                string[] tempSplit    = setter.Split(':');
                string   propertyName = tempSplit[0];
                string   value        = tempSplit[1];

                // convert from string to proper type
                foreach (ComponentProperty property in description.Properties)
                {
                    if (propertyName == property.Name)
                    {
                        newConfiguration.Setters.Add(property.SerializedName, new PropertyUnion(value, property.Type));
                        break;
                    }
                }
            }
            return(newConfiguration);
        }
        public static TypeDescriptionComponentType GetComponentType(this ComponentConfiguration configuration, ComponentDescription description)
        {
            var collection     = !string.IsNullOrEmpty(description.Metadata.ImplementSet) ? new Uri(description.Metadata.ImplementSet) : ComponentType.UnknownCollection;
            var collectionItem = !string.IsNullOrEmpty(description.Metadata.ImplementItem) ? description.Metadata.ImplementItem : description.ComponentName;

            return(new TypeDescriptionComponentType(description.Metadata.GUID, collection, configuration.ImplementationName ?? collectionItem ?? description.ComponentName));
        }
Пример #6
0
 private static void HandleValue(string key, ComponentConfiguration config, Dictionary <string, object> data)
 {
     HandleTotalValue(key, config, data);
     foreach (var dataItem in data)
     {
         var itemKey = dataItem.Key;
         if (config.ComponentItems.ContainsKey(itemKey))
         {
             var configItem = config.ComponentItems[itemKey];
             var db         = server.GetDatabase(key);
             var collection = db.GetCollection(itemKey);
             var doc        = new BsonDocument().Add("V", BsonValue.Create(dataItem.Value));
             doc.SetDocumentId(DateTime.Now.ToUniversalTime());
             if (configItem.ItemValueType == ItemValueType.TextValue)
             {
                 collection.RemoveAll();
                 collection.Insert(doc);
             }
             else if (configItem.ItemValueType == ItemValueType.ExpressionValue)
             {
             }
             else
             {
                 collection.Insert(doc);
             }
         }
     }
 }
Пример #7
0
        public void Generate(ComponentDescription description, ComponentConfiguration configuration, IResourceProvider resourceProvider, PreviewGenerationOptions options, Stream input, Stream output, SourceFileType sourceType)
        {
            switch (Renderer)
            {
            case PngRenderer.Skia:
            {
                var drawingContext = PreviewRenderer.RenderPreview(size => new SkiaDrawingContext((int)Math.Ceiling(size.Width), (int)Math.Ceiling(size.Height), SKColors.White, (float)options.Scale),
                                                                   description,
                                                                   options);
                drawingContext.WriteAsPng(output);
                break;
            }

            case PngRenderer.ImageSharp:
            {
                var drawingContext = PreviewRenderer.RenderPreview(size => new ImageSharpDrawingContext((int)Math.Ceiling(size.Width), (int)Math.Ceiling(size.Height), SixLabors.ImageSharp.Color.White),
                                                                   description,
                                                                   options);
                drawingContext.WriteAsPng(output);
                break;
            }

            default:
                throw new InvalidOperationException($"Unknown renderer: {Renderer}");
            }
        }
Пример #8
0
        public void InitializeComponent(Component component, ComponentConfiguration configuration)
        {
            if (component == null)
            {
                throw new ArgumentNullException(nameof(component));
            }
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            var context = new PythonDictionary
            {
                ["component_uid"] = component.Uid
            };

            if (!string.IsNullOrEmpty(configuration.Script))
            {
                // Having a script in place always overrides the logic and adapter configuration.
                SetupComponentBasedOnScript(component, configuration, context);
                return;
            }

            SetupComponentBasedOnPackages(component, configuration, context);
        }
Пример #9
0
        private void btnImplementationsNew_Click(object sender, RoutedEventArgs e)
        {
            winNewComponentImplementation newComImplementation = new winNewComponentImplementation();

            newComImplementation.Owner             = this;
            newComImplementation.ImplementationSet = cbxImplementationsSet.Text;
            if (newComImplementation.ShowDialog() == true)
            {
                if (cbxImplementationsSet.SelectedItem == null)
                {
                    ComponentRepresentations.Add(new ImplementationConversionCollection()
                    {
                        ImplementationSet = cbxImplementationsSet.Text
                    });
                    cbxImplementationsSet.SelectedItem = ComponentRepresentations.Last();
                }

                ImplementationConversion conversion = newComImplementation.GetChosenComponent();

                // Don't allow duplicates
                if ((cbxImplementationsSet.SelectedItem as ImplementationConversionCollection).Items.FirstOrDefault(item => item.ImplementationName == conversion.ImplementationName) != null)
                {
                    TaskDialogInterop.TaskDialog.ShowMessage(this, "The item could not be added because it is already present.\r\n\r\nYou can add this item again if you delete its current representation first.", "Could Not Add Item", TaskDialogInterop.TaskDialogCommonButtons.Close, TaskDialogInterop.VistaTaskDialogIcon.Warning);
                }
                else
                {
                    (cbxImplementationsSet.SelectedItem as ImplementationConversionCollection).Items.Add(newComImplementation.GetChosenComponent());

                    // Add to ComponentHelper's list of conversions
                    ComponentDescription   description      = ComponentHelper.FindDescription(conversion.ToGUID);
                    ComponentConfiguration theConfiguration = description.Metadata.Configurations.FirstOrDefault(check => check.Name == conversion.ToConfiguration);
                    ComponentHelper.SetStandardComponent(cbxImplementationsSet.Text, conversion.ImplementationName, description, theConfiguration);
                }
            }
        }
Пример #10
0
        private RunComponentsResult RunComponents(IEnumerable <IHostableComponentFactory> factories, IEnumerable <Assembly> componentsAssemblies, IConfiguration configuration, CancellationToken cancellationToken)
        {
            var cfg = ComponentConfiguration.Create(configuration);

            this.SetSharedLibrariesConfiguration(configuration, componentsAssemblies);

            var componentLoader = new ComponentAssemblyLoader(this.loader);

            var components = factories
                             .Select(f => f.CreateComponent(componentLoader, cfg))
                             .ToArray();

            var task = Task.Factory.StartNew(
                () =>
            {
                foreach (var component in components)
                {
                    component.Start();         // TODO: should pass the cancellationToken
                }
            },
                cancellationToken,
                TaskCreationOptions.LongRunning,
                TaskScheduler.Default);

            return(new RunComponentsResult
            {
                StartTask = task,
                Components = components
            });
        }
Пример #11
0
        private static ComponentContainer ImportExternalComponents(ComponentConfiguration configuration)
        {
            if (!configuration.IncludeComponents)
            {
                return(new ComponentContainer());
            }
            try
            {
                var importer   = new ComponentImporter();
                var components = importer.ImportComponents(configuration.ComponentPath);

                Console.WriteLine("Components:");
                Console.WriteLine("  Found {0} visitors.", components.AstVisitors.Count);
                Console.WriteLine("  Found {0} block analyzers.", components.BlockAnalyzers.Count);
                Console.WriteLine("  Found {0} reporters.", components.VulnerabilityReporters.Count);
                Console.WriteLine("  Found {0} taint providers.", components.TaintProviders.Count);

                return(components);
            }
            catch (DirectoryNotFoundException)
            {
                Console.WriteLine("EXTERNAL COMPONENTS ERROR: ");
                Console.WriteLine("Could not find specified component folder ({0}). Please make sure to set the correct folder in the config file.", configuration.ComponentPath);
                Environment.Exit(1);
                return(null);
            }
        }
Пример #12
0
        private void ReadDeclarationSection(XElement declaration, XNamespace ns, LoadContext lc, ComponentDescription description)
        {
            IXmlLineInfo line = declaration as IXmlLineInfo;

            // Read meta nodes
            foreach (var metaElement in declaration.Elements(ns + "meta"))
            {
                ReadMetaNode(metaElement, lc, description);
            }

            // Check all required metadata was set
            if (String.IsNullOrEmpty(description.ComponentName))
            {
                lc.Errors.Add(new LoadError(lc.FileName, line.LineNumber, line.LinePosition, LoadErrorCategory.Error,
                                            "Component name is required"));
            }

            //Read properties
            List <ComponentProperty> properties = new List <ComponentProperty>();

            foreach (var propertyElement in declaration.Elements(ns + "property"))
            {
                ScanPropertyNode(propertyElement, lc);
            }
            foreach (var propertyElement in declaration.Elements(ns + "property"))
            {
                ComponentProperty property = ReadPropertyNode(propertyElement, lc);
                properties.Add(property);
            }
            description.Properties = properties.ToArray();

            // Read flags
            List <Conditional <FlagOptions> > flagOptions = new List <Conditional <FlagOptions> >();

            foreach (var flagGroup in declaration.Elements(ns + "flags"))
            {
                var flags = ReadFlagOptionNode(flagGroup, lc);
                if (flags != null)
                {
                    flagOptions.Add(flags);
                }
            }
            description.Flags = flagOptions.ToArray();

            // Read configurations
            var componentConfigurations = new List <ComponentConfiguration>();
            var configurations          = declaration.Element(ns + "configurations");

            if (configurations != null)
            {
                foreach (var node in configurations.Elements(ns + "configuration"))
                {
                    ComponentConfiguration newConfiguration = ReadConfigurationNode(node, description);

                    componentConfigurations.Add(newConfiguration);
                }
            }
            description.Metadata.Configurations.AddRange(componentConfigurations);
        }
Пример #13
0
        public void Generate(ComponentDescription description, ComponentConfiguration configuration, IResourceProvider resourceProvider, PreviewGenerationOptions options, Stream input, Stream output, SourceFileType sourceType)
        {
            var drawingContext = PreviewRenderer.RenderPreview(size => new SkiaDrawingContext((int)Math.Ceiling(size.Width), (int)Math.Ceiling(size.Height), SKColors.White),
                                                               description,
                                                               options);

            drawingContext.WriteAsPng(output);
        }
 public ConfigurationDefinition(DefinitionMetadata metadata,
                                ComponentDescription componentDescription,
                                ComponentConfiguration configuration)
 {
     Metadata             = metadata;
     ComponentDescription = componentDescription;
     Configuration        = configuration;
 }
 private void TakimAnaForm_Load(object sender, EventArgs e)
 {
     compo = ComponentConfiguration.getInstance();
     _ozellikAta.bilesenlereOzellikAta(this, compo);
     comboLig = _tkimFormCon.comboLigDoldur(comboLig);
     dtGridYenile(txtArama.Text);
     dtGridTakim.Columns[0].Visible = false;
 }
Пример #16
0
        public void Generate(ComponentDescription description, ComponentConfiguration configuration, IResourceProvider resourceProvider, PreviewGenerationOptions options, Stream input, Stream output, SourceFileType sourceType)
        {
            var drawingContext = PreviewRenderer.RenderPreview(size => new SvgDrawingContext(Math.Ceiling(size.Width), Math.Ceiling(size.Height), output),
                                                               description,
                                                               options);

            drawingContext.Dispose();
        }
Пример #17
0
        /// <summary>
        /// Adds the application configuration.
        /// </summary>
        /// <param name="applicationCode">The application code.</param>
        /// <param name="enableOmsConfig">if set to <c>true</c> [enable oms configuration].</param>
        /// <returns></returns>
        public DataResponse <string> AddApplicationConfiguration(string applicationCode, bool enableOmsConfig)
        {
            try
            {
                List <Component> componentList = _context.Components.ToList();
                foreach (Component item in componentList)
                {
                    ComponentConfiguration appComponentConfiguration = _context.ComponentConfigurations.Where(x => x.ApplicationCode == applicationCode && x.ComponentId == item.ComponentId).FirstOrDefault();
                    if (appComponentConfiguration != null)
                    {
                        appComponentConfiguration.IsOmsLog     = enableOmsConfig;
                        appComponentConfiguration.ModifiedDate = DateTime.UtcNow;
                        appComponentConfiguration.ModifiedBy   = Guid.Parse("200EDCFA-8FF1-4837-91B1-7D5F967F5129");
                        _context.SaveChanges();
                    }
                    else
                    {
                        ComponentConfiguration componentConfig = new ComponentConfiguration()
                        {
                            ApplicationCode   = applicationCode,
                            ComponentConfigId = Guid.NewGuid(),
                            ComponentId       = item.ComponentId,
                            CreatedDate       = DateTime.UtcNow,
                            Debug             = false,
                            Error             = true,
                            Fatal             = true,
                            Info           = true,
                            IsOmsLog       = enableOmsConfig,
                            KeyName        = $"{item.Name.Trim()}Key",
                            Warn           = true,
                            ModifiedDate   = DateTime.UtcNow,
                            CreatedBy      = Guid.Parse("200EDCFA-8FF1-4837-91B1-7D5F967F5129"),
                            ModifiedBy     = Guid.Parse("200EDCFA-8FF1-4837-91B1-7D5F967F5129"),
                            SubscribeError = true,
                            SubscribeDebug = true,
                            CronJobDebug   = false,
                            CronJobError   = true,
                            CronJobFatal   = true,
                            CronJobInfo    = true,
                            CronJobWarn    = true,
                        };
                        _context.Add(componentConfig);
                        _context.SaveChanges();
                    }
                }

                return(new DataResponse <string>()
                {
                    Status = DataResponseStatus.Success,
                    Data = string.Empty
                });
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #18
0
        private void SetupComponentBasedOnScript(Component component, ComponentConfiguration configuration, IDictionary <object, object> context)
        {
            var logic = new ScriptComponentLogic(_pythonScriptHostFactoryService, _componentRegistryService, _scriptComponentLogicLogger);

            logic.Compile(component.Uid, configuration.Script);
            logic.AddToWirehomeWrapper("context", context);

            component.SetLogic(logic);
        }
 public void Configure(IComponentSchema schema, ComponentConfiguration configuration)
 {
     foreach (var automation in configuration.Automations.OfType<EventConfiguration>())
     {
         schema.AddAutomation(new EventAutomationSettings(
             automation.EventBinding,
             new CommandAutomationSettings(automation.CommandBinding)));
     }
 }
Пример #20
0
 private void HakemAnaForm_Load(object sender, EventArgs e)
 {
     compo = ComponentConfiguration.getInstance();
     _ozellikAta.bilesenlereOzellikAta(this, compo);
     defaultDegerleriAta();
     comboOrtaHakemYenile();
     dtGridYenile(txtArama.Text);
     dtGridHakem.Columns[0].Visible = false;
 }
Пример #21
0
        public void Generate(ComponentDescription description, ComponentConfiguration configuration, IResourceProvider resourceProvider, PreviewGenerationOptions options, Stream input, Stream output, SourceFileType sourceType)
        {
            ComponentCompileResult result = compiler.Compile(input, output, resourceProvider, new CompileOptions());

            if (!result.Success)
            {
                throw new Exception();
            }
        }
Пример #22
0
        private Config(ConfigurationMutable config)
        {
            Preconditions.NotNull(config, "config");

            PHPSettings = new PHPConfiguration(config.PHPConfiguration.PHPPath, config.PHPConfiguration.PHPParsePath, config.PHPConfiguration.PHPExts);
            GraphSettings = new GraphConfiguration(config.GraphConfiguration.GraphvizPath, config.GraphConfiguration.GraphvizArguments);
            ComponentSettings = new ComponentConfiguration(config.ComponentSettings.ComponentFolder, config.ComponentSettings.IncludeComponents);
            FuncSpecSettings = new FuncSpecConfiguration(config.FuncSpecSettings.PHPSpecs, config.FuncSpecSettings.ExtensionSpecs);
        }
Пример #23
0
        public static Component Create(string data)
        {
            // Load data
            data = data.Replace(",", "\r\n");
            Dictionary <string, object> properties = ComponentDataString.ConvertToDictionary(data);

            // Find component description
            ComponentDescription description;

            if (properties.ContainsKey("@rid"))
            {
                description = ComponentHelper.FindDescriptionByRuntimeID(int.Parse(properties["@rid"].ToString()));
            }
            else if (properties.ContainsKey("@guid"))
            {
                description = ComponentHelper.FindDescription(new Guid(properties["@guid"].ToString()));
            }
            else
            {
                description = ComponentHelper.FindDescription(properties["@type"].ToString());
            }
            Component newComponent = new Component(description);

            // Apply configuration
            if (properties.ContainsKey("@config"))
            {
                ComponentConfiguration configuration = description.Metadata.Configurations.FirstOrDefault(item => item.Name == properties["@config"].ToString());
                if (configuration != null)
                {
                    foreach (var setter in configuration.Setters)
                    {
                        if (!properties.ContainsKey(setter.Key))
                        {
                            properties.Add(setter.Key, setter.Value);
                        }
                        else
                        {
                            properties[setter.Key] = setter.Value;
                        }
                    }
                }
            }

            // Load other properties
            newComponent.Deserialize(properties);

            newComponent.ResetConnections();

            if (newComponent.Editor != null)
            {
                newComponent.Editor.Update();
            }

            return(newComponent);
        }
 private void AnaForm_Load(object sender, EventArgs e)
 {
     config = ComponentConfiguration.configureGetir();
     foreach (Control nesne in this.Controls)
     {
         if ((nesne) is Button)
         {
             nesne.Font = config.getButonFont;
         }
     }
 }
Пример #25
0
        private void HakemForm_Load(object sender, EventArgs e)
        {
            config = ComponentConfiguration.configureGetir();

            componentAyarla(panelListele.Controls);
            componentAyarla(panelHakemEkle.Controls);
            componentAyarla(panelHakemGuncelle.Controls);

            panelHakemEkle.BackColor     = config.getPanelBgcolorTip2;
            panelHakemGuncelle.BackColor = config.getPanelBgcolorTip1;
        }
Пример #26
0
        public void WriteComponentConfiguration(string uid, ComponentConfiguration configuration)
        {
            if (uid == null)
            {
                throw new ArgumentNullException(nameof(uid));
            }
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            _storageService.Write(configuration, ComponentsDirectory, uid, DefaultFileNames.Configuration);
        }
        protected override void visitComponentConfiguration(ComponentConfiguration configuration)
        {
            writer.Append(KeywordEnum.FOR.ToString()).Append(' ');
            output.writeComponentSpecification(configuration.ComponentSpecification);
            writer.Indent();

            bool hasBindingIndication = false;

            if (configuration.EntityAspect != null)
            {
                hasBindingIndication = true;
                writer.NewLine().Append(KeywordEnum.USE.ToString()).Append(' ');
                writer.Append(configuration.EntityAspect.ToString());
            }

            if (configuration.GenericMap.Count != 0)
            {
                hasBindingIndication = true;
                writer.NewLine();
                writer.Append(KeywordEnum.GENERIC.ToString()).Append(KeywordEnum.MAP.ToString()).Append(" (").NewLine();
                writer.Indent().BeginAlign();
                output.getMiscellaneousElementOutput().genericMap(configuration.GenericMap);
                writer.EndAlign().Dedent();
                writer.Append(")");
            }

            if (configuration.PortMap.Count != 0)
            {
                hasBindingIndication = true;
                writer.NewLine();
                writer.Append(KeywordEnum.PORT.ToString()).Append(KeywordEnum.MAP.ToString()).Append(" (").NewLine();
                writer.Indent().BeginAlign();
                output.getMiscellaneousElementOutput().portMap(configuration.PortMap);
                writer.EndAlign().Dedent();
                writer.Append(")");
            }

            if (hasBindingIndication)
            {
                writer.Append(";");
            }

            writer.NewLine();

            if (configuration.BlockConfiguration != null)
            {
                visit(configuration.BlockConfiguration);
            }
            writer.Dedent().Append(KeywordEnum.END.ToString()).Append(KeywordEnum.FOR.ToString());
            writer.Append(';').NewLine();
        }
Пример #28
0
 private bool IsItemUsed(ComponentDescription description, ComponentConfiguration configuration)
 {
     foreach (Category category in lbxCategories.Items)
     {
         foreach (CategoryItem item in category.Items)
         {
             if (item.Description == description && item.Configuration == configuration)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Пример #29
0
 /// <summary>
 /// Constructs an instance of a <see cref="CommandLineBuildJobMonitor"/>. Creates a build job for a component build and
 /// begins monitoring the job collection for child jobs to be added.
 /// </summary>
 /// <param name="componentConfiguration">The <see cref="ComponentConfiguration"/> for the component build being monitored.</param>
 /// <param name="progressToken">Progress token to create the build job with.</param>
 /// <param name="cancellationTokenSource">Cancellation token source to create the build job with.</param>
 public CommandLineBuildJobMonitor(
     ComponentConfiguration componentConfiguration,
     ProgressToken progressToken,
     CancellationTokenSource <CompileCancellationToken> cancellationTokenSource)
 {
     _jobFinishedCompletionSource = new TaskCompletionSource <object>();
     _jobCollection = componentConfiguration.Host.GetSharedExportedValue <IJobCollection>();
     _jobCollection.CollectionChanged += JobCollectionOnCollectionChanged;
     _rootJob = CreateNewBuildJob(componentConfiguration, cancellationTokenSource, progressToken, _jobCollection);
     if (_rootJob == null)
     {
         throw new CommandLineOperationException(LocalizedStrings.BuildComponentTool_FailToStartBuildErrorMessage);
     }
     SubscribeToRootJobFinishedEvent();
 }
Пример #30
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        internal static ComponentConfiguration Get(int ComponentConfigId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select ComponentConfigId, CreateBy, ModifyTime, ModifyBy, IsDelete, ComponentId, IsDebug, Environment, Content, Enable, Signature, Version, CreateTime  ");
            strSql.Append("  from ComponentConfiguration ");
            strSql.Append(" where ComponentConfigId=@ComponentConfigId");
            List <DbParameter> parameters = new List <DbParameter>();

            ComponentConfiguration r = new ComponentConfiguration();

            r = _dalService.GetDataByReader <ComponentConfiguration>(parameters, strSql.ToString(), delegate(DbDataReader dr) {
                r = null;
                if (dr.Read())
                {
                    r = new ComponentConfiguration()
                    {
                        ComponentConfigId = int.Parse(dr["ComponentConfigId"].ToString()),

                        CreateBy = int.Parse(dr["CreateBy"].ToString()),

                        ModifyTime = DateTime.Parse(dr["ModifyTime"].ToString()),

                        ModifyBy = int.Parse(dr["ModifyBy"].ToString()),


                        IsDelete    = Boolean.Parse(dr["IsDelete"].ToString()),
                        ComponentId = int.Parse(dr["ComponentId"].ToString()),


                        IsDebug     = Boolean.Parse(dr["IsDebug"].ToString()),
                        Environment = int.Parse(dr["Environment"].ToString()),

                        Content = dr["Content"].ToString(),


                        Enable    = Boolean.Parse(dr["Enable"].ToString()),
                        Signature = dr["Signature"].ToString(),

                        Version = int.Parse(dr["Version"].ToString()),

                        CreateTime = DateTime.Parse(dr["CreateTime"].ToString()),
                    };
                }
                return(r);
            });
            return(r);
        }
Пример #31
0
        public void InitializeComponent(Component component, ComponentConfiguration configuration)
        {
            if (component == null)
            {
                throw new ArgumentNullException(nameof(component));
            }
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            InitializeSettings(component);
            InitializeLogic(component, configuration.Logic);

            component.ProcessMessage(new WirehomeDictionary().WithType(ControlType.Initialize));
        }
Пример #32
0
 private static void HandleTotalValue(string key, ComponentConfiguration config, Dictionary <string, object> rawData)
 {
     if (!dataCache.ContainsKey(key))
     {
         var cache = new Dictionary <string, long>();
         foreach (var k in new List <string>(rawData.Keys))
         {
             if (config.ComponentItems.ContainsKey(k))
             {
                 var configItem = config.ComponentItems[k];
                 if (configItem.ItemValueType == ItemValueType.TotalValue)
                 {
                     var current = Convert.ToInt64(rawData[k]);
                     cache.Add(k, current);
                     rawData[k] = 0;
                 }
             }
         }
         dataCache.Add(key, cache);
     }
     else
     {
         var cache = dataCache[key];
         foreach (var k in new List <string>(rawData.Keys))
         {
             if (config.ComponentItems.ContainsKey(k))
             {
                 var configItem = config.ComponentItems[k];
                 if (configItem.ItemValueType == ItemValueType.TotalValue)
                 {
                     var current = Convert.ToInt64(rawData[k]);
                     if (cache.ContainsKey(k))
                     {
                         rawData[k] = Math.Max(current - cache[k], 0);
                         cache[k]   = current;
                     }
                     else
                     {
                         cache.Add(k, current);
                         rawData[k] = 0;
                     }
                 }
             }
         }
     }
 }
Пример #33
0
        private static ComponentContainer ImportExternalComponents(ComponentConfiguration configuration)
        {
            if (!configuration.IncludeComponents) {
                return new ComponentContainer ();
            }
            try {
                var importer = new ComponentImporter ();
                var components = importer.ImportComponents (configuration.ComponentPath);

                Console.WriteLine ("Components:");
                Console.WriteLine ("  Found " + components.AstVisitors.Count + " visitors.");
                Console.WriteLine ("  Found " + components.BlockAnalyzers.Count + " block analyzers.");
                Console.WriteLine ("  Found " + components.VulnerabilityReporters.Count + " reporters.");

                return components;
            } catch (DirectoryNotFoundException) {
                Console.WriteLine ("EXTERNAL COMPONENTS ERROR: ");
                Console.WriteLine ("Could not find specified component folder (" + configuration.ComponentPath + "). Please make sure to set the correct folder in the config file.");
                Environment.Exit (1);
                return null;
            }
        }