示例#1
0
        /// <summary>
        /// 存储/更新实体对象是否成功
        /// </summary>
        public bool StoredSuccess(object Instance)
        {
            AccessWebNews aWebNews = Instance as AccessWebNews;

            if (aWebNews == null)
            {
                return(false);
            }

            string strOp = (aWebNews.NewsID == 0) ? "I" : "U@[NewsID=" + aWebNews.NewsID.ToString() + "]";
            string sql   = OleDbHelper.BuildSqlIU(OleDbHelper.DbDialect.MsAccess, "Tbl_Articles", strOp,
                                                  new string[] { "TypeID", "VirtualPath", "Sort", "IsPrimary",
                                                                 "Title", "Author", "InnerUserName", "Summary", "Content", "Pubed", "PublishDate", "Hits" },
                                                  new object[] {
                aWebNews.Channel.ChannelID,
                OleDbHelper.EscapeSQL(aWebNews.VirtualPath),
                aWebNews.Sort,
                aWebNews.IsPrimary,
                OleDbHelper.EscapeSQL(aWebNews.Title),
                OleDbHelper.EscapeSQL(aWebNews.Author),
                OleDbHelper.EscapeSQL(aWebNews.InnerUserName),
                OleDbHelper.EscapeSQL(aWebNews.Summary),
                OleDbHelper.EscapeSQL(aWebNews.Content),
                aWebNews.IsPubed,
                "N'Now()", aWebNews.Hits
            });

            strOp = FanmaquerOleDbModule.GetOleDbInstance(FanmaquarConfig.ConnectionKey).ExecuteNonQuery(sql).ToString();
            return(strOp != "0");
        }
示例#2
0
        /// <summary>
        /// 从数据行中加载实体对象
        /// </summary>
        public static AccessWebNews LoadFromDataRow(DataRow dRow)
        {
            if (dRow == null)
            {
                return(null);
            }

            AccessWebNews aWebNews = new AccessWebNews(Convert.ToInt32(dRow["NewsID"]));

            aWebNews.IsExist       = true;
            aWebNews.Channel       = new AccessWebChannel(Convert.ToInt32(dRow["TypeID"]));
            aWebNews.Title         = dRow["Title"].ToString();
            aWebNews.VirtualPath   = dRow["VirtualPath"].ToString();
            aWebNews.Sort          = Convert.ToInt32(dRow["Sort"]);
            aWebNews.IsPrimary     = Convert.ToBoolean(dRow["IsPrimary"]);
            aWebNews.Author        = dRow["Author"].ToString();
            aWebNews.InnerUserName = dRow["InnerUserName"].ToString();
            aWebNews.Summary       = dRow["Summary"].ToString();
            aWebNews.Content       = dRow["Content"].ToString();
            aWebNews.IsPubed       = Convert.ToBoolean(dRow["Pubed"]);
            aWebNews.TimeFlag      = Convert.ToDateTime(dRow["PublishDate"]);
            aWebNews.Hits          = Convert.ToInt32(dRow["Hits"]);

            aWebNews.IsFilled = true;
            return(aWebNews);
        }
示例#3
0
        /// <summary>
        /// 通过ID初始化实例对象实现
        /// </summary>
        public object GetInstanceById(int InstanceID)
        {
            AccessWebNews aWebNews = new AccessWebNews(InstanceID);
            DataRow       dRow     = FanmaquerOleDbModule.GetOleDbInstance(FanmaquarConfig.ConnectionKey)
                                     .GetDataRow(string.Format("select top 1 * from Tbl_Articles where NewsID={0}", InstanceID));

            if (dRow != null)
            {
                aWebNews         = AccessWebNews.LoadFromDataRow(dRow);
                aWebNews.IsExist = true;
            }
            aWebNews.IsFilled = true;
            return(aWebNews);
        }
示例#4
0
        /// <summary>
        /// 频道默认新闻
        /// </summary>
        public IWebNews GetPrimaryNews()
        {
            DataRow dRow = FanmaquerOleDbModule.GetOleDbInstance(FanmaquarConfig.ConnectionKey)
                           .GetDataRow(string.Format("select top 1 * from Tbl_Articles where IsPrimary=true and Pubed=true and TypeID={0} order by NewsID desc",
                                                     this.ChannelID));

            if (dRow != null)
            {
                AccessWebNews aWebNews = AccessWebNews.LoadFromDataRow(dRow);
                aWebNews.IsExist  = true;
                aWebNews.IsFilled = true;
                return(aWebNews);
            }
            else
            {
                return(null);
            }
        }
示例#5
0
        /// <summary>
        /// 获取相关属性的值
        /// </summary>
        private string GetInstanceValue(string x)
        {
            //Util.Debug(false, x);
            if (this.NewsID > 0)
            {
                AccessWebNews news = (this.IsFilled == false) ? (AccessWebNews)this.GetInstanceById(this.NewsID) : this;
                if (news.IsExist == true)
                {
                    object strRet = null;
                    switch (x.ToLower())
                    {
                    case "newsid": strRet = news.NewsID; break;

                    case "channelid": strRet = news.Channel.ChannelID; break;

                    case "title": strRet = news.Title; break;

                    case "virtualpath": strRet = news.VirtualPath; break;

                    case "sort": strRet = news.Sort; break;

                    case "isprimary": strRet = news.IsPrimary; break;

                    case "author": strRet = news.Author; break;

                    case "innerusername": strRet = news.InnerUserName; break;

                    case "summary": strRet = news.Summary; break;

                    case "content": strRet = news.Content; break;

                    case "publishdate": strRet = news.TimeFlag; break;

                    case "hits": strRet = news.Hits; break;

                    default: strRet = "";  break;
                    }
                    return(strRet.ToString());
                }
            }
            return("");
        }
示例#6
0
        private void ViewNews(int newsid)
        {
            AccessWebNews news = new AccessWebNews(newsid);
            if (news.IsFilled == false)
            {
                news = (new AccessWebNews()).GetInstanceById(news.NewsID) as AccessWebNews;
            }

            #region 判断新闻有效性
            if (news != null && news.IsExist == true && news.IsFilled == true)
            {
                AccessWebChannel newsChannel = (new AccessWebChannel(news.Channel.ChannelID)).GetInstance() as AccessWebChannel;
                if (newsChannel == null || news.IsFilled == false)
                {
                    ShowMessage("获取改新闻所在的频道设置失败,生成终止!");
                    return;
                }
                else
                {
                    TempletSetting tptConfig = newsChannel.TempletConfig;
                    if (tptConfig == null)
                    {
                        ShowMessage("该频道没有配置模板,不能浏览动态内容!");
                    }
                    else
                    {
                        if (tptConfig.GenerateDetailPage == false)
                        {
                            ShowMessage("该频道模板设置关闭了详细内容显示,请先打开再浏览动态内容!");
                            return;
                        }

                        using (TempletParse tpp = new TempletParse())
                        {
                            PageTemplet pageTpt = (new PageTemplet()).GetInstanceById(tptConfig.DetailPageTemplet.TempletID) as PageTemplet;
                            tptConfig.DetailPageTemplet.FileNameConfig.FileNameTag.SetResourceDependency(news);

                            MultiResDependency newsRes = new MultiResDependency(newsChannel, news);
                            tpp.SetResourceDependency(newsRes);
                            tpp.SetTaggedObjectCollection(pageTpt.TempletRawContent);

                            string strGenFileContent = HtmlTextGenerator.GetRightHtmlText(pageTpt.SiteBaseDir, tpp.ParsedResult);
                            DisplayContent(strGenFileContent);
                        }
                    }
                }
            }
            else
            {
                ShowMessage("该资讯无效!");
            }
            #endregion
        }
示例#7
0
 /// <summary>
 /// 根据网站页面完整相对地址自动更新页面内容
 /// </summary>
 /// <param name="fileRelatviePath">页面完整相对地址</param>
 public static void GeneratorByPath(string fileRelatviePath)
 {
     string trackPath = fileRelatviePath.Replace("'", "");
     //先找新闻表,再找频道表
     OleDbHelper hp = FanmaquerOleDbModule.GetOleDbInstance(FanmaquarConfig.ConnectionKey);
     object tid = hp.ExecuteScalar("select top 1 NewsID from Tbl_Articles where VirtualPath='" + trackPath + "'");
     if (tid != null)
     {
         AccessWebNews news = new AccessWebNews(Convert.ToInt32(tid));
         (new PageGenerator()).Generate(news);
     }
     else
     {
         tid = hp.ExecuteScalar("select top 1 TypeID from Tbl_Type where OuterLinkUrl='" + trackPath + "'");
         if (tid != null)
         {
             AccessWebChannel channel = new AccessWebChannel(Convert.ToInt32(tid));
            (new PageGenerator()).Generate(channel);
         }
     }
 }
示例#8
0
        /// <summary>
        /// 生成新闻静态文件
        /// </summary>
        /// <param name="news">仅指定了NewsID的新闻实体</param>
        public void Generate(AccessWebNews news)
        {
            if (news.IsFilled == false)
            {
                news = (new AccessWebNews()).GetInstanceById(news.NewsID) as AccessWebNews;
            }

            #region 判断新闻有效性
            if (news != null && news.IsExist == true && news.IsFilled == true)
            {
                AccessWebChannel newsChannel = (new AccessWebChannel(news.Channel.ChannelID)).GetInstance() as AccessWebChannel;
                if (newsChannel == null || news.IsFilled == false)
                {
                    ShowMessage("获取改新闻所在的频道设置失败,生成终止!");
                    return;
                }
                else
                {
                    TempletSetting tptConfig = newsChannel.TempletConfig;
                    if (tptConfig == null)
                    {
                        ShowMessage("该频道没有配置模板,不能生成相关文件!");
                    }
                    else
                    {
                        if (tptConfig.GenerateDetailPage == false)
                        {
                            ShowMessage("该频道模板设置关闭了生成详细文件,请先打开再执行生成操作!");
                            return;
                        }

                        string strGenFilePath, strFileName, strFileExt, strGenResult = "";
                        if (newsChannel.StaticFileGenDir.IndexOf("{#$ChannelID$#}") != -1)
                        {
                            newsChannel.StaticFileGenDir = newsChannel.StaticFileGenDir.Replace("{#$ChannelID$#}", newsChannel.ChannelID.ToString());
                        }
                        strGenFilePath = Util.ParseAppPath(newsChannel.StaticFileGenDir);
                        if (!strGenFilePath.EndsWith("\\")) strGenFilePath += "\\";

                        #region 单篇新闻生成
                        using (TempletParse tpp = new TempletParse())
                        {
                            PageTemplet pageTpt = (new PageTemplet()).GetInstanceById(tptConfig.DetailPageTemplet.TempletID) as PageTemplet;
                            tptConfig.DetailPageTemplet.FileNameConfig.FileNameTag.SetResourceDependency(news);
                            strFileName = tptConfig.DetailPageTemplet.FileNameConfig.FileNameTag.GetTagValue().ToString();
                            strFileExt = tptConfig.DetailPageTemplet.FileNameConfig.FileExtentionName;

                            MultiResDependency newsRes = new MultiResDependency(newsChannel, news);
                            tpp.SetResourceDependency(newsRes);
                            tpp.TagTrack = new System.Collections.Generic.Dictionary<string, string>();
                            tpp.TagTrack.Add("T" + pageTpt.TempletID.ToString(), pageTpt.ModifiedTime.ToString("yyyyMMddHHmmss"));
                            tpp.SetTaggedObjectCollection(pageTpt.TempletRawContent);

                            string newsfileWithFullPath = strGenFilePath + strFileName + strFileExt;
                            if (news.VirtualPath.Length > 5)
                            {
                                newsfileWithFullPath = Util.ParseAppPath(news.VirtualPath);
                            }
                            else
                            {
                                news.VirtualPath = newsChannel.StaticFileGenDir + strFileName + strFileExt;
                                news.RefreshVirtualPath();
                            }

                            string strGenFileContent = HtmlTextGenerator.GetRightHtmlText(pageTpt.SiteBaseDir, tpp.ParsedResult);
                            //插入Track代码
                            string trackPath = GetSiteRelativeUrl(newsfileWithFullPath);
                            GetTrackHtmlInSertCode(tpp.TagTrack, trackPath, "</body>", ref strGenFileContent);
                            strGenResult = OleDbHelper.SetTextFileContent(newsfileWithFullPath, "utf-8", strGenFileContent);
                            TrackUnit.RemoveUpdateRecord(0, trackPath);

                            if (strGenResult == "0")
                            {
                                FireGeneratorFileFinished(newsfileWithFullPath);
                            }

                            ShowMessage((strGenResult == "0") ? string.Format("新闻内容页文件生成成功!<a href=\"{0}\" target=\"_blank\">{0}</a>", GetSiteRelativeUrl(newsfileWithFullPath)) : "生成失败:" + strGenResult);
                        }
                        #endregion
                    }
                }
            }
            #endregion

            ShowMessage("已完成处理,如没有任何消息显示,这可能是该栏目没有内容或配置错误!");
            ShowMessage("$end$");
        }
示例#9
0
 /// <summary>
 /// 通过ID初始化实例对象实现
 /// </summary>
 public object GetInstanceById(int InstanceID)
 {
     AccessWebNews aWebNews = new AccessWebNews(InstanceID);
     DataRow dRow = FanmaquerOleDbModule.GetOleDbInstance(FanmaquarConfig.ConnectionKey)
         .GetDataRow(string.Format("select top 1 * from Tbl_Articles where NewsID={0}", InstanceID));
     if (dRow != null)
     {
         aWebNews = AccessWebNews.LoadFromDataRow(dRow);
         aWebNews.IsExist = true;
     }
     aWebNews.IsFilled = true;
     return aWebNews;
 }
示例#10
0
        /// <summary>
        /// 从数据行中加载实体对象
        /// </summary>
        public static AccessWebNews LoadFromDataRow(DataRow dRow)
        {
            if (dRow == null) return null;

            AccessWebNews aWebNews = new AccessWebNews(Convert.ToInt32(dRow["NewsID"]));
            aWebNews.IsExist = true;
            aWebNews.Channel = new AccessWebChannel(Convert.ToInt32(dRow["TypeID"]));
            aWebNews.Title = dRow["Title"].ToString();
            aWebNews.VirtualPath = dRow["VirtualPath"].ToString();
            aWebNews.Sort = Convert.ToInt32(dRow["Sort"]);
            aWebNews.IsPrimary = Convert.ToBoolean(dRow["IsPrimary"]);
            aWebNews.Author = dRow["Author"].ToString();
            aWebNews.InnerUserName = dRow["InnerUserName"].ToString();
            aWebNews.Summary = dRow["Summary"].ToString();
            aWebNews.Content = dRow["Content"].ToString();
            aWebNews.IsPubed = Convert.ToBoolean(dRow["Pubed"]);
            aWebNews.TimeFlag = Convert.ToDateTime(dRow["PublishDate"]);
            aWebNews.Hits = Convert.ToInt32(dRow["Hits"]);

            aWebNews.IsFilled = true;
            return aWebNews;
        }