Пример #1
0
 public CabLog(string userId, LogAction logType, int value)
 {
     UserId      = userId;
     LogType     = logType.ToString();
     CreatedDate = DateTime.Now.ToDynamoDbDateTime();
     Value       = value;
 }
Пример #2
0
        /// <summary>
        /// 创建日志实体
        /// </summary>
        /// <param name="DOMAINNAME"></param>
        /// <param name="OPTIONNAME"></param>
        /// <param name="RECORDTIME"></param>
        /// <param name="CLASSNAME"></param>
        /// <param name="METHORDNAME"></param>
        /// <param name="logaction"></param>
        /// <param name="TABLENAME"></param>
        /// <param name="RECORDIDENCOLS"></param>
        /// <param name="RECORDIDENCOLSVALUES"></param>
        /// <param name="USERNAMES"></param>
        /// <param name="IPS"></param>
        /// <param name="FUNCTIONNAME"></param>
        /// <param name="DESCRIPTIONS"></param>
        /// <param name="SYSTEMNAME"></param>
        /// <param name="SFLAG"></param>
        /// <returns></returns>
        public static SSY_LOGENTITY CreateLogDataEnt(LogTypeDomain DOMAINNAME, LogLevelOption OPTIONNAME, string RECORDTIME, string CLASSNAME, string METHORDNAME,
                                                     LogAction logaction, string TABLENAME, string RECORDIDENCOLS, string RECORDIDENCOLSVALUES, string USERNAMES, string IPS, string FUNCTIONNAME,
                                                     string DESCRIPTIONS, string SYSTEMNAME, string SFLAG)
        {
            SSY_LOGENTITY ssylog = new SSY_LOGENTITY();

            ssylog.DOMAINNAME           = DOMAINNAME.ToString();
            ssylog.OPTIONNAME           = OPTIONNAME.ToString();
            ssylog.RECORDTIME           = RECORDTIME;
            ssylog.CLASSNAME            = CLASSNAME;
            ssylog.METHORDNAME          = METHORDNAME;
            ssylog.OPERATERIDEN         = logaction.ToString();
            ssylog.TABLENAME            = TABLENAME;
            ssylog.RECORDIDENCOLS       = RECORDIDENCOLS;
            ssylog.RECORDIDENCOLSVALUES = RECORDIDENCOLSVALUES;
            ssylog.USERNAMES            = USERNAMES;
            ssylog.IPS          = IPS;
            ssylog.FUNCTIONNAME = FUNCTIONNAME;
            if (Common.Utility.ChangeByte(DESCRIPTIONS, 4000))
            {
                ssylog.DESCRIPTIONS = DESCRIPTIONS;
            }
            else
            {
                ssylog.DESCRIPTIONS = DESCRIPTIONS.Substring(0, 3900); //预防汉子多占位,这里只取3900
            }
            ssylog.SYSTEMNAME = SYSTEMNAME;
            ssylog.SFLAG      = SFLAG;

            ssylog.OPFlag = "I"; //日志全部是新增

            return(ssylog);
        }
Пример #3
0
        public static void LogInfo(LogAction action, String message)
        {
            var user = UserProfileEx.GetByUserSid(ConfigHelper.CurrentUserId);

            if (user != null)
            {
                LogInfo(String.Format("[{0}] [{1}] {2}", user.Alias, action.ToString("g").ToUpper().PadRight(7), message));
            }
        }
Пример #4
0
        /// <summary>
        /// Writes a log message in the form: '16:24:15:Added Choice -PLAYER'
        /// </summary>
        /// <remarks>Timestamp:EffectiveAction subject -optionalextrainfo</remarks>
        /// <param name="action">The user's effective action, e.g. Opened, Added, Edited, Deleted</param>
        /// <param name="subject">The subject of the effective action, e.g. Line, BranchLine, Choice, Speaker, Sound</param>
        /// <param name="extraInfo">A string containing any extra applicable information in a non-standard format</param>
        /// <param name="includeTimeStamp">True to add a time stamp to the start of this message, false otherwise.</param>
        public static void WriteAction(LogAction action, string subject, string extraInfo, bool includeTimeStamp)
        {
            string message;
            string subjectmsg = subject == null ? "<Subject not logged>" : subject;

            if (extraInfo != null && extraInfo != String.Empty)
            {
                message = action.ToString() + " " + subjectmsg + " -" + extraInfo;
            }
            else
            {
                message = action.ToString() + " " + subjectmsg;
            }
            if (includeTimeStamp)
            {
                message = Tools.GetTimeStamp(false) + " " + message;
            }

            OnMessage(new LogEventArgs(message));
        }
Пример #5
0
        //將LogInfo物件轉為Json,便於寫入NLog
        private RecordLogInfo ConvertLogInfo(string adAccount, LogType logType, EventLevel eventLevel, LogAction logAction, SystemName systemName, string logMessage, object logJsonObject, Exception logException)
        {
            var recordLogInfo = new RecordLogInfo
            {
                ADAcnt     = adAccount,
                LogType    = logType.ToString(),
                EventLevel = eventLevel.ToString(),
                SystemName = systemName.ToString(),
                Action     = logAction.ToString(),
                Message    = logMessage,
                Exception  = BuildExceptionMessage(logException)
            };

            try
            {
                try
                {
                    recordLogInfo.Json = JsonConvert.SerializeObject(logJsonObject);
                    return(recordLogInfo);
                }
                catch (Exception)
                {
                    foreach (var item in (IList)logJsonObject)
                    {
                        recordLogInfo.Json += JsonConvert.SerializeObject(item);
                    }
                    return(recordLogInfo);
                }
            }
            catch (Exception e)
            {
                var message = new StringBuilder();
                message.AppendLine();
                message.AppendLine("ConvertLogInfo error, object convert json error!");
                message.AppendLine(BuildExceptionMessage(e));
                NLogWriter(message.ToString(), EventLevel.Error);
                return(recordLogInfo);
            }
        }
Пример #6
0
        // http://www.tkachenko.com/blog/archives/000053.html
        // http://www.codeproject.com/KB/XML/XmlAppending.aspx
        private static void writeXmlLog(Mission mission, LogAction logAction)
        {
            if (!File.Exists(LOG_FILE))
            {
                XmlTextWriter textWritter = new XmlTextWriter(LOG_FILE, Encoding.Unicode);
                textWritter.WriteStartElement(LogXmlTag.Missions.ToString());
                textWritter.WriteEndElement();
                textWritter.Close();
            }

            DateTime    dateTime = DateTime.Now;
            XmlDocument xmlDoc   = new XmlDocument();

            xmlDoc.Load(LOG_FILE);

            // TODO: Prune old entries

            XmlElement subRoot = xmlDoc.CreateElement(LogXmlTag.Mission.ToString());

            subRoot.SetAttribute(LogXmlTag.Date.ToString(), dateTime.ToString("yyyy/MM/dd"));
            subRoot.SetAttribute(LogXmlTag.Time.ToString(), dateTime.ToString("HH:mm:ss"));
            subRoot.SetAttribute(LogXmlTag.Action.ToString(), logAction.ToString());
            subRoot.SetAttribute(LogXmlTag.Id.ToString(), mission.getId());
            subRoot.SetAttribute(LogXmlTag.Name.ToString(), mission.getName());
            subRoot.SetAttribute(LogXmlTag.Type.ToString(), mission.getType().ToString());
            subRoot.SetAttribute(LogXmlTag.Key.ToString(), mission.getKey());
            XmlText xmlTextMission = xmlDoc.CreateTextNode(mission.getXML());

            subRoot.AppendChild(xmlTextMission);
            xmlDoc.DocumentElement.AppendChild(subRoot);

            /*XmlTextWriter writer = new XmlTextWriter(LOG_FILE, Encoding.Unicode);
             * writer.Formatting = Formatting.Indented;
             * writer.Indentation = 3;
             * xmlDoc.Save(writer);*/
            xmlDoc.Save(LOG_FILE);
        }
Пример #7
0
 public LogEntity(LogAction action, DateTime date, string userName)
 {
     ActionType = action.ToString();
     Date       = date;
     UserName   = userName;
 }
Пример #8
0
Файл: Log.cs Проект: kcitwm/dova
 public static void Write(LogAction action, string dir, string msg)
 {
     if ((LogConfig.LogType & (int)action) != 0)
     {
         string key = logPrex + dir + "\\" + action.ToString();
         PushLog(key, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "\t" + msg);
     }
 }
Пример #9
0
Файл: Log.cs Проект: kcitwm/dova
 /// <summary>
 /// 
 /// </summary>
 /// <param name="action">日志类型</param>
 /// <param name="dep">记录日志目录深度,根据category 值 为 1 , 2</param>
 /// <param name="firstCategory">应用名</param>
 /// <param name="secondCategory">进程名</param>
 /// <param name="thirdCategory">类名</param>
 /// <param name="forthCategory">方法名</param>
 /// <param name="fithCategory">标志名</param>
 /// <param name="timeSpan"></param>
 /// <param name="msg"></param>
 public static void Write(LogAction action,int dep, string firstCategory, string secondCategory, string thirdCategory, string forthCategory, string fithCategory, long timeSpan, string msg)
 {
     if ((LogConfig.LogType & (int)action) != 0)
     {
         if (msg.Length > limitLength)
             msg = msg.Substring(0, limitLength / 2);
         string s = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "\t" + string.Format(Config.LogFormat3, firstCategory, secondCategory, thirdCategory, forthCategory,fithCategory, timeSpan, msg);
         string path = action.ToString();
         if (dep == 1)
             path = firstCategory + "\\" + path;
         else if (logDep == 2)
             path = firstCategory + "\\" + secondCategory + "\\" + path;
         PushLog(logPrex + path, s);
         s = null;
     }
 }
Пример #10
0
Файл: Log.cs Проект: kcitwm/dova
 public static void Write(LogAction action, string msg)
 {
     if ((LogConfig.LogType & (int)action) != 0)
         PushLog(logPrex + action.ToString(), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "\t" + msg);
 }
Пример #11
0
Файл: Log.cs Проект: kcitwm/dova
 public static void WriteNoTime(LogAction action, string dir, string msg)
 {
     if ((LogConfig.LogType & (int)action) != 0)
     {
         string key = action.ToString() + "\\" + dir;
         if (tempDirs.IndexOf(key + ",") == -1)
         {
             tempDirs += key + ",";
             //logs[key] = new StringBuilder(); ;
         }
         PushLog(key, msg);
     }
 }
Пример #12
0
	/// <summary>
	/// Generate a standard log entry line
	/// </summary>
	/// <param name="action">action identifier</param>
	/// <param name="username">user</param>
	/// <param name="target">target informatio for action</param>
	public void LogActivity(LogAction action, string username, string target = "", string msg = "")
	{

		// build a string containing the log entry
		StringBuilder sb = new StringBuilder();
		
		// capture the timestamp and add as the first column
		sb.Append(timestamp.ToShortDateString() + " " + timestamp.ToShortTimeString() + LogSeparator);

		// add the ip address
		sb.Append( HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"] + LogSeparator );

		// add the current user
		sb.Append( username + LogSeparator );

		// add the action
		sb.Append( action.ToString() + LogSeparator );

		// add the target information
		sb.Append( target + LogSeparator );

		// add the message
		sb.Append(msg + LogSeparator);

		// add the entry to the log file
		LogAppend(sb.ToString());
	}
Пример #13
0
        // http://www.tkachenko.com/blog/archives/000053.html
        // http://www.codeproject.com/KB/XML/XmlAppending.aspx
        private static void writeXmlLog(Mission mission, LogAction logAction)
        {
            if (!File.Exists(LOG_FILE))
            {
                XmlTextWriter textWritter = new XmlTextWriter(LOG_FILE, Encoding.Unicode);
                textWritter.WriteStartElement(LogXmlTag.Missions.ToString());
                textWritter.WriteEndElement();
                textWritter.Close();
            }

            DateTime dateTime = DateTime.Now;
            XmlDocument xmlDoc=new XmlDocument();
            xmlDoc.Load(LOG_FILE);

            // TODO: Prune old entries

            XmlElement subRoot = xmlDoc.CreateElement(LogXmlTag.Mission.ToString());
            subRoot.SetAttribute(LogXmlTag.Date.ToString(), dateTime.ToString("yyyy/MM/dd"));
            subRoot.SetAttribute(LogXmlTag.Time.ToString(), dateTime.ToString("HH:mm:ss"));
            subRoot.SetAttribute(LogXmlTag.Action.ToString(), logAction.ToString());
            subRoot.SetAttribute(LogXmlTag.Id.ToString(), mission.getId());
            subRoot.SetAttribute(LogXmlTag.Name.ToString(), mission.getName());
            subRoot.SetAttribute(LogXmlTag.Type.ToString(), mission.getType().ToString());
            subRoot.SetAttribute(LogXmlTag.Key.ToString(), mission.getKey());
            XmlText xmlTextMission = xmlDoc.CreateTextNode(mission.getXML());
            subRoot.AppendChild(xmlTextMission);
            xmlDoc.DocumentElement.AppendChild(subRoot);

            /*XmlTextWriter writer = new XmlTextWriter(LOG_FILE, Encoding.Unicode);
            writer.Formatting = Formatting.Indented;
            writer.Indentation = 3;
            xmlDoc.Save(writer);*/
            xmlDoc.Save(LOG_FILE);
        }