private IResponse OnStarting(IRequest message) { Event = new VEvent(); Event.SetCreator((Person)message.Author); CommandConfiguration(); return(new ButtonResponse("Choose", GetCommands(), ResponseStatus.Expect)); }
private static void GetCalendarMethodAndType(IList <Item> items, out CalendarMethod calendarMethod, out CalendarType calendarType) { CalendarMethod?calendarMethod2 = null; CalendarType? calendarType2 = null; if (items.Count > 0) { foreach (Item item in items) { CalendarMethod icalMethod = CalendarUtil.GetICalMethod(item); if (icalMethod == CalendarMethod.None) { throw new ConversionFailedException(ConversionFailureReason.ConverterInternalFailure); } if (calendarMethod2 != null && icalMethod != calendarMethod2.Value) { throw new InvalidOperationException(ServerStrings.InconsistentCalendarMethod(calendarMethod2.Value.ToString(), item.Id.ToString())); } calendarMethod2 = new CalendarMethod?(icalMethod); CalendarType alternateCalendarType = VEvent.GetAlternateCalendarType(item); if (calendarType2 != null && alternateCalendarType != calendarType2) { throw new InvalidOperationException(ServerStrings.InconsistentCalendarMethod(calendarType2.Value.ToString(), item.Id.ToString())); } calendarType2 = new CalendarType?(alternateCalendarType); } } calendarMethod = ((calendarMethod2 != null) ? calendarMethod2.Value : CalendarMethod.Publish); calendarType = ((calendarType2 != null) ? calendarType2.Value : CalendarType.Default); }
public void ProcessRequest(HttpContext context) { var serviceContext = PortalCrmConfigurationManager.CreateServiceContext(); var scheduledActivity = serviceContext.CreateQuery("serviceappointment").FirstOrDefault(s => s.GetAttributeValue <Guid>("activityid") == Id); if (scheduledActivity == null) { NotFound(context.Response, string.Format(ResourceManager.GetString("Service_Appointment_Not_Found"), Id)); return; } var vevent = new VEvent { Created = scheduledActivity.GetAttributeValue <DateTime>("createdon"), Summary = scheduledActivity.GetRelatedEntity(serviceContext, new Relationship("service_service_appointments")).GetAttributeValue <string>("name"), Start = scheduledActivity.GetAttributeValue <DateTime?>("scheduledstart").GetValueOrDefault(), End = scheduledActivity.GetAttributeValue <DateTime?>("scheduledend").GetValueOrDefault() }; context.Response.ContentType = "text/calendar"; context.Response.Write(vevent.ToString()); }
private void DoFileDrop(Point pt, string[] files) { if (files != null && files.Length > 0) { for (int k = 0; k < files.Length; k++) { try { ImportAppointments(files[k], pt); } catch (iCalendarInvalidFileFormatException) { string message = String.Format(@"The file ""{0}"" is not a valid Internet Calendar file", Path.GetFileName(files[0])); MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (iCalendarEventImportException ex) { VEventCollection events = ex.Events; int count = events.Count; string message = String.Empty; for (int i = 0; i < count; i++) { VEvent ev = ex.Events[i]; message += String.Format("Unable to import event '{0}' started on {1:D} at {2}\n", ev.Summary.Value, ev.Start.Value.Date, ev.Start.Value.TimeOfDay); } MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { AfterImportActions(); } } } }
private VEvent ParseVEvent(TokenNode node) { var cEvent = new VEvent(); var refDate = DateTime.MinValue; bool refBool = false; string refString = ""; if (TryFindDate(node, "DTSTART", ref refDate, out refBool)) { cEvent.From = refDate; cEvent.IsFullDayEvent = refBool; } if (TryFindDate(node, "DTEND", ref refDate, out refBool)) { cEvent.To = refDate; cEvent.IsFullDayEvent = refBool; } if ((refString = TryFindString(node, "SUMMARY")) != null) { cEvent.Title = refString; } if ((refString = TryFindString(node, "DESCRIPTION")) != null) { cEvent.Description = refString; } return(cEvent); }
private void AddEventAttendees(VEvent ev, string[] addresses) { int count = addresses.Length; for (int i = 0; i < count; i++) { AddEventAttendee(ev, addresses[i]); } }
private void AddEventAttendee(VEvent ev, string address) { TextProperty p = new TextProperty("ATTENDEE", String.Format("mailto:{0}", address)); p.AddParameter("CN", address); p.AddParameter("RSVP", "TRUE"); ev.CustomProperties.Add(p); }
private void Page_Load(object sender, EventArgs e) { var oVEvent = new VEvent(); //N. Pitsch var oContext = default(HttpContext); oContext = HttpContext.Current; oVEvent.ProcessVCalRequest(oContext); }
/// <summary> /// Load event information into the controls /// </summary> /// <param name="ev">The event to use</param> private void LoadEventInfo(VEvent ev) { txtCompleted.Enabled = txtPercent.Enabled = false; lblEndDate.Text = "End"; lblUniqueId.Text = ev.UniqueId.Value; lblTimeZone.Text = ev.StartDateTime.TimeZoneId; chkTransparent.Checked = ev.Transparency.IsTransparent; txtSequence.Text = ev.Sequence.SequenceNumber.ToString(); txtPriority.Text = ev.Priority.PriorityValue.ToString(); // General if (ev.StartDateTime.TimeZoneDateTime != DateTime.MinValue) { txtStartDate.Text = ev.StartDateTime.TimeZoneDateTime.ToString("G"); } if (ev.EndDateTime.TimeZoneDateTime != DateTime.MinValue) { txtEndDate.Text = ev.EndDateTime.TimeZoneDateTime.ToString("G"); } if (ev.Duration.DurationValue != Duration.Zero) { txtDuration.Text = ev.Duration.DurationValue. ToString(Duration.MaxUnit.Weeks); } txtSummary.Text = ev.Summary.Value; txtLocation.Text = ev.Location.Value; txtDescription.Text = ev.Description.Value; txtOrganizer.Text = ev.Organizer.Value; txtUrl.Text = ev.Url.Value; txtComments.Text = ev.Comment.Value; // Load status values and set status cboStatus.Items.Add("None"); cboStatus.Items.Add("Tentative"); cboStatus.Items.Add("Confirmed"); cboStatus.Items.Add("Cancelled"); if (cboStatus.Items.FindByValue(ev.Status.StatusValue.ToString()) == null) { cboStatus.Items.Add(ev.Status.StatusValue.ToString()); } cboStatus.SelectedValue = ev.Status.StatusValue.ToString(); dgAttendees.DataSource = ev.Attendees; dgRecurrences.DataSource = ev.RecurrenceRules; dgRecurDates.DataSource = ev.RecurDates; dgExceptions.DataSource = ev.ExceptionRules; dgExDates.DataSource = ev.ExceptionDates; dgReqStats.DataSource = ev.RequestStatuses; }
public static bool IsAllDayEvent(this VEvent evnt) { DateTime startDate = evnt.StartDateTime.DateTimeValue; DateTime endDate = evnt.EndDateTime.DateTimeValue; return ((startDate == endDate || startDate.AddDays(1) == endDate ) && // event takes 0 or 24 hours - both options are used for full-day events startDate.Hour == 0 && startDate.Minute == 0); }
/// <summary> /// For Todoist task, returns name of the user's project assigned to the task based on description (which is /// localized). /// </summary> /// <param name="evnt"></param> /// <returns>user's project assigned to the task or null if not available</returns> public static string?ProjectName(this VEvent evnt) { if (evnt.Description.Value != null) { Match m = regexProjectName.Match(evnt.Description.Value); if (m.Success) { return(m.Groups[2].Value); } } return(null); }
public void MapEFToBOList() { var mapper = new DALVEventMapper(); VEvent entity = new VEvent(); entity.SetProperties(DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM"), 1m, 1, 1, DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM")); List <BOVEvent> response = mapper.MapEFToBO(new List <VEvent>() { entity }); response.Count.Should().Be(1); }
public virtual VEvent MapBOToEF( BOVEvent bo) { VEvent efVEvent = new VEvent(); efVEvent.SetProperties( bo.ActualEndDate, bo.ActualStartDate, bo.BillAmount, bo.EventStatusId, bo.Id, bo.ScheduledEndDate, bo.ScheduledStartDate); return(efVEvent); }
public virtual BOVEvent MapEFToBO( VEvent ef) { var bo = new BOVEvent(); bo.SetProperties( ef.Id, ef.ActualEndDate, ef.ActualStartDate, ef.BillAmount, ef.EventStatusId, ef.ScheduledEndDate, ef.ScheduledStartDate); return(bo); }
public void OnGet() { IcalCalendar ical = new IcalCalendar { Name = $"Badminton League", Description = "Fixtures and results of matches for the Badminton League" }; VEvent fixtureEvent = new VEvent { UID = $"RBL Home Team vs Away Team", Summary = $"🏸 Home Team vs Away Team", Location = $"Venue", DateStart = DateTime.Now.AddDays(1).Date.AddHours(19).AddMinutes(30), DateEnd = DateTime.Now.AddDays(1).Date.AddHours(22).AddMinutes(0), Priority = VEvent.PriorityLevel.Normal, Transparency = VEvent.TransparencyType.TRANSPARENT, Categories = "Badminton,Completed", Description = @"\nSCORE: 3-2\nHome team WINS\n" }; ical.Events.Add(fixtureEvent); fixtureEvent = new VEvent { UID = $"Away Team vs Heme Team", Summary = $"🏸 Home Team vs Away Team", Location = $"Other Venue", DateStart = DateTime.Now.AddDays(8).Date.AddHours(19).AddMinutes(30), DateEnd = DateTime.Now.AddDays(8).Date.AddHours(22).AddMinutes(0), Priority = VEvent.PriorityLevel.Normal, Transparency = VEvent.TransparencyType.OPAQUE, Alarms = new List <VAlarm> { new VAlarm { Trigger = new TimeSpan(0, 0, 60, 0), Action = VAlarm.ActionType.DISPLAY, Description = "Reminder" } }, Categories = "Badminton", Description = @"\n" }; ical.Events.Add(fixtureEvent); PreformattedIcal = ical.ToString(); }
public void MapBOToEF() { var mapper = new DALVEventMapper(); var bo = new BOVEvent(); bo.SetProperties(1, DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM"), 1m, 1, DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM")); VEvent response = mapper.MapBOToEF(bo); response.ActualEndDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); response.ActualStartDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); response.BillAmount.Should().Be(1m); response.EventStatusId.Should().Be(1); response.Id.Should().Be(1); response.ScheduledEndDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); response.ScheduledStartDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); }
public void MapEFToBO() { var mapper = new DALVEventMapper(); VEvent entity = new VEvent(); entity.SetProperties(DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM"), 1m, 1, 1, DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM")); BOVEvent response = mapper.MapEFToBO(entity); response.ActualEndDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); response.ActualStartDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); response.BillAmount.Should().Be(1m); response.EventStatusId.Should().Be(1); response.Id.Should().Be(1); response.ScheduledEndDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); response.ScheduledStartDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); }
public async void Get() { var mock = new ServiceMockFacade <IVEventRepository>(); var record = new VEvent(); mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(record)); var service = new VEventService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.VEventModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLVEventMapperMock, mock.DALMapperMockFactory.DALVEventMapperMock); ApiVEventResponseModel response = await service.Get(default(int)); response.Should().NotBeNull(); mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>())); }
private void PreProcessExceptions() { if (base.InboundContext.HasExceptionPromotion) { this.vEvents.AddRange(this.exceptions); this.exceptions.Clear(); return; } for (int i = this.exceptions.Count - 1; i >= 0; i--) { VEvent exception = this.exceptions[i]; if (!this.vEvents.Any((VEvent e) => e.HasRRule && e.Uid == exception.Uid)) { this.vEvents.Add(exception); this.exceptions.RemoveAt(i); } } }
public void UpdateQueue() { var queue = state.GetEvents(); for (int i = 0; i < queue.Count; i++) { VEvent e = queue[i]; switch (e.VEType) { case VEventType.WorldModification: Apply(e as VEWorldMod); break; default: break; } } }
void OnImportAppointment(object sender, AppointmentImportingEventArgs e) { VCalendarAppointmentImportingEventArgs args = (VCalendarAppointmentImportingEventArgs)e; Appointment apt = args.Appointment; VEvent ev = args.VEvent; VEventExtension ext = ev.Extensions[CustomFieldName]; // restore the custom information if (ext != null) { CustomObject obj = new CustomObject(); obj.Name = ext.Name; obj.ObjectType = ext.Parameters["TYPE"].Value; obj.ValueType = ext.Parameters["VALUE"].Value; obj.Value = ext.Value; apt.CustomFields[CustomFieldName] = obj; } }
private VEvent GetVEvent(EntityListEvent @event) { var vevent = new VEvent { Uid = "{0}@{1}".FormatWith(@event.EntityReference.Id, Request.Url.Host), Start = @event.Start, End = @event.End, Timestamp = DateTime.UtcNow, Summary = @event.Summary, Description = VCalendar.StripHtml(@event.Description), DescriptionHtml = @event.Description, Location = @event.Location, Url = string.IsNullOrEmpty(@event.Url) ? null : new UrlBuilder(@event.Url).ToString() }; if (@event.Organizer != null) { vevent.Organizer = VCalendar.FormatOrganizer(@event.Organizer.Name, @event.Organizer.Email); } return(vevent); }
void OnExportAppointment(object sender, AppointmentExportingEventArgs e) { VCalendarAppointmentExportingEventArgs args = (VCalendarAppointmentExportingEventArgs)e; Appointment apt = args.Appointment; VEvent ev = args.VEvent; // !!! only work time if (apt.Start.Hour < 8 || apt.Start.Hour > 17) { args.Cancel = true; return; } // save the custom information CustomObject obj = (CustomObject)apt.CustomFields[CustomFieldName]; VEventExtension ext = new VEventExtension(obj.Name, obj.Value); ext.Parameters.Add(new VCalendarParameter("TYPE", obj.ObjectType)); ext.Parameters.Add(new VCalendarParameter("VALUE", obj.ValueType)); ev.Extensions.Add(ext); }
private void DemoteVEvents(IList <Item> items) { foreach (Item item in items) { ExTimeZone exTimeZone = item.PropertyBag.ExTimeZone; try { REG_TIMEZONE_INFO reg_TIMEZONE_INFO = TimeZoneHelper.RegTimeZoneInfoFromExTimeZone(TimeZoneHelper.GetExTimeZoneFromItem(item)); string text = this.demotingTimeZones[reg_TIMEZONE_INFO]; item.PropertyBag.ExTimeZone = TimeZoneHelper.CreateCustomExTimeZoneFromRegTimeZoneInfo(reg_TIMEZONE_INFO, text, text); VEvent vevent = new VEvent(this); vevent.Demote(item); if (!base.OutboundContext.SuppressExceptionAndAttachmentDemotion && (base.Context.Method == CalendarMethod.Request || base.Context.Method == CalendarMethod.Cancel || base.Context.Method == CalendarMethod.Publish)) { InternalRecurrence recurrenceFromItem = CalendarItem.GetRecurrenceFromItem(item); if (recurrenceFromItem != null) { IList <OccurrenceInfo> modifiedOccurrences = recurrenceFromItem.GetModifiedOccurrences(); foreach (OccurrenceInfo occurrenceInfo in modifiedOccurrences) { ExceptionInfo exceptionInfo = (ExceptionInfo)occurrenceInfo; VEvent vevent2 = new VEvent(this); vevent2.DemoteException(exceptionInfo, vevent); } } } } catch (Exception ex) { ExTraceGlobals.ICalTracer.TraceError <Exception>((long)this.GetHashCode(), "VCalendar::DemoteVEvents. Skipping item due to {0}", ex); base.Context.AddError(ServerStrings.InvalidICalElement(ex.ToString())); } finally { item.PropertyBag.ExTimeZone = exTimeZone; } } }
public void CreateCalendarWithLocalEventAndNoTimezoneShouldHaveDefaultLocalZone() { var calendar = new VCalendar(); var start = DateTime.SpecifyKind(DateTime.Parse("1.5.2016 20:15"), DateTimeKind.Local); var end = DateTime.SpecifyKind(DateTime.Parse("1.5.2016 21:45"), DateTimeKind.Local); var vEvent = new VEvent { Start = start, End = end, Summary = "Tatort", Location = "ARD" }; calendar.Events.Add(vEvent); var textLines = calendar.GetText().Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); Assert.True(textLines.Length == 34); var tzLine = textLines.FirstOrDefault(line => line.Contains("VTIMEZONE")); Assert.NotNull(tzLine); }
private VCalendar BuildCalendar(string userId) { VCalendar vCal = new VCalendar(); vCal.CalendarName = $"Internet Calendar for {userId}"; vCal.Events = new List <VEvent>(); for (int i = 0; i < 5; i++) { VEvent ev = new VEvent(); ev.uid = Guid.NewGuid().ToString(); ev.Sequence = 0; ev.dtStamp = DateTimeOffset.UtcNow; ev.dtStart = DateTimeOffset.UtcNow.AddDays(i).AddHours(rnd.Next(-4, 5)); ev.dtEnd = ev.dtStart.AddMinutes(15 * rnd.Next(1, 9)); ev.Summary = $"Event number {i}"; vCal.Events.Add(ev); } return(vCal); }
internal bool Parse(CalendarPropertyReader propertyReader) { this.calendarPropertyId = new CalendarPropertyId(propertyReader.PropertyId, propertyReader.Name); this.value = null; this.valueType = propertyReader.ValueType; this.parameters = new List <CalendarParameter>(); CalendarParameterReader parameterReader = propertyReader.ParameterReader; while (parameterReader.ReadNextParameter()) { CalendarParameter calendarParameter = new CalendarParameter(); if (!calendarParameter.Parse(parameterReader) || !this.ProcessParameter(calendarParameter)) { return(false); } this.parameters.Add(calendarParameter); } this.valueType = propertyReader.ValueType; SchemaInfo schemaInfo; if (VEvent.GetConversionSchema().TryGetValue(this.calendarPropertyId.Key, out schemaInfo) && schemaInfo.IsMultiValue) { List <object> list = new List <object>(); while (propertyReader.ReadNextValue()) { object item = this.ReadValue(propertyReader); list.Add(item); } this.value = list; } else { this.value = this.ReadValue(propertyReader); } return(this.Validate()); }
public SecondReminderCommand(VEvent @event) : base("Second Reminder", "Send second reminder in format: yyyy.hh:mm:ss") { Event = @event; }
/// <summary> /// This is an example of how you can sort calendar object collections /// </summary> /// <param name="x">The first calendar object</param> /// <param name="y">The second calendar object</param> /// <remarks>Due to the variety of properties in a calendar object, sorting is left up to the developer /// utilizing a comparison delegate. This example sorts the collection by the start date/time property /// and, if they are equal, the summary description. This is used to handle all of the collection /// types.</remarks> private static int CalendarSorter(CalendarObject x, CalendarObject y) { DateTime d1, d2; string summary1, summary2; if (x is VEvent) { VEvent e1 = (VEvent)x, e2 = (VEvent)y; d1 = e1.StartDateTime.TimeZoneDateTime; d2 = e2.StartDateTime.TimeZoneDateTime; summary1 = e1.Summary.Value; summary2 = e2.Summary.Value; } else if (x is VToDo) { VToDo t1 = (VToDo)x, t2 = (VToDo)y; d1 = t1.StartDateTime.TimeZoneDateTime; d2 = t2.StartDateTime.TimeZoneDateTime; summary1 = t1.Summary.Value; summary2 = t2.Summary.Value; } else if (x is VJournal) { VJournal j1 = (VJournal)x, j2 = (VJournal)y; d1 = j1.StartDateTime.TimeZoneDateTime; d2 = j2.StartDateTime.TimeZoneDateTime; summary1 = j1.Summary.Value; summary2 = j2.Summary.Value; } else { VFreeBusy f1 = (VFreeBusy)x, f2 = (VFreeBusy)y; d1 = f1.StartDateTime.TimeZoneDateTime; d2 = f2.StartDateTime.TimeZoneDateTime; summary1 = f1.Organizer.Value; summary2 = f2.Organizer.Value; } if (d1.CompareTo(d2) == 0) { if (summary1 == null) { summary1 = String.Empty; } if (summary2 == null) { summary2 = String.Empty; } // For descending order, change this to compare summary 2 to summary 1 instead return(String.Compare(summary1, summary2, StringComparison.CurrentCulture)); } // For descending order, change this to compare date 2 to date 1 instead return(d1.CompareTo(d2)); }
public void ProcessRequest(HttpContext context) { Guid id; if (!Guid.TryParse(context.Request.QueryString["id"], out id)) { NotFound(context.Response, string.Format(@"Query string parameter ""id"" with value ""{0}"" is not a valid event ID.", context.Request.QueryString["id"])); return; } var serviceContext = (XrmServiceContext)PortalCrmConfigurationManager.CreateServiceContext(); if (string.Equals(context.Request.QueryString["type"], "registration", StringComparison.OrdinalIgnoreCase)) { var campaign = serviceContext.CampaignSet.FirstOrDefault(c => c.CampaignId == id); if (campaign == null) { NotFound(context.Response, string.Format(@"Campaign with ID ""{0}"" not found.", id)); return; } var vevent = new VEvent { Created = campaign.CreatedOn, Start = campaign.MSA_StartDateTime, End = campaign.MSA_EndDateTime, Summary = campaign.MSA_EventName, Description = campaign.MSA_EventDetails, Location = string.Format("{0} {1} {2} {3} {4}", campaign.MSA_Street1, campaign.MSA_City, campaign.MSA_StateProvince, campaign.MSA_ZipPostalCode, campaign.MSA_CountryRegion), Organizer = campaign.MSA_EventContact, Url = campaign.MSA_EventBrochureURL, }; context.Response.ContentType = "text/calendar"; context.Response.Write(vevent.ToString()); return; } if (string.Equals(context.Request.QueryString["type"], "service", StringComparison.OrdinalIgnoreCase)) { var scheduledActivity = serviceContext.ServiceAppointmentSet.FirstOrDefault(s => s.ActivityId == id); if (scheduledActivity == null) { NotFound(context.Response, string.Format(@"Service appointment with ID ""{0}"" not found.", id)); return; } var vevent = new VEvent { Created = scheduledActivity.CreatedOn, Summary = scheduledActivity.service_service_appointments.Name, Start = scheduledActivity.ScheduledStart, End = scheduledActivity.ScheduledEnd }; context.Response.ContentType = "text/calendar"; context.Response.Write(vevent.ToString()); return; } NotFound(context.Response, string.Format(@"Specified type ""{0}"" is not a recognized event type.", context.Request.QueryString["type"])); }