public List <string> GetVisitorInfo() { string sql = "select * from T_ARTICLE where ArtType=0"; DataTable dt = SqlServerHooker.GetDataTable(sql); string msg = string.Format("当前发表了{0}篇GIS类文章", dt.Rows.Count); List <string> listInfo = new List <string>(); listInfo.Add(Application["count"].ToString()); if (Application["browsertype"] != null) { listInfo.Add(Application["browsertype"].ToString()); } if (Application["ismobile"] != null) { listInfo.Add(Application["ismobile"].ToString()); } if (Application["ipaddress"] != null) { listInfo.Add(Application["ipaddress"].ToString()); } if (Application["visitpage"] != null) { listInfo.Add(Application["visitpage"].ToString()); } return(listInfo); }
protected void Page_Load(object sender, EventArgs e) { string sqlQuery = string.Format("select * from T_ARTICLE where ArtOrder={0} and ArtType={1}", _artOrder, _artType); DataTable dt = SqlServerHooker.GetDataTable(sqlQuery); artTitle.InnerText = dt.Rows[0]["ArtTitle"].ToString(); artDateTime.InnerText = "发表时间:" + ((DateTime)dt.Rows[0]["ArtDate"]).ToShortDateString(); artContent.InnerHtml = dt.Rows[0]["ArtContent"].ToString(); }
//选择文章管理表的一篇文章 protected void gvArtManager_SelectedIndexChanged(object sender, EventArgs e) { _selectArtID = (Guid)gvArtManager.DataKeys[gvArtManager.SelectedIndex].Value; ViewState["ArtID"] = _selectArtID; string sqlSelect = string.Format("select * from T_ARTICLE where ID='{0}'", _selectArtID); DataTable dt = SqlServerHooker.GetDataTable(sqlSelect); if (dt != null && dt.Rows.Count > 0) { txtArtTitle.Text = dt.Rows[0]["ArtTitle"].ToString(); //CKEditorControl1.Text = dt.Rows[0]["ArtContent"].ToString(); ddlArtType.SelectedIndex = int.Parse(dt.Rows[0]["ArtType"].ToString()); } }
protected void Page_Load(object sender, EventArgs e) { string sqlSelect = @"select top(1) * from T_ARTICLE where ArtType=0 and ArtDate=(select max(ArtDate) from T_ARTICLE where ArtType=0) union all select top(1) * from T_ARTICLE where ArtType=1 and ArtDate=(select max(ArtDate) from T_ARTICLE where ArtType=1) union all select top(1) * from T_ARTICLE where ArtType=2 and ArtDate=(select max(ArtDate) from T_ARTICLE where ArtType=2) union all select top(1) * from T_ARTICLE where ArtType=3 and ArtDate=(select max(ArtDate) from T_ARTICLE where ArtType=3) union all select top(1) * from T_ARTICLE where ArtType=4 and ArtDate=(select max(ArtDate) from T_ARTICLE where ArtType=4)"; DataTable dt = SqlServerHooker.GetDataTable(sqlSelect); lvLastedArticle.DataSource = dt; lvLastedArticle.DataBind(); }
public List <SiteVisitor> GetStatictisInfo() { string sqlSelect = "select * from T_VISITOR_INFO order by Date desc"; DataTable dt = SqlServerHooker.GetDataTable(sqlSelect); List <SiteVisitor> listVisitor = new List <SiteVisitor>(); for (int i = 0; i < dt.Rows.Count; i++) { SiteVisitor visitor = new SiteVisitor(); visitor.ID = i + 1; visitor.Date = dt.Rows[i]["DATE"].ToString(); visitor.BrowserType = dt.Rows[i]["BROWSERTYPE"].ToString(); visitor.DeviceType = dt.Rows[i]["DEVICETYPE"].ToString(); visitor.Location = dt.Rows[i]["LOCATION"].ToString(); visitor.VisitPage = dt.Rows[i]["VISITPAGE"].ToString(); listVisitor.Add(visitor); } return(listVisitor); }
//删除选中的文章 protected void btnDeleteArt_Click(object sender, EventArgs e) { for (int i = 0; i < gvArtManager.Rows.Count; i++) { //获取GridView中每一行的CheckBox引用 CheckBox chk = (CheckBox)gvArtManager.Rows[i].FindControl("chkCheck"); if (chk.Checked) { Guid artID = (Guid)gvArtManager.DataKeys[i].Value; string sqlQuery = string.Format("select * from T_ARTICLE where ID='{0}'", artID); DataTable dtQuery = SqlServerHooker.GetDataTable(sqlQuery); //删除文章中的图片 string imageNames = dtQuery.Rows[0][7].ToString(); string[] imageArr = imageNames.Split(';'); foreach (string imageName in imageArr) { string imgFtpPath = "ueditor/net/upload/image/" + imageName; _ftpManager.DeleteFile(imgFtpPath); } //删除ftp里面对应的html文件 string htmlName = dtQuery.Rows[0][6].ToString(); bool isSuc = _ftpManager.DeleteFile(string.Format("article/{0}.html", htmlName)); //if (isSuc) //{ //删除数据库信息 string sqlDelete = string.Format("delete from T_ARTICLE where ID='{0}'", artID); SqlServerHooker.DeleteDataFromTable(sqlDelete); //} } } //刷新GridView gvArtManager.DataBind(); }
//发布文章 protected void btnPublish_Click(object sender, EventArgs e) { string artTitle = txtArtTitle.Text; //文章标题 int artType = int.Parse(ddlArtType.SelectedValue); //文章类别 DateTime artPubTime = DateTime.Now; //文章发布时间 //string artContent = CKEditorControl1.Text; //文章内容 string artContent = Request.Params["content"]; //文章内容 int maxOrder = 0; string sqlQuery = string.Format("select max(ArtOrder) from T_ARTICLE where ArtType={0}", artType); DataTable dtQuery = SqlServerHooker.GetDataTable(sqlQuery); if (dtQuery == null || dtQuery.Rows[0][0].ToString() == "") { maxOrder = 1; } else { maxOrder = (int)dtQuery.Rows[0][0] + 1; } bool isSuc = true; if (radioList.SelectedIndex == 0) //新增文章 { string sqlInsert = string.Format("insert into T_ARTICLE(ID,ArtType,ArtTitle,ArtDate,ArtContent,ArtOrder) values('{0}',{1},'{2}','{3}','{4}',{5})", Guid.NewGuid(), artType, artTitle, artPubTime.ToString("yyyy-MM-dd HH:mm:ss"), artContent, maxOrder); isSuc = SqlServerHooker.InsertDataToTable(sqlInsert); } else //更新文章 { string sqlUpdate = string.Format("update T_ARTICLE set ArtType={0},ArtTitle='{1}',ArtContent='{2}' where ID='{3}'", artType, artTitle, artContent, _selectArtID); isSuc = SqlServerHooker.InsertDataToTable(sqlUpdate); } //生成静态html网页 string url = string.Format("http://127.0.0.1:8080/article/detail?type={0}&order={1}", artType, maxOrder); string id = OtherTool.GuidTo16String(); string path = Server.MapPath(string.Format("~/article/{0}.html", id)); CreateStaticHtml.ReturnStaticHtml(url, path); //上传html文件 bool isUpdateSuc = _ftpManager.UploadFile(path, "article/"); File.Delete(path); //上传图片 string ftpPath = "ueditor/net/upload/image/"; string imageDir = Server.MapPath("~/artpublish/ueditor/net/upload/image/"); string[] filePaths = Directory.GetFiles(imageDir); string imageNames = string.Empty; foreach (string filePath in filePaths) { //压缩图片 string newFilePath = Path.GetDirectoryName(filePath) + "\\" + Path.GetFileNameWithoutExtension(filePath) + "new" + Path.GetExtension(filePath); ResizeImage.GetPicThumbnail(filePath, newFilePath, 222, 650, 100); FileInfo fileInfo = new FileInfo(newFilePath); fileInfo.MoveTo(filePath); imageNames += Path.GetFileName(filePath) + ";"; _ftpManager.UploadFile(filePath, ftpPath); File.Delete(filePath); } if (imageNames.Length > 0) { imageNames = imageNames.Remove(imageNames.Length - 1, 1); } string sqlUpdateUrl = string.Format("update T_ARTICLE set ArtUrl='{0}',ArtContent='',ArtImages='{3}' where ArtType={1} and ArtOrder={2}", id, artType, maxOrder, imageNames); isSuc = SqlServerHooker.UpdateDataToTable(sqlUpdateUrl); if (isSuc) { div_text.InnerText = isUpdateSuc.ToString() + "发布成功!"; gvArtManager.DataBind(); } else { div_text.InnerText = "发布失败!"; } }