protected override T[] Execute(CodeActivityContext context)
        {
            var dt  = InputDataTable.Get(context);
            var col = Column.Get(context);

            int index = 0;

            if (col is string colName)
            {
                try
                {
                    index = dt.Columns[colName].Ordinal;
                }
                catch (NullReferenceException e)
                {
                    throw new ArgumentException(Resources.ExtractDataColumnValues_ErrorMsg_InvalidColumnNameFormat(colName), e);
                }
            }
            else
            {
                index = (int)col;
                if (index >= dt.Columns.Count)
                {
                    throw new ArgumentException(Resources.ExtractDataColumnValues_ErrorMsg_InvalidColumnIndexFormat(index));
                }
            }

            var values = dt.AsEnumerable().Select(row => row[index]).ToArray();

            return(ConvertValues(values, DefaultValue.Get(context)));
        }
        public ResultsControl()
        {
            InitializeComponent();
            random = new Random();

            _InputDataTable = new InputDataTable();
            inputDataGrid.ItemsSource = _InputDataTable.AsDataView;
        }
        protected override void Execute(CodeActivityContext context)
        {
            var    inputDataTable = InputDataTable.Get(context);
            var    columnIndex    = ColumnIndex.Get(context);
            double result         = Utils.ColumnActionOnDataTable(inputDataTable, columnIndex, "MAX");

            MaximumValue.Set(context, result);
        }
        protected override void Execute(CodeActivityContext context)
        {
            var inputDataTable = InputDataTable.Get(context);
            var columnName     = ColumnName.Get(context);
            var result         = inputDataTable.AsEnumerable().Select(r => r.Field <string>(columnName)).ToArray();

            ResultArray.Set(context, result);
        }
        protected override string Execute(CodeActivityContext context)
        {
            var dt = InputDataTable.Get(context);

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

            return(ConvertTo(TextFormat, dt, DateTimeFormat.Get(context) ?? DATE_FORMAT));
        }
        protected override void Execute(CodeActivityContext context)
        {
            Dictionary <string, string> dict = InputColumnsRenameMapping.Get(context);
            DataTable DT = InputDataTable.Get(context);

            foreach (string key in dict.Keys)
            {
                DT.Columns[key].ColumnName = dict[key];
            }

            OutputDataTable.Set(context, DT);
        }
        protected override void Execute(CodeActivityContext context)
        {
            var inputDataTable = InputDataTable.Get(context);
            int totalColumns   = inputDataTable.Columns.Count;

            string[] result = new string[totalColumns];
            for (int i = 0; i < totalColumns; i++)
            {
                result[i] = inputDataTable.Columns[i].ColumnName.ToString();
            }
            ResultArray.Set(context, result.ToArray());
        }
        protected override DataTable Execute(CodeActivityContext context)
        {
            var names     = new Dictionary <string, int>();
            var emptyName = EmptyColumnName.Get(context);

            var inputDT = InputDataTable.Get(context);

            if (inputDT.Rows.Count == 0)
            {
                throw new InvalidOperationException(Resources.PromoteHeaders_ErrorMsg_NoData);
            }

            var outputDT = inputDT.Copy();

            var row = outputDT.Rows[0];

            string getName(string firstRowValue)
            {
                return(string.IsNullOrEmpty(firstRowValue) ? emptyName : firstRowValue);
            }

            if (AutoRename)
            {
                foreach (DataColumn col in outputDT.Columns)
                {
                    var name = getName(row[col.ColumnName].ToString());
                    if (names.ContainsKey(name))
                    {
                        names[name]++;
                        name += names[name].ToString();
                    }
                    else
                    {
                        names.Add(name, 0);
                    }

                    col.ColumnName = name;
                }
            }
            else
            {
                foreach (DataColumn col in outputDT.Columns)
                {
                    col.ColumnName = getName(row[col.ColumnName].ToString());
                }
            }

            outputDT.Rows.Remove(row);
            return(outputDT);
        }
Exemplo n.º 9
0
        protected override object[] Execute(CodeActivityContext context)
        {
            var dt      = InputDataTable.Get(context);
            var columns = Columns?.Get(context);

            var columnIndexes = DataTableUtil.IdentifyDataColumns(dt, columns);

            var result = new object[dt.Columns.Count];

            if (dt.Rows.Count > 0)
            {
                AggregateTo(result, GetConvertibleColumns(dt, columnIndexes), dt.AsEnumerable());
            }

            return(result);
        }
Exemplo n.º 10
0
        protected override async Task <Action <AsyncCodeActivityContext> > ExecuteAsync(AsyncCodeActivityContext context, CancellationToken cancellationToken)
        {
            var names = new Dictionary <string, int>();

            // Inputs
            var inputDT = InputDataTable.Get(context);

            if (inputDT.Rows.Count == 0)
            {
                throw new InvalidOperationException(Resources.PromoteHeaders_EmptyRows_Error);
            }

            var outputDT = inputDT.Copy();

            var row = outputDT.Rows[0];

            if (AutoRename)
            {
                foreach (DataColumn col in outputDT.Columns)
                {
                    var name = row[col.ColumnName].ToString();
                    if (names.ContainsKey(name))
                    {
                        names[name]++;
                        name += names[name].ToString();
                    }
                    else
                    {
                        names.Add(name, 0);
                    }

                    col.ColumnName = name;
                }
            }
            else
            {
                foreach (DataColumn col in outputDT.Columns)
                {
                    col.ColumnName = row[col.ColumnName].ToString();
                }
            }

            outputDT.Rows.Remove(row);

            // Outputs
            return((ctx) => OutputDataTable.Set(ctx, outputDT));
        }
Exemplo n.º 11
0
        private void InputUpdate(int?prevPos = null)
        {
            Label activeLabel = null;

            if (!prevPos.HasValue)
            {
                prevPos = currentState.Data.CurrentPosition;
            }
            InputDataTable.SuspendLayout();
            InputDataTable.Controls.Clear();
            InputDataTable.ColumnCount = currentState.Data.Count;
            for (int i = -currentState.Data.NegativeCount; i < currentState.Data.PositiveCount; i++)
            {
                Label label = new Label()
                {
                    Font      = new Font(this.Font.FontFamily, 18, i == currentState.Data.CurrentPosition || i == prevPos ? FontStyle.Bold : FontStyle.Regular),
                    ForeColor = i == prevPos ? Color.Brown : Color.Black,
                    BackColor = i == currentState.Data.CurrentPosition ? Color.LightGreen : Color.White,
                    AutoSize  = false,
                    Width     = 40,
                    Height    = 40,
                    Text      = (currentState.Data[i] == '\0' ? '_' : currentState.Data[i]).ToString(),
                    Margin    = Padding.Empty,
                    TextAlign = ContentAlignment.MiddleCenter
                };
                if (i == currentState.Data.CurrentPosition)
                {
                    activeLabel = label;
                }
                InputDataTable.Controls.Add(label, i + (currentState.Data.NegativeCount), 0);
            }
            InputDataTable.ResumeLayout();
            if (activeLabel == null)
            {
                return;
            }
            int a = panel2.Width / 2 - (2 * activeLabel.Location.X + activeLabel.Width) / 2;

            InputDataTable.Location = new Point(a, InputDataTable.Location.Y);
        }
        protected override DataTable Execute(CodeActivityContext context)
        {
            var inputDt = InputDataTable.Get(context) ?? throw new ArgumentException(nameof(InputDataTable));
            var columns = DataTableUtil.IdentifyDataColumns(inputDt, Columns?.Get(context));

            DataTable outputDt;

            if (columns.Any())
            {
                outputDt = inputDt.Clone();
                var colIndexes = columns.ToArray();
                foreach (DataRow inRow in inputDt.Rows)
                {
                    var skip = false;
                    foreach (DataRow outRow in outputDt.Rows)
                    {
                        if (RowExist(inRow.ItemArray, outRow.ItemArray, colIndexes))
                        {
                            skip = true;
                            break;
                        }
                    }

                    if (skip)
                    {
                        continue;
                    }

                    outputDt.ImportRow(inRow);
                }
            }
            else
            {
                outputDt = inputDt.AsDataView().ToTable(true);
            }

            return(outputDt);
        }
Exemplo n.º 13
0
        protected override DataTable Execute(CodeActivityContext context)
        {
            var inputDt = InputDataTable.Get(context);

            bool predicate(object value) => value != null && value != DBNull.Value && !string.IsNullOrWhiteSpace(value.ToString());

            // default handler
            Func <DataRow, bool> handler = dr => dr.ItemArray.Any(predicate);

            if (Mode == DataRowEvaluationMode.Any)
            {
                handler = dr => dr.ItemArray.All(predicate);
            }
            else if (Mode == DataRowEvaluationMode.Custom)
            {
                handler = GetCustomModeHandler(context, inputDt, predicate);
            }

            var rows     = inputDt.AsEnumerable().Where(handler);
            var dtResult = rows.Any() ? rows.CopyToDataTable() : inputDt.Clone();

            return(dtResult);
        }
 private void InitClass() {
     this.DataSetName = "PrebuiltConfigData";
     this.Prefix = "";
     this.Namespace = "http://tempuri.org/PrebuiltConfigData.xsd";
     this.EnforceConstraints = true;
     this.SchemaSerializationMode = global::System.Data.SchemaSerializationMode.IncludeSchema;
     this.tableConfigurationCategory = new ConfigurationCategoryDataTable();
     base.Tables.Add(this.tableConfigurationCategory);
     this.tableConfiguration = new ConfigurationDataTable();
     base.Tables.Add(this.tableConfiguration);
     this.tableInput = new InputDataTable();
     base.Tables.Add(this.tableInput);
     global::System.Data.ForeignKeyConstraint fkc;
     fkc = new global::System.Data.ForeignKeyConstraint("FK_ConfigurationCategory_Configuration", new global::System.Data.DataColumn[] {
                 this.tableConfigurationCategory.CategoryIDColumn}, new global::System.Data.DataColumn[] {
                 this.tableConfiguration.CategoryIDColumn});
     this.tableConfiguration.Constraints.Add(fkc);
     fkc.AcceptRejectRule = global::System.Data.AcceptRejectRule.None;
     fkc.DeleteRule = global::System.Data.Rule.Cascade;
     fkc.UpdateRule = global::System.Data.Rule.Cascade;
     fkc = new global::System.Data.ForeignKeyConstraint("FK_Configuration_Input", new global::System.Data.DataColumn[] {
                 this.tableConfiguration.ConfigurationIDColumn}, new global::System.Data.DataColumn[] {
                 this.tableInput.ConfigurationIDColumn});
     this.tableInput.Constraints.Add(fkc);
     fkc.AcceptRejectRule = global::System.Data.AcceptRejectRule.None;
     fkc.DeleteRule = global::System.Data.Rule.Cascade;
     fkc.UpdateRule = global::System.Data.Rule.Cascade;
     this.relationFK_ConfigurationCategory_Configuration = new global::System.Data.DataRelation("FK_ConfigurationCategory_Configuration", new global::System.Data.DataColumn[] {
                 this.tableConfigurationCategory.CategoryIDColumn}, new global::System.Data.DataColumn[] {
                 this.tableConfiguration.CategoryIDColumn}, false);
     this.relationFK_ConfigurationCategory_Configuration.Nested = true;
     this.Relations.Add(this.relationFK_ConfigurationCategory_Configuration);
     this.relationFK_Configuration_Input = new global::System.Data.DataRelation("FK_Configuration_Input", new global::System.Data.DataColumn[] {
                 this.tableConfiguration.ConfigurationIDColumn}, new global::System.Data.DataColumn[] {
                 this.tableInput.ConfigurationIDColumn}, false);
     this.relationFK_Configuration_Input.Nested = true;
     this.Relations.Add(this.relationFK_Configuration_Input);
 }
 internal void InitVars(bool initTable) {
     this.tableConfigurationCategory = ((ConfigurationCategoryDataTable)(base.Tables["ConfigurationCategory"]));
     if ((initTable == true)) {
         if ((this.tableConfigurationCategory != null)) {
             this.tableConfigurationCategory.InitVars();
         }
     }
     this.tableConfiguration = ((ConfigurationDataTable)(base.Tables["Configuration"]));
     if ((initTable == true)) {
         if ((this.tableConfiguration != null)) {
             this.tableConfiguration.InitVars();
         }
     }
     this.tableInput = ((InputDataTable)(base.Tables["Input"]));
     if ((initTable == true)) {
         if ((this.tableInput != null)) {
             this.tableInput.InitVars();
         }
     }
     this.relationFK_ConfigurationCategory_Configuration = this.Relations["FK_ConfigurationCategory_Configuration"];
     this.relationFK_Configuration_Input = this.Relations["FK_Configuration_Input"];
 }
 internal InputRow(global::System.Data.DataRowBuilder rb) : 
         base(rb) {
     this.tableInput = ((InputDataTable)(this.Table));
 }