/// <summary>
        /// Changeset isn't guaranteed because ther could be no changes.
        /// </summary>
        public Changeset TryTransformToChangeset(RootModel root, String username)
        {
            var models  = this.traverser.TraverseGlobe(root.Globe);
            var changes = models
                          .Select(model => this.TryTransformToChangeOnceResolved(root.TargetingType.Id, model))
                          .Where(model => model != null);

            Changeset result;

            if (changes.Any())
            {
                result = new Changeset(
                    root.TargetingType.Id,
                    root.LatestTtbbvChangeset,
                    username,
                    changes
                    );
            }
            else
            {
                result = null;
            }
            return(result);
        }
Пример #2
0
        private void SendNotification(String ttName, String portfolioName, ChangingPsto.Changeset pstoChangeset, ChangingTtbbv.Changeset ttbbvChangeset, ChangingTtbpt.Changeset ttbptChangeset, IDataManager manager, SecurityRepository securityRepository, BasketRepository basketRepository, PortfolioRepository portfolioRepository, string userEmail)
        {
            try
            {
                MailMessage mail = new MailMessage();
                mail.IsBodyHtml = false;

                var pstoChanges  = this.pstoChangesetApplier.PrepareToSend(pstoChangeset, manager, securityRepository, portfolioRepository, portfolioName);
                var ttbbvChanges = this.ttbbvChangesetApplier.PrepareToSend(ttbbvChangeset, manager, securityRepository, basketRepository, ttName);
                var ttbptChanges = this.ttbptChangesetApplier.PrepareToSend(ttbptChangeset, manager, securityRepository, basketRepository, ttName, portfolioName);


                mail.Body    = "The following Asset Allocation changes were made to the Global Active Accounts:\n" + (ttbbvChangeset != null ? String.Join("\n", ttbbvChanges) : "\n") + (ttbptChangeset != null ? String.Join("\n", ttbptChanges) : "\n") + (pstoChangeset != null ? String.Join("\n", pstoChanges) : "");
                mail.Subject = "Targeting: Asset Allocation Changes";
                MailSender.SendTargetingAlert(mail, userEmail);
            }
            catch (Exception e)
            {
                throw new EmailNotificationException("See inner exception for details.", e);
            }
        }