Example #1
0
        void Scheduler_AppointmentCreating(object sender, AppointmentCreatingEventArgs e)
        {
            if (WebContext.Current.User.IsAuthenticated)
            {
                var app = new Appointment();
                app.CopyFrom(e.Appointment);
                e.Cancel = true;
                domainContext.Load<UserTeam>(domainContext.GetTeamByNameQuery(WebContext.Current.User.Name)).Completed += (s, a) =>
                    {
                        domainContext.Load<MeetingScheduler.Web.Resource>(domainContext.GeResourceByIDQuery(domainContext.UserTeams.ElementAt(0).Team)).Completed += (sen, args) =>
                            {

                                LoadOperation loadOp = sen as LoadOperation;
                                var res = loadOp.Entities.ElementAt(0) as MeetingScheduler.Web.Resource;

                                Telerik.Windows.Controls.Resource resource = new Telerik.Windows.Controls.Resource();
                                resource.ResourceName = res.Name;
                                resource.DisplayName = res.DisplayName;
                                resource.ResourceType = res.ResourceTypes.Name;
                                app.Resources.Add(resource);

                                resource = new Telerik.Windows.Controls.Resource();
                                resource.ResourceName = (SelectResource.SelectedValue as RadComboBoxItem).Content.ToString();
                                resource.DisplayName = (SelectResource.SelectedValue as RadComboBoxItem).Content.ToString();
                                resource.ResourceType = "Room";

                                app.Resources.Add(resource);
                                app.TimeMarker = new TimeMarker();

                                Scheduler_AppointmentCreated(app);

                                RadScheduleViewCommands.EditAppointment.Execute(app, Scheduler);
                            };
                    };
            }
            else
            {
                e.Cancel = true;
                MessageBox.Show("PLease login and try again");
            }
        }
Example #2
0
        private void LoadAppointments(string selectResource)
        {
            var tempApps = new ObservableCollection<Appointment>();

            var appointmentsLoadOperation = this.domainContext.Load<SqlAppointment>(this.domainContext.GetSqlAppointmentsQuery());
            appointmentsLoadOperation.Completed += (s, a) =>
            {
                foreach (SqlAppointment sqlAppointment in this.domainContext.SqlAppointments)
                {
                    if (sqlAppointment.AppointmentResources.Count(k => k.Resource.DisplayName == selectResource) == 0)
                        continue;
                    Appointment newApp = new Appointment();
                    newApp.Start = sqlAppointment.Start;
                    newApp.End = sqlAppointment.End;
                    newApp.Subject = sqlAppointment.Subject;
                    newApp.Body = sqlAppointment.Body;
                    newApp.IsAllDayEvent = sqlAppointment.IsAllDayEvent;
                    newApp.Location = sqlAppointment.Location;
                    newApp.Url = sqlAppointment.Url;
                    newApp.UniqueId = sqlAppointment.Id.ToString();

                    newApp.Category = new Category(sqlAppointment.Category, null);
                    newApp.TimeMarker = new TimeMarker(sqlAppointment.TimeMarker, null);
                    newApp.Importance = ImportanceHelper.CreateImportanceFromString(sqlAppointment.Importance);

                    foreach (var appointmentResource in sqlAppointment.AppointmentResources.ToList())
                    {
                        Telerik.Windows.Controls.Resource resource = new Telerik.Windows.Controls.Resource();
                        resource.ResourceName = appointmentResource.Resource.Name;
                        resource.DisplayName = appointmentResource.Resource.DisplayName;
                        resource.ResourceType = appointmentResource.Resource.ResourceTypes.Name;

                        if (appointmentResource.Resource.ResourceTypes.Name == "Team")
                            newApp.Category = CategoryHelper.MakeCategory(appointmentResource.Resource.Color);

                        newApp.Resources.Add(resource);
                    }

                    var pattern = new RecurrencePattern();
                    if (RecurrencePatternHelper.TryParseRecurrencePattern(sqlAppointment.RecurrencePattern, out pattern))
                    {
                        newApp.RecurrenceRule = new RecurrenceRule(pattern);
                        foreach (var exception in sqlAppointment.SqlAppointments1)
                        {
                            if (exception.Type == (int)AppointmentType.ExceptionDate)
                            {
                                newApp.RecurrenceRule.AddException(exception.ExceptionDate.Value);
                            }
                            else
                            {
                                var exceptionAppointment = new Appointment()
                                {
                                    Start = exception.Start,
                                    End = exception.End,
                                    Subject = exception.Subject,
                                    Body = exception.Body,
                                    IsAllDayEvent = exception.IsAllDayEvent,
                                    UniqueId = exception.Id.ToString(),
                                    Importance = ImportanceHelper.CreateImportanceFromString(exception.Importance),
                                    TimeMarker = new TimeMarker(exception.TimeMarker, null),
                                    Category =  new Category(exception.Category, null)
                                };
                                newApp.RecurrenceRule.AddException(exception.ExceptionDate.Value, exceptionAppointment);
                            }
                        }
                    }

                    tempApps.Add(newApp);
                };
                this.Scheduler.AppointmentsSource = tempApps;
            };
        }
Example #3
0
        private void LoadResources()
        {
            try
            {
                SelectResource.Items.Clear();
            }
            catch
            {
                ;
            }
            var loadResourcesOperation = this.domainContext.Load<MeetingScheduler.Web.Resource>(this.domainContext.GetResourceQuery());
            loadResourcesOperation.Completed += (sender, args) =>
            {
                var typesSource = new ObservableCollection<Telerik.Windows.Controls.ResourceType>();
                this.Scheduler.ResourceTypesSource = null;
                foreach (MeetingScheduler.Web.ResourceType dbResourceType in domainContext.ResourceTypes)
                {
                    Telerik.Windows.Controls.ResourceType resourceType = new Telerik.Windows.Controls.ResourceType();
                    resourceType.DisplayName = dbResourceType.DisplayName;
                    resourceType.Name = dbResourceType.Name;
                    resourceType.AllowMultipleSelection = dbResourceType.AllowMultipleSelection.Value;

                    foreach (MeetingScheduler.Web.Resource dbResource in dbResourceType.Resource)
                    {
                        Telerik.Windows.Controls.Resource resource = new Telerik.Windows.Controls.Resource();
                        resource.DisplayName = dbResource.DisplayName;
                        resource.ResourceName = dbResource.Name;
                        resourceType.Resources.Add(resource);
                        if (resourceType.DisplayName == "Room")
                        {
                            var item = new RadComboBoxItem();
                            item.Content = dbResource.DisplayName;
                            SelectResource.Items.Add(item);
                        }
                    }
                    if (resourceType.Name == "Room")
                        continue;
                    typesSource.Add(resourceType);
                }
                if (this.SelectResource.Items.Count > 0)
                    this.SelectResource.SelectedIndex = 0;
                this.Scheduler.ResourceTypesSource = typesSource;
            };
        }