コード例 #1
0
        private void DeleteCompleted(object sender, UploadStringCompletedEventArgs e)
        {
            try
            {
                CheckForErrors(e);

                string returnTypeName = app.GetBusinessObjectType(e.Result);

                switch (returnTypeName)
                {
                case "Acknowledgement":
                    PartyService.Acknowledgement ack = app.LoadBusinessObject <PartyService.Acknowledgement>(e.Result);
                    MessagePopUp ackPopUp            = new MessagePopUp(ack.Message, MessagePopUp.MessagePopUpType.OK);
                    ackPopUp.Show();
                    break;

                case "Error":
                    PartyService.Error err = app.LoadBusinessObject <PartyService.Error>(e.Result);
                    throw (new Exception(err.Message));

                default:
                    throw (new Exception("Unrecognised object type in server response"));
                }
            }
            catch (Exception ex)
            {
                app.ShowError(ex.Message);
            }
            finally
            {
                formBusyIndicator.IsBusy = false;
            }
        }
コード例 #2
0
        void PartyLoadCompleted(object sender, OpenReadCompletedEventArgs e)
        {
            try
            {
                CheckForErrors(e);

                string returnTypeName = app.GetBusinessObjectType(e.Result);

                switch (returnTypeName)
                {
                case "Business":
                    PartyService.Business bus          = app.LoadBusinessObject <PartyService.Business>(e.Result);
                    BusinessForm          businessForm = new BusinessForm();
                    businessForm.DataContext = bus;
                    SetContent(businessForm);
                    break;

                case "Person":
                    PartyService.Person per        = app.LoadBusinessObject <PartyService.Person>(e.Result);
                    PersonForm          personForm = new PersonForm();
                    personForm.DataContext = per;
                    SetContent(personForm);
                    break;

                case "Error":
                    PartyService.Error err = app.LoadBusinessObject <PartyService.Error>(e.Result);
                    throw (new Exception(err.Message));

                default:
                    throw (new Exception("Unrecognised object type in server response"));
                }
            }
            catch (Exception ex)
            {
                app.ShowError(ex.Message);
            }
            finally
            {
                formBusyIndicator.IsBusy = false;
            }
        }
コード例 #3
0
ファイル: App.xaml.cs プロジェクト: offspin/building_blocks
        public T LoadBusinessObject <T>(Stream s)
        {
            s.Seek(0, SeekOrigin.Begin);
            XmlSerializer xs = new XmlSerializer(typeof(T));

            try
            {
                return((T)xs.Deserialize(s));
            }
            catch
            {
                try
                {
                    XmlSerializer es = new XmlSerializer(typeof(PartyService.Error));
                    s.Seek(0, SeekOrigin.Begin);
                    PartyService.Error error = (PartyService.Error)es.Deserialize(s);
                    throw (new Exception(error.Message));
                }
                catch
                {
                    throw;
                }
            }
        }