/// <summary>
            /// Only replaces the <b>first</b> occurrence of the placeholder.
            /// </summary>
            /// <param name="eventName">The event whose name is going to be used.</param>
            /// <returns>
            /// The method name customised for the name of the supplied event.
            /// </returns>
            private string GetMethodNameCustomisedForEvent(string eventName)
            {
                string methodName = MethodName;

                if (MethodName.IndexOf(EventNamePlaceHolder) >= 0)
                {
                    methodName = MethodName.Replace(EventNamePlaceHolder, eventName);
                }
                return(methodName);
            }
示例#2
0
        public void LoggerJob()
        {
            string sql    = "";
            DbHelp dbHelp = new DbHelp(ConnString);

            #region 更新任务时间
            sql = string.Format("UPDATE [dbo].[sys_job] SET lastFireTime = '{0}', nextFireTime = '{1}' WHERE jobName = '{2}';", LastFireTime, NextFireTime, JobName);
            dbHelp.DataOperator(sql);
            #endregion

            #region 记录任务日志
            stopwatch.Stop();
            JobMessage = "总共耗时:" + stopwatch.Elapsed.TotalMilliseconds.ToString() + " 毫秒";

            JobName       = JobName.Replace("'", "''");
            JobGroup      = JobGroup.Replace("'", "''");
            MethodName    = MethodName.Replace("'", "''");
            MethodParams  = MethodParams.Replace("'", "''");
            JobMessage    = JobMessage.Replace("'", "''");
            ExceptionInfo = ExceptionInfo.Replace("'", "''");

            sql = string.Format(@"INSERT INTO [dbo].[sys_job_log]
                        ([jobName]
                        ,[jobGroup]
                        ,[methodName]
                        ,[methodParams]
                        ,[jobMessage]
                        ,[exceptionInfo]
                        ,[createTime]
                        ,[createBy])
                    VALUES
                        ('{0}'
                        ,'{1}'
                        ,'{2}'
                        ,'{3}'
                        ,'{4}'
                        ,'{5}'
                        , GETDATE()
                        , 'System')", JobName, JobGroup, MethodName, MethodParams, JobMessage, ExceptionInfo);
            dbHelp.DataOperator(sql);
            #endregion
        }
示例#3
0
 public TraceInvokePropSet(DateTime occurredAt, string content)
     : base(occurredAt, content)
 {
     this.PropertyName = MethodName.Replace("propSet_", "");
 }