Beispiel #1
0
        public void TryParseMacAddressFromConfigString(SourceConfig config)
        {
            if (string.IsNullOrEmpty(config.DeviceAddressString))
            {
                return;
            }

            if (config.DeviceAddressString.Length != 6)
            {
                return;
            }

            try
            {
                _usbExtenderMacAddress = new byte[3];

                for (int i = 0; i < 6; i = i + 2)
                {
                    var byteString = config.DeviceAddressString.Substring(i, 2);

                    var b = Byte.Parse(byteString, NumberStyles.HexNumber);

                    _usbExtenderMacAddress[i / 2] = b;
                }
            }
            catch (Exception e)
            {
                CloudLog.Exception(e);
            }
        }
Beispiel #2
0
        public List <PropertyModel> getPropertyList(DbContextEx db, ObjectModel obj)
        {
            PropertyItem exeCode = SourceConfig.GetProperty(db.builder, db);

            List <PropertyModel> popList = null;

            string sql = null;

            if (obj.Type < 3)
            {
                sql = exeCode.Table.Replace("{ID}", obj.ID).Replace("{NAME}", obj.Name);
            }
            else
            {
                sql = exeCode.StoredProcedure.Replace("{ID}", obj.ID).Replace("{NAME}", obj.Name).Trim();

                if (sql[0] == '@')
                {
                    popList = Weed.Addin.Eval <IParamsBuilder>(sql.Substring(1)).GetParams(obj.Name, db);
                }
            }

            if (popList == null)
            {
                popList = db.sql(sql).getList(new PropertyModel());
            }


            return(popList);
        }
Beispiel #3
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// The UpdateConfigs method processes the source file and updates the various config
        /// files
        /// </summary>
        /// <history>
        ///     [cnurse]	08/03/2007  created
        /// </history>
        /// -----------------------------------------------------------------------------
        public void UpdateConfigs()
        {
            var nodes = SourceConfig.SelectNodes("/configuration/nodes");

            if (nodes != null)
            {
                foreach (XmlNode configNode in nodes)
                {
                    Debug.Assert(configNode.Attributes != null, "configNode.Attributes != null");

                    //Attempt to load TargetFile property from configFile Atribute
                    TargetFileName = configNode.Attributes["configfile"].Value;
                    string targetProductName = "";
                    if (configNode.Attributes["productName"] != null)
                    {
                        targetProductName = configNode.Attributes["productName"].Value;
                    }
                    bool isAppliedToProduct;
                    TargetConfig = Config.Load(TargetFileName);
                    if (String.IsNullOrEmpty(targetProductName) || targetProductName == "All")
                    {
                        isAppliedToProduct = true;
                    }
                    else
                    {
                        isAppliedToProduct = DotNetNukeContext.Current.Application.ApplyToProduct(targetProductName);
                    }
                    //The nodes definition is not correct so skip changes
                    if (TargetConfig != null && isAppliedToProduct)
                    {
                        ProcessNodes(configNode.SelectNodes("node"), true);
                    }
                }
            }
        }
Beispiel #4
0
 protected ASource(DisplayBase display, SourceConfig config, ISourceDevice device)
     : base(display, config.DisplayInput, config.SourceType, device)
 {
     _config          = config;
     Name             = config.Name;
     IconName         = config.Icon.ToString();
     AvailabilityType = config.AvailabilityType;
 }
Beispiel #5
0
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// The UpdateConfig method processes the source file and updates the Target
 /// Config Xml Document.
 /// </summary>
 /// <param name="target">An Xml Document represent the Target Xml File</param>
 /// <history>
 ///     [cnurse]	08/04/2007  created
 /// </history>
 /// -----------------------------------------------------------------------------
 public void UpdateConfig(XmlDocument target)
 {
     TargetConfig = target;
     if (TargetConfig != null)
     {
         ProcessNodes(SourceConfig.SelectNodes("/configuration/nodes/node"), false);
     }
 }
Beispiel #6
0
        public static async Task ProcessSource(SourceConfig sourceConfig, CosmosClient dbClient, HarvesterSettings harvesterSettings, IConfiguration configuration, ILogger logger)
        {
            logger.LogInformation($"Config entry to be processed: {sourceConfig}");

            var sourceTypeName = ("source" + sourceConfig.Id).ToLowerInvariant();
            var sourceType     = Assembly.GetExecutingAssembly().GetTypes().FirstOrDefault(t => t.IsClass && t.Name.ToLowerInvariant() == sourceTypeName);

            if (sourceType == null)
            {
                logger.LogCritical($"Failed to find type for source ID '{sourceConfig.Id}'. Used '{sourceTypeName}' to scan for it.");
                return;
            }

            var source = (SourceBase)Activator.CreateInstance(sourceType, harvesterSettings, logger);

            if (source == null)
            {
                logger.LogCritical($"Failed to create instance of source for type '{sourceType}'");
                return;
            }

            SourceData sourceData = null;

            try
            {
                sourceData = await source.GetData();
            }
            catch (Exception ex)
            {
                logger.LogCritical($"Error getting source data: {ex}");
            }


            // Update source configuration.
            sourceConfig.LastUpdateUtc = DateTimeOffset.UtcNow;
            var      sourceConfigCronExpression = CronExpression.Parse(sourceConfig.CronExecutionTime);
            var      lastUpdateUtc    = sourceConfig.LastUpdateUtc != null ? sourceConfig.LastUpdateUtc.Value.UtcDateTime : DateTimeOffset.UtcNow.UtcDateTime;
            DateTime?nextExecutionUtc = sourceConfigCronExpression.GetNextOccurrence(lastUpdateUtc);

            sourceConfig.NextExecutionDueUtc = sourceConfigCronExpression.GetNextOccurrence(sourceConfig.LastUpdateUtc.Value.UtcDateTime);
            SaveSourceConfig(sourceConfig, logger);

            if (sourceData == null)
            {
                return;
            }

            // Save to database.
            if (dbClient != null)
            {
                var container = dbClient.GetContainer("dashboard", "sourcedata");
                await container.UpsertItemAsync(sourceData);
            }
            else
            {
                logger.LogWarning("CosmosClient is NULL - not saving source data!");
            }
        }
Beispiel #7
0
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// The UpdateConfig method processes the source file and updates the Target
 /// Config file.
 /// </summary>
 /// <param name="target">An Xml Document represent the Target Xml File</param>
 /// <param name="fileName">The fileName for the Target Xml File - relative to the webroot</param>
 /// <history>
 ///     [cnurse]	08/04/2007  created
 /// </history>
 /// -----------------------------------------------------------------------------
 public void UpdateConfig(XmlDocument target, string fileName)
 {
     TargetFileName = fileName;
     TargetConfig   = target;
     if (TargetConfig != null)
     {
         ProcessNodes(SourceConfig.SelectNodes("/configuration/nodes/node"), true);
     }
 }
        private void loadFromSourceConfig()
        {
            SourceConfig sourceConf = new SourceConfig(inputLink, folderPath);

            this.nextPageKey        = new Queue <KeyValuePair <string, int> >(sourceConf.returnNextPageIdentifiers(sourceConf.getHost()));
            this.homePageKey        = new Queue <KeyValuePair <string, int> >(sourceConf.returnHomePageIdentifiers(sourceConf.getHost()));
            this.imgPageKey         = new Queue <KeyValuePair <string, int> >(sourceConf.returnImageSourceIdentifiers(sourceConf.getHost()));
            this.chapterPageKey     = new Queue <KeyValuePair <string, int> >(sourceConf.returnChapterPageIdentifiers(sourceConf.getHost()));
            this.nextChapterPageKey = new Queue <KeyValuePair <string, int> >(sourceConf.returnNextChapterPageIdentifiers(sourceConf.getHost()));
            return;
        }
Beispiel #9
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// The UpdateConfig method processes the source file and updates the Target
        /// Config Xml Document.
        /// </summary>
        /// <param name="target">An Xml Document represent the Target Xml File</param>
        /// -----------------------------------------------------------------------------
        public void UpdateConfig(XmlDocument target)
        {
            var changedAnyNodes = false;

            TargetConfig = target;
            if (TargetConfig != null)
            {
                changedAnyNodes = ProcessNodes(SourceConfig.SelectNodes("/configuration/nodes/node"), false);
            }

            ConfigUpdateChangedNodes = changedAnyNodes;
        }
Beispiel #10
0
 public void UpdateConfigs()
 {
     foreach (XmlNode configNode in SourceConfig.SelectNodes("/configuration/nodes"))
     {
         _TargetFileName = configNode.Attributes["configfile"].Value;
         TargetConfig    = Config.Load(TargetFileName);
         if (TargetConfig != null)
         {
             ProcessNodes(configNode.SelectNodes("node"), true);
         }
     }
 }
Beispiel #11
0
        public void UpdateConfigs(bool autoSave)
        {
            var changedAnyNodes = false;
            var nodes           = SourceConfig.SelectNodes("/configuration/nodes");

            if (nodes != null)
            {
                foreach (XmlNode configNode in nodes)
                {
                    Debug.Assert(configNode.Attributes != null, "configNode.Attributes != null");

                    //Attempt to load TargetFile property from configFile Atribute
                    TargetFileName = configNode.Attributes["configfile"].Value;
                    string targetProductName = "";
                    if (configNode.Attributes["productName"] != null)
                    {
                        targetProductName = configNode.Attributes["productName"].Value;
                    }
                    bool isAppliedToProduct;

                    if (!File.Exists(Globals.ApplicationMapPath + "\\" + TargetFileName))
                    {
                        DnnInstallLogger.InstallLogInfo($"Target File {TargetFileName} doesn't exist, ignore the merge process");
                        return;
                    }

                    TargetConfig = Config.Load(TargetFileName);
                    if (String.IsNullOrEmpty(targetProductName) || targetProductName == "All")
                    {
                        isAppliedToProduct = true;
                    }
                    else
                    {
                        isAppliedToProduct = DotNetNukeContext.Current.Application.ApplyToProduct(targetProductName);
                    }
                    //The nodes definition is not correct so skip changes
                    if (TargetConfig != null && isAppliedToProduct)
                    {
                        var changedNodes = ProcessNodes(configNode.SelectNodes("node"), autoSave);
                        changedAnyNodes = changedAnyNodes || changedNodes;
                        if (!autoSave && changedNodes)
                        {
                            PendingDocuments.Add(TargetFileName, TargetConfig);
                        }
                    }
                }
            }

            ConfigUpdateChangedNodes = changedAnyNodes;
        }
Beispiel #12
0
        public void Record(string sourceName, string channel, string title, string mediaName)
        {
            Debug.WriteLine("RecorderControlService.Record " + sourceName + ", " + channel + ", " + title + ", " + mediaName);
            SourceConfig source = SourcesConfig.FindSource(sourceName);

            if (source != null)
            {
                SourceRecorder sourceRecorder = new SourceRecorder(source, channel, title, mediaName);
                if (sourceRecorder != null)
                {
                    sourceRecorder.Record();
                }
            }
        }
 public override bool Equals(object obj)
 {
     //Check for null and compare run-time types.
     if ((obj == null) || !this.GetType().Equals(obj.GetType()))
     {
         return(false);
     }
     else
     {
         LogTriggerConfig p = (LogTriggerConfig)obj;
         return(SourceConfig.Equals(p.SourceConfig) && JobConfig.Equals(p.JobConfig) &&
                (FunctionParameter.Count == p.FunctionParameter.Count && !FunctionParameter.Except(p.FunctionParameter).Any()) &&
                LogConfig.Equals(p.LogConfig) && Enable == p.Enable);
     }
 }
    static void Main()
    {
        XmlSerializer ser1  = new XmlSerializer(typeof(SourceConfig));
        SourceConfig  list1 = new SourceConfig();

        list1.Description = "Test Desc";
        list1.HelpLink    = String.Empty;
        list1.Parameters.Add(new ParamDetails {
            name = "param1", value = "1"
        });
        list1.Parameters.Add(new ParamDetails {
            name = "param2", value = "2"
        });
        ser1.Serialize(Console.Out, list1);
    }
Beispiel #15
0
        public static SourceConfig SaveSourceConfig(SourceConfig config, ILogger logger)
        {
            var appDataFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "dashboardharvester");

            if (!Directory.Exists(appDataFolder))
            {
                Directory.CreateDirectory(appDataFolder);
            }

            logger.LogInformation($"Saving source config for ID '{config.Id}' to '{appDataFolder}'");

            var jsonConfig = JsonConvert.SerializeObject(config);

            using var file = File.CreateText(Path.Combine(appDataFolder, $"{config.Id}.json"));
            file.Write(jsonConfig);

            return(config);
        }
Beispiel #16
0
        public void loadObjects(DbContextEx db)
        {
            ObjectList.Clear();

            try {
                //1.获取配置里的执行代码
                //
                ObjectItem exeCode = SourceConfig.GetObject(db.builder, db);

                ObjectModel dataTableRoot = new ObjectModel("数据表", 0);
                ObjectModel dataViewRoot  = new ObjectModel("数据视图", 0);
                ObjectModel dataSPRoot    = new ObjectModel("存储过程", 0);

                //2.执行代码,获取数据
                //
                List <ObjectModel> tableList = db.sql(exeCode.Table).getList(new ObjectModel(1));
                List <ObjectModel> viewList  = db.sql(exeCode.View).getList(new ObjectModel(2));
                List <ObjectModel> spList    = db.sql(exeCode.StoredProcedure).getList(new ObjectModel(3));

                //3.绑定到树控件上
                //
                dataTableRoot.AddRange(tableList);
                dataViewRoot.AddRange(viewList);
                dataSPRoot.AddRange(spList);

                if (dataTableRoot.Children.Count > 0)
                {
                    ObjectList.Add(dataTableRoot);
                }

                if (dataViewRoot.Children.Count > 0)
                {
                    ObjectList.Add(dataViewRoot);
                }

                if (dataSPRoot.Children.Count > 0)
                {
                    ObjectList.Add(dataSPRoot);
                }
            } catch (Exception ex) {
            }

            NotifyPropertyChanged("ObjectList");
        }
Beispiel #17
0
 protected ASource(ARoom room, SourceConfig config, ISourceDevice device)
     : base(room, config.SourceType, device)
 {
     _config            = config;
     Name               = config.Name;
     IconName           = config.Icon.ToString();
     DisplayDeviceInput = config.DisplayInput;
     if (config.SwitcherInputIndex > 0)
     {
         _switcherInputs[1] = config.SwitcherInputIndex;
     }
     if (config.SwitcherInputIndexSecondary > 0)
     {
         _switcherInputs[2] = config.SwitcherInputIndexSecondary;
     }
     DmEndpointSourceInput = config.DmEndpointSourceSelect;
     AvailabilityType      = config.AvailabilityType;
     DmpsAudioInput        = config.DmpsAudioInput;
 }
Beispiel #18
0
 public void Stop(string sourceName)
 {
     Debug.WriteLine("RecorderControlService.Stop " + sourceName);
     try
     {
         SourceConfig source = SourcesConfig.FindSource(sourceName);
         if (source != null)
         {
             SourceRecorder recorder = SourceRecorder.FindRecorder(source);
             if (recorder != null)
             {
                 recorder.Stop();
                 recorder.Dispose();
             }
         }
     }
     catch (Exception exc)
     {
         Debug.WriteLine("RecorderControlService.Stop Exception:");
         Debug.WriteLine(exc.Message);
     }
 }
Beispiel #19
0
 public AzureDevOpsRepositoryTarget(SourceConfig source)
     : base(source.Source, source.AccessToken)
 {
     _projectsToIgnore     = source.ProjectsToIgnore;
     _repositoriesToIgnore = source.RepositoriesToIgnore;
 }
 public GenericSource(ARoom room, SourceConfig config)
     : base(room, config, null)
 {
 }
 public GenericSource(DisplayBase display, SourceConfig config)
     : base(display, config, null)
 {
 }
 public override int GetHashCode()
 {
     return(string.Format("{0}_{1}_{2}_{3}_{4}",
                          SourceConfig.GetHashCode(), JobConfig.GetHashCode(), FunctionParameter.GetHashCode(), LogConfig.GetHashCode(), Enable.GetHashCode()).GetHashCode());
 }
 public GenericSource(ASystem system, SourceConfig config, ISourceDevice device)
     : base(system, config, device)
 {
 }
Beispiel #24
0
 public OffenderEmailService(
     IOptions <SourceConfig> sourceConfig
     )
 {
     this.sourceConfig = sourceConfig.Value;
 }
Beispiel #25
0
        private void ManageMakeFile(Dictionary <string, Dictionary <string, List <string> > > data, SourceConfig sourceConfig)
        {
            if (sourceConfig.sourceType.GetValue() == ESourceType.online && sourceConfig.online.GetValue().makeFile.GetValue())
            {
                Console.WriteLine("parsing data to file from onlineSource...");
                string targetMakeFile          = dataComparer.sourceConfigHolder.GetValue().GetLocalSourceFile(sourceConfig);
                string targetMakeFileDirectory = Path.GetDirectoryName(targetMakeFile);

                if (!Directory.Exists(targetMakeFileDirectory))
                {
                    Console.WriteLine("had to create directory: " + targetMakeFileDirectory);
                    Directory.CreateDirectory(targetMakeFileDirectory);
                }

                using (var writer = new StreamWriter(targetMakeFile, false)) {
                    Console.WriteLine("writing to file: " + targetMakeFile);
                    ISerializer serializer = new SerializerBuilder().Build();
                    string      yamlText   = serializer.Serialize(data);
                    writer.WriteLine(yamlText);
                }

                if (sourceConfig.online.GetValue().makeLastCreated.GetValue())
                {
                    Console.WriteLine("setting lastCreated to: " + targetMakeFile);
                    SaveLastCreated(targetMakeFile);
                }
            }
        }
Beispiel #26
0
 private Dictionary <string, Dictionary <string, List <string> > > BuildContent(SourceConfig sourceConfig)
 {
     if (sourceConfig.sourceType.GetValue() == ESourceType.online)
     {
         EOnlineDataType onlineDataType = dataComparer.sourceConfigHolder.GetValue().onlineSourcesConfig.GetValue().dataType;
         return(onlineDataType switch {
             EOnlineDataType.xmlFile => dataComparer.onlineSourceInterpreterConfig.GetValue()
             .BuildXMLContent(dataComparer.sourceConfigHolder.GetValue()
                              .onlineSourcesConfig.GetValue()
                              .GetDataFileURLs(sourceConfig.online.GetValue())),
             EOnlineDataType.bundleFile => dataComparer.onlineSourceInterpreterConfig.GetValue()
             .BuildBundleContent(dataComparer.sourceConfigHolder.GetValue()
                                 .onlineSourcesConfig.GetValue()
                                 .GetDataFileURLs(sourceConfig.online.GetValue())),
             _ => throw new InvalidOperationException("OnlineDataType " + onlineDataType + " not supported by DataComparer")
         });
Beispiel #27
0
 public override Task Save(SourceConfig source)
 => Api.SetConfiguration.ExecuteAsync(connector, name, new()
Beispiel #28
0
 public override Task Save(SourceConfig source)
 => Api.SetFlow.ExecuteAsync(flowName, new()
 public GenericSource(ARoom room, SourceConfig config, ISourceDevice device)
     : base(room, config, device)
 {
 }
 public GenericSource(DisplayBase display, SourceConfig config, ISourceDevice device)
     : base(display, config, device)
 {
 }