Exemplo n.º 1
0
        //生成中间页
        private void CreateMiddPage(List <string> list, ArticleInfoVO ainfo, AdPageInfoVO adinfo)
        {
            string html = "";

            string indexpath = HttpContext.Current.Server.MapPath(string.Format("{0}{1}", m_template, m_html_default));

            using (StreamReader reader = new StreamReader(indexpath))
            {
                html = reader.ReadToEnd();
            }

            string jsscript = "var domains = ['$domains$']; var rdmain = \"\"; if (domains.length == 1){ rdmain = domains[0];  }  else  { rdmain = domains[Math.floor(Math.random() * domains.length)]; }document.location.href = \"http://\" + rdmain;";

            jsscript = jsscript.Replace("$domains$", string.Join("','", list.ToArray()));
            Yahoo.Yui.Compressor.JavaScriptCompressor js = new Yahoo.Yui.Compressor.JavaScriptCompressor();

            string jstext = js.Compress(jsscript);

            html = html.Replace("$script$", jstext)
                   .Replace("$adid$", adinfo.Id.ToString())
                   .Replace("$ArticleDetail$", DN.Framework.Utility.HtmlHelper.DecodeHtml(ainfo.Content));

            string dir       = HttpContext.Current.Server.MapPath(m_diction);
            string nhtmlpath = Path.Combine(dir, "index.html");

            using (StreamWriter write = new StreamWriter(nhtmlpath))
            {
                write.Write(html);
                write.Flush();
                write.Close();
            }
        }
Exemplo n.º 2
0
        public ArticleInfoVO GetRandModel()
        {
            if (m_maxleng == 0)
            {
                Refresh();
            }

            ArticleInfoVO info = _list.First();
            int           len  = _random.Next(m_maxleng);

            for (int i = 0; i < m_maxleng; i++)
            {
                if (len == i)
                {
                    info = _list.Skip(len).First();
                }
            }

            return(info);
        }
Exemplo n.º 3
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            ArticleInfoVO info = new ArticleInfoVO();

            info.Title        = txtTitle.Value;
            info.Content      = hidContent.Value;
            info.CreateDate   = DateTime.Now;
            info.LastDate     = DateTime.Now;
            info.Title        = txtTitle.Value;
            info.TitleImg     = imgPerview.ImageUrl;
            info.AuditDate    = DateTime.Now;
            info.ChannelId    = int.Parse(ddlChannel.SelectedValue);
            info.CreateUserId = Account.UserId;
            info.TitleShort   = txtTitleShort.Text;

            if (ArticleInfoBLL.Instance.Add(info))
            {
                Response.Redirect("/Admin/Article/ArticleList.aspx");
            }
            else
            {
                lblMsg.Text = "【广告页面】己经存在。";
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 生成广告域名文件夹
        /// </summary>
        /// <param name="addomain"></param>
        public void CreatedAdDomain(AdDomainInfo addomain)
        {
            var info = AdPageInfoBLL.Instance.GetSingle(new AdPageInfoPara()
            {
                Id = addomain.AdId
            });
            var articleList = ArticleInfoBLL.Instance.GetModels(new ArticleInfoPara());

            StringBuilder sbdomain = new StringBuilder();
            List <string> domains  = new List <string>();

            if (info != null)
            {
                //分别获取HTML和CSS文件内容
                string indexpath = HttpContext.Current.Server.MapPath(string.Format("{0}{1}", m_template, m_html_index));
                string stylepath = HttpContext.Current.Server.MapPath(string.Format("{0}{1}", m_template, m_html_style));
                string html      = "";
                string style     = "";
                using (StreamReader reader = new StreamReader(indexpath))
                {
                    html = reader.ReadToEnd();
                }
                using (StreamReader reader = new StreamReader(stylepath))
                {
                    style = reader.ReadToEnd();
                }

                foreach (var item in addomain.Domains)
                {
                    if (string.IsNullOrEmpty(item))
                    {
                        continue;
                    }

                    string domain = CreateRoundDomain(item, addomain);
                    sbdomain.AppendLine(domain + ",");
                    domains.Add(domain);
                    string dir = string.Format("{0}{1}", m_diction, domain);
                    dir = HttpContext.Current.Server.MapPath(dir);
                    if (!Directory.Exists(dir))
                    {
                        Directory.CreateDirectory(dir);
                    }

                    ArticleInfoVO ainfo = articleList[m_random.Next(articleList.Count - 1)];


                    //写入域名相关的文件夹
                    string nhtmlpath  = Path.Combine(dir, "index.html");
                    string nstylename = Guid.NewGuid().ToString();
                    nstylename = nstylename.Substring(0, 4);
                    string nstylepath = Path.Combine(dir, string.Format("{0}.css", nstylename));

                    var result = ReplaceHtml(html, style, info, ainfo, nstylename);

                    using (StreamWriter write = new StreamWriter(nhtmlpath))
                    {
                        write.Write(result.Item1);
                        write.Flush();
                        write.Close();
                    }
                    using (StreamWriter write = new StreamWriter(nstylepath))
                    {
                        write.Write(result.Item2);
                        write.Flush();
                        write.Close();
                    }
                }
            }

            info.DomainList = sbdomain.ToString();
            AdPageInfoBLL.Instance.Edit(info);
            var arinfo = articleList[m_random.Next(articleList.Count - 1)];

            CreateMiddPage(domains, arinfo, info);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 更新静态文件内容
        /// </summary>
        /// <param name="html"></param>
        /// <param name="adpage"></param>
        /// <param name="info"></param>
        /// <returns></returns>
        private Tuple <string, string> ReplaceHtml(string html, string style, AdPageInfoVO adpage, ArticleInfoVO info, string stylefilename)
        {
            string        nhtml = html;
            StringBuilder sb    = new StringBuilder();

            sb.Append(style);

            //随机插入部分样式
            string rcss = Guid.NewGuid().ToString();

            sb.AppendLine(string.Format(".{0}", rcss));
            sb.Append("{color:red;padding:0px;}");
            string nstyle = sb.ToString();

            //替换CSS名称
            var csslist = GetCssList();

            foreach (var item in csslist)
            {
                nhtml.Replace(item.Key, item.Value);
                nstyle.Replace(item.Key, item.Value);
            }

            Yahoo.Yui.Compressor.CssCompressor css = new Yahoo.Yui.Compressor.CssCompressor();
            string nstylemin = css.Compress(nstyle);

            nhtml = nhtml.Replace("$AdPagetId$", adpage.Id.ToString())
                    .Replace("$ArticleDetail$", DN.Framework.Utility.HtmlHelper.DecodeHtml(info.Content))
                    .Replace("$UserCode$", DN.Framework.Utility.HtmlHelper.DecodeHtml(adpage.StaticContent))
                    .Replace("$Title$", info.Title)
                    .Replace("$version$", DateTime.Now.ToString("yyyyMMddhhmmss"))
                    .Replace("href=\"style.css\"", string.Format("href=\"{0}\"", stylefilename));

            return(new Tuple <string, string>(nhtml, nstylemin));
        }
Exemplo n.º 6
0
        public override bool Edit(ArticleInfoVO m)
        {
            CodeCommand command = new CodeCommand();

            command.CommandText = EDIT;

            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@ChannelId", Value = ParameterHelper.ConvertValue(m.ChannelId)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@ArticleTypeId", Value = ParameterHelper.ConvertValue(m.ArticleTypeId)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@Title", Value = ParameterHelper.ConvertValue(m.Title)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@TitleImg", Value = ParameterHelper.ConvertValue(m.TitleImg)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@TitleShort", Value = ParameterHelper.ConvertValue(m.TitleShort)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@LinkUrl", Value = ParameterHelper.ConvertValue(m.LinkUrl)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@PageKey", Value = ParameterHelper.ConvertValue(m.PageKey)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@PageDesc", Value = ParameterHelper.ConvertValue(m.PageDesc)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@ConetntShort", Value = ParameterHelper.ConvertValue(m.ConetntShort)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@Content", Value = ParameterHelper.ConvertValue(m.Content)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@ContentGroup", Value = ParameterHelper.ConvertValue(m.ContentGroup)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@Lable", Value = ParameterHelper.ConvertValue(m.Lable)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@Source", Value = ParameterHelper.ConvertValue(m.Source)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@EditUser", Value = ParameterHelper.ConvertValue(m.EditUser)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@IsContributions", Value = ParameterHelper.ConvertValue(m.IsContributions)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@IsState", Value = ParameterHelper.ConvertValue(m.IsState)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@IsShow", Value = ParameterHelper.ConvertValue(m.IsShow)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@ContributionsUserId", Value = ParameterHelper.ConvertValue(m.ContributionsUserId)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@OrderIndex", Value = ParameterHelper.ConvertValue(m.OrderIndex)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@IsHot", Value = ParameterHelper.ConvertValue(m.IsHot)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@IsHeadline", Value = ParameterHelper.ConvertValue(m.IsHeadline)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@IsTop", Value = ParameterHelper.ConvertValue(m.IsTop)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@OpenCount", Value = ParameterHelper.ConvertValue(m.OpenCount)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@CommentCount", Value = ParameterHelper.ConvertValue(m.CommentCount)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@LikeCount", Value = ParameterHelper.ConvertValue(m.LikeCount)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@StepCount", Value = ParameterHelper.ConvertValue(m.StepCount)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@CreateDate", Value = ParameterHelper.ConvertValue(m.CreateDate)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@LastDate", Value = ParameterHelper.ConvertValue(m.LastDate)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@CreateUserId", Value = ParameterHelper.ConvertValue(m.CreateUserId)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@AuditUserId", Value = ParameterHelper.ConvertValue(m.AuditUserId)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@AuditState", Value = ParameterHelper.ConvertValue(m.AuditState)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@AuditDate", Value = ParameterHelper.ConvertValue(m.AuditDate)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@AuditDesc", Value = ParameterHelper.ConvertValue(m.AuditDesc)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@IsAd", Value = ParameterHelper.ConvertValue(m.IsAd)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@Id", Value = ParameterHelper.ConvertValue(m.Id)
            });


            int result = DbProxyFactory.Instance.Proxy.ExecuteNonQuery(command);

            if (result >= 1)
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 7
0
        public override int InsertIdentityId(ArticleInfoVO m)
        {
            CodeCommand command = new CodeCommand();

            command.CommandText = INSERT + "; select @@Identity";

            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@ChannelId", Value = ParameterHelper.ConvertValue(m.ChannelId)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@ArticleTypeId", Value = ParameterHelper.ConvertValue(m.ArticleTypeId)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@Title", Value = ParameterHelper.ConvertValue(m.Title)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@TitleImg", Value = ParameterHelper.ConvertValue(m.TitleImg)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@TitleShort", Value = ParameterHelper.ConvertValue(m.TitleShort)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@LinkUrl", Value = ParameterHelper.ConvertValue(m.LinkUrl)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@PageKey", Value = ParameterHelper.ConvertValue(m.PageKey)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@PageDesc", Value = ParameterHelper.ConvertValue(m.PageDesc)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@ConetntShort", Value = ParameterHelper.ConvertValue(m.ConetntShort)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@Content", Value = ParameterHelper.ConvertValue(m.Content)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@ContentGroup", Value = ParameterHelper.ConvertValue(m.ContentGroup)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@Lable", Value = ParameterHelper.ConvertValue(m.Lable)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@Source", Value = ParameterHelper.ConvertValue(m.Source)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@EditUser", Value = ParameterHelper.ConvertValue(m.EditUser)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@IsContributions", Value = ParameterHelper.ConvertValue(m.IsContributions)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@IsState", Value = ParameterHelper.ConvertValue(m.IsState)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@IsShow", Value = ParameterHelper.ConvertValue(m.IsShow)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@ContributionsUserId", Value = ParameterHelper.ConvertValue(m.ContributionsUserId)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@OrderIndex", Value = ParameterHelper.ConvertValue(m.OrderIndex)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@IsHot", Value = ParameterHelper.ConvertValue(m.IsHot)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@IsHeadline", Value = ParameterHelper.ConvertValue(m.IsHeadline)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@IsTop", Value = ParameterHelper.ConvertValue(m.IsTop)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@OpenCount", Value = ParameterHelper.ConvertValue(m.OpenCount)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@CommentCount", Value = ParameterHelper.ConvertValue(m.CommentCount)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@LikeCount", Value = ParameterHelper.ConvertValue(m.LikeCount)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@StepCount", Value = ParameterHelper.ConvertValue(m.StepCount)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@CreateDate", Value = ParameterHelper.ConvertValue(m.CreateDate)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@LastDate", Value = ParameterHelper.ConvertValue(m.LastDate)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@CreateUserId", Value = ParameterHelper.ConvertValue(m.CreateUserId)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@AuditUserId", Value = ParameterHelper.ConvertValue(m.AuditUserId)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@AuditState", Value = ParameterHelper.ConvertValue(m.AuditState)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@AuditDate", Value = ParameterHelper.ConvertValue(m.AuditDate)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@AuditDesc", Value = ParameterHelper.ConvertValue(m.AuditDesc)
            });
            command.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@IsAd", Value = ParameterHelper.ConvertValue(m.IsAd)
            });


            var result = DbProxyFactory.Instance.Proxy.ExecuteScalar(command);

            return(int.Parse(result.ToString()));
        }
Exemplo n.º 8
0
 public override string GetOtherConditionByModel(ArticleInfoVO m)
 {
     return("");
 }
Exemplo n.º 9
0
 public override string GetOrderByModel(ArticleInfoVO m)
 {
     return("");
 }