Beispiel #1
0
        private async void cmdStore_Click(object sender, EventArgs e)
        {
            if (!ZUIDs(out var lUIDs))
            {
                return;
            }

            eStoreOperation lOperation;
            cStorableFlags  lFlags;
            ulong?          lIfUnchangedSinceModSeq;

            using (frmStoreDialog lStoreDialog = new frmStoreDialog())
            {
                if (lStoreDialog.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }

                lOperation = lStoreDialog.Operation;
                lFlags     = lStoreDialog.Flags;
                lIfUnchangedSinceModSeq = lStoreDialog.IfUnchangedSinceModSeq;
            }

            cUIDStoreFeedback lFeedback;

            try { lFeedback = await mClient.SelectedMailbox.UIDStoreAsync(lUIDs, lOperation, lFlags, lIfUnchangedSinceModSeq); }
            catch (Exception ex)
            {
                if (!IsDisposed)
                {
                    MessageBox.Show(this, $"store error\n{ex}");
                }
                return;
            }

            var lSummary = lFeedback.Summary();

            if (lSummary.LikelyOKCount == lFeedback.Count)
            {
                return;                                            // all messages were updated or didn't need updating
            }
            if (lSummary.LikelyWorthPolling)
            {
                // see if polling the server helps explain any possible failures
                try { await mClient.PollAsync(); }
                catch { }

                // re-get the summary
                lSummary = lFeedback.Summary();

                // re-check the summary
                if (lSummary.LikelyOKCount == lFeedback.Count)
                {
                    return;                                            // all messages were updated or didn't need updating
                }
            }

            if (IsDisposed)
            {
                return;
            }
            MessageBox.Show(this, $"(some of) the messages don't appear to have been updated: {lSummary}");
        }
        private async void cmdStore_Click(object sender, EventArgs e)
        {
            var lBindingSource = dgvMessages.DataSource as BindingSource;

            if (lBindingSource == null)
            {
                return;
            }
            if (lBindingSource.Count == 0)
            {
                MessageBox.Show("there have to be some messages to update");
            }

            // get them now: some could be delivered while the dialog is up (TODO: test that theory)
            var lMessages = new List <cMessage>(from cGridRowData lItem in lBindingSource select lItem.Message);

            eStoreOperation lOperation;
            cStorableFlags  lFlags;
            ulong?          lIfUnchangedSinceModSeq;

            using (frmStoreDialog lStoreDialog = new frmStoreDialog())
            {
                if (lStoreDialog.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }

                lOperation = lStoreDialog.Operation;
                lFlags     = lStoreDialog.Flags;
                lIfUnchangedSinceModSeq = lStoreDialog.IfUnchangedSinceModSeq;
            }

            cStoreFeedback lFeedback;

            try { lFeedback = await mClient.StoreAsync(lMessages, lOperation, lFlags, lIfUnchangedSinceModSeq); }
            catch (Exception ex)
            {
                if (!IsDisposed)
                {
                    MessageBox.Show(this, $"store error\n{ex}");
                }
                return;
            }

            var lSummary = lFeedback.Summary();

            if (lSummary.LikelyOKCount == lFeedback.Count)
            {
                return;                                            // all messages were updated or didn't need updating
            }
            if (lSummary.LikelyWorthPolling)
            {
                // see if polling the server helps explain any possible failures
                try { await mClient.PollAsync(); }
                catch { }

                // re-get the summary
                lSummary = lFeedback.Summary();

                // re-check the summary
                if (lSummary.LikelyOKCount == lFeedback.Count)
                {
                    return;                                            // all messages were updated or didn't need updating
                }
            }

            if (IsDisposed)
            {
                return;
            }
            MessageBox.Show(this, $"(some of) the messages don't appear to have been updated: {lSummary}");
        }