コード例 #1
0
        internal static string CalendarMethodToString(CalendarMethod calendarMethod)
        {
            switch (calendarMethod)
            {
            case CalendarMethod.Publish:
                return("PUBLISH");

            case CalendarMethod.Request:
                return("REQUEST");

            case CalendarMethod.Publish | CalendarMethod.Request:
                break;

            case CalendarMethod.Reply:
                return("REPLY");

            default:
                if (calendarMethod == CalendarMethod.Cancel)
                {
                    return("CANCEL");
                }
                if (calendarMethod == CalendarMethod.Counter)
                {
                    return("COUNTER");
                }
                break;
            }
            throw new ArgumentException("Not supported method: " + calendarMethod.ToString());
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        internal static CalendarMethod GetICalMethod(Item item)
        {
            CalendarMethod result    = CalendarMethod.None;
            string         className = item.ClassName;

            if (ObjectClass.IsMeetingRequest(className))
            {
                result = CalendarMethod.Request;
            }
            else if (ObjectClass.IsMeetingCancellation(className))
            {
                result = CalendarMethod.Cancel;
            }
            else if (ObjectClass.IsMeetingResponse(className))
            {
                if (item.GetValueOrDefault <bool>(InternalSchema.AppointmentCounterProposal))
                {
                    result = CalendarMethod.Counter;
                }
                else
                {
                    result = CalendarMethod.Reply;
                }
            }
            else if (ObjectClass.IsCalendarItemCalendarItemOccurrenceOrRecurrenceException(className))
            {
                result = CalendarMethod.Publish;
            }
            return(result);
        }
コード例 #4
0
        private bool PromoteProperties()
        {
            this.HandleFloatingTime();
            CalendarMethod method = base.Context.Method;

            foreach (CalendarPropertyBase calendarPropertyBase in base.ICalProperties)
            {
                SchemaInfo schemaInfo;
                if (VTodo.conversionSchema.TryGetValue(calendarPropertyBase.CalendarPropertyId.Key, out schemaInfo) && schemaInfo.PromotionMethod != null)
                {
                    if ((method & schemaInfo.Methods) != method)
                    {
                        continue;
                    }
                    object promotionMethod = schemaInfo.PromotionMethod;
                    PromoteTaskPropertyDelegate promoteTaskPropertyDelegate = promotionMethod as PromoteTaskPropertyDelegate;
                    try
                    {
                        if (promoteTaskPropertyDelegate != null)
                        {
                            if (!promoteTaskPropertyDelegate(this, calendarPropertyBase))
                            {
                                string propertyName = calendarPropertyBase.CalendarPropertyId.PropertyName;
                                ExTraceGlobals.ICalTracer.TraceError <string>((long)this.GetHashCode(), "VTodo::PromoteProperties. Failed to promote property. Property:'{1}'.", propertyName);
                                base.Context.AddError(ServerStrings.InvalidICalElement(propertyName));
                                return(false);
                            }
                        }
                        else
                        {
                            PropertyDefinition propertyDefinition = (PropertyDefinition)promotionMethod;
                            base.SetProperty(propertyDefinition, calendarPropertyBase.Value);
                        }
                        continue;
                    }
                    catch (ArgumentException)
                    {
                        if (calendarPropertyBase.ValueType == CalendarValueType.DateTime || calendarPropertyBase.ValueType == CalendarValueType.Date)
                        {
                            string propertyName2 = calendarPropertyBase.CalendarPropertyId.PropertyName;
                            ExTraceGlobals.ICalTracer.TraceError <string>((long)this.GetHashCode(), "VTodo::PromoteProperties. Failed to promote data time property. Property:'{1}'.", propertyName2);
                            base.Context.AddError(ServerStrings.InvalidICalElement(propertyName2));
                            return(false);
                        }
                        throw;
                    }
                }
                ExTraceGlobals.ICalTracer.TraceDebug <CalendarPropertyId>((long)this.GetHashCode(), "VTodo::PromoteProperties. There is no method to promote property: {0}", calendarPropertyBase.CalendarPropertyId);
            }
            return(true);
        }
コード例 #5
0
        /// <summary>
        /// Convert Enum to a string
        /// </summary>
        public static string CalendarMethod(CalendarMethod calendarMethod)
        {
            switch (calendarMethod)
            {
            case ScheduleICS.CalendarMethod.CANCEL:
                return("CANCEL");

            case ScheduleICS.CalendarMethod.PUBLISH:
                return("PUBLISH");

            case ScheduleICS.CalendarMethod.REQUEST:
            default:
                return("REQUEST");
            }
        }
コード例 #6
0
        /// <summary>
        /// Convert Enum to a string
        /// </summary>
        public static string CalendarMethod(CalendarMethod calendarMethod)
        {
            switch (calendarMethod)
            {
            case MeetingRequest.CalendarMethod.CANCEL:
                return("CANCEL");

            case MeetingRequest.CalendarMethod.PUBLISH:
                return("PUBLISH");

            case MeetingRequest.CalendarMethod.REQUEST:
            default:
                return("REQUEST");
            }
        }
コード例 #7
0
        internal static string ItemClassFromMethod(CalendarMethod method)
        {
            string result = null;

            if (method <= CalendarMethod.Cancel)
            {
                switch (method)
                {
                case CalendarMethod.Publish:
                    result = "IPM.Appointment";
                    break;

                case CalendarMethod.Request:
                    result = "IPM.Schedule.Meeting.Request";
                    break;

                case CalendarMethod.Publish | CalendarMethod.Request:
                case CalendarMethod.Reply:
                    break;

                default:
                    if (method == CalendarMethod.Cancel)
                    {
                        result = "IPM.Schedule.Meeting.Canceled";
                    }
                    break;
                }
            }
            else if (method != CalendarMethod.Refresh)
            {
                if (method != CalendarMethod.Counter)
                {
                }
            }
            else
            {
                result = "IPM.Note";
            }
            return(result);
        }
コード例 #8
0
 private static void AddSchemaInfo(CalendarPropertyId calendarPropertyId, object promotionMethod, object demotionMethod, CalendarMethod methods, IcalFlags flags)
 {
     VTodo.conversionSchema.Add(calendarPropertyId.Key, new SchemaInfo(calendarPropertyId, promotionMethod, demotionMethod, methods, flags));
 }
コード例 #9
0
 internal SchemaInfo(CalendarPropertyId calendarPropertyId, object promotionMethod, object demotionMethod, CalendarMethod methods, IcalFlags flags)
 {
     this.CalendarPropertyId = calendarPropertyId;
     this.PromotionMethod    = promotionMethod;
     this.DemotionMethod     = demotionMethod;
     this.Methods            = methods;
     this.Flags = flags;
 }
コード例 #10
0
 internal static bool IsReplyOrCounter(CalendarMethod calendarMethod)
 {
     return(calendarMethod == CalendarMethod.Reply || calendarMethod == CalendarMethod.Counter);
 }