Ejemplo n.º 1
0
        public void InitApp(TypeCatalog externalTypeCatalog = null)
        {
            string rootFolder = Server.MapPath("~");

            JsConfig <DateTime> .SerializeFn = t => t.ToString(DateTimeFormat);

            // Preparing logs folder
            string logsFolder = Path.Combine(rootFolder, ConfigurationManager.AppSettings["LogsFolder"]);

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

            // preparing plugins folder
            string pluginsFolder = Path.Combine(rootFolder, ConfigurationManager.AppSettings["PluginsFolder"]);

            DirectoryCatalog dcatalog = new DirectoryCatalog(pluginsFolder, "*.dll");
            var catalog = new AggregateCatalog();

            catalog.Catalogs.Add(dcatalog);

            // adding subfolders - if any
            foreach (var subdir in Directory.GetDirectories(pluginsFolder))
            {
                dcatalog = new DirectoryCatalog(subdir, "*.dll");
                catalog.Catalogs.Add(dcatalog);
            }


            if (externalTypeCatalog != null)
            {
                catalog.Catalogs.Add(externalTypeCatalog);
            }
            _container = new CompositionContainer(catalog);
            _container.ComposeExportedValue("ServiceRootFolder", rootFolder);
            _container.ComposeParts(this);

            // initializing logger
            Lazy <ILogger> logger       = _container.GetExport <ILogger>(ConfigurationManager.AppSettings["LoggerType"]);
            ILoggerParams  loggerParams = logger.Value.CreateParams();

            if (ConfigurationManager.AppSettings["LoggerType"] == "FileLogger")
            {
                loggerParams.Parameters["LogFolder"]    = logsFolder;
                loggerParams.Parameters["NameTemplate"] = ConfigurationManager.AppSettings["LogFileNameTemplate"];
                logger.Value.Init(loggerParams);
            }

            _logger = logger.Value;
        }
Ejemplo n.º 2
0
        public void Start()
        {
            try
            {
                // Preparing logs folder
                string rootFolder = AssemblyDirectory;
                string logsFolder = Path.Combine(rootFolder, ConfigurationManager.AppSettings["LogsFolder"]);
                if (!Directory.Exists(logsFolder))
                {
                    Directory.CreateDirectory(logsFolder);
                }

                // preparing plugins folder
                string pluginsFolder = Path.Combine(rootFolder, ConfigurationManager.AppSettings["PluginsFolder"]);

                DirectoryCatalog dcatalog = new DirectoryCatalog(pluginsFolder, "*.dll");

                var catalog = new AggregateCatalog();
                catalog.Catalogs.Add(dcatalog);
                _container = new CompositionContainer(catalog);
                _container.ComposeParts();

                // initializing logger
                Lazy <ILogger> logger       = _container.GetExport <ILogger>(ConfigurationManager.AppSettings["LoggerType"]);
                ILoggerParams  loggerParams = logger.Value.CreateParams();

                if (ConfigurationManager.AppSettings["LoggerType"] == "FileLogger")
                {
                    loggerParams.Parameters["LogFolder"]    = logsFolder;
                    loggerParams.Parameters["NameTemplate"] = ConfigurationManager.AppSettings["LogFileNameTemplate"];
                    logger.Value.Init(loggerParams);
                }

                logger.Value.Log(EErrorType.Info, "InfraStartup initialized");

                logger.Value.Dispose();
            }
            catch (Exception ex)
            {
                Console.WriteLine(string.Format("Error occured: {0}", ex.Message));
            }
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Reading...");
            DirectoryInfo dirInfo = Directory.CreateDirectory(ConfigurationManager.AppSettings["LogsFolder"]);

            _logger = new FileLogger();
            ILoggerParams loggerParams = _logger.CreateParams();



            loggerParams.Parameters["LogFolder"]    = ConfigurationManager.AppSettings["LogsFolder"];
            loggerParams.Parameters["NameTemplate"] = ConfigurationManager.AppSettings["LogFileNameTemplate"];

            _logger.Init(loggerParams);

            _beaClient = new DMFX.BEA.Api.BEAApi();

            DMFX.BEA.Api.BEAApi.CallParams callParams = new DMFX.BEA.Api.BEAApi.CallParams();

            BEAResponse <BEAGetDataSetList> respGetDataSetList = _beaClient.GetDataSetList(callParams);

            foreach (var ds in respGetDataSetList.BEAAPI.Results.Dataset)
            {
                if (ds.DatasetName != "RegionalData")
                {
                    _logger.Log(EErrorType.Info, string.Format("DATASET: {0}\tDesc: {1}", ds.DatasetName, ds.DatasetDescription));
                    DumpDataSet(ds.DatasetName);
                }
            }

            Console.WriteLine("Dumping...");

            System.Threading.Thread.Sleep(60000);

            Console.WriteLine("Done");
        }
Ejemplo n.º 4
0
        public void Init(ILoggerParams loggerParams)
        {
            FileLoggerParams flParams = loggerParams as FileLoggerParams;

            if (flParams != null)
            {
                // reading parameters
                string folder   = flParams.Parameters["LogFolder"].ToString();
                string template = flParams.Parameters["NameTemplate"].ToString();
                _bufferSize = flParams.Parameters.ContainsKey("BufferSize") ? Int32.Parse(flParams.Parameters["BufferSize"].ToString()) : 100;

                string fileName = string.Format(template, DateTime.UtcNow.ToString("dd-MM-yyyy HH-mm-ss"));

                _filePath = Path.Combine(folder, fileName);

                _flushTask        = new Task(FlushThread);
                _isFlushThreadRun = true;
                _flushTask.Start();
            }
            else
            {
                throw new ArgumentException(string.Format("Invalid parameters provided: unexpected type '{0}'", loggerParams.GetType().ToString()));
            }
        }
Ejemplo n.º 5
0
 public void Init(ILoggerParams loggerParams)
 {
     NullLoggerParams parameters = loggerParams as NullLoggerParams;
 }