Exemple #1
0
        public ActionResult ClassificationsEdit(int id, int[] item, int[] driver)
        {
            var classificationMapper = new ClassificationMapper();

            try
            {
                foreach (var row in item)
                {
                    var rowId = Array.IndexOf(item, row);

                    var classification = classificationMapper.SelectGpDriver(id, driver[rowId]);

                    if (row > 0)
                    {
                        if (classification == null)
                        {
                            classificationMapper.Insert(id, driver[rowId], row);
                        }
                        else
                        {
                            classificationMapper.Edit(id, driver[rowId], row);
                        }
                    }
                }
            }
            catch (Exception)
            {
                TempData["message-error"] = "Vyskytla se chyba";
                return(RedirectToAction("Classifications", "Gp", new { id = id }));
            }

            TempData["message-success"] = "Výslekdy byly zmeněny";
            return(RedirectToAction("Classifications", "Gp", new { id = id }));
        }
Exemple #2
0
        protected override Task Context()
        {
            _executionContext     = A.Fake <IExecutionContext>();
            _classificationMapper = A.Fake <ClassificationMapper>();
            _snapshotMapper       = A.Fake <ISnapshotMapper>();
            sut = new ClassificationSnapshotTask(_classificationMapper);

            _classifications = new List <Classification>();

            _modelClassification    = new Classification().WithName("classification");
            _subModelClassification = new Classification().WithName("subModelClassification");
            _modelClassification.ClassificationType    = ClassificationType.ObservedData;
            _subModelClassification.ClassificationType = ClassificationType.ObservedData;
            _snapshotClassification = new Snapshots.Classification().WithName("classification");
            _snapshotClassification.Classifiables = new[] { "subject" };
            _subClassification = new Snapshots.Classification().WithName("subClassification");
            _snapshotClassification.Classifications = new[] { _subClassification };

            _classifications.Add(_modelClassification);
            A.CallTo(() => _classificationMapper.MapToSnapshot(_modelClassification, A <ClassificationContext> ._)).Returns(_snapshotClassification);
            A.CallTo(() => _classificationMapper.MapToModel(_snapshotClassification, A <ClassificationSnapshotContext> .That.Matches(x => x.ClassificationType == ClassificationType.ObservedData)))
            .Returns(_modelClassification);

            A.CallTo(() => _classificationMapper.MapToModel(_subClassification, A <ClassificationSnapshotContext> .That.Matches(x => x.ClassificationType == ClassificationType.ObservedData)))
            .Returns(_subModelClassification);

            A.CallTo(() => _executionContext.Resolve <ISnapshotMapper>()).Returns(_snapshotMapper);

            _project = new PKSimProject();

            _snapshotContext = new SnapshotContext(_project, ProjectVersions.V10);
            return(_completed);
        }
Exemple #3
0
        private void buttonGpSave_Click(object sender, EventArgs e)
        {
            try
            {
                var gpMapper = new GpMapper();
                var gp       = gpMapper.SelectGp(_gpId);

                if (gp.Date.AddHours(1) > DateTime.Now)
                {
                    labelError.Text = @"Výsledky nelze vložit, protože neuběhla nejméně 1 hodina od startu. ";
                    return;
                }

                var classificationMapper = new ClassificationMapper();

                foreach (DataGridViewRow row in dataGridView1.Rows)
                {
                    if (ReferenceEquals(row.Cells["Position"].Value, ""))
                    {
                        continue;
                    }

                    var driver = (int)row.Cells["ID"].Value;

                    var position       = (int?)row.Cells["Position"].Value;
                    var classification = classificationMapper.SelectGpDriver(_gpId, driver);

                    if (position == null || position == 0)
                    {
                        continue;
                    }
                    if (classification == null)
                    {
                        classificationMapper.Insert(_gpId, driver, (int)position);
                    }
                    else
                    {
                        classificationMapper.Edit(_gpId, driver, (int)position);
                    }
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
                throw;
            }

            Close();
        }
        public bool OpenRecord(object primaryKey)
        {
            if (primaryKey == null)
            {
                return(false);
            }
            var idGp                 = (int)primaryKey;
            var gpMapper             = new GpMapper();
            var classificationMapper = new ClassificationMapper();
            var gp      = gpMapper.SelectGp(idGp);
            var drivers = new DriversMapper().SelectAll();

            var bindingList = new BindingList <Drivers>(drivers);

            dataGridView1.AutoGenerateColumns = false;
            dataGridView1.Rows.Clear();
            foreach (var driver in bindingList)
            {
                var rowIndex = dataGridView1.Rows.Add();
                var row      = dataGridView1.Rows[rowIndex];

                row.Cells["Position"].Value  = classificationMapper.SelectGpDriver(gp.Id, driver.Id);
                row.Cells["LastName"].Value  = driver.LastName;
                row.Cells["FirstName"].Value = driver.FirstName;
                row.Cells["ID"].Value        = driver.Id;
            }

            if (classificationMapper.SelectGpCount(gp.Id) == 0)
            {
                labelError.Text = @"Výsledky pro tuto GP ještě neexistují.";
            }
            else
            {
                labelError.Text = "";
            }

            labelHeader.Text = @"Zobrazení výsledků GP - " + gp.Name;
            Text             = labelHeader.Text;

            _gpId = idGp;
            gpMapper.GetPrevNextDriver(_gpId, out _prevId, out _nextId);

            buttonGpEdit.Visible = ButtonEnable.TeamsEdit(gp.UserId, new UsersMapper().SelectUser(Logged.CurrentUser.UserRole));

            return(true);
        }
Exemple #5
0
        public ActionResult Classifications(int id)
        {
            var gpMapper = new GpMapper();
            var gp       = gpMapper.SelectGp(id);

            ViewBag.Name = gp.Name;

            gpMapper.GetPrevNextDriver(id, out int?prev, out int?next);
            ViewBag.Prev = prev;
            ViewBag.Next = next;
            ViewBag.Id   = id;

            Dictionary <int, Classification> classifications = new ClassificationMapper().SelectAll(id);

            ViewBag.IfGp = User.Identity.IsAuthenticated && ButtonEnable.GpEdit(gp.UserId, new UsersMapper().SelectUser(User.Identity.Name));

            return(View(classifications));
        }
Exemple #6
0
        protected override Task Context()
        {
            _classificationMapper          = A.Fake <ClassificationMapper>();
            _snapshotMapper                = A.Fake <ISnapshotMapper>();
            _executionContext              = A.Fake <IExecutionContext>();
            _lazyLoadTask                  = A.Fake <ILazyLoadTask>();
            _simulationMapper              = A.Fake <SimulationMapper>();
            _simulationComparisonMapper    = A.Fake <SimulationComparisonMapper>();
            _parameterIdentificationMapper = A.Fake <ParameterIdentificationMapper>();
            _classificationSnapshotTask    = A.Fake <IClassificationSnapshotTask>();
            _qualificationPlanMapper       = A.Fake <QualificationPlanMapper>();
            _creationMetaDataFactory       = A.Fake <ICreationMetaDataFactory>();
            _logger = A.Fake <ILogger>();

            sut = new ProjectMapper(
                _simulationMapper,
                _simulationComparisonMapper,
                _parameterIdentificationMapper,
                _qualificationPlanMapper,
                _executionContext,
                _classificationSnapshotTask,
                _lazyLoadTask,
                _creationMetaDataFactory,
                _logger);


            A.CallTo(() => _executionContext.Resolve <ISnapshotMapper>()).Returns(_snapshotMapper);
            _individual               = new Individual().WithName("IND");
            _compound                 = new Compound().WithName("COMP");
            _event                    = new PKSimEvent().WithName("EVENT");
            _formulation              = new Formulation().WithName("FORM");
            _protocol                 = new SimpleProtocol().WithName("PROTO");
            _population               = new RandomPopulation().WithName("POP");
            _observedData             = new DataRepository().WithName("OD");
            _parameterIdentification  = new OSPSuite.Core.Domain.ParameterIdentifications.ParameterIdentification().WithName("PI").WithId("PI_ID");
            _classifiableObservedData = new ClassifiableObservedData {
                Subject = _observedData
            };
            _classification = new Classification {
                ClassificationType = ClassificationType.ObservedData
            }.WithName("OD Classification");
            _simulationComparison = new IndividualSimulationComparison().WithName("COMP").WithId("SimComp");
            _simulation           = new IndividualSimulation().WithName("IND_SIM").WithId("IndSim");
            _qualificationPlan    = new QualificationPlan().WithName("QP").WithId("QP_ID");
            _project = new PKSimProject();
            _project.AddBuildingBlock(_individual);
            _project.AddBuildingBlock(_compound);
            _project.AddBuildingBlock(_event);
            _project.AddBuildingBlock(_formulation);
            _project.AddBuildingBlock(_protocol);
            _project.AddBuildingBlock(_population);
            _project.AddObservedData(_observedData);
            _project.AddBuildingBlock(_simulation);
            _project.AddClassifiable(_classifiableObservedData);
            _project.AddClassification(_classification);
            _project.AddSimulationComparison(_simulationComparison);
            _project.AddParameterIdentification(_parameterIdentification);
            _project.AddQualificationPlan(_qualificationPlan);

            _compoundSnapshot                              = new Snapshots.Compound();
            _individualSnapshot                            = new Snapshots.Individual();
            _eventSnapshot                                 = new Event();
            _formulationSnapshot                           = new Snapshots.Formulation();
            _protocolSnapshot                              = new Snapshots.Protocol();
            _populationSnapshot                            = new Snapshots.Population();
            _observedDataSnapshot                          = new Snapshots.DataRepository();
            _parameterIdentificationSnapshot               = new ParameterIdentification();
            _observedDataClassificationSnapshot            = new Snapshots.Classification();
            _simulationComparisonSnapshot                  = new SimulationComparison();
            _simulationClassificationSnapshot              = new Snapshots.Classification();
            _comparisonClassificationSnapshot              = new Snapshots.Classification();
            _parameterIdentificationClassificationSnapshot = new Snapshots.Classification();
            _qualificationPlanClassificationSnapshot       = new Snapshots.Classification();
            _qualificationPlanSnapshot                     = new Snapshots.QualificationPlan();
            _simulationSnapshot                            = new Simulation();


            A.CallTo(() => _snapshotMapper.MapToSnapshot(_compound)).Returns(_compoundSnapshot);
            A.CallTo(() => _snapshotMapper.MapToSnapshot(_individual)).Returns(_individualSnapshot);
            A.CallTo(() => _snapshotMapper.MapToSnapshot(_event)).Returns(_eventSnapshot);
            A.CallTo(() => _snapshotMapper.MapToSnapshot(_formulation)).Returns(_formulationSnapshot);
            A.CallTo(() => _snapshotMapper.MapToSnapshot(_protocol)).Returns(_protocolSnapshot);
            A.CallTo(() => _snapshotMapper.MapToSnapshot(_population)).Returns(_populationSnapshot);
            A.CallTo(() => _snapshotMapper.MapToSnapshot(_observedData)).Returns(_observedDataSnapshot);
            A.CallTo(() => _simulationMapper.MapToSnapshot(_simulation, _project)).Returns(_simulationSnapshot);
            A.CallTo(() => _simulationComparisonMapper.MapToSnapshot(_simulationComparison)).Returns(_simulationComparisonSnapshot);
            A.CallTo(() => _parameterIdentificationMapper.MapToSnapshot(_parameterIdentification, _project)).Returns(_parameterIdentificationSnapshot);
            A.CallTo(() => _qualificationPlanMapper.MapToSnapshot(_qualificationPlan)).Returns(_qualificationPlanSnapshot);

            A.CallTo(() => _classificationSnapshotTask.MapClassificationsToSnapshots <ClassifiableObservedData>(_project)).Returns(new[] { _observedDataClassificationSnapshot });
            A.CallTo(() => _classificationSnapshotTask.MapClassificationsToSnapshots <ClassifiableSimulation>(_project)).Returns(new[] { _simulationClassificationSnapshot });
            A.CallTo(() => _classificationSnapshotTask.MapClassificationsToSnapshots <ClassifiableComparison>(_project)).Returns(new[] { _comparisonClassificationSnapshot });
            A.CallTo(() => _classificationSnapshotTask.MapClassificationsToSnapshots <ClassifiableParameterIdentification>(_project)).Returns(new[] { _parameterIdentificationClassificationSnapshot });
            A.CallTo(() => _classificationSnapshotTask.MapClassificationsToSnapshots <ClassifiableQualificationPlan>(_project)).Returns(new[] { _qualificationPlanClassificationSnapshot });

            return(_completed);
        }
Exemple #7
0
        public bool OpenRecord(object primaryKey)
        {
            try
            {
                if (primaryKey == null)
                {
                    return(false);
                }
                _gpId = (int)primaryKey;
                var gpMapper             = new GpMapper();
                var classificationMapper = new ClassificationMapper();
                var results = classificationMapper.SelectAll(_gpId);
                var gp      = gpMapper.SelectGp(_gpId);
                var drivers = new DriversMapper().SelectAll();

                var positions = new PointsMapper().SelectAll();

                var bindingList = new BindingList <Drivers>(drivers);
                dataGridView1.AutoGenerateColumns = false;
                dataGridView1.Rows.Clear();

                foreach (var driver in bindingList)
                {
                    var rowIndex = dataGridView1.Rows.Add();
                    var row      = dataGridView1.Rows[rowIndex];

                    row.Cells["Position"].ValueType = typeof(int);

                    ((DataGridViewComboBoxCell)row.Cells["Position"]).Items.Insert(0, "");

                    foreach (var position in positions)
                    {
                        ((DataGridViewComboBoxCell)row.Cells["Position"]).Items.Insert(position.Position, position.Position);
                    }

                    try
                    {
                        if (results.ContainsKey(driver.Id))
                        {
                            row.Cells["Position"].Value = results[driver.Id].Position;
                        }
                    }
                    catch
                    {
                        // ignored
                    }

                    row.Cells["LastName"].Value  = driver.LastName;
                    row.Cells["FirstName"].Value = driver.FirstName;
                    row.Cells["ID"].Value        = driver.Id;
                }

                labelError.Text = "";
                if (results.Count == 0)
                {
                    labelError.Text += @"Výsledky pro tuto GP ještě neexistují. ";
                }
                if (gp.Date.AddHours(1) > DateTime.Now)
                {
                    labelError.Text += @"Výsledky lze uložit nejdříve 1 hodinu po startu GP. ";
                }

                labelHeader.Text = @"Úprava výsledků GP - " + gp.Name;
                Text             = labelHeader.Text;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }

            return(true);
        }