Пример #1
0
        //adding the columns to the table
        private static void AddColumnsToDT(ExcelRange Range, bool addHeaders, DataTable Result, LinkedList <object[]> Rows, int MaxColNo)
        {
            //adding column to the table
            if (addHeaders)
            {
                //get the header row
                object[] headers = Rows.First();
                Result.AddColumns(headers);

                //add more columns in case the header is smaller than the maximum sized row
                Result.AddColumns(MaxColNo - headers.Length);
                Rows.RemoveFirst();
            }
            else
            {
                //simply adding the correct number of empty column rows
                if (Range.EndRow == -1)
                {
                    Result.AddColumns(MaxColNo);
                }
                else
                {
                    Result.AddColumns(Range.ColumnCount);
                }
            }
        }
Пример #2
0
        private void createData()
        {
            //Always added for each curve
            _dataTable.AddColumn <float>(X);

            _dataTable.AddColumns <float>(YColumnNames);

            if (HasLLOQ)
            {
                _dataTable.AddColumns <float>(LLOQ_SUFFIX);
            }

            _dataTable.AddColumn <int>(INDEX_OF_VALUE_IN_CURVE);
        }
Пример #3
0
        private DataTable createParametersHistoryTableFrom(IReadOnlyCollection <IdentificationParameterHistory> parametersHistory, IReadOnlyList <float> totalErrorHistory)
        {
            var dataTable = new DataTable(Captions.ParameterIdentification.ParametersHistory);
            var allNames  = parametersHistory.Select(x => x.DisplayName).ToList();

            dataTable.AddColumns <double>(allNames);
            dataTable.AddColumn <double>(Captions.ParameterIdentification.Error);

            if (parametersHistory.Count == 0)
            {
                return(dataTable);
            }

            var numberOfValues   = parametersHistory.ElementAt(0).Values.Count;
            var totalErrorValues = totalErrorHistory.Count;

            //use min to ensure that we are not taken by surprise if one array has been changed since we are using references
            var numberOfElements = Math.Min(numberOfValues, totalErrorValues);

            for (int i = 0; i < numberOfElements; i++)
            {
                var row = dataTable.NewRow();
                foreach (var parameterHistory in parametersHistory)
                {
                    row[parameterHistory.DisplayName] = parameterHistory.DisplayValueAt(i);
                }
                row[Captions.ParameterIdentification.Error] = totalErrorHistory[i];
                dataTable.Rows.Add(row);
            }
            return(dataTable);
        }
Пример #4
0
        private static void AddFullRowToDT(object[] Row, bool addHeaders, DataTable DT)
        {
            //if we are supposed to add headers but no columns added yet
            if (addHeaders && DT.Columns.Count == 0)
            {
                DT.AddColumns(Row);
                return;
            }
            else if (DT.Columns.Count == 0)
            {
                DT.AddColumns(Row.Length);
            }

            //add the row as normal
            DT.Rows.Add(Row);
        }
Пример #5
0
        /// <summary>
        /// Gets the data table.
        /// </summary>
        /// <param name="insertValues">if set to <c>true</c> [insert values].</param>
        /// <returns></returns>
        public DataTable GetDataTable(bool insertValues, string nameOverride = "")
        {
            DataTable performanceTable = new DataTable("perf_" + folderName);

            if (!nameOverride.isNullOrEmpty())
            {
                performanceTable.SetTitle(nameOverride);
            }

            // performanceTable.Add(nameof(performanceRecord.crawlerName));
            performanceTable.AddColumns(typeof(performanceRecord), nameof(crawlerName),
                                        nameof(domainsLoaded), nameof(jobTimeInMinutes), nameof(loadTotal),
                                        nameof(loadMbPerMinute), nameof(domainCrashed), nameof(pageLoads), nameof(pageLoadsReal),
                                        nameof(timePerDomain), nameof(pageLoadsPerDomain), nameof(termsPerPageLoads),
                                        nameof(blocksRecovered), nameof(blocksPerPageLoads), nameof(cpuAverage),
                                        nameof(termsRecoveredSerbian), nameof(blocksRecoveredSerbian),
                                        nameof(relevantPageLoads), nameof(relevantPagePerDomain), nameof(relevantVsLoadedAverage),
                                        nameof(termsRecoveredAll), nameof(termsRecoveredOther), nameof(domainCrashedList),
                                        nameof(pageLoadByIterationRecord), nameof(pageLoadDuplicate), nameof(FRA_TimePercent), nameof(ContentProcessor_TimePercent), nameof(IterationTimeAvg), nameof(Iterations));

            if (insertValues)
            {
                performanceTable.AddObject(this);
            }

            return(performanceTable);
        }
        public CommandResult <List <DriveInfo> > Driveinfo(
            CommandEvaluationContext context,
            [Parameter("drive name for which informations must be printed. if no drive specified, list all drives", true)] string drive,
            [Option("b", "borders", "if set add table borders")] bool borders
            )
        {
            var drives = DriveInfo.GetDrives().AsQueryable();

            if (drive != null)
            {
                drives = drives.Where(x => x.Name.Equals(drive, CommandLineParser.SyntaxMatchingRule));
                if (drives.Count() == 0)
                {
                    context.Errorln($"drive \"{drive}\" not found");
                }
            }
            var table = new DataTable();

            table.AddColumns("name", "label", "type", "format", "bytes");
            foreach (var di in drives)
            {
                var f   = DefaultForegroundCmd;
                var row = table.NewRow();
                try
                {
                    row["name"]   = $"{context.ShellEnv.Colors.Highlight}{di.Name}{f}";
                    row["label"]  = $"{context.ShellEnv.Colors.Highlight}{di.VolumeLabel}{f}";
                    row["type"]   = $"{context.ShellEnv.Colors.Name}{di.DriveType}{f}";
                    row["format"] = $"{context.ShellEnv.Colors.Name}{di.DriveFormat}{f}";
                    row["bytes"]  = (di.TotalSize == 0) ? "" : $"{HumanFormatOfSize(di.TotalFreeSpace, 2, " ", context.ShellEnv.Colors.Numeric.ToString(), f)}{f}/{context.ShellEnv.Colors.Numeric}{HumanFormatOfSize(di.TotalSize, 2, " ", context.ShellEnv.Colors.Numeric.ToString(), f)} {f}({context.ShellEnv.Colors.Highlight}{Math.Round((double)di.TotalFreeSpace / (double)di.TotalSize * 100d, 2)}{f} %)";
                }
                catch (UnauthorizedAccessException)
                {
                    context.Errorln($"unauthorized access to drive {di.Name}");
                    row["name"]   = $"{context.ShellEnv.Colors.Highlight}{di.Name}{f}";
                    row["label"]  = "?";
                    row["type"]   = "?";
                    row["format"] = "?";
                    row["bytes"]  = "?";
                }
                catch (Exception ex)
                {
                    context.Errorln($"error when accessing drive {di.Name}: {ex.Message}");
                    row["name"]   = $"{context.ShellEnv.Colors.Highlight}{di.Name}{f}";
                    row["label"]  = "?";
                    row["type"]   = "?";
                    row["format"] = "?";
                    row["bytes"]  = "?";
                }
                table.Rows.Add(row);
            }
            table.Echo(
                new EchoEvaluationContext(context.Out, context,
                                          new TableFormattingOptions(context.ShellEnv.GetValue <TableFormattingOptions>(ShellEnvironmentVar.display_tableFormattingOptions))
            {
                NoBorders = !borders
            }));

            return(new CommandResult <List <DriveInfo> >(drives.ToList()));
        }
Пример #7
0
    public static DataTable CombineVertically(DataTable report1, DataTable report2)
    {
      var combo = new DataTable();

      // set the columns of the combined reports to the columns of either report1
      // or report 2.
      combo.AddColumns(report1);
      if (combo.Columns.Count == 0)
        combo.AddColumns(report2);

      // combine the report rows of the two input tables.
      combo.AddRows(report1);
      combo.AddRows(report2);

      return combo;
    }
        internal static void AddDmpColumns(this DataTable dataTable, DataManagementPlan dmp)
        {
            dataTable.AddColumns(false, typeof(DataStorage), typeof(NewDataDetail),
                                 typeof(ExistingDataDetail), typeof(DataDocumentation), typeof(Ethic), typeof(Confidentiality),
                                 typeof(BackupPolicy), typeof(DataRetention), typeof(DataSharing), typeof(DataRelationshipDetail), typeof(DataOrganisation));

            dataTable.Columns.Add(CreationDateColumn, typeof(DateTime));
            dataTable.Columns.Add(ProjectAccessRolesColumn, typeof(string));
        }
Пример #9
0
        public void SetColumns(params object[][] rows)
        {
            _tables.Remove("COLUMNS");
            var table = new DataTable("COLUMNS");

            table.AddColumns("TABLE_SCHEMA", "TABLE_NAME", "COLUMN_NAME", "IS_IDENTITY");
            table.AddRows(AddIdentityDefault(rows));
            _tables.Add("COLUMNS", table);
        }
        public DataTable MapFrom(SensitivityAnalysis sensitivityAnalysis, SensitivityAnalysisRunResult sensitivityAnalysisRunResult)
        {
            var dataTable = new DataTable(Captions.SensitivityAnalysis.Results);

            dataTable.AddColumns <string>(Captions.SensitivityAnalysis.Output, Captions.SensitivityAnalysis.PKParameterName, Captions.SensitivityAnalysis.ParameterName, Captions.SensitivityAnalysis.ParameterDisplayPath, Captions.SensitivityAnalysis.PKParameterDescription, Captions.SensitivityAnalysis.ParameterPath);
            dataTable.AddColumn <double>(Captions.SensitivityAnalysis.Value);
            sensitivityAnalysisRunResult.AllPKParameterSensitivities.Each(x => addParameterSensitivity(x, dataTable, sensitivityAnalysis));
            return(dataTable);
        }
Пример #11
0
        public void SetTables(params object[][] rows)
        {
            _tables.Remove("TABLES");
            var table = new DataTable("TABLES");

            table.AddColumns("TABLE_SCHEMA", "TABLE_NAME", "TABLE_TYPE");
            table.AddRows(rows);
            _tables.Add("TABLES", table);
        }
Пример #12
0
        public void SetParameters(params object[][] rows)
        {
            _tables.Remove("PARAMETERS");
            var table = new DataTable("PARAMETERS");

            table.AddColumns("PROCEDURE_SCHEMA", "PROCEDURE_NAME", "PARAMETER_NAME");
            table.AddRows(rows);
            _tables.Add("PARAMETERS", table);
        }
Пример #13
0
        public void SetPrimaryKeys(params object[][] rows)
        {
            var table = new DataTable("PRIMARY_KEYS");

            table.AddColumns("TABLE_SCHEMA", "TABLE_NAME", "COLUMN_NAME");
            table.Columns.Add("ORDINAL_POSITION", typeof(int));
            table.AddRows(rows);
            _tables.Add("PRIMARY_KEYS", table);
        }
Пример #14
0
        public void SetForeignKeys(params object[][] rows)
        {
            var table = new DataTable("FOREIGN_KEYS");

            table.AddColumns("CONSTRAINT_NAME", "TABLE_SCHEMA", "TABLE_NAME", "COLUMN_NAME",
                             "UNIQUE_TABLE_SCHEMA", "UNIQUE_TABLE_NAME", "UNIQUE_COLUMN_NAME");
            table.Columns.Add("ORDINAL_POSITION", typeof(int));
            table.AddRows(rows);
            _tables.Add("FOREIGN_KEYS", table);
        }
Пример #15
0
        public static DataTable MainTable()
        {
            var table = new DataTable("QOAMcorners");

            table.AddColumns("Test Corner", "Another Corner");

            table.AddRow(new[] { "123-123", "777-888" });
            table.AddRow(new[] { "456-456", "" });

            return(table);
        }
Пример #16
0
        private DataTable createDataTable(IEnumerable <string> compounds, IEnumerable <CalculationMethod> calculationMethods)
        {
            var dataTable = new DataTable();;

            dataTable.AddColumns <string>("Compound", "Category", "Calculation Method");
            dataTable.AddColumn <bool>("Value");
            compounds.Each(compound => addRows(compound, calculationMethods, dataTable));


            return(dataTable);
        }
Пример #17
0
        public static DataTable LicenseTable(string licenseName)
        {
            var table = new DataTable(licenseName);

            table.AddColumns("eISSN", "text");

            table.AddRow(new[] { "0219-3094", "Discount of 100% on publication fee. Please contact your library for more information." });
            table.AddRow(new[] { "0219-3116", "Some random text" });
            table.AddRow(new[] { "0814-6039", "I'm Batman" });
            table.AddRow(new[] { "0942-0940", "No, really." });

            return(table);
        }
Пример #18
0
        /// <summary>
        /// This method converts a generic list into a DataTable. Properties will be used as columns.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="data">Generic list of data that you want to copy to a DataTable.</param>
        /// <returns></returns>
        public static DataTable CopyToDataTable <T>(this List <T> data)
        {
            var dataTable = new DataTable(typeof(T).Name);

            // Get properties and sort them by metadatatoken to preserve their order. If it is in an incorrect order, bulk insert will fail.
            var properties = typeof(T).GetProperties().OrderBy(_ => _.MetadataToken);

            dataTable.AddColumns(properties);

            dataTable.AddValues(data, properties);

            return(dataTable);
        }
Пример #19
0
        public static DataTable AuthorsTable()
        {
            var table = new DataTable("Links");

            table.AddColumns("eissn", "url");

            table.AddRow(new[] { "1687-8140", "http://ade.sagepub.com/submission" });
            table.AddRow(new[] { "2073-4395", "http://www.mdpi.com/journal/agronomy/submission" });
            table.AddRow(new[] { "2372-0484", "http://www.aimspress.com/journal/Materials/submission" });
            table.AddRow(new[] { "1687-7675", "http://www.hindawi.com/journals/aess/submission" });

            return(table);
        }
 public static void InitializeDatabase()
 {
     GetAccountsData();
     //Create default login "admin" if table is not existing in the accounts database
     if (AccountTable == null)
     {
         AccountsDataSet.Tables.Add("Accounts");
         AccountTable = AccountsDataSet.Tables["Accounts"];
         AccountTable.AddColumns("", "Username", "Password", "ManagerName", "SecretQuestion", "SecretAnswer", "Status");
         AccountTable.SetKey("Username");
         AccountTable.Rows.Add("admin", "admin", "admin", "admin", "admin", "admin");
         AccountsDataSet.SaveXML();
     }
 }
Пример #21
0
        public static DataTable AuthorsTable()
        {
            var table = new DataTable("Authors");

            table.AddColumns("eissn", "Author email address", "Author name");

            table.AddRow(new[] { "1687-8140", "*****@*****.**", "A. Caenen" });
            table.AddRow(new[] { "2073-4395", "*****@*****.**", "Jeroen De Waele" });
            table.AddRow(new[] { "2372-0484", "*****@*****.**", "Dolores Esquivel" });
            table.AddRow(new[] { "1687-7675", "*****@*****.**", "E. Van Ranst" });
            table.AddRow(new[] { "1234-7675", "[email protected],[email protected];[email protected]", "K. Test" });

            return(table);
        }
Пример #22
0
        public static DataTable UniversitiesTable()
        {
            var table = new DataTable("Universities");

            table.AddColumns("Domains", "Tabs");

            table.AddRow(new[] { "ru.nl", "Sage" });
            table.AddRow(new[] { "uu.nl", "Springer" });
            table.AddRow(new[] { "uva.nl", "Springer, Sage" });
            table.AddRow(new[] { "rug.nl", "Springer,Sage" });
            table.AddRow(new[] { "ugent.be", "Springer; Sage" });
            table.AddRow(new[] { "upc.cat", "Springer;Sage" });

            return(table);
        }
Пример #23
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);
        }
Пример #24
0
        private IEnumerable <object> dissociationConstants(Compound compound)
        {
            var table = new DataTable(groupDisplayName(CoreConstants.Groups.COMPOUND_PKA));

            table.AddColumns <string>(CoreConstants.Parameters.PARAMETER_PKA_BASE, Constants.Parameters.ParameterCompoundTypeBase);
            addCompoundTypePart(table, compound, CoreConstants.Parameters.PARAMETER_PKA1, Constants.Parameters.COMPOUND_TYPE1);
            addCompoundTypePart(table, compound, CoreConstants.Parameters.PARAMETER_PKA2, Constants.Parameters.COMPOUND_TYPE2);
            addCompoundTypePart(table, compound, CoreConstants.Parameters.PARAMETER_PKA3, Constants.Parameters.COMPOUND_TYPE3);
            if (table.Rows.Count == 0)
            {
                return(null);
            }

            return(new object[] { new SubSubSection(PKSimConstants.UI.DissociationConstants), table });
        }
Пример #25
0
        /// <summary>
        /// Gets the data table.
        /// </summary>
        /// <param name="insertValues">if set to <c>true</c> [insert values].</param>
        /// <returns></returns>
        public DataTable GetDataTable(bool insertValues, string nameOverride = "")
        {
            DataTable performanceTable = new DataTable("sgn_" + nameOverride);

            if (!nameOverride.isNullOrEmpty())
            {
                performanceTable.SetTitle(nameOverride);
            }

            // performanceTable.Add(nameof(performanceRecord.crawlerName));
            performanceTable.AddColumns(GetType(), nameof(name), nameof(description), nameof(reportFolder), nameof(slot), nameof(className),
                                        nameof(spiderSettings.limitIterationNewLinks), nameof(spiderSettings.limitIterations), nameof(spiderSettings.limitTotalLinks), nameof(spiderSettings.limitTotalPageLoad));


            if (insertValues)
            {
                performanceTable.AddObject(this);
            }

            return(performanceTable);
        }
        public static DataTable Fill <T>(this DataTable dt, params T[] collection) where T : class, new()
        {
            Type type = typeof(T);

            dt.TableName = type.UnderlyingSystemType.Name;
            Dictionary <int, PropertyInfo> columnIndexAndProperties = null;

            dt.AddColumns(type, ref columnIndexAndProperties);

            if (collection == null)
            {
                return(dt);
            }

            foreach (T obj in collection)
            {
                dt.AddRow(obj, columnIndexAndProperties);
            }

            return(dt);
        }
Пример #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
 public static DataTable AddColumns(this DataTable dt, params KeyValuePair <string, Func <DataRow, int, object> >[] columns)
 {
     return(dt.AddColumns((IEnumerable <KeyValuePair <string, Func <DataRow, int, object> > >)columns));
 }
Пример #29
0
 public static DataTable AddColumns(this DataTable dt, params KeyValuePair <string, Func <DataRow, object> >[] columns)
 {
     return(dt.AddColumns(columns.Select(item => new KeyValuePair <string, Func <DataRow, int, object> >(item.Key, (row, index) => item.Value(row)))));
 }
Пример #30
0
 /// <summary>
 /// 添加列
 /// </summary>
 /// <param name="table"></param>
 /// <param name="columns"></param>
 public static void AddColumns(this DataTable table, params string[] columns) => table.AddColumns(columns?.ToList());