示例#1
0
        /// <summary>
        /// Method for dispaiing last transaction details
        /// </summary>
        private void DisplayLastTransactionDetails()
        {
            TransactionProcessor transactionProcessor = TransactionProcessor.GetTransactionProcessor();

            TransactionLogEntry tmp = transactionProcessor.LastTransaction;

            //TransactionLogEntry tmp = transactionProcessor[transactionProcessor.TransactionCount - 1];


            lbl_LogTransactionType.Text   = tmp.TransactionType.ToString();
            lbl_LogAmount.Text            = tmp.Amount.Amount.ToString();
            lbl_LogCurrency.Text          = tmp.Amount.Currency;
            lbl_LogTransactionStatus.Text = tmp.Status.ToString();

            foreach (IAccount account in tmp.Accounts)
            {
                if (account is ITransactionAccount)
                {
                    populateTransactionAccount(account as ITransactionAccount);
                }
                else if (account is ILoanAccount)
                {
                    populateLoanAccount(account as ILoanAccount);
                }
                else if (account is IDepositAccount)
                {
                    populateDepositAccount(account as IDepositAccount);
                }
            }


            lblNumberTransactions.Text = "Number of transactions: " + transactionProcessor.TransactionCount.ToString();
        }
        private void HandleExceptionFlow(TransactionLogEntry methodLogEntry,
                                         InvocationContext invocationContext, IBaseHandler targetObject, Exception ex)
        {
            AppException exToThrow = null;

            if (ex is AppException)
            {
                var appEx = (AppException)ex;
                appEx.LogEntry = methodLogEntry;
                exToThrow      = appEx;
            }
            else
            {
                exToThrow = new AppException(ex, methodLogEntry, this.loggingAttribute.ErrorMessage);
            }
            // LOG
            Log.Error(exToThrow);
            if (this.loggingAttribute.IsFlowBreakReuired)
            {
                invocationContext.MethodException = exToThrow;
            }
            else
            {
                invocationContext.MethodException = null;
            }
        }
 public AuthorizationController(TransactionLogEntry logEntry,
                                IAuthenticationService authenticationService,
                                IHttpContextAccessor httpContextAccessor) : base(logEntry)
 {
     _authenticationService = authenticationService;
     _httpContextAccessor   = httpContextAccessor;
 }
 private void InitializeLogEntry(TransactionLogEntry logEntry,
                                 string functionName, string methodName, string loggedInUserId)
 {
     logEntry.TransactionId       = Guid.NewGuid();
     logEntry.TransactionStatus   = TransactionStatus.Success;
     logEntry.LoggingFunctionName = functionName;
     logEntry.LoggingMethodName   = methodName;
     logEntry.LogEntryType        = TransactionRecordType.Summary;
     logEntry.StartTime           = DateTime.Now;
     logEntry.ExtendedProperties  = new Dictionary <string, object>();
 }
        public static TransactionLogEntry populateTransaction(TransactionLogEntry inputLogEntry)
        {
            TransactionLogEntry newTranEntry = new TransactionLogEntry();

            newTranEntry.TransactionId       = inputLogEntry.TransactionId;
            newTranEntry.LoggingFunctionName = inputLogEntry.LoggingFunctionName;
            newTranEntry.LoggingHostName     = inputLogEntry.LoggingHostName;
            newTranEntry.LogEntryType        = TransactionRecordType.Detail;
            newTranEntry.LogInUserId         = inputLogEntry.LogInUserId;
            newTranEntry.SessionId           = inputLogEntry.SessionId;
            newTranEntry.ExtendedProperties  = new Dictionary <string, object>();
            return(newTranEntry);
        }
        private void HandlePostMethodExecution(InvocationContext invocationContext, object result, Exception ex)
        {
            _stopWatch.Stop();
            IBaseHandler        targetObject   = invocationContext.Invocation.InvocationTarget as IBaseHandler;
            TransactionLogEntry methodlogEntry = new TransactionLogEntry();

            if (targetObject != null)
            {
                methodlogEntry = targetObject.LogEntry;
            }

            HandleTransactionFlow(methodlogEntry, invocationContext, targetObject, result, ex);
            if (ex != null && !this.loggingAttribute.IsExceptionHandlingNotRequired)
            {
                HandleExceptionFlow(methodlogEntry, invocationContext, targetObject, ex);
            }
        }
        public void BeforeInvoke(InvocationContext invocationContext)
        {
            // Initialize fresh Log object for each Layer copying from Global log object

            _logEntry = invocationContext.ServiceProvider.GetRequiredService <TransactionLogEntry>();
            IBaseHandler targetObject = invocationContext.Invocation.InvocationTarget as IBaseHandler;

            if (targetObject != null)
            {
                var targetLogEntry = CommonLogUtility.populateTransaction(_logEntry);
                targetObject.LockObject = new object();
                targetObject.LogEntry   = targetLogEntry;
            }
            _stopWatch.Reset();
            _stopWatch.Start();

            // Get the logging attribute
            this.loggingAttribute = invocationContext.GetAttributeFromMethod <LogMethodAttribute>();
            // To DO: Customized with your code before finction call here..
        }
示例#8
0
        public virtual string Format(TransactionLogEntry logEntry)
        {
            StringBuilder sb = new StringBuilder();

            logEntry.ExtendedProperties = logEntry.ExtendedProperties ?? new Dictionary <string, object>();
            DateTime now = DateTime.Now;

            sb.AppendFormat("[{0}] ", now.ToString("dd/MM/yyyy:HH:mm:ss zzz"));

            sb.AppendFormat("sessionId={0};",
                            !string.IsNullOrWhiteSpace(logEntry.SessionId) ?
                            logEntry.SessionId : Guid.Empty.ToString());
            sb.AppendFormat("transactionId={0};",
                            !string.IsNullOrWhiteSpace(Convert.ToString(logEntry.TransactionId)) ?
                            logEntry.SessionId : Guid.Empty.ToString());

            sb.AppendFormat("logEntryType={0};", logEntry.LogEntryType.ToString());
            sb.AppendFormat("transactionStatus={0};", logEntry.TransactionStatus.ToString());
            sb.AppendFormat("loggingFunctionName={0};", logEntry.LoggingFunctionName);
            sb.AppendFormat("loggingMethodName={0};", logEntry.LoggingMethodName);
            sb.AppendFormat("logInUserId={0};", logEntry.LogInUserId);
            sb.AppendFormat("StartTime={0};", logEntry.StartTime.ToString("HH:mm:ss:fff"));
            sb.AppendFormat("duration={0};", logEntry.Duration);
            sb.AppendFormat("loggingHostName={0};", logEntry.LoggingHostName);

            if (!string.IsNullOrWhiteSpace(logEntry.ErrorMessage))
            {
                sb.AppendFormat("errorMessage=\"{0}\", ;", logEntry.ErrorMessage.Replace(Environment.NewLine, " "));
            }
            if (logEntry.ExtendedProperties != null && logEntry.ExtendedProperties.Count > 0)
            {
                foreach (KeyValuePair <string, object> kvp in logEntry.ExtendedProperties)
                {
                    sb.Append(string.Format(", {0}=\"{1}\";", kvp.Key, kvp.Value));
                }
            }


            return(sb.ToString().TrimEnd(new char[] { ',', ' ' }));
        }
示例#9
0
            public void AddEntry(TransactionLogEntry tl_entry)
            {
                int factor = 1;

                switch (tl_entry.factor)
                {
                case "K": factor = 1000; break;

                case "M": factor = 1000000; break;

                case "B": factor = 1000000000; break;
                }

                ExpenseEntry entry = new ExpenseEntry
                {
                    month  = tl_entry.month,
                    reason = tl_entry.reason,
                    amount = Convert.ToInt32(tl_entry.amount) * factor
                };

                expenses.Add(entry);
            }
        private void HandleTransactionFlow(TransactionLogEntry methodLogEntry,
                                           InvocationContext invocationContext, IBaseHandler targetObject, object result, Exception ex)
        {
            methodLogEntry.Duration          = _stopWatch.ElapsedMilliseconds;
            methodLogEntry.LoggingMethodName = invocationContext.GetExecutingMethodFullName();
            methodLogEntry.ErrorMessage      = ex == null ?
                                               (string.IsNullOrWhiteSpace(methodLogEntry.ErrorMessage) ?
                                                "None" : methodLogEntry.ErrorMessage) :
                                               !string.IsNullOrWhiteSpace(this.loggingAttribute.ErrorMessage) ?
                                               this.loggingAttribute.ErrorMessage : ex.Message;

            methodLogEntry.TransactionStatus = ex == null ? TransactionStatus.Success : TransactionStatus.Fail;
            if (this.loggingAttribute.InputLoggingReuired && invocationContext.Invocation.Arguments != null)
            {
                var serialier = JsonConvert.SerializeObject(invocationContext.Invocation.Arguments);
                serialier = serialier.Replace("\"", "'");
                serialier = serialier.Replace(",", ";");
                methodLogEntry.ExtendedProperties["inputData"] = "\"" + serialier + "\"";
                if (result != null)
                {
                    serialier = JsonConvert.SerializeObject(result);
                    serialier = serialier.Replace("\"", "'");
                    serialier = serialier.Replace(",", ";");
                    methodLogEntry.ExtendedProperties["outputData"] = "\"" + serialier + "\"";
                }
            }

            if (!this.loggingAttribute.IsFlowBreakReuired)
            {
                if (methodLogEntry.ExtendedProperties == null)
                {
                    methodLogEntry.ExtendedProperties = new Dictionary <string, object>();
                }
                methodLogEntry.ExtendedProperties["isPartialError"] = "True";
            }

            // Log
            Log.Info(methodLogEntry);
        }
示例#11
0
        void Events_SavedChanges(object sender, EntitySessionEventArgs e)
        {
            var entSession = (EntitySession)e.Session;
            var dur        = (int)(App.TimeService.ElapsedMilliseconds - entSession.TransactionStart);
            //Filter out entities/records that we do not need to track
            var recChanged = entSession.RecordsChanged;

            if (recChanged.Count == 0)
            {
                return;
            }
            var filteredRecs = recChanged.Where(r => ShouldTrack(r)).ToList();

            if (filteredRecs.Count == 0)
            {
                return;
            }
            string changes     = BuildChangeLog(filteredRecs);
            var    user        = entSession.Context.User;
            var    userSession = entSession.Context.UserSession;
            var    transEntry  = new TransactionLogEntry(entSession.Context, entSession.TransactionDateTime, dur, entSession.TransactionRecordCount, changes);

            _saveService.AddObject(transEntry);
        }
 public AppException(TransactionLogEntry logEntry, string userMessage) : base(userMessage)
 {
     LogEntry     = logEntry;
     _userMessage = userMessage;
 }
 public BaseApiController(TransactionLogEntry logEntry)
 {
     _logEntry = logEntry;
 }
示例#14
0
 public TestController(TransactionLogEntry logEntry, ISampleBc sampleBc) : base(logEntry)
 {
     _sampleBc = sampleBc;
 }
 public static void Info(TransactionLogEntry logEntry)
 {
     Logger.Info(_transactionlogFormatter.Format(logEntry));
 }
示例#16
0
 void Events_SavedChanges(object sender, EntitySessionEventArgs e)
 {
     var entSession = (EntitySession)e.Session;
       var dur = (int)(App.TimeService.ElapsedMilliseconds - entSession.TransactionStart);
       //Filter out entities/records that we do not need to track
       var recChanged = entSession.RecordsChanged;
       if(recChanged.Count == 0)
     return;
       var filteredRecs = recChanged.Where(r => !r.EntityInfo.Flags.IsSet(EntityFlags.DoNotTrack)).ToList();
       if(filteredRecs.Count == 0)
     return;
       string changes = BuildChangeLog(filteredRecs);
       var user = entSession.Context.User;
       var userSession = entSession.Context.UserSession;
       var transEntry = new TransactionLogEntry(entSession.Context, entSession.TransactionDateTime, dur, entSession.TransactionRecordCount, changes);
       _saveService.AddObject(transEntry);
 }
 public AppException(Exception ex, TransactionLogEntry logEntry, string userMessage) : base(userMessage, ex)
 {
     LogEntry = logEntry;
 }