Ejemplo n.º 1
0
        /// <summary>
        /// 获取所有表格的最后数据组成新表
        /// </summary>
        /// <param name="name">表名称</param>
        /// <param name="ignoreRowCountLessThan">忽略行数量少于此的列,不含</param>
        /// <param name="period"></param>
        /// <param name="reference"></param>
        /// <returns></returns>
        public ObjectTableStorage GetFractionOfLastValueOfAllCols(string name, int ignoreRowCountLessThan = 10, double period = 1.0, double reference = 0.5)
        {
            var newTable            = new ObjectTableStorage(name);
            var PeriodFilterManager = new PeriodPipeFilterManager(period, reference);

            foreach (var table in this)
            {
                var siteName = TableNameHelper.ParseName(table.Name);
                newTable.NewRow();
                newTable.AddItem("Name", siteName);// 第一列为名称

                var lastValues = table.GetLastValueOfAllCols(ignoreRowCountLessThan);
                foreach (var colName in lastValues.Keys) //每个测站对应一行
                {
                    var initVal = lastValues[colName];
                    //结果统一到一个周期区间
                    // lly修改,这个地方直接取每一列的小数部分即可,不用再进行区间的变化
                    //var val = PeriodFilterManager.GetOrCreate(siteName).Filter(initVal);
                    //newTable.AddItem(colName, val);
                    newTable.AddItem(colName, initVal);
                }
                newTable.EndRow();
            }

            return(newTable);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///  将相同列合并到一个表格中,标题以不同表名称命名。
        /// </summary>
        /// <param name="indexes"></param>
        /// <param name="colNames"></param>
        /// <param name="tableNamePostfix"></param>
        /// <returns></returns>
        public ObjectTableManager GetSameColAssembledTableManager(List <object> indexes, List <string> colNames, string tableNamePostfix = "")
        {
            var indexColName             = this.GetIndexColName();
            ObjectTableManager newManger = new ObjectTableManager(this.OutputDirectory);

            //建立表格
            foreach (var oldColName in colNames)
            {
                if (indexColName.Equals(oldColName, StringComparison.CurrentCultureIgnoreCase))
                {
                    continue;
                }

                var newTableName = oldColName;
                if (!String.IsNullOrWhiteSpace(tableNamePostfix))
                {
                    newTableName = TableNameHelper.BuildName(oldColName, tableNamePostfix, true);
                }

                newManger.AddTable(newTableName);
            }
            //填充数据
            foreach (var indexVal in indexes)        //逐历元
            {
                foreach (var oldColName in colNames) //逐新表
                {
                    if (indexColName.Equals(oldColName, StringComparison.CurrentCultureIgnoreCase))
                    {
                        continue;
                    }

                    var newTable = newManger.Get(oldColName);

                    newTable.NewRow();

                    newTable.AddItem(indexColName, indexVal);
                    foreach (var oldTableName in this.Keys) // 逐新表列, 逐老表
                    {
                        var oldTable = this[oldTableName];

                        if (!oldTable.ParamNames.Contains(oldColName))
                        {
                            continue;
                        }

                        var val = oldTable[indexVal, oldColName];
                        if (val != null)
                        {
                            var colName = TableNameHelper.ParseName(oldTableName);
                            newTable.AddItem(colName, val);
                        }
                    }
                    newTable.EndRow();
                }
            }
            return(newManger);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 对同名列进行统计,返回表。
        /// </summary>
        /// <returns></returns>
        public ObjectTableStorage GetValidDataCount(Func <double, bool> Condition, string tableName = "ValidDataCount")
        {
            ObjectTableStorage table = new ObjectTableStorage(tableName);

            foreach (var item in this)
            {
                table.NewRow();
                var name = TableNameHelper.ParseName(item.Name);
                table.AddItem("Name", name);
                var dic = item.GetValidDataCount(Condition);
                table.AddItem(dic);
                table.EndRow();
            }
            return(table);
        }