public override bool MarkAsCancelledCalendarItem(string content) { string reservationsNumber = "ReservationsNumber not found"; //<div><strong>Reservation #:</strong> 1322312<br> string pattern = "<strong>Reservation #:</strong> (\\d+)<br>"; Regex regex = new Regex(pattern); Match match = regex.Match(content); if ((match.Success) && (match.Groups.Count > 1)) { reservationsNumber = match.Groups[1].Value; ConEx.Log("MarkAsCancelledCalendarItem: reservationsNumber={0}", reservationsNumber); Items items = GetAppointmentsByReservationNumber(reservationsNumber); if ((items != null) && (items.Count > 0)) { AppointmentItem item = items.GetFirst(); item.Categories = cancelledTennisCat; return(true); // } else { return(false); } // } return(false); }
public override bool DeleteCalendarItem(string content) { string reservationsNumber = "ReservationsNumber not found"; //<div><strong>Reservation #:</strong> 1322312<br> string pattern = "<strong>Reservation #:</strong> (\\d+)<br>"; Regex regex = new Regex(pattern); Match match = regex.Match(content); if ((match.Success) && (match.Groups.Count > 1)) { reservationsNumber = match.Groups[1].Value; ConEx.Log("DeleteCalendarItem: reservationsNumber={0}", reservationsNumber); Items items = GetAppointmentsByReservationNumber(reservationsNumber); if ((items != null) && (items.Count > 0)) { AppointmentItem item = items.GetFirst(); item.Delete(); return(true); // } else { return(false); } // } /* if using the Body this alternative is not thoroughly implemented through this code * pattern = "(Reservation #: (\\d+))"; * regex = new Regex( pattern ); * match = regex.Match( content ); * if( ( match.Success ) && ( match.Groups.Count > 1 ) ) * { * reservationsNumber = match.Groups[2].Value; * Items items = GetAppointmentsByReservationNumber( reservationsNumber ); * if( ( items != null ) && ( items.Count > 0 ) ) * items.GetFirst().Delete(); * * return; * // * } */ return(false); // }
public async Task <PreviouslySubmitted> PreviouslySubmittedAsyncByJobId(string jobId) { //String content = null; try { string url = @"http://localhost:56491/api/GetSubmittedByJobId?jobId=" + jobId; //response = await httpClient.GetStringAsync( url ); var response = await httpClient.GetStringAsync(url).ConfigureAwait(false); PreviouslySubmitted previouslySubmitted = JsonConvert.DeserializeObject <PreviouslySubmitted>(response); return(previouslySubmitted); // } catch (System.Net.Http.HttpRequestException ex) { ConEx.Log(ex.StackTrace); } catch (TaskCanceledException ex) { ConEx.Log(ex.StackTrace); } catch (System.Exception ex) { ConEx.Log(ex.StackTrace); } /* * try * { * PreviouslySubmitted previouslySubmitted = JsonConvert.DeserializeObject<PreviouslySubmitted>( content ); * return previouslySubmitted; * } * catch (Exception ex) * { * return null; * } */ return(null); // }
public void Test1() { ReservationParser reservationParser = new ReservationParser(content); ConEx.Log(reservationParser.PrincipalPlayer); ConEx.Log(reservationParser.Reservation); ConEx.Log(reservationParser.Location); ConEx.Log(reservationParser.ActivityDateStart); ConEx.Log(reservationParser.ActivityDateEnd); Assert.AreEqual("*****@*****.**", reservationParser.PrincipalPlayer); Assert.AreEqual("2627792", reservationParser.Reservation); Assert.AreEqual(" Lafayette Tennis Court #2", reservationParser.Location); //int year, int month, int day, int hour, int minute, int second DateTime start = new DateTime(2021, 8, 29, 9, 0, 0); Assert.AreEqual(start, reservationParser.ActivityDateStart); DateTime end = new DateTime(2021, 8, 29, 10, 30, 0); Assert.AreEqual(end, reservationParser.ActivityDateEnd); // }
bool testing = false;//false true public override object CreateCalendarItem(string content) { //workApp = new Microsoft.Office.Interop.Word.Application(); //abc: string reservationsNumber = "ReservationsNumber not found"; //<div><strong>Reservation #:</strong> 1322312<br> string pattern = "<strong>Reservation #:</strong> (.*)<br>"; Regex regex = new Regex(pattern); Match match = regex.Match(content); if ((match.Success) && (match.Groups.Count > 1)) { reservationsNumber = match.Groups[1].Value; //Items appts = GetAppointmentsByReservationNumber( reservationsNumber ); //if( !testing ) // if( ( appts != null ) && ( appts.Count > 0 ) ) // return null; } /* if using the Body this alternative is not thoroughly implemented through this code * if( !match.Success ) * { * pattern = "(Reservation #: (\\d+))"; * regex = new Regex( pattern ); * match = regex.Match( content ); * if( ( match.Success ) && ( match.Groups.Count > 1 ) ) * { * reservationsNumber = match.Groups[2].Value; * } * // * } */ ConEx.Log("CreateCalendarItem: reservationsNumber={0}", reservationsNumber); Items appts = GetAppointmentsByReservationNumber(reservationsNumber); ConEx.Log("is this already present? " + ((appts != null) && (appts.Count > 0))); if (!testing) { if ((appts != null) && (appts.Count > 0)) { return(null); } } //This email was sent to [email protected] string footer = "An email address was not found"; //<strong>Spot Name:</strong> Lafayette Tennis Court #2</div> pattern = "(This email was sent to (.*))"; regex = new Regex(pattern); match = regex.Match(content); string categoryStr = tennisCat1; if ((match.Success) && (match.Groups.Count > 1)) { footer = match.Groups[1].Value; if (footer.Contains("greenflashtennis")) { categoryStr = tennisCat2; } else if (footer.Contains("gslockwood")) { categoryStr = tennisCat3; } // } footer = "<div><div><div>" + footer.TrimEnd('\r').Trim() + "</div></div></div>"; string location = "Location not found"; //<strong>Spot Name:</strong> Lafayette Tennis Court #2</div> pattern = "<strong>Spot Name:</strong> (.*)</div>"; regex = new Regex(pattern); match = regex.Match(content); if ((match.Success) && (match.Groups.Count > 1)) { location = match.Groups[1].Value; } string body = "Body not found"; string temp = content; //<div>Dear int start = temp.IndexOf("<div>Dear ");// - "<div>Dear ".Length; int end = temp.IndexOf("</td>", start) + "</td>".Length; int length = end - start; temp = temp.Substring(start, length); temp = temp.Replace("\r\n", ""); temp = temp.Replace("\t", ""); pattern = "(<div>Dear (.*))</td>"; regex = new Regex(pattern); match = regex.Match(temp); if ((match.Success) && (match.Groups.Count > 1)) { body = match.Groups[1].Value + "</div></div></div></div></div>"; } AppointmentItem newAppointment = (AppointmentItem)app.CreateItem(OlItemType.olAppointmentItem); pattern = "<strong>Activity Date:</strong> (.*)</div>"; regex = new Regex(pattern); match = regex.Match(content); if ((match.Success) && (match.Groups.Count > 1)) { string value = match.Groups[1].Value; var array = value.Split(new string[] { " to " }, StringSplitOptions.None); try { newAppointment.Start = DateTime.Parse(array[0]); newAppointment.End = DateTime.Parse(newAppointment.Start.ToShortDateString() + " " + array[1]); } catch (System.Exception) { //throw ex; } // } //GetAppointmentsInRange( newAppointment.Start.Date, newAppointment.Start.AddDays( 1 ).Date ); body += footer; newAppointment.Subject = string.Format("{0} #{1} ({2} minutes)", location, reservationsNumber, newAppointment.Duration); ItemProperty MeetingNameProperty = newAppointment.ItemProperties.Add(ReservationUserPropertyTitle, OlUserPropertyType.olText, true); MeetingNameProperty.Value = ReservationUserPropertyValue + reservationsNumber; ConEx.Log("MeetingNameProperty.Value ={0}", MeetingNameProperty.Value); newAppointment.Categories = categoryStr; body += "<div>"; ////[SpoteryReservation]='Reservation: #1364009' //body += "<strong>["+ ReservationUserPropertyTitle + "]='" + MeetingNameProperty.Value + "'</strong>"; body += "Seachable"; body += "</div>"; HTML2RTFConverter html2RTFConverter = new HTML2RTFConverter(); string newTemp = html2RTFConverter.Convert(body); newAppointment.RTFBody = Encoding.ASCII.GetBytes(newTemp); newAppointment.Save(); Items items = GetAppointmentsByReservationNumber(reservationsNumber); ConEx.Log("after save is this Now present? " + ((items != null) && (items.Count > 0))); //if( ( items != null ) && ( items.Count > 0 ) ) //{ // System.Diagnostics.Debug.WriteLine( "created and found!" ); //} /* * UserProperties userProperties = newAppointment.UserProperties; * if( userProperties != null ) * { * Console.WriteLine( userProperties.Count ); * foreach( UserProperty prop in userProperties ) * { * new System.Threading.Thread( () => * { * System.Windows.Forms.MessageBox.Show( prop.Name + " " + prop.Value ); * * } ).Start(); * * } * //Console.WriteLine( prop.Name + " " + prop.Value ); * * } */ return(newAppointment); // }
private void OnDisconnected(NamedPipeConnection <string, string> connection) { ConEx.Log("OnDisconnected"); _client = null; }
bool testing = false;//false true public override object CreateCalendarItem(string content) { ReservationParser reservationParser = new ReservationParser(content); /* * ConEx.Log(reservationParser.Reservation); * ConEx.Log(reservationParser.Location); * ConEx.Log(reservationParser.ActivityDateStart); * ConEx.Log(reservationParser.ActivityDateEnd); */ ConEx.Log("CreateCalendarItem: reservationsNumber={0}", reservationParser.Reservation); Items appts = GetAppointmentsByReservationNumber(reservationParser.Reservation); ConEx.Log("is this already present? " + ((appts != null) && (appts.Count > 0))); if (!testing) { if ((appts != null) && (appts.Count > 0)) { return(null); } } //string footer = "An email address was not found"; string footer = "<div><div><div>" + "N/A" + "</div></div></div>"; if (reservationParser.PrincipalPlayer != null) { footer = "<div><div><div>" + reservationParser.PrincipalPlayer.TrimEnd('\r').Trim() + "</div></div></div>"; } string categoryStr = tennisCat1; if (reservationParser.PrincipalPlayer.Contains("greenflashtennis")) { categoryStr = tennisCat2; } else if (reservationParser.PrincipalPlayer.Contains("gslockwood")) { categoryStr = tennisCat3; } AppointmentItem newAppointment = (AppointmentItem)app.CreateItem(OlItemType.olAppointmentItem); newAppointment.Start = reservationParser.ActivityDateStart; newAppointment.End = reservationParser.ActivityDateEnd; string body = reservationParser.Body + footer; newAppointment.Subject = string.Format("{0} #{1} ({2} minutes)", reservationParser.Location, reservationParser.Reservation, newAppointment.Duration); ItemProperty MeetingNameProperty = newAppointment.ItemProperties.Add(ReservationUserPropertyTitle, OlUserPropertyType.olText, true); MeetingNameProperty.Value = ReservationUserPropertyValue + reservationParser.Reservation; ConEx.Log("MeetingNameProperty.Value ={0}", MeetingNameProperty.Value); newAppointment.Categories = categoryStr; body += "<div>"; ////[SpoteryReservation]='Reservation: #1364009' //body += "<strong>["+ ReservationUserPropertyTitle + "]='" + MeetingNameProperty.Value + "'</strong>"; body += "Seachable"; body += "</div>"; HTML2RTFConverter html2RTFConverter = new HTML2RTFConverter(); string newTemp = html2RTFConverter.Convert(body); newAppointment.RTFBody = Encoding.ASCII.GetBytes(newTemp); if (testing) { newAppointment.Display(true); } else { newAppointment.Save(); } appts = GetAppointmentsByReservationNumber(reservationParser.Reservation); ConEx.Log("after save is this Now present? " + ((appts != null) && (appts.Count > 0))); return(newAppointment); // }
//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; // }