Exemplo n.º 1
0
        /// <summary>
        /// Processes UID entries
        /// </summary>
        /// <param name="entry"></param>
        /// <param name="app"></param>
        /// <returns></returns>
        private List<Appointment> ProcessUid(CalendarEntry entry, Appointment app)
        {
            List<Appointment> uidApp;

            if (_Uid.TryGetValue(entry.Value, out uidApp) == false)
            {
                uidApp = new List<Appointment>();
                uidApp.Add(app);

                _Uid.Add(entry.Value, uidApp);
            }

            return (uidApp);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Processes Calendar version entries
 /// </summary>
 /// <param name="entry"></param>
 private void ProcessVersion(CalendarEntry entry)
 {
     if (entry.Value.Equals(Version) == false)
         ReportError(entry, "iCalendar VERSION 2.0 is required");
 }
Exemplo n.º 3
0
        /// <summary>
        /// ProcessEventEndEx
        /// </summary>
        /// <param name="model"></param>
        /// <param name="entry"></param>
        /// <param name="app"></param>
        /// <param name="evData"></param>
        private void ProcessEventEndEx(CalendarModel model,
            CalendarEntry entry, Appointment app, VEventData evData)
        {
            if (ValidateAppTime(entry, app, evData) == true)
            {
                if (evData.UidApps == null)
                {
                    evData.UidApps = new List<Appointment>();
                    evData.UidApps.Add(app);
                }

                if (evData.RecurRule != null)
                {
                    switch (evData.RecurRule.Freq)
                    {
                        case Frequency.Daily:
                            ProcessDailyRecurrence(model, app, evData);
                            break;

                        case Frequency.Weekly:
                            ProcessWeeklyRecurrence(model, app, evData);
                            break;

                        case Frequency.Monthly:
                            ProcessMonthlyRecurrence(model, app, evData);
                            break;

                        case Frequency.Yearly:
                            ProcessYearlyRecurrence(model, app, evData);
                            break;
                    }

                    ProcessRDateRange(model, app, evData);
                }
                else
                {
                    model.Appointments.Add(app);
                }

                ProcessVEventReminder(evData);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Reports encountered import errors
        /// </summary>
        /// <param name="entry"></param>
        /// <param name="text"></param>
        private void ReportError(CalendarEntry entry, string text)
        {
            if (IgnoreErrors == false)
            {
                if (entry != null)
                {
                    string s = String.Format("Error: {0}. \n{1}: Line {2}",
                                             text, _ImportFile, entry.LineStart);

                    if (entry.LineEnd - entry.LineStart > 1)
                        s += ("-" + (entry.LineEnd - 1));

                    throw new Exception(s);
                }
                else
                {
                    string s = String.Format("Error: {0}. {1}:", text, _ImportFile);

                    throw new Exception(s);
                }
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// Processes final Calendar component termination
 /// </summary>
 /// <param name="entry"></param>
 private void ProcessCalEnd(CalendarEntry entry)
 {
     if ((ComponentToken)GetToken(_components, entry.Value) != ComponentToken.VCalendar)
         ReportError(entry, "Expected \"END:VCALENDAR\"");
 }
Exemplo n.º 6
0
        /// <summary>
        /// Initiates the syntactic parsing of the given line
        /// </summary>
        /// <param name="s"></param>
        /// <param name="lineStart"></param>
        /// <param name="lineEnd"></param>
        private void ParseLine(string s, int lineStart, int lineEnd)
        {
            if (IsBlankLine(s) == false)
            {
                CalendarEntry entry = new CalendarEntry(lineStart, lineEnd);

                if (ParseId(entry, ref s) == true)
                {
                    ParseAttributes(entry, ref s);
                    ParseValue(entry, ref s);

                    _CalendarEntries.Add(entry);
                }
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// Initiates the parsing of the line attributes
 /// </summary>
 /// <param name="entry"></param>
 /// <param name="s"></param>
 private void ParseAttributes(CalendarEntry entry, ref string s)
 {
     if (s.StartsWith(";") == true)
         ParseAttributeData(entry.Attributes, ref s);
 }
Exemplo n.º 8
0
        /// <summary>
        /// Processes DNB ImageKey entries
        /// </summary>
        /// <param name="entry"></param>
        /// <param name="evData"></param>
        /// <returns></returns>
        private string ProcessXDnbImageKey(CalendarEntry entry, VEventData evData)
        {
            evData.AppPropSet |= AppProp.XDnbImageKey;

            return (entry.Value);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Processes DNB Locked entries
        /// </summary>
        /// <param name="entry"></param>
        /// <param name="evData"></param>
        /// <returns></returns>
        private bool ProcessXDnbLocked(CalendarEntry entry, VEventData evData)
        {
            evData.AppPropSet |= AppProp.XDnbLocked;

            return (entry.Value.ToLower().Equals("true"));
        }
Exemplo n.º 10
0
        /// <summary>
        /// Processes DNB DisplayTemplate entries
        /// </summary>
        /// <param name="entry"></param>
        /// <param name="evData"></param>
        /// <returns></returns>
        private string ProcessXDnbDisplayTemplate(CalendarEntry entry, VEventData evData)
        {
            evData.AppPropSet |= AppProp.XDnbDisplayTemplate;

            return (entry.Value);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Processes DNB specific ImageAlign entries
        /// </summary>
        /// <param name="entry"></param>
        /// <param name="evData"></param>
        /// <returns></returns>
        private eImageContentAlignment ProcessXDnbImageAlign(CalendarEntry entry, VEventData evData)
        {
            evData.AppPropSet |= AppProp.XDnbImageAlign;

            return ((eImageContentAlignment)
                GetEnumValue(typeof(eImageContentAlignment), entry.Value));
        }
Exemplo n.º 12
0
        /// <summary>
        /// Processes DNB CategoryColor entries
        /// </summary>
        /// <param name="entry"></param>
        /// <param name="evData"></param>
        /// <returns></returns>
        private string ProcessXDnbCategoryColor(CalendarEntry entry, VEventData evData)
        {
            evData.AppPropSet |= AppProp.XDnbCategoryColor;

            return(entry.Value);
        }
Exemplo n.º 13
0
        private Related ProcessRelated(CalendarEntry entry, string value)
        {
            ValueToken rtkn = (ValueToken)GetToken(_values, value);

            switch (rtkn)
            {
                case ValueToken.Start:
                    return (Related.Start);

                case ValueToken.End:
                    return (Related.End);

                default:
                    ReportError(entry, "Invalid RELATED value: " + value.ToUpper());
                    return (Related.Date);
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Processes VAlarm Trigger properties
        /// </summary>
        /// <param name="entry"></param>
        /// <param name="valarm"></param>
        private void ProcessTrigger(CalendarEntry entry, VAlarm valarm)
        {
            if (entry.Attributes.Count > 0)
            {
                foreach (AttributeData attr in entry.Attributes)
                {
                    ParameterToken tkn = (ParameterToken)GetToken(_parameters, attr.Id);

                    switch (tkn)
                    {
                        case ParameterToken.Related:
                            valarm.Rel = ProcessRelated(entry, attr.Value);
                            break;

                        case ParameterToken.Value:
                            switch ((ValueToken)GetToken(_values, attr.Value))
                            {
                                case ValueToken.Date:
                                    valarm.Rel = Related.Date;
                                    valarm.Date = ProcessDateValue(entry, entry.Value);
                                    break;

                                case ValueToken.DateTime:
                                    valarm.Rel = Related.Date;
                                    valarm.Date = ProcessDateTime(entry, entry.Value);
                                    break;

                                case ValueToken.Duration:
                                    valarm.Duration = ProcessDuration(entry, entry.Value);
                                    break;
                            }
                            break;
                    }
                }
            }
            else
            {
                valarm.Duration = ProcessDuration(entry, entry.Value);
            }
        }
Exemplo n.º 15
0
        private void ProcessZonePartEnd(CalendarEntry entry,
            CalendarTimeZone zone, TimeZonePart part, ComponentToken tkn)
        {
            if ((ComponentToken)GetToken(_components, entry.Value) != tkn)
                ReportError(entry, "Expected \"END:" + _components[(int)tkn].Text.ToUpper() + "\"");

            if (zone.Part == null)
                zone.Part = new List<TimeZonePart>();

            zone.Part.Add(part);
        }
Exemplo n.º 16
0
 /// <summary>
 /// Processes DNB RecStartDate entries
 /// </summary>
 /// <param name="entry"></param>
 /// <returns></returns>
 private DateTime ProcessXDnbRecStartDate(CalendarEntry entry)
 {
     return (ProcessDateTime(entry, entry.Value));
 }
Exemplo n.º 17
0
        /// <summary>
        /// Processes X-WR-CALNAME entries
        /// </summary>
        /// <param name="entry"></param>
        /// <returns></returns>
        private string ProcessWrCalName(CalendarEntry entry)
        {
            if (entry.Attributes.Count > 0)
            {
                foreach (AttributeData attr in entry.Attributes)
                {
                    ParameterToken tkn = (ParameterToken)GetToken(_parameters, attr.Id);

                    if (tkn == ParameterToken.Value)
                        return (entry.Value);
                }
            }

            return (null);
        }
Exemplo n.º 18
0
        /// <summary>
        /// Processes DNB StartTimeAction entries
        /// </summary>
        /// <param name="entry"></param>
        /// <param name="evData"></param>
        /// <returns></returns>
        private eStartTimeAction ProcessXDnbStartTimeAction(CalendarEntry entry, VEventData evData)
        {
            evData.AppPropSet |= AppProp.XDnbStartTimeAction;

            return ((eStartTimeAction)
                GetEnumValue(typeof(eStartTimeAction), entry.Value));
        }
Exemplo n.º 19
0
        /// <summary>
        /// Parses the Id portion of the given line
        /// </summary>
        /// <param name="entry"></param>
        /// <param name="s"></param>
        /// <returns></returns>
        private bool ParseId(CalendarEntry entry, ref string s)
        {
            Regex p = new Regex("^[^;:]+\\s*");
            Match ma = p.Match(s);

            if (ma.Success == false)
            {
                ReportError(entry, "Expected ID:");
                return (false);
            }

            entry.Id = ma.Value;

            s = s.Substring(ma.Index + ma.Length);

            return (true);
        }
Exemplo n.º 20
0
        /// <summary>
        /// Processes DNB TimeMarkedAs entries
        /// </summary>
        /// <param name="entry"></param>
        /// <param name="evData"></param>
        /// <returns></returns>
        private string ProcessXDnbTimeMarkedAs(CalendarEntry entry, VEventData evData)
        {
            evData.AppPropSet |= AppProp.XDnbTimeMarkedAs;

            return (entry.Value);
        }
Exemplo n.º 21
0
        /// <summary>
        /// Parses the value portion of the given line
        /// </summary>
        /// <param name="entry"></param>
        /// <param name="s"></param>
        private void ParseValue(CalendarEntry entry, ref string s)
        {
            Regex p = new Regex("^:\\s*((?<value>\"[^\"]\")|(?<value>.+))");
            Match ma = p.Match(s);

            if (ma.Success == true)
            {
                entry.Value = RemoveMetaData(ma.Groups["value"].Value);

                s = s.Substring(ma.Index + ma.Length);
            }
        }
Exemplo n.º 22
0
        /// <summary>
        /// Processes DNB ToolTip entries
        /// </summary>
        /// <param name="entry"></param>
        /// <param name="evData"></param>
        /// <returns></returns>
        private string ProcessXDnbTooltip(CalendarEntry entry, VEventData evData)
        {
            evData.AppPropSet |= AppProp.XDnbTooltip;

            return (entry.Value);
        }
Exemplo n.º 23
0
        /// <summary>
        /// Initiates the processing of each calendar component entry
        /// </summary>
        /// <param name="entry"></param>
        private void ProcessCalendarEntries(CalendarEntry entry)
        {
            while (entry != null)
            {
                switch ((PropertyToken)GetToken(_properties, entry.Id))
                {
                    case PropertyToken.Begin:
                        switch ((ComponentToken)GetToken(_components, entry.Value))
                        {
                            case ComponentToken.VCalendar:
                                ProcessVCalendar();
                                break;
                        }
                        break;
                }

                entry = GetNextEntry();
            }
        }
Exemplo n.º 24
0
 /// <summary>
 /// Processes TxId values
 /// </summary>
 /// <param name="entry"></param>
 /// <returns></returns>
 private string ProcessTzId(CalendarEntry entry)
 {
     return (entry.Value);
 }
Exemplo n.º 25
0
        /// <summary>
        /// Processes Calendar Scale (Gregorian only support)
        /// </summary>
        /// <param name="entry"></param>
        private void ProcessCalScale(CalendarEntry entry)
        {
            ValueToken tkn = (ValueToken)GetToken(_values, entry.Value);

            if (tkn != ValueToken.Gregorian)
                ReportError(entry, "Only GREGORIAN calendar scale is supported");
        }
Exemplo n.º 26
0
        /// <summary>
        /// Processes TzOffset values
        /// </summary>
        /// <param name="entry"></param>
        /// <returns></returns>
        private int ProcessTzOffset(CalendarEntry entry)
        {
            const string s = "^(?<sign>[+-]+)*";
            const string t = "((?<hours>\\d{2})(?<minutes>\\d{2})*)*";

            Regex p = new Regex(s + t);
            Match ma = p.Match(entry.Value);

            if (ma.Success == true)
            {
                int sign = ma.Groups["sign"].Value.Equals("-") ? -1 : 1;

                int hours = GetGroupIntValue(ma, "hours", sign);
                int minutes = GetGroupIntValue(ma, "minutes", sign);

                return (hours * 60 + minutes);
            }

            ReportError(entry, "Invalid TZOFFSET");

            return (0);
        }
Exemplo n.º 27
0
 /// <summary>
 /// Processes Event termination
 /// </summary>
 /// <param name="entry"></param>
 /// <param name="app"></param>
 /// <param name="evData"></param>
 private void ProcessVEventEnd(CalendarEntry entry, Appointment app, VEventData evData)
 {
     if (evData.RecIdDate != DateTime.MinValue)
         ProcessRecurrenceId(entry, app, evData);
     else
         ProcessEventEndEx(Model, entry, app, evData);
 }
Exemplo n.º 28
0
        /// <summary>
        /// ProcessVTimezoneEnd
        /// </summary>
        /// <param name="entry"></param>
        /// <param name="zone"></param>
        private void ProcessVTimezoneEnd(CalendarEntry entry, CalendarTimeZone zone)
        {
            if ((ComponentToken)GetToken(_components, entry.Value) != ComponentToken.VTimezone)
                ReportError(entry, "Expected \"END:VTIMEZONE\"");

            if (_CalendarTimeZone == null)
                _CalendarTimeZone = new List<CalendarTimeZone>();

            _CalendarTimeZone.Add(zone);
        }
Exemplo n.º 29
0
        private bool ValidateAppTime(CalendarEntry entry, Appointment app, VEventData evData)
        {
            if (app.StartTime == DateTime.MinValue)
            {
                ReportError(entry, "DTSTART not set");
                return (false);
            }

            if (evData.Duration.TotalSeconds != 0)
                app.EndTime = app.StartTime.Add(evData.Duration);

            else if (app.EndTime == DateTime.MinValue)
            {
                app.EndTime = (evData.IsDtStartValue == true)
                                  ? app.StartTime.AddDays(1)
                                  : app.StartTime;
            }

            if (app.StartTime > app.EndTime)
            {
                ReportError(entry, "DTSTART is greater than DTEND");
                return (false);
            }

            evData.StartTime = app.StartTime;
            evData.EndTime = app.EndTime;

            return (true);
        }
Exemplo n.º 30
0
        /// <summary>
        /// Processes Summary entries
        /// </summary>
        /// <param name="entry"></param>
        /// <param name="evData"></param>
        /// <returns></returns>
        private string ProcessSummary(CalendarEntry entry, VEventData evData)
        {
            evData.AppPropSet |= AppProp.Summary;

            return (entry.Value);
        }