void AddDraft_Click(object sender, EventArgs e) { LogTitle = Title.Text; LogContext = Editor.Html; Weblog_Log WL = new Weblog_Log(); WL.Log_CommentCount = 0; WL.Log_IsTop = false; WL.Log_IsVisible = true; WL.Log_ViewCount = 0; WL.Log_IP = Globals.IPAddress; WL.Log_IsDraft = true; WL.Log_LastModiTime = DateTime.Now; WL.Log_Title = LogTitle; WL.Log_Content = LogContext; WL.Log_UserId = blogContext.User.BlogUserID; WL.Log_CreateTime = DateTime.Now; BWeblog_log.Insert(WL); }
void AddDraft_Click(object sender, EventArgs e) { AddDraft.Enabled = false; LogTitle = Title.Text; LogContext = Editor.Text; try { if (TextBox2.Text != "") LogId = Convert.ToInt32(TextBox2.Text); } catch { } Weblog_Log WL = new Weblog_Log(); WL.Log_CateId = 0; //草稿部分类 WL.Log_CommentCount = 0; WL.Log_IsTop = false; WL.Log_IsVisible = true; WL.Log_ViewCount = 0; WL.Log_IP = Globals.IPAddress; WL.Log_IsDraft = true; WL.Log_LastModiTime = DateTime.Now; WL.Log_Title = LogTitle; WL.Log_Content = LogContext; WL.Log_UserId = blogContext.BlogUserId; WL.Log_CreateTime = Convert.ToDateTime(CreateTime.Text.Trim()); WL.Log_PassWord = ""; WL.Log_IsPasssword = false; //草稿不设置密码 WL.Log_KeyWords = KeyWords.Text.Trim(); if (LogId == 0) { BWeblog_log.Insert(WL); } else { WL.Log_Id = LogId; BWeblog_log.Update(WL); } BWeblog_log.SetLogCountByUID(blogContext.BlogUserId); PageRedirct(true, "操作成功,文章已经保存到草稿箱!"); }
void Add_Click(object sender, EventArgs e) { if (LogIdTex.Text != "") { CDES1 c = new CDES1(); LogId = Convert.ToInt32(c.Decrypt1(LogIdTex.Text)); } LogTitle = Title.Text; LogContext = Editor.Html; if (LogId == 0)//添加 { Weblog_Log WL = new Weblog_Log(); WL.Log_CommentCount = 0; WL.Log_IsTop = false; WL.Log_IsVisible = true; WL.Log_ViewCount = 0; WL.Log_IP = Globals.IPAddress; WL.Log_IsDraft = false; WL.Log_CreateTime = DateTime.Now; WL.Log_LastModiTime = DateTime.Now; WL.Log_Title = LogTitle; WL.Log_Content = LogContext; WL.Log_UserId = blogContext.User.BlogUserID; BWeblog_log.Insert(WL); PageRedirct(true); } else //修改 { Weblog_Log WL = new Weblog_Log(); WL.Log_IsDraft = false; WL.Log_Id = LogId; WL.Log_LastModiTime = DateTime.Now; WL.Log_Title = LogTitle; WL.Log_Content = LogContext; BWeblog_log.Update(WL); PageRedirct(true); } }
private void Add_Click(object sender, EventArgs e) { Add.Enabled = false; LogTitle = Title.Text; LogContext = Editor.Text; //myself:尽量不要使用try catch bool blHasLogID = int.TryParse(this.TextBox2.Text.Trim(), out LogId); if (!blHasLogID) { LogId = 0; } //try //{ // if(TextBox2.Text!="") // LogId = Convert.ToInt32(TextBox2.Text); //} //catch { } Weblog_Log WL = new Weblog_Log(); WL.Log_CateId = Convert.ToInt32(LogCategory.SelectedValue); WL.Log_CommentCount = 0; WL.Log_IsTop = false; WL.Log_IsVisible = true; WL.Log_ViewCount = 0; WL.Log_IP = Globals.IPAddress; WL.Log_IsDraft = false; WL.Log_LastModiTime = DateTime.Now; WL.Log_Title = LogTitle; WL.Log_Content = LogContext; WL.Log_UserId = blogContext.BlogUserId; WL.Log_CreateTime = Convert.ToDateTime(CreateTime.Text.Trim()); WL.Log_IsEnRePly = IsEnReply.Checked; WL.Log_IsIndexShow = IsIndexShow.Checked; if (AllowPsd.Checked == true&&TextBox1.Text.Trim()!="") { WL.Log_PassWord = TextBox1.Text.Trim(); WL.Log_IsPasssword = true; } else { WL.Log_PassWord = ""; WL.Log_IsPasssword = false; } WL.Log_KeyWords = KeyWords.Text.Trim(); int TxzID = Convert.ToInt32(BWeblog_User.GetByID(blogContext.BlogUserId).User_TxzId); int NewsUrlTypeID = -1; if (TxzID < 200000) { NewsUrlTypeID = 3; } else NewsUrlTypeID = 13; Ncuhome.Blog.Core.clubNewsService.NewsService clubNews = new Ncuhome.Blog.Core.clubNewsService.NewsService(); if (LogId == 0)//添加 { BWeblog_log.Insert(WL); try //peng 20081109 webservice 上要有异常处理 { clubNews.AddNews(TxzID, -1, WL.Log_Title, WL.Log_Content, NewsUrlTypeID, WL.Log_Id); } catch { } } else//更新 { WL.Log_Id = LogId; BWeblog_log.Update(WL); try //peng 20081109 { clubNews.AddNews(TxzID, -1, WL.Log_Title, WL.Log_Content, NewsUrlTypeID, WL.Log_Id); } catch { } } BWeblog_log.SetLogCountByUID(blogContext.BlogUserId); DateTime PublishTime = Convert.ToDateTime(CreateTime.Text.Trim()); if (PublishTime < DateTime.Now) PageRedirct(true, "操作成功,文章已经发布!"); else PageRedirct(true, "文章将于" + PublishTime.ToString() + "发布"); }
private void AddDraft_Click(object sender, EventArgs e) { AddDraft.Enabled = false; LogTitle = Title.Text; LogContext = Editor.Text; //myself:尽量不要使用try catch bool blHasLogID = int.TryParse(this.TextBox2.Text.Trim(), out LogId); if (!blHasLogID) { LogId = 0; } //try //{ // if (TextBox2.Text != "") // { // LogId = Convert.ToInt32(TextBox2.Text); // } //} //catch { } Weblog_Log WL = new Weblog_Log(); WL.Log_CateId = 0; //草稿部分类 WL.Log_CommentCount = 0; WL.Log_IsTop = false; WL.Log_IsVisible = true; WL.Log_ViewCount = 0; WL.Log_IP = Globals.IPAddress; WL.Log_IsDraft = true; WL.Log_LastModiTime = DateTime.Now; WL.Log_Title = LogTitle; WL.Log_Content = LogContext; WL.Log_UserId = blogContext.BlogUserId; WL.Log_CreateTime = Convert.ToDateTime( CreateTime.Text.Trim()); WL.Log_PassWord = ""; WL.Log_IsPasssword = false; //草稿不设置密码 WL.Log_KeyWords = KeyWords.Text.Trim(); if (LogId == 0) { BWeblog_log.Insert(WL); } else { WL.Log_Id = LogId; BWeblog_log.Update(WL); } PageRedirct(true, "操作成功,文章已经保存到草稿箱!"); }
/// <summary> /// 自动添加 /// </summary> /// <param name="WL"></param> /// <returns></returns> public static void AutoInsert(Weblog_Log WL,out int LogId) { BlogDataDataContext BD = new BlogDataDataContext(); BD.Weblog_Logs.InsertOnSubmit(WL); BD.SubmitChanges(); LogId = WL.Log_Id; }
public static void Update(Weblog_Log WL) { BlogDataDataContext BD = new BlogDataDataContext(); Weblog_Log temp = BD.Weblog_Logs.Single(p => p.Log_Id == WL.Log_Id); temp.Log_CateId = WL.Log_CateId; temp.Log_Title = WL.Log_Title; temp.Log_Content = WL.Log_Content; temp.Log_IsDraft = WL.Log_IsDraft; temp.Log_LastModiTime = WL.Log_LastModiTime; temp.Log_IsTop = WL.Log_IsTop; temp.Log_IsPasssword = WL.Log_IsPasssword; temp.Log_IsEnRePly = WL.Log_IsEnRePly; temp.Log_IsIndexShow = WL.Log_IsIndexShow; temp.Log_PassWord = WL.Log_PassWord; temp.Log_KeyWords = WL.Log_KeyWords; temp.Log_CreateTime = WL.Log_CreateTime; BD.SubmitChanges(); }
public static bool Insert(Weblog_Log WL ,out int Log_Id) { BlogDataDataContext BD = new BlogDataDataContext(); BD.Weblog_Logs.InsertOnSubmit(WL); BD.SubmitChanges(); Log_Id = WL.Log_Id; return true; }
/// <summary>Called before a Weblog_Log is deleted.</summary> /// <param name="instance">The instance.</param> partial void DeleteWeblog_Log(Weblog_Log instance);
/// <summary>Called before a Weblog_Log is updated.</summary> /// <param name="instance">The instance.</param> partial void UpdateWeblog_Log(Weblog_Log instance);
/// <summary>Called before a Weblog_Log is inserted.</summary> /// <param name="instance">The instance.</param> partial void InsertWeblog_Log(Weblog_Log instance);
private static void UpdateCss(object User_Id) { int UserId = Convert.ToInt32(User_Id); DateTime CurrentTime = DateTime.Now; Weblog_User WU = BWeblog_User.GetByID(UserId); DateTime BeViewLastTime = Convert.ToDateTime(WU.User_BeViewLastTime); TimeSpan TS = CurrentTime - BeViewLastTime; //当前时间与最后访问的时间差 if (TS.TotalDays > 1) { int Count = BWeblog_UserRssLink.GetRssLinkCountByUID(UserId); if (Count > 0) { WU.User_BeViewLastTime = CurrentTime; BWeblog_User.Update(WU); foreach (Weblog_UserRssLink WURL in BWeblog_UserRssLink.GetRssLinkByUID(UserId)) { Weblog_Log WL = new Weblog_Log(); try { RssFeed feed = RssFeed.Read(WURL.Weblog_UserRssLinkUrl); foreach (RssChannel channel in feed.Channels) { foreach (RssItem temp in channel.Items) { WL.Log_CreateTime = temp.PubDate; WL.Log_Title = temp.Title; if (!BWeblog_log.HasLogByUIDAndTitle(UserId, WL.Log_Title, WL.Log_CreateTime)) {//通过标题和日记的创建时间来判断日记是否已经存在 WL.Log_Title = temp.Title; WL.Log_Content = temp.Description+ "<br/>(原文出处:<a target='_blank' href='" + temp.Link+ "'>" + temp.Link+ "</a>)"; WL.Log_CateId = 1; WL.Log_CommentCount = 0; WL.Log_IsEnRePly = true; WL.Log_IsIndexShow = true; WL.Log_IsDraft = false; WL.Log_IsPasssword = false; WL.Log_IsVisible = true; WL.Log_LastModiTime = temp.PubDate; WL.Log_ViewCount = 0; WL.Log_UserId = UserId; BWeblog_log.Insert(WL); } } } //XDocument RssFeed = XDocument.Load(WURL.Weblog_UserRssLinkUrl); ////XDocument RssFeed = XDocument.Load("http://blog.ncuhome.cn/RssFiles/46.xml"); //foreach (var item in RssFeed.Descendants("item")) //{ // WL.Log_CreateTime = DateTime.Parse(item.Element("pubDate").Value); // WL.Log_Title = item.Element("title").Value; // if (!BWeblog_log.HasLogByUIDAndTitle(UserId, WL.Log_Title, WL.Log_CreateTime)) // {//通过标题和日记的创建时间来判断日记是否已经存在 // WL.Log_Title = item.Element("title").Value; // WL.Log_Content = item.Element("description").Value + "<br/>(原文出处:<a target='_blank' href='" + item.Element("link").Value + "'>" + item.Element("link").Value + "</a>)"; // WL.Log_CateId = 1; // WL.Log_CommentCount = 0; // WL.Log_IsDraft = false; // WL.Log_IsPasssword = false; // WL.Log_IsVisible = true; // WL.Log_LastModiTime = DateTime.Parse(item.Element("pubDate").Value); // WL.Log_ViewCount = 0; // WL.Log_UserId = UserId; // BWeblog_log.Insert(WL); // } //} BWeblog_log.SetLogCountByUID(BlogContext.Current.BlogUserId); } catch (Exception) { MailServices.MailServices ma = new Ncuhome.Blog.Core.MailServices.MailServices(); ma.WriteMail("系统消息更新rss:" + WURL.Weblog_UserRssLinkUrl + "失败!!时间:" + DateTime.Now.ToString(), "系统消息", WU.User_TxzId.ToString(), false, 46811, 1); } } } } }