1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
|
private void ProduceEvents()
{
var currEvent = default(PointEvent<Stream>);
EnqueueCtiEvent(new DateTimeOffset(_config.StartDate, TimeSpan.Zero));
Console.WriteLine("CTI : 10/07/2008 00:00:02");
try
{
// Loop until stop signal
while (AdapterState != AdapterState.Stopping)
{
if (pendingEvent != null)
{
currEvent = pendingEvent;
pendingEvent = null;
}
else
{
if (pointeurCopieFichier.MoveNext())
{
try
{
var quote = pointeurCopieFichier.Current;
// Produce INSERT event
currEvent = CreateInsertEvent();
currEvent.StartTime = DateTime.Parse(quote.Value[0], QuoteFormatProvider);
//Console.WriteLine(DateTime.Parse(quote.Value[0], QuoteFormatProvider));
currEvent.Payload = new Stream
{
Timestamp = DateTime.Parse(quote.Value[0], QuoteFormatProvider),
NomPlateau = quote.Value[1],
NomFlux = quote.Value[2],
NombreAppels = double.Parse(quote.Value[3], QuoteFormatProvider)
};
pendingEvent = null;
PrintEvent(currEvent);
Enqueue(ref currEvent);
Console.WriteLine("J'ajoute l'événement");
EnqueueCtiEvent(new DateTimeOffset(DateTime.Parse("10/07/2008 00:00:06", QuoteFormatProvider), TimeSpan.Zero));
var date = new DateTimeOffset(DateTime.Parse(quote.Value[0], QuoteFormatProvider), TimeSpan.Zero);
//var date = new DateTimeOffset(DateTime.Now, TimeSpan.Zero);
// Also send an CTI event : cela signifie que le flux est achevé : aucun événement après cette date ne peut être inséré :
//l'info peut être propagée.
EnqueueCtiEvent(date);
}
catch
{
Console.WriteLine("ERREUR, les données ne rentrent pas dans la file !"); // Error handling should go here
}
Thread.Sleep(_config.Interval);
}
else
{
break;
}
}
}
if (pendingEvent != null)
{
currEvent = pendingEvent;
pendingEvent = null;
}
PrepareToStop(currEvent);
Stopped();
}
catch (AdapterException e)
{
Console.WriteLine("ERRREUR : AdvantIQ.StockInsightTypedPointInput.ProduceEvents - " + e.Message + e.StackTrace);
}
} |
Partager