Beispiel #1
0
 public BlockPipe(ModelEnum model) : base(model.ToString(), new Model(ModelTypeEnum.Pipe, model))
 {
 }
Beispiel #2
0
 public BlockTileSet(ModelEnum model) : base(model.ToString(), new TileSetModel(model))
 {
 }
Beispiel #3
0
 /// <summary>
 /// 根据记录级别,日志写到文件或数据库中
 /// </summary>
 /// <param name="msg">日志内容(中文)</param>
 /// <param name="level">日志级别</param>
 /// <param name="source">日志来源,模块标识</param>
 /// <param name="classname">类名称</param>
 /// <param name="userID">用户GUID</param>
 /// <param name="refType">关联单据类型,0订单号</param>
 /// <param name="refID">关联单据号</param>
 /// <param name="bForceToDb">将日期强制写入数据库</param>
 public void WriteEvent(string msg, ModelEnum.ActionLevel level, ModelEnum.ActionSource source,
     string classname, Guid? userID, ModelEnum.NoteType? refType, Guid? refID, bool bForceToDb = false)
 {
     string sMessage = "";
     string sRefMsg;
     string sLevelMsg = "[INFO],[WARN],[ERROR]";
     string[] sLevelList = sLevelMsg.Split(',');
     byte nLevel = (byte)level;
     if (nLevel < sLevelList.Length)
         sMessage = sLevelList[nLevel];
     try
     {
         sRefMsg = (refID == null) ? "" : String.Format("[0][1]", refType.ToString(), refID);
         sMessage += String.Format("[{0}][{1}][{2}][{3}][{4}][{5}]", DateTimeOffset.Now.ToString("yyyy-MM-dd HH:mm:ss"),
             source.ToString(), classname, userID, sRefMsg, msg);
         StreamWriter oLogWriter = new StreamWriter(strLogFile, true);
         oLogWriter.WriteLine(sMessage);
         oLogWriter.Close();
         oLogWriter.Dispose();
         // 严重错误,写入数据库
         if ((bForceToDb) || ((level == ModelEnum.ActionLevel.ERROR) && (dbEntity != null)))
         {
             GeneralAction oAction = new GeneralAction { Grade = (byte)level, Source = (byte)source, ClassName = classname, UserID = userID, RefType = (byte)refType, RefID = refID, Matter = msg };
             dbEntity.GeneralActions.Add(oAction);
             dbEntity.SaveChanges();
         }
         if (bIsDebug) Debug.WriteLine("{0}, {1}", this.ToString(), sMessage);
     }
     catch (Exception ex)
     {
         try
         {
             sMessage = String.Format("[ERROR][{0}][{1}][{2}][{3}][][{4}]", DateTimeOffset.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                 ModelEnum.ActionSource.SYSTEM, this.ToString(), userID, ex.Message);
             StreamWriter oLogWriter = new StreamWriter(strLogFile, true);
             oLogWriter.WriteLine(sMessage);
             oLogWriter.Close();
             oLogWriter.Dispose();
             if (bIsDebug) Debug.WriteLine("{0}, {1}", this.ToString(), sMessage);
         }
         catch { }
     }
 }