예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="logLevel">0 debug,1 info,2 warning,3 error,10 operate</param>
        /// <param name="logContent"></param>
        /// <param name="loginName"></param>
        /// <param name="module"></param>
        /// <param name="experimentID"></param>
        public static void AddLogInfo(LogInfoLevelEnum logLevel, string logContent, string loginName, string module, Guid?experimentID)
        {
            LogInfo logInfo = new LogInfo()
            {
                LogID        = WanTaiObjectService.NewSequentialGuid(),
                LogContent   = logContent,
                LogLevel     = (short)logLevel,
                LoginName    = loginName,
                CreaterTime  = DateTime.Now,
                ExperimentID = experimentID,
                Module       = module
            };

            using (WanTaiEntities wanTaiEntities = new WanTaiEntities())
            {
                wanTaiEntities.AddToLogInfoes(logInfo);
                wanTaiEntities.SaveChanges();
            }
        }
예제 #2
0
 public static void InstertKingFisherLog(Guid experimentID, DateTime dtStart, DateTime dtEnd, out string ErrMsg)
 {
     ErrMsg = "success";
     using (SqlConnection con = new SqlConnection(WanTai.Common.Configuration.GetKingFisherConnectionString()))
     {
         try
         {
             SqlCommand cmd = new SqlCommand();
             cmd.Connection  = con;
             cmd.CommandText = "select * from tbl_log where creation_time between @dtStart and @dtEnd ";// + dtStart.ToUniversalTime().ToString() + "' and '" + dtEnd.ToString() + "'";
             DateTime _dtStart = dtStart.ToUniversalTime();
             DateTime _dtEnd   = dtEnd.ToUniversalTime();
             cmd.Parameters.AddWithValue("@dtStart", _dtStart);
             cmd.Parameters.AddWithValue("@dtEnd", _dtEnd);
             con.Open();
             SqlDataReader dReader = cmd.ExecuteReader();
             using (WanTaiEntities wanTaiEntities = new WanTaiEntities())
             {
                 while (dReader.Read())
                 {
                     LogInfo logInfo = new LogInfo()
                     {
                         LogID        = WanTaiObjectService.NewSequentialGuid(),
                         LogContent   = dReader["object_name"].ToString() + " " + dReader["message"].ToString(),
                         LogLevel     = (int)LogInfoLevelEnum.KingFisher,
                         LoginName    = SessionInfo.LoginName,
                         CreaterTime  = DateTime.Parse(dReader["creation_time"].ToString()).ToLocalTime(),
                         ExperimentID = experimentID,
                         Module       = "KingFisherLog"
                     };
                     wanTaiEntities.AddToLogInfoes(logInfo);
                 }
                 wanTaiEntities.SaveChanges();
             }
         }catch (Exception ex)
         {
             ErrMsg = "连接KingFisher数据库失败!";
             WanTai.Common.CommonFunction.WriteLog(ex.ToString());
         }
     }
 }