Ejemplo n.º 1
0
        public void Insert(DEOperationLog log)
        {
            if (log != null)
            {
                log.CreateTime = SCActionContext.Current.TimePoint;
                StringBuilder strB = new StringBuilder(256);

                strB.Append(ORMapping.GetInsertSql(log, this.GetMappingInfo(), TSqlBuilder.Instance));
                strB.Append(TSqlBuilder.Instance.DBStatementSeperator);
                strB.Append("SELECT SCOPE_IDENTITY()");

                Decimal newID = (Decimal)DbHelper.RunSqlReturnScalar(strB.ToString(), this.GetConnectionName());

                log.ID = Decimal.ToInt32(newID);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 根据环境信息初始化Log。
        /// 初始化的属性包括:CorrelationID、RequestContextString、Operator、RealOperator
        /// </summary>
        /// <returns></returns>
        public static DEOperationLog CreateLogFromEnvironment()
        {
            DEOperationLog log = new DEOperationLog();

            log.CorrelationID        = Trace.CorrelationManager.ActivityId.ToString();
            log.RequestContextString = EnvironmentHelper.GetEnvironmentInfo();
            log.CreateTime           = SCActionContext.Current.TimePoint;

            if (DeluxePrincipal.IsAuthenticated)
            {
                log.Operator     = DeluxeIdentity.CurrentUser;
                log.RealOperator = DeluxeIdentity.CurrentRealUser;
            }

            return(log);
        }
        public static DEOperationLog ToOperationLog(this DEBase data, DEOperationType opType)
        {
            data.NullCheck("data");

            DEOperationLog log = DEOperationLog.CreateLogFromEnvironment();

            log.ResourceID    = data.ID;
            log.SchemaType    = data.SchemaType;
            log.OperationType = opType;
            log.Category      = data.Schema.Category;
            log.Subject       = string.Format("{0}: {1}",
                                              EnumItemDescriptionAttribute.GetDescription(opType), data.Name);

            log.SearchContent = data.ToFullTextString();

            return(log);
        }