Exemplo n.º 1
0
        void btnSend_Click(object sender, EventArgs e)
        {
            try {
                if (Model == null)
                {
                    return;
                }

                Model.Comments = txtComments.Text;

                BackgroundSendModel sendModel = BackgroundSendModelAccessor.SendReportInBackgroundThread(Model.SendReport);

                ReportSendProgressForm progressForm = new ReportSendProgressForm(sendModel);
                DialogResult           result       = progressForm.ShowDialog(this);
                if (result == DialogResult.OK)
                {
                    this.DialogResult = DialogResult.OK;
                }
                else if (result == DialogResult.Retry)
                {
                    MessageBox.Show(this, "Unable to send, please try again", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch {
            }
        }
Exemplo n.º 2
0
        void OnSendClick(object sender, RoutedEventArgs e)
        {
            try {
                if (Model == null)
                {
                    return;
                }

                Model.Comments = txtComments.Text;
                BackgroundSendModel sendModel = BackgroundSendModelAccessor.SendReportInBackgroundThread(Model.SendReport);

                ReportSendProgressForm progressForm = new ReportSendProgressForm(sendModel);
                progressForm.Owner = this;
                progressForm.ShowDialog();
                ReportSendProgressDialogResult result = progressForm.Result;
                if (result == ReportSendProgressDialogResult.OK)
                {
                    this.DialogResult = true;
                }
                else if (result == ReportSendProgressDialogResult.Retry)
                {
                    MessageBox.Show(this, "Unable to send, please try again", this.Title, MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            catch {
            }
        }
Exemplo n.º 3
0
        public static BackgroundSendModel SendReportInBackgroundThread(Func <bool> sendAction)
        {
            Thread thread = new Thread(BackgroundSend);
            BackgroundSendModel sendModel = new BackgroundSendModel();

            sendModel.SendAction = sendAction;
            sendModel.Thread     = thread;
            thread.Start(sendModel);
            return(sendModel);
        }
Exemplo n.º 4
0
        public ReportSendProgressForm(BackgroundSendModel model)
        {
            InitializeComponent();

            this.Model = model;
            if (Model != null)
            {
                this.timer          = new System.Windows.Forms.Timer();
                this.timer.Tick    += OnTimerTick;
                this.timer.Interval = 100;
                this.timer.Start();
            }
        }
Exemplo n.º 5
0
        static void BackgroundSend(object obj)
        {
            BackgroundSendModel model = obj as BackgroundSendModel;

            if (model == null)
            {
                return;
            }

            try {
                if (model.SendAction == null)
                {
                    model.SendResult = false;
                    //model.SendComplete = true;
                    return;
                }

                model.SendResult = model.SendAction();
                //model.SendComplete = true;
            }
            finally {
                model.SendComplete = true;
            }
        }