protected override void Execute(CodeActivityContext context) { DataTable dataTable = DataTable.Get(context); DataColumn dataColumn = DataColumn.Get(context); string columnName = ColumnName.Get(context); Int32 columnIndex = ColumnIndex.Get(context); string SortColName = null; string SortText = null; if (dataColumn != null) { SortColName = dataColumn.ColumnName; } else if (columnName != null && columnName != "") { SortColName = columnName; } else { SortColName = dataTable.Columns[columnIndex].ColumnName; } SortText = SortType == SortTypes.增序 ? SortColName + "ASC" : SortColName + "DESC"; dataTable.DefaultView.Sort = SortText; DataTable dtNew = dataTable.DefaultView.ToTable(); OutDataTable.Set(context, dtNew); }
protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state) { DataRow dataRow = DataRow.Get(context); DataColumn dataColumn = DataColumn.Get(context); Int32 columnIndex = ColumnIndex.Get(context); string columnName = ColumnName.Get(context); object value = null; try { if (dataColumn != null) { value = dataRow[dataColumn]; } else if (columnName != null && columnName != "") { value = dataRow[columnName]; } else { value = dataRow[columnIndex]; } } catch (Exception e) { SharedObject.Instance.Output(SharedObject.enOutputType.Error, "获取行数据失败", e.Message); throw e; } m_Delegate = new runDelegate(Run); return(m_Delegate.BeginInvoke(callback, state)); }
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); }
/// <summary> Performs the query requested. </summary> /// <param name="context"></param> protected override void DoWork(CodeActivityContext context) { DataTable table = TargetTable.Get(context); DataColumn column = new DataColumn(); column.DataType = ColumnType.Get(context); column.ColumnName = ColumnName.Get(context); table.Columns.Add(column); Result.Set(context, table); }
// https://www.neovolve.com/2010/09/30/creating-updatable-generic-windows-workflow-activities/ protected override void Execute(CodeActivityContext context) { var dt = DataTable.Get(context); var name = ColumnName.Get(context); var col = new DataColumn(name, TargetType); col.AllowDBNull = AllowDBNull; col.AutoIncrement = AutoIncrement; col.DefaultValue = DefaultValue; col.MaxLength = MaxLength; col.Unique = Unique; dt.Columns.Add(col); }
/// <summary> Performs the query requested. </summary> /// <param name="context"></param> protected override void DoWork(CodeActivityContext context) { DataRow row = TargetRow.Get(context); string column = ColumnName.Get(context); object value = Value.Get(context); if (value != null) { row[column] = value; } else { row[column] = System.DBNull.Value; } }
protected override void Execute(CodeActivityContext context) { try { this.localDataTable = InputTable.Get(context); this.localColumnName = ColumnName.Get(context); this.localSelect = Select.Get(context); this.DoCount(); Result.Set(context, this.localOutPut); } catch (Exception ex) { throw ex; } }
protected override void Execute(CodeActivityContext context) { if (InputOrder == ddEnum.Ascending) { order = " ASC"; } else { order = " DESC"; } _table = Input.Get(context); var name = ColumnName.Get(context); DataView view = _table.DefaultView; view.Sort = name.ToString() + order; DataTable res = view.ToTable(); Result.Set(context, res); }
protected override void Execute(CodeActivityContext context) { DataTable dataTable = DataTable.Get(context); DataColumn dataColumn = DataColumn.Get(context); string columnName = ColumnName.Get(context); Int32 columnIndex = ColumnIndex.Get(context); if (dataColumn != null) { dataTable.Columns.Remove(dataColumn); } else if (columnName == null || columnName == "") { dataTable.Columns.RemoveAt(columnIndex); } else { dataTable.Columns.Remove(columnName); } }
protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state) { Type type = typeof(T); DataTable dataTable = DataTable.Get(context); DataColumn column = Column.Get(context); string columnName = ColumnName.Get(context); object defaultValue = DefaultValue.Get(context); try { if (column != null) { dataTable.Columns.Add(column); } else { DataColumn newColumn = new DataColumn(columnName); newColumn.DataType = type; if (defaultValue != null) { newColumn.DefaultValue = defaultValue; } if (MaxLength >= 0) { newColumn.MaxLength = MaxLength; } newColumn.AllowDBNull = AllowNull; newColumn.Unique = Unique; newColumn.AutoIncrement = AutoIncrement; dataTable.Columns.Add(newColumn); } } catch (Exception e) { SharedObject.Instance.Output(SharedObject.enOutputType.Error, "增加数据库列失败", e.Message); throw e; } m_Delegate = new runDelegate(Run); return(m_Delegate.BeginInvoke(callback, state)); }
protected override void Execute(CodeActivityContext context) { var userName = UserName.Get(context); var password = Password.Get(context); var listName = ListName.Get(context); var camlQueryXml = CamlQueryXml.Get(context); var column = ColumnName.Get(context); var value = updateVaule.Get(context); var securePassword = new SecureString(); foreach (char c in Password.Get(context)) { securePassword.AppendChar(c); } using (var clientContext = new ClientContext(SharePointSiteUri.Get(context))) { clientContext.Credentials = new SharePointOnlineCredentials(userName, securePassword); var listItemOperations = new ListItemOperations(clientContext, listName, camlQueryXml); isUpdated.Set(context, listItemOperations.updateListItemColumn(column, value)); } }
protected override void Execute(NativeActivityContext context) { try { ICollection <string> collect = CollectionVariable.Get(context); string colname = ColumnName.Get(context); DataTable dt = new DataTable(); dt.Columns.Add(colname, System.Type.GetType("System.String")); foreach (var item in collect) { DataRow dr = dt.NewRow(); dr[0] = item; dt.Rows.Add(dr); } DataTableVariable.Set(context, dt); } catch (Exception ex) { Logger.Log.Logger.LogData("CollectionToDataTable Activity failed with Exception : " + ex, Logger.LogLevel.Error); } }
protected override void Execute(CodeActivityContext context) { _table = Input.Get(context); var check = ColumnName.Get(context); var value = Value.Get(context); List <DataRow> rowsToDelete = new List <DataRow>(); foreach (DataRow row in _table.Rows) { if (value.Contains(row[check].ToString())) { rowsToDelete.Add(row); } } foreach (DataRow row in rowsToDelete) { _table.Rows.Remove(row); } _table.AcceptChanges(); Input.Set(context, _table); }
protected override void Execute(CodeActivityContext context) { string cn = ColumnName.Get(context); DataTable dt = DataTable.Get(context); int ci; if (null == cn) { ci = ColumnNumber.Get(context); } else { if (!dt.Columns.Contains(cn)) { throw new ArgumentException("Column '" + cn + "' was not found"); } //add 1 to the column index since we always start with column index 0 ci = dt.Columns.IndexOf(cn) + 1; } ColumnLetter.Set(context, CalculateColumnLetter(ci)); }
protected override void Execute(CodeActivityContext context) { DataTable dataTable = DataTable.Get(context); string lookupValue = LookupValue.Get(context); DataColumn dataColumn = DataColumn.Get(context); DataColumn targetDataColumn = TargetDataColumn.Get(context); Int32 columnIndex = ColumnIndex.Get(context); Int32 targetColumnIndex = ColumnIndex.Get(context); string columnName = ColumnName.Get(context); string targetColumnName = TargetColumnName.Get(context); object cellValue = null; Int32 rowIndex = 0; try { int beginIndex = 0, endInex = 0; DataColumn beginColumn = new DataColumn(); if (dataColumn != null) { beginIndex = dataTable.Columns.IndexOf(dataColumn); } else if (columnName != null && columnName != "") { beginIndex = dataTable.Columns.IndexOf(columnName); } else { beginIndex = columnIndex; } if (targetDataColumn != null) { endInex = dataTable.Columns.IndexOf(targetDataColumn); } else if (targetColumnName != null && targetColumnName != "") { endInex = dataTable.Columns.IndexOf(targetColumnName); } else { endInex = targetColumnIndex; } if (beginIndex < 0 || endInex < 0 || beginIndex > endInex) { SharedObject.Instance.Output(SharedObject.enOutputType.Error, "数据表列索引有误,请检查开始列与结束列"); return; } DataRowCollection dataRows = dataTable.Rows; for (int index = beginIndex; index < endInex; index++) { foreach (DataRow datarow in dataRows) { object data = datarow[index]; string dataStr = data as string; if (dataStr.Equals(lookupValue)) { rowIndex = dataRows.IndexOf(datarow); cellValue = data; break; } } } if (CellValue != null) { CellValue.Set(context, cellValue); } if (RowIndex != null) { RowIndex.Set(context, rowIndex); } } catch (Exception e) { SharedObject.Instance.Output(SharedObject.enOutputType.Error, "查找数据表失败", e.Message); } }