Пример #1
0
        private IEnumerable <object> anatomyAndPhysiologyFor(Individual individual)
        {
            var report        = new List <object>();
            var allParameters = _containerTask.CacheAllChildrenSatisfying <IParameter>(individual, valueShouldBeExportedForAnatomy);

            if (!allParameters.Any())
            {
                report.Add(PKSimConstants.UI.Default);
                return(report);
            }

            var dataTable = new DataTable {
                TableName = PKSimConstants.UI.AnatomyAndPhysiology
            };

            dataTable.AddColumn(PKSimConstants.UI.Parameter);
            dataTable.AddColumn(PKSimConstants.UI.Value);
            dataTable.AddColumn(PKSimConstants.UI.DefaultValue);

            foreach (var parameter in allParameters)
            {
                var row = dataTable.NewRow();
                row[PKSimConstants.UI.Parameter]    = _fullPathDisplayResolver.FullPathFor(parameter);
                row[PKSimConstants.UI.Value]        = ParameterMessages.DisplayValueFor(parameter);
                row[PKSimConstants.UI.DefaultValue] = ParameterMessages.DisplayValueFor(parameter, parameter.DefaultValue.GetValueOrDefault(parameter.Value));

                dataTable.Rows.Add(row);
            }

            var table     = new Table(dataTable.DefaultView, new Text(dataTable.TableName));
            var reference = new Reference(table);
            var text      = new Text(PKSimConstants.UI.AnatomyAndPhysiologyText, reference);

            report.Add(text);
            report.Add(table);
            return(report);
        }
Пример #2
0
        /// <summary>
        /// Formula:
        /// DefectDensity(changed) = (DefectCount * 1000) / LOCChanged;
        ///
        /// Expected data table format:
        /// {
        ///   "datatable": [
        ///     ["Product", "Defects/KLOCC"],
        ///     ["Team1", 0.1],
        ///     ["Team2", 0.034]
        ///   ]
        /// }
        /// </summary>
        public void GenerateDefectDensityChangedByProduct()
        {
            log.Info("Generating: Code defect density (changed) by product ...");

            DataTable dataTable = new DataTable();

            dataTable.AddColumn(new Column("string", "Product"));
            dataTable.AddColumn(new Column("number", "Defects/KLOCC"));

            var query = EagleEyeSettingsReader.Settings.Products
                        .GroupJoin(
                GetValidRecords(),
                product => product,
                record => record.CreatorProductName,
                (product, matching) => new { ProductName = product, Records = matching.ToList() }
                );

            foreach (var item in query)
            {
                ReviewsStatistics stat = new ReviewsStatistics(item.Records);
                var totalDefectCount   = stat.TotalDefectCount;
                var totalLOCChanged    = stat.TotalLOCChanged;

                double density = 0;
                if (totalLOCChanged != 0)
                {
                    density = Math.Round((double)(totalDefectCount * 1000) / totalLOCChanged, decimalPlaces);
                }

                Row row = new Row(item.ProductName, density);
                dataTable.AddRow(row);
            }

            EagleEyePlatformApi.EditDataTable(EagleEyeSettingsReader.Settings.CodeDefectDensityChanged.ChartId, dataTable);

            log.Info("Generating: Code defect density (changed) by product ... Done");
        }
Пример #3
0
        private DataTable createSelectionTableFor(CategorialParameterIdentificationRunMode categorialRunMode, IReadOnlyList <CategoryDTO> calculationMethodCategories, IReadOnlyList <ISimulation> simulations)
        {
            var dataTable = new DataTable();

            dataTable.AddColumns <string>(Constants.CategoryOptimizations.COMPOUND, Constants.CategoryOptimizations.CATEGORY, Constants.CategoryOptimizations.CATEGORY_DISPLAY,
                                          Constants.CategoryOptimizations.CALCULATION_METHOD, Constants.CategoryOptimizations.CALCULATION_METHOD_DISPLAY);

            dataTable.AddColumn <bool>(Constants.CategoryOptimizations.VALUE);

            var compounds = compoundsFromSimulations(simulations, categorialRunMode.AllTheSame);

            compounds.Each(compound => addCategories(categorialRunMode, compound, calculationMethodCategories, dataTable));

            return(dataTable);
        }
Пример #4
0
        private object parameterRangeTable(IEnumerable <ParameterRange> parameterRanges)
        {
            var dataTable = new DataTable {
                TableName = PKSimConstants.UI.PopulationParameterRanges
            };

            dataTable.AddColumn(PKSimConstants.UI.Parameter);
            dataTable.AddColumn(PKSimConstants.UI.MinValue);
            dataTable.AddColumn(PKSimConstants.UI.MaxValue);
            dataTable.AddColumn(PKSimConstants.UI.Unit);

            foreach (var parameterRange in parameterRanges)
            {
                var row = dataTable.NewRow();
                row[PKSimConstants.UI.Parameter] = parameterRange.ParameterDisplayName;
                row[PKSimConstants.UI.MinValue]  = parameterRange.MinValueInDisplayUnit;
                row[PKSimConstants.UI.MaxValue]  = parameterRange.MaxValueInDisplayUnit;
                row[PKSimConstants.UI.Unit]      = parameterRange.Unit;

                dataTable.Rows.Add(row);
            }

            return(dataTable);
        }
        private DataTable createPKAnalysesDataToExport(PopulationSimulation populationSimulation)
        {
            var dataTable = new DataTable(populationSimulation.Name);

            if (!populationSimulation.HasPKAnalyses)
            {
                return(dataTable);
            }

            var pkAnalyses = populationSimulation.PKAnalyses;

            dataTable.AddColumn <int>(CoreConstants.SimulationResults.INDIVIDUAL_ID);
            dataTable.AddColumn <string>(CoreConstants.SimulationResults.QUANTITY_PATH);
            dataTable.AddColumn <string>(CoreConstants.SimulationResults.PARAMETER);
            dataTable.AddColumn <string>(CoreConstants.SimulationResults.VALUE);
            dataTable.AddColumn <string>(CoreConstants.SimulationResults.UNIT);

            dataTable.BeginLoadData();
            foreach (var pkParameter in pkAnalyses.All())
            {
                var parameter = pkParameter;
                var unit      = _displayUnitRetriever.PreferredUnitFor(parameter);
                parameter.Values.Each((value, index) =>
                {
                    var row = dataTable.NewRow();
                    row[CoreConstants.SimulationResults.INDIVIDUAL_ID] = index;
                    row[CoreConstants.SimulationResults.QUANTITY_PATH] = parameter.QuantityPath;
                    row[CoreConstants.SimulationResults.PARAMETER]     = parameter.Name;
                    row[CoreConstants.SimulationResults.VALUE]         = parameter.ConvertToUnit(value, unit).ConvertedTo <string>();
                    row[CoreConstants.SimulationResults.UNIT]          = unit.Name;
                    dataTable.Rows.Add(row);
                });
            }
            dataTable.EndLoadData();
            return(dataTable);
        }
Пример #6
0
        public DataTable CreateNormalData(double mean, double std, double?min = null, double?max = null, int numberOfData = 300)
        {
            var gaussTable         = new DataTable();
            var normalDistribution = new NormalDistribution(mean, std);
            var randomGenerator    = new RandomGenerator();

            gaussTable.AddColumn <double>(Constants.X);
            gaussTable.AddColumn <double>(Constants.Y);

            var minToUse = min ?? mean - 4 * std;
            var maxToUse = max ?? mean + 4 * std;

            for (int i = 0; i < numberOfData; i++)
            {
                var x   = randomGenerator.UniformDeviate(minToUse, maxToUse);
                var y   = normalDistribution.ProbabilityDensityFor(x);
                var row = gaussTable.NewRow();
                row[Constants.X] = x;
                row[Constants.Y] = y;
                gaussTable.Rows.Add(row);
            }

            return(gaussTable);
        }
Пример #7
0
        private DataTable generateEmptySimulationParameterDataTable()
        {
            var dt = new DataTable();

            dt.AddColumn(_path);
            dt.AddColumn(_name);
            dt.AddColumn <double>(_value);
            dt.AddColumn(_formula);
            dt.AddColumn(_rhsFormula);
            dt.AddColumn(_unit);
            dt.AddColumn(_description);
            dt.TableName = AppConstants.Captions.Parameters;
            return(dt);
        }
Пример #8
0
        public void AddRow_CellInteger_Serialized()
        {
            var dt = new DataTable();

            dt.AddColumn(ColumnType.Number);


            dt.AddRow(Enumerable.Range(1, 1).Select(x => new Cell(x)));

            var json = dt.ToJson();

            var jelem  = JsonHelper.Deserialize(json);
            var jValue = jelem["rows"][0]["c"][0]["v"];

            Assert.IsTrue((int)jValue == 1);
        }
Пример #9
0
        internal DataTable GetStatistics()
        {
            var dt              = new DataTable();
            var col0_testName   = dt.AddColumn(TableHeader.TestName);
            var col1_metric     = dt.AddColumn(TableHeader.Metric);
            var col2_iterations = dt.AddColumn(TableHeader.Iterations);
            var col3_average    = dt.AddColumn(TableHeader.AVG);
            var col4_stdevs     = dt.AddColumn(TableHeader.SD);
            var col5_min        = dt.AddColumn(TableHeader.MIN);
            var col6_max        = dt.AddColumn(TableHeader.MAX);

            foreach (var testModel in Collection)
            {
                foreach (var metric in testModel.Performance.Metrics)
                {
                    var values = testModel.Performance.IterationModels
                                 .Where(iter => iter.Iteration.ContainsKey(metric.Name))
                                 .Select(iter => iter.Iteration[metric.Name]);

                    if (values.Count() == 0) // Cannot compute statistics when there are not results (e.g. user only ran a subset of all tests).
                    {
                        continue;
                    }

                    // Skip the warmup run.
                    if (values.Count() > 1)
                    {
                        values = values.Skip(1);
                    }

                    var avg     = values.Average();
                    var stdev_s = Math.Sqrt(values.Sum(x => Math.Pow(x - avg, 2)) / (values.Count() - 1));
                    var max     = values.Max();
                    var min     = values.Min();

                    var newRow = dt.AppendRow();
                    newRow[col0_testName] = testModel.Name;
                    newRow[col1_metric]   = metric.DisplayName;

                    newRow[col2_iterations] = values.Count().ToString();
                    newRow[col3_average]    = avg.ToString();
                    newRow[col4_stdevs]     = stdev_s.ToString();
                    newRow[col5_min]        = min.ToString();
                    newRow[col6_max]        = max.ToString();
                }
            }

            return(dt);
        }
Пример #10
0
        private DataTable generateEmptyMoleculeParameterDataTable()
        {
            var dt = new DataTable();

            dt.AddColumn <string>(_name);

            dt.AddColumn(_path);
            dt.AddColumn <double>(_initialValue);
            dt.AddColumn(_formula);
            dt.AddColumn(_unit);
            dt.AddColumn <double>(_scaleDivisor);
            dt.AddColumn(_description);
            dt.TableName = AppConstants.Captions.MoleculeStartValues;
            return(dt);
        }
Пример #11
0
        /// <summary>
        /// 将一个数据行复制到一个新的数据行
        /// </summary>
        /// <param name="fromDataRow">来源数据行</param>
        /// <param name="toDataRow">要复制的数据行</param>
        public static void CopyTo(this DataRow fromDataRow, DataRow toDataRow)
        {
            //得到来源数据表
            DataTable fromTable = fromDataRow.Table;
            //得到目标数据表
            DataTable toTable = toDataRow.Table;

            //遍历来源数据表的所有列
            foreach (DataColumn column in fromTable.Columns)
            {
                //给目标数据表增加相应的列
                toTable.AddColumn(column.ColumnName, column.DataType);
                //取出刚刚增加的那一列
                DataColumn toColumn = toTable.Columns[column.ColumnName];
                //对目标数据行进行赋值
                toDataRow[toColumn] = RowUtil.Get(fromDataRow, toColumn.DataType, toColumn.ColumnName);
            }
        }
Пример #12
0
 /// <summary>
 /// 给数据表添加字段
 /// </summary>
 /// <param name="from">要添加字段的数据表</param>
 /// <param name="columnName">要添加的字段</param>
 /// <param name="columnType">要添加的字段的类型</param>
 public static void AddColumn(this DataTable from, string columnName, Type columnType)
 {
     //如果数据表中已经有这个字段了,就直接返回
     if (from.Columns.Contains(columnName))
     {
         return;
     }
     //如果字段类型是可空的,就按默认的方式添加字段
     if (columnType.FullName.IndexOf("System.Nullable`1") == 0)
     {
         from.AddColumn(columnName);
     }
     else
     {
         //否则就添加字段并设置为指定类型
         from.Columns.Add(columnName, columnType);
     }
 }
        public DataTable MapFrom(GlobalPKAnalysis globalPKAnalysis, bool addMetaData = false)
        {
            var dataTable = new DataTable(PKSimConstants.UI.GlobalPKAnalyses);

            dataTable.AddColumn(PKSimConstants.PKAnalysis.ParameterDisplayName);
            dataTable.AddColumn(PKSimConstants.PKAnalysis.Compound);
            dataTable.AddColumn <double>(PKSimConstants.PKAnalysis.Value);
            dataTable.AddColumn(PKSimConstants.PKAnalysis.Unit);

            if (addMetaData)
            {
                dataTable.AddColumn(PKSimConstants.PKAnalysis.ParameterName);
                dataTable.AddColumn(PKSimConstants.PKAnalysis.Description);
                dataTable.AddColumn(PKSimConstants.PKAnalysis.Warning);
            }

            foreach (var parameterName in globalPKAnalysis.AllPKParameterNames)
            {
                foreach (var compoundName in globalPKAnalysis.CompoundNames)
                {
                    var parameter = globalPKAnalysis.PKParameter(compoundName, parameterName);
                    if (parameter == null)
                    {
                        continue;
                    }

                    var info = _representationInfoRepository.InfoFor(parameter);
                    var row  = dataTable.NewRow();

                    row[PKSimConstants.PKAnalysis.ParameterDisplayName] = info.DisplayName;
                    row[PKSimConstants.PKAnalysis.Compound]             = compoundName;
                    row[PKSimConstants.PKAnalysis.Value] = parameter.ValueInDisplayUnit;
                    row[PKSimConstants.PKAnalysis.Unit]  = parameter.DisplayUnit;

                    if (addMetaData)
                    {
                        row[PKSimConstants.PKAnalysis.ParameterName] = parameter.Name;
                        row[PKSimConstants.PKAnalysis.Warning]       = parameter.Validate().Message;
                        row[PKSimConstants.PKAnalysis.Description]   = info.Description;
                    }

                    dataTable.Rows.Add(row);
                }
            }

            return(dataTable);
        }
Пример #14
0
        public void AddRow_CellBoolean_Serialized()
        {
            var dt = new DataTable();

            dt.AddColumn(ColumnType.Boolean);

            dt.AddRow(new List <Cell> {
                new Cell(true)
            });

            var json = dt.ToJson(true);

            var jelem    = JsonHelper.Deserialize(json);
            var jrowElem = jelem["rows"][0];
            var jcElem   = jrowElem["c"];

            Assert.IsTrue(bool.Parse((string)jcElem[0]["v"]));
        }
Пример #15
0
        public void AddRow_CellDateTime_Serialized()
        {
            var dt = new DataTable();

            dt.AddColumn(ColumnType.Datetime);

            var date = new DateTime(2000, 1, 1, 12, 30, 15);

            dt.AddRow(new List <Cell> {
                new Cell(date)
            });

            var json = dt.ToJson(true);

            var jelem    = JsonHelper.Deserialize(json);
            var jValElem = jelem["rows"][0]["c"][0]["v"];

            Assert.IsTrue(string.Compare(jValElem.ToString(), "Date(2000, 0, 1, 12, 30, 15)", CultureInfo.InvariantCulture, CompareOptions.IgnoreCase | CompareOptions.IgnoreSymbols) == 0);
        }
Пример #16
0
        public void AddRow_CellDate_Serialized()
        {
            var dt = new DataTable();

            dt.AddColumn(ColumnType.Date);

            var date = new DateTime(2000, 1, 1, 12, 30, 15);

            dt.AddRow(new List <Cell> {
                new Cell(date)
            });

            var json = dt.ToJson();

            var jelem    = JsonHelper.Deserialize(json);
            var jValElem = jelem["rows"][0]["c"][0]["v"];

            Assert.IsTrue((string)jValElem == "Date(2000, 0, 1)");
        }
        protected override void AddSpecificChartColumns(DataTable dataTable, CurveData <RangeXValue, RangeYValue> curveData, bool exportForPivot)
        {
            _xValueColumn               = curveData.XAxis.Caption;
            _yValueColumn               = curveData.YAxis.Caption;
            _yLowerPercentileColumn     = CoreConstants.CompositeNameFor(PKSimConstants.UI.LowerPercentile, _yValueColumn);
            _yUpperPercentileColumn     = CoreConstants.CompositeNameFor(PKSimConstants.UI.UpperPercentile, _yValueColumn);
            _xMinimumColumn             = CoreConstants.CompositeNameFor(PKSimConstants.UI.Minimum, _xValueColumn);
            _xMaximumColumn             = CoreConstants.CompositeNameFor(PKSimConstants.UI.Maximum, _xValueColumn);
            _xNumberOfIndividualsColumn = PKSimConstants.UI.NumberOfIndividuals;

            dataTable.AddColumn <float>(_xMinimumColumn);
            dataTable.AddColumn <float>(_xValueColumn);
            dataTable.AddColumn <float>(_xMaximumColumn);
            dataTable.AddColumn <float>(_xNumberOfIndividualsColumn);
            dataTable.AddColumn <float>(_yLowerPercentileColumn);
            dataTable.AddColumn <float>(_yValueColumn);
            dataTable.AddColumn <float>(_yUpperPercentileColumn);
        }
        private DataColumn createRelatedColumnFor(DataTable dataTable, DataColumn dataColumn, AuxiliaryType auxiliaryType, string caption)
        {
            if (!dataColumn.ContainsRelatedColumn(auxiliaryType))
            {
                return(null);
            }

            var realatedColumn = dataColumn.GetRelatedColumn(AuxiliaryType.ArithmeticStdDev);

            if (realatedColumn == null)
            {
                return(null);
            }

            var errCol = dataTable.AddColumn <float>(realatedColumn.Name);

            errCol.SetUnit(realatedColumn.DataInfo.DisplayUnitName);
            errCol.SetNotes(new[] { caption });
            return(realatedColumn);
        }
Пример #19
0
        private void refreshLegend()
        {
            var legendDataTable = new DataTable();

            for (var i = 0; i < NUMBER_OF_LEGEND_CELLS; i++)
            {
                legendDataTable.AddColumn(i.ToString());
            }

            var row = legendDataTable.NewRow();

            row[FIRST_CELL]         = -_maxValue;
            row[QUARTER_CELL]       = -_maxValue / 2;
            row[HALF_CELL]          = 0;
            row[THREE_QUARTER_CELL] = _maxValue / 2;
            row[LAST_CELL]          = _maxValue;
            legendDataTable.Rows.Add(row);

            legendGridControl.DataSource = legendDataTable;
        }
Пример #20
0
        private static DataTable CreateLookupDataTable(IEnumerable <LightLookup> lookupData)
        {
            DataTable table = new DataTable();

            table.AddColumn <int>(Id);
            table.AddColumn <string>(RepeatableB);
            table.AddColumn <string>(RepeatableC);
            table.AddColumn <string>(RepeatableD);
            table.AddColumn <decimal>(RepeatableF);
            table.AddColumn <decimal>(RepeatableG);

            PopulateDataTable(table, lookupData);

            return(table);
        }
      protected override void Context()
      {
         _editObservedDataTask = A.Fake<IEditObservedDataTask>();
         _view = A.Fake<IDataRepositoryDataView>();
         _dataRepositoryTask = A.Fake<IDataRepositoryTask>();
         _commandCollector = A.Fake<ICommandCollector>();
         sut = new DataRepositoryDataPresenter(_view, _dataRepositoryTask, _editObservedDataTask);
         sut.InitializeWith(_commandCollector);

         //common setup
         _dataRepository = new DataRepository();
         _dataTable = new DataTable();
         A.CallTo(() => _dataRepositoryTask.ToDataTable(_dataRepository, false, true, true)).Returns(new[] {_dataTable});

         var col = _dataTable.AddColumn<float>("test");
         col.ExtendedProperties.Add(Constants.DATA_REPOSITORY_COLUMN_ID, "col");
         _baseGrid = new BaseGrid("base", "base", Constants.Dimension.NO_DIMENSION) {Values = new ArraySegment<float>()};
         _dim = A.Fake<IDimension>();
         _col = new DataColumn("col", "col", _dim, _baseGrid) {Values = new ArraySegment<float>()};
         _dataRepository.Add(_baseGrid);
         _dataRepository.Add(_col);
      }
        protected override void PerformSpecificTransformationOnPivotedTable(DataTable pivotTable)
        {
            //column xValueColumn was used as string in order to allow correct pivotation. We need the value as double for the export
            if (!pivotTable.Columns.Contains(_xValueColumn))
            {
                return;
            }

            var column = pivotTable.Columns[_xValueColumn];
            var xValueColumnAsString = string.Format("{0}AsString", _xValueColumn);

            column.ColumnName = xValueColumnAsString;

            //make the column the first column of the pivot table
            pivotTable.AddColumn <float>(_xValueColumn).SetOrdinal(0);
            foreach (DataRow row in pivotTable.Rows)
            {
                row[_xValueColumn] = row.ValueAt <float>(xValueColumnAsString);
            }

            pivotTable.Columns.Remove(column);
        }
Пример #23
0
        public void AddColumn_NoArgs_Serialized()
        {
            var dt = new DataTable();

            dt.AddColumn();

            var json = dt.ToJson();

            var jelem = JsonHelper.Deserialize(json);

            Assert.AreEqual(2, jelem.Count);           //cols and rows

            Assert.AreEqual(0, jelem["rows"].Count()); // no rows
            Assert.AreEqual(1, jelem["cols"].Count()); // one column

            var jCol = jelem["cols"][0];

            Assert.IsNotEmpty((string)jCol["id"]);
            Assert.AreEqual("string", (string)jCol["type"]);
            Assert.IsNull(jCol["label"]);
            Assert.IsNull(jCol["role"]);
        }
Пример #24
0
        private static DataTable GetCallLogBufferTable()
        {
            DataTable tblCallLogBuffer = new DataTable("tblCallLogBuffer");

            Dictionary <string, string> columns = new Dictionary <string, string>()
            {
                { "MethodId", "System.Int32" },
                { "ExecutionDuration", "System.Float" },
                { "CalledAt", "System.DateTime" },
                { "ApplicationId", "System.Int32" },
                { "HandledByIpAddress", "System.String" },
                { "HostIpAddress", "System.String" },
                { "ClientIpAddress", "System.String" }
            };

            foreach (KeyValuePair <string, string> column in columns)
            {
                tblCallLogBuffer.AddColumn(column.Key, column.Value);
            }

            return(tblCallLogBuffer);
        }
        public static DataTable GenerateRedirectionReport(ICollection <Resource> resources)
        {
            DataTable table = new DataTable("Redirection");

            table.AddColumn("Status code", typeof(string), 11);
            table.AddColumn("Source URL", typeof(string), 85);
            table.AddColumn("Target URL", typeof(string), 50);
            table.AddColumn("Final status code", typeof(string), 11);
            table.AddColumn("Referenced by types", typeof(string), 14);
            table.AddColumn("Referenced by URLs", typeof(string), 85);

            foreach (Resource resource in resources.Where(x => x.Status == ResourceStatus.Processed && x.References.Any(y => y.Type == ResourceReferenceTypes.Redirection)))
            {
                Resource redirectedResource = FollowRedirection(resource);

                // Récupère la liste de tous les types de contenus qui pointent sur cette resource
                var referencedByContent = resource.ReferencedBy
                                          .Select(x => x.Source.ContentType)            // On récupère le type de contenu de chaque référence
                                          .Distinct()                                   // Élimination des doublons
                                          .Where(x => x != ResourceContentType.Unknown) // On ne veut pas avoir le type Unknown
                                          .OrderBy(x => x);                             // Mettre en ordre (de code)

                string redirectedUrl = (redirectedResource == resource) ? "" : redirectedResource.Url.AbsoluteUri;

                var referencedByUrl = String.Join(", ", resource.ReferencedBy.Take(9).Select(x => x.Source.Url.AbsoluteUri)) + (resource.ReferencedBy.Count > 9 ? ", ..." : "");

                table.Rows.Add(
                    GenerateStatusName(resource),
                    resource.Url.AbsoluteUri,
                    redirectedUrl,
                    GenerateStatusName(redirectedResource),
                    String.Join(",", referencedByContent),
                    referencedByUrl);
            }

            return(table);
        }
        public static DataTable GenerateCachingReport(ICollection <Resource> resources)
        {
            DataTable table = new DataTable("Caching");

            table.AddColumn("Content type", typeof(string), 11);
            table.AddColumn("URL", typeof(string), 85);
            table.AddColumn("Cache control", typeof(string), 13);
            table.AddColumn("Has ETAG", typeof(string), 10);
            table.AddColumn("Last modified", typeof(DateTime), 20, "yyyy-mm-dd hh:mm:ss");
            table.AddColumn("Expires", typeof(DateTime), 20, "yyyy-mm-dd hh:mm:ss");

            foreach (Resource resource in resources.Where(x => x.HttpStatus == HttpStatusCode.OK))
            {
                table.Rows.Add(
                    resource.ContentType.ToString(),
                    resource.Url.AbsoluteUri,
                    resource.Headers.TryGetValue("cache-control"),
                    String.IsNullOrWhiteSpace(resource.Headers.TryGetValue("ETag")) ? "No" : "Yes",
                    TryParseDate(resource.Headers.TryGetValue("last-modified")),
                    TryParseDate(resource.Headers.TryGetValue("expires")));
            }

            return(table);
        }
Пример #27
0
        private IEnumerable <object> calculatedAlternatives(Compound compound, string groupName, string columnName, string parameterName, string description, Func <ICompoundAlternativeTask, Func <Compound, IEnumerable <IParameter> > > calculatedParameters)
        {
            var parameterGroup        = compound.ParameterAlternativeGroup(groupName);
            var table                 = new DataTable(groupDisplayName(groupName));
            var calcualtedAlternative = parameterGroup.AllAlternatives.First();

            table.AddColumns <string>(PKSimConstants.UI.Experiment, PKSimConstants.UI.Lipophilicity);
            table.AddColumn <double>(columnName);


            bool needsDefault = (parameterGroup.AllAlternatives.Count() > 1);

            if (needsDefault)
            {
                table.AddColumn <bool>(PKSimConstants.UI.IsDefault);
            }

            bool needsDescription = _tracker.Settings.Verbose && parameterGroup.AllAlternatives.Any(x => !string.IsNullOrEmpty(x.Description));

            if (needsDescription)
            {
                table.AddColumn(PKSimConstants.UI.Description);
            }

            DataRow CreateDefaultRow(ParameterAlternative alternative)
            {
                var row = table.NewRow();

                row[PKSimConstants.UI.Experiment] = alternative.Name;

                if (needsDefault)
                {
                    row[PKSimConstants.UI.IsDefault] = alternative.IsDefault;
                }

                if (needsDescription)
                {
                    row[PKSimConstants.UI.Description] = alternative.Description;
                }

                return(row);
            }

            foreach (var alternative in parameterGroup.AllAlternatives)
            {
                if (calcualtedAlternative == alternative)
                {
                    foreach (var parameter in calculatedParameters(_compoundAlternativeTask)(compound))
                    {
                        var row = CreateDefaultRow(alternative);
                        row[PKSimConstants.UI.Lipophilicity] = parameter.Name;
                        setParameterValue(parameter, row, columnName);
                        table.Rows.Add(row);
                    }
                }
                else
                {
                    var row = CreateDefaultRow(alternative);
                    setParameterValue(alternative.Parameter(parameterName), row, columnName);
                    table.Rows.Add(row);
                }
            }
            return(tableWithParagraph(table, description, compound.Name));
        }
Пример #28
0
 protected override void OnInitialized()
 {
     base.OnInitialized();
     DataTable?.AddColumn(this);
 }
        private DataTable createResultDataToExport(Simulation simulation)
        {
            //Id	Time	Output1	Output2	...	OutputN
            var dataTable = new DataTable(simulation.Name);

            if (!simulation.HasResults)
            {
                return(dataTable);
            }

            var simulationResults = simulation.Results;

            var allQuantities     = _quantityRetriever.QuantitiesFrom(simulation);
            var timeColumnName    = Constants.NameWithUnitFor(CoreConstants.SimulationResults.TIME, _timeDimension.BaseUnit);
            var quantityPathCache = new Cache <string, string>();

            dataTable.AddColumn <int>(CoreConstants.SimulationResults.INDIVIDUAL_ID);
            dataTable.AddColumn <string>(timeColumnName);

            var allQuantityPaths = simulationResults.AllQuantityPaths();

            foreach (var quantityPath in allQuantityPaths)
            {
                var quantity = allQuantities[quantityPath];
                if (quantity == null)
                {
                    continue;
                }

                //export results in base unit so that they can be computed automatically from matlab scripts
                quantityPathCache[quantityPath] = Constants.NameWithUnitFor(quantityPath, quantity.Dimension.BaseUnit);
                dataTable.AddColumn <string>(quantityPathCache[quantityPath]);
            }

            dataTable.BeginLoadData();
            int numberOfValues = simulationResults.Time.Length;

            foreach (var individualResults in simulationResults.OrderBy(x => x.IndividualId))
            {
                var allQuantitiesCache = new Cache <string, QuantityValues>(x => x.QuantityPath);
                allQuantitiesCache.AddRange(individualResults);

                for (int i = 0; i < numberOfValues; i++)
                {
                    var row = dataTable.NewRow();
                    row[CoreConstants.SimulationResults.INDIVIDUAL_ID] = individualResults.IndividualId;
                    row[timeColumnName] = simulationResults.Time[i].ConvertedTo <string>();

                    foreach (var quantityPath in allQuantityPaths)
                    {
                        var quantity = allQuantities[quantityPath];
                        if (quantity == null)
                        {
                            continue;
                        }

                        row[quantityPathCache[quantityPath]] = allQuantitiesCache[quantityPath][i].ConvertedTo <string>();
                    }
                    dataTable.Rows.Add(row);
                }
            }
            dataTable.EndLoadData();
            return(dataTable);
        }
Пример #30
0
 /// <summary>
 /// Adds a new Column to a Google.DataTable.Net.Wrapper.DataTable
 /// </summary>
 /// <param name="col"></param>
 /// <param name="cellFunction"></param>
 /// <returns></returns>
 public DataTableConfig <T> AddColumn(Column col, Func <T, Cell> cellFunction)
 {
     _dataTable.AddColumn(col);
     _colFunc.Add(cellFunction);
     return(this);
 }