<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Web;
using Microsoft.WindowsAzure.ServiceRuntime;
using Purchasing.Web.Services;

namespace Purchasing.Web.App_Start
{
    public class VerifyIndexesRole : RoleEntryPoint
    {
        private static readonly IIndexService IndexService = new IndexService(new DbService());
        public override void Run()
        {
            const string pathRoot = @"E:\sitesroot\0\Purchasing.Web\App_Data\Indexes";

            IndexService.SetIndexRoot(pathRoot);

            var mail = new System.Net.Mail.SmtpClient("smtp.ucdavis.edu");
            var message = new System.Net.Mail.MailMessage("<EMAIL>", "<EMAIL>",
                                                          "verify indexes role notificaiton", "");

            while (true)
            {
                Thread.Sleep(TimeSpan.FromMinutes(5));
                try
                {
                    var lastModified = IndexService.LastModified(Indexes.OrderHistory);
                    var sinceLastModified = DateTime.Now - lastModified;

                    message.Body = string.Format("last modified at {0}, which was {1} minutes and {2} seconds ago",
                                                 lastModified, sinceLastModified.Minutes, sinceLastModified.Seconds);

                    //recreate index if it hasn't been modified for at least 6 minutes
                    //this would mean the update timer isn't working
                    if (sinceLastModified > TimeSpan.FromMinutes(6))
                    {
                        IndexService.CreateHistoricalOrderIndex();   
                    }
                }
                catch (Exception ex)
                {
                    message.Body = "error checking/setting index: " + ex.Message;
                }

                mail.Send(message);
            }
        }
    }
}<commit_msg>add stacktrace to the error message<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Web;
using Microsoft.WindowsAzure.ServiceRuntime;
using Purchasing.Web.Services;

namespace Purchasing.Web.App_Start
{
    public class VerifyIndexesRole : RoleEntryPoint
    {
        private static readonly IIndexService IndexService = new IndexService(new DbService());

        public override void Run()
        {
            const string pathRoot = @"E:\sitesroot\0\Purchasing.Web\App_Data\Indexes";

            IndexService.SetIndexRoot(pathRoot);

            var mail = new System.Net.Mail.SmtpClient("smtp.ucdavis.edu");
            var message = new System.Net.Mail.MailMessage("<EMAIL>", "<EMAIL>",
                                                          "verify indexes role notificaiton", "");

            while (true)
            {
                Thread.Sleep(TimeSpan.FromMinutes(5));
                try
                {
                    var lastModified = IndexService.LastModified(Indexes.OrderHistory);
                    var sinceLastModified = DateTime.Now - lastModified;

                    message.Body = string.Format("last modified at {0}, which was {1} minutes and {2} seconds ago",
                                                 lastModified, sinceLastModified.Minutes, sinceLastModified.Seconds);

                    //recreate index if it hasn't been modified for at least 6 minutes
                    //this would mean the update timer isn't working
                    if (sinceLastModified > TimeSpan.FromMinutes(6))
                    {
                        IndexService.CreateHistoricalOrderIndex();
                    }
                }
                catch (Exception ex)
                {
                    message.Body = "error checking/setting index: " + ex.Message + "     " + ex.StackTrace;
                }
                finally
                {
                    mail.Send(message);   
                }
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.08341633466135458, 'fraction_numerical': 0.0034860557768924302, 'mean_word_length': 1.5248271527341295, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7477718', 'n_tokens_mistral': 977, 'n_tokens_neox': 913, 'n_words': 227}