예제 #1
0
        public ReleaseNoteViewModel(IReleaseNoteRepositories repos, Guid id, IUserNotify notify, ISecurityContext ctx)
        {
            this.repos  = repos;
            this.notify = notify;
            this.ctx    = ctx;

            saveCommand   = ViewModelSource.Create(() => new SaveReleaseNoteCommand(this, repos, notify, ctx));
            shipCommand   = ViewModelSource.Create(() => new ShipReleaseNoteCommand(this, repos, notify, ctx));
            unshipCommand = ViewModelSource.Create(() => new UnshipReleaseNoteCommand(this, repos, notify, ctx));

            ReleaseNotePipes = new PlainPipeBindingList();
            if (id == Guid.Empty)
            {
                NewRailcar();
            }
            else
            {
                ReleaseNote = repos.ReleaseNoteRepo.Get(id);
                if (ReleaseNote == null)
                {
                    log.Error(string.Format("Release Note (id:{0}) does not exist.", id));
                    // TODO: user message? close document?
                }
                else
                {
                    IList <Pipe> pipes = repos.ReleaseNoteRepo.GetReleasedNotePipe(id);
                    foreach (var p in pipes)
                    {
                        ReleaseNotePipes.Add(new PlainPipe(p));
                    }
                }
            }
        }
예제 #2
0
        public ReleaseNoteViewModel(IReleaseNoteRepositories repos, Guid id, IUserNotify notify, ISecurityContext ctx)
        {
            try
            {
                this.repos  = repos;
                this.notify = notify;
                this.ctx    = ctx;

                saveCommand   = ViewModelSource.Create(() => new SaveReleaseNoteCommand(this, repos, notify, ctx));
                shipCommand   = ViewModelSource.Create(() => new ShipReleaseNoteCommand(this, repos, notify, ctx));
                unshipCommand = ViewModelSource.Create(() => new UnshipReleaseNoteCommand(this, repos, notify, ctx));

                ReleaseNotePipes = new PlainPipeBindingList();
                if (id == Guid.Empty)
                {
                    NewRailcar();
                }
                else
                {
                    ReleaseNote = repos.SimpleNoteRepo.Get(id);
                    if (ReleaseNote == null)
                    {
                        log.Error(string.Format("Release Note (id:{0}) does not exist.", id));
                        // TODO: user message? close document?
                    }
                    else
                    {
                        IList <SimplePipe> pipes = repos.SimpleNoteRepo.GetReleasedNotePipe(id);
                        foreach (var p in pipes)
                        {
                            ReleaseNotePipes.Add(new PlainPipe(p));
                        }
                    }
                }
            }
            catch (RepositoryException ex)
            {
                log.Warn(this.GetType().Name + " | " + ex.ToString());
                notify.ShowWarning(Program.LanguageManager.GetString(StringResources.Notification_Error_Db_Message),
                                   Program.LanguageManager.GetString(StringResources.Notification_Error_Db_Header));
            }
        }