private void buttonSelectWebPage_Click(object sender, EventArgs e) { if (this.comboBoxRepositories.SelectedItem != null) { RepositoryInfo rep = (RepositoryInfo)this.comboBoxRepositories.SelectedItem; if (rep.siteInfo != null) { WebSiteInfo webSiteInfo = new WebSiteInfo(); webSiteInfo.id = rep.siteInfo.id; webSiteInfo.title = rep.siteInfo.title; FormSelectPageToOpen frm = new FormSelectPageToOpen(documentType, webSiteInfo); DialogResult result = frm.ShowDialog(this); if (result == DialogResult.OK && frm.WebPage != null) { this.textBox_WebPage.Text = frm.WebPage.title; this.textBox_WebPage.Tag = frm.WebPage; } } else { FormSelectPageToOpen frm = new FormSelectPageToOpen(documentType); DialogResult result = frm.ShowDialog(this); if (result == DialogResult.OK && frm.WebPage != null) { this.textBox_WebPage.Text = frm.WebPage.title; this.textBox_WebPage.Tag = frm.WebPage; } } } }
// GET: About public ActionResult Index() { WebSiteInfo siteInfo = new WebSiteInfo(); ViewBag.SiteTitle = siteInfo.GetWebSiteInfo().SiteTitle; return(View()); }
public ActionResult Detail(int Id) { WebSiteInfo siteInfo = new WebSiteInfo(); ViewBag.Site = siteInfo.GetWebSiteInfo(); //浏览次数+1 var model = service.GetDetail(Id); model.ReadNum++; service.UpdateModel(model); //获得最新model model = service.GetDetail(Id); //延伸阅读 ViewBag.OtherList = service.GetRandomArticleList(2); //每页显示数目 int PageSize = 10; ViewBag.PageSize = PageSize; //总条数 int Count = commentService.GetByWhere(Id == 0 ? null : string.Format("WHERE ParentId=0 and ArticleId = {0}", Id)).ToList().Count; ViewBag.Count = Count; //总页数 int PageCount = (Count + PageSize - 1) / PageSize; ViewBag.PageCount = PageCount; return(View(model)); }
public FormSelectPageToOpen(DocumentType type, WebSiteInfo siteInfo) { InitializeComponent(); this.type = type; this.siteInfo = siteInfo; this.cancel.Enabled = true; }
public async Task <ActionResult <WebSiteInfo> > PostWebSiteInfo(WebSiteInfo webSiteStatistics) { _context.WebSites.Add(webSiteStatistics); await _context.SaveChangesAsync(); return(CreatedAtAction("GetWebSiteStatistics", new { id = webSiteStatistics.Id }, webSiteStatistics)); }
public async Task <IActionResult> PutWebSiteInfo(int id, WebSiteInfo webSiteStatistics) { if (id != webSiteStatistics.Id) { return(BadRequest()); } _context.Entry(webSiteStatistics).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!WebSiteInfoExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public SelectSiteToOpen(DocumentType type, WebSiteInfo siteInfo) : base(false, siteInfo) { this.type = type; this.siteInfo = siteInfo; this.ValidateStep += new CancelEventHandler(SelectSiteToOpen_ValidateStep); }
public static WebSiteInfo GetWebSiteInfoById(int id) { WebSiteInfo _websiteinfo = new WebSiteInfo(); if (HttpContext.Current.Cache["websiteinfo" + id.ToString()] != null) { return((WebSiteInfo)HttpContext.Current.Cache.Get("websiteinfo" + id.ToString())); } string slqstr = "SELECT * FROM [WebSite] WHERE [ID]=" + id; SqlDataReader dr = DataBase.ExecuteReader(CommandType.Text, slqstr); if (dr.Read()) { _websiteinfo.ID = (int)dr["ID"]; _websiteinfo.SiteName = dr["SiteName"].ToString(); _websiteinfo.Domain = dr["Domain"].ToString(); _websiteinfo.Description = dr["Description"].ToString(); _websiteinfo.SiteType = (int)dr["SiteType"]; _websiteinfo.AddTime = DateTime.Parse(dr["AddTime"].ToString()); _websiteinfo.Status = (int)dr["Status"]; _websiteinfo.Uid = (int)dr["Uid"]; } dr.Close(); HttpContext.Current.Cache.Insert("websiteinfo" + id.ToString(), _websiteinfo); return(_websiteinfo); }
private static IWebSiteInfo ParseWebSiteInfo(string url, HttpWebResponse response, string content) { WebSiteInfo info = new WebSiteInfo { SiteUri = url, ProtocolType = string.Format("HTTP{0} {1} {2}", response.ProtocolVersion, (int)response.StatusCode, response.StatusDescription), PageType = response.ContentType, ServerType = response.Server, EncodingType = response.ContentEncoding, }; Match match = g_htmlTitleRegex.Match(content); if (match != null && match.Success) { info.HtmlTitle = match.Groups[1].Value; } int?nameIndex = null, contentIndex = null; Capture[] keyCaptures = null, valueCaptures = null; foreach (Match item in g_metaRegex.Matches(content)) { nameIndex = contentIndex = null; keyCaptures = item.Groups["key"].Captures.Cast <Capture>().ToArray(); valueCaptures = item.Groups["value"].Captures.Cast <Capture>().ToArray(); for (int i = 0; i < keyCaptures.Length; i++) { switch (keyCaptures[i].Value.ToLower()) { case META_NAME: nameIndex = i; break; case META_CONTENT: contentIndex = i; break; } } if (!nameIndex.HasValue || !contentIndex.HasValue) { continue; } switch (valueCaptures[nameIndex.Value].Value.ToLower()) { case META_KEYWORDS_NAME: info.MetaKeywords = valueCaptures[contentIndex.Value].Value; break; case META_DESCRIPTION_NAME: info.MetaDescription = valueCaptures[contentIndex.Value].Value; break; } } info.SiteKeywords = info.MetaKeywords != null?info.MetaKeywords.Split(SiteKeywordsSeparators, StringSplitOptions.RemoveEmptyEntries).Select((item) => item.Trim()).Where((item) => item.Length > 0).Distinct(StringComparer.OrdinalIgnoreCase).ToArray() : Enumerable.Empty <string>(); return(info); }
public static bool UpdateWebSite(WebSiteInfo _websiteinfo) { HttpContext.Current.Cache.Remove("websiteinfo" + _websiteinfo.ID.ToString()); HttpContext.Current.Cache.Remove(_websiteinfo.Domain); SqlParameter[] prams = new SqlParameter[] { DataBase.MakeInParam("@ID", SqlDbType.Int, 4, _websiteinfo.ID), DataBase.MakeInParam("@SiteName", SqlDbType.VarChar, 100, _websiteinfo.SiteName), DataBase.MakeInParam("@Domain", SqlDbType.VarChar, 100, _websiteinfo.Domain), DataBase.MakeInParam("@Description", SqlDbType.VarChar, 500, _websiteinfo.Description), DataBase.MakeInParam("@SiteType", SqlDbType.Int, 4, _websiteinfo.SiteType), DataBase.MakeInParam("@AddTime", SqlDbType.DateTime, 8, _websiteinfo.AddTime), DataBase.MakeInParam("@Status", SqlDbType.Int, 4, _websiteinfo.Status), DataBase.MakeInParam("@Uid", SqlDbType.Int, 4, _websiteinfo.Uid) }; return(DataBase.ExecuteNonQuery(CommandType.StoredProcedure, "WebSite_Update", prams) > 0); }
//public static int GetWebSiteIdByDomain(string domain) //{ // int _id = 0; // string slqstr = string.Concat(new object[] { "SELECT [ID] FROM [WebSite] WHERE Status=", 1, " AND [Domain]='", domain, "'" }); // SqlDataReader dr = Database.ExecuteReader(CommandType.Text, slqstr); // if (dr.Read()) // { // _id = (int) dr["ID"]; // } // dr.Close(); // dr.Dispose(); // return _id; //} public static WebSiteInfo GetWebSiteInfoByDomain(string domain) { WebSiteInfo _websiteinfo = new WebSiteInfo(); if (HttpContext.Current.Cache[domain] != null) { return((WebSiteInfo)HttpContext.Current.Cache.Get(domain)); } string slqstr = string.Concat(new object[] { "SELECT * FROM [WebSite] WHERE Status=", 1, " AND [Domain]='", domain, "'" }); SqlDataReader dr = DataBase.ExecuteReader(CommandType.Text, slqstr); if (dr.Read()) { _websiteinfo.ID = (int)dr["ID"]; _websiteinfo.SiteName = dr["SiteName"].ToString(); _websiteinfo.Domain = dr["Domain"].ToString(); _websiteinfo.Description = dr["Description"].ToString(); _websiteinfo.SiteType = (int)dr["SiteType"]; _websiteinfo.AddTime = DateTime.Parse(dr["AddTime"].ToString()); _websiteinfo.Status = (int)dr["Status"]; _websiteinfo.Uid = (int)dr["Uid"]; } dr.Close(); dr.Dispose(); HttpContext.Current.Cache.Insert(domain, _websiteinfo); return(_websiteinfo); }
private void DownLoadMainPictures(string html, DirectoryInfo directoryInfo, WebSiteInfo webSiteInfo) { MatchCollection collection = mainPictureRegex.Matches(html); int index = 1; foreach (Match m in collection) { string value = HttpUtility.HtmlDecode(m.Value); string pictureInfo = value.Substring(11, value.Length - 12); JObject jsonArray = (JObject)JsonConvert.DeserializeObject(pictureInfo); // Preview imapge will be created by ALI or TAOBAO, there is no need to download them. //string previewPictureUrl = jsonArray["preview"].ToString(); string originalPictureUrl = jsonArray["original"].ToString(); //string previewFileName = Path.Combine(directoryInfo.FullName, index+"_small"); string suffix = Path.GetExtension(originalPictureUrl); string originalFileName = Path.Combine(directoryInfo.FullName, index.ToString() + suffix); //DownLoadPicture(previewPictureUrl, previewFileName); DownLoadPicture(originalPictureUrl, originalFileName); webSiteInfo.DownloadIndex++; index++; } }
public static WebSiteInfo ReaderBind(SqlDataReader dataReader) { WebSiteInfo model = new WebSiteInfo(); object ojb = dataReader["ID"]; if ((ojb != null) && (ojb != DBNull.Value)) { model.ID = (int)ojb; } model.SiteName = dataReader["SiteName"].ToString(); model.Domain = dataReader["Domain"].ToString(); model.Description = dataReader["Description"].ToString(); ojb = dataReader["SiteType"]; if ((ojb != null) && (ojb != DBNull.Value)) { model.SiteType = (int)ojb; } ojb = dataReader["AddTime"]; if ((ojb != null) && (ojb != DBNull.Value)) { model.AddTime = (DateTime)ojb; } ojb = dataReader["Status"]; if ((ojb != null) && (ojb != DBNull.Value)) { model.Status = (int)ojb; } ojb = dataReader["Uid"]; if ((ojb != null) && (ojb != DBNull.Value)) { model.Uid = (int)ojb; } return(model); }
public SelectWebPage(WebSiteInfo webSiteInfo) { InitializeComponent(); if (webSiteInfo != null) { foreach (WebSiteInfo site in OfficeApplication.OfficeApplicationProxy.getSites()) { if (webSiteInfo.id.Equals(site.id)) { WebSiteTreeNode siteNode = new WebSiteTreeNode(site); this.treeView1.Nodes.Add(siteNode); siteNode.AddNode += new NodeEvent(siteNode_onAddNode); } } } else { foreach (WebSiteInfo site in OfficeApplication.OfficeApplicationProxy.getSites()) { WebSiteTreeNode siteNode = new WebSiteTreeNode(site); this.treeView1.Nodes.Add(siteNode); siteNode.AddNode += new NodeEvent(siteNode_onAddNode); } } }
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) { listView1.Items.Clear(); if (e.Node is SemanticFolderNode) { SemanticFolderNode sfnode = (SemanticFolderNode)e.Node; WebSiteInfo site = (WebSiteInfo)this.comboBoxSite.SelectedItem; SiteInfo siteinfo = new SiteInfo(); siteinfo.id = site.id; SemanticRepository sr = (SemanticRepository)this.comboBoxRepository.SelectedItem; foreach (SemanticFileRepository semanticfile in OfficeApplication.OfficeApplicationProxy.getSemanticFileRepositories(siteinfo, sr, sfnode.SemanticFolderRepository)) { listView1.Items.Add(new SemanticFileItem(semanticfile)); } } if (e.Node is SemanticRepositoryNode) { WebSiteInfo site = (WebSiteInfo)this.comboBoxSite.SelectedItem; SiteInfo siteinfo = new SiteInfo(); siteinfo.id = site.id; SemanticRepository sr = (SemanticRepository)this.comboBoxRepository.SelectedItem; foreach (SemanticFileRepository semanticfile in OfficeApplication.OfficeApplicationProxy.getSemanticFileRepositories(siteinfo, sr)) { listView1.Items.Add(new SemanticFileItem(semanticfile)); } } }
public FormPublishcontentToPage(OfficeDocument document, String title, String description, WebSiteInfo site) { InitializeComponent(); this.document = document; this.title = title; this.description = description; this.site = site; }
public SelectSitePublish(OfficeDocument document, WebSiteInfo webSiteInfo) : base(webSiteInfo) { this.document = document; type = document.DocumentType; this.ValidateStep += new System.ComponentModel.CancelEventHandler(SelectSitePublish_ValidateStep); selectWebPage.AddNode += new WBOffice4.Controls.NodeEvent(selectWebPage_onAddNode); }
private WebSiteInfo SetWebSiteInfoStatus(WebSiteInfo webSiteInfo, StatusCode status) { if (webSiteInfo != null) { webSiteInfo.Status = status; } return(webSiteInfo); }
/// <summary> /// 获取xml实体类信息 /// </summary> /// <returns></returns> public static ArrayList GetWebModelInfo() { ArrayList list = new ArrayList(); WebSiteInfo webModel = new WebSiteInfo(); //城市名称 webModel.cityName = "广东"; //商品标题 webModel.title = "商品1"; //商品创建时间 webModel.createtime = Convert.ToDateTime("2017-11-26 09:10:00"); //商家名称 webModel.merchants_id = "商家1"; //商品图片 webModel.productimg = "这是商品图"; //市场价 webModel.market_price = Convert.ToDecimal("120"); //团购价 webModel.team_price = Convert.ToDecimal("100"); //折扣价 webModel.zhekou_price = Convert.ToDecimal("20"); //开始时间 webModel.begin_time = Convert.ToDateTime("2017-12-26 09:00:00"); //结束时间 webModel.end_time = Convert.ToDateTime("2017-12-31 09:00:00"); //商品说明 webModel.description = "这是商品描述"; //最低购买数量 webModel.lowBuNo = Convert.ToInt32("1"); //商家电话 webModel.Telphone = "88888888"; //商家地址 webModel.Address = "特发信息科技大厦"; //城市编号 webModel.cCode = "440000"; //图片文件夹名称 webModel.folderName = "Upload/SpecIcon"; //现在购买人数 webModel.nownumber = Convert.ToInt32("10000"); //商品编号 webModel.productID = Convert.ToInt32("1000888"); int status = Convert.ToInt32("1"); switch (status) { case 0: webModel.StatusMessage = "结束"; break; case 1: webModel.StatusMessage = "成功"; break; } list.Add(webModel); return(list); }
// GET: Archives public ActionResult Index() { WebSiteInfo siteInfo = new WebSiteInfo(); ViewBag.SiteTitle = siteInfo.GetWebSiteInfo().SiteTitle; ViewData["Year"] = service.GetYear(); ViewData["ArticleList"] = service.GetAll(); return(View()); }
private void process_Exited(object sender, EventArgs e) { string html = string.Empty; string hashCode = string.Empty; string htmlPath = string.Empty; string realHashCode = string.Empty; WebSiteInfo webSiteInfo = null; try { // Download main pictures Process process = (Process)sender; htmlPath = process.StartInfo.Arguments.Split(' ')[3] + ".html"; hashCode = Path.GetFileNameWithoutExtension(htmlPath); realHashCode = hashCode.Replace('_', '-'); webSiteInfo = GetWebSiteInfoByHashCode(realHashCode); processPool.KillProcess(downloadProcess[webSiteInfo]); downloadProcess.Remove(webSiteInfo); using (StreamReader sw = new StreamReader(File.OpenRead(Path.Combine(Arguments.TEMP_FOLDER, htmlPath)))) { html = sw.ReadToEnd(); } } catch { SetWebSiteInfoStatus(webSiteInfo, StatusCode.Failed); return; } if (string.IsNullOrEmpty(html) == false) { try { logger.Info(string.Format("读取HTML结束 {0}.", webSiteInfo.Url)); DownLoad(html, webSiteInfo); webSiteInfo.Status = StatusCode.Finish; } catch { SetWebSiteInfoStatus(webSiteInfo, StatusCode.Failed); } File.Delete(htmlPath); } else { logger.Info(string.Format("读取HTML结束失败.")); SetWebSiteInfoStatus(webSiteInfo, StatusCode.Failed); } }
// GET: Links public ActionResult Index() { WebSiteInfo siteInfo = new WebSiteInfo(); ViewBag.SiteTitle = siteInfo.GetWebSiteInfo().SiteTitle; IEnumerable <LinksModel> LinksList = service.GetAll(); return(View(LinksList)); }
internal static void ClearDownLoader() { WebSiteInfo[] downloadList = new WebSiteInfo[downloadProcess.Keys.Count]; downloadProcess.Keys.CopyTo(downloadList, 0); foreach (WebSiteInfo webSiteInfo in downloadList) { StopTask(webSiteInfo); } downloadProcess.Clear(); }
internal static void StopTask(WebSiteInfo webSiteInfo) { if (downloadProcess.ContainsKey(webSiteInfo)) { downloadProcess[webSiteInfo].EnableRaisingEvents = false; processPool.KillProcess(downloadProcess[webSiteInfo]); downloadProcess.Remove(webSiteInfo); } webSiteInfo.Status = StatusCode.Wait; }
// GET: Feedback public ActionResult Index() { WebSiteInfo siteInfo = new WebSiteInfo(); ViewBag.Site = siteInfo.GetWebSiteInfo(); int Count = service.GetByWhere("WHERE ParentId=0").ToList().Count; ViewBag.Count = Count; int PageSize = 15; ViewBag.PageSize = PageSize; ViewBag.PageCount = (Count + PageSize - 1) / PageSize; return View(); }
protected override void DownLoad(string html, WebSiteInfo webSiteInfo) { string titile = TextUtility.RemoveSpecialChar(GetTitle(html)); string folderTitile = titile.Length < 18 ? titile : titile.Substring(0, 18); webSiteInfo.Title = folderTitile; logger.Info(string.Format("创建文件夹: {0}", webSiteInfo.Url)); DirectoryInfo directory; lock (locker) { string folderName = CalculateFolderName(folderTitile, webSiteInfo); directory = new DirectoryInfo(folderName); if (directory.Exists == true) { directory.Delete(true); } directory.Create(); } DirectoryInfo mainDirectory = new DirectoryInfo(Path.Combine(directory.FullName, "main")); mainDirectory.Create(); DirectoryInfo ditailsDirectory = new DirectoryInfo(Path.Combine(directory.FullName, "details")); ditailsDirectory.Create(); FileStream fs = File.Create(Path.Combine(directory.FullName, titile + ".txt")); fs.Close(); logger.Info(string.Format("开始下载主要图片: {0}", webSiteInfo.Url)); MatchCollection collection = mainPictureRegex.Matches(html); int mainPictureCount = collection.Count; List <string> images = GetDetailPictures(html); int detailPictureCount = images.Count; webSiteInfo.PictureCount = mainPictureCount + detailPictureCount; // Download main pictures DownLoadMainPictures(html, mainDirectory, webSiteInfo); logger.Info(string.Format("开始下载详细图片: {0}", webSiteInfo.Url)); DownLoadDetailPicture(images, ditailsDirectory, webSiteInfo); logger.Info(string.Format("下载完成: {0}", webSiteInfo.Url)); }
private IList <WebSiteInfo> GetSelectedList() { IList <WebSiteInfo> selectedList = new List <WebSiteInfo>(); foreach (DataGridViewRow row in this.dgMain.SelectedRows) { WebSiteInfo webSiteInfo = (WebSiteInfo)row.DataBoundItem; selectedList.Add(webSiteInfo); } return(selectedList); }
public JsonResult ReplyComment(string openid, string remarkId, string targetUserId, string articleid, string editorContent) { QQUserModel userModel = qqUserService.GetQQUserByOpenId(openid); if (userModel == null) { return(Json(new AjaxResult { state = ResultType.error.ToString(), message = "非法提交,Openid不存在" })); } if (!userModel.Status.Value) { return(Json(new AjaxResult { state = ResultType.error.ToString(), message = "QQ用户已被锁定,无法评论" })); } WebSiteInfo siteInfo = new WebSiteInfo(); int maxCommentNum = Convert.ToInt32(siteInfo.GetWebSiteInfo().MaxCommentNum); int todayCommentNum = service.GetTodayCommentNum(openid); if (todayCommentNum >= maxCommentNum) { //锁定QQ用户 userModel.Status = false; qqUserService.UpdateQQUser(userModel); return(Json(new AjaxResult { state = ResultType.error.ToString(), message = "评论提交失败,已超出每日最大提交数量" })); } CommentModel model = new CommentModel() { SendId = userModel.Id, AcceptId = Convert.ToInt32(targetUserId), Content = XSS.FilterXSS(editorContent), Status = true, ParentId = Convert.ToInt32(remarkId), ArticleId = Convert.ToInt32(articleid), CreateOn = DateTime.Now }; bool result = service.CreateModel(model); if (result) { return(Json(new AjaxResult { state = ResultType.success.ToString(), message = "评论回复成功" })); } else { return(Json(new AjaxResult { state = ResultType.error.ToString(), message = "评论回复失败" })); } }
public JsonResult AddFeedback(string openid, string editorContent, string fromcity, string browserName) { QQUserModel userModel = qqUserService.GetQQUserByOpenId(openid); if (userModel == null) { return(Json(new AjaxResult { state = ResultType.error.ToString(), message = "非法提交,Openid不存在" })); } if (!userModel.Status.Value) { return(Json(new AjaxResult { state = ResultType.error.ToString(), message = "QQ用户已被锁定,无法留言" })); } WebSiteInfo siteInfo = new WebSiteInfo(); int maxFeedbackNum = Convert.ToInt32(siteInfo.GetWebSiteInfo().MaxFeedbackNum); int todayFeedbackNum = service.GetTodayFeedbackNum(openid); if (todayFeedbackNum >= maxFeedbackNum) { //锁定QQ用户 userModel.Status = false; qqUserService.UpdateQQUser(userModel); return(Json(new AjaxResult { state = ResultType.error.ToString(), message = "留言提交失败,已超出每日最大提交数量" })); } FeedbackModel model = new FeedbackModel() { SendId = userModel.Id, AcceptId = 0, Content = XSS.FilterXSS(editorContent), ParentId = 0, City = fromcity, Equip = browserName, CreateOn = DateTime.Now }; bool result = service.CreateModel(model); if (result) { return(Json(new AjaxResult { state = ResultType.success.ToString(), message = "留言提交成功" })); } else { return(Json(new AjaxResult { state = ResultType.error.ToString(), message = "留言提交失败" })); } }
public WebSiteTreeNode(WebSiteInfo webSiteInfo) { this.webSiteInfo = webSiteInfo; this.Text = webSiteInfo.title; this.Tag = webSiteInfo; this.SelectedImageIndex = 1; this.ImageIndex = 1; TreeNode dummy = new TreeNode(""); Nodes.Add(dummy); }