public static string GetUrl(FeedFormats format, string userName, Uri requestUri) { string result = string.Empty; result = requestUri.GetLeftPart(UriPartial.Authority); result += "/feeds/help/staffhours/" + FeedFormatToString(format) + "/" + userName; return(result); }
public static string GetUrl(FeedFormats format, string userName, string resourceId, string fileName, Uri requestUri) { string result = string.Empty; result = requestUri.GetLeftPart(UriPartial.Authority); result += "/feeds/scheduler/reservations/" + FeedFormatToString(format) + "/" + userName + "/" + resourceId + "/" + fileName; return(result); }
public static Feed CreateFeed(FeedFormats format, string username, string resourceId) { switch (format) { case FeedFormats.Calendar: DateTime d = DateTime.Now.Date; DateTime sd = d.AddDays(-1); DateTime ed = d.AddMonths(4); DataTable dt = InitCalendarTable(); int rid = GetResourceID(resourceId); IEnumerable <IReservationFeed> reservations; // if there is username we must also look for invitees if (!string.IsNullOrEmpty(username) && username != "all") { reservations = AllReservationInDateRange(username, sd, ed, rid); } else { reservations = AllReservationInDateRange(sd, ed, rid); } int facilityDowntimeActivityID = 23; var items = reservations.Where(x => x.ActivityID != facilityDowntimeActivityID).ToList(); foreach (var item in items) { DataRow dr = dt.NewRow(); dr["DTSTART"] = item.BeginDateTime.ToUniversalTime().ToString("yyyyMMdd'T'HHmmss'Z'"); dr["DTEND"] = item.EndDateTime.ToUniversalTime().ToString("yyyyMMdd'T'HHmmss'Z'"); dr["UID"] = item.ReservationID.ToString(); dr["CREATED"] = item.CreatedOn.ToUniversalTime().ToString("yyyyMMdd'T'HHmmss'Z'"); dr["LAST-MODIFIED"] = item.LastModifiedOn.ToUniversalTime().ToString("yyyyMMdd'T'HHmmss'Z'"); dr["STATUS"] = (item.IsActive) ? "CONFIRMED" : "CANCELLED"; if (!item.IsActive) { dr["METHOD"] = "CANCEL"; } dr["SUMMARY"] = string.Format("{0} [{1}] | {2} ({3})", item.ResourceName, item.ResourceID, Clients.GetDisplayName(item.LName, item.FName), item.Email); dr["DESCRIPTION"] = string.Format( "Activity: {0}\\nStatus: {1}\\nScheduled Start: {2}\\nScheduled End: {3}\\nActual Start: {4}\\nActual End: {5}", item.ActivityName, GetReservationStatus(item), GetDateTime(item.BeginDateTime), GetDateTime(item.EndDateTime), GetDateTime(item.ActualBeginDateTime), GetDateTime(item.ActualEndDateTime) ); dt.Rows.Add(dr); } return(new Feed(format, dt)); default: throw new NotImplementedException("Feed format has not been implemented."); } }
internal Feed(FeedFormats format, DataTable dt) { Format = format; _Data = dt; switch (Format) { case FeedFormats.Calendar: ContentType = "text/calendar"; Charset = string.Empty; FileExtension = ".ics"; break; default: throw new NotImplementedException("Feed format has not been implemented."); } }
public static Feed CreateFeed(FeedFormats format, string userName) { switch (format) { case FeedFormats.Calendar: DataTable dt = FeedGenerator.InitCalendarTable(); Dictionary <string, object> search_params = new Dictionary <string, object>(); IStaffDirectory sd = null; if (!string.IsNullOrEmpty(userName)) { sd = ServiceProvider.Current.Data.Client.GetStaffDirectory(userName); } if (sd != null) { DateTime[] week = WeekArray(sd.LastUpdate); StaffTimeInfoCollection staffTime = new StaffTimeInfoCollection(sd.HoursXML); IClient c = ServiceProvider.Current.Data.Client.GetClient(sd.ClientID); _ = new StaffDirectoryEntry() { StaffDirectoryID = sd.StaffDirectoryID, ClientID = sd.ClientID, UserName = c.UserName, Privs = c.Privs, LName = c.LName, MName = c.MName, FName = c.FName, Hours = staffTime.ToString(), Email = c.Email, Phone = c.Phone, Office = sd.Office, Deleted = sd.Deleted, ReadOnly = true }; foreach (KeyValuePair <DayOfWeek, StaffTimeInfo> kvp in staffTime) { if (kvp.Value.Checked) { DataRow dr = dt.NewRow(); DateTime dtstart = week[(int)kvp.Key].Add(kvp.Value.AM.Start.Value.Value); DateTime dtend = week[(int)kvp.Key].Add(kvp.Value.PM.End.Value.Value); DateTime lunchStart = week[(int)kvp.Key].Add(kvp.Value.AM.End.Value.Value); DateTime lunchEnd = week[(int)kvp.Key].Add(kvp.Value.PM.Start.Value.Value); dr["DTSTART"] = ";TZID=America/New_York:" + dtstart.ToString("yyyyMMddTHHmmss"); dr["DTEND"] = ";TZID=America/New_York:" + dtend.ToString("yyyyMMddTHHmmss"); dr["RRULE"] = ":FREQ=WEEKLY;BYDAY=" + DayCode(kvp.Key); dr["DTSTAMP"] = ":" + DateTime.Now.ToUniversalTime().ToString("yyyyMMddTHHmmssZ"); dr["UID"] = ":staffdirectory_" + sd.StaffDirectoryID.ToString(); dr["CREATED"] = ":" + sd.LastUpdate.ToUniversalTime().ToString("yyyyMMddTHHmmssZ"); dr["LAST-MODIFIED"] = ":" + sd.LastUpdate.ToUniversalTime().ToString("yyyyMMddTHHmmssZ"); dr["STATUS"] = ":CONFIRMED"; dr["SUMMARY"] = ":" + sd.LName + " " + TimeRangeToString(dtstart, dtend); dr["DESCRIPTION"] = ":Lunch: " + TimeRangeToString(lunchStart, lunchEnd); //BEGIN:VEVENT //DTSTART;TZID=America/New_York:20120914T080000 //DTEND;TZID=America/New_York:20120914T170000 //RRULE:FREQ=WEEKLY;BYDAY=FR //DTSTAMP:20120911T212356Z //UID:[email protected] //CREATED:20120911T212251Z //LAST-MODIFIED:20120911T212251Z //STATUS:CONFIRMED //SUMMARY:Getty\, James 8am - 5pm //DESCRIPTION:Lunch: 12pm - 12:30pm //SEQUENCE:0 //END:VEVENT //dr["DTSTART"] = week[(int)kvp.Key].Add(kvp.Value.AM.Start.Value.Value).ToUniversalTime().ToString("yyyyMMdd'T'HHmmss'Z'"); //dr["DTEND"] = week[(int)kvp.Key].Add(kvp.Value.PM.End.Value.Value).ToUniversalTime().ToString("yyyyMMdd'T'HHmmss'Z'"); //dr["UID"] = sd.StaffDirectoryID; //dr["CREATED"] = DateTime.Now.ToUniversalTime().ToString("yyyyMMdd'T'HHmmss'Z'"); //dr["LAST-MODIFIED"] = DateTime.Now.ToUniversalTime().ToString("yyyyMMdd'T'HHmmss'Z'"); //dr["STATUS"] = "CONFIRMED"; //dr["SUMMARY"] = string.Format("{0} | {1} ({2})", item.ResourceName, item.DisplayName, item.Email); //dr["DESCRIPTION"] = string.Format( // "Activity: {0}\\nStatus: {1}\\nScheduled Start: {2}\\nScheduled End: {3}\\nActual Start: {4}\\nActual End: {5}", // item.ActivityName, GetReservationStatus(item), GetDateTime(item.BeginDateTime), GetDateTime(item.EndDateTime), GetDateTime(item.ActualBeginDateTime), GetDateTime(item.ActualEndDateTime) //); dt.Rows.Add(dr); } } } return(new Feed(format, dt)); default: throw new NotImplementedException("Feed format has not been implemented."); } }
public static string FeedFormatToString(FeedFormats format) { return(Enum.GetName(typeof(FeedFormats), format).ToLower()); }