public bool DataColumnFillField(string node, string fieldName, string condition, string filedValue)
        {
            var result = true;

            try
            {
                var           cacheData = GetDataFlowCache(node);
                var           dt        = cacheData.DataTable;
                StringBuilder filter    = new StringBuilder();
                switch (condition)
                {
                case "null":
                    filter.Append($"{fieldName} is null and ");
                    break;

                case "blank":
                    filter.Append($"{fieldName} ='' and ");
                    break;

                case "blankOrNull":
                    filter.Append($"{fieldName} is null or {fieldName} =''  and ");
                    break;
                }
                filter.Append(" 1=1");
                var rows = dt.Select(filter.ToString());
                if (rows != null && rows.Length > 0)
                {
                    for (int i = 0; i < rows.Length; i++)
                    {
                        rows[i][fieldName] = filedValue;
                    }
                    var handler = new LegacyCodeHandler(_extractEngineDataHandlerlogger);
                    cacheData.DataColumns = handler.GenerateColumnDataForCache(cacheData.DataTable, cacheData.DataColumns);
                    SetDataFlowCache(cacheData, node);
                }
            }
            catch (Exception ex)
            {
                _logger.LogError("DataColumnFillField失败:" + ex.ToString());
                result = false;
            }
            return(result);
        }
        public int DataRowFilterByColumns(string node, List <DataRowFilter> filterColumns)
        {
            var result = 0;

            try
            {
                var           cacheData = GetDataFlowCache(node);
                StringBuilder filter    = new StringBuilder();
                foreach (var r in filterColumns)
                {
                    if (r.Operation.Equals("like"))
                    {
                        filter.Append($"{r.Column} {r.Operation} '%{r.Value}%' and ");
                    }
                    else if (r.Operation.Equals("nl"))
                    {
                        filter.Append($"{r.Column} not like '%{r.Value}%' and ");
                    }
                    else
                    {
                        filter.Append($"{r.Column} {r.Operation} '{r.Value}' and ");
                    }
                }
                filter.Append(" 1=1");

                var filterRows = cacheData.DataTable.Select(filter.ToString());
                if (filterRows.Length > 0)
                {
                    result = filterRows.Length;
                    cacheData.DataTable = filterRows.CopyToDataTable();
                    cacheData.DataCount = filterRows.Length;
                    var handler = new LegacyCodeHandler(_extractEngineDataHandlerlogger);
                    cacheData.DataColumns = handler.GenerateColumnDataForCache(cacheData.DataTable, cacheData.DataColumns);
                    SetDataFlowCache(cacheData, node);
                }
            }
            catch (Exception ex)
            {
                _logger.LogError("DataRowFilterByColumns失败:" + ex.ToString());
            }
            return(result);
        }
        public bool DataCombineAppend(string node, List <string> prevNodeIds, string fieldSource)
        {
            var result = true;

            try
            {
                var mainData   = GetDataFlowCache(prevNodeIds[0], "");
                var secondData = GetDataFlowCache(prevNodeIds[1], "");

                var table1      = mainData.DataTable;
                var table2      = secondData.DataTable;
                var modifyTable = table1.Copy();

                if (fieldSource == "mainData")
                {
                    modifyTable.Merge(table2, true, MissingSchemaAction.Ignore);
                }
                else
                {
                    modifyTable.Merge(table2, true, MissingSchemaAction.Add);
                }

                var mainColumns   = mainData.DataColumns.Select(x => x.Name).ToList();
                var secondColumns = secondData.DataColumns.Select(x => x.Name).ToList();
                //DataTable dt = new DataTable();
                //if (fieldSource == "mainData")
                //{
                //    string[] colCommon = mainColumns.Intersect(secondColumns).ToArray();
                //    dt = mainData.DataTable.Copy();
                //    DataTable dt2 = secondData.DataTable.DefaultView.ToTable(false, colCommon);
                //    foreach (DataRow itemR in dt2.Rows)
                //    {
                //        DataRow dr = dt.NewRow();
                //        foreach (System.Data.DataColumn itemC in dt2.Columns)
                //        {
                //            dr[itemC] = itemR[itemC];
                //        }
                //        dt.Rows.Add(dr);
                //    }
                //}
                //else
                //{
                //    string[] colCommon = mainColumns.Union(secondColumns).ToArray();
                //    //获取两个数据源的并集
                //    IEnumerable<DataRow> query2 = secondData.DataTable.AsEnumerable().Union(secondData.DataTable.AsEnumerable(), DataRowComparer.Default);
                //    //两个数据源的并集集合
                //    dt = query2.CopyToDataTable();
                //}
                var diffColumns = secondColumns.Except(mainColumns).ToList();
                var data        = new DataFlowCacheModel();
                var handler     = new LegacyCodeHandler(_extractEngineDataHandlerlogger);

                var columns = mainData.DataColumns;
                if (diffColumns.Count > 0)
                {
                    foreach (var r in diffColumns)
                    {
                        columns.Add(secondData.DataColumns.FirstOrDefault(x => x.Name == r));
                    }
                }
                data.DataTable   = modifyTable;
                data.DataColumns = handler.GenerateColumnDataForCache(modifyTable, columns);
                data.DataCount   = modifyTable.Rows.Count;
                data.DataSetInfo = mainData.DataSetInfo;
                data.Id          = mainData.Id;
                data.Name        = mainData.Name;
                data.ProjectInfo = mainData.ProjectInfo;
                data.TableName   = mainData.TableName;
                data.WdName      = mainData.WdName;

                SetDataFlowCache(data, node);
            }
            catch (Exception ex)
            {
                _logger.LogError("ExtractSimple失败:" + ex.ToString());
                result = false;
            }
            return(result);
        }
        public bool DataSampleExtractSimple(string node, DataSampleModel simObj)
        {
            var result = true;

            try
            {
                var       cacheData = GetDataFlowCache(node);
                DataTable dtRel     = new DataTable();
                var       dt        = cacheData.DataTable;
                int       dataCount = dt.Rows.Count;
                var       rowList   = new List <DataRow>();
                switch (simObj.Method)
                {
                case "extract":
                    var count = Convert.ToInt32(dataCount / simObj.SimVal);
                    dtRel = dt.AsEnumerable().Take(count).CopyToDataTable();
                    break;

                case "pecent":
                    bool valBoo = System.Text.RegularExpressions.Regex.IsMatch(simObj.SimVal.ToString(), @"^[1-9]\d*$");
                    if (!valBoo)
                    {
                        simObj.SimVal = simObj.SimVal * 100;
                    }
                    if (simObj.SimMax > 0)
                    {
                        double dc = 0;
                        if (valBoo)
                        {
                            dc = dataCount * ((double)(simObj.SimVal) / 100);
                        }
                        else
                        {
                            dc = dataCount * ((double)(simObj.SimVal));
                        }
                        if (simObj.SimMax > dc)
                        {
                            dtRel = dt.AsEnumerable().Take(simObj.SimMax).CopyToDataTable();
                        }
                        else
                        {
                            dtRel = dt.AsEnumerable().Take(Convert.ToInt32(Math.Round(simObj.SimMax / (double)(simObj.SimVal / 100), 0))).CopyToDataTable();
                            dtRel = dtRel.AsEnumerable().Take(Convert.ToInt32(Math.Round(dataCount * (simObj.SimVal / 100), 0))).CopyToDataTable();
                        }
                    }
                    else
                    {
                        dtRel = dt.AsEnumerable().Take(Convert.ToInt32(Math.Round(dataCount * (simObj.SimVal / 100), 0))).CopyToDataTable();
                    }
                    break;

                default:
                    dtRel = dt.AsEnumerable().Take(Convert.ToInt32(Math.Round(simObj.SimVal, 0))).CopyToDataTable();
                    break;
                }

                cacheData.DataTable = dtRel;
                cacheData.DataCount = dtRel.Rows.Count;
                var handler = new LegacyCodeHandler(_extractEngineDataHandlerlogger);
                cacheData.DataColumns = handler.GenerateColumnDataForCache(cacheData.DataTable, cacheData.DataColumns);
                SetDataFlowCache(cacheData, node);
            }
            catch (Exception ex)
            {
                _logger.LogError("ExtractSimple失败:" + ex.ToString());
                result = false;
            }
            return(result);
        }