コード例 #1
0
        public void Apply(Int32 calculationId, Changeset changeset, IDataManager manager)
        {
            var latestChangeSet = manager.GetLatestPortfolioSecurityTargetChangeSet();

            if (changeset.LatestChangeset.Id < latestChangeSet.Id)
            {
                throw new ValidationException(
                          new ErrorIssue("User \"" + latestChangeSet.Username + "\" modified the P-S-T composition on " + latestChangeSet.Timestamp + ".")
                          );
            }

            var changesetIdRange = manager.ReservePortfolioSecurityTargetChangesetIds(1);

            if (!changesetIdRange.MoveNext())
            {
                throw new ApplicationException("There is no ID reserved for the P-S-T changeset.");
            }
            var changesetId = changesetIdRange.Current;


            var changesetInfo = new BuPortfolioSecurityTargetChangesetInfo(
                changesetId,
                changeset.Username,
                DateTime.Now, /* is going to be ignored */
                calculationId
                );

            manager.InsertPortfolioSecurityTargetChangeset(changesetInfo);

            var changes       = changeset.Changes;
            var changeIdRange = manager.ReservePortfolioSecurityTargetChangeIds(changes.Count());

            foreach (var change in changes)
            {
                if (!changeIdRange.MoveNext())
                {
                    throw new ApplicationException("There is no ID reserved for the P-S-T change.");
                }
                var changeId = changeIdRange.Current;

                var resolver = new Apply_IPstChangeResolver(this, manager, changesetId, changeId);
                change.Accept(resolver);
            }
        }
コード例 #2
0
        public MailMessage PrepareToSend(Changeset changeset, IDataManager manager, SecurityRepository securityRepository)
        {
            var result = new MailMessage();

            result.IsBodyHtml = false;

            var date = DateTime.Now;

            foreach (var change in changeset.Changes)
            {
                var resolver = new Mail_IPSTChangeResolver(this, manager, securityRepository, result, changeset.Username, date);
                change.Accept(resolver);
            }

            result.Body = "The following changes were made to " + this.PortfolioName + "\n\n" + result.Body;

            result.Subject = "Targeting: Stock Selection changes in " + this.PortfolioName;
            return(result);
        }
コード例 #3
0
        public Changeset TryTransformToChangeset(String username, RootModel root)
        {
            var items   = root.Items;
            var changes = this.TransformItems(root.PortfolioId, items);


            Changeset result;

            if (changes.Any())
            {
                result = new Changeset(
                    root.LatestChangeset,
                    username,
                    changes
                    );
            }
            else
            {
                result = null;
            }

            return(result);
        }