Check-in [93688da7bc]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fixed timers (they weren't moved with the rest of the code :-P)
Timelines: family | ancestors | descendants | both | dotnet/timers
Files: files | file ages | folders
SHA1: 93688da7bcd339b34e42e13aef9f7866ee104beb
User & Date: tinus 2019-09-13 19:03:17
Wiki:dotnet/timers
Context
2019-09-14
05:54
Merge dotnet into dotnet/timers (error reporting improvements). Leaf check-in: 1e71405b77 user: tinus tags: dotnet/timers
2019-09-13
19:03
Fixed timers (they weren't moved with the rest of the code :-P) check-in: 93688da7bc user: tinus tags: dotnet/timers
18:58
Merge dotnet into dotnet/timers. check-in: e57149797c user: tinus tags: dotnet/timers
Changes

Changes to MailSynchronizer.cs.

336
337
338
339
340
341
342



343
344





345

346


347


348
349

350
351
352
353
354
355
356
...
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
...
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
...
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
                            await work.FolderMessages.AddAsync(folderMessage);
                        }
                        dbMessage = folderMessage.Message;
                        dbMessage.GlobalID = summary.GMailMessageId;
                        dbMessage.DateRetrievedUTC = DateTime.UtcNow;
                        dbMessage.Flags = summary.Flags ?? MessageFlags.None;
                        dbMessage.DateReceived = summary.InternalDate;



                        await PopulateMessageAsync(dbMessage, mailMessage, summary.Keywords);






                        // Store all separate entities contained in the mail message

                        await PopulateParticipantsAsync(work, dbMessage, mailMessage);    // from headers


                        await PopulateKeywordsAsync(work, dbMessage, summary.Keywords, summary.GMailLabels); // from summary


                        await PopulateReferencesAsync(work, dbMessage, mailMessage);      // from summary + headers


                    }
                    await work.SaveChangesAsync();
                }
                catch (Exception ex)
                {
                    if (ex is TaskCanceledException || ex is OperationCanceledException || ex is ServiceNotConnectedException)
                    {
................................................................................
        }

        private async Task<MimeMessage> GetMailMessageAsync(IMessageSummary summary, IMailFolder mailFolder)
        {
            MimeMessage mailMessage;
            try
            {
                            TimerCollection.Global.Start("mailFolder.GetMessageAsync");
                            try {
                                mailMessage = await mailFolder.GetMessageAsync(summary.UniqueId, _cancellationToken);
                            } finally {
                                TimerCollection.Global.Stop("mailFolder.GetMessageAsync");
                            }
            }
            catch (FormatException)
            {
                var mailEncoding = Encoding.GetEncoding("ISO-8859-1");
                // Upon failure to parse the message, try to download the entire message stream
                using (Stream mailStream = await mailFolder.GetStreamAsync(summary.UniqueId, 0, (int)summary.Size.Value, _cancellationToken))
                using (StreamReader reader = new StreamReader(mailStream, mailEncoding, true))
................................................................................
                        };
                        mailMessage = await MimeMessage.LoadAsync(options, fixedStream, _cancellationToken);
                    }
                }
            }

            return mailMessage;
                        TimerCollection.Global.Start("PopulateMessageAsync");
                        try {
                        } finally {
                            TimerCollection.Global.Stop("PopulateMessageAsync");
                        }
        }

        public async Task ClearUnunsedObjectsAsync(bool vacuumDatabase = false)
        {
            using (var work = new UnitOfWork(_cancellationToken))
            {
                await Con.WriteLineAsync("Cleaning up database...", TraceLevel.Verbose);
................................................................................
                    using (var compressedStream = entry.Open())
                        await sourceMsg.WriteToAsync(compressedStream);
                }
                targetMsg.Original = zipStream.ToArray();
            }
            TimerCollection.Global.Stop("ZipArchive");
            // TODO: skip the above if we only have the headers
            TimerCollection.Global.Start("PopulateParticipants");
            TimerCollection.Global.Stop("PopulateParticipants");
            TimerCollection.Global.Start("PopulateKeywords");
            TimerCollection.Global.Stop("PopulateKeywords");
            TimerCollection.Global.Start("PopulateReferences");
            TimerCollection.Global.Stop("PopulateReferences");
        } // PopulateMessageAsync

        private static string CreateMessageFilename(MimeMessage sourceMsg, string extension = ".eml")
        {
            string subject = MakeSafe(sourceMsg.Subject);
            InternetAddress sender = sourceMsg.From.FirstOrDefault();
            string senderName = MakeSafe(sender?.Name ?? sender?.ToString());







>
>
>
|
|
>
>
>
>
>

>

>
>

>
>

<
>







 







|
|
|
|
|
|







 







<
<
<
<
<







 







<
<
<
<
<
<







336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361

362
363
364
365
366
367
368
369
...
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
...
428
429
430
431
432
433
434





435
436
437
438
439
440
441
...
502
503
504
505
506
507
508






509
510
511
512
513
514
515
                            await work.FolderMessages.AddAsync(folderMessage);
                        }
                        dbMessage = folderMessage.Message;
                        dbMessage.GlobalID = summary.GMailMessageId;
                        dbMessage.DateRetrievedUTC = DateTime.UtcNow;
                        dbMessage.Flags = summary.Flags ?? MessageFlags.None;
                        dbMessage.DateReceived = summary.InternalDate;
                        TimerCollection.Global.Start("PopulateMessageAsync");
                        try
                        {
                            await PopulateMessageAsync(dbMessage, mailMessage, summary.Keywords);
                        }
                        finally
                        {
                            TimerCollection.Global.Stop("PopulateMessageAsync");
                        }

                        // Store all separate entities contained in the mail message
                        TimerCollection.Global.Start("PopulateParticipants");
                        await PopulateParticipantsAsync(work, dbMessage, mailMessage);    // from headers
                        TimerCollection.Global.Stop("PopulateParticipants");
                        TimerCollection.Global.Start("PopulateKeywords");
                        await PopulateKeywordsAsync(work, dbMessage, summary.Keywords, summary.GMailLabels); // from summary
                        TimerCollection.Global.Stop("PopulateKeywords");
                        TimerCollection.Global.Start("PopulateReferences");
                        await PopulateReferencesAsync(work, dbMessage, mailMessage);      // from summary + headers

                        TimerCollection.Global.Stop("PopulateReferences");
                    }
                    await work.SaveChangesAsync();
                }
                catch (Exception ex)
                {
                    if (ex is TaskCanceledException || ex is OperationCanceledException || ex is ServiceNotConnectedException)
                    {
................................................................................
        }

        private async Task<MimeMessage> GetMailMessageAsync(IMessageSummary summary, IMailFolder mailFolder)
        {
            MimeMessage mailMessage;
            try
            {
                TimerCollection.Global.Start("mailFolder.GetMessageAsync");
                try {
                    mailMessage = await mailFolder.GetMessageAsync(summary.UniqueId, _cancellationToken);
                } finally {
                    TimerCollection.Global.Stop("mailFolder.GetMessageAsync");
                }
            }
            catch (FormatException)
            {
                var mailEncoding = Encoding.GetEncoding("ISO-8859-1");
                // Upon failure to parse the message, try to download the entire message stream
                using (Stream mailStream = await mailFolder.GetStreamAsync(summary.UniqueId, 0, (int)summary.Size.Value, _cancellationToken))
                using (StreamReader reader = new StreamReader(mailStream, mailEncoding, true))
................................................................................
                        };
                        mailMessage = await MimeMessage.LoadAsync(options, fixedStream, _cancellationToken);
                    }
                }
            }

            return mailMessage;





        }

        public async Task ClearUnunsedObjectsAsync(bool vacuumDatabase = false)
        {
            using (var work = new UnitOfWork(_cancellationToken))
            {
                await Con.WriteLineAsync("Cleaning up database...", TraceLevel.Verbose);
................................................................................
                    using (var compressedStream = entry.Open())
                        await sourceMsg.WriteToAsync(compressedStream);
                }
                targetMsg.Original = zipStream.ToArray();
            }
            TimerCollection.Global.Stop("ZipArchive");
            // TODO: skip the above if we only have the headers






        } // PopulateMessageAsync

        private static string CreateMessageFilename(MimeMessage sourceMsg, string extension = ".eml")
        {
            string subject = MakeSafe(sourceMsg.Subject);
            InternetAddress sender = sourceMsg.From.FirstOrDefault();
            string senderName = MakeSafe(sender?.Name ?? sender?.ToString());