Esempio n. 1
0
        public void FillPersons(EmailMessage emailMessage)
        {
            if (string.IsNullOrWhiteSpace(emailMessage.Text))
            {
                return;
            }
            var persons = _mailAnalyzeService.Persons(emailMessage.Text);

            if (persons.Any())
            {
                foreach (var contactSummary in emailMessage.From)
                {
                    UpdateContact(persons, contactSummary);
                }

                foreach (var contactSummary in emailMessage.To)
                {
                    UpdateContact(persons, contactSummary);
                }
            }
        }
Esempio n. 2
0
        private void Convert(string file, int i)
        {
            var emailMessage = JsonConvert.DeserializeObject <EmailMessage>(File.ReadAllText(file));
            var doc          = emailMessage.Body;
            var isHtml       = emailMessage.IsBodyHtml;

            if (!string.IsNullOrWhiteSpace(doc))
            {
                File.WriteAllText("test.html", doc);
                var stopwatch = Stopwatch.StartNew();
                stopwatch.Start();
                const int max = 100000;
                if (!emailMessage.IsBodyHtml && emailMessage.Body.Length > max)
                {
                    return;
                }
                if (emailMessage.IsBodyHtml && emailMessage.Body.Length > (max * 2))
                {
                    return;
                }
                var convertHtml = isHtml ? _htmlConverterService.ConvertHtml(doc) : doc;
                if (convertHtml.Length > max)
                {
                    return;
                }

                File.WriteAllText("test.txt", convertHtml);
                var persons = _mailAnalyzeService.Persons(convertHtml);
                if (persons.Any(c => c.Emails.Any(e =>
                {
                    var ok = (e.EndsWith(".ru") || e.EndsWith(".com") || e.EndsWith(".net") || e.EndsWith(".info") || e.EndsWith(".su") ||
                              e.EndsWith(".org") || e.EndsWith(".tech") || e.EndsWith("D297BED0") || e.EndsWith("ae") || e.EndsWith("015d1c70"));
                    if (!ok)
                    {
                        Console.WriteLine(file);
                        Console.WriteLine(e);
                    }

                    return(!ok);
                })))
                {
                    // throw new Exception("криво");
                }

                if (persons.Any())
                {
                    foreach (var contactSummary in emailMessage.From)
                    {
                        UpdateContact(persons, contactSummary);
                    }

                    foreach (var contactSummary in emailMessage.To)
                    {
                        UpdateContact(persons, contactSummary);
                    }
                }

                stopwatch.Stop();
                Statictics.Add(i, stopwatch.ElapsedMilliseconds);

                Console.WriteLine($"{i} {stopwatch.ElapsedMilliseconds}");
            }
        }