Exemple #1
0
 public void AddSiteLog(int siteId, int channelId, int contentId, string action, string summary)
 {
     if (siteId <= 0)
     {
         LogUtils.AddAdminLog(AdminName, action, summary);
     }
     else
     {
         try
         {
             if (!string.IsNullOrEmpty(action))
             {
                 action = StringUtils.MaxLengthText(action, 250);
             }
             if (!string.IsNullOrEmpty(summary))
             {
                 summary = StringUtils.MaxLengthText(summary, 250);
             }
             if (channelId < 0)
             {
                 channelId = -channelId;
             }
             var logInfo = new SiteLogInfo(0, siteId, channelId, contentId, AdminName, PageUtils.GetIpAddress(), DateTime.Now, action, summary);
             DataProvider.SiteLogDao.Insert(logInfo);
         }
         catch
         {
             // ignored
         }
     }
 }
Exemple #2
0
        public void Insert(SiteLogInfo log)
        {
            var sqlString = "INSERT INTO siteserver_SiteLog(SiteId, ChannelId, ContentId, UserName, IpAddress, AddDate, Action, Summary) VALUES (@SiteId, @ChannelId, @ContentId, @UserName, @IpAddress, @AddDate, @Action, @Summary)";

            var parms = new IDataParameter[]
            {
                GetParameter(ParmSiteId, DataType.Integer, log.SiteId),
                GetParameter(ParmChannelId, DataType.Integer, log.ChannelId),
                GetParameter(ParmContentId, DataType.Integer, log.ContentId),
                GetParameter(ParmUserName, DataType.VarChar, 50, log.UserName),
                GetParameter(ParmIpAddress, DataType.VarChar, 50, log.IpAddress),
                GetParameter(ParmAddDate, DataType.DateTime, log.AddDate),
                GetParameter(ParmAction, DataType.VarChar, 255, log.Action),
                GetParameter(ParmSummary, DataType.VarChar, 255, log.Summary)
            };

            ExecuteNonQuery(sqlString, parms);
        }
        public static void AddSiteLog(int siteId, int channelId, int contentId, AdministratorInfo adminInfo, string action, string summary)
        {
            if (!ConfigManager.SystemConfigInfo.IsLogSite)
            {
                return;
            }

            if (siteId <= 0)
            {
                AddAdminLog(adminInfo, action, summary);
            }
            else
            {
                try
                {
                    DataProvider.SiteLogDao.DeleteIfThreshold();

                    if (!string.IsNullOrEmpty(action))
                    {
                        action = StringUtils.MaxLengthText(action, 250);
                    }
                    if (!string.IsNullOrEmpty(summary))
                    {
                        summary = StringUtils.MaxLengthText(summary, 250);
                    }
                    if (channelId < 0)
                    {
                        channelId = -channelId;
                    }
                    var siteLogInfo = new SiteLogInfo(0, siteId, channelId, contentId, adminInfo.UserName, PageUtils.GetIpAddress(), DateTime.Now, action, summary);

                    DataProvider.SiteLogDao.Insert(siteLogInfo);

                    DataProvider.AdministratorDao.UpdateLastActivityDate(adminInfo);
                }
                catch (Exception ex)
                {
                    AddErrorLog(ex);
                }
            }
        }