Пример #1
0
        /// <summary>
        /// Получает объект типа McEvent из дерева связанных EntityObject (EntityObjectHierarchy)
        /// </summary>
        /// <param name="entityHierarchy">The entity hierarchy.</param>
        /// <returns></returns>
        public static McEvent GetMcEventFromEntityObjectHierarchy(EntityObjectHierarchy entityHierarchy)
        {
            McEvent             retVal     = new McEvent();
            McSerializerFactory factory    = new McSerializerFactory();
            IEntitySerializable serializer = factory.Create <IEntitySerializable>(retVal);

            retVal = (McEvent)serializer.Deserialize <CalendarEventEntity>(entityHierarchy.InnerEntity);
            foreach (EntityObjectHierarchy child in entityHierarchy.Childrens)
            {
                if (child.InnerEntity.MetaClassName == CalendarEventRecurrenceEntity.ClassName)
                {
                    McRecurrencePattern rPattern = new McRecurrencePattern();
                    retVal.AddChild(rPattern);
                    serializer = factory.Create <IEntitySerializable>(rPattern);
                    if (serializer != null)
                    {
                        rPattern     = (McRecurrencePattern)serializer.Deserialize <CalendarEventRecurrenceEntity>(child.InnerEntity);
                        retVal.RRule = new RecurrencePattern[] { rPattern };
                    }
                }
                else if (child.InnerEntity.MetaClassName == CalendarEventResourceEntity.ClassName)
                {
                    McCalAddress resource = new McCalAddress();
                    retVal.AddChild(resource);
                    serializer = factory.Create <IEntitySerializable>(resource);
                    if (serializer != null)
                    {
                        resource = (McCalAddress)serializer.Deserialize <CalendarEventResourceEntity>(child.InnerEntity);
                        retVal.AddChild(resource);
                        if (((CalendarEventResourceEntity)child.InnerEntity).ResourceEventOrganizator)
                        {
                            retVal.Organizer = resource;
                        }
                        else
                        {
                            List <Cal_Address> oldVals = new List <Cal_Address>();
                            if (retVal.Attendee != null)
                            {
                                oldVals.AddRange(retVal.Attendee);
                            }
                            oldVals.Add(resource);
                            retVal.Attendee = oldVals.ToArray();
                        }
                    }
                }
                else if (child.InnerEntity.MetaClassName == CalendarEventEntity.ClassName)
                {
                    McEvent exception = GetMcEventFromEntityObjectHierarchy(child);
                    if (exception != null)
                    {
                        retVal.AddReccurenceException(exception);
                    }
                }
            }

            return(retVal);
        }
Пример #2
0
        /// <summary>
        /// Получает дерево связвнных entityObject из объектной модели эвента
        /// <remarks>
        /// Структура EntityObjectHierarchy События
        ///		<event>
        ///			<recurrencePattern>
        ///			</recurrencePattern>
        ///			<resource>
        ///			</resource>
        ///			<exception>
        ///				<resource>
        ///				</resource>
        ///			</exception>
        ///		</event>
        /// </remarks>
        /// </summary>
        /// <returns></returns>
        public EntityObjectHierarchy GetEntityObjectHierarchy()
        {
            EntityObjectHierarchy retVal     = null;
            McSerializerFactory   factory    = new McSerializerFactory();
            IEntitySerializable   serializer = factory.Create <IEntitySerializable>(this);

            retVal = serializer.Serialize <CalendarEventEntity>();
            if (RRule != null)
            {
                foreach (RecurrencePattern rpattern in RRule)
                {
                    serializer = factory.Create <IEntitySerializable>(rpattern);
                    retVal.Childrens.Add(serializer.Serialize <CalendarEventRecurrenceEntity>());
                }
            }

            if (Organizer != null)
            {
                serializer = factory.Create <IEntitySerializable>(Organizer);
                if (serializer != null)
                {
                    retVal.Childrens.Add(serializer.Serialize <CalendarEventResourceEntity>());
                }
            }
            if (Attendee != null)
            {
                foreach (Cal_Address attendee in Attendee)
                {
                    serializer = factory.Create <IEntitySerializable>(attendee);
                    if (serializer != null)
                    {
                        retVal.Childrens.Add(serializer.Serialize <CalendarEventResourceEntity>());
                    }
                }
            }
            //exceptions
            if (RecurrenceException != null)
            {
                foreach (McEvent exception in RecurrenceException)
                {
                    retVal.Childrens.Add(exception.GetEntityObjectHierarchy());
                }
            }

            return(retVal);
        }
Пример #3
0
        /// <summary>
        /// Получает дерево связвнных entityObject из объектной модели эвента
        /// <remarks>
        /// Структура EntityObjectHierarchy События 
        ///		<event>
        ///			<recurrencePattern>
        ///			</recurrencePattern>
        ///			<resource>
        ///			</resource>
        ///			<exception>
        ///				<resource>
        ///				</resource>
        ///			</exception>
        ///		</event>
        /// </remarks>
        /// </summary>
        /// <returns></returns>
        public EntityObjectHierarchy GetEntityObjectHierarchy()
        {
            EntityObjectHierarchy retVal = null;
            McSerializerFactory factory = new McSerializerFactory();
            IEntitySerializable serializer = factory.Create<IEntitySerializable>(this);
            retVal = serializer.Serialize<CalendarEventEntity>();
            if (RRule != null)
            {
                foreach (RecurrencePattern rpattern in RRule)
                {
                    serializer = factory.Create<IEntitySerializable>(rpattern);
                    retVal.Childrens.Add(serializer.Serialize<CalendarEventRecurrenceEntity>());
                }
            }

            if (Organizer != null)
            {

                serializer = factory.Create<IEntitySerializable>(Organizer);
                if (serializer != null)
                    retVal.Childrens.Add(serializer.Serialize<CalendarEventResourceEntity>());
            }
            if (Attendee != null)
            {
                foreach (Cal_Address attendee in Attendee)
                {
                    serializer = factory.Create<IEntitySerializable>(attendee);
                    if (serializer != null)
                        retVal.Childrens.Add(serializer.Serialize<CalendarEventResourceEntity>());

                }
            }
            //exceptions
            if (RecurrenceException != null)
            {
                foreach (McEvent exception in RecurrenceException)
                {
                    retVal.Childrens.Add(exception.GetEntityObjectHierarchy());
                }
            }

            return retVal;
        }
Пример #4
0
        /// <summary>
        /// Получает объект типа McEvent из дерева связанных EntityObject (EntityObjectHierarchy)
        /// </summary>
        /// <param name="entityHierarchy">The entity hierarchy.</param>
        /// <returns></returns>
        public static McEvent GetMcEventFromEntityObjectHierarchy(EntityObjectHierarchy entityHierarchy)
        {
            McEvent retVal = new McEvent();
            McSerializerFactory factory = new McSerializerFactory();
            IEntitySerializable serializer = factory.Create<IEntitySerializable>(retVal);
            retVal = (McEvent)serializer.Deserialize<CalendarEventEntity>(entityHierarchy.InnerEntity);
            foreach (EntityObjectHierarchy child in entityHierarchy.Childrens)
            {
                if (child.InnerEntity.MetaClassName == CalendarEventRecurrenceEntity.ClassName)
                {
                    McRecurrencePattern rPattern = new McRecurrencePattern();
                    retVal.AddChild(rPattern);
                    serializer = factory.Create<IEntitySerializable>(rPattern);
                    if (serializer != null)
                    {
                        rPattern = (McRecurrencePattern)serializer.Deserialize<CalendarEventRecurrenceEntity>(child.InnerEntity);
                        retVal.RRule = new RecurrencePattern[] { rPattern };
                    }
                }
                else if (child.InnerEntity.MetaClassName == CalendarEventResourceEntity.ClassName)
                {
                    McCalAddress resource = new McCalAddress();
                    retVal.AddChild(resource);
                    serializer = factory.Create<IEntitySerializable>(resource);
                    if(serializer != null)
                    {
                        resource = (McCalAddress)serializer.Deserialize<CalendarEventResourceEntity>(child.InnerEntity);
                        retVal.AddChild(resource);
                        if(((CalendarEventResourceEntity)child.InnerEntity).ResourceEventOrganizator)
                        {
                            retVal.Organizer = resource;
                        }
                        else
                        {

                            List<Cal_Address> oldVals = new List<Cal_Address>();
                            if (retVal.Attendee != null)
                            {
                                oldVals.AddRange(retVal.Attendee);
                            }
                            oldVals.Add(resource);
                            retVal.Attendee = oldVals.ToArray();
                        }
                    }
                }
                else if (child.InnerEntity.MetaClassName == CalendarEventEntity.ClassName)
                {
                    McEvent exception = GetMcEventFromEntityObjectHierarchy(child);
                    if (exception != null)
                    {
                        retVal.AddReccurenceException(exception);
                    }
                }
            }

            return retVal;
        }