Ejemplo n.º 1
0
 public void ReadLogs()
 {
     TraceLogReader reader = new TraceLogReader(
         "TestLogs", "xroutermanager");
     var entries = reader.GetEntries(
         new DateTime(2011, 1, 1),
         new DateTime(2012, 1, 1),
         LogLevelFilters.Error | LogLevelFilters.Warning | LogLevelFilters.Info,
         int.MaxValue, 1);
     int total = entries.Count();
     Console.WriteLine("Total: " + total);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Starts the console server in a new thread.
        /// </summary>
        public void Start()
        {
            // init DB storage
            this.storage = new PersistentStorage(this.storagesInfo.DbConnectionString);

            // init log readers
            this.eventLogReader = new EventLogReader(this.storagesInfo.LogsDirectory, this.serviceName);
            this.traceLogReader = new TraceLogReader(this.storagesInfo.LogsDirectory, this.serviceName);

            ObjectConfigurator.Configurator.CustomItemTypes.Add(new TokenSelectionConfigurationItemType());
            ObjectConfigurator.Configurator.CustomItemTypes.Add(new XRouter.Common.Xrm.XrmUriConfigurationItemType());
            ObjectConfigurator.Configurator.CustomItemTypes.Add(new UriConfigurationItemType());
            UpdatePluginsInApplicationConfiguration();

            // create WCF service on a new thread
            Exception exception = null;
            Thread wcfHostThread = new Thread(delegate(object data)
            {
                try
                {
                    this.wcfHost = new ServiceHost(this, new Uri(this.uri));

                    // set binding (WebService - SOAP/HTTP)
                    WSHttpBinding binding = new WSHttpBinding();
                    binding.MaxReceivedMessageSize = int.MaxValue;
                    binding.ReaderQuotas = new XmlDictionaryReaderQuotas()
                    {
                        MaxBytesPerRead = int.MaxValue,
                        MaxArrayLength = int.MaxValue,
                        MaxStringContentLength = int.MaxValue
                    };

                    // set endpoint
                    this.wcfHost.AddServiceEndpoint(typeof(IConsoleServer), binding, "ConsoleServer");

                    // set metadata behavior
                    ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
                    smb.HttpGetEnabled = true;
                    smb.HttpGetUrl = new Uri(this.metadataUri);
                    this.wcfHost.Description.Behaviors.Add(smb);
                    foreach (var b in this.wcfHost.Description.Behaviors)
                    {
                        if (b is System.ServiceModel.Description.ServiceDebugBehavior)
                        {
                            var sdb = (System.ServiceModel.Description.ServiceDebugBehavior)b;
                            sdb.IncludeExceptionDetailInFaults = true;
                        }
                    }

                    // open connection
                    this.wcfHost.Open();
                }
                catch (Exception e)
                {
                    exception = e;
                }
            });
            wcfHostThread.Start();
            wcfHostThread.Join();

            if (exception != null)
            {
                throw exception;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Starts the reporter server in a new thread.
        /// </summary>
        public void Start()
        {
            // init log readers
            this.eventLogReader = new EventLogReader(this.storagesInfo.LogsDirectory, this.serviceName);
            this.traceLogReader = new TraceLogReader(this.storagesInfo.LogsDirectory, this.serviceName);

            this.worker = new Thread(Run);
            this.worker.Start();
        }