コード例 #1
0
        public static string FieldValueToString(object value, RuleColumn rc)
        {
            if (value == null)
            {
                return("");
            }
            else if (rc != null)
            {
                switch (rc.DataType)
                {
                case DataTypes.dtBLOB:
                    return(BCUtil.Encode(value as byte[]));

                case DataTypes.dtLONG:
                    return(BCUtil.Encode(value as byte[]));

                case DataTypes.dtCLOB:
                    return(BCUtil.Encode(value.ToString()));

                case DataTypes.dtXMLType:
                    return(BCUtil.Encode(value.ToString()));

                case DataTypes.dtBoolean:
                    return(BCUtil.Encode((bool)value == true ? "1" : "0"));

                default:
                    return(BCUtil.Encode(value.ToString()));
                }
            }
            else if (value is byte[])
            {
                return(BCUtil.Encode(value as byte[]));
            }
            else
            {
                return(BCUtil.Encode(value.ToString()));
            }
        }
コード例 #2
0
        private static void FillTableData(DataTable table, string body, int offset, int length)
        {
            string            colFlag = "<F", curColFlag, curRow, curCol, curBody = body;
            DataRowCollection datarows = table.Rows;
            DataRow           row      = null;

            DataColumnCollection columns = table.Columns;
            DataColumn           column;
            int sdpDataType = 0;

            int index, subindex;

            string[] rows = StrUtil.GetParamList(curBody, "<R>");

            table.Clear();
            if (offset < 0)
            {
                offset = 0;
            }
            if (length < 0)
            {
                length = rows.Length - offset;
            }

            int limit = offset + length >= rows.Length ? rows.Length : offset + length;

            for (int i = 0; i < length; i++)
            {
                if (offset + i >= limit)
                {
                    break;
                }

                curRow = rows[offset + i];
                if (curRow.Equals(""))
                {
                    continue;
                }
                curRow = StrUtil.ReplaceStr(curRow, SignConstant.RowReplace, SignConstant.RowSign);

                row = table.NewRow();
                for (int j = 0; j < columns.Count; j++)
                {
                    curColFlag = colFlag + Convert.ToString(j) + ">";
                    index      = curRow.IndexOf(curColFlag);
                    if (index > 0)
                    {
                        curCol   = curRow.Substring(0, index);
                        subindex = curRow.Length - index - curColFlag.Length;
                        curRow   = curRow.Substring(index + curColFlag.Length, subindex);
                        if (!curCol.Equals(""))
                        {
                            curCol      = StrUtil.ReplaceStr(curCol, SignConstant.FieldReplace, SignConstant.FieldSign);
                            column      = columns[j];
                            sdpDataType = TableUtil.IntProperty(column, "SDPDataType");

                            if (sdpDataType == 0)
                            {
                                sdpDataType = DataTypes.ToDataType(column.DataType);
                            }

                            switch (sdpDataType)
                            {
                            case DataTypes.dtBLOB:
                                row[j] = BCUtil.Decode(curCol);
                                break;

                            case DataTypes.dtCLOB:
                                row[j] = StrUtil.FromByteArray(BCUtil.Decode(curCol));
                                break;

                            case DataTypes.dtXMLType:
                                row[j] = StrUtil.FromByteArray(BCUtil.Decode(curCol));
                                break;

                            case DataTypes.dtBoolean:
                                row[j] = curCol.Equals("1") ? true : false;
                                break;

                            //case DataTypes.dtDateTime:
                            //    row[j] = Convert.ToDateTime(curCol);
                            //    break;
                            //case DataTypes.dtDate:
                            //    row[j] = Convert.ToDateTime(curCol);
                            //    break;
                            //case DataTypes.dtTime:
                            //    row[j] = Convert.ToDateTime(curCol);
                            //    break;
                            default:
                                row[j] = curCol;
                                break;
                            }
                        }
                    }
                }
                datarows.Add(row);
            }
            if (length > 0)
            {
                table.AcceptChanges();
            }
        }