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) { 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 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); } }