コード例 #1
0
        private void GetDataForClassComboFromService()
        {
            try
            {
                List <CACCCheckInDb.Class> classes = null;

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

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

                    classes = proxy.GetClassesByDeptName(TargetDepartment);
                }

                // 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.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);
            }
        }