Esempio n. 1
0
        private void GetDepartmentsFromService()
        {
            try
            {
                CACCCheckInDb.Departments departments = null;

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

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

                    departments = new CACCCheckInDb.Departments(proxy.GetAllFromDepartment());
                    departments.CollectionChanged +=
                        new NotifyCollectionChangedEventHandler(DepartmentsCollectionChanged);
                    departments.ItemEndEdit +=
                        new CACCCheckInDb.ItemEndEditEventHandler(DepartmentsItemEndEdit);
                }

                Debug.Assert(View != null);
                View.ViewDispatcher.BeginInvoke(DispatcherPriority.DataBind,
                                                new DispatcherOperationCallback(
                                                    delegate(object arg)
                {
                    View.DepartmentsDataContext = departments;
                    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);
            }
        }