コード例 #1
0
 private void UpdateIndex()
 {
     // Update Lucene search index
     Indexer.LuceneIndexer li = new Indexer.LuceneIndexer();
     li.CreateIndexWriter();
     li.UpdateWebPage(NewsID.ToString(), URL, Headline, Content ?? "", "News");
     li.Close();
     li.IndexWords();
 }
コード例 #2
0
ファイル: AccessWebNews.cs プロジェクト: ridgew/fmq
        /// <summary>
        /// 获取对象键值定义
        /// </summary>
        public object GetDefinition(string x)
        {
            // 系统标签: {#$Channel.TypeId$#}
            // --
            // 新闻频道资料获取
            #region 获取频道相关信息
            if (x.StartsWith("{#$Channel."))
            {
                string key = x.Substring(11).TrimEnd('}', '$', '#');
                //OleDbHelper.AppendToFile("~/debug.log", System.Environment.NewLine + key);
                if (Channel.IsDefined(string.Concat("{#$", key, "$#}")))
                {
                    return(Channel.GetDefinition(string.Concat("{#$", key, "$#}")));
                }
                else
                {
                    return(Channel.GetDefinition(string.Concat("{#%", key, "%#}")));
                }
            }
            #endregion

            if (x.IndexOf("{#$NewsID$#}") != -1)
            {
                x = x.Replace("{#$NewsID$#}", NewsID.ToString());
            }

            // Show-{#%NewsID%#}
            StringBuilder   sb = new StringBuilder(x.Length);
            Regex           RE = new Regex(@"\{#%([\w]+)%#\}", RegexOptions.IgnoreCase | RegexOptions.Compiled);
            MatchCollection mc = RE.Matches(x);
            int             idxBegin = 0, idxEnd = 0;
            foreach (Match m in mc)
            {
                idxEnd = m.Index;
                sb.Append(x.Substring(idxBegin, idxEnd - idxBegin));
                //处理标签定义
                sb.Append(GetInstanceValue(m.Groups[1].Value));

                idxBegin = idxEnd + m.Length;
            }
            if (idxBegin < x.Length)
            {
                sb.Append(x.Substring(idxBegin));
            }
            return(sb.ToString());
        }
コード例 #3
0
        public void Delete()
        {
            using (SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString)) {
                using (SqlCommand cmd = new SqlCommand("DELETE FROM cms_News WHERE NewsSerial = @NewsSerial", cn)) {
                    cmd.CommandType = CommandType.Text;
                    cmd.Parameters.Add("@NewsSerial", SqlDbType.Int).Value = _NewsSerial;

                    cmd.Connection.Open();
                    cmd.ExecuteNonQuery();
                    cmd.Connection.Close();
                }
            }

            // Remove from Lucene search index
            Indexer.LuceneIndexer li = new Indexer.LuceneIndexer();
            li.CreateIndexWriter();
            li.Delete(NewsID.ToString());
            li.Close();
        }