Example #1
0
        /// <summary>
        /// Reads the appointments from the Exchange server.
        /// </summary>
        /// <param name="owner">The owner RadScheduler instance.</param>
        /// <returns></returns>
        public override IEnumerable <Appointment> GetAppointments(RadScheduler owner)
        {
            List <Appointment> appointments = new List <Appointment>();

            foreach (Resource resource in owner.Resources)
            {
                string sharedCalendarName = this.CalendarNames;// resource.Text;

                // Identify which folders to search.
                DistinguishedFolderIdType distinguishedFolderIdType = new DistinguishedFolderIdType();
                distinguishedFolderIdType.Id = DistinguishedFolderIdNameType.calendar;


                EmailAddressType emailAddressType = new EmailAddressType();
                emailAddressType.EmailAddress = sharedCalendarName;

                distinguishedFolderIdType.Mailbox = emailAddressType;

                List <ItemIdType> itemIds = new List <ItemIdType>();

                foreach (CalendarItemType item in FindCalendarItems(new DistinguishedFolderIdType[] { distinguishedFolderIdType }))
                {
                    if ((item.Start < owner.VisibleRangeEnd && item.End > owner.VisibleRangeStart) ||
                        item.CalendarItemType1 == CalendarItemTypeType.RecurringMaster)
                    {
                        itemIds.Add(item.ItemId);
                    }
                }

                appointments.AddRange(GetAppointments(owner, sharedCalendarName, itemIds.ToArray()));
            }

            return(appointments);
        }
Example #2
0
 public static void bind_resources(ref RadScheduler _obj)
 {
     foreach (venue _item in List())
     {
         _obj.Resources.Add(new Resource("Venue", _item.venueID, _item.venuename));
     }
 }
Example #3
0
        /// <summary>
        /// Updates the specified appointment.
        /// </summary>
        /// <param name="owner">The owner RadScheduler instance.</param>
        /// <param name="appointmentToUpdate">The appointment to update.</param>
        public override void Update(RadScheduler owner, Appointment appointmentToUpdate)
        {
            if (owner.ProviderContext is RemoveRecurrenceExceptionsContext)
            {
                RemoveRecurrenceExceptions(appointmentToUpdate);
                return;
            }

            if (owner.ProviderContext is UpdateAppointmentContext)
            {
                // When removing recurrences through the UI,
                // one Update operation is used to both update the appointment
                // and remove the recurrence exceptions.
                RecurrenceRule updatedRule;
                RecurrenceRule.TryParse(appointmentToUpdate.RecurrenceRule, out updatedRule);

                if (updatedRule != null && updatedRule.Exceptions.Count == 0)
                {
                    RemoveRecurrenceExceptions(appointmentToUpdate);
                }
            }

            CreateRecurrenceExceptionContext createExceptionContext = owner.ProviderContext as CreateRecurrenceExceptionContext;

            if (createExceptionContext == null)
            {
                // We are not creating a recurrence exceptions - synchronize deleted occurrences.
                SynchronizeDeletedOccurrences(appointmentToUpdate);
            }

            ItemChangeType[] changes = new ItemChangeType[] { GetAppointmentChanges(appointmentToUpdate) };
            UpdateCalendarItem(changes);
        }
        public override IEnumerable <Appointment> GetAppointments(RadScheduler owner)
        {
            RetrieveData();

            List <Appointment> appointments = new List <Appointment>();

            int index = 1;

            foreach (CalendarEventDto calendarEvent in CalendarEvents)
            {
                Appointment apt = new Appointment();
                apt.Owner   = owner;
                apt.ID      = index++;
                apt.Subject = string.Format("{0} ({1}, {2:t})", calendarEvent.EventSubject, calendarEvent.ObjectDisplay, calendarEvent.ScheduledTime);
                apt.Start   = calendarEvent.ScheduledTime;
                if (calendarEvent.ScheduledTime.Hour == 0 && calendarEvent.ScheduledTime.Minute == 0)
                {
                    apt.End = calendarEvent.ScheduledTime.AddDays(1);
                }
                else
                {
                    apt.End = calendarEvent.ScheduledTime.AddHours(0.5);
                }
                apt.RecurrenceRule     = string.Empty;
                apt.RecurrenceParentID = null;

                appointments.Add(apt);
            }

            return(appointments);
        }
Example #5
0
 public virtual void Update(RadScheduler owner, Appointment appointmentToUpdate)
 {
     if (!PersistChanges)
     {
         return;
     }
 }
    public override IEnumerable <ResourceType> GetResourceTypes(RadScheduler owner)
    {
        ResourceType[] resourceTypes = new ResourceType[2];
        resourceTypes[0] = new ResourceType("Teacher", false);
        resourceTypes[1] = new ResourceType("Student", true);

        return(resourceTypes);
    }
Example #7
0
        private static RecurrenceType CreateRecurrence(RecurrenceRule schedulerRule, RadScheduler owner)
        {
            RecurrenceType recurrence = new RecurrenceType();

            recurrence.Item  = RecurrencePatternBaseType.CreateFromSchedulerRecurrencePattern(schedulerRule.Pattern);
            recurrence.Item1 = RecurrenceRangeBaseType.CreateFromSchedulerRecurrenceRule(schedulerRule, owner);

            return(recurrence);
        }
Example #8
0
    /// <summary>
    /// Set header of scheduler. Also set start time and end time of TimeLineView.
    /// </summary>
    /// <param name="scheduler">Scheduler whose TimeLineView need to be set.</param>
    /// <param name="hiddenHeader">HiddenField which will be used to customize header of Scheduler.</param>
    public static void SetTimeLineAttributes(RadScheduler scheduler, HiddenField hiddenHeader)
    {
        scheduler.SelectedDate = scheduler.SelectedDate.Date;
        hiddenHeader.Value     = String.Format("{0:dddd, MMMM d, yyyy}", scheduler.SelectedDate);

        scheduler.TimelineView.StartTime     = OpenTime;
        scheduler.TimelineView.SlotDuration  = TimeSpan.FromHours(1);
        scheduler.TimelineView.NumberOfSlots = NumberOfSlots = (CloseTime.Subtract(OpenTime)).Hours;
    }
Example #9
0
    /// <summary>
    /// Check if event exceeds limit of more than one event.
    /// </summary>
    /// <param name="apt">Appointment object which needs to be checked.</param>
    /// <param name="scheduler">RadScheduler in which appointment would be created.</param>
    /// <returns>Return true if event exceeds limit.</returns>
    public static bool ExceedsLimit(Appointment apt, RadScheduler scheduler)
    {
        const int aptLimit = 1;
        var       aptRoom  = apt.Resources.GetResourceByType("Room");

        var aptCount = (from existingApt in scheduler.Appointments.GetAppointmentsInRange(apt.Start, apt.End) let exstAptRoom = existingApt.Resources.GetResourceByType("Room") where existingApt.Visible && exstAptRoom.Equals(aptRoom) select existingApt).Count();

        return(aptCount > aptLimit - 1);
    }
Example #10
0
    protected void RadScheduler_TimeSlotCreated(object sender, TimeSlotCreatedEventArgs e)
    {
        RadScheduler scheduler = (RadScheduler)sender;

        if (e.TimeSlot.Start.Month != Int32.Parse(scheduler.ID.Substring(12)))
        {
            e.TimeSlot.CssClass += "Disabled";
        }
    }
        public override IEnumerable<Appointment> GetAppointments(RadScheduler owner)
        {
            List<Appointment> appointments = new List<Appointment>();
            var employees = GetAllEmployees();

            using (DbConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["CalendarConnectionString"].ToString()))
            {
                DbCommand cmd = new SqlCommand();
                cmd.Connection = conn;
                cmd.CommandText = @"SELECT [ID], [ScheduleID], [TypeID], [Subject], [Start], [End], [UserID],
                                    [RecurrenceRule], [RecurrenceParentId] FROM [Appointments] WHERE [ScheduleID]=@ScheduleID";
                cmd.Parameters.Add(CreateParameter("@ScheduleID", _session["ScheduleID"]));

                conn.Open();
                using (DbDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        Appointment apt = new Appointment();
                        apt.Owner = owner;
                        apt.ID = reader["ID"];
                        apt.Subject = Convert.ToString(reader["Subject"]);
                        apt.Start = DateTime.SpecifyKind(Convert.ToDateTime(reader["Start"]), DateTimeKind.Utc);
                        apt.End = DateTime.SpecifyKind(Convert.ToDateTime(reader["End"]), DateTimeKind.Utc);
                        apt.RecurrenceRule = Convert.ToString(reader["RecurrenceRule"]);
                        apt.RecurrenceParentID = reader["RecurrenceParentId"] == DBNull.Value ? null : reader["RecurrenceParentId"];

                        if (apt.RecurrenceParentID != null)
                        {
                            apt.RecurrenceState = RecurrenceState.Exception;
                        }
                        else if (apt.RecurrenceRule != string.Empty)
                        {
                            apt.RecurrenceState = RecurrenceState.Master;
                        }

                        var typeID = reader["TypeID"].ToString();
                        apt.Resources.Add(_types.Where(x => x.Key.ToString() == typeID).SingleOrDefault());

                        if (!String.IsNullOrEmpty(reader["UserID"].ToString()))
                        {
                            var employeeID = reader["UserID"].ToString();
                            apt.Resources.Add(employees.Where(x => x.Key.ToString() == employeeID).SingleOrDefault());
                        }

                        apt.Attributes.Add("ScheduleID", reader["ScheduleID"].ToString());

                        appointments.Add(apt);
                    }
                }
            }

            return appointments;
        }
Example #12
0
        private IEnumerable <Appointment> GetAppointments(RadScheduler owner, string sharedCalendarName, ItemIdType[] itemIdsArray)
        {
            IList <CalendarItemType> calendarItems = GetCalendarItems(itemIdsArray);
            List <Appointment>       appointments  = new List <Appointment>(calendarItems.Count);

            foreach (CalendarItemType item in calendarItems)
            {
                appointments.AddRange(CreateAppointmentsFromCalendarItem(owner, sharedCalendarName, item));
            }

            return(appointments);
        }
Example #13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ResourceGroupsCollection"/> class.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="scheduler">The scheduler.</param>
        public ResourceGroupsCollection(AppointmentCollectionView source, RadScheduler scheduler)
        {
            this.Source = source;

            this.Scheduler = scheduler;

            this.Scheduler.ResourceTypes.CollectionChanged         += this.OnCollectionChanged;
            this.Scheduler.ResourceStyleMappings.CollectionChanged += this.OnCollectionChanged;
            this.Source.CollectionChanged += this.OnCollectionChanged;

            this.RecreateGroups(true);
        }
Example #14
0
    /// <summary>
    /// Check if event overlaps another event.
    /// </summary>
    /// <param name="apt">Appointment object which needs to be checked.</param>
    /// <param name="scheduler">RadScheduler in which appointment would be created.</param>
    /// <returns>Return true if event overlap.</returns>
    public static bool AppointmentsOverlap(Appointment apt, RadScheduler scheduler)
    {
        if (ExceedsLimit(apt, scheduler))
        {
            var aptRoom = apt.Resources.GetResourceByType("Room");

            var resAppts = (from existApt in scheduler.Appointments.GetAppointmentsInRange(apt.Start, apt.End) let exstAptRoom = existApt.Resources.GetResourceByType("Room") where aptRoom.Equals(exstAptRoom) select existApt).ToList();

            var aptId = Convert.ToInt32(Convert.ToString(apt.ID));
            return(resAppts.Select(a => Convert.ToInt32(Convert.ToString(a.ID))).Any(aId => aId != aptId));
        }
        return(false);
    }
Example #15
0
        /// <summary>
        /// Deletes the specified appointment.
        /// </summary>
        /// <param name="owner">The owner RadScheduler instance.</param>
        /// <param name="appointmentToDelete">The appointment to delete.</param>
        public override void Delete(RadScheduler owner, Appointment appointmentToDelete)
        {
            if (owner.ProviderContext is RemoveRecurrenceExceptionsContext)
            {
                return;
            }

            ItemIdType itemId = new ItemIdType();

            itemId.Id        = appointmentToDelete.Attributes[ExchangeIdAttribute];
            itemId.ChangeKey = appointmentToDelete.Attributes[ExchangeChangeKeyAttribute];

            DeleteItem(itemId);
        }
Example #16
0
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel(RadScheduler scheduler)
        {
            _clientService = NinjectBootstrap.Kernel.Get<Service.Interface.IClientService>();
            _orderService = NinjectBootstrap.Kernel.Get<Service.Interface.IOrderService>();

            _scheduler = scheduler;

            SearchTextBoxVisibility = Visibility.Collapsed;
            
            //Выбираем первый зал:
            SelectedHall = 1;

            LoadData();
        }
    public override IEnumerable <Resource> GetResourcesByType(RadScheduler owner, string resourceType)
    {
        switch (resourceType)
        {
        case "Teacher":
            return(Teachers.Values);

        case "Student":
            return(Students.Values);

        default:
            throw new InvalidOperationException("Unknown resource type: " + resourceType);
        }
    }
Example #18
0
        private void InsertRecurrenceException(RadScheduler owner, Appointment appointmentToInsert, DateTime exceptionDate)
        {
            Appointment      master          = owner.Appointments.FindByID(appointmentToInsert.RecurrenceParentID);
            int              occurrenceIndex = GetOccurrenceIndex(exceptionDate, master);
            CalendarItemType occurrenceItem  = GetOccurrenceItem(master, occurrenceIndex);

            occurrenceItem.MeetingTimeZone = GetTimeZone(appointmentToInsert.Owner.TimeZoneOffset);

            // Update the occurrence
            ItemChangeType itemUpdates = GetAppointmentChanges(appointmentToInsert);

            itemUpdates.Item = occurrenceItem.ItemId;
            ItemChangeType[] changes = new ItemChangeType[] { itemUpdates };

            UpdateCalendarItem(changes);
        }
Example #19
0
        public MantenimientoSessionAppCollection(RadScheduler scheduler)
        {
            MantenimientoDataLogic      MantenimientoLogic = new MantenimientoDataLogic();
            EquipoDataLogic             EquipoLogic        = new EquipoDataLogic();
            TurnoMantenimientoDataLogic TurnoLogic         = new TurnoMantenimientoDataLogic();
            int      month          = DateTime.Now.Month;
            DateTime mondayDate     = CalendarHelper.GetFirstDayOfWeek(DateTime.Today, DayOfWeek.Monday);
            DateTime satDate        = CalendarHelper.GetFirstDayOfWeek(DateTime.Today, DayOfWeek.Saturday);
            DateTime lastsundayDate = CalendarHelper.GetEndOfMonth(DateTime.Today);

            foreach (T_C_Mantenimiento Mantenimiento in MantenimientoLogic.ListarActivosMantenimientos())
            {
                MantenimientoSessionApp MantenimientoApp = new MantenimientoSessionApp();
                MantenimientoApp.Subject = EquipoLogic.SeleccionarEquipo(Mantenimiento.Id_Equipo.ToString()).Descripcion;
                MantenimientoApp.Body    = "mantenimiento de equipo " + MantenimientoApp.Subject;
                string horaminutoinicio, horaminutofin, horainicio, minutoinicio, horafin, minutofin = "";
                horaminutoinicio = TurnoLogic.SeleccionarTurnoMantenimiento(Mantenimiento.Id_TurnoMantenimiento).HoraInicio.ToString();
                horaminutofin    = TurnoLogic.SeleccionarTurnoMantenimiento(Mantenimiento.Id_TurnoMantenimiento).HoraFin.ToString();
                if (horaminutoinicio.Length == 4)
                {
                    horainicio   = horaminutoinicio.Substring(0, 2);
                    minutoinicio = horaminutoinicio.Substring(2, 2);
                }
                else
                {
                    horainicio   = horaminutoinicio.Substring(0, 1);
                    minutoinicio = horaminutoinicio.Substring(1, 3);
                }
                if (horaminutofin.Length == 4)
                {
                    horafin   = horaminutofin.Substring(0, 2);
                    minutofin = horaminutofin.Substring(2, 2);
                }
                else
                {
                    horafin   = horaminutofin.Substring(0, 1);
                    minutofin = horaminutofin.Substring(1, 3);
                }
                MantenimientoApp.Start    = Convert.ToDateTime(Mantenimiento.FechaProgramacion.Year + "-" + Mantenimiento.FechaProgramacion.Month + "-" + Mantenimiento.FechaProgramacion.Day + " " + horainicio + ":" + minutoinicio + ":00.000");
                MantenimientoApp.End      = Convert.ToDateTime(Mantenimiento.FechaProgramacion.Year + "-" + Mantenimiento.FechaProgramacion.Month + "-" + Mantenimiento.FechaProgramacion.Day + " " + horafin + ":" + minutofin + ":00.000");
                MantenimientoApp.Equipo   = Mantenimiento.Id_Equipo;
                MantenimientoApp.Category = scheduler.Categories.GetCategoryByName("MANTE");
                Add(MantenimientoApp);
            }
        }
Example #20
0
        /// <summary>
        /// Inserts the specified appointment.
        /// </summary>
        /// <param name="owner">The owner RadScheduler instance.</param>
        /// <param name="appointmentToInsert">The appointment to insert.</param>
        public override void Insert(RadScheduler owner, Appointment appointmentToInsert)
        {
            CreateRecurrenceExceptionContext createExceptionContext = owner.ProviderContext as CreateRecurrenceExceptionContext;

            if (createExceptionContext != null)
            {
                Debug.Assert(appointmentToInsert.RecurrenceState == RecurrenceState.Exception);
                InsertRecurrenceException(owner, appointmentToInsert, createExceptionContext.RecurrenceExceptionDate);
                return;
            }


            CalendarItemType calendarItem = CreateCalendarItem(owner, appointmentToInsert);

            CreateItemType createItemRequest = new CreateItemType();

            DistinguishedFolderIdType destFolder = new DistinguishedFolderIdType();

            destFolder.Id = DistinguishedFolderIdNameType.calendar;

            EmailAddressType emailAddressType = new EmailAddressType();

            emailAddressType.EmailAddress = this.CalendarNames;

            destFolder.Mailbox = emailAddressType;

            createItemRequest.SavedItemFolderId      = new TargetFolderIdType();
            createItemRequest.SavedItemFolderId.Item = destFolder;


            createItemRequest.SendMeetingInvitations          = CalendarItemCreateOrDeleteOperationType.SendToNone;
            createItemRequest.SendMeetingInvitationsSpecified = true;
            createItemRequest.Items       = new NonEmptyArrayOfAllItemsType();
            createItemRequest.Items.Items = new CalendarItemType[] { calendarItem };

            CreateItemResponseType response        = Service.CreateItem(createItemRequest);
            ResponseMessageType    responseMessage = response.ResponseMessages.Items[0];

            if (responseMessage.ResponseCode != ResponseCodeType.NoError)
            {
                throw new Exception("CreateItem failed with response code " + responseMessage.ResponseCode);
            }
        }
Example #21
0
        /// <summary>
        /// Implement this method if you use custom resources.
        /// </summary>
        public override IEnumerable <Resource> GetResourcesByType(RadScheduler owner, string resourceType)
        {
            string[] sharedCalendarNames = CalendarNames.Split(new char[] { ',' });


            List <Resource> resources = new List <Resource>(sharedCalendarNames.Length);

            for (int ix = 0; ix < sharedCalendarNames.Length; ix++)
            {
                Resource sharedCalendar = new Resource();
                sharedCalendar.Type     = "SharedCalendar";
                sharedCalendar.Key      = sharedCalendarNames[ix];
                sharedCalendar.Text     = sharedCalendarNames[ix];
                sharedCalendar.CssClass = "res" + sharedCalendarNames[ix];

                resources.Add(sharedCalendar);
            }

            return(resources.ToArray());
        }
        public override void Delete(RadScheduler owner, Appointment appointmentToDelete)
        {
            using (DbConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["CalendarConnectionString"].ToString()))
            {
                conn.Open();
                using (DbTransaction tran = conn.BeginTransaction())
                {
                    DbCommand cmd = new SqlCommand();
                    cmd.Connection = conn;
                    cmd.Transaction = tran;

                    cmd.CommandText = @"DELETE [Appointments] WHERE ID=@ID";

                    cmd.Parameters.Add(CreateParameter("@ID", appointmentToDelete.ID));

                    cmd.ExecuteNonQuery();
                    tran.Commit();
                }
            }
        }
Example #23
0
    protected void RadScheduler1_NavigationComplete1(object sender, SchedulerNavigationCompleteEventArgs e)
    {
        RadScheduler scheduler = (RadScheduler)sender;

        if (e.Command == SchedulerNavigationCommand.SwitchToSelectedDay)
        {
            scheduler.SelectedView = SchedulerViewType.TimelineView;
        }

        if (scheduler.SelectedView != SchedulerViewType.TimelineView)
        {
            if (e.Command == SchedulerNavigationCommand.SwitchToTimelineView)
            {
                RadScheduler1.RowHeight           = 60;
                RadScheduler1.AppointmentTemplate = new AppTemplate();
                RadScheduler1.GroupBy             = "Date,Room";
                RadScheduler1.GroupingDirection   = GroupingDirection.Vertical;
            }
            else
            {
                RadScheduler1.RowHeight = 25;
            }
        }
        else
        {
            if (e.Command == SchedulerNavigationCommand.NavigateToPreviousPeriod ||
                e.Command == SchedulerNavigationCommand.NavigateToNextPeriod || e.Command == SchedulerNavigationCommand.SwitchToSelectedDay)
            {
                RadScheduler1.RowHeight           = 60;
                RadScheduler1.AppointmentTemplate = new AppTemplate();
                RadScheduler1.GroupBy             = "Date,Room";
                RadScheduler1.GroupingDirection   = GroupingDirection.Vertical;
            }
            else
            {
                RadScheduler1.RowHeight = 25;
            }
        }
    }
Example #24
0
        protected virtual CalendarItemType CreateCalendarItem(RadScheduler owner, Appointment apt)
        {
            CalendarItemType calendarItem = new CalendarItemType();

            calendarItem.Subject        = apt.Subject;
            calendarItem.Start          = apt.Start;
            calendarItem.StartSpecified = true;
            calendarItem.End            = apt.End;
            calendarItem.EndSpecified   = true;

            calendarItem.MeetingTimeZone = GetTimeZone(owner.TimeZoneOffset);

            RecurrenceRule rrule;

            RecurrenceRule.TryParse(apt.RecurrenceRule, out rrule);
            if (rrule != null && rrule.Pattern.Frequency != RecurrenceFrequency.Hourly)
            {
                calendarItem.Recurrence = CreateRecurrence(rrule, owner);
            }

            return(calendarItem);
        }
        public override void Insert(RadScheduler owner, Appointment appointmentToInsert)
        {
            using (DbConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["CalendarConnectionString"].ToString()))
            {
                conn.Open();
                using (DbTransaction tran = conn.BeginTransaction())
                {
                    DbCommand cmd = new SqlCommand();
                    cmd.Connection = conn;
                    cmd.Transaction = tran;

                    PopulateAppointmentParameters(cmd, appointmentToInsert);

                    cmd.CommandText =
                        @"INSERT INTO [Appointments]
                                            ([ScheduleID], [TypeID], [Subject], [Start], [End], [UserID],
                                            [RecurrenceRule], [RecurrenceParentID])
                                    VALUES	(@ScheduleID, @TypeID, @Subject, @Start, @End, @UserID, @RecurrenceRule, @RecurrenceParentID)";

                    if (DbFactory is SqlClientFactory)
                    {
                        cmd.CommandText += Environment.NewLine + "SELECT SCOPE_IDENTITY()";
                    }
                    else
                    {
                        cmd.ExecuteNonQuery();

                        cmd.CommandText = "SELECT @@IDENTITY";
                    }
                    int identity = Convert.ToInt32(cmd.ExecuteScalar());

                    tran.Commit();
                }
            }
        }
Example #26
0
    public override IEnumerable <Appointment> GetAppointments(RadScheduler owner)
    {
        List <Appointment> appointments = new List <Appointment>();

        var events = qSoc_Event.GetEventsByType(owner.VisibleRangeStart, owner.VisibleRangeEnd, "Event");

        foreach (var e in events)
        {
            Appointment appointment = new Appointment();

            appointment.ID          = e.EventID;
            appointment.AllowDelete = false;
            appointment.AllowEdit   = false;
            appointment.Start       = e.DateTime;
            appointment.End         = e.DateTime;
            appointment.Subject     = e.Name;
            appointment.Description = "Event: " + e.Summary;
            appointment.ToolTip     = "Event: " + e.Summary;
            appointment.Resources.Add(new Resource("Calendar", 1, "Event"));

            appointments.Add(appointment);
        }

        var trainings = qSoc_Event.GetEventsByType(owner.VisibleRangeStart, owner.VisibleRangeEnd, "Training");

        foreach (var t in trainings)
        {
            Appointment appointment = new Appointment();

            appointment.ID          = t.EventID;
            appointment.AllowDelete = false;
            appointment.AllowEdit   = false;
            appointment.Start       = t.DateTime;
            appointment.End         = t.DateTime;
            appointment.Subject     = t.Name;
            appointment.Description = "Training: " + t.Summary;
            appointment.ToolTip     = "Training: " + t.Summary;
            appointment.Resources.Add(new Resource("Calendar", 2, "Training"));

            appointments.Add(appointment);
        }

        var meetings = qSoc_Event.GetEventsByType(owner.VisibleRangeStart, owner.VisibleRangeEnd, "Meeting");

        foreach (var m in meetings)
        {
            Appointment appointment = new Appointment();

            appointment.ID          = m.EventID;
            appointment.AllowDelete = false;
            appointment.AllowEdit   = false;
            appointment.Start       = m.DateTime;
            appointment.End         = m.DateTime;
            appointment.Subject     = m.Name;
            appointment.Description = "Meeting: " + m.Summary;
            appointment.ToolTip     = "Meeting: " + m.Summary;
            appointment.Resources.Add(new Resource("Calendar", 3, "Meeting"));
            appointment.Attributes.Add("Mode", "read");

            appointments.Add(appointment);
        }

        // turn off basic events, contests and tasks for St. Judes

        /*
         * var events = qSoc_Event.GetEvents(owner.VisibleRangeStart, owner.VisibleRangeEnd);
         *
         * foreach (var e in events)
         * {
         *  Appointment appointment = new Appointment();
         *
         *  appointment.ID = e.EventID;
         *  appointment.AllowDelete = false;
         *  appointment.AllowEdit = false;
         *  appointment.Start = e.DateTime;
         *  appointment.End = e.DateTime;
         *  appointment.Subject = e.Name;
         *  appointment.Description = e.Summary;
         *  appointment.ToolTip = e.Summary;
         *  appointment.Resources.Add(new Resource("Calendar", 1, "Events"));
         *  appointment.Attributes.Add("NavigateURL", string.Format("events-view.aspx?EventID={0}", e.EventID));
         *
         *  appointments.Add(appointment);
         * }
         *
         * var contests = qSoc_Contest.GetContests(owner.VisibleRangeStart, owner.VisibleRangeEnd);
         *
         * foreach (var c in contests)
         * {
         *  Appointment appointment = new Appointment();
         *
         *  appointment.ID = c.ContestID;
         *  appointment.AllowDelete = false;
         *  appointment.AllowEdit = false;
         *  appointment.Start = c.StartDateTime;
         *  appointment.End = c.EndDateTime;
         *  appointment.Subject = c.Name;
         *  appointment.Description = c.Summary;
         *  appointment.ToolTip = c.Summary;
         *  appointment.Resources.Add(new Resource("Calendar", 2, "Contests"));
         *  appointment.Attributes.Add("NavigateURL", string.Format("contests-view.aspx?ContestID={0}", c.ContestID));
         *
         *  appointments.Add(appointment);
         * }
         *
         * {
         *  var tasks = qPtl_Task.GetTasks(owner.VisibleRangeStart, owner.VisibleRangeEnd);
         *
         *  foreach (var c in tasks)
         *  {
         *      Appointment appointment = new Appointment();
         *
         *      appointment.ID = c.TaskID;
         *      appointment.AllowDelete = false;
         *      appointment.AllowEdit = false;
         *      appointment.Start = c.StartDate.GetValueOrDefault();
         *      appointment.End = c.DueDate.GetValueOrDefault();
         *      appointment.Subject = c.Name;
         *      appointment.Description = c.Description;
         *      appointment.ToolTip = c.Name;
         *      appointment.Resources.Add(new Resource("Calendar", 3, "Tasks"));
         *      appointment.Attributes.Add("NavigateURL", string.Format("tasks-view.aspx?TaskID={0}", c.TaskID));
         *
         *      appointments.Add(appointment);
         *  }
         * }
         */

        return(appointments);
    }
Example #27
0
        private void ProcessRecurringCalendarItem(Appointment targetAppointment, CalendarItemType calendarItem, RadScheduler owner, ICollection <Appointment> instances)
        {
            targetAppointment.RecurrenceState = RecurrenceState.Master;

            RecurrencePattern pattern = calendarItem.Recurrence.Item.ConvertToRecurrencePattern();

            RecurrenceRange range = calendarItem.Recurrence.Item1.ConvertToRecurrenceRange();

            range.EventDuration = targetAppointment.Duration;
            range.Start         = targetAppointment.Start;

            RecurrenceRule rrule = RecurrenceRule.FromPatternAndRange(pattern, range);

            if (calendarItem.ModifiedOccurrences != null)
            {
                foreach (CalendarItemType modifiedOccurrence in GetModifiedOccurrences(calendarItem))
                {
                    foreach (Appointment aptException in CreateAppointmentsFromCalendarItem(owner, modifiedOccurrence))
                    {
                        aptException.RecurrenceState    = RecurrenceState.Exception;
                        aptException.RecurrenceParentID = calendarItem.ItemId.Id;

                        instances.Add(aptException);
                    }

                    rrule.Exceptions.Add(modifiedOccurrence.OriginalStart);
                }
            }

            if (calendarItem.DeletedOccurrences != null)
            {
                foreach (DeletedOccurrenceInfoType occurenceInfo in calendarItem.DeletedOccurrences)
                {
                    rrule.Exceptions.Add(occurenceInfo.Start);
                }
            }

            targetAppointment.RecurrenceRule = rrule.ToString();
        }
		/// <summary>
		/// Updates the specified appointment.
		/// </summary>
		/// <param name="owner">The owner RadScheduler instance.</param>
		/// <param name="appointmentToUpdate">The appointment to update.</param>
		public override void Update(RadScheduler owner, Appointment appointmentToUpdate)
		{
			if (owner.ProviderContext is RemoveRecurrenceExceptionsContext)
			{
				RemoveRecurrenceExceptions(appointmentToUpdate);
				return;
			}
			
			if (owner.ProviderContext is UpdateAppointmentContext)
			{
				// When removing recurrences through the UI,
				// one Update operation is used to both update the appointment
				// and remove the recurrence exceptions.
				RecurrenceRule updatedRule;
				RecurrenceRule.TryParse(appointmentToUpdate.RecurrenceRule, out updatedRule);

				if (updatedRule != null && updatedRule.Exceptions.Count == 0)
				{
					RemoveRecurrenceExceptions(appointmentToUpdate);
				}
			}

			CreateRecurrenceExceptionContext createExceptionContext = owner.ProviderContext as CreateRecurrenceExceptionContext;
			if (createExceptionContext == null)
			{
				// We are not creating a recurrence exceptions - synchronize deleted occurrences.
				SynchronizeDeletedOccurrences(appointmentToUpdate);
			}

			ItemChangeType[] changes = new ItemChangeType[] { GetAppointmentChanges(appointmentToUpdate) };
			UpdateCalendarItem(changes);
		}
    public override IEnumerable<Appointment> GetAppointments(RadScheduler owner)
    {
        List<Appointment> appointments = new List<Appointment>();

        var events = qSoc_Event.GetEventsByType(owner.VisibleRangeStart, owner.VisibleRangeEnd, "Event");

        foreach (var e in events)
        {
            Appointment appointment = new Appointment();

            appointment.ID = e.EventID;
            appointment.AllowDelete = false;
            appointment.AllowEdit = false;
            appointment.Start = e.DateTime;
            appointment.End = e.DateTime;
            appointment.Subject = e.Name;
            appointment.Description = "Event: " + e.Summary;
            appointment.ToolTip = "Event: " + e.Summary;
            appointment.Resources.Add(new Resource("Calendar", 1, "Event"));

            appointments.Add(appointment);
        }

        var trainings = qSoc_Event.GetEventsByType(owner.VisibleRangeStart, owner.VisibleRangeEnd, "Training");

        foreach (var t in trainings)
        {
            Appointment appointment = new Appointment();

            appointment.ID = t.EventID;
            appointment.AllowDelete = false;
            appointment.AllowEdit = false;
            appointment.Start = t.DateTime;
            appointment.End = t.DateTime;
            appointment.Subject = t.Name;
            appointment.Description = "Training: " + t.Summary;
            appointment.ToolTip = "Training: " + t.Summary;
            appointment.Resources.Add(new Resource("Calendar", 2, "Training"));

            appointments.Add(appointment);
        }

        var meetings = qSoc_Event.GetEventsByType(owner.VisibleRangeStart, owner.VisibleRangeEnd, "Meeting");

        foreach (var m in meetings)
        {
            Appointment appointment = new Appointment();

            appointment.ID = m.EventID;
            appointment.AllowDelete = false;
            appointment.AllowEdit = false;
            appointment.Start = m.DateTime;
            appointment.End = m.DateTime;
            appointment.Subject = m.Name;
            appointment.Description = "Meeting: " + m.Summary;
            appointment.ToolTip = "Meeting: " + m.Summary;
            appointment.Resources.Add(new Resource("Calendar", 3, "Meeting"));
            appointment.Attributes.Add("Mode", "read");

            appointments.Add(appointment);
        }

        // turn off basic events, contests and tasks for St. Judes
        /*
         var events = qSoc_Event.GetEvents(owner.VisibleRangeStart, owner.VisibleRangeEnd);

        foreach (var e in events)
        {
            Appointment appointment = new Appointment();

            appointment.ID = e.EventID;
            appointment.AllowDelete = false;
            appointment.AllowEdit = false;
            appointment.Start = e.DateTime;
            appointment.End = e.DateTime;
            appointment.Subject = e.Name;
            appointment.Description = e.Summary;
            appointment.ToolTip = e.Summary;
            appointment.Resources.Add(new Resource("Calendar", 1, "Events"));
            appointment.Attributes.Add("NavigateURL", string.Format("events-view.aspx?EventID={0}", e.EventID));

            appointments.Add(appointment);
        }
         *
        var contests = qSoc_Contest.GetContests(owner.VisibleRangeStart, owner.VisibleRangeEnd);

        foreach (var c in contests)
        {
            Appointment appointment = new Appointment();

            appointment.ID = c.ContestID;
            appointment.AllowDelete = false;
            appointment.AllowEdit = false;
            appointment.Start = c.StartDateTime;
            appointment.End = c.EndDateTime;
            appointment.Subject = c.Name;
            appointment.Description = c.Summary;
            appointment.ToolTip = c.Summary;
            appointment.Resources.Add(new Resource("Calendar", 2, "Contests"));
            appointment.Attributes.Add("NavigateURL", string.Format("contests-view.aspx?ContestID={0}", c.ContestID));

            appointments.Add(appointment);
        }

        {
            var tasks = qPtl_Task.GetTasks(owner.VisibleRangeStart, owner.VisibleRangeEnd);

            foreach (var c in tasks)
            {
                Appointment appointment = new Appointment();

                appointment.ID = c.TaskID;
                appointment.AllowDelete = false;
                appointment.AllowEdit = false;
                appointment.Start = c.StartDate.GetValueOrDefault();
                appointment.End = c.DueDate.GetValueOrDefault();
                appointment.Subject = c.Name;
                appointment.Description = c.Description;
                appointment.ToolTip = c.Name;
                appointment.Resources.Add(new Resource("Calendar", 3, "Tasks"));
                appointment.Attributes.Add("NavigateURL", string.Format("tasks-view.aspx?TaskID={0}", c.TaskID));

                appointments.Add(appointment);
            }
        }
        */

        return appointments;
    }
        private IEnumerable<Appointment> GetAppointments(RadScheduler owner, string sharedCalendarName, ItemIdType[] itemIdsArray)
		{
			IList<CalendarItemType> calendarItems = GetCalendarItems(itemIdsArray);
			List<Appointment> appointments = new List<Appointment>(calendarItems.Count);
			foreach (CalendarItemType item in calendarItems)
			{
                appointments.AddRange(CreateAppointmentsFromCalendarItem(owner, sharedCalendarName, item));
			}

			return appointments;
		}
		private static RecurrenceType CreateRecurrence(RecurrenceRule schedulerRule, RadScheduler owner)
		{
			RecurrenceType recurrence = new RecurrenceType();
			recurrence.Item = RecurrencePatternBaseType.CreateFromSchedulerRecurrencePattern(schedulerRule.Pattern);
			recurrence.Item1 = RecurrenceRangeBaseType.CreateFromSchedulerRecurrenceRule(schedulerRule, owner);

			return recurrence;
		}
		public static RecurrenceRangeBaseType CreateFromSchedulerRecurrenceRule(RecurrenceRule schedulerRule, RadScheduler owner)
		{
			RecurrenceRange schedulerRange = schedulerRule.Range;

			DateTime start = schedulerRange.Start;

			//DateTime start = owner.UtcDayStart(schedulerRange.Start);
			if (schedulerRule.Pattern.Frequency == RecurrenceFrequency.Monthly ||
				schedulerRule.Pattern.Frequency == RecurrenceFrequency.Yearly)
			{
				DateTime monthStart = new DateTime(schedulerRange.Start.Year, schedulerRange.Start.Month, 1, 0, 0, 0, DateTimeKind.Utc);
				start = monthStart;
			}

			if (schedulerRange.RecursUntil < DateTime.MaxValue)
			{
				EndDateRecurrenceRangeType range = new EndDateRecurrenceRangeType();
				range.StartDate = start;
				range.EndDate = schedulerRange.RecursUntil.AddDays(-1);
				return range;
			}

			if (schedulerRange.MaxOccurrences < int.MaxValue)
			{
				NumberedRecurrenceRangeType range = new NumberedRecurrenceRangeType();
				range.StartDate = start;
				range.NumberOfOccurrences = schedulerRange.MaxOccurrences;
				return range;
			}

			NoEndRecurrenceRangeType noEndRange = new NoEndRecurrenceRangeType();
			noEndRange.StartDate = start;

			return noEndRange;
		}
		private void InsertRecurrenceException(RadScheduler owner, Appointment appointmentToInsert, DateTime exceptionDate)
		{
			Appointment master = owner.Appointments.FindByID(appointmentToInsert.RecurrenceParentID);
			int occurrenceIndex = GetOccurrenceIndex(exceptionDate, master);
			CalendarItemType occurrenceItem = GetOccurrenceItem(master, occurrenceIndex);
			occurrenceItem.MeetingTimeZone = GetTimeZone(appointmentToInsert.Owner.TimeZoneOffset);

			// Update the occurrence
			ItemChangeType itemUpdates = GetAppointmentChanges(appointmentToInsert) ;
			itemUpdates.Item = occurrenceItem.ItemId;
			ItemChangeType[] changes = new ItemChangeType[] { itemUpdates };

			UpdateCalendarItem(changes);
		}
		private void ProcessRecurringCalendarItem(Appointment targetAppointment, CalendarItemType calendarItem, RadScheduler owner, ICollection<Appointment> instances)
		{
			targetAppointment.RecurrenceState = RecurrenceState.Master;

			RecurrencePattern pattern = calendarItem.Recurrence.Item.ConvertToRecurrencePattern();

			RecurrenceRange range = calendarItem.Recurrence.Item1.ConvertToRecurrenceRange();
			range.EventDuration = targetAppointment.Duration;
			range.Start = targetAppointment.Start;

			RecurrenceRule rrule = RecurrenceRule.FromPatternAndRange(pattern, range);

			if (calendarItem.ModifiedOccurrences != null)
			{
				foreach (CalendarItemType modifiedOccurrence in GetModifiedOccurrences(calendarItem))
				{
					foreach (Appointment aptException in CreateAppointmentsFromCalendarItem(owner, modifiedOccurrence))
					{
						aptException.RecurrenceState = RecurrenceState.Exception;
						aptException.RecurrenceParentID = calendarItem.ItemId.Id;

						instances.Add(aptException);
					}

					rrule.Exceptions.Add(modifiedOccurrence.OriginalStart);
				}
			}

			if (calendarItem.DeletedOccurrences != null)
			{
				foreach (DeletedOccurrenceInfoType occurenceInfo in calendarItem.DeletedOccurrences)
				{
					rrule.Exceptions.Add(occurenceInfo.Start);
				}
			}

			targetAppointment.RecurrenceRule = rrule.ToString();
		}
 public override IEnumerable<Resource> GetResourcesByType(RadScheduler owner, string resourceType)
 {
     throw new NotImplementedException();
 }
 public override void Insert(RadScheduler owner, Appointment appointmentToInsert)
 {
     throw new NotImplementedException();
 }
Example #37
0
        protected virtual IEnumerable <Appointment> CreateAppointmentsFromCalendarItem(RadScheduler owner, string sharedCalendarName, CalendarItemType calendarItem)
        {
            Appointment calendarAppointment = new Appointment();

            calendarAppointment.ID      = calendarItem.ItemId.Id;
            calendarAppointment.Subject = calendarItem.Subject;
            calendarAppointment.Start   = calendarItem.Start;
            calendarAppointment.End     = calendarItem.End;
            calendarAppointment.Owner   = owner;

            calendarAppointment.Attributes[ExchangeIdAttribute]        = calendarItem.ItemId.Id;
            calendarAppointment.Attributes[ExchangeChangeKeyAttribute] = calendarItem.ItemId.ChangeKey;


            //Get any additional data to display.
            calendarAppointment.Attributes["Location"]  = calendarItem.Location;
            calendarAppointment.Attributes["Organizer"] = calendarItem.Organizer.Item.Name;

            //Create a ToolTip similar to the one in Outlook.
            const string hourFormat = "%h:mmtt";


            string tooltip;

            if (!String.IsNullOrEmpty(calendarItem.Location))
            {
                tooltip = String.Format("{0}-{1} {2}\n({3})",
                                        calendarItem.Start.ToString(hourFormat).ToLower(),
                                        calendarItem.End.ToString(hourFormat).ToLower(),
                                        calendarItem.Subject,
                                        calendarItem.Location);
            }
            else
            {
                tooltip = String.Format("{0}-{1} {2}",
                                        calendarItem.Start.ToString(hourFormat).ToLower(),
                                        calendarItem.End.ToString(hourFormat).ToLower(),
                                        calendarItem.Subject);
            }


            calendarAppointment.ToolTip = tooltip;

            if (sharedCalendarName != null)
            {
                calendarAppointment.Resources.Add(owner.Resources.GetResource("SharedCalendar", sharedCalendarName));
            }


            List <Appointment> instances = new List <Appointment>();

            instances.Add(calendarAppointment);

            if (calendarItem.Recurrence != null)
            {
                ProcessRecurringCalendarItem(calendarAppointment, calendarItem, owner, instances);
            }

            return(instances);
        }
		protected virtual IEnumerable<Appointment> CreateAppointmentsFromCalendarItem(RadScheduler owner, string sharedCalendarName, CalendarItemType calendarItem)
		{
			Appointment calendarAppointment = new Appointment();
			calendarAppointment.ID = calendarItem.ItemId.Id;
			calendarAppointment.Subject = calendarItem.Subject;
			calendarAppointment.Start = calendarItem.Start;
			calendarAppointment.End = calendarItem.End;
			calendarAppointment.Owner = owner;

			calendarAppointment.Attributes[ExchangeIdAttribute] = calendarItem.ItemId.Id;
			calendarAppointment.Attributes[ExchangeChangeKeyAttribute] = calendarItem.ItemId.ChangeKey;


            //Get any additional data to display.
            calendarAppointment.Attributes["Location"] = calendarItem.Location;
            calendarAppointment.Attributes["Organizer"] = calendarItem.Organizer.Item.Name;

            //Create a ToolTip similar to the one in Outlook.
		    const string hourFormat = "%h:mmtt";


            string tooltip;
            if (!String.IsNullOrEmpty(calendarItem.Location))
            {
                tooltip = String.Format("{0}-{1} {2}\n({3})",
                calendarItem.Start.ToString(hourFormat).ToLower(),
                calendarItem.End.ToString(hourFormat).ToLower(),
                calendarItem.Subject,
                calendarItem.Location);
            }
            else
            {
                tooltip = String.Format("{0}-{1} {2}",
                calendarItem.Start.ToString(hourFormat).ToLower(),
                calendarItem.End.ToString(hourFormat).ToLower(),
                calendarItem.Subject);
            }
           

		    calendarAppointment.ToolTip = tooltip;

            if (sharedCalendarName != null)
            {
                calendarAppointment.Resources.Add(owner.Resources.GetResource("SharedCalendar", sharedCalendarName));
            }


		    List<Appointment> instances = new List<Appointment>();
			instances.Add(calendarAppointment);

			if (calendarItem.Recurrence != null)
			{
				ProcessRecurringCalendarItem(calendarAppointment, calendarItem, owner, instances);
			}

			return instances;
		}
 public override void Delete(RadScheduler owner, Appointment appointmentToDelete)
 {
     throw new NotImplementedException();
 }
Example #40
0
 protected virtual IEnumerable <Appointment> CreateAppointmentsFromCalendarItem(RadScheduler owner, CalendarItemType calendarItem)
 {
     return(CreateAppointmentsFromCalendarItem(owner, null, calendarItem));
 }
 public override IEnumerable <Resource> GetResourcesByType(RadScheduler owner, string resourceType)
 {
     return(null);
 }
		/// <summary>
		/// Deletes the specified appointment.
		/// </summary>
		/// <param name="owner">The owner RadScheduler instance.</param>
		/// <param name="appointmentToDelete">The appointment to delete.</param>
		public override void Delete(RadScheduler owner, Appointment appointmentToDelete)
		{
			if (owner.ProviderContext is RemoveRecurrenceExceptionsContext)
			{
				return;
			}

			ItemIdType itemId = new ItemIdType();
			itemId.Id = appointmentToDelete.Attributes[ExchangeIdAttribute];
			itemId.ChangeKey = appointmentToDelete.Attributes[ExchangeChangeKeyAttribute];

			DeleteItem(itemId);
		}
 public override IEnumerable <ResourceType> GetResourceTypes(RadScheduler owner)
 {
     return(null);
 }
		/// <summary>
		/// Inserts the specified appointment.
		/// </summary>
		/// <param name="owner">The owner RadScheduler instance.</param>
		/// <param name="appointmentToInsert">The appointment to insert.</param>
		public override void Insert(RadScheduler owner, Appointment appointmentToInsert)
		{
			CreateRecurrenceExceptionContext createExceptionContext = owner.ProviderContext as CreateRecurrenceExceptionContext;
			if (createExceptionContext != null)
			{
				Debug.Assert(appointmentToInsert.RecurrenceState == RecurrenceState.Exception);
				InsertRecurrenceException(owner, appointmentToInsert, createExceptionContext.RecurrenceExceptionDate);
				return;
			}

          
			CalendarItemType calendarItem = CreateCalendarItem(owner, appointmentToInsert);
     
			CreateItemType createItemRequest = new CreateItemType();

            DistinguishedFolderIdType destFolder = new DistinguishedFolderIdType();
            destFolder.Id = DistinguishedFolderIdNameType.calendar;

            EmailAddressType emailAddressType = new EmailAddressType();
            emailAddressType.EmailAddress = this.CalendarNames;

            destFolder.Mailbox = emailAddressType;

            createItemRequest.SavedItemFolderId = new TargetFolderIdType();
            createItemRequest.SavedItemFolderId.Item = destFolder;

            
			createItemRequest.SendMeetingInvitations = CalendarItemCreateOrDeleteOperationType.SendToNone;
			createItemRequest.SendMeetingInvitationsSpecified = true;
			createItemRequest.Items = new NonEmptyArrayOfAllItemsType();
			createItemRequest.Items.Items = new CalendarItemType[] { calendarItem };
           
			CreateItemResponseType response = Service.CreateItem(createItemRequest);
			ResponseMessageType responseMessage = response.ResponseMessages.Items[0];

			if (responseMessage.ResponseCode != ResponseCodeType.NoError)
			{
				throw new Exception("CreateItem failed with response code " + responseMessage.ResponseCode);
			}
		}
 protected virtual IEnumerable<Appointment> CreateAppointmentsFromCalendarItem(RadScheduler owner, CalendarItemType calendarItem)
 {
     return CreateAppointmentsFromCalendarItem(owner, null, calendarItem);
 }
		/// <summary>
		/// Reads the appointments from the Exchange server.
		/// </summary>
		/// <param name="owner">The owner RadScheduler instance.</param>
		/// <returns></returns>
		public override IEnumerable<Appointment> GetAppointments(RadScheduler owner)
		{
            List<Appointment> appointments = new List<Appointment>();

		    foreach (Resource resource in owner.Resources)
		    {
                string sharedCalendarName = this.CalendarNames;// resource.Text;

                // Identify which folders to search.
                DistinguishedFolderIdType distinguishedFolderIdType = new DistinguishedFolderIdType();
                distinguishedFolderIdType.Id = DistinguishedFolderIdNameType.calendar;
               

                EmailAddressType emailAddressType = new EmailAddressType();
                emailAddressType.EmailAddress = sharedCalendarName;

                distinguishedFolderIdType.Mailbox = emailAddressType;

                List<ItemIdType> itemIds = new List<ItemIdType>();

                foreach (CalendarItemType item in FindCalendarItems(new DistinguishedFolderIdType[] { distinguishedFolderIdType }))
                {
                    if ((item.Start < owner.VisibleRangeEnd && item.End > owner.VisibleRangeStart) ||
                        item.CalendarItemType1 == CalendarItemTypeType.RecurringMaster)
                    {
                        itemIds.Add(item.ItemId);
                    }
                }

                appointments.AddRange(GetAppointments(owner, sharedCalendarName, itemIds.ToArray()));
		    }

            return appointments;
		}
        protected virtual CalendarItemType CreateCalendarItem(RadScheduler owner, Appointment apt)
        {
            CalendarItemType calendarItem = new CalendarItemType();
            calendarItem.Subject = apt.Subject;
            calendarItem.Start = apt.Start;
            calendarItem.StartSpecified = true;
            calendarItem.End = apt.End;
            calendarItem.EndSpecified = true;
         
            calendarItem.MeetingTimeZone = GetTimeZone(owner.TimeZoneOffset);

            RecurrenceRule rrule;
            RecurrenceRule.TryParse(apt.RecurrenceRule, out rrule);
            if (rrule != null && rrule.Pattern.Frequency != RecurrenceFrequency.Hourly)
            {
                calendarItem.Recurrence = CreateRecurrence(rrule, owner);
            }

            return calendarItem;
        }
Example #48
0
 public override void Update(RadScheduler owner, Appointment appointmentToUpdate)
 {
     throw new NotImplementedException();
 }
		/// <summary>
		/// Implement this method if you use custom resources.
		/// </summary>
        public override IEnumerable<Resource> GetResourcesByType(RadScheduler owner, string resourceType)
        {
            
            string[] sharedCalendarNames = CalendarNames.Split(new char[] { ',' });
            

            List<Resource> resources = new List<Resource>(sharedCalendarNames.Length);

            for (int ix = 0; ix < sharedCalendarNames.Length; ix++)
            {
                Resource sharedCalendar = new Resource();
                sharedCalendar.Type = "SharedCalendar";
                sharedCalendar.Key = sharedCalendarNames[ix];
                sharedCalendar.Text = sharedCalendarNames[ix];
                sharedCalendar.CssClass = "res" + sharedCalendarNames[ix];

                resources.Add(sharedCalendar);
            }

            return resources.ToArray();
        }
        public override void Update(RadScheduler owner, Appointment appointmentToUpdate)
        {
            using (DbConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["CalendarConnectionString"].ToString()))
            {
                conn.Open();
                using (DbTransaction tran = conn.BeginTransaction())
                {
                    DbCommand cmd = new SqlCommand();
                    cmd.Connection = conn;
                    cmd.Transaction = tran;

                    PopulateAppointmentParameters(cmd, appointmentToUpdate);

                    cmd.CommandText =
                        @"UPDATE [Appointments]
                                            set [ScheduleID]=@ScheduleID, [TypeID]=@TypeID,
                                            [Subject]=@Subject, [Start]=@Start,
                                            [End]=@End, [UserID]=@UserID,
                                            [RecurrenceRule]=@RecurrenceRule, [RecurrenceParentID] = @RecurrenceParentID
                         WHERE ID=@ID";

                    cmd.ExecuteNonQuery();
                    tran.Commit();
                }
            }
        }
		/// <summary>
		/// Implement this method if you use custom resources.
		/// </summary>
		public override IEnumerable<ResourceType> GetResourceTypes(RadScheduler owner)
		{
			return new ResourceType[] { new ResourceType("SharedCalendar") };
		}
Example #52
0
 public override void Insert(RadScheduler owner, Appointment appointmentToInsert)
 {
     throw new NotImplementedException();
 }
Example #53
0
 /// <summary>
 /// Implement this method if you use custom resources.
 /// </summary>
 public override IEnumerable <ResourceType> GetResourceTypes(RadScheduler owner)
 {
     return(new ResourceType[] { new ResourceType("SharedCalendar") });
 }
    public override IEnumerable<Resource> GetResourcesByType(RadScheduler owner, string resourceType)
    {
        switch (resourceType)
        {
            case "Teacher":
                return Teachers.Values;

            case "Student":
                return Students.Values;

            default:
                throw new InvalidOperationException("Unknown resource type: " + resourceType);
        }
    }
 public override IEnumerable<ResourceType> GetResourceTypes(RadScheduler owner)
 {
     //throw new NotImplementedException();
     return new List<ResourceType>();
 }
Example #56
0
        public static RecurrenceRangeBaseType CreateFromSchedulerRecurrenceRule(RecurrenceRule schedulerRule, RadScheduler owner)
        {
            RecurrenceRange schedulerRange = schedulerRule.Range;

            DateTime start = schedulerRange.Start;

            //DateTime start = owner.UtcDayStart(schedulerRange.Start);
            if (schedulerRule.Pattern.Frequency == RecurrenceFrequency.Monthly ||
                schedulerRule.Pattern.Frequency == RecurrenceFrequency.Yearly)
            {
                DateTime monthStart = new DateTime(schedulerRange.Start.Year, schedulerRange.Start.Month, 1, 0, 0, 0, DateTimeKind.Utc);
                start = monthStart;
            }

            if (schedulerRange.RecursUntil < DateTime.MaxValue)
            {
                EndDateRecurrenceRangeType range = new EndDateRecurrenceRangeType();
                range.StartDate = start;
                range.EndDate   = schedulerRange.RecursUntil.AddDays(-1);
                return(range);
            }

            if (schedulerRange.MaxOccurrences < int.MaxValue)
            {
                NumberedRecurrenceRangeType range = new NumberedRecurrenceRangeType();
                range.StartDate           = start;
                range.NumberOfOccurrences = schedulerRange.MaxOccurrences;
                return(range);
            }

            NoEndRecurrenceRangeType noEndRange = new NoEndRecurrenceRangeType();

            noEndRange.StartDate = start;

            return(noEndRange);
        }
    public override IEnumerable<ResourceType> GetResourceTypes(RadScheduler owner)
    {
        ResourceType[] resourceTypes = new ResourceType[2];
        resourceTypes[0] = new ResourceType("Teacher", false);
        resourceTypes[1] = new ResourceType("Student", true);

        return resourceTypes;
    }