public ActionResult Index(HtmlModel html) { WebClient wc = new WebClient(); NameValueCollection nameValue = new NameValueCollection(); //nameValue.Add("wd", html.Keyword); nameValue.Add("q", html.Keyword); wc.QueryString.Add(nameValue); html.Result = wc.DownloadString(html.url); List <string> resultList = new List <string>(); string regex = @"(<a\s.*?>)(.*?)(<\/a>)"; string hrefRegex = @"href=""([^ ""]*)"""; Regex reg = new Regex(regex, RegexOptions.IgnoreCase); Match match = reg.Match(html.Result); KeyValue keyValue = new KeyValue(); while (match.Success) { Regex hrefReg = new Regex(hrefRegex, RegexOptions.IgnoreCase); keyValue.Key = match.Groups[2].Value; keyValue.Value = hrefReg.Match(match.Groups[1].Value).Groups[1].Value; if (keyValue.Value[0] == '/') { keyValue.Value = "https://www.google.com.au" + keyValue.Value; } html.ValuePair.Add(keyValue); match = match.NextMatch(); } return(View("Result", html)); }
public ActionResult Index() { HtmlModel html = new HtmlModel(); html.url = "https://www.google.com.au/search"; return(View(html)); }
public override Task <ModuleViewComponentResult> OnViewComponentLoad() { HtmlModel model = new HtmlModel(this); model.Content = _htmlBusiness.GetHtmlContent(Module.ModuleId)?.Content; return(Task.FromResult(ModuleView("Index", model))); }
public HtmlModel ReadHtml(HtmlModel model) { return(Session.QueryOver <HtmlModel>() .Where(m => (m.UserId == model.UserId) && (m.HtmlId == model.HtmlId)) .SingleOrDefault <HtmlModel>()); }
public HtmlModel CreateHtml(HtmlModel model) { HtmlModel rtn; Session.Clear(); rtn = Session.Save(model) as HtmlModel; Session.Flush(); return(rtn); }
public ActionResult Tag(string BlogTagName, int Page = 1) { ViewBag.Page = Page; ViewBag.BlogTagName = BlogTagName; ViewBag.BlogContent = _ContentService.Get(Request.Url.Authority, "blog"); ViewBag.Title = HtmlModel.FindValue(ViewBag.BlogContent, "blog-title", true).ToString() + " | " + BlogTagName; ViewBag.MetaDescription = HtmlModel.FindValue(ViewBag.BlogContent, "blog-subtitle", true).ToString() + " | " + BlogTagName; return(View("Index", _BlogService.Get(Request.Url.Authority , APP._CurrentLang, null, BlogTagName, Page))); }
public int ReadMaxHtmlWordId(HtmlModel model) { ISQLQuery query = Session.CreateSQLQuery( " SELECT ISNULL(MAX(HTML_WD_ID), 0)" + " FROM TBL_HTML_WORD" + " WHERE USR_ID = :userId" + " AND HTML_ID = :htmlId"); query.SetParameter("userId", model.UserId); query.SetParameter("htmlId", model.HtmlId); return((int)query.UniqueResult()); }
public object Post(HtmlModel data) { var htmlContent = data.html; var pdfBytes = (new NReco.PdfGenerator.HtmlToPdfConverter()).GeneratePdf(htmlContent); var policy = new CacheItemPolicy { AbsoluteExpiration = DateTimeOffset.Now.AddSeconds(30) }; var cacheId = Guid.NewGuid().ToString(); MemoryCache.Default.Add(cacheId, pdfBytes, policy); return(new { id = cacheId }); }
public IList <HtmlWord> ReadHtmlWordList(HtmlModel model) { ISQLQuery query = Session.CreateSQLQuery( " SELECT *" + " FROM TBL_HTML_WORD" + " WHERE USR_ID = :userId" + " AND HTML_ID = :htmlId" + " ORDER BY USR_ID, HTML_ID"); query.SetParameter("userId", model.UserId); query.SetParameter("htmlId", model.HtmlId); query.AddEntity(typeof(HtmlWord)); return(query.List <HtmlWord>()); }
public bool StoreHtml(String url, String wordList) { try { HtmlModel model = new HtmlModel(); model.URL = url; return(SendHtwdCommand(model, wordList)); } catch (Exception ex) { logger.Error(ex.Message); return(false); } }
public ActionResult Feed(string Lang) { if (string.IsNullOrEmpty(Lang)) { Lang = APP._CurrentLang; } var _BlogContent = _ContentService.Get(Request.Url.Authority, Lang, "blog"); var _Title = HtmlModel.FindValue(_BlogContent, "blog-title", true).ToString(); var _Description = HtmlModel.FindValue(_BlogContent, "blog-subtitle", true).ToString(); var _Feeds = _BlogService.Get(Request.Url.Authority, Lang, null, null, 1, true); return(new RssResult(_Feeds.Data, _Title, _Description)); }
private void HandleHtwdCommand(String argument) { if (!isLogin) { SendResponse(ProtocolResponse.NotLoggedIn, "로그인 후 사용하세요."); return; } String[] split = argument.Split(new char[] { ',' }, 2); HtmlModel mHtml = new HtmlModel(); mHtml.UserId = userId; mHtml.HtmlId = htmlDao.ReadMaxHtmlId(userId) + 1; mHtml.URL = split[0].Split('|')[2]; mHtml.CreateTime = DateTime.Now; htmlDao.CreateHtml(mHtml); HtmlWord mHtmlWord = new HtmlWord(); mHtmlWord.UserId = mHtml.UserId; mHtmlWord.HtmlId = mHtml.HtmlId; foreach (String htmlWord in split[1].Trim().Split(' ')) { mHtmlWord.Word = htmlWord.ToLower(); mHtmlWord = htmlWordDao.ReadHtmlWordUsingWord(mHtmlWord); if (mHtmlWord == null) { mHtmlWord = new HtmlWord(); mHtmlWord.UserId = mHtml.UserId; mHtmlWord.HtmlId = mHtml.HtmlId; mHtmlWord.HtmlWordId = htmlWordDao.ReadMaxHtmlWordId(mHtml) + 1; mHtmlWord.Word = htmlWord.ToLower(); mHtmlWord.WordCount = 1; htmlWordDao.CreateHtmlWord(mHtmlWord); } else { mHtmlWord.WordCount += 1; htmlWordDao.UpdateHtmlWord(mHtmlWord); } } SendResponse(ProtocolResponse.CommandOkay, "HTML 정보가 추가되었습니다."); }
public ActionResult Index(string BlogCategoryFriendlyUrl, int Page = 1) { ViewBag.Page = Page; ViewBag.BlogCategoryFriendlyUrl = BlogCategoryFriendlyUrl; ViewBag.BlogContent = _ContentService.Get(Request.Url.Authority, "blog"); ViewBag.Title = HtmlModel.FindValue(ViewBag.BlogContent, "blog-title", true).ToString(); if (!string.IsNullOrEmpty(BlogCategoryFriendlyUrl)) { ViewBag.Title += " | " + BlogCategoryFriendlyUrl; } ViewBag.MetaDescription = HtmlModel.FindValue(ViewBag.BlogContent, "blog-subtitle", true).ToString(); var _Model = _BlogService.Get(Request.Url.Authority , APP._CurrentLang, BlogCategoryFriendlyUrl, null, Page); return(View(_Model)); }
private bool SendHtwdCommand(HtmlModel htmlModel, String wordList) { ProtocolResponse response; SendRequest(ProtocolRequest.HtmlWord, String.Format("{0},{1}", htmlModel.ToString(), wordList)); response = ReceiveResponse(); switch (response.Code) { case ProtocolResponse.NotLoggedIn: logger.Info(response.Message); return(false); case ProtocolResponse.CommandOkay: logger.Info(response.Message); return(true); default: throw new Exception("알 수 없는 에러가 발생하였습니다."); } }
private void MainForm_Load(object sender, EventArgs e) { MyMessageBox.MessageBoxEvent += SetMessageBox; DgvHelper.InitDgv(gridView1, @"test"); HtmlModel hm = new HtmlModel("http://x3.1024lualu.pw", "pw/thread.php?fid=16&page=", "//div[@class='tpc_content']/img", "href", ""); HtmlModelTool.htmlModel = hm; this.htmlModelBindingSource.DataSource = HtmlModelTool.htmlModel; this.BasePathTextBox.DataBindings.Add(new Binding("Text", this.htmlModelBindingSource, "BasePath", true)); this.BasePathTextBox.DataBindings.Add(new Binding("Tag", this.htmlModelBindingSource, "BasePath", true)); this.AddressTextBox.DataBindings.Add(new Binding("Text", this.htmlModelBindingSource, "ExtendPath", true)); this.AddressTextBox.DataBindings.Add(new Binding("Tag", this.htmlModelBindingSource, "ExtendPath", true)); this.fileXpath.DataBindings.Add(new Binding("Text", this.htmlModelBindingSource, "Match", true)); this.fileXpath.DataBindings.Add(new Binding("Tag", this.htmlModelBindingSource, "Match", true)); this.PropertyName.DataBindings.Add(new Binding("Text", this.htmlModelBindingSource, "AttrName", true)); this.PropertyName.DataBindings.Add(new Binding("Tag", this.htmlModelBindingSource, "AttrName", true)); }
public List <HtmlModel> FindActiveUsers() { var hassioModel = GroupAllDevices(); List <HtmlModel> activeUsers = new List <HtmlModel>(); var jsonArr = JsonConvert.DeserializeObject <List <JsonFileModel> >(System.IO.File.ReadAllText(@"JSON_structure/employees.txt")); var networks = JsonConvert.DeserializeObject <List <NetworkModel> >(System.IO.File.ReadAllText(@"JSON_structure/networks.txt")); foreach (var jsonVal in jsonArr) { foreach (var hassioValue in hassioModel) { foreach (var networkVal in networks) { if (jsonVal.MacAddr == hassioValue.Attributes.Mac && hassioValue.Attributes.ApMac == networkVal.MacAddr && hassioValue.State == "home") { var data = new HtmlModel(); data.Mac = hassioValue.Attributes.Mac; data.ScName = jsonVal.UserName; data.Name = jsonVal.Name; data.State = hassioValue.State; data.Location = networkVal.Name.Substring(0, 3); data.PhoneNumber = jsonVal.PhoneNumber; activeUsers.Add(data); } } } } return(activeUsers); }
public void UpdateHtml(HtmlModel model) { Session.Clear(); Session.Update(model); Session.Flush(); }
public void DeleteHtml(HtmlModel model) { Session.Clear(); Session.Delete(model); Session.Flush(); }
public ActionResult Result(HtmlModel html) { return(View(html)); }