//protected virtual async System.Threading.Tasks.Task<string> BuildList() //protected virtual async Task<HtmlNode> BuildList() protected virtual void BuildList() { //if (exemptCompaniesJobItems != null) if ((exemptCompaniesJobItems == null) || (exemptCompaniesJobItems.Count > 0)) { foreach (JobItem jobItem in exemptCompaniesJobItems.Values) { HtmlNode tr = HtmlNode.CreateNode("<tr>"); HtmlNode td = HtmlNode.CreateNode("<td>"); tr.ChildNodes.Append(td); td.InnerHtml = string.Format("<b>{0}</b>", jobItem.title); td = HtmlNode.CreateNode("<td>"); tr.ChildNodes.Append(td); td.InnerHtml = string.Format("<b>{0}</b>", jobItem.company); td = HtmlNode.CreateNode("<td>"); tr.ChildNodes.Append(td); td.InnerHtml = string.Format("<i>{0}</i>", jobItem.location); tableExemptCompanyJobs.ChildNodes.Append(tr); } } if ((includedJobItems == null) || (includedJobItems.Count == 0)) { return; } System.Net.Http.HttpClient httpClient = new System.Net.Http.HttpClient { Timeout = TimeSpan.FromSeconds(15) }; foreach (JobItem jobItem in includedJobItems.Values) { LinkedInHelper.PreviouslySubmittedItem result = null; string url = string.Empty; try { if ((this.isLinkedInHelperAvailable != null) && (isLinkedInHelperAvailable == true)) { if ((jobItem.title == null) || (jobItem.company == null)) { continue; } //http://localhost:56491/api/GetSubmittedJobsByTitleAndCompany?jobTitle=VP of Engineering&companyName=5th Kind url = string.Format("http://localhost:56491/api/GetSubmittedJobsByTitleAndCompany?jobTitle={0}&companyName={1}", jobItem.title, jobItem.company); //string response = await httpClient.GetStringAsync( url ).ConfigureAwait( false ); string response = httpClient.GetStringAsync(url).Result;//.ConfigureAwait( false ); LinkedInHelper.PreviouslySubmittedList previouslySubmittedList = Newtonsoft.Json.JsonConvert.DeserializeObject <LinkedInHelper.PreviouslySubmittedList>(response); if (previouslySubmittedList != null && previouslySubmittedList.statusCode != 404) { if ((previouslySubmittedList.result != null) && (previouslySubmittedList.result.Count > 0)) { result = previouslySubmittedList.result[0]; if (result != null) { jobItem.JobId = result.JobId; } } } else { } } // } catch (Exception) { //throw ex; } HtmlNode tr = HtmlNode.CreateNode("<tr>"); //table.ChildNodes.Append( tr ); HtmlNode td = HtmlNode.CreateNode("<td>"); tr.ChildNodes.Append(td); td.InnerHtml = string.Format("<b>{0}</b>", jobItem.title); td = HtmlNode.CreateNode("<td>"); tr.ChildNodes.Append(td); td.InnerHtml = string.Format("<b>{0}</b>", jobItem.company); td = HtmlNode.CreateNode("<td>"); tr.ChildNodes.Append(td); td.InnerHtml = string.Format("<i>{0}</i>", jobItem.location); td = HtmlNode.CreateNode("<td>"); tr.AppendChild(td); td.InnerHtml = string.Format("<input style=\"background-color:#3CFF33\" type=\"button\" value=\"Careers\" onclick=\"window.open( 'https://www.google.com/search?q=careers+at+{0}' )\"></input>", jobItem.company); //jobItem.CareersLink = string.Format( "https://www.google.com/search?q=careers+at+{0}", jobItem.company ); td = HtmlNode.CreateNode("<td>"); tr.AppendChild(td); string temp = string.Format("{0}&gsl={1}", jobItem.company, jobItem.title); //td.InnerHtml = string.Format( "<button style=\"background-color:#1AEFA2\" onclick='window.open(\"https://www.w3schools.com/jobid=" + "{0} and \"{1}\"" + "\",\"_self\" );window.back();'>LinkedIn</button>", td.InnerHtml = string.Format("<button style=\"background-color:#1AEFA2; \" onclick='window.open(\"https://www.w3schools.com/jobid=" + "{0}" + "\",\"_self\" );window.back();'>LinkedIn</button>", temp //company ); //jobItem.LinkedInMessage = td = HtmlNode.CreateNode("<td>"); tr.ChildNodes.Append(td); if (result == null) { td.InnerHtml = string.Format("<b>{0}</b>", "Unsubmitted"); tableAvailable.ChildNodes.Append(tr); } else { tableSubmitted.ChildNodes.Append(tr); DateTime?submitted = result.submitted; if (submitted == null) { td.InnerHtml = string.Format("<span style=\"background-color:green; font-size:11.0pt\"><b>{0}</b></span>", "Unsubmitted"); } else { int totalDays = (int)(DateTime.Now - submitted.Value).TotalDays; td.InnerHtml = string.Format("<span style=\"background-color:red; color:white; font-size:11.0pt\"><b>{0}</b></span>", totalDays.ToString() + " days since"); jobItem.Submitted = totalDays.ToString() + " days since"; } } } return;// table; // }
//protected override async System.Threading.Tasks.Task<HtmlNode> BuildList() protected override void BuildList() { const string nodeText = "<button onclick='window.open(\"https://www.w3schools.com/jobid=" + "VALUE" + "\",\"_self\");window.back();'>LinkedIn</button>"; foreach (string key in includedJobItems.Keys) { JobItem item = includedJobItems[key]; System.Text.RegularExpressions.Regex r = new System.Text.RegularExpressions.Regex(@"view/(\d+)\?"); System.Text.RegularExpressions.Match m = r.Match(key); if (!m.Success && m.Groups.Count <= 1) { continue; } string href = m.Groups[1].Value; item.JobId = long.Parse(href); string nodeTextTemp = nodeText.Replace("VALUE", m.Groups[1].Value); HtmlNode linkedInButton = HtmlNode.CreateNode(nodeTextTemp); linkedInButton.SetAttributeValue("title", item.title); string submittedText = "Unsubmitted"; HtmlNode table = null; try { if (LinkedInHelper.VerifyServer) { LinkedInHelper linkedInHelper = new LinkedInHelper(); LinkedInHelper.PreviouslySubmitted linkedInItem = linkedInHelper.PreviouslySubmittedAsyncByJobId(m.Groups[1].Value).Result; if ((linkedInItem != null) && (linkedInItem.result != null)) { //Helper.LinkedInHelper.PreviouslySubmittedItem result = linkedInItem.result; LinkedInHelper.PreviouslySubmittedItem result = linkedInItem.result; if (result != null) { item.JobId = result.JobId; } if ((result != null) && (result.submitted != null)) { int totalDays = (int)(System.DateTime.Now - result.submitted.Value).TotalDays; submittedText = totalDays.ToString() + " days ago"; if (totalDays == 0) { submittedText = "Today"; } linkedInButton.SetAttributeValue("style", "font-size:7pt;color:white;background-color:red;border:2px solid #336600;padding:3px"); table = tableSubmitted; } else { linkedInButton.SetAttributeValue("style", "font-size:7pt;color:white;background-color:green;border:2px solid #336600;padding:3px"); table = tableAvailable; } } else { linkedInButton.SetAttributeValue("style", "font-size:7pt;color:white;background-color:green;border:2px solid #336600;padding:3px"); table = tableAvailable; } } } catch (System.Threading.Tasks.TaskCanceledException ex) { ConEx.Log(ex.StackTrace); } catch (System.Exception) { //throw ex; } HtmlNode tr = HtmlNode.CreateNode("<tr>"); if (table == null) { continue; } table.ChildNodes.Append(tr); HtmlNode td = HtmlNode.CreateNode("<td>"); tr.ChildNodes.Append(td); td.InnerHtml = string.Format("<span style='color: green; font-weight: bold;'>{0}</span>", item.title); td = HtmlNode.CreateNode("<td>"); tr.ChildNodes.Append(td); td.InnerHtml = string.Format("<span style='background-color: white; font-weight: bold;'>{0}</span>", item.company); td = HtmlNode.CreateNode("<td>"); tr.ChildNodes.Append(td); td.InnerHtml = string.Format("<span style='background-color: white; font-weight: bold;'>{0}</span>", item.location); td = HtmlNode.CreateNode("<td>"); tr.ChildNodes.Append(td); td.InnerHtml = string.Format("<input type=\"button\" value=\"Careers\" onclick=\"window.open( 'https://www.google.com/search?q=careers+at+{0}' )\" />", item.company); //style='background-color: #3CFF33; td = HtmlNode.CreateNode("<td>"); tr.ChildNodes.Append(td); td.ChildNodes.Append(linkedInButton); // //td.InnerHtml = string.Format( "<span style=\"background-color:red; color:white; font-size:11.0pt\"><b>{0}</b></span>", totalDays.ToString() + " days since" ); td = HtmlNode.CreateNode("<td>"); tr.ChildNodes.Append(td); td.InnerHtml = string.Format("<span style=\"font-size:11.0pt\"><b>{0}</b></span>", submittedText); }//foreach (string key in includedJobItems.Keys) return;// table; // }