Example #1
0
        public static Models.PageCommentLogsModels GetGoodLogs(long commentID, ViewModels.CommentLogType LogType, long MemberID)
        {
            SQLData.Database            db    = new SQLData.Database(WebInfo.Conn);
            SQLData.ParameterCollection paras = new SQLData.ParameterCollection();
            paras.Add("@CommentID", commentID);
            paras.Add("@MemberShipID", MemberID);
            paras.Add("@LogType", (int)LogType);

            string    sql      = @" SELECT * FROM PageCommentLogs WHERE CommentID=@CommentID AND MemberShipID=@MemberShipID AND LogType=@LogType";
            DataTable logTable = db.GetDataTable(sql, paras);

            if (logTable != null && logTable.Rows.Count > 0)
            {
                DataRow dr = logTable.Rows[0];
                PageCommentLogsModels item = new PageCommentLogsModels();
                item.ID           = long.Parse(dr["ID"].ToString());
                item.CommentID    = long.Parse(dr["CommentID"].ToString());
                item.MemberShipID = long.Parse(dr["MemberShipID"].ToString());
                item.LogType      = int.Parse(dr["LogType"].ToString());
                item.Browser      = dr["Browser"].ToString().Trim();
                item.UserAgent    = dr["UserAgent"].ToString().Trim();
                item.IP           = dr["IP"].ToString().Trim();
                item.IPNum        = dr["IPNum"].ToString().Trim();
                item.AddTime      = (DateTime)dr["AddTime"];
                return(item);
            }
            return(null);
        }
Example #2
0
        /// <summary>
        /// 檢查是否已投過票, 依 IP 及 MemberID (若非 NULL 時) 目前限制為 10 分鐘, return: true 已投過, 時效未過 | false: 未投過或時效已過
        /// </summary>
        /// <param name="commentID"></param>
        /// <param name="LogType"></param>
        /// <param name="MemberID"></param>
        /// <returns></returns>
        public static bool IsAddGoodLogOverTime(long commentID, ViewModels.CommentLogType LogType, long?MemberID)
        {
            //因應 cc 所提, 先不限制時間, 故 always false 2018-04-18 charlie_shan
            return(false);

            SQLData.Database db     = new SQLData.Database(WebInfo.Conn);
            string           AddCol = "";

            SQLData.ParameterCollection paras = new SQLData.ParameterCollection();
            paras.Add("@CommentID", commentID);
            paras.Add("@LogType", (int)LogType);
            paras.Add("@IP", WorkLib.GetItem.IPAddr());
            if (MemberID.HasValue)
            {
                AddCol = " AND MemberShipID=@MemberShipID ";
                paras.Add("@MemberShipID", MemberID.Value);
            }
            string sql = string.Format(@" SELECT TOP 1 * FROM  PageCommentLogs WHERE CommentID=@CommentID AND LogType=@LogType AND IP=@IP {0} Order By AddTime DESC "
                                       , AddCol);
            DataTable logTable = db.GetDataTable(sql, paras);

            if (logTable == null || logTable.Rows.Count <= 0)
            {
                return(false);
            }

            DateTime LastAddTime = DateTime.Parse(logTable.Rows[0]["AddTime"].ToString());

            if (DateTime.Now.Subtract(LastAddTime).TotalMinutes > 10)
            {
                return(false);
            }
            return(true);
        }
Example #3
0
        public static int AddGoodLogs(long commentID, ViewModels.CommentLogType LogType, string Browser, string UserAgent, long?MemberID)
        {
            int goodCountResult = 0;

            SQLData.Database db = new SQLData.Database(WebInfo.Conn);
            string           AddCol = "", AddColPara = "";

            SQLData.ParameterCollection paras = new SQLData.ParameterCollection();
            paras.Add("@ID", commentID);
            paras.Add("@NewLogID", WorkLib.GetItem.NewSN());
            paras.Add("@LogType", (int)LogType);
            paras.Add("@Browser", Browser);
            paras.Add("@UserAgent", UserAgent);
            paras.Add("@IP", WorkLib.GetItem.IPAddr());
            paras.Add("@IPNum", WorkLib.GetItem.GetIPNum().ToString());
            if (MemberID.HasValue)
            {
                AddCol     = ", MemberShipID";
                AddColPara = ", @MemberShipID";
                paras.Add("@MemberShipID", MemberID.Value);
            }
            string    sql      = string.Format(@" UPDATE PageComments SET GoodCount=GoodCount+1 WHERE ID=@ID;
                                INSERT PageCommentLogs (ID, CommentID{0}, LogType, Browser, UserAgent, IP, IPNum, AddTime) 
                                        VALUES (@NewLogID, @ID{1}, @LogType, @Browser, @UserAgent, @IP, @IPNum, GETDATE());
                                SELECT GoodCount FROM PageComments WHERE ID=@ID", AddCol, AddColPara);
            DataTable logTable = db.GetDataTable(sql, paras);

            if (logTable != null && logTable.Rows.Count > 0)
            {
                if (!string.IsNullOrEmpty(logTable.Rows[0][0].ToString()))
                {
                    goodCountResult = int.Parse(logTable.Rows[0][0].ToString());
                }
            }
            return(goodCountResult);
        }