protected void btnGen_Click(object sender, EventArgs e) { try { NewsListInfo list = new NewsListInfo(); foreach (GridViewRow row in gvList.Rows) { CheckBox cbSel = row.FindControl("cbSel") as CheckBox; string id = cbSel.Attributes["value"]; NewsInfo nInfo = new News().GetByID(id); if (cbSel.Checked == true) { PicNewsInfo pInfo = new PicNewsInfo(); pInfo.Summary = nInfo.Summary; pInfo.Url = this.SiteUrl + "Browse.aspx?id=" + id; pInfo.Title = nInfo.Title; string content = nInfo.Content; int imgStart = content.IndexOf("<img"); int srcStart = content.IndexOf("src", imgStart); int start = content.IndexOf("UploadFiles/", srcStart); int end = content.IndexOf("\"", start); pInfo.FilePath = content.Substring(start, end - start); list.List.Add(pInfo); } } Save(list); ShowMsg("图片新闻生成成功。"); } catch (Exception ex) { ShowMsg("生成出错:" + ex.Message); LogEntry.Log.Write(ex.ToString(), EventLogEntryType.Error, LogSourceType.一般错误); } }
/// <summary> /// 查询 /// </summary> private void Query() { QueryNewsParam param = new QueryNewsParam(); param.conName = "政务信息列表查询"; newsListInfo = null; newsListInfo = NewsAccess.QueryNewsLists(param); if ("9999".Equals(newsListInfo.success)) { setShowinfo(newsListInfo.msg); hideTitle(); return; } int j = newsListInfo.data.Count; j--; int count = 0; for (int i = j; i >= 0; i--) { resultInfo.Add(count, new string[] { newsListInfo.data[i].pubTime, newsListInfo.data[i].title }); count++; } setPage(pageNo); if (newsListInfo.data.Count == 0) { hideTitle(); throw new Exception(); } else { showTitle(); showinfo.Dispatcher.Invoke(new setTextBlockVisibilityDelegate(setTextBlockVisibility), showinfo, false); } }
private void Save(NewsListInfo nInfo) { if (null != nInfo && nInfo.List.Count != 0) { string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Flash\PicNews.xml"); SerializeHandler<NewsListInfo>.SerializeToXMLFile(nInfo, filePath); } gvSelect.DataSource = nInfo.List; gvSelect.DataBind(); gvSelect.Visible = true; }