public void TestAddResourceAndPluginMap()
        {
            PluginResourceAction resourceAction = new PluginResourceAction(ConnectString);
            Resource             resource       = new Resource();

            resource.ResourceType = "Plugin";

            FileStream   fileStream   = new FileStream(@"D:\Crazywolf\Devops\DevopsSupportCenter\HP.TS.Devops.CentralConnect.Plugin.General\bin\Debug\HP.TS.Devops.CentralConnect.Plugin.General.dll", FileMode.Open, FileAccess.Read, FileShare.None);
            StreamReader streamReader = new StreamReader(fileStream);

            byte[] source = new byte[fileStream.Length];
            fileStream.Read(source, 0, (int)fileStream.Length);
            fileStream.Close();
            resource.ResourceType = "Plugin";
            resource.FileName     = @"HP.TS.Devops.CentralConnect.Plugin.General.dll";
            resource.FileContent  = source;
            resource.CreateBy     = "UnitTest";
            int       result    = resourceAction.AddResource(resource);
            PluginMap pluginMap = new PluginMap();

            pluginMap.PluginClass   = "CentralConnectMetrics";
            pluginMap.PluginType    = "MetricsV1";
            pluginMap.Description   = "Official Metrics Plugin";
            pluginMap.FileName      = resource.FileName;
            pluginMap.ClassFullName = "HP.TS.Devops.CentralConnect.Plugin.General.Metrics.MetricsV1";
            result = resourceAction.AddPluginMap(pluginMap);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Construct the repository using specific properties
 /// </summary>
 /// <param name="properties">the properties to set for this repository</param>
 /// <remarks>
 /// <para>
 /// Initializes the repository with specified properties.
 /// </para>
 /// </remarks>
 protected LoggerRepositorySkeleton(PropertiesDictionary properties)
 {
     m_properties            = properties;
     m_rendererMap           = new RendererMap();
     m_pluginMap             = new PluginMap(this);
     m_levelMap              = new LevelMap();
     m_configurationMessages = EmptyCollection.Instance;
     m_configured            = false;
     AddBuiltinLevels();
     m_threshold = Level.All;
 }
        /// <summary>
        /// Construct the repository using specific properties
        /// </summary>
        /// <param name="properties">the properties to set for this repository</param>
        /// <remarks>
        /// <para>
        /// Initializes the repository with specified properties.
        /// </para>
        /// </remarks>
        protected LoggerRepositorySkeleton(PropertiesDictionary properties)
        {
            m_properties  = properties;
            m_rendererMap = new RendererMap();
            m_pluginMap   = new PluginMap(this);
            m_levelMap    = new LevelMap();
            m_configured  = false;

            AddBuiltinLevels();

            // Don't disable any levels by default.
            m_threshold = Level.All;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LoggerRepositorySkeleton"/> class.
        /// Construct the repository using specific properties.
        /// </summary>
        /// <param name="properties">the properties to set for this repository.</param>
        /// <remarks>
        /// <para>
        /// Initializes the repository with specified properties.
        /// </para>
        /// </remarks>
        protected LoggerRepositorySkeleton(PropertiesDictionary properties)
        {
            this.m_properties            = properties;
            this.m_rendererMap           = new RendererMap();
            this.m_pluginMap             = new PluginMap(this);
            this.m_levelMap              = new LevelMap();
            this.m_configurationMessages = EmptyCollection.Instance;
            this.m_configured            = false;

            this.AddBuiltinLevels();

            // Don't disable any levels by default.
            this.m_threshold = Level.All;
        }
Ejemplo n.º 5
0
        public PluginResponse InvokeMetrics(MetricsRequest metricsRequest, string metricsType)
        {
            PluginResourceAction pluginResourceAction = new PluginResourceAction(this.ConnectString);
            List <PluginMap>     pluginMaps           = pluginResourceAction.RetrievePluginMapByClassAndType(CentralConnectMetrics, metricsType);

            if (pluginMaps.Count != 1)
            {
                return(new PluginResponse()
                {
                    IsSuccess = false, Message = Enum.GetName(typeof(CentralConnectCode), CentralConnectCode.PluginMapNotExist)
                });
            }
            Logger.Write("PluginMaps", pluginMaps[0]);
            PluginMap pluginMap = pluginMaps[0];
            Resource  resource  = pluginResourceAction.RetrieveResourceByTypeAndFileName(PluginResource, pluginMap.FileName);

            if (string.IsNullOrEmpty(resource.FileName))
            {
                return(new PluginResponse()
                {
                    IsSuccess = false, Message = Enum.GetName(typeof(CentralConnectCode), CentralConnectCode.ResourceFileNotExist)
                });
            }
            System.Reflection.Assembly assembly = null;
            if (!LoadPluginResourceFile(resource, out assembly) || assembly == null)
            {
                return(new PluginResponse()
                {
                    IsSuccess = false, Message = Enum.GetName(typeof(CentralConnectCode), CentralConnectCode.LoadResourceFileFail)
                });
            }
            IMetrics iMetrics = (IMetrics)assembly.CreateInstance(pluginMap.ClassFullName);

            if (iMetrics == null)
            {
                return(new PluginResponse()
                {
                    IsSuccess = false, Message = Enum.GetName(typeof(CentralConnectCode), CentralConnectCode.CreateMetricsInstanceFail)
                });
            }
            DictionaryAction dictionaryAction = new DictionaryAction(this.ConnectString);
            string           workspace        = dictionaryAction.RetrieveValueByTypeAndKey("Settings", "Workspace");

            metricsRequest.Workspace = System.IO.Path.Combine(workspace, CentralConnectMetrics);
            return(iMetrics.GenerateMetrics(metricsRequest));
        }
 /// <summary>
 /// Default Constructor
 /// </summary>
 /// <remarks>
 /// <para>
 /// Initializes the repository with default (empty) properties.
 /// </para>
 /// </remarks>
 protected LoggerRepositorySkeleton()
 {
     m_pluginMap = new PluginMap(this);
     m_Threshold = Level.ALL;
 }