Esempio n. 1
0
        public void Write(DataMessage message, XsltTransformation transformation)
        {
            if (message == null || message.Parameters == null || string.IsNullOrEmpty(message.Parameters["EventType"]))
            {
                return;
            }
            messageId = message.Id;


            eventCode = int.Parse(message.Parameters["EventType"]);

            var emailSubscriptions = repository.GetSubscriptions(eventCode, protocolType, message.Id);

            transformation.Load(Resources.EmailTemplate);

            foreach (var emailSubscription in emailSubscriptions)
            {
                Log <PartnerEmailSink> .Info($"Sending email for Message: {message.Id} to {emailSubscription.Email}");

                var attributes = emailSubscription.GeTranformableAttributes();
                attributes.Add("ISIN", message.Parameters["ISIN"]);
                EmailComposer.SendEmail("Product Update",
                                        transformation.Transform(message.Content, attributes),
                                        new List <string> {
                    emailSubscription.Email
                });

                partnerIds.Add(emailSubscription.Id);
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            var rootObject       = new RootObject();
            var checkedGamesData = new Dictionary <string, string>();
            var changedGamesData = new Dictionary <string, string>();

            var mail = new EmailComposer();

            mail.InitializeOutlookComposer();

            var outputHandler = new OutputHandler();

            Console.SetOut(outputHandler);

            InitializePaths();
            UpdateTrackedGameData(ref checkedGamesData, ref changedGamesData);
            UpdateTrackedGameSystemData(checkedGamesData);

            try
            {
                using (StreamReader r = new StreamReader(Path.Combine(dataDirectory, "main_data.json")))
                {
                    var json = r.ReadToEnd();
                    rootObject = JsonConvert.DeserializeObject <RootObject>(json);
                    if (rootObject.Usernames is null)
                    {
                        Console.WriteLine("The list of usernames in the 'main_data.json' file is empty.");
                    }
                    else
                    {
                        UpdateTrackedUserData(rootObject, ref checkedGamesData, changedGamesData);
                    }
                }
            }
            catch (FileNotFoundException)
            {
                //FileNotFoundHandler.AbortProgramToDueMissingCriticalFile("main_data.json", dataDirectory);
            }

            WriteRecentChanges(outputHandler, rootObject);
            rootObject.LastAccess = DateTime.Now;
            rootObject.SaveProperties(Path.Combine(dataDirectory, "main_data.json"));
            try
            {
                mail.SendEmail($"RA Scraping Results, " +
                               $"{rootObject.LastAccess.ToString("yyyy/MM/dd, H:mm tt")}",
                               outputHandler.Output.ToString());
            }
            catch (SmtpException)
            {
                File.WriteAllText(
                    Path.Combine(dataDirectory,
                                 $"error_{rootObject.LastAccess.ToString("yyyy-MM-dd  H,mm tt")}.txt"),
                    outputHandler.Output.ToString());
            }
        }