예제 #1
0
        /// <summary>
        /// <para>Creates a new ActionLog.</para>
        /// </summary>
        public virtual ActionLog GetActionLog(string actionKey, string[] keys, string[] values, string userKey)
        {
            ActionLog actionLog = new ActionLog();

            actionLog.ActionKey = actionKey;
            actionLog.Milliseconds = null;
            actionLog.UserKey = userKey;

            Dictionary<string, List<string>> keyValues = GetSelectedValues(keys, values);
            foreach (KeyValuePair<string, List<string>> kvp in keyValues)
            {
                ActionLogParameter actionLogParam = new ActionLogParameter();
                actionLogParam.ActionLog = actionLog;
                actionLogParam.Key = kvp.Key;
                foreach (string s in kvp.Value)
                {
                    actionLogParam.Values += s + ";";
                }
                actionLogParam.Values = actionLogParam.Values.TrimEnd(';');
                actionLog.ActionLogParameters.Add(actionLogParam);
            }

            return actionLog;
        }
예제 #2
0
        /// <summary>
        /// <para>Log an exception in the database.</para>
        /// </summary>
        public virtual ExceptionLog LogException(Exception exp, ActionLog actionLog)
        {
            string guid = Guid.NewGuid().ToString("N");
            ExceptionLog exLog = new ExceptionLog
            {
                Message = exp.Message,
                StackTrace = exp.StackTrace,
                Type = exp.GetType().ToString(),
                Guid = guid,
                ActionLog = actionLog
            };

            if (exp.InnerException != null)
            {
                exLog.InnerMessage = exp.InnerException.Message;
                exLog.InnerStackTrace = exp.InnerException.StackTrace;
            }

            new BaseRepository().Insert<ExceptionLog>(exLog);
            return exLog;
        }
예제 #3
0
 /// <summary>
 /// <para>Updates the database with the time it took for the action to complete.</para>
 /// </summary>
 public virtual void LogActionOperationTime(ActionLog actionLog)
 {
     actionLog.Milliseconds = actionLog.GetOperationTime();
     NH_PERFORMS.Instance.Flush();
 }