Ejemplo n.º 1
0
        private void AddRecipientByRankGroupAction_Execute(object sender, PopupWindowShowActionExecuteEventArgs e)
        {
            Announcement currentAnnouncement = (Announcement)View.CurrentObject;

            View.ObjectSpace.SetModified(currentAnnouncement);
            foreach (RankGroup selected in e.PopupWindow.View.SelectedObjects)
            {
                ICollection tempEmployee;
                DevExpress.Xpo.Metadata.XPClassInfo        employeeClass;
                DevExpress.Data.Filtering.CriteriaOperator criteria;
                DevExpress.Xpo.SortingCollection           sortProps;
                DevExpress.Xpo.Session session;
                DevExpress.Xpo.Generators.CollectionCriteriaPatcher patcher;

                session = currentAnnouncement.Session;
                //session.ConnectionString = XpoDefault.ConnectionString;

                // Obtain the persistent object class info required by the GetObjects method
                employeeClass = session.GetClassInfo(typeof(Employee));
                // Create criteria to get objects
                criteria = CriteriaOperator.Parse("StructuralPosition.RankGroup.Oid = ? And IsActive = true", selected.Oid);
                // Create a sort list if objects must be processed in a specific order
                sortProps = new SortingCollection(null);
                sortProps.Add(new SortProperty("FirstName", DevExpress.Xpo.DB.SortingDirection.Ascending));

                // Create criteria patcher to filter out the objects marked as "deleted"
                // and to support loading of inherited objects of a given base persistent class
                patcher = new DevExpress.Xpo.Generators.CollectionCriteriaPatcher(false, session.TypesManager);

                // Call GetObjects


                //tempEmployee = session.GetObjects(employeeClass, criteria, sortProps, 0, patcher, selectDeleted:false, force: false);
                tempEmployee = session.GetObjects(employeeClass, criteria, sortProps, 0, 0, false, true);

                foreach (Employee emp in tempEmployee)
                {
                    if (emp.IsActive == true)
                    {
                        Employee nEmp = ObjectSpace.GetObjectByKey <Employee>(emp.Oid);
                        AnnouncementRecepients nRec = new AnnouncementRecepients(currentAnnouncement.Session);
                        nRec.Employee = nEmp;
                        nRec.Email    = nEmp.CorporateEmail;
                        currentAnnouncement.AnnouncementRecepients.Add(nRec);
                    }
                }
            }
            if (View is DetailView && ((DetailView)View).ViewEditMode == ViewEditMode.View)
            {
                View.ObjectSpace.CommitChanges();
            }
        }
Ejemplo n.º 2
0
        private void AddRecipientAction_Execute(object sender, PopupWindowShowActionExecuteEventArgs e)
        {
            //Schedule currentSchedule = (Schedule)View.CurrentObject;
            Announcement currentAnnouncement = (Announcement)View.CurrentObject;

            View.ObjectSpace.SetModified(currentAnnouncement);

            foreach (Employee emp in e.PopupWindow.View.SelectedObjects)
            {
                Employee nEmp = ObjectSpace.GetObjectByKey <Employee>(emp.Oid);
                AnnouncementRecepients nRec = new AnnouncementRecepients(currentAnnouncement.Session);
                nRec.Employee = nEmp;
                nRec.Email    = nEmp.CorporateEmail;
                currentAnnouncement.AnnouncementRecepients.Add(nRec);
            }

            if (View is DetailView && ((DetailView)View).ViewEditMode == ViewEditMode.View)
            {
                View.ObjectSpace.CommitChanges();
            }
        }
Ejemplo n.º 3
0
        private void AddRecepientAllAction_Execute(object sender, SimpleActionExecuteEventArgs e)
        {
            Announcement currentAnnouncement = (Announcement)View.CurrentObject;

            View.ObjectSpace.SetModified(currentAnnouncement);

            ICollection employees;

            DevExpress.Xpo.Metadata.XPClassInfo        employeeClass;
            DevExpress.Data.Filtering.CriteriaOperator criteria;
            DevExpress.Xpo.SortingCollection           sortProps;
            DevExpress.Xpo.Session session;
            DevExpress.Xpo.Generators.CollectionCriteriaPatcher patcher;

            session       = currentAnnouncement.Session;
            employeeClass = session.GetClassInfo(typeof(Employee));
            criteria      = CriteriaOperator.Parse("IsActive = true");
            sortProps     = new SortingCollection(null);
            sortProps.Add(new SortProperty("FullName", DevExpress.Xpo.DB.SortingDirection.Ascending));
            patcher   = new DevExpress.Xpo.Generators.CollectionCriteriaPatcher(false, session.TypesManager);
            employees = session.GetObjects(employeeClass, criteria, sortProps, 0, false, false);
            foreach (Employee employee in employees)
            {
                if (employee.IsActive == true)
                {
                    AnnouncementRecepients nRec = new AnnouncementRecepients(currentAnnouncement.Session);
                    nRec.Employee = employee;
                    nRec.Email    = employee.CorporateEmail;
                    currentAnnouncement.AnnouncementRecepients.Add(nRec);
                }
            }

            if (View is DetailView && ((DetailView)View).ViewEditMode == ViewEditMode.View)
            {
                View.ObjectSpace.CommitChanges();
            }
        }