private void RaiseExternalConstructionChanged()
        {
            EntityChangedToken entityChangedToken = new EntityChangedToken(_externalConstructionInstance,
                                                                           EntityChangedToken.EntityChangedAction.Updated);

            _eventAggregator.GetEvent <ExternalConstructionChanged>()
            .Publish(entityChangedToken);
        }
示例#2
0
        public ExternalReport CreateExternalReport()
        {
            Views.ExternalReportCreationDialog creationDialog = new Views.ExternalReportCreationDialog();

            if (creationDialog.ShowDialog() == true)
            {
                EntityChangedToken token = new EntityChangedToken(creationDialog.ExternalReportInstance,
                                                                  EntityChangedToken.EntityChangedAction.Created);
                _eventAggregator.GetEvent <ExternalReportChanged>()
                .Publish(token);
                return(creationDialog.ExternalReportInstance);
            }
            else
            {
                return(null);
            }
        }
示例#3
0
        public Batch CreateBatch()
        {
            Views.BatchCreationDialog batchCreator = new Views.BatchCreationDialog();

            if (batchCreator.ShowDialog() == true)
            {
                EntityChangedToken token = new EntityChangedToken(batchCreator.BatchInstance,
                                                                  EntityChangedToken.EntityChangedAction.Created);
                _eventAggregator.GetEvent <BatchChanged>()
                .Publish(token);
                return(batchCreator.BatchInstance);
            }
            else
            {
                return(null);
            }
        }
示例#4
0
        public Organization CreateNewOrganization()
        {
            StringInputDialog creationDialog = new StringInputDialog
            {
                Title = "Crea nuovo Ente"
            };

            if (creationDialog.ShowDialog() == true)
            {
                Organization output = new Organization
                {
                    Category = "",
                    Name     = creationDialog.InputString
                };
                foreach (OrganizationRole orr in _labDbData.RunQuery(new OrganizationRolesQuery()))
                {
                    OrganizationRoleMapping tempORM = new OrganizationRoleMapping
                    {
                        IsSelected = false,
                        RoleID     = orr.ID
                    };

                    output.RoleMapping.Add(tempORM);
                }

                output.Create();

                EntityChangedToken token = new EntityChangedToken(output,
                                                                  EntityChangedToken.EntityChangedAction.Created);
                _eventAggregator.GetEvent <OrganizationChanged>()
                .Publish(token);

                return(output);
            }
            else
            {
                return(null);
            }
        }
示例#5
0
        public Organization CreateNewOrganization()
        {
            StringInputDialog creationDialog = new StringInputDialog
            {
                Title = "Crea nuovo Ente"
            };

            if (creationDialog.ShowDialog() == true)
            {
                Organization output = new Organization
                {
                    Name = creationDialog.InputString
                };
                foreach (OrganizationRole orr in _lInstData.RunQuery(new OrganizationRolesQuery()))
                {
                    OrganizationRoleMapping tempORM = new OrganizationRoleMapping
                    {
                        IsSelected         = false,
                        OrganizationRoleID = orr.ID
                    };

                    output.RoleMappings.Add(tempORM);
                }

                _lInstData.Execute(new InsertEntityCommand <LInstContext>(output));

                EntityChangedToken token = new EntityChangedToken(output,
                                                                  EntityChangedToken.EntityChangedAction.Created);
                _eventAggregator.GetEvent <EntityChanged>()
                .Publish(token);

                return(output);
            }
            else
            {
                return(null);
            }
        }
示例#6
0
        public ExternalReportEditViewModel(IEventAggregator aggregator,
                                           IDataService <LabDbEntities> labDbData,
                                           IReportService reportService)
        {
            _labDbData       = labDbData;
            _editMode        = false;
            _eventAggregator = aggregator;
            _reportService   = reportService;

            AddBatchCommand = new DelegateCommand(
                () =>
            {
                Batch tempBatch;

                BatchPickerDialog batchPicker = new BatchPickerDialog();
                if (batchPicker.ShowDialog() == true)
                {
                    tempBatch = _labDbData.RunQuery(new BatchQuery()
                    {
                        Number = batchPicker.BatchNumber
                    });
                    _instance.AddBatch(tempBatch);
                    RefreshTestRecords();
                    ResultColumnCollection = _instance.GetResultPresentationColumns();
                }
            },
                () => _instance != null && EditMode);

            AddFileCommand = new DelegateCommand(
                () =>
            {
                OpenFileDialog fileDialog = new OpenFileDialog
                {
                    InitialDirectory = UserSettings.ExternalReportPath,
                    Multiselect      = true
                };

                if (fileDialog.ShowDialog() == DialogResult.OK)
                {
                    foreach (string pth in fileDialog.FileNames)
                    {
                        ExternalReportFile temp = new ExternalReportFile();
                        temp.Path             = pth;
                        temp.Description      = "";
                        temp.ExternalReportID = _instance.ID;

                        temp.Create();
                    }

                    RaisePropertyChanged("ReportFiles");
                }
            },
                () => EditMode);

            AddMethodCommand = new DelegateCommand <MethodVariant>(
                mtd =>
            {
                _instance.AddTestMethod(mtd);

                _instance.MethodVariants.Add(mtd);
                RaisePropertyChanged("MethodVariantList");

                RefreshTestRecords();
            },
                mtd => EditMode);

            OpenBatchCommand = new DelegateCommand(
                () =>
            {
                NavigationToken token = new NavigationToken(MaterialViewNames.BatchInfoView,
                                                            _selectedRecord.Batch);
                _eventAggregator.GetEvent <NavigationRequested>().Publish(token);
            },
                () => _selectedRecord != null);

            OpenFileCommand = new DelegateCommand(
                () =>
            {
                System.Diagnostics.Process.Start(_selectedFile.Path);
            },
                () => _selectedFile != null);

            RemoveBatchCommand = new DelegateCommand(
                () =>
            {
                _selectedRecord.Delete();
                SelectedRecord = null;
                RefreshTestRecords();
                ResultColumnCollection = _instance.GetResultPresentationColumns();
            },
                () => _selectedRecord != null && EditMode);

            RemoveFileCommand = new DelegateCommand(
                () =>
            {
                _selectedFile.Delete();
                SelectedFile = null;
            },
                () => _selectedFile != null && EditMode);

            RemoveMethodCommand = new DelegateCommand <MethodVariant>(
                mtd =>
            {
                _instance.RemoveTestMethodVariant(mtd);

                _instance.MethodVariants.Remove(mtd);
                RaisePropertyChanged("MethodVariantList");

                RefreshTestRecords();
            },
                mtd => EditMode);

            SaveCommand = new DelegateCommand(
                () =>
            {
                _instance.Update(true);
                EditMode = false;

                EntityChangedToken token = new EntityChangedToken(_instance,
                                                                  EntityChangedToken.EntityChangedAction.Updated);

                _eventAggregator.GetEvent <ExternalReportChanged>()
                .Publish(token);
            },
                () => _editMode);

            StartEditCommand = new DelegateCommand(
                () =>
            {
                EditMode = true;
            },
                () => !_editMode && CanModify);
        }