public ComponentNewEditViewModel( IComponentRepositories repos, Guid id, IUserNotify notify, ISecurityContext context) { this.repos = repos; this.notify = notify; this.context = context; try { this.componentTypes = new BindingList <ComponentType>(repos.ComponentTypeRepo.GetAll()); this.Inspectors = repos.RepoInspector.GetAll(); } catch (RepositoryException ex) { log.Warn("ComponentNewEditViewModel " + ex.ToString()); notify.ShowWarning(Program.LanguageManager.GetString(StringResources.Notification_Error_Db_Message), Program.LanguageManager.GetString(StringResources.Notification_Error_Db_Header)); } saveCommand = ViewModelSource .Create(() => new SaveComponentCommand(this, repos, notify, context)); newSaveCommand = ViewModelSource .Create(() => new NewSaveComponentCommand(this, repos, notify, context)); deactivationCommand = ViewModelSource .Create(() => new ComponentDeactivationCommand(this, repos, notify, context)); if (id == Guid.Empty) { NewComponent(); } else { try { this.Component = repos.ComponentRepo.Get(id); } catch (RepositoryException ex) { log.Warn("ComponentNewEditViewModel " + ex.ToString()); notify.ShowWarning(Program.LanguageManager.GetString(StringResources.Notification_Error_Db_Message), Program.LanguageManager.GetString(StringResources.Notification_Error_Db_Header)); } } if (this.Inspectors == null || this.Inspectors.Count <= 0) { log.Warn(string.Format("Componentry (id:{0}) creation: List of Inspectors is NULL or empty", id)); } }
/// <summary> /// Creation of child form. Can be used from outside to pass some Guid of entity and number to newly created forms. /// </summary> /// <param name="formType">exact type of form</param> /// <param name="id">Guid of entity</param> /// <param name="parameters">input parameters passed to the newly created form</param> public ChildForm OpenChildForm(Type formType, List <KeyValuePair <string, object> > parameters, Guid id = default(Guid)) { ChildForm form = null; if (typeof(ChildForm).IsAssignableFrom(formType)) { var forms = GetListChildForm(formType); //search int indexById = GetFormIndex(formType.Name, id); if (indexById >= 0 && forms.Count > 0) // is open { form = forms[indexById]; } if (form != null) { form.Activate(); } else //create new { int index = FindOpenForm(formType.Name, true); if (formType == typeof(ReleaseNoteNewEditXtraForm) && index >= 0)// this type form is open in edit mode { if (id == default(Guid)) { string text = Program.LanguageManager.GetString(StringResources.MainWindow_CloseEditingReleaseNote); notify.ShowWarning(text, ""); form = forms[index]; form.Activate(); } else { string text = Program.LanguageManager.GetString(StringResources.MainWindow_OpenReleaseNoteReadOnly); if (notify.ShowYesNo(text, "")) { form = ShowChildForm(formType, parameters, false); } } } else { form = ShowChildForm(formType, parameters, true); } } } else { var e = new ApplicationException(String.Format("Could not create child form {0} because not of child type.", formType.Name)); log.Error(e.Message); throw e; } return(form); }
private void SetupHeats() { try { heats = new List <Prizm.Domain.Entity.Mill.Heat>(repo.HeatRepo.GetAll().ToList()); } 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)); } }
public void Execute() { try { viewModel.Data = repo.GetPipelineElements( viewModel.PipeNumber, viewModel.CheckedPipeTypes.Select <PipeMillSizeType, string>(x => x.Type).ToArray <string>()); if (viewModel.Data == null || viewModel.Data.Rows.Count <= 0) { log.Warn(string.Format("Data Table for Pipe Report (pipe #{0}) report is NULL or empty", viewModel.PipeNumber)); } var report = new PipeConstructionXtraReport(); report.DataSource = viewModel.PipeReportDataList; report.FootersVisibility = viewModel.IsFooterVisible; report.CreateDocument(); viewModel.PreviewSource = report; RefreshVisualStateEvent(); } 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)); } }
public PartInspectionViewModel(ISession session, IPartInspectionRepository repos, IUserNotify notify, ISecurityContext ctx) { try { this.session = session; this.repos = repos; this.notify = notify; this.ctx = ctx; this.Inspectors = repos.RepoInspector.GetAll(); if(this.Inspectors == null || this.Inspectors.Count <= 0) log.Warn("Incoming Inspection of Componentry: List of Inspectors is NULL or empty"); searchCommand = ViewModelSource.Create(() => new SearchPartForInspectionCommand(this, session, ctx)); saveInspectionTestResultsCommand = ViewModelSource.Create(() => new SaveInspectionTestResultsCommand(repos.RepoInspectionTestResult, this, notify, ctx)); saveAndClearTestResultsCommand = ViewModelSource.Create(() => new SaveAndClearTestResultsCommand(this)); this.Inspectors = repos.RepoInspector.GetAll(); } 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)); } }
public PartInspectionViewModel(ISession session, IPartInspectionRepository repos, IUserNotify notify, ISecurityContext ctx) { try { this.session = session; this.repos = repos; this.notify = notify; this.ctx = ctx; this.Inspectors = repos.RepoInspector.GetAll(); if (this.Inspectors == null || this.Inspectors.Count <= 0) { log.Warn("Incoming Inspection of Componentry: List of Inspectors is NULL or empty"); } searchCommand = ViewModelSource.Create(() => new SearchPartForInspectionCommand(this, session, ctx)); saveInspectionTestResultsCommand = ViewModelSource.Create(() => new SaveInspectionTestResultsCommand(repos.RepoInspectionTestResult, this, notify, ctx)); saveAndClearTestResultsCommand = ViewModelSource.Create(() => new SaveAndClearTestResultsCommand(this)); this.Inspectors = repos.RepoInspector.GetAll(); } 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)); } }
public FirstSetupViewModel(IFirstSetupRepo firstSetupRepo) { try { this.firstSetupRepo = firstSetupRepo; saveCommand = ViewModelSource.Create(() => new FirstSetupSaveCommand(this, firstSetupRepo)); var defaultStation = (WorkstationType)Enum.Parse(typeof(WorkstationType), ConfigurationManager.AppSettings["WorkstationType"]); var defaultProjName = ConfigurationManager.AppSettings["ProjectName"]; if (defaultStation == WorkstationType.Undefined) { defaultStation = WorkstationType.Mill; } project.WorkstationType = defaultStation; project.Title = defaultProjName; project.DocumentSizeLimit = 1024; foreach (Permission permission in firstSetupRepo.PermissionRepo.GetAll()) { SuperUser.Permissions.Add(permission); } admin.Roles = new List <Role>() { SuperUser }; } 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)); } }
public void RefreshFiles(Guid item) { if (item != Guid.Empty) { IList <Prizm.Domain.Entity.File> fileList = new List <Prizm.Domain.Entity.File>(); try { fileList = repos.FileRepo.GetByItem(item); } catch (RepositoryException ex) { log.Warn("ExternalFilesViewModel " + ex.ToString()); notify.ShowWarning(Program.LanguageManager.GetString(StringResources.Notification_Error_Db_Message), Program.LanguageManager.GetString(StringResources.Notification_Error_Db_Header)); } foreach (var dictItem in this.FilesToAttach) { Prizm.Domain.Entity.File file = new Domain.Entity.File() { FileName = dictItem.Value, UploadDate = DateTime.Now, NewName = string.Format("{0}{1}", Directories.FilesToAttachFolder, dictItem.Key) }; fileList.Add(file); } if (fileList != null) { files = new BindingList <Prizm.Domain.Entity.File>(fileList); } else { log.Warn(string.Format("List of attached files for Entity id:{0} is NULL", item)); } } else { if (files == null) { files = new BindingList <Prizm.Domain.Entity.File>(); } } }
public void Execute() { if (Prizm.Main.Common.DateExtension.CheckDiapason(viewModel.StartDate, viewModel.EndDate)) { if (viewModel.TracingMode == TracingModeEnum.TracingByNumber) { IList <AuditLog> results = new List <AuditLog>(); try { results = repo.GetRecordsByNumber(viewModel.Number, viewModel.StartDate, viewModel.EndDate, viewModel.OperationTypes); } catch (RepositoryException ex) { log.Warn("AuditSearchCommandExecute " + ex.ToString()); notify.ShowWarning(Program.LanguageManager.GetString(StringResources.Notification_Error_Db_Message), Program.LanguageManager.GetString(StringResources.Notification_Error_Db_Header)); } viewModel.AuditResults = new BindingList <AuditLog>(results); } else if (viewModel.TracingMode == TracingModeEnum.TracingByUser) { IList <AuditLog> results = new List <AuditLog>(); try { results = repo.GetRecordsByUser(viewModel.SelectedUser, viewModel.StartDate, viewModel.EndDate, viewModel.OperationTypes); } catch (RepositoryException ex) { log.Warn("AuditSearchCommandExecute " + ex.ToString()); notify.ShowWarning(Program.LanguageManager.GetString(StringResources.Notification_Error_Db_Message), Program.LanguageManager.GetString(StringResources.Notification_Error_Db_Header)); } viewModel.AuditResults = new BindingList <AuditLog>(results); } } else { notify.ShowInfo(Program.LanguageManager.GetString(StringResources.WrongDate), Program.LanguageManager.GetString(StringResources.Message_ErrorHeader)); log.Warn("Date limits not valid!" + "Diapason: start date= " + viewModel.StartDate.ToString() + " end date= " + viewModel.EndDate.ToString()); } }
public ComponentNewEditViewModel( IComponentRepositories repos, Guid id, IUserNotify notify, ISecurityContext context) { this.repos = repos; this.notify = notify; this.context = context; try { this.componentTypes = new BindingList<ComponentType>(repos.ComponentTypeRepo.GetAll()); this.Inspectors = repos.RepoInspector.GetAll(); } catch(RepositoryException ex) { log.Warn("ComponentNewEditViewModel " + ex.ToString()); notify.ShowWarning(Program.LanguageManager.GetString(StringResources.Notification_Error_Db_Message), Program.LanguageManager.GetString(StringResources.Notification_Error_Db_Header)); } saveCommand = ViewModelSource .Create(() => new SaveComponentCommand(this, repos, notify, context)); newSaveCommand = ViewModelSource .Create(() => new NewSaveComponentCommand(this, repos, notify, context)); deactivationCommand = ViewModelSource .Create(() => new ComponentDeactivationCommand(this, repos, notify, context)); if (id == Guid.Empty) { NewComponent(); } else { try { this.Component = repos.ComponentRepo.Get(id); } catch(RepositoryException ex) { log.Warn("ComponentNewEditViewModel " + ex.ToString()); notify.ShowWarning(Program.LanguageManager.GetString(StringResources.Notification_Error_Db_Message), Program.LanguageManager.GetString(StringResources.Notification_Error_Db_Header)); } } if(this.Inspectors == null || this.Inspectors.Count <=0) log.Warn(string.Format("Componentry (id:{0}) creation: List of Inspectors is NULL or empty", id)); }
public void Execute() { try { bool noPipe = false; foreach (SimpleRailcar r in viewModel.ReleaseNote.Railcars) { if (r.Pipes.Count == 0) { noPipe = true; } } if (noPipe) { notify.ShowError(Program.LanguageManager.GetString(StringResources.ReleaseNoteNewEdit_PipesAbsent), Program.LanguageManager.GetString(StringResources.Message_ErrorHeader)); return; } if (!noPipe) { foreach (SimpleRailcar r in viewModel.Railcars) { r.IsShipped = true; foreach (var pipe in r.Pipes) { pipe.Status = PipeMillStatus.Shipped; pipe.ToExport = true; } } viewModel.Shipped = true; notify.ShowSuccess(Program.LanguageManager.GetString(StringResources.ReleaseNoteNewEdit_Shipped) + " #" + viewModel.ReleaseNote.Number, Program.LanguageManager.GetString(StringResources.Alert_InfoHeader)); log.Info(string.Format("Shipment is successful. Release Note #{0}, id:{1}.", viewModel.ReleaseNote.Number, viewModel.ReleaseNote.Id)); viewModel.SaveCommand.Execute(); } RefreshVisualStateEvent(); } 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)); } }
/// <summary> /// Gets control operations that can be added for current pipe (based on pipe size type) /// </summary> private void GetAvailableTests() { try { var tests = this.repoMill.RepoPipeTest.GetByMillSizeType(Pipe.Type); if (tests != null) { AvailableTests = new BindingList <PipeTest>(tests); } else { log.Warn(string.Format("List of Pipe Tests for type {0} is NULL.", Pipe.Type)); } } 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)); } }
public void LoadData() { try { GetAllCertificateTypes(); GetAllSeamTypes(); GetAllPipeMillSizeType(); GetAllWelders(); GetAllInspectors(); GetAllPermissions(); GetAllRoles(); GetAllUsers(); GetProjectSettings(); GetAllManufacturers(); GetAllJointOperations(); LoadJointOperationTypes(); GetAllComponentryTypes(); ControlType = new BindingList <EnumWrapper <PipeTestControlType> >(); ResultType = new BindingList <EnumWrapper <PipeTestResultType> >(); foreach (string controlTypeName in Enum.GetNames(typeof(PipeTestControlType))) { if (controlTypeName != Enum.GetName(typeof(PipeTestControlType), PipeTestControlType.Undefined)) { ControlType.Add(new EnumWrapper <PipeTestControlType>() { Value = (PipeTestControlType)Enum.Parse(typeof(PipeTestControlType), controlTypeName) } ); } } foreach (string resultTypeName in Enum.GetNames(typeof(PipeTestResultType))) { if (resultTypeName != Enum.GetName(typeof(PipeTestResultType), PipeTestResultType.Undefined)) { ResultType.Add(new EnumWrapper <PipeTestResultType>() { Value = (PipeTestResultType)Enum.Parse(typeof(PipeTestResultType), resultTypeName) } ); } } } 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)); } }
private void RefreshJointData() { try { if (Joint.FirstElement != null && Joint.SecondElement != null && Joint.Status != Domain.Entity.Construction.JointStatus.Withdrawn && Joint.IsActive) { 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 if (!Joint.IsActive) { GeneratePartDataForInactiveJoint(); } else { log.Warn(string.Format("Joint #{0} do not has connected Parts or is Withdrawn.", Joint.Number)); } var weldResults = this.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 = this.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)); } } 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)); } }
public void Execute() { try { if (!viewModel.ValidatableView.Validate()) { return; } DateTime previousProductionDate = viewModel.Pipe.ProductionDate; var previousPipeMillSizeType = viewModel.PipeMillSizeType; var previousHeat = viewModel.Heat; var previousPurchaseOrder = viewModel.PipePurchaseOrder; viewModel.SavePipeCommand.Execute(); if (viewModel.Number != string.Empty) { viewModel.NewPipe(); viewModel.ProductionDate = previousProductionDate; viewModel.PipeMillSizeType = previousPipeMillSizeType; viewModel.PipeTestResults = viewModel.GetRequired(previousPipeMillSizeType); viewModel.Pipe.PipeTestResult = viewModel.PipeTestResults; foreach (var t in viewModel.Pipe.PipeTestResult) { var insp = (List <Inspector>)viewModel.listOfInspectors.Where(_ => _.Key == t.Operation.Code).FirstOrDefault().Value; if (insp != null) { t.Inspectors = insp; } } viewModel.Heat = previousHeat; viewModel.PipePurchaseOrder = previousPurchaseOrder; viewModel.ModifiableView.IsModified = false; viewModel.ModifiableView.Id = viewModel.Pipe.Id; } RefreshVisualStateEvent(); } 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)); } }
public void Execute() { try { var controlOperations = repo.RepoJointOperation.GetControlOperations(); viewModel.ControlOperations = new BindingList <JointOperation>(controlOperations); var repairOperations = repo.RepoJointOperation.GetRepairOperations(); viewModel.RepairOperations = new BindingList <JointOperation>(repairOperations); } catch (RepositoryException ex) { log.Warn("ExtractOperationsCommand " + ex.ToString()); notify.ShowWarning(Program.LanguageManager.GetString(StringResources.Notification_Error_Db_Message), Program.LanguageManager.GetString(StringResources.Notification_Error_Db_Header)); } }
public void Execute() { try { viewModel.Heats = repo.GetAll(); if (viewModel.Heats == null) { viewModel.Heats = new List <Prizm.Domain.Entity.Mill.Heat>(); } } 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)); } }
public AuditViewModel(IAuditRepository repo, IUserNotify notify) { this.repo = repo; this.notify = notify; try { UsersList = repo.AuditLogRepo.GetAllUsers(); searchCommand = ViewModelSource.Create(() => new AuditSearchCommand(this, repo.AuditLogRepo, notify)); } catch (RepositoryException ex) { log.Warn("AuditViewModel " + ex.ToString()); notify.ShowWarning(Program.LanguageManager.GetString(StringResources.Notification_Error_Db_Message), Program.LanguageManager.GetString(StringResources.Notification_Error_Db_Header)); } }
public AuditViewModel(IAuditRepository repo, IUserNotify notify) { this.repo = repo; this.notify = notify; try { UsersList = repo.AuditLogRepo.GetAllUsers(); searchCommand = ViewModelSource.Create(() => new AuditSearchCommand(this, repo.AuditLogRepo, notify)); } catch(RepositoryException ex) { log.Warn("AuditViewModel " + ex.ToString()); notify.ShowWarning(Program.LanguageManager.GetString(StringResources.Notification_Error_Db_Message), Program.LanguageManager.GetString(StringResources.Notification_Error_Db_Header)); } }
public void Execute() { try { if (repos.PipeRepo.GetByNumber(viewModel.PipeNumber) != null) { viewModel.Pipe = repos.PipeRepo.GetByNumber(viewModel.PipeNumber); if (viewModel.Pipe.Length <= Constants.MinSpoolCut) { notify.ShowError( Program.LanguageManager.GetString(StringResources.Spool_NullSpoolLength), Program.LanguageManager.GetString(StringResources.Spool_CutSpoolFromPipeHeader)); viewModel.ModifiableView.IsEditMode = false; } else { viewModel.ModifiableView.IsEditMode = true; StringBuilder number = new StringBuilder(); int spoolNumber = repos.SpoolRepo.GetAllSpoolFromPipe(viewModel.Spool.PipeNumber).Count + 1; number.Append(viewModel.Spool.PipeNumber + "/" + spoolNumber.ToString()); viewModel.SpoolNumber = number.ToString(); viewModel.InitPipeLenght = viewModel.Pipe.Length; viewModel.editableForm.spoolLength.Properties.MinValue = Constants.MinSpoolCut; viewModel.editableForm.spoolLength.Properties.MaxValue = viewModel.Pipe.Length - Constants.MinSpoolCut; } } else { notify.ShowError( Program.LanguageManager.GetString(StringResources.Spool_WrongPipeNumberForCutting), Program.LanguageManager.GetString(StringResources.Spool_WrongPipeNumberForCuttingHeader)); viewModel.ModifiableView.IsEditMode = false; } RefreshVisualStateEvent(); } 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)); } }
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)); } }
public void Execute() { try { IList <Prizm.Domain.Entity.Construction.Joint> list = repo.QuickSearchByNumber(viewModel.SearchNumber); if (dialog == null) { dialog = new JointSelectDialog(list, viewModel); } else { dialog.SetupForm(list, viewModel); } dialog.ShowDialog(); } 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)); } }
public void Execute() { try { if (Prizm.Main.Common.DateExtension.CheckDiapason(viewModel.WeldDateFrom, viewModel.WeldDateTo)) { viewModel.Data = repo.GetPipelineElements(viewModel.WeldDateFrom, viewModel.WeldDateTo); if (viewModel.Data == null || viewModel.Data.Rows.Count <= 0) { log.Warn("Construction report: Data Table for Weld by Date report is NULL or empty"); } var report = new WeldDateXtraReport(); report.DataSource = viewModel.WeldDateReportDataList; report.FootersVisibility = viewModel.IsFooterVisible; var tool = new ReportPrintTool(report); tool.AutoShowParametersPanel = false; tool.ShowPreview(); RefreshVisualStateEvent(); } else { notify.ShowInfo(Program.LanguageManager.GetString(StringResources.Message_FailureReportDate), Program.LanguageManager.GetString(StringResources.Message_FailureReportDateHeader)); log.Warn("Date limits not valid!" + "Diapason: start date= " + viewModel.WeldDateFrom.ToString() + " end date= " + viewModel.WeldDateTo.ToString()); } } 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)); } }
public MillPipeSearchViewModel( IMillRepository repoMill, IUserNotify notify) { try { this.repoMill = repoMill; this.notify = notify; searchCommand = ViewModelSource.Create <MillPipeSearchCommand>( () => new MillPipeSearchCommand(this, repoMill.RepoPipe, notify)); pipeTypes = repoMill.RepoPipeType.GetAll(); checkedPipeTypes = repoMill.RepoPipeType.GetAll(); LoadStatuses(); } 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)); } }
public MillPipeSearchViewModel( IMillRepository repoMill, IUserNotify notify) { try { this.repoMill = repoMill; this.notify = notify; searchCommand = ViewModelSource.Create<MillPipeSearchCommand>( () => new MillPipeSearchCommand(this, repoMill.RepoPipe, notify)); pipeTypes = repoMill.RepoPipeType.GetAll(); checkedPipeTypes = repoMill.RepoPipeType.GetAll(); LoadStatuses(); } 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)); } }
public void Execute() { try { if (!viewModel.Shipped) { notify.ShowError(Program.LanguageManager.GetString(StringResources.ReleaseNoteNewEdit_NotShipped), Program.LanguageManager.GetString(StringResources.Message_ErrorHeader)); } else { foreach (SimpleRailcar r in viewModel.Railcars) { r.IsShipped = false; foreach (var pipe in r.Pipes) { pipe.Status = PipeMillStatus.ReadyToShip; pipe.ToExport = false; } } viewModel.Shipped = false; notify.ShowSuccess(Program.LanguageManager.GetString(StringResources.ReleaseNoteNewEdit_Unshipped), Program.LanguageManager.GetString(StringResources.Alert_InfoHeader)); viewModel.SaveCommand.Execute(); } RefreshVisualStateEvent(); } 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)); } }
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)); } }
private void PipelineTracing() { try { usedProductList = new List <PartData>(); if (joints == null) { this.joints = repoJoint.GetJointsForTracing().ToList <construct.Joint>(); if (this.joints == null || this.joints.Count <= 0) { log.Warn("Report at Construction: List of Joints is NULL or empty."); } } if (partDataList == null) { var data = repo.GetPipelineElements(SQLProvider.GetQuery(SQLProvider.SQLStatic.GetWeldedParts).ToString()); if (data == null || data.Rows.Count <= 0) { log.Warn("Report at Construction: Data Table of Pieces is NULL or empty."); } this.partDataList = this.FormWeldedParts(data); } graph = new PipelineGraph(partDataList.Count); tracingDataList = new List <TracingData>(); if (partDataList != null) { foreach (var partData in partDataList) { graph.AddPipelineVertex(partData); } foreach (var joint in this.joints) { graph.AddJointEdge(joint); } construct.Joint startJoint = null; construct.Joint endJoint = null; if (viewModel.TracingMode == TracingModeEnum.TracingByKP && viewModel.AllKP.Contains(viewModel.StartPK) && viewModel.AllKP.Contains(viewModel.EndPK)) { startJoint = joints.First <construct.Joint>( x => x.NumberKP == viewModel.StartPK && x.DistanceFromKP == joints .Where <construct.Joint>(y => y.NumberKP == viewModel.StartPK) .Min <construct.Joint>(z => z.DistanceFromKP)); endJoint = joints.Last <construct.Joint>( x => x.NumberKP == viewModel.EndPK && x.DistanceFromKP == joints .Where <construct.Joint>(y => y.NumberKP == viewModel.EndPK) .Max <construct.Joint>(z => z.DistanceFromKP)); } if (endJoint == null && startJoint == null) { startJoint = joints.First <construct.Joint>(x => x.Id == viewModel.StartJoint.Id); endJoint = joints.First <construct.Joint>(x => x.Id == viewModel.EndJoint.Id); } var paths = graph.Pathfinder(startJoint.FirstElement, endJoint.FirstElement); if (paths.Count != 0) { path = graph.ShortestPath(paths); path = graph.RemovalExternalComponents(startJoint, endJoint, path); for (int i = path.Count - 1; i > 0; --i) { var tracingDataItem = new TracingData(path[i].Data, path[i - 1].Data); var commonJoint = path[i].GetCommonJoint(path[i - 1]); tracingDataItem.JointNumber = commonJoint.Data.Number; tracingDataItem.WeldingDate = GetWeldDate(commonJoint.Data); tracingDataList.Add(tracingDataItem); } for (int i = 0; i < path.Count; ++i) { usedProductList.Add(path[i].Data); } PartData firstElement = partDataList.Where(_ => _.Id == startJoint.FirstElement.Id).FirstOrDefault(); PartData secondElement = partDataList.Where(_ => _.Id == endJoint.SecondElement.Id).FirstOrDefault(); var firstTracingDataItem = new TracingData(firstElement, path.Last().Data); firstTracingDataItem.JointNumber = startJoint.Number; firstTracingDataItem.WeldingDate = GetWeldDate(startJoint); tracingDataList.Insert(0, firstTracingDataItem); usedProductList.Add(firstElement); var lastTracingDataItem = new TracingData(path.First().Data, secondElement); lastTracingDataItem.JointNumber = endJoint.Number; lastTracingDataItem.WeldingDate = GetWeldDate(endJoint); tracingDataList.Add(lastTracingDataItem); usedProductList.Add(secondElement); PipelineLenghtCalculation(); } } else { log.Warn(string.Format("List of Pipeline elements is NULL for construction report type: {0}", viewModel.ReportType)); } } 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)); } }
/// <summary> /// helper method to determine the possibility to open/create document. /// Can show questions to user. /// </summary> /// <param name="type">type of document</param> /// <param name="isNew">is entity supposed to be new</param> /// <param name="flags">flags pack</param> /// <param name="editMode">can/should this document to be opened in edit mode.</param> /// <returns></returns> private bool CanOpen(DocumentTypes type, bool isNew, FormFlags flags, out bool editMode) { editMode = !flags.HasFlag(FormFlags.EditAccessDenied) && flags.HasFlag(FormFlags.CanEditAtThisWorkstation); bool canOpen = true; if (flags.HasFlag(FormFlags.EditConflict)) { if (type == DocumentTypes.Settings) { canOpen &= notify.ShowYesNo(Program.LanguageManager.GetString(StringResources.Message_OpenSettingsForViewing), Program.LanguageManager.GetString(StringResources.Message_OpenSettingsForViewingHeader)); } else { canOpen &= notify.ShowYesNo(Program.LanguageManager.GetString(StringResources.Message_OpenFormForViewing), Program.LanguageManager.GetString(StringResources.Message_OpenFormForViewingHeader)); } editMode = false; } if (flags.HasFlag(FormFlags.SingleEditAlreadyOpened)) { string text = string.Empty; if (isNew) { switch (type) { case DocumentTypes.MillReleaseNote: text = Program.LanguageManager.GetString(StringResources.MainWindow_CloseEditingReleaseNote); break; case DocumentTypes.ConstructionJoint: text = Program.LanguageManager.GetString(StringResources.MainWindow_ConstructionJoint); break; default: break; } notify.ShowWarning(text, ""); canOpen = false; } else { switch (type) { case DocumentTypes.MillReleaseNote: text = Program.LanguageManager.GetString(StringResources.MainWindow_OpenReleaseNoteReadOnly); break; case DocumentTypes.ConstructionJoint: text = Program.LanguageManager.GetString(StringResources.MainWindow_OpenConstructionJointReadOnly); break; default: break; } canOpen &= notify.ShowYesNo(text, ""); editMode = false; } } return(canOpen); }
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)); } }
public void Execute() { try { foreach (JointTestResult t in viewModel.JointTestResults) { if (t.Inspectors.Count <= 0) { numberOfOperationWithoutInspectors++; } } if (numberOfOperationWithoutInspectors == 0) { 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]; } notify.ShowInfo( string.Concat(Program.LanguageManager.GetString(StringResources.DuplicateEntity_Message) + result), Program.LanguageManager.GetString(StringResources.DuplicateEntity_MessageHeader)); viewModel.Number = string.Empty; } else { viewModel.Joint.Number = viewModel.Joint.Number.ToUpper(); viewModel.Joint.ToExport = true; repo.BeginTransaction(); repo.RepoJoint.SaveOrUpdate(viewModel.Joint); var filesViewModel = viewModel.FilesFormViewModel; bool fileCopySuccess = true; if (null != filesViewModel) { filesViewModel.FileRepo = repo.FileRepo; viewModel.FilesFormViewModel.Item = viewModel.Joint.Id; if (!viewModel.FilesFormViewModel.TrySaveFiles(viewModel.Joint)) { fileCopySuccess = false; repo.Rollback(); } } if (fileCopySuccess) { repo.Commit(); } repo.RepoJoint.Evict(viewModel.Joint); if (fileCopySuccess) { if (null != filesViewModel) { filesViewModel.DetachFileEntities(); } notify.ShowSuccess( string.Concat(Program.LanguageManager.GetString(StringResources.Joint_Saved), viewModel.Number), Program.LanguageManager.GetString(StringResources.Joint_SavedHeader)); log.Info(string.Format("The entity #{0}, id:{1} has been saved in DB.", viewModel.Joint.Number, viewModel.Joint.Id)); } else { notify.ShowError( Program.LanguageManager.GetString(StringResources.ExternalFiles_NotCopied), Program.LanguageManager.GetString(StringResources.ExternalFiles_NotCopied_Header)); log.Info(string.Format("File for entity #{0}, id:{1} hasn't been saved ", viewModel.Joint.Number, viewModel.Joint.Id)); } viewModel.ModifiableView.IsModified = false; viewModel.ModifiableView.Id = viewModel.Joint.Id; viewModel.ModifiableView.UpdateState(); } } catch (RepositoryException ex) { log.Error(ex.Message); notify.ShowFailure(ex.InnerException.Message, ex.Message); } } else { notify.ShowError( Program.LanguageManager.GetString(StringResources.SelectInspectorsForTestResult), Program.LanguageManager.GetString(StringResources.SelectInspectorsForTestResultHeader)); } } 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)); } }
public void Execute() { try { if (Prizm.Main.Common.DateExtension.CheckDiapason(viewModel.FromDate, viewModel.ToDate)) { repo.Clear(); if (viewModel.Statuses.Count > 0) { bool?status; switch (viewModel.Activity) { case ActivityCriteria.StatusActive: status = true; break; case ActivityCriteria.StatusUnactive: status = false; break; default: status = null; break; } IList <Construction.Joint> list = repo.SearchJoint ( viewModel.Number, viewModel.Statuses, viewModel.FromDate, viewModel.ToDate, viewModel.PegNumber, status, Program.ThisWorkstationType ); list.OrderBy(n => n.Number).ToList(); viewModel.Joints.Clear(); foreach (var item in list) { viewModel.Joints.Add(item); } viewModel.Amount = list.Count(); RefreshVisualStateEvent(); } } else { notify.ShowInfo(Program.LanguageManager.GetString(StringResources.WrongDate), Program.LanguageManager.GetString(StringResources.Message_ErrorHeader)); log.Warn("Date limits not valid!" + "Diapason: start date= " + viewModel.FromDate.ToString() + " end date= " + viewModel.ToDate.ToString()); } } 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)); } }