Ejemplo n.º 1
0
        private void MailUpdateChange(PstUpdateChange change, IDataManager dataManager, SecurityRepository securityRepository, MailMessage mailMessage, String username, DateTime date)
        {
            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 + ") from " + MailSender.TransformTargetToString(change.TargetBefore) + " to " + MailSender.TransformTargetToString(change.TargetAfter));
            bodyAppendix.AppendLine("COMMENT: " + change.Comment);
            mailMessage.Body += bodyAppendix;
        }
Ejemplo n.º 2
0
        protected void ApplyUpdateChange(PstUpdateChange change, IDataManager manager, Int32 changesetId, Int32 changeId)
        {
            var changeInfo = new BuPortfolioSecurityTargetChangeInfo
                             (
                changeId,
                change.PortfolioId,
                change.SecurityId,
                change.TargetBefore,
                change.TargetAfter,
                changesetId,
                change.Comment
                             );

            manager.InsertPortfolioSecurityTargetChange(changeInfo);

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

            manager.UpdatePortfolioSecurityTarget(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);
        }
Ejemplo n.º 4
0
 public void Resolve(PstUpdateChange change)
 {
     this.applier.ApplyUpdateChange(change, this.manager, this.changesetId, this.changeId);
 }
Ejemplo n.º 5
0
 public void Resolve(PstUpdateChange change)
 {
     this.applier.MailUpdateChange(change, this.manager, this.securityRepository, this.mail, this.username, this.date);
 }