示例#1
0
 public static int AddHumorInfo(T_Humor_HumorInfo humorInfo)
 {
     if (string.IsNullOrWhiteSpace(humorInfo.HumorContent))
     {
         return 0;
     }
     int res = dal_HumorInfo.AddHumorInfo(humorInfo);
     humorInfo.Id = res;
     return res;
 }
示例#2
0
 /// <summary>
 /// 添加帖子
 /// </summary>
 /// <param name="humorInfo"></param>
 /// <returns></returns>
 public static int AddHumorInfo(T_Humor_HumorInfo humorInfo)
 {
     SqlParameter[] prams = {
                               new SqlParameter("@CreateUserId", humorInfo.CreateUserId),
                               new SqlParameter("@HumorTitle", humorInfo.HumorTitle),
                               new SqlParameter("@HumorType", humorInfo.HumorType),
                               new SqlParameter("@HumorUbbContent", humorInfo.HumorUbbContent),
                               new SqlParameter("@HumorContent", humorInfo.HumorContent),
                               new SqlParameter("@CommentNum",humorInfo.CommentNum),
                               new SqlParameter("@CreateUserName", humorInfo.CreateUserName),
                               new SqlParameter("@SupportNum", humorInfo.SupportNum),
                               new SqlParameter("@OpposeNum", humorInfo.OpposeNum),
                               new SqlParameter("@IpAddress", humorInfo.IpAddress),
                               new SqlParameter("@TagIds", humorInfo.TagIds)
                            };
     return Convert.ToInt32(SqlHelper.ExecuteScalar(DbConfig.GetDb("Humor")
         , CommandType.StoredProcedure
         , "AddHumor"
         , prams));
 }
示例#3
0
 public static SolrHumorModel GetSolrHumor(T_Humor_HumorInfo humor)
 {
     if (humor == null)
     {
         return null;
     }
     int iHourCount = Convert.ToInt32(Math.Floor((DateTime.Now - humor.ShowTime).TotalHours));
     return new SolrHumorModel()
     {
         CommentNum = humor.CommentNum,
         CreateUserId = humor.CreateUserId,
         HumorContent = com_StringHelper.FilterContent(humor.HumorContent),
         HumorId = humor.Id,
         HumorTitle = humor.HumorTitle,
         Id = humor.Id.ToString(),
         IsDelete = humor.IsDelete,
         OpposeNum = humor.OpposeNum,
         SupportNum = humor.SupportNum,
         Tags = string.IsNullOrEmpty(humor.TagIds) ? new List<string>(0) : (humor.TagIds.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).ToList()),
         Score = (((humor.SupportNum - humor.OpposeNum * 5 + humor.CommentNum * 3) * (Math.Pow(2.71828182845905, (-Math.Pow(iHourCount, 3) / 144)) + 2 * Math.Pow(2.71828182845905, (-Math.Pow(iHourCount, 2) / 89))) / 3) * humor.Factor)
     };
 }
示例#4
0
 public static T_Humor_HumorInfo GetHumor(string html)
 {
     string regTitle = @"<div class=""mala-title"">
             <h2>(.+)?</h2>
         </div>";
     string regContent = @"<div class=""mala-img"">
                                     <a class=""mala-link-jump"" [^>]*> (.+)?</a>
             <div class=""mala-img-sponsor fn-clear"">
                 <!--广告位-->
                 广告
                 <!--广告位end-->
             </div>
             <!-- // mala-img-sponsor end -->
         </div>";
     string regGood = @"<i class=""ui-icon give-good""></i>[^<]*<em>(\d+)?</em>";
     string regBad = @"<i class=""ui-icon give-bad""></i>[^<]*<em>(\d+)?</em>";
     var match = Regex.Match(html, regTitle);
     string title = match.Groups[1].Value;
     var contentMatch = Regex.Match(html, regContent);
     string content = contentMatch.Groups[1].Value;
     int supportNum = Regex.Match(html, regGood).Groups[1].Value.ToSimpleT(0);
     int opposeNum = Regex.Match(html, regBad).Groups[1].Value.ToSimpleT(0);
     string regUserInfo = @"<a class=""mala-author-avatar"" href=""#"">[^<]*?<img src=""([^""]+)?""[^>]*?></a>[^<]*?<h5><a href=""http://www.jiongshibaike.com/users/([^""]+)?"">([^<]+)?</a></h5>";
     string regTags = @"<a href=""http://www.jiongshibaike.com/gs/([^""]+)?"" title=""([^""]+)?"">([^<]+)?</a>";
     Match matchUser=Regex.Match(html, regUserInfo);
     string face = "http://www.jiongshibaike.com/Data/Static/face/default.png";
     int userId = 0;
     string userName = "******";
     if (matchUser.Success)
     {
         face = matchUser.Groups[1].Value;
         userId = Convert.ToInt32(matchUser.Groups[2].Value);
         userName = matchUser.Groups[3].Value;
     }
     var matchs = Regex.Matches(html, regTags);
     string tags = string.Empty;
     foreach (Match m in matchs)
     {
         string tag = m.Groups[1].Value;
         tags += HttpUtility.UrlDecode(tag) + ",";
     }
     T_Humor_HumorInfo humorInfo=new T_Humor_HumorInfo()
     {
         HumorTitle = title,
         HumorContent = content,
         CreateUserId = userId,
         CreateUserName = userName,
         SupportNum = supportNum,
         OpposeNum = opposeNum,
         TagIds = tags,
         HumorUbbContent = "",
         HumorType = GetHumorType(content),
         IpAddress = "127.0.0.1"
     };
     return humorInfo;
 }
示例#5
0
 public static void UpdateHumorInfo(T_Humor_HumorInfo humorInfo)
 {
     SqlParameter[] prams = {
                               new SqlParameter("@HumorContent", humorInfo.HumorContent),
                               new SqlParameter("@HumorType", humorInfo.HumorType),
                               new SqlParameter("@Id", humorInfo.Id)
                            };
     SqlHelper.ExecuteNonQuery(DbConfig.GetDb("Humor"), CommandType.Text, @"
     UPDATE dbo.T_Humor_HumorInfo SET HumorContent=@HumorContent,HumorType=@HumorType WHERE id=@Id", prams);
 }
示例#6
0
        public static T_Humor_HumorInfo GetHumorInfo(string html)
        {
            /*
             <div id="fiddencontent_1266911" class="humordatacontent" style="display: none"></div>
             */

            string regTitle = @"<a  href=""javascript:;"" >(.+)?</a>
                        <!--版主导航条开始-->
            ";
            string regContent = @"<!--编辑导航条开始-->
                    </div>
                    <div class=""imgbox"">
                        (.+)?
                    </div>
            ";
            string regGood = @"<em class=""sicon"" id=""span_SupportNum[^""]+?""></em>\s*<span>(\d+)?</span>";
            string regBad = @"<em class=""xicon"" id=""span_OpposeNum[^""]+?""></em>\s*<span>(\d+)?</span>";
            string regCommentNum = @"<span class=""plFont"">(\d+)?</span>";
            string commentNum = Regex.Match(html, regCommentNum).Groups[1].Value;
            var match = Regex.Match(html, regTitle);
            if (!match.Success)
            {
                return null;
            }
            string title = match.Groups[1].Value;
            var contentMatch = Regex.Match(html, regContent);
            string content = contentMatch.Groups[1].Value;
            int supportNum = Regex.Match(html, regGood).Groups[1].Value.ToSimpleT(0);
            int opposeNum = Regex.Match(html, regBad).Groups[1].Value.ToSimpleT(0);
            string regUserInfo = @"<a href=""/u/([^""]+)?"" target=""_blank""><img src=""([^""]+)?"" width=""35"" height=""35"" /></a>
            ";
            string regTags = @"<p id=""em_[^""]+?"">

                                        <a target=""_blank"" href='/tag_\d+?_1.html'>(.+)?</a>
            ";
            Match matchUser = Regex.Match(html, regUserInfo);
            string face = "http://www.jiongshibaike.com/Data/Static/face/default.png";
            int userId = 0;
            string userName = "******";
            if (matchUser.Success)
            {
                face = matchUser.Groups[2].Value;
                userId = Convert.ToInt32(matchUser.Groups[1].Value);
            }
            var matchs = Regex.Matches(html, regTags);
            string tags = string.Empty;
            foreach (Match m in matchs)
            {
                string tag = m.Groups[1].Value;
                tags += HttpUtility.UrlDecode(tag) + ",";
            }
            T_Humor_HumorInfo humorInfo = new T_Humor_HumorInfo()
            {
                HumorTitle = title,
                HumorContent = content,
                CreateUserId = userId,
                CreateUserName = userName,
                SupportNum = supportNum,
                OpposeNum = opposeNum,
                TagIds = tags,
                HumorUbbContent = "",
                HumorType = GetHumorType(content),
                IpAddress = "127.0.0.1",
                CommentNum = commentNum.ToSimpleT(0)
            };
            return humorInfo;
        }