public override void OnActionExecuting(HttpActionContext actionContext)
        {
            TraceHandler.TraceIn(TraceLevel.Info);

            if (actionContext == null)
            {
                throw new ArgumentNullException("HttpActionContext");
            }

            if (actionContext.Request.Headers.Referrer == null)
            {
                actionContext.Response = actionContext.Request.CreateErrorResponse(HttpStatusCode.Forbidden, EXCEPTION_REFERRER_NULL);
            }

            var referrer = actionContext.Request.Headers.Referrer.ToString();

            TraceHandler.TraceAppend(string.Format(FORMAT_REFERRER, referrer));

            // If no Origins Are Set - Do Nothing
            if (policy.Origins.Count > 0)
            {
                var isFound = policy.Origins.Contains(referrer);

                TraceHandler.TraceAppend(string.Format(FORMAT_REFERRER_FOUND, isFound));

                if (!isFound)
                {
                    TraceHandler.TraceAppend("IsFound was FALSE");
                    actionContext.Response = actionContext.Request.CreateErrorResponse(HttpStatusCode.Forbidden, string.Format(FORMAT_INVALID_REFERRER, referrer));
                }
            }

            TraceHandler.TraceOut();
            base.OnActionExecuting(actionContext);
        }
Exemplo n.º 2
0
        public string ReportOptions(Report report)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("===============================================================================");
            sb.AppendLine("[Global scope options]");

            sb.AppendLine(ArgsOnlyHandler.Report());
            sb.AppendLine(DebugHandler.Report());
            sb.AppendLine(InitFileHandler.Report());
            sb.AppendLine(ScriptHandler.Report());
            sb.AppendLine(TraceHandler.Report());
            sb.AppendLine(VerboseHandler.Report());
            sb.AppendLine(VerifyHandler.Report());
            sb.AppendLine(VerifyMemoryHandler.Report());

            sb.AppendLine("[Session scope options]");
            sb.AppendLine(report.Session.ReportOptions());

            sb.AppendLine("[Report scope options]");
            sb.AppendLine(report.ReportOptions());
            sb.AppendLine("===============================================================================");

            return(sb.ToString());
        }
Exemplo n.º 3
0
        // 主线程循环
        internal static void MainThreadUpdate()
        {
            // 添加
            int length = WaitToAddGroup.Count;

            for (int i = 0; i < length; i++)
            {
                ListenerGroup.Add(WaitToAddGroup[0]);
                WaitToAddGroup.RemoveAt(0);
            }

            // 清理
            if (NeroDriver.NeedClear)
            {
                ListenerGroup.ClearNullElement();
            }

            // 派发
            if (ListenerGroup.Count > 0)
            {
                List <TraceData> traceDatas = TraceHandler.GetTraceDatas();
                if (traceDatas != null)
                {
                    length = traceDatas.Count;
                    for (int i = 0; i < length; i++)
                    {
                        ListenerGroup.DispatchAll(traceDatas[i]);
                    }
                }
            }
        }
Exemplo n.º 4
0
        private void Enqueue(ClaimMessage claimMessage)
        {
            var queueName = ConfigurationManager.AppSettings[Settings.Messaging.Queue.Name].ToString();
            var queue     = new MessageQueue(queueName);

            queue.DefaultPropertiesToSend.Recoverable = true;

            TraceHandler.TraceAppend(FORMAT_QUEUE_NAME, queueName);

            MessageQueueTransaction transaction;

            transaction = new MessageQueueTransaction();
            transaction.Begin();

            var message = new System.Messaging.Message();

            message.Formatter = new XmlMessageFormatter(new Type[] { typeof(ClaimMessage) });

            message.Label = "ClaimID " + claimMessage.ClaimID;

            message.Body = claimMessage;
            queue.Send(message, transaction);

            transaction.Commit();
            queue.Close();
        }
Exemplo n.º 5
0
        public IEnumerable <BankAccount> FindOverdrafts(IAccountAlgorithm overdraftAlgorithm)
        {
            TraceHandler.TraceIn(TraceLevel.Info);

            var accounts = new List <BankAccount>();

            try
            {
                var entities = UnitOfWork.BankAccounts.GetAll().ToList();

                entities.ForEach(e => {
                    IAlgorithmResult calculation = overdraftAlgorithm.Calculate(e.Balance);

                    if (calculation.Result)
                    {
                        accounts.Add(e);
                    }
                });
            }
            catch (Exception ex)
            {
                TraceHandler.TraceError(ex);
            }
            finally
            {
                TraceHandler.TraceOut();
            }

            return(accounts.AsEnumerable());
        }
Exemplo n.º 6
0
        private static void ConfigureHttp(
            HttpConfiguration config,
            StatelessServiceContext serviceContext)
        {
            var exceptionHandler = new CustomExceptionHandler(serviceContext);

            config.Services.Replace(typeof(IExceptionHandler), exceptionHandler);

            var authenticationHandler = new AuthenticationHandler(serviceContext);

            config.MessageHandlers.Add(authenticationHandler);

            var traceHandler = new TraceHandler(serviceContext);

            config.MessageHandlers.Add(traceHandler);

            var serializer = config.Formatters.JsonFormatter;

            serializer.SerializerSettings.Formatting       = Formatting.Indented;
            serializer.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();

            config.Formatters.Clear();
            var jsonFormatter = new JsonMediaTypeFormatter();

            jsonFormatter.SupportedMediaTypes.Remove(new MediaTypeHeaderValue("text/json"));
            config.Formatters.Add(jsonFormatter);

            config.MapHttpAttributeRoutes();
        }
Exemplo n.º 7
0
        public static void UseTraceActuator(IConfiguration configuration, ITraceRepository traceRepository = null, ILoggerFactory loggerFactory = null)
        {
            var options = new TraceOptions(configuration);

            traceRepository = traceRepository ?? new TraceDiagnosticObserver(options, CreateLogger <TraceDiagnosticObserver>(loggerFactory));
            DiagnosticsManager.Instance.Observers.Add((IDiagnosticObserver)traceRepository);
            var ep      = new TraceEndpoint(options, traceRepository, CreateLogger <TraceEndpoint>(loggerFactory));
            var handler = new TraceHandler(ep, SecurityService, CreateLogger <TraceHandler>(loggerFactory));

            ConfiguredHandlers.Add(handler);
        }
Exemplo n.º 8
0
        private static void UseTraceActuatorComponents(IConfiguration configuration, ITraceRepository traceRepository, ILoggerFactory loggerFactory)
        {
            var options = new TraceEndpointOptions(configuration);

            _mgmtOptions.RegisterEndpointOptions(configuration, options);
            traceRepository = traceRepository ?? new TraceDiagnosticObserver(options, CreateLogger <TraceDiagnosticObserver>(loggerFactory));
            DiagnosticsManager.Instance.Observers.Add((IDiagnosticObserver)traceRepository);
            var ep      = new TraceEndpoint(options, traceRepository, CreateLogger <TraceEndpoint>(loggerFactory));
            var handler = new TraceHandler(ep, SecurityServices, _mgmtOptions, CreateLogger <TraceHandler>(loggerFactory));

            ConfiguredHandlers.Add(handler);
        }
Exemplo n.º 9
0
        private void EnqueueToPoison(Exception exception, ClaimMessage claimdata)
        {
            TraceHandler.TraceIn(TraceLevel.Info);

            var poison  = ToPoisonMessage(exception, claimdata);
            var message = new System.Messaging.Message();

            try
            {
                var poisonQueueName = ConfigurationManager.AppSettings[Settings.Messaging.PoisonQueue.Name].ToString();

                TraceHandler.TraceAppend(FORMAT_QUEUE_NAME, poisonQueueName);

                if (MessageQueue.Exists(poisonQueueName))
                {
                    var queue = new MessageQueue(poisonQueueName);
                    queue.DefaultPropertiesToSend.Recoverable = true;

                    var transaction = new MessageQueueTransaction();
                    transaction.Begin();

                    message.Formatter = new XmlMessageFormatter(new Type[] { typeof(PoisonClaimMessage) });
                    message.Label     = "Poison ClaimID " + poison.ClaimID;

                    var xmlSerializer = new XmlSerializer(poison.GetType());
                    xmlSerializer.Serialize(message.BodyStream, poison);

                    queue.Send(message, transaction);

                    TraceHandler.TraceAppend(FORMAT_ENQUEUED_POISON_SUCCESS, poison.ClaimID);

                    transaction.Commit();
                    queue.Close();
                }
            }
            catch (Exception ex)
            {
                // An error occurred while enqueuing to POISON
                var poisonXml = ToString(poison);

                TraceHandler.TraceError(ex);
                TraceHandler.TraceAppend(poisonXml);
            }
            finally
            {
                TraceHandler.TraceOut();
            }
        }
Exemplo n.º 10
0
        /// <exception cref="ArgumentNullException">Non-Existent "OwnerFullName" argument throws this exception.</exception>
        /// <exception cref="ArgumentException">Invalid "StartingBalance" argument throws this exception.</exception>
        /// <exception cref="ArgumentException">Invalid "AnnualPercentageRate" argument throws this exception.</exception>
        public BankAccount CreateNew(AccountType bankAccountType, string ownerFullName, decimal startingBalance, decimal annualPercentageRate, string executedBy)
        {
            TraceHandler.TraceIn(TraceLevel.Info);

            if (string.IsNullOrWhiteSpace(ownerFullName))
            {
                throw new ArgumentNullException("Owner Full Name");
            }

            if (startingBalance < 0.0M)
            {
                throw new ArgumentException(string.Format(StartingBalanceInvalidFormat, startingBalance));
            }

            if (annualPercentageRate <= 0.0M)
            {
                throw new ArgumentException(string.Format(AnnualPercentageRateInvalidFormat, annualPercentageRate));
            }

            var account = new BankAccount();

            try
            {
                BankAccountType accountType = GetAccountType(bankAccountType);

                account.AnnualPercentageRate = annualPercentageRate;
                account.Balance           = startingBalance;
                account.BankAccountTypeId = accountType.BankAccountTypeId;
                account.OwnerFullName     = ownerFullName;
                account.ExecutedByName    = executedBy;
                account.ExecutedDatetime  = DateTime.UtcNow;

                UnitOfWork.BankAccounts.Add(account);
                UnitOfWork.SaveChanges();
            }
            catch (Exception ex)
            {
                TraceHandler.TraceError(ex);
            }
            finally
            {
                TraceHandler.TraceOut();
            }

            return(account);
        }
Exemplo n.º 11
0
        public HttpResponseMessage Ping()
        {
            TraceHandler.TraceIn(TraceLevel.Info);

            if (Request.Headers.Referrer == null)
            {
                TraceHandler.TraceAppend(MESSAGE_REFERRER_NULL);
            }

            if (Request.Headers.Referrer != null)
            {
                TraceHandler.TraceAppend(string.Format(FORMAT_REFERRER, Request.Headers.Referrer));
            }

            TraceHandler.TraceOut();
            return(Request.CreateResponse(HttpStatusCode.OK, "Ping back at cha..."));
        }
Exemplo n.º 12
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            // bind connection strings to the dropdown list
            cboConnectionString.DisplayMember = "Name";
            foreach (ConnectionStringSettings connectionStringSetting in ConfigurationManager.ConnectionStrings)
            {
                cboConnectionString.Items.Add(connectionStringSetting);
            }

            if (cboConnectionString.Items.Count > 0)
            {
                cboConnectionString.SelectedIndex = 0;
            }

            // configure delegate trace listener
            DelegateTraceListener traceListener = new DelegateTraceListener();

            traceDelegate = new TraceHandler(traceToMessageBox);
            traceListener.WriteDelegate     += new DelegateTraceListener.WriteHandler(traceListener_WriteDelegate);
            traceListener.WriteLineDelegate += new DelegateTraceListener.WriteHandler(traceListener_WriteLineDelegate);
            Trace.Listeners.Add(traceListener);
        }
Exemplo n.º 13
0
        public HttpResponseMessage Enqueue(HttpRequestMessage request)
        {
            TraceHandler.TraceIn(TraceLevel.Info);

            if (Request.Headers.Referrer == null)
            {
                TraceHandler.TraceAppend(MESSAGE_REFERRER_NULL);
            }

            if (Request.Headers.Referrer != null)
            {
                TraceHandler.TraceAppend(string.Format(FORMAT_REFERRER, Request.Headers.Referrer));
            }

            try
            {
                // Do Amazing Stuff Here...

                TraceHandler.TraceAppend(FORMAT_ENQUEUED_SUCCESS, claimId);
            }
            catch (Exception ex)
            {
                TraceHandler.TraceError(ex);
                TraceHandler.TraceOut();

                EnqueueToPoison(ex, claimMessage);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, GetHttpError()));
            }

            TraceHandler.TraceOut();

            // FORCE: Correct Header
            var response = Request.CreateResponse(HttpStatusCode.OK, string.Format(FORMAT_ENQUEUED_SUCCESS, claimId));

            response.Headers.Add("Access-Control-Allow-Origin", "*");
            return(response);
        }
Exemplo n.º 14
0
        internal void Render(HtmlTextWriter output)
        {
            if (PageOutput && _requestData != null)
            {
                TraceEnable oldEnabled = _isEnabled;

                _isEnabled = TraceEnable.Disable;

                Control table;

                output.Write("<div id=\"__asptrace\">\r\n");
                output.Write(TraceHandler.StyleSheet);
                output.Write("<span class=\"tracecontent\">\r\n");

                table = TraceHandler.CreateDetailsTable(_requestData.Tables[SR.Trace_Request]);
                if (table != null)
                {
                    table.RenderControl(output);
                }

                table = TraceHandler.CreateTraceTable(_requestData.Tables[SR.Trace_Trace_Information]);
                if (table != null)
                {
                    table.RenderControl(output);
                }

                table = TraceHandler.CreateControlTable(_requestData.Tables[SR.Trace_Control_Tree]);
                if (table != null)
                {
                    table.RenderControl(output);
                }

                table = TraceHandler.CreateTable(_requestData.Tables[SR.Trace_Session_State], true /*encodeSpaces*/);
                if (table != null)
                {
                    table.RenderControl(output);
                }

                table = TraceHandler.CreateTable(_requestData.Tables[SR.Trace_Application_State], true /*encodeSpaces*/);
                if (table != null)
                {
                    table.RenderControl(output);
                }

                table = TraceHandler.CreateTable(_requestData.Tables[SR.Trace_Request_Cookies_Collection], true /*encodeSpaces*/);
                if (table != null)
                {
                    table.RenderControl(output);
                }

                table = TraceHandler.CreateTable(_requestData.Tables[SR.Trace_Response_Cookies_Collection], true /*encodeSpaces*/);
                if (table != null)
                {
                    table.RenderControl(output);
                }

                table = TraceHandler.CreateTable(_requestData.Tables[SR.Trace_Headers_Collection], true /*encodeSpaces*/);
                if (table != null)
                {
                    table.RenderControl(output);
                }

                table = TraceHandler.CreateTable(_requestData.Tables[SR.Trace_Response_Headers_Collection], true /*encodeSpaces*/);
                if (table != null)
                {
                    table.RenderControl(output);
                }

                table = TraceHandler.CreateTable(_requestData.Tables[SR.Trace_Form_Collection]);
                if (table != null)
                {
                    table.RenderControl(output);
                }

                table = TraceHandler.CreateTable(_requestData.Tables[SR.Trace_Querystring_Collection]);
                if (table != null)
                {
                    table.RenderControl(output);
                }

                table = TraceHandler.CreateTable(_requestData.Tables[SR.Trace_Server_Variables], true /*encodeSpaces*/);
                if (table != null)
                {
                    table.RenderControl(output);
                }

                output.Write("<hr width=100% size=1 color=silver>\r\n\r\n");
                output.Write(SR.GetString(SR.Error_Formatter_CLR_Build) + VersionInfo.ClrVersion +
                             SR.GetString(SR.Error_Formatter_ASPNET_Build) + VersionInfo.EngineVersion + "\r\n\r\n");
                output.Write("</font>\r\n\r\n");

                output.Write("</span>\r\n</div>\r\n");

                _isEnabled = oldEnabled;
            }
        }
Exemplo n.º 15
0
 public static void Trace(string message) => TraceHandler?.Invoke(message);
 internal void Render(HtmlTextWriter output)
 {
     if (this.PageOutput && (this._requestData != null))
     {
         TraceEnable enable = this._isEnabled;
         this._isEnabled = TraceEnable.Disable;
         output.Write("<div id=\"__asptrace\">\r\n");
         output.Write(TraceHandler.StyleSheet);
         output.Write("<span class=\"tracecontent\">\r\n");
         Control control = TraceHandler.CreateDetailsTable(this._requestData.Tables["Trace_Request"]);
         if (control != null)
         {
             control.RenderControl(output);
         }
         control = TraceHandler.CreateTraceTable(this._requestData.Tables["Trace_Trace_Information"]);
         if (control != null)
         {
             control.RenderControl(output);
         }
         control = TraceHandler.CreateControlTable(this._requestData.Tables["Trace_Control_Tree"]);
         if (control != null)
         {
             control.RenderControl(output);
         }
         control = TraceHandler.CreateTable(this._requestData.Tables["Trace_Session_State"], true);
         if (control != null)
         {
             control.RenderControl(output);
         }
         control = TraceHandler.CreateTable(this._requestData.Tables["Trace_Application_State"], true);
         if (control != null)
         {
             control.RenderControl(output);
         }
         control = TraceHandler.CreateTable(this._requestData.Tables["Trace_Request_Cookies_Collection"], true);
         if (control != null)
         {
             control.RenderControl(output);
         }
         control = TraceHandler.CreateTable(this._requestData.Tables["Trace_Response_Cookies_Collection"], true);
         if (control != null)
         {
             control.RenderControl(output);
         }
         control = TraceHandler.CreateTable(this._requestData.Tables["Trace_Headers_Collection"], true);
         if (control != null)
         {
             control.RenderControl(output);
         }
         control = TraceHandler.CreateTable(this._requestData.Tables["Trace_Response_Headers_Collection"], true);
         if (control != null)
         {
             control.RenderControl(output);
         }
         control = TraceHandler.CreateTable(this._requestData.Tables["Trace_Form_Collection"]);
         if (control != null)
         {
             control.RenderControl(output);
         }
         control = TraceHandler.CreateTable(this._requestData.Tables["Trace_Querystring_Collection"]);
         if (control != null)
         {
             control.RenderControl(output);
         }
         control = TraceHandler.CreateTable(this._requestData.Tables["Trace_Server_Variables"], true);
         if (control != null)
         {
             control.RenderControl(output);
         }
         output.Write("<hr width=100% size=1 color=silver>\r\n\r\n");
         output.Write(System.Web.SR.GetString("Error_Formatter_CLR_Build") + VersionInfo.ClrVersion + System.Web.SR.GetString("Error_Formatter_ASPNET_Build") + VersionInfo.EngineVersion + "\r\n\r\n");
         output.Write("</font>\r\n\r\n");
         output.Write("</span>\r\n</div>\r\n");
         this._isEnabled = enable;
     }
 }
Exemplo n.º 17
0
 public static extern void libssh2_trace_sethandler(
     SshSessionHandle session,
     IntPtr context,
     TraceHandler callback);
Exemplo n.º 18
0
        internal void Render(HtmlTextWriter output)
        {
            if (PageOutput && _requestData != null)
            {
                TraceEnable oldEnabled = _isEnabled;

                _isEnabled = TraceEnable.Disable;

                Control table;

                output.Write("<div id=\"__asptrace\">\r\n");
                output.Write(TraceHandler.StyleSheet);
                output.Write("<span class=\"tracecontent\">\r\n");

                table = TraceHandler.CreateDetailsTable(_requestData.Tables[SR.Trace_Request]);
                if (table != null)
                {
                    table.RenderControl(output);
                }

                table = TraceHandler.CreateTraceTable(_requestData.Tables[SR.Trace_Trace_Information]);
                if (table != null)
                {
                    table.RenderControl(output);
                }

                table = TraceHandler.CreateControlTable(_requestData.Tables[SR.Trace_Control_Tree]);
                if (table != null)
                {
                    table.RenderControl(output);
                }

                table = TraceHandler.CreateTable(_requestData.Tables[SR.Trace_Session_State]);
                if (table != null)
                {
                    table.RenderControl(output);
                }

                table = TraceHandler.CreateTable(_requestData.Tables[SR.Trace_Application_State]);
                if (table != null)
                {
                    table.RenderControl(output);
                }

                table = TraceHandler.CreateTable(_requestData.Tables[SR.Trace_Cookies_Collection]);
                if (table != null)
                {
                    table.RenderControl(output);
                }

                table = TraceHandler.CreateTable(_requestData.Tables[SR.Trace_Headers_Collection]);
                if (table != null)
                {
                    table.RenderControl(output);
                }

                table = TraceHandler.CreateTable(_requestData.Tables[SR.Trace_Form_Collection]);
                if (table != null)
                {
                    table.RenderControl(output);
                }

                table = TraceHandler.CreateTable(_requestData.Tables[SR.Trace_Querystring_Collection]);
                if (table != null)
                {
                    table.RenderControl(output);
                }

                table = TraceHandler.CreateTable(_requestData.Tables[SR.Trace_Server_Variables]);
                if (table != null)
                {
                    table.RenderControl(output);
                }

                output.Write("</span>\r\n</div>\r\n");

                _isEnabled = oldEnabled;
            }
        }