Пример #1
0
        /// <summary>
        /// 获取栏目页网页
        /// </summary>
        /// <param name="columnId">行业类别</param>
        /// <param name="pageIndex">页码</param>
        /// <param name="pageSize">每页条数</param>
        /// <returns></returns>
        public List <htmlPara> GetHtmlList(string columnId, int pageIndex, int pageSize)
        {
            //分页查询
            List <htmlPara> hList = new List <htmlPara>();
            DataTable       dt    = SqlHelperCatalog.ExecuteDataTable(@"select * from 
                (select *, ROW_NUMBER() OVER(order by addTime desc) AS RowId from htmlPara where columnId=@columnId) as b where b.RowId between @startNum and @endNum",
                                                                      new SqlParameter("@columnId", columnId),
                                                                      new SqlParameter("@startNum", (pageIndex - 1) * pageSize + 1),
                                                                      new SqlParameter("@endNum", pageIndex * pageSize));

            if (dt.Rows.Count < 1)
            {
                return(null);
            }
            foreach (DataRow row in dt.Rows)
            {
                htmlPara hPara = new htmlPara();
                hPara.Id       = (long)row["Id"];
                hPara.userId   = row["userId"].ToString();
                hPara.title    = (string)row["title"];
                hPara.titleImg = (string)row["titleImg"];
                hPara.titleURL = (string)row["titleURL"];
                hPara.columnId = (string)row["columnId"];                                //栏目Id
                string content = (string)row["articlecontent"];
                hPara.articlecontent = ReplaceHtmlTag(content, 60);                      //产品简介
                hPara.city           = (string)row["city"];                              //生产城市
                hPara.smallCount     = (string)row["smallCount"];                        //起订
                hPara.companyName    = (string)SqlHelper.FromDBNull(row["companyName"]); //公司名字
                hPara.ten_qq         = (string)SqlHelper.FromDBNull(row["ten_qq"]);
                hPara.com_web        = (string)SqlHelper.FromDBNull(row["com_web"]);     //网址
                hPara.addTime        = ((DateTime)row["addTime"]).ToString("yyyy-MM-dd");
                hList.Add(hPara);
            }
            return(hList);
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="columnId"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public List <htmlPara> GetHtmlList(string count, string columnId)
        {
            //分页查询
            List <htmlPara> hList = new List <htmlPara>();
            DataTable       dt    = SqlHelperCatalog.ExecuteDataTable(@"select top (CONVERT(int,@count)) * from htmlPara where columnId !='@columnId' order by addTime desc",
                                                                      new SqlParameter("@columnId", columnId),
                                                                      new SqlParameter("@count", count));

            if (dt.Rows.Count < 1)
            {
                return(null);
            }
            foreach (DataRow row in dt.Rows)
            {
                htmlPara hPara = new htmlPara();
                hPara.Id       = (long)row["Id"];
                hPara.userId   = row["userId"].ToString();
                hPara.title    = (string)row["title"];
                hPara.titleImg = (string)row["titleImg"];
                hPara.titleURL = (string)row["titleURL"];
                hPara.columnId = (string)row["columnId"];                                //栏目Id
                string content = (string)row["articlecontent"];
                hPara.articlecontent = ReplaceHtmlTag(content, 60);                      //产品简介
                hPara.city           = (string)row["city"];                              //生产城市
                hPara.smallCount     = (string)row["smallCount"];                        //起订
                hPara.companyName    = (string)SqlHelper.FromDBNull(row["companyName"]); //公司名字
                hPara.ten_qq         = (string)SqlHelper.FromDBNull(row["ten_qq"]);
                hPara.com_web        = (string)SqlHelper.FromDBNull(row["com_web"]);     //网址
                hPara.addTime        = ((DateTime)row["addTime"]).ToString("yyyy-MM-dd");
                hList.Add(hPara);
            }
            return(hList);
        }
Пример #3
0
        /// <summary>
        /// 渲染详情页,伪静态
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public string DetailPage(HttpContext context)
        {
            string columnId = context.Request["cId"];
            string Id       = context.Request["Id"];

            if (string.IsNullOrEmpty(columnId) || string.IsNullOrEmpty(Id))
            {
                return(SqlHelperCatalog.WriteTemplate("", "404.html"));
            }
            try
            {
                htmlPara hInfo       = bll.GetHtmlPara(columnId, Id);
                string   keyword     = ""; //关键词
                string   description = ""; //描述
                if (hInfo.title.Length > 6)
                {
                    keyword = hInfo.title + "," + hInfo.title.Substring(0, 2) + "," + hInfo.title.Substring(2, 2) + "," + hInfo.title.Substring(4, 2);
                }
                else
                {
                    keyword = hInfo.title;
                }
                description = hInfo.title + "," + BLL.ReplaceHtmlTag(hInfo.articlecontent, 80)
                              .Replace("\r\n", "").Replace("<br/>", "").Replace("\r", "").Replace("\n", "").Replace("&nbsp;", "") + "...";//产品简介;//产品简介
                #region  一篇,下一篇
                List <string>   BAPage = new List <string>();
                List <htmlPara> pList  = bll.GetHtmlBAPage(columnId, Id);//上一篇,下一篇
                if (pList.Count == 1)
                {
                    BAPage.Add("上一篇:<a href = '" + pList[0].titleURL + "' >" + pList[0].title + "</a> <br />");//上一篇
                }
                if (pList.Count == 2)
                {
                    BAPage.Add("上一篇:<a href = '" + pList[0].titleURL + "' >" + pList[0].title + "</a> <br />");
                    BAPage.Add("下一篇:<a href = '" + pList[1].titleURL + "' >" + pList[1].title + "</a> <br />");//下一篇
                }
                #endregion
                var data = new
                {
                    htmlTitle = hInfo.title + "_" + hInfo.companyName,
                    hInfo,
                    keyword,
                    description,
                    hostUrl,
                    hostName,
                    columnName  = bll.GetColumns(" where Id=" + columnId)[0].columnName,
                    columnsList = bll.GetColumns(""),                   //导航
                    BAPage,
                    ProductFloat = bll.GetProFloat(hInfo.userId, "22"), //右侧浮动10条产品
                    NewsFloat    = bll.GetNewsFloat(hInfo.userId, "22") //右侧浮动10条新闻
                };
                string html = SqlHelperCatalog.WriteTemplate(data, "DetailModel.html");
                return(html);
            }
            catch (Exception ex)
            {
                return(json.WriteJson(0, ex.ToString(), new { }));
            }
        }
Пример #4
0
    /// <summary>
    /// 将html内容参数存入数据库
    /// </summary>
    /// <param name="info"></param>
    public void AddHtml(htmlPara info)
    {
        int a = SqlHelperCatalog.ExecuteNonQuery(@"INSERT INTO htmlPara
     ([title]
       ,[titleURL]
       ,[articlecontent]
       ,[columnId]
       ,[pinpai]
       ,[xinghao]
       ,[price]
       ,[smallCount]
       ,[sumCount]
       ,[unit]
       ,[city]
       ,[titleImg]
       ,[addTime]
       ,[ten_qq]
       ,[companyName]
       ,[com_web]
       ,[userId]
       ,[userName])
 VALUES
       (@title
       ,@titleURL+CONVERT(varchar(10), IDENT_CURRENT('htmlPara'))+'.html'
       ,@articlecontent
       ,@columnId
       ,@pinpai
       ,@xinghao
       ,@price
       ,@smallCount
       ,@sumCount
       ,@unit
       ,@city
       ,@titleImg
       ,@addTime
       ,@ten_qq
       ,@companyName
       ,@com_web
       ,@userId
       ,@userName)",
                                                 new SqlParameter("@title", SqlHelper.ToDBNull(info.title)),
                                                 new SqlParameter("@titleURL", SqlHelper.ToDBNull(info.titleURL)),
                                                 new SqlParameter("@articlecontent", SqlHelper.ToDBNull(info.articlecontent)),
                                                 new SqlParameter("@columnId", SqlHelper.ToDBNull(info.columnId)),
                                                 new SqlParameter("@pinpai", SqlHelper.ToDBNull(info.pinpai)),
                                                 new SqlParameter("@xinghao", SqlHelper.ToDBNull(info.xinghao)),
                                                 new SqlParameter("@price", SqlHelper.ToDBNull(info.price)),
                                                 new SqlParameter("@smallCount", SqlHelper.ToDBNull(info.smallCount)),
                                                 new SqlParameter("@sumCount", SqlHelper.ToDBNull(info.sumCount)),
                                                 new SqlParameter("@unit", SqlHelper.ToDBNull(info.unit)),
                                                 new SqlParameter("@city", SqlHelper.ToDBNull(info.city)),
                                                 new SqlParameter("@titleImg", SqlHelper.ToDBNull(info.titleImg)),
                                                 new SqlParameter("@addTime", SqlHelper.ToDBNull(info.addTime)),
                                                 new SqlParameter("@ten_qq", SqlHelper.ToDBNull(info.ten_qq)),
                                                 new SqlParameter("@companyName", SqlHelper.ToDBNull(info.companyName)),
                                                 new SqlParameter("@com_web", SqlHelper.ToDBNull(info.com_web)),
                                                 new SqlParameter("@userId", SqlHelper.ToDBNull(info.userId)),
                                                 new SqlParameter("@userName", SqlHelper.ToDBNull(info.username)));
    }
Пример #5
0
        /// <summary>
        /// 写模板
        /// </summary>
        /// <param name="hInfo"></param>
        /// <param name="uInfo"></param>
        /// <param name="username"></param>
        /// <param name="hName"></param>
        /// <returns></returns>
        public static bool WriteFile(htmlPara hInfo, cmUserInfo uInfo, string username, string hName)
        {
            //文件输出目录
            string path = HttpContext.Current.Server.MapPath("~/" + username + "/");

            // 读取模板文件
            string temp = HttpContext.Current.Server.MapPath("~/DetailPage.html");//模版文件

            //string str = SiteTemplate();//读取模版页面html代码
            string str = "";

            using (StreamReader sr = new StreamReader(temp, Encoding.GetEncoding("gb2312")))
            {
                str = sr.ReadToEnd();
                sr.Close();
            }
            string htmlfilename = hName;//静态文件名

            // 替换内容
            str = str.Replace("companyName_Str", uInfo.companyName);
            if (hInfo.title.Length > 6)
            {
                str = str.Replace("keywords_Str", hInfo.title + "," + hInfo.title.Substring(0, 2) + "," + hInfo.title.Substring(2, 2) + "," + hInfo.title.Substring(4, 2));
            }
            else
            {
                str = str.Replace("keywords_Str", hInfo.title);
            }
            str = str.Replace("description_Str", hInfo.articlecontent.Substring(0, 80));
            str = str.Replace("host_Str", host);
            str = str.Replace("catid_Str", hInfo.columnId);
            str = str.Replace("Id_Str", hInfo.Id.ToString());
            str = str.Replace("title_Str", hInfo.title);
            str = str.Replace("addTime_Str", hInfo.addTime);

            str = str.Replace("pinpai_Str", hInfo.pinpai);
            str = str.Replace("price_Str", hInfo.price);
            str = str.Replace("qiding_Str", hInfo.smallCount);
            str = str.Replace("gonghuo_Str", hInfo.sumCount);
            str = str.Replace("xinghao_Str", hInfo.xinghao);
            str = str.Replace("city_Str", hInfo.city);
            str = str.Replace("unit_Str", hInfo.unit);

            str = str.Replace("titleImg_Str", hInfo.titleImg);
            str = str.Replace("content_Str", hInfo.articlecontent);
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            // 写文件
            using (StreamWriter sw = new StreamWriter(path + htmlfilename, true))
            {
                sw.Write(str);
                sw.Flush();
                sw.Close();
            }
            return(true);
        }
Пример #6
0
        public string Post(string strJson)
        {
            BLL bll = new BLL();
            //需要做一个时间,每隔多长时间才允许访问一次
            string keyValue = NetHelper.GetMD5("liu" + "100dh888");
            string username = "";
            string url      = "";

            try
            {
                JObject jo = (JObject)JsonConvert.DeserializeObject(strJson);
                //return json.WriteJson(1, "dsasdasda", new { });
                string key = jo["key"].ToString();
                if (key != keyValue)
                {
                    return(json.WriteJson(0, "参数错误", new { }));
                }
                htmlPara hPara = new htmlPara();
                username     = jo["username"].ToString();
                hPara.userId = bll.GetUserId(username);//用户名
                //公司/会员信息
                cmUserInfo uInfo = bll.GetUser(string.Format("where username='******'", username));
                hPara.title = jo["title"].ToString();
                string cid = jo["catid"].ToString();
                if (string.IsNullOrEmpty(cid))
                {
                    return(json.WriteJson(0, "行业或栏目不能为空", new { }));
                }

                //命名规则:ip/目录/用户名/show_行业id+(五位数id)
                string showName = "show_" + cid + (bll.GetMaxId() + 1).ToString() + ".html";
                url                  = host + "/" + username + "/" + showName;
                hPara.titleURL       = url;
                hPara.articlecontent = HttpUtility.UrlDecode(jo["content"].ToString(), Encoding.UTF8); //内容,UrlDecode解码
                hPara.columnId       = cid;                                                            //行业id,行业新闻id=23
                hPara.pinpai         = jo["pinpai"].ToString();
                hPara.xinghao        = jo["xinghao"].ToString();
                hPara.price          = jo["price"].ToString();
                hPara.smallCount     = jo["qiding"].ToString();
                hPara.sumCount       = jo["gonghuo"].ToString();
                hPara.unit           = jo["unit"].ToString();
                hPara.city           = jo["city"].ToString();
                hPara.titleImg       = jo["thumb"].ToString();
                hPara.companyName    = uInfo.companyName;
                hPara.com_web        = uInfo.com_web;
                hPara.ten_qq         = uInfo.ten_qq;
                hPara.addTime        = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                bll.AddHtml(hPara);                          //存入数据库
                WriteFile(hPara, uInfo, username, showName); //写模板
            }
            catch (Exception ex)
            {
                return(json.WriteJson(0, ex.ToString(), new { }));
            }
            return(json.WriteJson(1, "发布成功", new { url, username }));
        }
Пример #7
0
        /// <summary>
        /// 右侧浮动栏,前十条新闻
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public List <htmlPara> GetNewsFloat(string userId)
        {
            List <htmlPara> hList = new List <htmlPara>();
            DataTable       dt    = SqlHelperCatalog.ExecuteDataTable(@"select top 10 * from htmlPara where userId=1 and columnId=20 order by addTime desc",
                                                                      new SqlParameter("@userId", userId));

            if (dt.Rows.Count < 1)
            {
                return(null);
            }
            foreach (DataRow row in dt.Rows)
            {
                htmlPara hPara = new htmlPara();
                hPara.Id       = (long)row["Id"];
                hPara.title    = (string)row["title"];
                hPara.titleURL = row["titleURL"].ToString();
                hList.Add(hPara);
            }
            return(hList);
        }
Пример #8
0
        /// <summary>
        /// XML
        /// </summary>
        /// <returns></returns>
        public List <htmlPara> GetXML()
        {
            List <htmlPara> hParaList = new List <htmlPara>();
            DataTable       dt        = SqlHelperCatalog.ExecuteDataTable("select top 1000 Id, title,titleURL,addTime from htmlPara order by Id desc");

            if (dt.Rows.Count < 1)
            {
                return(null);
            }
            foreach (DataRow row in dt.Rows)
            {
                htmlPara hPara = new htmlPara();
                hPara.Id       = (long)SqlHelper.FromDBNull(row["Id"]);
                hPara.title    = (string)SqlHelper.FromDBNull(row["title"]);
                hPara.titleURL = (string)SqlHelper.FromDBNull(row["titleURL"]);
                hPara.addTime  = ((DateTime)SqlHelper.FromDBNull(row["addTime"])).ToString("yyyy-MM-dd");
                hParaList.Add(hPara);
            }
            return(hParaList);
        }
Пример #9
0
        /// <summary>
        /// 右侧浮动栏,前十条公司产品
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public List <htmlPara> GetProFloat(string userId, string cId)
        {
            List <htmlPara> hList = new List <htmlPara>();
            DataTable       dt    = SqlHelperCatalog.ExecuteDataTable(@"select top 10 Id,title,titleURL from htmlPara where userId=@userId and columnId!=@columnId order by addTime desc",
                                                                      new SqlParameter("@userId", userId),
                                                                      new SqlParameter("@columnId", cId));

            if (dt.Rows.Count < 1)
            {
                return(null);
            }
            foreach (DataRow row in dt.Rows)
            {
                htmlPara hPara = new htmlPara();
                hPara.Id       = (long)SqlHelper.FromDBNull(row["Id"]);
                hPara.title    = (string)SqlHelper.FromDBNull(row["title"]);
                hPara.titleURL = (string)SqlHelper.FromDBNull(row["titleURL"]);
                hList.Add(hPara);
            }
            return(hList);
        }
Пример #10
0
        public string DetailPage(HttpContext context)
        {
            string columnId = context.Request["cId"];
            string Id       = context.Request["Id"];

            if (string.IsNullOrEmpty(columnId) || string.IsNullOrEmpty(Id))
            {
                return(SqlHelperCatalog.WriteTemplate("", "404.html"));
            }
            try
            {
                htmlPara hInfo   = bll.GetHtmlPara(columnId, Id);
                string   keyword = "";//关键词
                if (hInfo.title.Length > 6)
                {
                    keyword = hInfo.title + "," + hInfo.title.Substring(0, 2) + "," + hInfo.title.Substring(2, 2) + "," + hInfo.title.Substring(4, 2);
                }
                else
                {
                    keyword = hInfo.title;
                }
                var data = new
                {
                    title = hInfo.title + "_" + hInfo.companyName,
                    hInfo,
                    keyword,
                    description  = BLL.ReplaceHtmlTag(hInfo.articlecontent, 80),//产品简介
                    host         = hostUrl,
                    ProductFloat = bll.GetProFloat(hInfo.userId),
                    NewsFloat    = bll.GetNewsFloat(hInfo.userId)
                };
                string html = SqlHelperCatalog.WriteTemplate(data, "DetailModel.html");
                return(html);
            }
            catch (Exception ex)
            {
                return(json.WriteJson(0, ex.ToString(), new { }));
            }
        }
Пример #11
0
        /// <summary>
        /// 获取前多少条数据
        /// </summary>
        /// <param name="count">条数</param>
        /// <param name="columnId">栏目Id</param>
        /// <returns></returns>
        public List <htmlPara> GetHtmlList(string count, string columnId)
        {
            List <htmlPara> hList = new List <htmlPara>();
            DataTable       dt    = SqlHelperCatalog.ExecuteDataTable(@"select top (CONVERT(int,@count)) Id,title,titleURL,addTime from htmlPara where columnId !='@columnId' order by addTime desc",
                                                                      new SqlParameter("@columnId", columnId),
                                                                      new SqlParameter("@count", count));

            if (dt.Rows.Count < 1)
            {
                return(null);
            }
            foreach (DataRow row in dt.Rows)
            {
                htmlPara hPara = new htmlPara();
                hPara.Id       = (long)SqlHelper.FromDBNull(row["Id"]);
                hPara.title    = (string)SqlHelper.FromDBNull(row["title"]);
                hPara.titleURL = (string)SqlHelper.FromDBNull(row["titleURL"]);
                hPara.addTime  = ((DateTime)SqlHelper.FromDBNull(row["addTime"])).ToString("yyyy-MM-dd");
                hList.Add(hPara);
            }
            return(hList);
        }
Пример #12
0
        /// <summary>
        /// 获取单条信息
        /// </summary>
        /// <param name="Id"></param>
        /// <param name="columnId"></param>
        /// <returns></returns>
        public htmlPara GetHtmlPara(string columnId, string Id)
        {
            htmlPara  hPara = new htmlPara();
            DataTable dt    = SqlHelperCatalog.ExecuteDataTable(@"select * from htmlPara h left join columnInfo c on h.columnId=c.Id  where columnId =@columnId and h.Id=@Id",
                                                                new SqlParameter("@columnId", columnId),
                                                                new SqlParameter("@Id", Id));

            if (dt.Rows.Count != 1)
            {
                return(null);
            }
            DataRow row = dt.Rows[0];

            hPara.Id       = (long)SqlHelper.FromDBNull(row["Id"]);
            hPara.userId   = SqlHelper.FromDBNull(row["userId"]).ToString();
            hPara.title    = (string)SqlHelper.FromDBNull(row["title"]);
            hPara.titleImg = (string)SqlHelper.FromDBNull(row["titleImg"]);
            hPara.titleURL = (string)SqlHelper.FromDBNull(row["titleURL"]);
            hPara.columnId = (string)SqlHelper.FromDBNull(row["columnId"]);//栏目Id
            string content = (string)SqlHelper.FromDBNull(row["articlecontent"]);

            //hPara.articlecontent = ReplaceHtmlTag(content, 60);//产品简介
            hPara.articlecontent = content;
            hPara.city           = (string)SqlHelper.FromDBNull(row["city"]);        //生产城市
            hPara.smallCount     = (string)SqlHelper.FromDBNull(row["smallCount"]);  //起订
            hPara.xinghao        = (string)SqlHelper.FromDBNull(row["xinghao"]);     //型号
            hPara.unit           = (string)SqlHelper.FromDBNull(row["unit"]);        //单位
            hPara.sumCount       = (string)SqlHelper.FromDBNull(row["sumCount"]);    //供货总量
            hPara.price          = (string)SqlHelper.FromDBNull(row["price"]);       //单价
            hPara.pinpai         = (string)SqlHelper.FromDBNull(row["pinpai"]);      //品牌
            hPara.companyName    = (string)SqlHelper.FromDBNull(row["companyName"]); //公司名字
            hPara.ten_qq         = (string)SqlHelper.FromDBNull(row["ten_qq"]);
            hPara.com_web        = (string)SqlHelper.FromDBNull(row["com_web"]);     //网址
            hPara.addTime        = ((DateTime)SqlHelper.FromDBNull(row["addTime"])).ToString("yyyy-MM-dd");
            hPara.columnName     = (string)SqlHelper.FromDBNull(row["columnName"]);  //栏目名
            hPara.username       = (string)SqlHelper.FromDBNull(row["username"]);    //用户名
            return(hPara);
        }
Пример #13
0
        /// <summary>
        /// 查询上一条下一条
        /// </summary>
        /// <param name="columnId"></param>
        /// <param name="Id"></param>
        /// <returns></returns>
        public List <htmlPara> GetHtmlBAPage(string columnId, string Id)
        {
            List <htmlPara> hList = new List <htmlPara>();
            DataTable       dt    = SqlHelperCatalog.ExecuteDataTable(@"select top 1 -1 as [Sort],Id,title,columnId,titleURL from (select top 1 Id,title,columnId,titleURL from htmlPara where columnId=@columnId and Id<@Id order by Id desc) as tab_up 
                 union select top 1 1 as [Sort],Id,title,columnId,titleURL from (select top 1 Id,title,columnId,titleURL from htmlPara where columnId=@columnId and Id>@Id order by Id) as tab_up",
                                                                      new SqlParameter("@columnId", columnId),
                                                                      new SqlParameter("@Id", Id));

            if (dt.Rows.Count < 1)
            {
                return(null);
            }
            foreach (DataRow row in dt.Rows)
            {
                htmlPara hPara = new htmlPara();
                hPara.Id       = (long)row["Id"];
                hPara.title    = (string)row["title"];
                hPara.titleURL = row["titleURL"].ToString();
                hPara.columnId = (string)row["columnId"];
                hList.Add(hPara);
            }
            return(hList);
        }
Пример #14
0
        /// <summary>
        /// 发布系统调用的post接口
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public string ModuleHtml(HttpContext context)
        {
            string username = context.Request["username"];

            if (string.IsNullOrEmpty(username))
            {
                return(json.WriteJson(0, "用户名不能为空", new { }));
            }
            //key值判断
            string keyValue = NetHelper.GetMD5(username + "100dh888");
            string key      = context.Request["key"];

            if (key != keyValue)
            {
                return(json.WriteJson(0, "key值错误", new { }));
            }
            //根据username调用tool接口获取userInfo
            string     strjson  = NetHelper.HttpGet("http://tool.100dh.cn/UserHandler.ashx?action=GetUserByUsername&username="******"", Encoding.UTF8);//公共接口,调用user信息
            JObject    jo       = (JObject)JsonConvert.DeserializeObject(strjson);
            cmUserInfo userInfo = JsonConvert.DeserializeObject <cmUserInfo>(jo["detail"]["cmUser"].ToString());
            //时间间隔必须大于60秒
            DateTime dt  = DateTime.Now;
            DateTime sdt = Convert.ToDateTime(userInfo.beforePubTime);
            TimeSpan d3  = dt.Subtract(sdt);

            if (d3.TotalSeconds < 10)
            {
                return(json.WriteJson(0, "信息发布过快,请隔60秒再提交!", new { }));
            }
            //判断今日条数是否达到1000条
            if (userInfo.endTodayPubCount > 999)
            {
                return(json.WriteJson(0, "今日投稿已超过限制数!", new { }));
            }
            //判断所有条数是否发完
            if (!(userInfo.canPubCount > userInfo.endPubCount))
            {
                return(json.WriteJson(0, "会员套餐信息条数已发完!", new { }));
            }
            string url = "";

            try
            {
                htmlPara hInfo = new htmlPara();
                hInfo.userId = userInfo.Id.ToString();//用户名
                hInfo.title  = context.Request["title"];
                string cid = context.Request["catid"];
                if (string.IsNullOrEmpty(cid))
                {
                    return(json.WriteJson(0, "行业或栏目不能为空", new { }));
                }
                hInfo.columnId = cid;//行业id,行业新闻id=20
                string content = context.Request["content"];
                if (string.IsNullOrEmpty(content) || content.Length < 500)
                {
                    return(json.WriteJson(0, "文章不能少于500字,请丰富文章内容", new { }));
                }
                hInfo.articlecontent = content;
                //hInfo.articlecontent = HttpUtility.UrlDecode(jo["content"].ToString(), Encoding.UTF8);//内容,UrlDecode解码
                //命名规则:ip/目录/用户名/show_行业id+(五位数id)
                hInfo.titleURL    = hostUrl + "/" + username + "/ashow-" + cid + "-";
                hInfo.pinpai      = context.Request["pinpai"];
                hInfo.xinghao     = context.Request["xinghao"];
                hInfo.price       = context.Request["price"];
                hInfo.smallCount  = context.Request["qiding"];
                hInfo.sumCount    = context.Request["gonghuo"];
                hInfo.unit        = context.Request["unit"];
                hInfo.city        = context.Request["city"];
                hInfo.titleImg    = context.Request["thumb"];
                hInfo.addTime     = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                hInfo.username    = username;
                hInfo.ten_qq      = userInfo.ten_qq;
                hInfo.companyName = userInfo.companyName;
                hInfo.com_web     = userInfo.com_web;
                //hInfo.realmNameId = "1";//发到哪个站
                bll.AddHtml(hInfo);//存入数据库
                url = bll.GetTitleUrl(userInfo.Id.ToString());
                //调用tool接口,更新userInfo已发条数等信息
                NetHelper.HttpGet("http://tool.100dh.cn/UserHandler.ashx?action=UpUserPubInformation&userId=" + userInfo.Id, "", Encoding.UTF8);//公共接口,调用user信息
            }
            catch (Exception ex)
            {
                return(json.WriteJson(0, ex.ToString(), new { }));
            }
            return(json.WriteJson(1, "发布成功", new { url, username }));
        }
Пример #15
0
        public string ModuleHtml(HttpContext context)
        {
            //需要做一个时间,每隔多长时间才允许访问一次
            string keyValue = NetHelper.GetMD5("liu" + "100dh888");
            string url      = "";
            string key      = context.Request["key"];

            if (key != keyValue)
            {
                return(json.WriteJson(0, "key值错误", new { }));
            }
            string username = context.Request["username"];

            if (string.IsNullOrEmpty(username))
            {
                return(json.WriteJson(0, "用户名不能为空", new { }));
            }
            try
            {
                htmlPara hInfo = new htmlPara();
                hInfo.userId = bll.GetUserId(username);//用户名
                hInfo.title  = context.Request["title"];
                string cid = context.Request["catid"];
                if (string.IsNullOrEmpty(cid))
                {
                    return(json.WriteJson(0, "行业或栏目不能为空", new { }));
                }
                hInfo.columnId = cid;//行业id,行业新闻id=20
                string content = context.Request["content"];
                if (string.IsNullOrEmpty(content) || content.Length < 500)
                {
                    return(json.WriteJson(0, "文章不能少于500字,请丰富文章内容", new { }));
                }
                hInfo.articlecontent = content;
                //hInfo.articlecontent = HttpUtility.UrlDecode(jo["content"].ToString(), Encoding.UTF8);//内容,UrlDecode解码
                //命名规则:ip/目录/用户名/show_行业id+(五位数id)
                long htmlId = (bll.GetMaxId() + 1);
                hInfo.Id = htmlId;
                string showName = "show_" + cid + "_" + htmlId + ".html";
                url            = host + username + "/" + showName;
                hInfo.titleURL = url;
                //hInfo.titleURL = string.Format("handler/TestHandler.ashx?action=DetailPage&cId={0}&Id={1}", cid, htmlId);
                //url = host + hInfo.titleURL;
                hInfo.pinpai     = context.Request["pinpai"];
                hInfo.xinghao    = context.Request["xinghao"];
                hInfo.price      = context.Request["price"];
                hInfo.smallCount = context.Request["qiding"];
                hInfo.sumCount   = context.Request["gonghuo"];
                hInfo.unit       = context.Request["unit"];
                hInfo.city       = context.Request["city"];
                hInfo.titleImg   = context.Request["thumb"];
                hInfo.addTime    = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                hInfo.username   = username;
                //公司 / 会员信息
                cmUserInfo uInfo = bll.GetUser(string.Format("where username='******'", username));
                hInfo.companyName = uInfo.companyName;
                hInfo.com_web     = uInfo.com_web;
                //hInfo.realmNameId = "1";//发到哪个站
                bll.AddHtml(hInfo);      //存入数据库

                string keyword     = ""; //关键词
                string description = ""; //描述
                if (hInfo.title.Length > 6)
                {
                    keyword = hInfo.title + "," + hInfo.title.Substring(0, 2) + "," + hInfo.title.Substring(2, 2) + "," + hInfo.title.Substring(4, 2);
                }
                else
                {
                    keyword = hInfo.title;
                }
                description = BLL.ReplaceHtmlTag(hInfo.articlecontent, 80);//产品简介
                var data = new
                {
                    title = hInfo.title + "_" + hInfo.companyName,
                    hInfo,
                    keyword,
                    description,
                    host,
                    columnName   = bll.GetColumns(" where Id=" + cid)[0].columnName,
                    ProductFloat = bll.GetProFloat(hInfo.userId),
                    NewsFloat    = bll.GetNewsFloat(hInfo.userId)
                };
                string html = SqlHelperCatalog.WriteTemplate(data, "DetailModel.html");
                WriteFile(html, showName, username);//写模板
            }
            catch (Exception ex)
            {
                return(json.WriteJson(0, ex.ToString(), new { }));
            }
            return(json.WriteJson(1, "发布成功", new { url, username }));
        }