Inheritance: ViewModelBase, IDisposable, ISupportModifiableView
Esempio n. 1
0
 public SpoolDeactivationCommand(ISpoolRepositories repo, SpoolViewModel viewModel, IUserNotify notify, ISecurityContext ctx)
 {
     this.repo      = repo;
     this.viewModel = viewModel;
     this.notify    = notify;
     this.ctx       = ctx;
 }
 public EditPipeForCutCommand(SpoolViewModel viewModel, ISpoolRepositories repos, IUserNotify notify, ISecurityContext ctx)
 {
     this.viewModel = viewModel;
     this.repos     = repos;
     this.notify    = notify;
     this.ctx       = ctx;
 }
Esempio n. 3
0
        public SpoolsXtraForm(Guid id, string number)
        {
            this.id = id;

            InitializeComponent();
            SetControlsTextLength();
            viewModel = (SpoolViewModel)Program.Kernel.Get <SpoolViewModel>(new ConstructorArgument("id", id));
            viewModel.ModifiableView = this;
            pipeNumber.SetAsIdentifier();
            spoolNumber.SetAsIdentifier();
            if (number != string.Empty)
            {
                viewModel.SpoolNumber = number;
            }
            SetAlwaysReadOnly(pipeLength);
            if (id == Guid.Empty)
            {
                SetAlwaysEditable(pipeNumber);
            }
            else
            {
                this.Text = Program.LanguageManager.GetString(StringResources.Spool_EditDocumentHeader);
                SetAlwaysReadOnly(pipeNumber);
            }
            IsEditMode = true;//do not remove until IsEditMode logic is changed
            IsEditMode = ctx.HasAccess(global::Domain.Entity.Security.Privileges.EditSpool);

            CannotOpenForViewing = id == Guid.Empty;
        }
 public EditPipeForCutCommand(SpoolViewModel viewModel, ISpoolRepositories repos, IUserNotify notify, ISecurityContext ctx)
 {
     this.viewModel = viewModel;
     this.repos = repos;
     this.notify = notify;
     this.ctx = ctx;
 }
 public SpoolDeactivationCommand(ISpoolRepositories repo, SpoolViewModel viewModel, IUserNotify notify, ISecurityContext ctx)
 {
     this.repo = repo;
     this.viewModel = viewModel;
     this.notify = notify;
     this.ctx = ctx;
 }
        public void TestSaveCommand()
        {
            var modifiableView = new Mock<IModifiable>();
            var notify = new Mock<IUserNotify>();
            var ctx = new Mock<ISecurityContext>();
            var spoolRepo = new Mock<ISpoolRepository>();
            var pipeRepo = new Mock<IPipeRepository>();
            var inspectorRepo = new Mock<IInspectorRepository>();

            var spool = new Prizm.Domain.Entity.Construction.Spool();
            var pipe = new Prizm.Domain.Entity.Mill.Pipe();

            pipeRepo.Setup(x => x.GetAvailableForCutPipes()).Returns(new List<Prizm.Domain.Entity.Mill.Pipe>());

            var spoolRepos = new Mock<ISpoolRepositories>();

            spoolRepos.SetupGet(_ => _.PipeRepo).Returns(pipeRepo.Object);
            spoolRepos.SetupGet(_ => _.RepoInspector).Returns(inspectorRepo.Object);
            spoolRepos.SetupGet(_ => _.SpoolRepo).Returns(spoolRepo.Object);


            modifiableView.SetupGet(x => x.IsModified).Returns(false);


            var viewModel = new SpoolViewModel(
                spoolRepos.Object,
                Guid.Empty,
                notify.Object,
                ctx.Object);

            viewModel.Spool = spool;
            viewModel.Pipe = pipe;
            viewModel.InspectionTestResults =
                new BindingList<InspectionTestResult>() { new InspectionTestResult()
                    {Status = PartInspectionStatus.Pending}};

            viewModel.ModifiableView = modifiableView.Object;

            var command = new SaveSpoolCommand(
                viewModel,
                spoolRepos.Object,
                notify.Object,
                ctx.Object);

            viewModel.SpoolLength = 200;
            viewModel.InitPipeLenght = 1000;
            viewModel.Pipe.Length = 800;
            viewModel.Pipe.Number = "Test";
            viewModel.Spool.Number = "Test";

            command.Execute();

            spoolRepos.Verify(_ => _.BeginTransaction(), Times.Once());
            spoolRepo.Verify(_ => _.SaveOrUpdate(It.IsAny<Prizm.Domain.Entity.Construction.Spool>()), Times.Once());
            spoolRepos.Verify(_ => _.Commit(), Times.Once());
            spoolRepo.Verify(_ => _.Evict(It.IsAny<Prizm.Domain.Entity.Construction.Spool>()), Times.Once());
        }
Esempio n. 7
0
        public SpoolsXtraForm(Guid id, string number)
        {
            this.Id = id;

            InitializeComponent();
            SetControlsTextLength();
            viewModel = (SpoolViewModel)Program.Kernel.Get<SpoolViewModel>(new ConstructorArgument("id", id));
            viewModel.ModifiableView = this;
            pipeNumber.SetAsLookUpIdentifier();
            spoolNumber.SetAsLookUpIdentifier();
            if(number != string.Empty)
            {
                viewModel.SpoolNumber = number;
            }
            SetAlwaysReadOnly(pipeLength);

            if(id == Guid.Empty)
            {
                SetAlwaysEditable(pipeNumber);
            }
            else
            {
                this.Text = Program.LanguageManager.GetString(StringResources.Spool_EditDocumentHeader);
                SetAlwaysReadOnly(pipeNumber);
                if (Program.ThisWorkstationType == Domain.Entity.Setup.WorkstationType.Master)
                {
                    SetAlwaysReadOnly(spoolNumber);
                    SetAlwaysReadOnly(spoolLength);
                    SetAlwaysReadOnly(inspectionHistory);
                }
                else 
                {
                    SetConditional(inspectionHistory, delegate(bool editMode)
                    {
                        return (viewModel.Spool.ConstructionStatus != PartConstructionStatus.Welded); 
                    });

                    SetConditional(spoolNumber, delegate(bool editMode)
                    {
                        return (viewModel.SpoolIsActive);
                    });

                    SetConditional(spoolLength, delegate(bool editMode)
                    {
                        return (viewModel.SpoolIsActive);
                    });
                    SetConditional(pipeNumber, delegate(bool editMode)
                    {
                        return (viewModel.SpoolIsActive);
                    });
                }

            }
            IsEditMode = true;//do not remove until IsEditMode logic is changed
            IsEditMode = ctx.HasAccess(global::Domain.Entity.Security.Privileges.EditSpool);

            CannotOpenForViewing = id == Guid.Empty;

            viewModel.editableForm = this;
            spoolLength.SetMask(Constants.PositiveDigitMask);
            spoolLength.Properties.MinValue = Constants.MinSpoolCut;
            spoolLength.Properties.MaxValue = viewModel.InitPipeLenght - Constants.MinSpoolCut;

        }
Esempio n. 8
0
 private void SpoolsXtraForm_FormClosed(object sender, FormClosedEventArgs e)
 {
     commandManager.Dispose();
     viewModel.Dispose();
     viewModel = null;
 }
Esempio n. 9
0
 private void SpoolsXtraForm_FormClosed(object sender, FormClosedEventArgs e)
 {
     commandManager.Dispose();
     viewModel.Dispose();
     viewModel = null;
 }
Esempio n. 10
0
        public SpoolsXtraForm(Guid id, string number)
        {
            this.Id = id;

            InitializeComponent();
            SetControlsTextLength();
            viewModel = (SpoolViewModel)Program.Kernel.Get <SpoolViewModel>(new ConstructorArgument("id", id));
            viewModel.ModifiableView = this;
            pipeNumber.SetAsLookUpIdentifier();
            spoolNumber.SetAsLookUpIdentifier();
            if (number != string.Empty)
            {
                viewModel.SpoolNumber = number;
            }
            SetAlwaysReadOnly(pipeLength);

            if (id == Guid.Empty)
            {
                SetAlwaysEditable(pipeNumber);
            }
            else
            {
                this.Text = Program.LanguageManager.GetString(StringResources.Spool_EditDocumentHeader);
                SetAlwaysReadOnly(pipeNumber);
                if (Program.ThisWorkstationType == Domain.Entity.Setup.WorkstationType.Master)
                {
                    SetAlwaysReadOnly(spoolNumber);
                    SetAlwaysReadOnly(spoolLength);
                    SetAlwaysReadOnly(inspectionHistory);
                }
                else
                {
                    SetConditional(inspectionHistory, delegate(bool editMode)
                    {
                        return(viewModel.Spool.ConstructionStatus != PartConstructionStatus.Welded);
                    });

                    SetConditional(spoolNumber, delegate(bool editMode)
                    {
                        return(viewModel.SpoolIsActive);
                    });

                    SetConditional(spoolLength, delegate(bool editMode)
                    {
                        return(viewModel.SpoolIsActive);
                    });
                    SetConditional(pipeNumber, delegate(bool editMode)
                    {
                        return(viewModel.SpoolIsActive);
                    });
                }
            }
            IsEditMode = true;//do not remove until IsEditMode logic is changed
            IsEditMode = ctx.HasAccess(global::Domain.Entity.Security.Privileges.EditSpool);

            CannotOpenForViewing = id == Guid.Empty;

            viewModel.editableForm = this;
            spoolLength.SetMask(Constants.PositiveDigitMask);
            spoolLength.Properties.MinValue = Constants.MinSpoolCut;
            spoolLength.Properties.MaxValue = viewModel.InitPipeLenght - Constants.MinSpoolCut;
        }
Esempio n. 11
0
 public EditPipeForCutCommand(SpoolViewModel viewModel, ISpoolRepositories repos, IUserNotify notify)
 {
     this.viewModel = viewModel;
     this.repos     = repos;
     this.notify    = notify;
 }