コード例 #1
0
        public static void Log(Logger logger, NLog.LogLevel LogLevel,
                               string Class, string Device, string Data,
                               string VehicleID = null, string CarrierID = null, string LogID = null, string Level = null, string ThreadID = null, string Lot = null, string XID = null, string Details = null,
                               [CallerMemberName] string Method = "")
        {
            LogObj logObj = LogObjPool.GetObject();

            try
            {
                logObj.dateTime  = DateTime.Now;
                logObj.Sequence  = getSequence();
                logObj.LogLevel  = LogLevel.Name;
                logObj.Class     = Class;
                logObj.Method    = Method;
                logObj.Device    = Device;
                logObj.Data      = Data;
                logObj.VH_ID     = VehicleID;
                logObj.CarrierID = CarrierID;

                logObj.LogID    = LogID;
                logObj.ThreadID = ThreadID != null ?
                                  ThreadID : Thread.CurrentThread.ManagedThreadId.ToString();
                logObj.Lot   = Lot;
                logObj.Level = Level;

                string xid = System.Runtime.Remoting.Messaging.CallContext.GetData(CALL_CONTEXT_KEY_WORD_SERVICE_ID) as string;
                logObj.XID = xid;

                Transaction Transaction = getCurrentTransaction();
                logObj.TransactionID = Transaction == null ?
                                       string.Empty : Transaction.TransactionInformation.LocalIdentifier.ToString();
                logObj.Details = Details;
                logObj.Index   = "SystemProcessLog";

                LogHelper.logger.Log(LogLevel, logObj.ToString());
            }
            catch (Exception e)
            {
                LogHelper.logger.Error($"{e}, Exception");
            }
            finally
            {
                LogObjPool.PutObject(logObj);
            }
        }
コード例 #2
0
        public static void Log(Logger logger, NLog.LogLevel LogLevel,
                               string Class, string Device, string Data = "",
                               string VehicleID = null, string CarrierID = null, LogConstants.Type?Type = null, string LogID = null, string Level = null, string ThreadID = null, string Lot = null, string XID = null, string Details = null,
                               [CallerMemberName] string Method = "")
        {
            LogObj logObj = LogObjPool.GetObject();

            try
            {
                logObj.dateTime  = DateTime.Now;
                logObj.Sequence  = getSequence();
                logObj.LogLevel  = LogLevel.Name;
                logObj.Class     = Class;
                logObj.Method    = Method;
                logObj.Device    = Device;
                logObj.Data      = Data;
                logObj.VH_ID     = VehicleID;
                logObj.CarrierID = CarrierID;

                logObj.Type     = Type;
                logObj.LogID    = LogID;
                logObj.ThreadID = ThreadID != null ?
                                  ThreadID : Thread.CurrentThread.ManagedThreadId.ToString();
                logObj.Lot   = Lot;
                logObj.Level = Level;
                string service_id = System.Runtime.Remoting.Messaging.CallContext.GetData(CALL_CONTEXT_KEY_WORD_SERVICE_ID) as string;
                logObj.ServiceID = service_id;

                logObj.XID = XID;

                Transaction Transaction = getCurrentTransaction();
                logObj.TransactionID = Transaction == null ?
                                       string.Empty : Transaction.TransactionInformation.LocalIdentifier.ToString();
                logObj.Details = Details;
                logObj.Index   = "SystemProcessLog";

                LogHelper.logger.Log(LogLevel, logObj.ToString());
                //Task.Run(() => SCApplication.getInstance().LineService.PublishSystemLog(logObj));
                SYSTEMPROCESS_INFO systemProc = new SYSTEMPROCESS_INFO();
                systemProc.TIME     = DateTime.Now.ToString(SCAppConstants.DateTimeFormat_23);
                systemProc.SEQ      = logObj.Sequence;
                systemProc.LOGLEVEL = LogLevel.Name == null ? string.Empty : LogLevel.Name;
                systemProc.CLASS    = Class == null ? string.Empty : Class;
                systemProc.METHOD   = Method == null ? string.Empty : Method;
                systemProc.DEVICE   = Device == null ? string.Empty : Device;
                systemProc.DATA     = Data == null ? string.Empty : Data;
                systemProc.VHID     = VehicleID == null ? string.Empty : VehicleID;
                systemProc.CRRID    = CarrierID == null ? string.Empty : CarrierID;
                systemProc.TYPE     = Type.ToString();
                systemProc.LOGID    = LogID == null ? string.Empty : LogID;
                systemProc.THREADID = logObj.ThreadID;
                systemProc.LOT      = Lot == null ? string.Empty : Lot;
                systemProc.LEVEL    = Level == null ? string.Empty : Level;
                systemProc.XID      = XID == null ? string.Empty : XID;
                systemProc.TRXID    = logObj.TransactionID;
                systemProc.DETAILS  = Details == null ? string.Empty : Details;
                System.Threading.ThreadPool.QueueUserWorkItem(new WaitCallback(SCApplication.getInstance().LineService.PublishSystemMsgInfo), systemProc);
            }
            catch (Exception e)
            {
                LogHelper.logger.Error($"{e}, Exception");
            }
            finally
            {
                LogObjPool.PutObject(logObj);
            }
        }