コード例 #1
0
        /// <summary>
        /// Write result set to a binary file for later retrieval
        /// </summary>

        public void WriteBinaryResultsFile(string fileName)
        {
            int id = Query.UserObject.Id;

            if (id <= 0)
            {
                throw new Exception("UserObject id not defined, Query not saved");
            }

            BinaryWriter bw = BinaryFile.OpenWriter(fileName + ".new"); // open ".new" file
            string       sq = Query.Serialize();                        // serialize & write the query

            bw.Write(sq);
            int voArrayLen = DataTableMx.Columns.Count - KeyValueVoPos; // don't write values before the key

            bw.Write(voArrayLen);                                       // write the array length

            for (int dri = 0; dri < DataTableMx.Rows.Count; dri++)
            {
                DataRowMx dr = DataTableMx.Rows[dri];
                VoArray.WriteBinaryVoArray(dr.ItemArrayRef, bw, KeyValueVoPos);
            }

            bw.Close();
            FileUtil.BackupAndReplaceFile(fileName, fileName + ".bak", fileName + ".new");

            return;
        }