Ejemplo n.º 1
0
        private void Scheduler_DataBound(object sender, EventArgs e)
        {
            ASPxSchedulerListEditor listEditor = (ASPxSchedulerListEditor)this.View.Editor;
            ASPxScheduler           scheduler  = listEditor.SchedulerControl;

            if (this._schedulerViewType != SchedulerViewType.Agenda)
            {
                List <object> value = IEventControllerResourceManager.Resources.Value;

                if (value.Count == 0 && scheduler.Storage.Resources.Items.Count >= 1)
                {
                    WorkflowResource workflowResource = this.CurrentObjectSpace.GetObjects <WorkflowResource>(CriteriaOperator.Parse("ObjectOid == ?", SecuritySystem.CurrentUserId.ToString())).FirstOrDefault();

                    for (int i = 0; i < scheduler.Storage.Resources.Items.Count; i++)
                    {
                        DevExpress.XtraScheduler.Resource res = scheduler.Storage.Resources.Items[i];

                        if (res.Caption.Contains(workflowResource.Description))
                        {
                            value.Add(res.Id);
                            break;
                        }
                    }
                }

                scheduler.SetVisibleResources(value);
            }
        }
Ejemplo n.º 2
0
        private void schedulerStorage1_AppointmentsInserted(object sender, DevExpress.XtraScheduler.PersistentObjectsEventArgs e)
        {
            //gets the newly created Devexpress appointment;
            DevExpress.XtraScheduler.Appointment app = e.Objects[0] as DevExpress.XtraScheduler.Appointment;


            //*********************************************************
            //questo codice è inserito per risolvere il problema dell'assegnazione della risorsa
            //dopo il grag drop
            DevExpress.XtraScheduler.Resource ee = app.ResourceId as DevExpress.XtraScheduler.Resource;
            //questa situazione si verifica quando lo scheduler non è stato in grado
            //di assegnare una risorsa all'appuntamento creato nella funzione GetDragData
            //e pertanto assegna la risorsa "All" all'appuntamento
            if (ee != null)
            {
                Customer ccc = app.GetValue(schedulerStorage1, "Customer") as Customer;
                if (ccc != null)
                {
                    app.SetValue(schedulerStorage1, "Resource", ccc.Resource);
                    app.ResourceId = ccc.Resource.Id;
                }
                else
                {
                    WIN.SCHEDULING_APPLICATION.DOMAIN.ComboElements.Resource t = new ResourceHandler().GetAll()[0] as WIN.SCHEDULING_APPLICATION.DOMAIN.ComboElements.Resource;
                    app.SetValue(schedulerStorage1, "Resource", t);
                    app.ResourceId = t.Id;
                }
            }
            else
            {
                app.SetValue(schedulerStorage1, "Resource", new ResourceHandler().GetElementById(app.ResourceId.ToString()) as WIN.SCHEDULING_APPLICATION.DOMAIN.ComboElements.Resource);
            }
            //****************************************************************++



            //imposto per sicurezza il campo allday a false;
            app.AllDay = false;

            ////i get my custom object
            MyAppointment a = app.GetSourceObject(schedulerStorage1) as MyAppointment;



            ////i save on my db
            AppointmentHandler h = new AppointmentHandler();

            try
            {
                h.SaveOrUpdate(a);
            }
            catch (Exception ex)
            {
                WIN.SCHEDULING_APP.GUI.Utility.ErrorHandler.Show(ex);

                return;
            }


            //notifico l'id all'oggetto appena creato
            Key newId = a.Key;

            app.SetValue(schedulerStorage1, "Key", newId);


            //Appointment app1 = app.Copy();
            //app1.Start = DateTime.Now.AddHours(2);

            //schedulerStorage1.Appointments.Add(app1);

            //foreach (Appointment item in schedulerStorage1 .Appointments.Items  )
            //{
            //    MyAppointment a1 = app.GetSourceObject(schedulerStorage1) as MyAppointment;

            //}
        }