Esempio n. 1
0
        public int mWriteMap(RecordSetMD aRecordSetMD)
        //throws com.WDataSci.WDS.WDSException
        {
            try {
                if (this.Header.Buffer == null)
                {
                    throw new com.WDataSci.WDS.WDSException("Error, Header buffer not set before WriteMap!");
                }

                long nColumns = aRecordSetMD.nColumns();
                int  nColumnNameMaxByteLength = (int)(this.Header.MaxStringByteLength);

                DBB buf = this.Header.Buffer;
                buf.cAsUsualLayout("WDSH", nColumns, 40, 2 * nColumnNameMaxByteLength);
                buf.position(0, 0, 0);

                int bptr = 0;

                //write leading data
                buf.PutLayerFLenString(0, "WDSH", 8, 0);
                buf.PutLayerLong(0, buf.nDBBRequiredBytes);
                buf.PutLayerLong(0, buf.nDBBLeadingBytes);
                buf.PutLayerLong(0, buf.nDBBFLenBytes);
                buf.PutLayerLong(0, buf.nDBBVLenBytes);
                buf.PutLayerLong(0, buf.nRecords);
                buf.PutLayerLong(0, buf.nRecordFLenBytes);
                buf.PutLayerLong(0, buf.nRecordVLenBytes);

                buf.position(buf.ptr, 0, 0);
                //here bptr is relative only to layer 1
                bptr = 0;

                for (int jj = 0; jj < nColumns; jj++, bptr += (int)buf.nRecordFLenBytes)
                {
                    aRecordSetMD.Column[jj].Consistency();
                    buf.position(buf.ptr, bptr, buf.vlenptr);
                    buf.PutLayerVLenString(1, aRecordSetMD.Column[jj].Name, nColumnNameMaxByteLength, 2);
                    if (aRecordSetMD.Column[jj].MapKey != null)
                    {
                        buf.PutLayerVLenString(1, aRecordSetMD.Column[jj].MapKey.getValue(), nColumnNameMaxByteLength, 2);
                    }
                    else
                    {
                        buf.PutLayerVLenString(1, "", nColumnNameMaxByteLength, 2);
                    }
                    buf.PutLayerInt(1, aRecordSetMD.Column[jj].DTyp.AsInt());
                    buf.PutLayerLong(1, aRecordSetMD.Column[jj].ByteMemLength);
                    buf.PutLayerLong(1, aRecordSetMD.Column[jj].ByteMaxLength);
                }

                return(0);
            }
            catch (Exception e) {
                throw new com.WDataSci.WDS.WDSException("Error in writing output map to DBB", e);
            }
        }
Esempio n. 2
0
        public int mWriteRecordSet(RecordSetMD inRecordSetMD
                                   , Object[,] r
                                   , Boolean bIncludesHeaderRow
                                   )
        {
            try {
                if (this.RecordSet.Buffer == null)
                {
                    throw new com.WDataSci.WDS.WDSException("Error, RecordSet buffer not set before WriteSet!");
                }

                DBB buf = this.RecordSet.Buffer;

                int rowstartindex = r.GetLowerBound(0);
                int nRows         = r.GetUpperBound(0) - rowstartindex + 1;
                if (bIncludesHeaderRow)
                {
                    nRows         -= 1;
                    rowstartindex += 1;
                }
                int nColumns = r.GetUpperBound(1) - r.GetLowerBound(1) + 1;

                if (nColumns != inRecordSetMD.nColumns())
                {
                    throw new com.WDataSci.WDS.WDSException("Error, Excel ListObject #columns does not match RecordSetMD #columns");
                }

                this.mWritePrepFor(inRecordSetMD, nRows);

                buf.position(0, 0, 0);


                //write leading data
                buf.PutLayerFLenString(0, "WDSD", 8, 0);
                buf.PutLayerLong(0, buf.nDBBRequiredBytes);
                buf.PutLayerLong(0, buf.nDBBLeadingBytes);
                buf.PutLayerLong(0, buf.nDBBFLenBytes);
                buf.PutLayerLong(0, buf.nDBBVLenBytes);
                buf.PutLayerLong(0, buf.nRecords);
                buf.PutLayerLong(0, buf.nRecordFLenBytes);
                buf.PutLayerLong(0, buf.nRecordVLenBytes);

                int bptr = 0;
                //bptr = (int) buf.nDBBLeadingBytes;



                int nInputColumns = inRecordSetMD.nColumns();



                for (int i = 0, ii = rowstartindex; i < nRows; i++, ii++)
                {
                    if (i > 0)
                    {
                        bptr += (int)this.RecordSet.Buffer.nRecordFLenBytes;
                    }
                    long lbptr = bptr;
                    buf.position(buf.ptr, (int)bptr, buf.vlenptr);

                    for (int j = 0, jj = r.GetLowerBound(1); j < nColumns; j++, jj++)
                    {
                        Object obj = r [ii, jj];
                        switch (inRecordSetMD.Column [j].DTyp)
                        {
                        case FieldMDEnums.eDTyp.Dbl:
                            buf.PutLayerDouble(1, obj);
                            break;

                        case FieldMDEnums.eDTyp.Lng:
                            buf.PutLayerLong(1, obj);
                            break;

                        case FieldMDEnums.eDTyp.Dte:
                            buf.PutLayerDouble(1, obj);
                            break;

                        case FieldMDEnums.eDTyp.DTm:
                            buf.PutLayerDouble(1, obj);
                            break;

                        case FieldMDEnums.eDTyp.Int:
                            buf.PutLayerInt(1, obj);
                            break;

                        case FieldMDEnums.eDTyp.Str:
                            buf.PutLayerFLenString(1, Convert.ToString(obj), (int)inRecordSetMD.Column [j].ByteMaxLength, 2);
                            break;

                        case FieldMDEnums.eDTyp.VLS:
                            buf.PutLayerVLenString(1, Convert.ToString(obj), (int)inRecordSetMD.Column [j].ByteMaxLength, 2);
                            break;

                        default:
                            throw new Exception("Hey");
                        }
                    }
                }

                return(0);
            }
            catch (Exception e) {
                throw new com.WDataSci.WDS.WDSException("Error in writing output map to DBB", e);
            }
        }
Esempio n. 3
0
        /* C# >>> */
        public int mWriteRecordSet(RecordSetMD inRecordSetMD
                                   , MOIE.ListObject aListObject
                                   )
        {
            try {
                if (this.RecordSet.Buffer == null)
                {
                    throw new com.WDataSci.WDS.WDSException("Error, RecordSet buffer not set before WriteSet!");
                }

                DBB buf = this.RecordSet.Buffer;

                int nRows    = aListObject.ListRows.Count;
                int nColumns = aListObject.ListColumns.Count;

                if (nColumns != inRecordSetMD.nColumns())
                {
                    throw new com.WDataSci.WDS.WDSException("Error, Excel ListObject #columns does not match RecordSetMD #columns");
                }

                this.mWritePrepFor(inRecordSetMD, nRows);

                buf.position(0, 0, 0);


                //write leading data
                buf.PutLayerFLenString(0, "WDSD", 8, 0);
                buf.PutLayerLong(0, buf.nDBBRequiredBytes);
                buf.PutLayerLong(0, buf.nDBBLeadingBytes);
                buf.PutLayerLong(0, buf.nDBBFLenBytes);
                buf.PutLayerLong(0, buf.nDBBVLenBytes);
                buf.PutLayerLong(0, buf.nRecords);
                buf.PutLayerLong(0, buf.nRecordFLenBytes);
                buf.PutLayerLong(0, buf.nRecordVLenBytes);

                int bptr = 0;
                //bptr = (int) buf.nDBBLeadingBytes;



                int nInputColumns = inRecordSetMD.nColumns();


                object[,] r = aListObject.Range.Value2;

                for (int i = 0, iP2 = 2; i < nRows; i++, iP2++)
                {
                    if (i > 0)
                    {
                        bptr += (int)this.RecordSet.Buffer.nRecordFLenBytes;
                    }
                    long lbptr = bptr;
                    buf.position(buf.ptr, (int)bptr, buf.vlenptr);

                    for (int j = 0, jP1 = 1; j < nColumns; j++, jP1++)
                    {
                        Object obj = r[iP2, jP1];
                        switch (inRecordSetMD.Column[j].DTyp)
                        {
                        case FieldMDEnums.eDTyp.Dbl:
                            buf.PutLayerDouble(1, obj);
                            break;

                        case FieldMDEnums.eDTyp.Lng:
                            buf.PutLayerLong(1, obj);
                            break;

                        case FieldMDEnums.eDTyp.Dte:
                            buf.PutLayerDouble(1, obj);
                            break;

                        case FieldMDEnums.eDTyp.DTm:
                            buf.PutLayerDouble(1, obj);
                            break;

                        case FieldMDEnums.eDTyp.Int:
                            buf.PutLayerInt(1, obj);
                            break;

                        case FieldMDEnums.eDTyp.Str:
                            buf.PutLayerFLenString(1, Convert.ToString(obj), (int)inRecordSetMD.Column[j].ByteMaxLength, 2);
                            break;

                        case FieldMDEnums.eDTyp.VLS:
                            buf.PutLayerVLenString(1, Convert.ToString(obj), (int)inRecordSetMD.Column[j].ByteMaxLength, 2);
                            break;

                        default:
                            throw new Exception("Hey");
                        }
                    }
                }

                return(0);
            }
            catch (Exception e) {
                throw new com.WDataSci.WDS.WDSException("Error in writing output map to DBB", e);
            }
        }
Esempio n. 4
0
        public int mWriteRecordSet(RecordSetMD outRecordSetMD
                                   , RecordSet aOutputRecordSet
                                   , RecordSetMD inRecordSetMD
                                   , RecordSet aInputRecordSet
                                   )
        //throws com.WDataSci.WDS.WDSException
        {
            try {
                if (this.RecordSet.Buffer == null)
                {
                    throw new com.WDataSci.WDS.WDSException("Error, RecordSet buffer not set before WriteSet!");
                }

                DBB buf = this.RecordSet.Buffer;

                int nRows = aOutputRecordSet.Records.size();
                this.mWritePrepFor(outRecordSetMD, nRows);

                buf.position(0, 0, 0);

                int bptr = 0;

                //write leading data
                buf.PutLayerFLenString(0, "WDSD", 8, 0);
                buf.PutLayerLong(0, buf.nDBBRequiredBytes);
                buf.PutLayerLong(0, buf.nDBBLeadingBytes);
                buf.PutLayerLong(0, buf.nDBBFLenBytes);
                buf.PutLayerLong(0, buf.nDBBVLenBytes);
                buf.PutLayerLong(0, buf.nRecords);
                buf.PutLayerLong(0, buf.nRecordFLenBytes);
                buf.PutLayerLong(0, buf.nRecordVLenBytes);

                int nColumns = outRecordSetMD.nColumns();

                int nInputColumns = inRecordSetMD.nColumns();


                bptr = 0;
                for (int i = 0; i < nRows; i++, bptr += (int)buf.nRecordFLenBytes)
                {
                    buf.position(buf.ptr, bptr, buf.vlenptr);

                    Map <FieldName, Object> outRow = aOutputRecordSet.Records.get(i);
                    Object[] inRow = null;

                    if (outRecordSetMD.ModeMatter.bRepeatInputFields)
                    {
                        inRow = aInputRecordSet.Records_Orig.get(i);
                    }

                    Boolean bInInputSet = outRecordSetMD.ModeMatter.bRepeatInputFields;
                    int     j           = 0;
                    int     jj          = 0;

                    for (jj = 0, j = 0; jj < nColumns; jj++, j++)
                    {
                        if (bInInputSet && jj == nInputColumns)
                        {
                            bInInputSet = false;
                            j           = 0;
                        }

                        Object lv = 0;

                        if (bInInputSet)
                        {
                            lv = inRow[j];
                        }
                        else
                        {
                            lv = outRow.get(outRecordSetMD.Column[j].MapKey);
                        }

                        switch (outRecordSetMD.Column[jj].DTyp)
                        {
                        //case Dbl:
                        case FieldMDEnums.eDTyp.Dbl:
                            if (lv == null)
                            {
                                lv = Double.NaN;
                            }
                            buf.PutLayerDouble(1, (double)lv);
                            break;

                        //case Lng:
                        case FieldMDEnums.eDTyp.Lng:
                            //Java if ( lv == null ) lv = Long.MIN_VALUE;
                            //C#
                            if (lv == null)
                            {
                                lv = long.MinValue;
                            }
                            buf.PutLayerLong(1, (long)lv);
                            break;

                        //case Int:
                        case FieldMDEnums.eDTyp.Int:
                            //Java if ( lv == null ) lv = Integer.MIN_VALUE;
                            //C#
                            if (lv == null)
                            {
                                lv = int.MinValue;
                            }
                            buf.PutLayerInt(1, (int)lv);
                            break;

                        //case Dte:
                        case FieldMDEnums.eDTyp.Dte:
                            if (lv == null)
                            {
                                lv = Double.NaN;
                            }
                            buf.PutLayerDouble(1, (double)lv);
                            break;

                        //case DTm:
                        case FieldMDEnums.eDTyp.DTm:
                            if (lv == null)
                            {
                                lv = Double.NaN;
                            }
                            buf.PutLayerDouble(1, (double)lv);
                            break;

                        //case Str:
                        case FieldMDEnums.eDTyp.Str:
                            buf.PutLayerFLenString(1, (String)lv, (int)outRecordSetMD.Column[jj].ByteMaxLength, 2);
                            break;

                        //case VLS:
                        case FieldMDEnums.eDTyp.VLS:
                            buf.PutLayerVLenString(1, (String)lv, (int)outRecordSetMD.Column[jj].ByteMaxLength, 2);
                            break;

                        default:
                            throw new com.WDataSci.WDS.WDSException("Error, unImplemented column type" + outRecordSetMD.Column[jj].DTyp.ToString());
                        }
                    }
                }

                return(0);
            }
            catch (Exception e) {
                throw new com.WDataSci.WDS.WDSException("Error in writing output map to DBB", e);
            }
        }