Exemplo n.º 1
0
        private static EntityObject CreateEntityObject(SyncTransferData transferData)
        {
            EntityObject retVal = null;
            string       entityName;

            if (_transfer2entity.TryGetValue(transferData.SyncDataName, out entityName))
            {
                switch (entityName)
                {
                case CalendarEventEntity.ClassName:
                    retVal = new CalendarEventEntity();
                    break;

                case CalendarEventRecurrenceEntity.ClassName:
                    retVal = new CalendarEventRecurrenceEntity();
                    break;

                case CalendarEventResourceEntity.ClassName:
                    retVal = new CalendarEventResourceEntity();
                    break;
                }
                if (retVal != null)
                {
                    CopyProperies(transferData, retVal);
                }
            }

            return(retVal);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates the entity object.
        /// </summary>
        /// <param name="metaClassName">Name of the meta class.</param>
        /// <param name="primaryKeyId">The primary key id.</param>
        /// <returns></returns>
        protected override EntityObject CreateEntityObject(string metaClassName, PrimaryKeyId?primaryKeyId)
        {
            if (metaClassName == CalendarEventRecurrenceEntity.ClassName)
            {
                CalendarEventRecurrenceEntity retVal = new CalendarEventRecurrenceEntity();
                retVal.PrimaryKeyId = primaryKeyId;
                return(retVal);
            }

            return(base.CreateEntityObject(metaClassName, primaryKeyId));
        }
        /// <summary>
        /// Creates the entity object.
        /// </summary>
        /// <param name="metaClassName">Name of the meta class.</param>
        /// <param name="primaryKeyId">The primary key id.</param>
        /// <returns></returns>
        protected override EntityObject CreateEntityObject(string metaClassName, PrimaryKeyId? primaryKeyId)
        {
            if (metaClassName == CalendarEventRecurrenceEntity.ClassName)
            {
                CalendarEventRecurrenceEntity retVal = new CalendarEventRecurrenceEntity();
                retVal.PrimaryKeyId = primaryKeyId;
                return retVal;
            }

            return base.CreateEntityObject(metaClassName, primaryKeyId);
        }
Exemplo n.º 4
0
        protected override void PreUpdate(BusinessContext context)
        {
            CalendarEventRecurrenceEntity recurrenceEntity = context.Request.Target as CalendarEventRecurrenceEntity;
            UpdateRequest updateRequest = context.Request as UpdateRequest;
            bool          forceBase     = updateRequest.Parameters.GetValue <bool>(EventHelper.FORCE_BASE_PARAM, false);

            if (!forceBase)
            {
                PrimaryKeyId pk = EventHelper.PrepareUpdateRecurrenceRequest(updateRequest);
                context.Request.Target.PrimaryKeyId = pk;
            }

            base.PreUpdate(context);
        }
Exemplo n.º 5
0
        protected override void Delete(BusinessContext context)
        {
            CalendarEventRecurrenceEntity recurrenceEntity = context.Request.Target as CalendarEventRecurrenceEntity;
            DeleteRequest deleteRequest = context.Request as DeleteRequest;
            bool          forceBase     = deleteRequest.Parameters.GetValue <bool>(EventHelper.FORCE_BASE_PARAM, false);

            if (!forceBase)
            {
                Mediachase.Ibn.Events.CustomMethods.EventHelper.DeleteRecurrenceRequestHandle(deleteRequest);
            }
            else
            {
                base.Delete(context);
            }
        }
Exemplo n.º 6
0
        protected void btnDelete_Click(object sender, System.EventArgs e)
        {
            CalendarEventEntity ceo = BusinessManager.Load(CalendarEventEntity.ClassName, EventId) as CalendarEventEntity;

            if (ceo != null)
            {
                FilterElementCollection fec     = new FilterElementCollection();
                PrimaryKeyId            realKey = ((VirtualEventId)EventId).RealEventId;
                FilterElement           fe      = FilterElement.EqualElement("EventId", realKey);
                fec.Add(fe);
                EntityObject[] list = BusinessManager.List(CalendarEventRecurrenceEntity.ClassName, fec.ToArray());
                if (list.Length > 0)
                {
                    CalendarEventRecurrenceEntity cero = (CalendarEventRecurrenceEntity)list[0];
                    BusinessManager.Delete(cero);

                    Response.Redirect("~/Apps/MetaUIEntity/Pages/EntityView.aspx?ClassName=CalendarEvent&ObjectId=" + realKey.ToString());
                }
            }
        }
        /// <summary>
        /// Serializes this instance.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public EntityObjectHierarchy Serialize <T>()
        {
            CalendarEventRecurrenceEntity recurrenceEntity = new CalendarEventRecurrenceEntity();

            recurrenceEntity.DayOfMonth = RPattern.ByMonthDay.Count != 0 ? RPattern.ByMonthDay[0] : 0;
            eBitDayOfWeek dayOfWeekMask = eBitDayOfWeek.Unknown;
            eInstanceType instance      = eInstanceType.InstanceFirst;

            //Primary key
            McRecurrencePattern mcRecurrencePattern = RPattern as McRecurrencePattern;

            if (mcRecurrencePattern != null)
            {
                recurrenceEntity.PrimaryKeyId = mcRecurrencePattern.MetaObjectId;
            }
            //Copy RPATTERN Parameters to entity property
            foreach (string paramName in RPattern.Parameters.Keys)
            {
                iCal2EntityMapping.MappingResult mapRes = iCal2EntityMapping.iCalProp2EntityProp <T>(paramName);
                if (mapRes != null && RPattern.Parameters.ContainsKey(paramName))
                {
                    foreach (string paramValue in ((Parameter)RPattern.Parameters[paramName]).Values)
                    {
                        recurrenceEntity[mapRes.Name] = EntityPropConverter.ToEntityProperty(mapRes.ValueType, paramValue);
                    }
                }
            }

            foreach (DaySpecifier daySpec in RPattern.ByDay)
            {
                if (daySpec.Num != int.MinValue)
                {
                    instance = (eInstanceType)daySpec.Num;
                }
                switch (daySpec.DayOfWeek)
                {
                case DayOfWeek.Sunday:
                    dayOfWeekMask |= eBitDayOfWeek.Sunday;
                    break;

                case DayOfWeek.Friday:
                    dayOfWeekMask |= eBitDayOfWeek.Friday;
                    break;

                case DayOfWeek.Monday:
                    dayOfWeekMask |= eBitDayOfWeek.Monday;
                    break;

                case DayOfWeek.Saturday:
                    dayOfWeekMask |= eBitDayOfWeek.Saturday;
                    break;

                case DayOfWeek.Thursday:
                    dayOfWeekMask |= eBitDayOfWeek.Thursday;
                    break;

                case DayOfWeek.Tuesday:
                    dayOfWeekMask |= eBitDayOfWeek.Tuesday;
                    break;

                case DayOfWeek.Wednesday:
                    dayOfWeekMask |= eBitDayOfWeek.Wednesday;
                    break;
                }
            }
            recurrenceEntity.DayOfWeekMask = (int)dayOfWeekMask;
            recurrenceEntity.Instance      = (int)instance;
            recurrenceEntity.Interval      = RPattern.Interval;

            eRecurrenceType recType = eRecurrenceType.RecursDaily;

            if (RPattern.Frequency == FrequencyType.Daily)
            {
                recType = eRecurrenceType.RecursDaily;
            }
            else if (RPattern.Frequency == FrequencyType.Weekly)
            {
                recType = eRecurrenceType.RecursWeekly;
            }
            else if (RPattern.Frequency == FrequencyType.Yearly)
            {
                recType = eRecurrenceType.RecursYearly;
            }
            //TODO: MOTH YEAR NTLR
            recurrenceEntity.RecurrenceType = (int)recType;
            recurrenceEntity.MonthOfYear    = RPattern.ByMonth.Count != 0 ? RPattern.ByMonth[0] : 0;
            if (RPattern.Until != null)
            {
                recurrenceEntity.PatternEndDate = DateTime.SpecifyKind(RPattern.Until.Value, DateTimeKind.Local);
            }
            recurrenceEntity.Occurrences = RPattern.Count == int.MinValue ? 0 : RPattern.Count;

            return(new EntityObjectHierarchy(recurrenceEntity));
        }
Exemplo n.º 8
0
        private void BindValues()
        {
            BindLists();

            SetDefaulValues();

            CalendarEventEntity ceo = BusinessManager.Load(CalendarEventEntity.ClassName, EventId) as CalendarEventEntity;

            if (ceo != null)
            {
                dtcDateStart.SelectedDate = ceo.Start;
                dtcDateEnd.SelectedDate   = ceo.End;

                FilterElementCollection fec = new FilterElementCollection();
                FilterElement           fe  = FilterElement.EqualElement("EventId", ((VirtualEventId)EventId).RealEventId);
                fec.Add(fe);
                EntityObject[] list = BusinessManager.List(CalendarEventRecurrenceEntity.ClassName, fec.ToArray());
                if (list.Length > 0)
                {
                    CalendarEventRecurrenceEntity cero = (CalendarEventRecurrenceEntity)list[0];

                    int pattern = cero.RecurrenceType;
                    if (cero.RecurrenceType == (int)eRecurrenceType.RecursWeekly &&
                        cero.DayOfWeekMask.HasValue &&
                        cero.DayOfWeekMask.Value == (int)eBitDayOfWeek.Weekdays)
                    {
                        pattern = 1;
                    }

                    Pattern = (byte)pattern;

                    if (cero.Interval.HasValue)
                    {
                        Frequency = (byte)cero.Interval.Value;
                    }
                    if (cero.DayOfWeekMask.HasValue)
                    {
                        Weekdays = (byte)cero.DayOfWeekMask;
                    }
                    if (cero.DayOfMonth.HasValue)
                    {
                        MonthDay = (byte)cero.DayOfMonth.Value;
                    }
                    if (cero.Instance.HasValue)
                    {
                        WeekNumber = (byte)cero.Instance.Value;
                    }
                    if (cero.MonthOfYear.HasValue)
                    {
                        MonthNumber = (byte)cero.MonthOfYear.Value;
                    }

                    if (cero.PatternEndDate.HasValue)
                    {
                        rbEndBy.Checked         = true;
                        rbEndAfter.Checked      = false;
                        dtcDateEnd.SelectedDate = cero.PatternEndDate.Value.Date;
                    }
                    else if (cero.Occurrences.HasValue && cero.Occurrences.Value > 0)
                    {
                        rbEndAfter.Checked = true;
                        tbEndAfter.Text    = cero.Occurrences.Value.ToString();
                    }
                }
            }
        }
Exemplo n.º 9
0
        private void BindValues()
        {
            CalendarEventEntity ceo = (CalendarEventEntity)DataItem;            //BusinessManager.Load(CalendarEventEntity.ClassName, EventId) as CalendarEventEntity;

            if (ceo != null)
            {
                FilterElementCollection fec = new FilterElementCollection();
                FilterElement           fe  = FilterElement.EqualElement("EventId", EventId);
                fec.Add(fe);
                EntityObject[] list = BusinessManager.List(CalendarEventRecurrenceEntity.ClassName, fec.ToArray());
                if (list.Length > 0)
                {
                    CalendarEventRecurrenceEntity cero = (CalendarEventRecurrenceEntity)list[0];

                    lblNoRecurrence.Visible = false;
                    ShowRecurrence.Visible  = true;
                    txtStartTime.Text       = ceo.Start.ToShortTimeString();
                    txtEndTime.Text         = ceo.End.ToShortTimeString();
                    Pattern = (byte)cero.RecurrenceType;
                    if (cero.RecurrenceType == (int)eRecurrenceType.RecursWeekly &&
                        cero.DayOfWeekMask.HasValue &&
                        cero.DayOfWeekMask.Value == (int)eBitDayOfWeek.Weekdays)
                    {
                        Pattern = (byte)eRecurrenceType.RecursDaily;
                    }

                    if (cero.Interval.HasValue)
                    {
                        Frequency = (byte)cero.Interval.Value;
                    }
                    if (cero.DayOfWeekMask.HasValue)
                    {
                        bWeekdays = (byte)cero.DayOfWeekMask;
                    }
                    if (cero.DayOfMonth.HasValue)
                    {
                        MonthDay = (byte)cero.DayOfMonth.Value;
                    }
                    if (cero.Instance.HasValue)
                    {
                        bWeekNumber = (byte)cero.Instance.Value;
                    }
                    if (cero.MonthOfYear.HasValue)
                    {
                        MonthNumber = (byte)cero.MonthOfYear.Value;
                    }

                    if (cero.Occurrences.HasValue)
                    {
                        EndAfter = cero.Occurrences.Value;
                    }

                    int pattern = Pattern;
                    if (Pattern == 1)
                    {
                        pattern = (cero.DayOfWeekMask.HasValue &&
                                   cero.DayOfWeekMask.Value == (int)eBitDayOfWeek.Weekdays) ? 12 : 11;
                    }

                    Label lblControl = (Label)this.FindControl("txtInfo" + pattern);
                    if (lblControl != null)
                    {
                        lblControl.Visible = true;
                    }
                    if (EndAfter != 0)
                    {
                        lblEnd.Text = LocRM.GetString("Endafter") + ":";
                        txtEnd.Text = EndAfter.ToString() + " " + LocRM.GetString("occurrences");
                    }
                    else if (cero.PatternEndDate.HasValue)
                    {
                        lblEnd.Text = LocRM.GetString("Endby") + ":";
                        txtEnd.Text = cero.PatternEndDate.Value.ToShortDateString();
                    }
                }
                else
                {
                    lblNoRecurrence.Text    = "<br>&nbsp; " + LocRM.GetString("NotSet") + "<br>&nbsp;";
                    lblNoRecurrence.Visible = true;
                    ShowRecurrence.Visible  = false;
                }
            }
        }