private void StartHeartbeat(object sender, EventArgs e) { PracticeClient client = new PracticeClient(); RSR_CalItems calItems = client.GetCalendarForTeam("InvalidTeam"); UpdateStats(calItems); }
public static RSR_CalItems GetCalendarItemsForTeam(string sLinkID) { SqlWhere sw = new SqlWhere(); RSR rsr; RSR_CalItems rci; RwpSlots slots = new RwpSlots(); sw.AddAliases(RwpSlot.s_mpAliases); try { sw.Add(String.Format("$$rwllpractice$$.Reserved = (select TeamID from rwllcalendarlinks where linkid='{0}')", Sql.Sqlify(sLinkID)), SqlWhere.Op.And); rsr = RSR.FromSR(Sql.ExecuteQuery(null, sw.GetWhere(RwpSlot.s_sSqlQueryString), slots, Startup._sResourceConnString)); if (!rsr.Succeeded) { rci = RSR_CalItems.FromRSR(rsr); rci.Reason = String.Format("{0} {1}", rci.Reason, Startup._sResourceConnString); return(rci); } rci = RSR_CalItems.FromRSR(RSR.FromSR(SR.Success())); List <CalItem> plci = new List <CalItem>(); if (slots.Slots != null) { foreach (RwpSlot slot in slots.Slots) { CalItem ci = new CalItem(); ci.Start = slot.SlotStart; ci.End = slot.SlotStart.AddMinutes(slot.SlotLength); ci.Location = String.Format("{0}: {1}", slot.Venue, slot.Field); ci.Title = String.Format("Team Practice: {0}", slot.Reserved); ci.Description = String.Format("Redmond West Little League team practice at {0} ({1}), for team {2}", slot.Venue, slot.Field, slot.Reserved); ci.UID = String.Format("{0}-rwllpractice-{1}", slot.Slot, slot.SlotStart.ToString("yyyyMMdd")); plci.Add(ci); } } rci.TheValue = plci; return(rci); } catch (Exception e) { rci = RSR_CalItems.FromRSR(RSR.Failed(e)); rci.Reason = String.Format("{0} ({1})", rci.Reason, sLinkID); return(rci); } }
void UpdateStats(RSR_CalItems rsr) { m_ebLastResponse.Text = rsr.Reason; if (rsr.Result) { m_ebStatus.Text = "ONLINE"; m_ebStatus.BackColor = Color.Green; } else { m_ebStatus.Text = "OFFLINE"; m_ebStatus.BackColor = Color.Red; } }
protected void DoReport(string sLinkID) { sLinkID = sLinkID.Replace(" ", "%20"); RSR_CalItems rci = m_apiInterop.CallService <RSR_CalItems>($"api/opencalendar/GetCalendarForTeam/{sLinkID}", false); if (!rci.Result) { ErrorResponse.InnerText = String.Format("Failed to get calendar for {0}: {1}", sLinkID, rci.Reason); return; } Response.Clear(); Response.ContentType = "text/calendar"; Response.AddHeader("Content-Disposition", "filename=\"practices.ics\""); Response.Write("BEGIN:VCALENDAR\r\n"); Response.Write("PRODID://Thetasoft//RWLL Practice Tool\r\n"); Response.Write("VERSION:2.0\r\n"); foreach (CalItem ci in rci.TheValue) { Response.Write("BEGIN:VEVENT\r\n"); Response.Write(String.Format("UID:{0}\r\n", ci.UID)); Response.Write(String.Format("DTSTART:{0}\r\n", ci.Start.ToString("yyyyMMddTHHmmssZ"))); Response.Write(String.Format("DTEND:{0}\r\n", ci.End.ToString("yyyyMMddTHHmmssZ"))); Response.Write(String.Format("DESCRIPTION:{0}\r\n", ci.Description)); Response.Write(String.Format("LOCATION:{0}\r\n", ci.Location)); Response.Write(String.Format("SUMMARY:{0}\r\n", ci.Title)); Response.Write("END:VEVENT\r\n"); } Response.Write("END:VCALENDAR\r\n"); Response.Flush(); Response.End(); }
public IHttpActionResult GetCalendarForTeam(string linkID) { RSR_CalItems items = RwpSlots.GetCalendarItemsForTeam(linkID); return(Ok(items)); }