Пример #1
0
        public void Execute()
        {
            if (!viewModel.ValidatableView.Validate())
            {
                return;
            }

            if (!DateCheck())
            {
                notify.ShowInfo(Program.LanguageManager.GetString(StringResources.WrongDate),
                                Program.LanguageManager.GetString(StringResources.Message_ErrorHeader));
                log.Warn("Date limits not valid!");
                return;
            }

            if (viewModel.Joint.LoweringDate == DateTime.MinValue)
            {
                viewModel.Joint.LoweringDate = null;
            }

            var joints = repo.RepoJoint.GetActiveByNumber(viewModel.Joint);

            foreach (var joint in joints)
            {
                repo.RepoJoint.Evict(joint);
            }

            if (joints != null && joints.Count > 0)
            {
                notify.ShowInfo(
                    string.Concat(Program.LanguageManager.GetString(StringResources.Joint_Duplicate), viewModel.Number),
                    Program.LanguageManager.GetString(StringResources.Joint_DuplicateHeader));
                viewModel.Number = string.Empty;
            }
            else
            {
                if (viewModel.Joint.Status == Domain.Entity.Construction.JointStatus.Withdrawn)
                {
                    viewModel.SaveOrUpdateJointCommand.Execute();
                }
                else if (viewModel.MakeTheConnection())
                {
                    viewModel.SaveOrUpdateJointCommand.Execute();
                }
                else
                {
                    notify.ShowInfo(
                        Program.LanguageManager.GetString(StringResources.Joint_IncorrectDiameter),
                        Program.LanguageManager.GetString(StringResources.Joint_IncorrectDiameterHeader));
                }

                viewModel.NewJoint();
            }

            RefreshVisualStateEvent();
        }
Пример #2
0
        public void Execute()
        {
            try
            {
                var duplicateNumber = duplicateNumberRepo.GetAllActiveDuplicateEntityByNumber(viewModel.Number, viewModel.Joint.Id).Distinct(new DuplicateNumberEntityComparer()).ToList();

                String result = string.Empty;

                if (duplicateNumber != null && duplicateNumber.Count > 0)
                {
                    for (int i = 0; i <= duplicateNumber.Count - 1; i++)
                    {
                        DuplicateNumberEntityType translate = (DuplicateNumberEntityType)Enum.Parse(typeof(DuplicateNumberEntityType),
                                                                                                    duplicateNumber[i].EntityType);
                        result = result + viewModel.localizedAllType[(int)((object)translate) - 1] + (i < duplicateNumber.Count - 1 ? ", " : "");
                    }

                    notify.ShowInfo(
                        string.Concat(Program.LanguageManager.GetString(StringResources.DuplicateEntity_Message) + result),
                        Program.LanguageManager.GetString(StringResources.DuplicateEntity_MessageHeader));
                    viewModel.Number = string.Empty;
                }
                else
                {
                    if (!viewModel.ValidatableView.Validate())
                    {
                        return;
                    }

                    if (!DateCheck())
                    {
                        notify.ShowInfo(Program.LanguageManager.GetString(StringResources.WrongDate),
                                        Program.LanguageManager.GetString(StringResources.Message_ErrorHeader));
                        log.Warn("Date limits not valid!");
                        return;
                    }

                    if (viewModel.Joint.LoweringDate == DateTime.MinValue)
                    {
                        viewModel.Joint.LoweringDate = null;
                    }

                    numberOfWeldOperationWithoutWelders = 0;
                    foreach (JointWeldResult w in viewModel.JointWeldResults)
                    {
                        if (w.Welders.Count <= 0 &&
                            w.Operation.Type == Prizm.Domain.Entity.Setup.JointOperationType.Weld)
                        {
                            numberOfWeldOperationWithoutWelders++;
                        }
                    }

                    numberOfControlOperationWithoutInspectors = 0;
                    foreach (JointTestResult t in viewModel.JointTestResults)
                    {
                        if (t.Inspectors.Count <= 0)
                        {
                            numberOfControlOperationWithoutInspectors++;
                        }
                    }

                    if (numberOfWeldOperationWithoutWelders == 0)
                    {
                        if (numberOfControlOperationWithoutInspectors == 0)
                        {
                            var joints = repo.RepoJoint.GetActiveByNumber(viewModel.Joint);

                            foreach (var joint in joints)
                            {
                                repo.RepoJoint.Evict(joint);
                            }

                            if (joints != null && joints.Count > 0)
                            {
                                notify.ShowInfo(
                                    string.Concat(Program.LanguageManager.GetString(StringResources.Joint_Duplicate), viewModel.Number),
                                    Program.LanguageManager.GetString(StringResources.Joint_DuplicateHeader));
                                viewModel.Number = string.Empty;
                            }
                            else
                            {
                                if (viewModel.Joint.Status == Domain.Entity.Construction.JointStatus.Withdrawn)
                                {
                                    viewModel.SaveOrUpdateJointCommand.Execute();

                                    viewModel.RemovePartDataFromList(viewModel.Joint.FirstElement);
                                    viewModel.RemovePartDataFromList(viewModel.Joint.SecondElement);
                                }
                                else if (viewModel.MakeTheConnection())
                                {
                                    viewModel.SaveOrUpdateJointCommand.Execute();

                                    viewModel.RemovePartDataFromList(viewModel.Joint.FirstElement);
                                    viewModel.RemovePartDataFromList(viewModel.Joint.SecondElement);
                                }
                                else
                                {
                                    notify.ShowInfo(
                                        Program.LanguageManager.GetString(StringResources.Joint_IncorrectDiameter),
                                        Program.LanguageManager.GetString(StringResources.Joint_IncorrectDiameterHeader));

                                    log.Info(string.Format("There are no suitable diameters or wall thicknesses for the joint #{0}, id:{1} formation",
                                                           viewModel.Joint.Number,
                                                           viewModel.Joint.Id));
                                }

                                viewModel.NewJoint();
                                viewModel.ModifiableView.Id         = viewModel.Joint.Id;
                                viewModel.ModifiableView.IsModified = false;
                            }

                            RefreshVisualStateEvent();
                        }
                        else
                        {
                            notify.ShowError(
                                Program.LanguageManager.GetString(StringResources.SelectInspectorsForTestResult),
                                Program.LanguageManager.GetString(StringResources.SelectInspectorsForTestResultHeader));
                            numberOfControlOperationWithoutInspectors = 0;

                            log.Warn(string.Format("There are no inspectors for appropriate control operations for the joint #{0}, id:{1} formation",
                                                   viewModel.Joint.Number,
                                                   viewModel.Joint.Id));
                        }
                    }
                    else
                    {
                        notify.ShowError(
                            Program.LanguageManager.GetString(StringResources.SelectWeldersForOperation),
                            Program.LanguageManager.GetString(StringResources.SelectWeldersForOperationHeader));
                        numberOfWeldOperationWithoutWelders = 0;

                        log.Warn(string.Format("There are no welders for appropriate weld operations for the joint #{0}, id:{1} formation",
                                               viewModel.Joint.Number,
                                               viewModel.Joint.Id));
                    }
                }
            }
            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));
            }
        }
Пример #3
0
        public void Execute()
        {
            if (!DateCheck())
            {
                notify.ShowInfo(Program.LanguageManager.GetString(StringResources.WrongDate),
                                Program.LanguageManager.GetString(StringResources.Message_ErrorHeader));
                log.Warn("Date limits not valid!");
                return;
            }

            foreach (JointWeldResult w in viewModel.JointWeldResults)
            {
                if (w.Welders.Count <= 0)
                {
                    numberOfWeldOperationWithoutWelders++;
                }
            }

            foreach (JointTestResult t in viewModel.JointTestResults)
            {
                if (t.Inspectors.Count <= 0)
                {
                    numberOfControlOperationWithoutInspectors++;
                }
            }
            if (viewModel.ValidatableView.Validate())
            {
                if (numberOfWeldOperationWithoutWelders == 0)
                {
                    if (numberOfControlOperationWithoutInspectors == 0)
                    {
                        if (viewModel.Joint.LoweringDate == DateTime.MinValue)
                        {
                            viewModel.Joint.LoweringDate = null;
                        }
                        var joints = repo.RepoJoint.GetActiveByNumber(viewModel.Joint);
                        foreach (var joint in joints)
                        {
                            repo.RepoJoint.Evict(joint);
                        }
                        if (joints != null && joints.Count > 0)
                        {
                            notify.ShowInfo(
                                string.Concat(Program.LanguageManager.GetString(StringResources.Joint_Duplicate), viewModel.Number),
                                Program.LanguageManager.GetString(StringResources.Joint_DuplicateHeader));
                            viewModel.Number = string.Empty;
                        }
                        else
                        {
                            numberOfWeldOperationWithoutWelders       = 0;
                            numberOfControlOperationWithoutInspectors = 0;

                            if (viewModel.Joint.Status == Domain.Entity.Construction.JointStatus.Withdrawn)
                            {
                                viewModel.SaveOrUpdateJointCommand.Execute();
                            }
                            else if (viewModel.MakeTheConnection())
                            {
                                viewModel.SaveOrUpdateJointCommand.Execute();
                            }
                            else
                            {
                                notify.ShowInfo(
                                    Program.LanguageManager.GetString(StringResources.Joint_IncorrectDiameter),
                                    Program.LanguageManager.GetString(StringResources.Joint_IncorrectDiameterHeader));
                            }
                        }
                        RefreshVisualStateEvent();
                    }
                    else
                    {
                        notify.ShowError(
                            Program.LanguageManager.GetString(StringResources.SelectInspectorsForTestResult),
                            Program.LanguageManager.GetString(StringResources.SelectInspectorsForTestResultHeader));
                        numberOfControlOperationWithoutInspectors = 0;
                    }
                }
                else
                {
                    notify.ShowError(
                        Program.LanguageManager.GetString(StringResources.SelectWeldersForOperation),
                        Program.LanguageManager.GetString(StringResources.SelectWeldersForOperationHeader));
                    numberOfWeldOperationWithoutWelders = 0;
                }
            }
        }