コード例 #1
0
        public JointNewEditViewModel(
            IConstructionRepository repoConstruction,
            IUserNotify notify,
            Guid id,
            Prizm.Data.DAL.IMillReportsRepository adoRepo,
            ISecurityContext ctx)
        {
            this.repoConstruction = repoConstruction;
            this.JointId          = id;
            this.notify           = notify;
            this.adoRepo          = adoRepo;
            this.ctx = ctx;

            #region Commands
            saveOrUpdateJointCommand =
                ViewModelSource.Create(() => new SaveOrUpdateJointCommand(repoConstruction, this, notify, ctx));
            saveJointCommand =
                ViewModelSource.Create(() => new SaveJointCommand(repoConstruction, this, notify, ctx));
            newSaveJointCommand =
                ViewModelSource.Create(() => new NewSaveJointCommand(repoConstruction, this, notify, ctx));
            extractOperationsCommand =
                ViewModelSource.Create(() => new ExtractOperationsCommand(repoConstruction, this, notify));
            jointdeactivationCommand =
                ViewModelSource.Create(() => new JointDeactivationCommand(repoConstruction, this, notify, ctx));
            jointCutCommand =
                ViewModelSource.Create(() => new JointCutCommand(repoConstruction, this, notify));
            quickSearchCommand =
                ViewModelSource.Create(() => new QuickSearchCommand(this, repoConstruction.RepoJoint, notify));
            #endregion
            try
            {
                Inspectors = repoConstruction.RepoInspector.GetAll();
                if (this.Inspectors == null || this.Inspectors.Count <= 0)
                {
                    log.Warn(string.Format("Joint (id:{0}) creation: List of Inspectors is NULL or empty", this.JointId));
                }

                Welders = repoConstruction.RepoWelder.GetAll();
                if (this.Welders == null || this.Welders.Count <= 0)
                {
                    log.Warn(string.Format("Joint (id:{0}) creation: List of Welders is NULL or empty", this.JointId));
                }

                Pieces = adoRepo.GetPipelineElements();
                if (this.Pieces == null || this.Pieces.Rows.Count <= 0)
                {
                    log.Warn(string.Format("Joint (id:{0}) creation: Data Table of Pieces is NULL or empty", this.JointId));
                }

                extractOperationsCommand.Execute();

                if (id == Guid.Empty)
                {
                    NewJoint();
                }
                else
                {
                    this.Joint = repoConstruction.RepoJoint.Get(id);

                    RefreshJointData();
                }
            }
            catch (RepositoryException ex)
            {
                log.Warn("JointNewEditViewModel " + ex.ToString());
                notify.ShowWarning(Program.LanguageManager.GetString(StringResources.Notification_Error_Db_Message),
                                   Program.LanguageManager.GetString(StringResources.Notification_Error_Db_Header));
            }
        }
コード例 #2
0
ファイル: JointNewEditViewModel.cs プロジェクト: horba/prizm
        public JointNewEditViewModel(
            IConstructionRepository repoConstruction,
            IUserNotify notify,
            Guid id,
            Prizm.Data.DAL.IMillReportsRepository adoRepo,
            ISecurityContext ctx)
        {
            this.repoConstruction = repoConstruction;
            this.JointId          = id;
            this.notify           = notify;
            this.adoRepo          = adoRepo;
            this.ctx = ctx;

            #region Commands
            saveOrUpdateJointCommand =
                ViewModelSource.Create(() => new SaveOrUpdateJointCommand(repoConstruction, this, notify, ctx));
            saveJointCommand =
                ViewModelSource.Create(() => new SaveJointCommand(repoConstruction, this, notify, ctx));
            newSaveJointCommand =
                ViewModelSource.Create(() => new NewSaveJointCommand(repoConstruction, this, notify, ctx));
            extractOperationsCommand =
                ViewModelSource.Create(() => new ExtractOperationsCommand(repoConstruction, this));
            jointdeactivationCommand =
                ViewModelSource.Create(() => new JointDeactivationCommand(repoConstruction, this, notify, ctx));
            jointCutCommand =
                ViewModelSource.Create(() => new JointCutCommand(repoConstruction, this, notify));
            #endregion

            Inspectors = repoConstruction.RepoInspector.GetAll();
            if (this.Inspectors == null || this.Inspectors.Count <= 0)
            {
                log.Warn(string.Format("Joint (id:{0}) creation: List of Inspectors is NULL or empty", this.JointId));
            }

            Welders = repoConstruction.RepoWelder.GetAll();
            if (this.Welders == null || this.Welders.Count <= 0)
            {
                log.Warn(string.Format("Joint (id:{0}) creation: List of Welders is NULL or empty", this.JointId));
            }

            Pieces = adoRepo.GetPipelineElements();
            if (this.Pieces == null || this.Pieces.Rows.Count <= 0)
            {
                log.Warn(string.Format("Joint (id:{0}) creation: Data Table of Pieces is NULL or empty", this.JointId));
            }

            extractOperationsCommand.Execute();

            if (id == Guid.Empty)
            {
                NewJoint();
            }
            else
            {
                this.Joint = repoConstruction.RepoJoint.Get(id);

                if (Joint.FirstElement != null &&
                    Joint.SecondElement != null &&
                    Joint.Status != Domain.Entity.Construction.JointStatus.Withdrawn)
                {
                    this.firstElement  = GetPartDataFromList(Joint.FirstElement, GetPart(Joint.FirstElement));
                    this.secondElement = GetPartDataFromList(Joint.SecondElement, GetPart(Joint.SecondElement));

                    Joint.FirstElement  = this.firstElement;
                    Joint.SecondElement = this.secondElement;
                }
                else
                {
                    log.Warn(string.Format("Joint #{0} do not has connected Parts or is Withdrawn.", Joint.Number));
                }

                var weldResults = repoConstruction.RepoJointWeldResult.GetByJoint(this.Joint);
                if (weldResults != null)
                {
                    jointWeldResults = new BindingList <JointWeldResult>(weldResults);
                }
                else
                {
                    log.Warn(string.Format("Joint #{0} do not have Welding Results.", Joint.Number));
                }

                var testResults = repoConstruction.RepoJointTestResult.GetByJoint(this.Joint);
                if (testResults != null)
                {
                    jointTestResults = new BindingList <JointTestResult>(testResults);
                }
                else
                {
                    log.Warn(string.Format("Joint #{0} do not have Test Results.", Joint.Number));
                }
            }
        }