Пример #1
0
        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);
        }
Пример #2
0
        protected override void Execute(CodeActivityContext context)
        {
            DataTable dataTable = DataTable.Get(context);
            DataView  dataView  = dataTable.AsDataView();
            DataTable outTable  = dataView.ToTable(true);

            OutDataTable.Set(context, outTable);
        }
Пример #3
0
        protected override void Execute(CodeActivityContext context)
        {
            Encoding csvEncoding;
            string   filePath     = PathUrl.Get(context);
            string   encodingType = EncodingType.Get(context);
            string   delimiter    = ",";

            if (Delimiter == DelimiterEnums.Caret插入符号)
            {
                delimiter = "^";
            }
            else if (Delimiter == DelimiterEnums.Comma逗号)
            {
                delimiter = ",";
            }
            else if (Delimiter == DelimiterEnums.Pipe竖线)
            {
                delimiter = "|";
            }
            else if (Delimiter == DelimiterEnums.Semicolon分号)
            {
                delimiter = ";";
            }
            else if (Delimiter == DelimiterEnums.Tab制表符)
            {
                delimiter = "	";
            }

            if (!File.Exists(filePath))
            {
                SharedObject.Instance.Output(SharedObject.enOutputType.Error, "文件不存在,请检查路径有效性", filePath);
                return;
            }

            /*取字符编码 如果为空则取文件编码 异常则取系统默认编码*/
            try
            {
                if (encodingType == null)
                {
                    csvEncoding = CSVEncoding.GetEncodingType(filePath);
                }
                else
                {
                    csvEncoding = Encoding.GetEncoding(encodingType);
                }
            }
            catch (Exception)
            {
                csvEncoding = System.Text.Encoding.Default;
            }

            /*设置DataTable*/
            try
            {
                DataTable dataTable = ReadCSVFile(filePath, csvEncoding, delimiter);
                OutDataTable.Set(context, dataTable);
                foreach (DataRow dr in dataTable.Rows)
                {
                    for (int i = 0; i < dataTable.Columns.Count; i++)
                    {
                        System.Diagnostics.Debug.WriteLine("dt : " + dr[i]);
                    }
                }
            }
            catch (Exception e)
            {
                SharedObject.Instance.Output(SharedObject.enOutputType.Error, "EXCEL执行过程出错", e.Message);
                throw e;
            }
        }