Esempio n. 1
0
        private void MailUpdateChange(PstInsertChange change, IDataManager dataManager, SecurityRepository securityRepository, MailMessage mailMessage, String username, DateTime date)
        {
            this.PortfolioName = change.PortfolioId;
            this.PortfolioName = change.PortfolioId;
            StringBuilder bodyAppendix = new StringBuilder("\n");

            bodyAppendix.AppendLine("---" + date + ", Approved by: " + username + "---");
            var security = securityRepository.FindSecurity(change.SecurityId);

            bodyAppendix.AppendLine(security.Name + "(" + security.ShortName + ") was added to " + MailSender.TransformTargetToString(change.TargetAfter));
            bodyAppendix.AppendLine("COMMENT: " + change.Comment);
            mailMessage.Body += bodyAppendix;
        }
Esempio n. 2
0
        protected void ApplyInsertChange(PstInsertChange change, IDataManager manager, Int32 changesetId, Int32 changeId)
        {
            var changeInfo = new BuPortfolioSecurityTargetChangeInfo
                             (
                changeId,
                change.PortfolioId,
                change.SecurityId,
                null,
                change.TargetAfter,
                changesetId,
                change.Comment
                             );

            manager.InsertPortfolioSecurityTargetChange(changeInfo);

            var pstInfo = new BuPortfolioSecurityTargetInfo(
                change.PortfolioId,
                change.SecurityId,
                change.TargetAfter,
                changeId
                );

            manager.InsertPortfolioSecurityTarget(pstInfo);
        }
        public IEnumerable <IPstChange> TransformItems(String portfolioId, IEnumerable <ItemModel> items)
        {
            var result = new List <IPstChange>();

            foreach (var item in items)
            {
                IPstChange change;
                if (item.Target.InitialValue.HasValue)
                {
                    // update or delete
                    if (item.Target.EditedValue.HasValue && item.Target.EditedValue.Value != 0)
                    {
                        if (CalculationHelper.NoDifference(item.Target.InitialValue.Value, item.Target.EditedValue.Value))
                        {
                            continue;
                        }
                        else
                        {
                            // update
                            change = new PstUpdateChange(
                                portfolioId,
                                item.Security.Id,
                                item.Target.InitialValue.Value,
                                item.Target.EditedValue.Value,
                                item.Target.Comment
                                );
                        }
                    }
                    else
                    {
                        // delete
                        change = new PstDeleteChange(
                            portfolioId,
                            item.Security.Id,
                            item.Target.InitialValue.Value,
                            item.Target.Comment
                            );
                    }
                }
                else
                {
                    // insert or nothing
                    if (item.Target.EditedValue.HasValue)
                    {
                        // insert
                        change = new PstInsertChange(
                            portfolioId,
                            item.Security.Id,
                            item.Target.EditedValue.Value,
                            item.Target.Comment
                            );
                    }
                    else
                    {
                        // nothing, just skip this guy
                        continue;
                    }
                }
                result.Add(change);
            }

            return(result);
        }
Esempio n. 4
0
 public void Resolve(PstInsertChange change)
 {
     this.applier.ApplyInsertChange(change, this.manager, this.changesetId, this.changeId);
 }
Esempio n. 5
0
 public void Resolve(PstInsertChange change)
 {
     this.applier.MailUpdateChange(change, this.manager, this.securityRepository, this.mail, this.username, this.date);
 }