/// <summary>
        /// Calls to update Person in database
        /// </summary>
        /// <param name="person"></param>
        public void UpdatePerson(CACCCheckInDb.Person person)
        {
            try
            {
                using (CACCCheckInServiceProxy proxy =
                           new CACCCheckInServiceProxy())
                {
                    proxy.Open();

                    logger.Debug("Calling UpdatePeople on CACCCheckInService.");

                    proxy.UpdatePeople(person);
                }
            }
            catch (Exception ex)
            {
                Debug.Assert(View != null);
                View.ViewDispatcher.BeginInvoke(DispatcherPriority.DataBind,
                                                new DispatcherOperationCallback(
                                                    delegate(object arg)
                {
                    View.DisplayExceptionDetail(ex);
                    return(null);
                }), null);
            }
        }
Пример #2
0
        private void GetDataForTeacherListFromService(string departmentName, string className)
        {
            List <CACCCheckInDb.PeopleWithDepartmentAndClassView> people = null;

            logger.Debug("Retrieving GetPeopleWithDepartmentAndClassByDepartmentAndClass from CACCCheckInService");

            using (CACCCheckInServiceProxy proxy =
                       new CACCCheckInServiceProxy())
            {
                proxy.Open();

                people = proxy.GetPeopleWithDepartmentAndClassByDepartmentAndClass(departmentName,
                                                                                   className);
            }

            var filteredPeople = (from p in people
                                  where p.ClassRole.Equals(ClassRoles.Teacher)
                                  select p).ToList();

            Debug.Assert(View != null);
            View.ViewDispatcher.BeginInvoke(DispatcherPriority.DataBind,
                                            new DispatcherOperationCallback(
                                                delegate(object arg)
            {
                View.TeachersDataContext =
                    new ObservableCollection <CACCCheckInDb.PeopleWithDepartmentAndClassView>(
                        filteredPeople);
                return(null);
            }), null);
        }
        /// <summary>
        /// Retrieve the attendance records of family for Today
        /// </summary>
        /// <param name="person"></param>
        /// <returns></returns>
        public List <CACCCheckInDb.AttendanceWithDetail> GetAttendanceRecordsForFamilyToday(CACCCheckInDb.PeopleWithDepartmentAndClassView person)
        {
            List <CACCCheckInDb.AttendanceWithDetail> records = null;

            try
            {
                logger.Debug("Retrieving attendance records for family for today.");

                using (CACCCheckInServiceProxy proxy =
                           new CACCCheckInServiceProxy())
                {
                    proxy.Open();

                    logger.Debug("Calling GetAttendanceByFamilyIdAndDate on CACCCheckInService.");

                    records = proxy.GetAttendanceByFamilyIdAndDate(person.FamilyId.GetValueOrDefault(),
                                                                   DateTime.Today);
                }
            }
            catch (Exception ex)
            {
                Debug.Assert(View != null);
                View.ViewDispatcher.BeginInvoke(DispatcherPriority.DataBind,
                                                new DispatcherOperationCallback(
                                                    delegate(object arg)
                {
                    View.DisplayExceptionDetail(ex);
                    return(null);
                }), null);
            }

            return(records);
        }
        private void GetFamilyFromService(CACCCheckInDb.PeopleWithDepartmentAndClassView person)
        {
            try
            {
                List <CACCCheckInDb.PeopleWithDepartmentAndClassView> people = null;

                if (person != null)
                {
                    using (CACCCheckInServiceProxy proxy =
                               new CACCCheckInServiceProxy())
                    {
                        proxy.Open();

                        if (person.FamilyId.HasValue)
                        {
                            logger.DebugFormat("Retrieving GetFamilyMembersByFamilyId from CACCCheckInService for FamilyId=[{0}]",
                                               person.FamilyId.Value);
                            people = proxy.GetFamilyMembersByFamilyId(person.FamilyId.Value);
                        }
                        else
                        {
                            logger.DebugFormat("Retrieving GetFamilyMembersByFamilyId from CACCCheckInService for PersonId=[{0}]",
                                               person.PersonId);
                            people = proxy.GetFamilyMembersByFamilyId(person.PersonId);
                        }
                    }
                }

                Debug.Assert(View != null);
                View.ViewDispatcher.BeginInvoke(DispatcherPriority.DataBind,
                                                new DispatcherOperationCallback(
                                                    delegate(object arg)
                {
                    // We will filter to get ONLY Family members who are
                    // either in Adult or MOPS department. These are
                    // the only valid departments for MOPS check-in
                    // screen. Also, we make sure only records where
                    // ClassRole is Member are needed.
                    View.FamilyDataContext = people.FindAll(p =>
                                                            (p.DepartmentName.Equals(Departments.Adult) ||
                                                             p.DepartmentName.Equals(Departments.MOPS)) &&
                                                            p.ClassRole.Equals(ClassRoles.Member));
                    return(null);
                }), null);
            }
            catch (Exception ex)
            {
                Debug.Assert(View != null);
                View.ViewDispatcher.BeginInvoke(DispatcherPriority.DataBind,
                                                new DispatcherOperationCallback(
                                                    delegate(object arg)
                {
                    View.DisplayExceptionDetail(ex);
                    return(null);
                }), null);
            }
        }
Пример #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="newClass"></param>
        public void AddClass(CACCCheckInDb.Class newClass)
        {
            using (CACCCheckInServiceProxy proxy =
                       new CACCCheckInServiceProxy())
            {
                proxy.Open();

                proxy.InsertClass(newClass);
            }
        }
Пример #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="department"></param>
        public void UpdateDepartment(CACCCheckInDb.Department department)
        {
            using (CACCCheckInServiceProxy proxy =
                       new CACCCheckInServiceProxy())
            {
                proxy.Open();

                proxy.UpdateDepartment(department);
            }
        }
Пример #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="department"></param>
        public void AddDepartment(CACCCheckInDb.Department department)
        {
            using (CACCCheckInServiceProxy proxy =
                       new CACCCheckInServiceProxy())
            {
                proxy.Open();

                proxy.InsertDepartment(department);
            }
        }
Пример #8
0
        /// <summary>
        /// Deletes attendance record
        /// </summary>
        /// <param name="record"></param>
        private void DeleteAttendance(CACCCheckInDb.Attendance record)
        {
            using (CACCCheckInServiceProxy proxy =
                       new CACCCheckInServiceProxy())
            {
                proxy.Open();

                proxy.DeleteAttendance(record);
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="classMember"></param>
        public void InsertClassMember(CACCCheckInDb.ClassMember classMember)
        {
            using (CACCCheckInServiceProxy proxy =
                       new CACCCheckInServiceProxy())
            {
                proxy.Open();

                proxy.InsertClassMember(classMember);
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="person"></param>
        public static void DeletePerson(CACCCheckInDb.Person person)
        {
            using (CACCCheckInServiceProxy proxy =
                       new CACCCheckInServiceProxy())
            {
                proxy.Open();

                proxy.DeletePeople(person);
            }
        }
Пример #11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="theClass"></param>
        public void DeleteClass(CACCCheckInDb.Class theClass)
        {
            using (CACCCheckInServiceProxy proxy =
                       new CACCCheckInServiceProxy())
            {
                proxy.Open();

                proxy.DeleteClass(theClass);
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="person"></param>
        public static CACCCheckInDb.Person InsertPerson(CACCCheckInDb.Person person)
        {
            using (CACCCheckInServiceProxy proxy =
                       new CACCCheckInServiceProxy())
            {
                proxy.Open();

                person = proxy.InsertPeople(person);
            }

            return(person);
        }
Пример #13
0
        private void GetDataForAdultListFromService(string targetDepartment)
        {
            try
            {
                List <CACCCheckInDb.PeopleWithDepartmentAndClassView> people = null;

                logger.Debug("Retrieving GetPeopleWithDepartmentAndClassByDepartment from CACCCheckInService");

                using (CACCCheckInServiceProxy proxy =
                           new CACCCheckInServiceProxy())
                {
                    proxy.Open();

                    if (targetDepartment.Equals(Departments.MOPS))
                    {
                        people = proxy.GetPeopleWithDepartmentAndClassByDepartmentAndClass(
                            Departments.Adult, "MOPS Adults");
                    }
                    if (targetDepartment.Equals(Departments.LadiesBibleStudy))
                    {
                        people = proxy.GetPeopleWithDepartmentAndClassByDepartmentAndClass(
                            Departments.Adult, "Ladies Bible Study Adults");
                    }
                    else
                    {
                        people = proxy.GetPeopleWithDepartmentAndClassByDepartmentAndClass(
                            Departments.Adult, "Adult");
                    }
                }

                Debug.Assert(View != null);
                View.ViewDispatcher.BeginInvoke(DispatcherPriority.DataBind,
                                                new DispatcherOperationCallback(
                                                    delegate(object arg)
                {
                    View.AdultsDataContext =
                        new ObservableCollection <CACCCheckInDb.PeopleWithDepartmentAndClassView>(
                            people);
                    return(null);
                }), null);
            }
            catch (Exception ex)
            {
                Debug.Assert(View != null);
                View.ViewDispatcher.BeginInvoke(DispatcherPriority.DataBind,
                                                new DispatcherOperationCallback(
                                                    delegate(object arg)
                {
                    View.DisplayExceptionDetail(ex);
                    return(null);
                }), null);
            }
        }
        private void GetDataForClassListFromService(string departmentName, string className, bool fromList)
        {
            try
            {
                List <CACCCheckInDb.PeopleWithDepartmentAndClassView> people = null;

                logger.Debug("Retrieving GetPeopleWithDepartmentAndClassByDepartmentAndClass from CACCCheckInService");

                using (CACCCheckInServiceProxy proxy =
                           new CACCCheckInServiceProxy())
                {
                    proxy.Open();

                    people = proxy.GetPeopleWithDepartmentAndClassByDepartmentAndClass(
                        departmentName, className);
                }

                logger.Debug("Filtering people to only show Class Members and NOT Teachers.");
                var filteredPeople = new ObservableCollection <CACCCheckInDb.PeopleWithDepartmentAndClassView>(
                    (from p in people
                     where p.ClassRole.Equals(ClassRoles.Member)
                     select p).ToList());

                Debug.Assert(View != null);
                View.ViewDispatcher.BeginInvoke(DispatcherPriority.DataBind,
                                                new DispatcherOperationCallback(
                                                    delegate(object arg)
                {
                    if (fromList)
                    {
                        View.ClassFromListDataContext = filteredPeople;
                    }
                    else
                    {
                        View.ClassToListDataContext = filteredPeople;
                    }
                    return(null);
                }), null);
            }
            catch (Exception ex)
            {
                Debug.Assert(View != null);
                View.ViewDispatcher.BeginInvoke(DispatcherPriority.DataBind,
                                                new DispatcherOperationCallback(
                                                    delegate(object arg)
                {
                    View.DisplayExceptionDetail(ex);
                    return(null);
                }), null);
            }
        }
        private void GetClassAttendanceInDateRangeFromService(Guid departmentId, Guid classId,
                                                              DateTime?attendanceStartDate, DateTime?attendanceEndDate)
        {
            try
            {
                List <CACCCheckInDb.AttendanceWithDetail> records = null;

                using (CACCCheckInServiceProxy proxy =
                           new CACCCheckInServiceProxy())
                {
                    proxy.Open();

                    if (classId.Equals(new Guid("00000000-0000-0000-0000-000000000000")))
                    {
                        logger.Debug("Retrieving GetAttendanceByDepartmentAndDateRange from CACCCheckInServiceProxy");

                        records = proxy.GetAttendanceByDepartmentAndDateRange(departmentId,
                                                                              attendanceStartDate.Value, attendanceEndDate.Value);
                    }
                    else
                    {
                        logger.Debug("Retrieving GetAttendanceByDepartmentAndClassIdAndDateRange from CACCCheckInServiceProxy");

                        records = proxy.GetAttendanceByDepartmentAndClassIdAndDateRange(
                            departmentId, classId,
                            attendanceStartDate.Value, attendanceEndDate.Value);
                    }
                }

                Debug.Assert(View != null);
                View.ViewDispatcher.BeginInvoke(DispatcherPriority.DataBind,
                                                new DispatcherOperationCallback(
                                                    delegate(object arg)
                {
                    View.ReportDataContext = records;
                    return(null);
                }), null);
            }
            catch (Exception ex)
            {
                Debug.Assert(View != null);
                View.ViewDispatcher.BeginInvoke(DispatcherPriority.DataBind,
                                                new DispatcherOperationCallback(
                                                    delegate(object arg)
                {
                    View.DisplayExceptionDetail(ex);
                    return(null);
                }), null);
            }
        }
        private void GetFamilyFromService(CACCCheckInDb.Person person)
        {
            try
            {
                CACCCheckInDb.People people = null;

                if (person != null)
                {
                    logger.Debug("Retrieving GetPeopleByFamilyId from CACCCheckInService");

                    using (CACCCheckInServiceProxy proxy =
                               new CACCCheckInServiceProxy())
                    {
                        proxy.Open();

                        if (person.FamilyId.HasValue)
                        {
                            people = new CACCCheckInDb.People(
                                proxy.GetPeopleByFamilyId(person.FamilyId.Value));

                            people.CollectionChanged +=
                                new NotifyCollectionChangedEventHandler(FamilyCollectionChanged);
                            people.ItemEndEdit +=
                                new CACCCheckInDb.ItemEndEditEventHandler(PeopleItemEndEdit);
                        }
                    }
                }

                Debug.Assert(View != null);
                View.ViewDispatcher.BeginInvoke(DispatcherPriority.DataBind,
                                                new DispatcherOperationCallback(
                                                    delegate(object arg)
                {
                    View.FamilyDataContext = people;
                    return(null);
                }), null);
            }
            catch (Exception ex)
            {
                Debug.Assert(View != null);
                View.ViewDispatcher.BeginInvoke(DispatcherPriority.DataBind,
                                                new DispatcherOperationCallback(
                                                    delegate(object arg)
                {
                    View.DisplayExceptionDetail(ex);
                    return(null);
                }), null);
            }
        }
        private void GetPersonAttendanceOnDateFromService(Guid personId, DateTime?attendanceDate)
        {
            try
            {
                List <CACCCheckInDb.AttendanceWithDetail> records = null;

                using (CACCCheckInServiceProxy proxy =
                           new CACCCheckInServiceProxy())
                {
                    proxy.Open();

                    if (attendanceDate.HasValue)
                    {
                        logger.Debug("Retrieving GetAttendanceByPersonIdAndDate from CACCCheckInServiceProxy");

                        records = proxy.GetAttendanceByPersonIdAndDate(personId,
                                                                       attendanceDate.Value);
                    }
                    else
                    {
                        logger.Debug("Retrieving GetAttendanceByPersonId from CACCCheckInServiceProxy");

                        records = proxy.GetAttendanceByPersonId(personId);
                    }
                }

                Debug.Assert(View != null);
                View.ViewDispatcher.BeginInvoke(DispatcherPriority.DataBind,
                                                new DispatcherOperationCallback(
                                                    delegate(object arg)
                {
                    View.ReportDataContext = records;
                    return(null);
                }), null);
            }
            catch (Exception ex)
            {
                Debug.Assert(View != null);
                View.ViewDispatcher.BeginInvoke(DispatcherPriority.DataBind,
                                                new DispatcherOperationCallback(
                                                    delegate(object arg)
                {
                    View.DisplayExceptionDetail(ex);
                    return(null);
                }), null);
            }
        }
        /// <summary>
        /// Will add a person to class
        /// </summary>
        /// <param name="person"></param>
        private void AddPersonClassMembership(CACCCheckInDb.PeopleWithDepartmentAndClassView person)
        {
            logger.DebugFormat("Adding class membership for [{0} {1}]",
                               person.FirstName, person.LastName);

            // Get a reference to ClassMember record for current person
            CACCCheckInDb.ClassMember newClassMember = (CACCCheckInDb.ClassMember)person;

            using (CACCCheckInServiceProxy proxy =
                       new CACCCheckInServiceProxy())
            {
                proxy.Open();

                logger.Debug("Calling InsertClassMember in CACCCheckInService");
                proxy.InsertClassMember(newClassMember);
            }
        }
        private void GetPeopleFromService()
        {
            try
            {
                List <CACCCheckInDb.PeopleWithDepartmentAndClassView> people = null;

                logger.Debug("Retrieving GetPeopleWithDepartmentAndClassByDepartment from CACCCheckInService");

                using (CACCCheckInServiceProxy proxy =
                           new CACCCheckInServiceProxy())
                {
                    proxy.Open();

                    // We retrieve just the Adult members here.
                    people = proxy.GetPeopleWithDepartmentAndClassByDepartmentAndClass(Departments.Adult,
                                                                                       "MOPS Adults");
                }

                // Filter the list of adults to make sure we only get Member records. If we
                // don't do this, it is possible we might get multiple records for people
                // who are serve in Member and Teacher class roles.
                var filteredPeople = (from p in people
                                      where p.ClassRole.Equals(ClassRoles.Member)
                                      select p).ToList();

                Debug.Assert(View != null);
                View.ViewDispatcher.BeginInvoke(DispatcherPriority.DataBind,
                                                new DispatcherOperationCallback(
                                                    delegate(object arg)
                {
                    View.PeopleDataContext = filteredPeople;
                    return(null);
                }), null);
            }
            catch (Exception ex)
            {
                Debug.Assert(View != null);
                View.ViewDispatcher.BeginInvoke(DispatcherPriority.DataBind,
                                                new DispatcherOperationCallback(
                                                    delegate(object arg)
                {
                    View.DisplayExceptionDetail(ex);
                    return(null);
                }), null);
            }
        }
        private void GetDepartmentClassesFromService(Guid departmentId)
        {
            try
            {
                List <CACCCheckInDb.Class> classes = null;

                logger.Debug("Retrieving GetClassesByDeptId from CACCCheckInServiceProxy");

                using (CACCCheckInServiceProxy proxy =
                           new CACCCheckInServiceProxy())
                {
                    proxy.Open();

                    classes = proxy.GetClassesByDeptId(departmentId);
                }

                // Add a bogus class to the list, this will be used
                // so user can select it to signify default
                classes.Insert(0, new CACCCheckInDb.Class
                {
                    Name = String.Empty,
                    Id   = new Guid("00000000-0000-0000-0000-000000000000")
                });

                Debug.Assert(View != null);
                View.ViewDispatcher.BeginInvoke(DispatcherPriority.DataBind,
                                                new DispatcherOperationCallback(
                                                    delegate(object arg)
                {
                    View.DepartmentClassesDataContext = classes;
                    return(null);
                }), null);
            }
            catch (Exception ex)
            {
                Debug.Assert(View != null);
                View.ViewDispatcher.BeginInvoke(DispatcherPriority.DataBind,
                                                new DispatcherOperationCallback(
                                                    delegate(object arg)
                {
                    View.DisplayExceptionDetail(ex);
                    return(null);
                }), null);
            }
        }
Пример #21
0
        private void InnerPrintTeacherLabelsForDepartment(string departmentName)
        {
            List <CACCCheckInDb.PeopleWithDepartmentAndClassView> teachers = null;

            try
            {
                using (CACCCheckInServiceProxy proxy =
                           new CACCCheckInServiceProxy())
                {
                    proxy.Open();

                    teachers = proxy.GetPeopleWithDepartmentAndClassByDepartment(departmentName);
                }

                teachers = teachers.FindAll(p => p.ClassRole.Equals(ClassRoles.Teacher));

                logger.DebugFormat("Printing labels for [{0}] teachers.",
                                   teachers.Count);

                teachers.ForEach(t => t.SpecialConditions = ClassRoles.Teacher);

                _labelPrinterService.PrintLabels(null, Constants.ChurchName,
                                                 0, teachers);

                View.ViewDispatcher.BeginInvoke(DispatcherPriority.DataBind,
                                                new DispatcherOperationCallback(
                                                    delegate(object arg)
                {
                    View.LabelPrintingCompleted();
                    return(null);
                }), null);
            }
            catch (Exception ex)
            {
                Debug.Assert(View != null);
                View.ViewDispatcher.BeginInvoke(DispatcherPriority.DataBind,
                                                new DispatcherOperationCallback(
                                                    delegate(object arg)
                {
                    View.DisplayExceptionDetail(ex);
                    return(null);
                }), null);
            }
        }
        private void GetDataForClassComboFromService(Guid departmentId, bool fromCombo)
        {
            try
            {
                List <CACCCheckInDb.Class> classes = null;

                logger.Debug("Retrieving GetClassesByDeptId from CACCCheckInService");

                using (CACCCheckInServiceProxy proxy =
                           new CACCCheckInServiceProxy())
                {
                    proxy.Open();

                    classes = proxy.GetClassesByDeptId(departmentId);
                }

                Debug.Assert(View != null);
                View.ViewDispatcher.BeginInvoke(DispatcherPriority.DataBind,
                                                new DispatcherOperationCallback(
                                                    delegate(object arg)
                {
                    if (fromCombo)
                    {
                        View.ClassFromDataContext = classes;
                    }
                    else
                    {
                        View.ClassToDataContext = classes;
                    }
                    return(null);
                }), null);
            }
            catch (Exception ex)
            {
                Debug.Assert(View != null);
                View.ViewDispatcher.BeginInvoke(DispatcherPriority.DataBind,
                                                new DispatcherOperationCallback(
                                                    delegate(object arg)
                {
                    View.DisplayExceptionDetail(ex);
                    return(null);
                }), null);
            }
        }
        public List <string> GetAllFamilyRoles()
        {
            List <string> records = null;

            try
            {
                using (CACCCheckInServiceProxy proxy =
                           new CACCCheckInServiceProxy())
                {
                    proxy.Open();

                    records = proxy.GetAllFromFamilyRole();
                }
            }
            catch (Exception)
            {}

            return(records);
        }
        private void GetPeopleByDeptIdAndClassIdFromService(Guid departmentId, Guid classId)
        {
            try
            {
                CACCCheckInDb.People people = null;

                logger.Debug("Retrieving GetAllFromPeople from CACCCheckInService");

                using (CACCCheckInServiceProxy proxy =
                           new CACCCheckInServiceProxy())
                {
                    proxy.Open();

                    people = new CACCCheckInDb.People(proxy.GetPeopleByDeptIdAndClassId(
                                                          departmentId, classId));
                    people.CollectionChanged +=
                        new NotifyCollectionChangedEventHandler(PeopleCollectionChanged);
                    people.ItemEndEdit +=
                        new CACCCheckInDb.ItemEndEditEventHandler(PeopleItemEndEdit);
                }

                Debug.Assert(View != null);
                View.ViewDispatcher.BeginInvoke(DispatcherPriority.DataBind,
                                                new DispatcherOperationCallback(
                                                    delegate(object arg)
                {
                    View.PeopleDataContext = people;
                    return(null);
                }), null);
            }
            catch (Exception ex)
            {
                Debug.Assert(View != null);
                View.ViewDispatcher.BeginInvoke(DispatcherPriority.DataBind,
                                                new DispatcherOperationCallback(
                                                    delegate(object arg)
                {
                    View.DisplayExceptionDetail(ex);
                    return(null);
                }), null);
            }
        }
Пример #25
0
        private void GetAttendanceByDeptIdFromService(Guid departmentId)
        {
            try
            {
                CACCCheckInDb.AttendanceRecords attendance = null;

                logger.Debug("Retrieving GetAttendanceByDeptId from CACCCheckInService");

                using (CACCCheckInServiceProxy proxy =
                           new CACCCheckInServiceProxy())
                {
                    proxy.Open();

                    attendance = new CACCCheckInDb.AttendanceRecords(proxy.GetAttendanceByDeptId(departmentId));

                    logger.Debug("Hooking up CollectionChanged event handler for attendance records");

                    attendance.CollectionChanged +=
                        new NotifyCollectionChangedEventHandler(AttendanceRecordsCollectionChanged);
                }

                Debug.Assert(View != null);
                View.ViewDispatcher.BeginInvoke(DispatcherPriority.DataBind,
                                                new DispatcherOperationCallback(
                                                    delegate(object arg)
                {
                    View.AttendanceDataContext = attendance;
                    return(null);
                }), null);
            }
            catch (Exception ex)
            {
                Debug.Assert(View != null);
                View.ViewDispatcher.BeginInvoke(DispatcherPriority.DataBind,
                                                new DispatcherOperationCallback(
                                                    delegate(object arg)
                {
                    View.DisplayExceptionDetail(ex);
                    return(null);
                }), null);
            }
        }
        private void GetDataForDepartmentCombosFromService()
        {
            try
            {
                List <CACCCheckInDb.Department> departmentsFrom = null;
                List <CACCCheckInDb.Department> departmentsTo   = null;

                logger.Debug("Retrieving GetAllFromDepartment from CACCCheckInService");

                using (CACCCheckInServiceProxy proxy =
                           new CACCCheckInServiceProxy())
                {
                    proxy.Open();

                    departmentsFrom = proxy.GetAllFromDepartment();
                }

                departmentsTo = new List <CACCCheckInDb.Department>(departmentsFrom);

                Debug.Assert(View != null);
                View.ViewDispatcher.BeginInvoke(DispatcherPriority.DataBind,
                                                new DispatcherOperationCallback(
                                                    delegate(object arg)
                {
                    View.DepartmentFromDataContext = departmentsFrom;
                    View.DepartmentToDataContext   = departmentsTo;
                    return(null);
                }), null);
            }
            catch (Exception ex)
            {
                Debug.Assert(View != null);
                View.ViewDispatcher.BeginInvoke(DispatcherPriority.DataBind,
                                                new DispatcherOperationCallback(
                                                    delegate(object arg)
                {
                    View.DisplayExceptionDetail(ex);
                    return(null);
                }), null);
            }
        }
        /// <summary>
        /// Will move a person from current class to new class
        /// </summary>
        /// <param name="person"></param>
        /// <param name="newClass"></param>
        public void UpdatePersonClassMembership(CACCCheckInDb.PeopleWithDepartmentAndClassView person,
                                                CACCCheckInDb.Class newClass)
        {
            try
            {
                logger.DebugFormat("Updating class membership for [{0} {1}]",
                                   person.FirstName, person.LastName);

                // Get a reference to ClassMember record for current person
                CACCCheckInDb.ClassMember oldClassMember = (CACCCheckInDb.ClassMember)person;
                // Create a new ClassMember record to move current person to new class
                CACCCheckInDb.ClassMember newClassMember = new CACCCheckInDb.ClassMember();
                // The new ClassId is used along with current ClassRole and PersonId
                newClassMember.ClassId   = newClass.Id;
                newClassMember.ClassRole = oldClassMember.ClassRole;
                newClassMember.PersonId  = oldClassMember.PersonId;

                using (CACCCheckInServiceProxy proxy =
                           new CACCCheckInServiceProxy())
                {
                    proxy.Open();

                    logger.Debug("Calling DeleteClassMember in CACCCheckInService");
                    proxy.DeleteClassMember(oldClassMember);

                    logger.Debug("Calling InsertClassMember in CACCCheckInService");
                    proxy.InsertClassMember(newClassMember);
                }
            }
            catch (Exception ex)
            {
                Debug.Assert(View != null);
                View.ViewDispatcher.BeginInvoke(DispatcherPriority.DataBind,
                                                new DispatcherOperationCallback(
                                                    delegate(object arg)
                {
                    View.DisplayExceptionDetail(ex);
                    return(null);
                }), null);
            }
        }
Пример #28
0
        private void GetDepartmentClassesFromService(Guid departmentId)
        {
            try
            {
                CACCCheckInDb.Classes classes = null;

                logger.Debug("Retrieving GetClassesByDeptId from CACCCheckInServiceProxy");

                using (CACCCheckInServiceProxy proxy =
                           new CACCCheckInServiceProxy())
                {
                    proxy.Open();

                    classes = new CACCCheckInDb.Classes(proxy.GetClassesByDeptId(departmentId));
                    classes.CollectionChanged +=
                        new NotifyCollectionChangedEventHandler(ClassesCollectionChanged);
                    classes.ItemEndEdit +=
                        new CACCCheckInDb.ItemEndEditEventHandler(ClassesItemEndEdit);
                }

                Debug.Assert(View != null);
                View.ViewDispatcher.BeginInvoke(DispatcherPriority.DataBind,
                                                new DispatcherOperationCallback(
                                                    delegate(object arg)
                {
                    View.ClassesDataContext = classes;
                    return(null);
                }), null);
            }
            catch (Exception ex)
            {
                Debug.Assert(View != null);
                View.ViewDispatcher.BeginInvoke(DispatcherPriority.DataBind,
                                                new DispatcherOperationCallback(
                                                    delegate(object arg)
                {
                    View.DisplayExceptionDetail(ex);
                    return(null);
                }), null);
            }
        }
        /// <summary>
        /// Call to see if child is already checked in today to specific class
        /// </summary>
        /// <param name="person"></param>
        /// <returns></returns>
        public bool IsChildAlreadyCheckedInToday(CACCCheckInDb.PeopleWithDepartmentAndClassView person,
                                                 Guid classId)
        {
            bool isCheckedIntoClassToday = false;

            try
            {
                logger.Debug("Retrieving attendance records for person for today.");

                using (CACCCheckInServiceProxy proxy =
                           new CACCCheckInServiceProxy())
                {
                    proxy.Open();

                    logger.Debug("Calling GetAttendanceByPersonIdAndDate on CACCCheckInService.");

                    // First, we get attendance records for person for Today
                    List <CACCCheckInDb.AttendanceWithDetail> records =
                        proxy.GetAttendanceByPersonIdAndDate(person.PersonId, DateTime.Today);

                    // Then, we see if the attendance was in the specified class
                    isCheckedIntoClassToday = records.Any(r => r.ClassId.Equals(classId));
                }
            }
            catch (Exception ex)
            {
                Debug.Assert(View != null);
                View.ViewDispatcher.BeginInvoke(DispatcherPriority.DataBind,
                                                new DispatcherOperationCallback(
                                                    delegate(object arg)
                {
                    View.DisplayExceptionDetail(ex);
                    return(null);
                }), null);
            }

            return(isCheckedIntoClassToday);
        }
        private void GetDepartmentPeopleFromService(string departmentName)
        {
            try
            {
                List <CACCCheckInDb.PeopleWithDepartmentAndClassView> people = null;

                logger.Debug("Retrieving GetPeopleWithDepartmentAndClassByDepartment from CACCCheckInServiceProxy");

                using (CACCCheckInServiceProxy proxy =
                           new CACCCheckInServiceProxy())
                {
                    proxy.Open();

                    people = proxy.GetPeopleWithDepartmentAndClassByDepartment(departmentName);
                }

                Debug.Assert(View != null);
                View.ViewDispatcher.BeginInvoke(DispatcherPriority.DataBind,
                                                new DispatcherOperationCallback(
                                                    delegate(object arg)
                {
                    View.DepartmentPeopleDataContext = people;
                    return(null);
                }), null);
            }
            catch (Exception ex)
            {
                Debug.Assert(View != null);
                View.ViewDispatcher.BeginInvoke(DispatcherPriority.DataBind,
                                                new DispatcherOperationCallback(
                                                    delegate(object arg)
                {
                    View.DisplayExceptionDetail(ex);
                    return(null);
                }), null);
            }
        }