本文整理汇总了C#中Article类的典型用法代码示例。如果您正苦于以下问题:C# Article类的具体用法?C# Article怎么用?C# Article使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Article类属于命名空间,在下文中一共展示了Article类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateContentItem
/// <summary>
/// This should only run after the Article exists in the data store.
/// </summary>
/// <returns>The newly created ContentItemID from the data store.</returns>
public ContentItem CreateContentItem(Article objArticle, int tabId)
{
var typeController = new ContentTypeController();
var colContentTypes = (from t in typeController.GetContentTypes() where t.ContentType == ContentTypeName select t);
int contentTypeId;
if (colContentTypes.Count() > 0)
{
var contentType = colContentTypes.Single();
contentTypeId = contentType == null ? CreateContentType() : contentType.ContentTypeId;
}
else
{
contentTypeId = CreateContentType();
}
var objContent = new ContentItem
{
Content = objArticle.Title + " " + HttpUtility.HtmlDecode(objArticle.Description),
ContentTypeId = contentTypeId,
Indexed = false,
ContentKey = "aid=" + objArticle.ArticleId,
ModuleID = objArticle.ModuleId,
TabID = tabId
};
objContent.ContentItemId = Util.GetContentController().AddContentItem(objContent);
// Add Terms
var cntTerm = new Terms();
cntTerm.ManageArticleTerms(objArticle, objContent);
return objContent;
}
示例2: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (((DataView)odsDieuTriHo.Select()).Count <= DataPager1.PageSize)
{
DataPager1.Visible = false;
}
string strTitle, strDescription, strMetaTitle, strMetaDescription;
if (!string.IsNullOrEmpty(Request.QueryString["di"]))
{
var oArticle = new Article();
var oArticleCategory = new ArticleCategory();
var dv = oArticle.ArticleSelectOne(Request.QueryString["di"]).DefaultView;
if (dv != null && dv.Count <= 0) return;
var row = dv[0];
strTitle = Server.HtmlDecode(row["ArticleTitleEn"].ToString());
strDescription = Server.HtmlDecode(row["DescriptionEn"].ToString());
strMetaTitle = Server.HtmlDecode(row["MetaTittleEn"].ToString());
strMetaDescription = Server.HtmlDecode(row["MetaDescriptionEn"].ToString());
}
else
{
strTitle = strMetaTitle = "Cough Treatment";
strDescription = "";
strMetaDescription = "";
}
Page.Title = !string.IsNullOrEmpty(strMetaTitle) ? strMetaTitle : strTitle;
var meta = new HtmlMeta() { Name = "description", Content = !string.IsNullOrEmpty(strMetaDescription) ? strMetaDescription : strDescription };
Header.Controls.Add(meta);
}
}
示例3: AddEntity
public void AddEntity()
{
//Please use a normal running database and not the ones contained in the Base Class
using (var store = new DocumentStore())
{
store.Conventions.FindIdentityPropertyNameFromEntityName = typeName => "ID";
store.Conventions.FindIdentityProperty = prop => prop.Name == "ID";
IDocumentSession session = store.OpenSession();
var article = new Article
{
Title = "Article 1",
SubTitle = "Article 1 subtitle",
PublishDate = DateTime.UtcNow.Add(TimeSpan.FromDays(1))
};
session.Store(article);
session.SaveChanges();
Assert.True(article.ID > 0);
var insertedArticle = session.Query<Article>().Where(
a => a.ID.In(new int[] {article.ID}) && a.PublishDate > DateTime.UtcNow).FirstOrDefault();
Assert.NotNull(insertedArticle);
}
}
示例4: ArticleButton
public ArticleButton(Article art)
{
ArticleButtonDesign design = null;
string designdef = DatabaseHandler.GetArticleButtonDesignXml(art);
if (designdef == "")
design = ArticleButtonDesign.GetDefaultDesign();
else
{
design = new ArticleButtonDesign();
XmlReader reader = XmlReader.Create(new StringReader(designdef));
design.ReadXml(reader);
}
this.BackColor = design.BackColor;
this.ForeColor = design.ForeColor;
this.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.FlatAppearance.BorderSize = 0;
this.FlatAppearance.BorderColor = Color.Black;
this.Size = new Size(120, 30);
this.Location = CalculateArticleLocation(art.Position);
if (!art.IsEnabled)
{
this.Enabled = false;
this.Font = new Font(this.Font, FontStyle.Strikeout);
this.BackColor = Color.FromArgb(234, 234, 234);
}
if (!art.IsVisible) this.Visible = false;
if (!art.DoPrint) this.Font = new Font(this.Font, FontStyle.Italic);
this.Text = art.Name;
}
示例5: Main
static void Main(string[] args)
{
OrderedMultiDictionary<double, Article> articles = new OrderedMultiDictionary<double, Article>(true);
//filling the dictionary takes a few seconds
for (int i = 0; i <= 2000000; i++)
{
double price = i / 100.3;
Article article = new Article(i * 971, Math.Round(price, 2), i.ToString(), i.ToString());
articles.Add(price, article);
}
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
var articlesInRange = GetArticlesInPriceRange(articles, 1d, 300000d);
stopwatch.Stop();
//Uncomment to see found items title and price
StringBuilder sb = new StringBuilder();
//foreach (var node in articlesInRange)
//{
// foreach (var item in node.Value)
// {
// sb.AppendFormat("{0}: {1}\n", item.Title, item.Price);
// }
//}
Console.WriteLine(sb.ToString());
Console.WriteLine("Found count: {0}", articlesInRange.Count);
Console.WriteLine("Items in range found in: {0}", stopwatch.Elapsed);
}
示例6: AddEntity
public void AddEntity()
{
//SetUp
using (var store = NewDocumentStore())
{
store.Conventions.FindIdentityPropertyNameFromEntityName = (typeName) => "ID";
store.Conventions.FindIdentityProperty = prop => prop.Name == "ID";
using (IDocumentSession session = store.OpenSession())
{
var article = new Article()
{
Title = "Article 1",
SubTitle = "Article 1 subtitle",
PublishDate = DateTime.UtcNow.Add(TimeSpan.FromDays(1))
};
session.Store(article);
session.SaveChanges();
Assert.True(article.ID > 0);
var insertedArticle = session.Query<Article>().Where(
a => a.ID.In(new int[] {article.ID}) && a.PublishDate > DateTime.UtcNow).FirstOrDefault();
Assert.NotNull(insertedArticle);
}
}
}
示例7: GetFilesByArticle
public List<string> GetFilesByArticle(Article article)
{
var findNameBom = GetFileNameToFindBom(article);
var findNameDoc = GetFileNameToFindDoc(article);
var pathDataBom = Path.Combine(LocationDirectory, "BOM");
var pathDataDoc = Path.Combine(LocationDirectory, "Doc");
var dataFilesPatchBom = new List<string>();
var taskBom = new Task(() =>
{
dataFilesPatchBom.AddRange(Directory.GetFiles(pathDataBom, "*.pdf", SearchOption.AllDirectories));
dataFilesPatchBom.AddRange(Directory.GetFiles(pathDataBom, "*.tif*", SearchOption.AllDirectories));
});
taskBom.Start();
var dataFilesPatchDoc = new List<string>();
var taskDoc = new Task(() =>
{
dataFilesPatchDoc.AddRange(Directory.GetFiles(pathDataDoc, "*.pdf", SearchOption.AllDirectories));
dataFilesPatchDoc.AddRange(Directory.GetFiles(pathDataDoc, "*.tif*", SearchOption.AllDirectories));
});
taskDoc.Start();
Task.WaitAll(taskDoc, taskBom);
var files = dataFilesPatchBom.Where(x => x.Replace(pathDataBom, string.Empty).Contains(findNameBom)).Union(dataFilesPatchDoc.Where(y => y.Replace(pathDataDoc, string.Empty).Contains(findNameDoc))).ToList();
return files;
}
示例8: Add
public void Add(Article article)
{
ArticleBundle targetBundle = null;
foreach (ArticleBundle bundle in articleBundleSet)
{
if (bundle.MainArticle.Blog != article.Blog && AreSame(bundle.MainArticle, article))
{
targetBundle = bundle;
break;
}
}
if (targetBundle != null)
{
articleBundleSet.Remove(targetBundle);
targetBundle.Bundle(article);
articleBundleSet.Add(targetBundle);
}
else
{
articleBundleSet.Add(new ArticleBundle(article));
while (articleBundleSet.Count > maxNumArticleBundles)
{
articleBundleSet.Remove(articleBundleSet.Max);
}
}
}
示例9: DoDelete
public ActionResult DoDelete(Article article)
{
article.ACategoryName = "recycle";
DataOperator dop = new DataOperator(Runtime.SqlConfig);
dop.Update(article);
return Redirect("/Admin/Success.do");
}
示例10: ParsePagingPage
public override IEnumerable<Article> ParsePagingPage(string rawHtml)
{
var htmlDoc = new HtmlDocument();
htmlDoc.LoadHtml(rawHtml);
var articleNodes = htmlDoc.DocumentNode.SelectNodes("//tr[@height=28 and @bgcolor='white']");
if (articleNodes == null)
{
yield break;
}
foreach (var articleNode in articleNodes)
{
var link = articleNode.SelectSingleNode("td[@class='bbsSubject']").SelectSingleNode("a").Attributes["href"].Value;
const string token = "=&l=";
var articleId = int.Parse(link.Substring(link.LastIndexOf(token) + token.Length));
var article = new Article
{
Game = (int)Games.tera,
TargetSite = (int)TargetSites.inven,
CategoryId = CategoryId,
ArticleId = articleId,
Link = link,
Author = articleNode.SelectSingleNode("td[@align='left']").InnerText.Trim(),
};
yield return article;
}
}
示例11: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string strTitle, strDescription, strMetaTitle, strMetaDescription;
if (!string.IsNullOrEmpty(Request.QueryString["tv"]))
{
var oTuVan = new Article();
var dv = oTuVan.ArticleSelectOne(Request.QueryString["tv"]).DefaultView;
if (dv != null && dv.Count <= 0) return;
var row = dv[0];
strTitle = Server.HtmlDecode(row["ArticleTitle"].ToString());
strDescription = Server.HtmlDecode(row["Description"].ToString());
strMetaTitle = Server.HtmlDecode(row["MetaTittle"].ToString());
strMetaDescription = Server.HtmlDecode(row["MetaDescription"].ToString());
//hdnSanPham.Value = progressTitle(dv[0]["ProductCategoryName"].ToString()) + "-pci-" + dv[0]["ProductCategoryID"].ToString() + ".aspx";
}
else
{
strTitle = strMetaTitle = "Tư Vấn";
strDescription = "";
strMetaDescription = "";
}
Page.Title = !string.IsNullOrEmpty(strMetaTitle) ? strMetaTitle : strTitle;
var meta = new HtmlMeta() { Name = "description", Content = !string.IsNullOrEmpty(strMetaDescription) ? strMetaDescription : strDescription };
Header.Controls.Add(meta);
lblTitle.Text = strTitle;
lblTitle2.Text = strTitle;
}
}
示例12: GetMockRepository
public static Repository GetMockRepository(
Article article = null,
ArticleRevision articleRevision = null,
ArticleRedirect articleRedirect = null)
{
var documentStore =
new EmbeddableDocumentStore
{
Configuration =
{
RunInUnreliableYetFastModeThatIsNotSuitableForProduction
= true,
DefaultStorageTypeName = "munin",
RunInMemory = true,
}
}.Initialize();
DocumentStoreInitializer.InitDocumentStore(documentStore);
var repository = new Repository(documentStore);
if (article != null)
{
repository.SaveArticle(article, articleRevision);
}
if (articleRedirect != null)
{
string articleId = articleRedirect.RedirectToArticleSlug;
repository.SaveArticleRedirects(articleId, articleRedirect);
}
return new Repository(documentStore);
}
示例13: GetResponse
public AbstractResponse GetResponse(ReplyInfo reply, string openId)
{
if (reply.MessageType == MessageType.Text)
{
TextReplyInfo info = reply as TextReplyInfo;
TextResponse response = new TextResponse {
CreateTime = DateTime.Now,
Content = info.Text
};
if (reply.Keys == "登录")
{
string str = string.Format("http://{0}/Vshop/Login.aspx?SessionId={1}", HttpContext.Current.Request.Url.Host, openId);
response.Content = response.Content.Replace("$login$", string.Format("<a href=\"{0}\">一键登录</a>", str));
}
return response;
}
NewsResponse response2 = new NewsResponse {
CreateTime = DateTime.Now,
Articles = new List<Article>()
};
foreach (NewsMsgInfo info2 in (reply as NewsReplyInfo).NewsMsg)
{
Article item = new Article {
Description = info2.Description,
PicUrl = string.Format("http://{0}{1}", HttpContext.Current.Request.Url.Host, info2.PicUrl),
Title = info2.Title,
Url = string.IsNullOrEmpty(info2.Url) ? string.Format("http://{0}/Vshop/ImageTextDetails.aspx?messageId={1}", HttpContext.Current.Request.Url.Host, info2.Id) : info2.Url
};
response2.Articles.Add(item);
}
return response2;
}
示例14: addSentencesToArticle
private static void addSentencesToArticle(string file, Article article)
{
Sentence current = new Sentence();
string sentence = null;
string[] words = file.Split('\n');
for (int i = 0; i < words.Length; i++)
{
if (words[i] == "")
{
//now we are at the end of a sentence
if (sentence != null)
{
addWordsToSentence(sentence, current);
sentence = null;
article.addSentence(current); //add sentence to the article
current = new Sentence(); //empty the sentence;
}
}
else
{
sentence += (words[i] + '\n'.ToString());
}
}
if (sentence != null) //maybe the last sentence
{
addWordsToSentence(sentence, current);
article.addSentence(current);
}
}
示例15: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
BLArticle bll = new BLArticle();
art = bll.SelectOne(Request.QueryString["Id"]);
if (art != null)
{
this.artName.InnerText = art.ArticleName;
this.artDate.InnerText = art.AddDate.ToString("yyyy-MM-dd HH:mm:ss");
string path = GetPath(art.ArticlePath);
string artContent="出错了...";
try
{
artContent = System.Text.Encoding.Default.GetString(System.IO.File.ReadAllBytes(path));
}
catch { }
//artContent = System.Text.Encoding.Default.GetString(System.IO.File.ReadAllBytes(art.ArticlePath));
this.articleContent.InnerHtml = artContent;
fileName=art.ArticleName+art.AddDate.ToString("yyyy-MM-dd.HH-mm-ss");
listReview = new BLReview().SelectByArticleId(art.Id.ToString());
}
}
}