69 lines
2.1 KiB
C#
69 lines
2.1 KiB
C#
// using System;
|
|
// using System.Collections.Generic;
|
|
// using System.Linq;
|
|
// using System.Text;
|
|
// using System.IO;
|
|
|
|
// namespace BCG
|
|
// {
|
|
// public class RecorderStream : ViewStream
|
|
// {
|
|
// private ViewStream mySource;
|
|
// private DateTime myStartTime;
|
|
// private FileStream myOutFile;
|
|
// private string myFileName;
|
|
// private IBlueDataSerializer mySerializer;
|
|
|
|
// public RecorderStream(ViewStream src, string recordFile)
|
|
// {
|
|
// mySource = src;
|
|
// myFileName = recordFile;
|
|
|
|
// myFileName = myFileName.Replace("%DATE%", DateTime.Now.ToString("yyyyMMdd_HHmmss"));
|
|
// }
|
|
|
|
// protected override void myOnFirstSubscriber()
|
|
// {
|
|
// myStartTime = DateTime.Now;
|
|
// mySource.onChange += new ChangeDelegate(mySource_onChange);
|
|
// myOutFile = new FileStream(myFileName, FileMode.OpenOrCreate);
|
|
// }
|
|
|
|
// protected override void myOnLastSubscriber()
|
|
// {
|
|
// mySource.onChange -= mySource_onChange;
|
|
// myOutFile.Close();
|
|
// }
|
|
|
|
// void mySource_onChange(object newValue)
|
|
// {
|
|
// DataPacket dp = (DataPacket)newValue;
|
|
|
|
// BlueTable toWrite = new BlueTable(dp.schema);
|
|
|
|
// if (mySerializer == null)
|
|
// {
|
|
// mySerializer = new UniversalSerializer(dp.schema);
|
|
// }
|
|
// foreach (IBlueRow r in dp.newRows)
|
|
// toWrite.addRow(r);
|
|
|
|
// byte[] result;
|
|
|
|
// if (myLastValue == null)
|
|
// mySerializer.serialize(StreamOpCode.create, new IBlueRowCollection[] { dp.newRows }, out result);
|
|
// else
|
|
// mySerializer.serialize(StreamOpCode.multipleRemoveAdd, new IBlueRowCollection[] { dp.deletedRows, dp.addedRows }, out result);
|
|
|
|
// BinaryWriter bw = new BinaryWriter(myOutFile);
|
|
// //write down what time this happened
|
|
// bw.Write((DateTime.Now - myStartTime).TotalSeconds);
|
|
// bw.Write(result.Length);
|
|
// bw.Write(result);
|
|
// myOutFile.Flush();
|
|
|
|
// myFireEvent(dp);
|
|
// }
|
|
// }
|
|
// }
|