private void TransferQueueToDatebase(string messageQueuePath) { try { var simpleMessageQueueWrapper = new SimpleMessageQueueWrapper <IDictionary <string, object> >(); simpleMessageQueueWrapper.Initialize(messageQueuePath); var dictionary = simpleMessageQueueWrapper.Peek(); int num = 500; while (dictionary != null && num-- >= 0) { IEnumerable <string> source = from key in dictionary.Keys where key.Contains("MeasureTime") select key; string timeKeyName = source.FirstOrDefault <string>(); if (timeKeyName != null) { DateTime dateTime = (DateTime)dictionary[timeKeyName]; IEnumerable <string> enumerable = from key in dictionary.Keys where key != timeKeyName select key; foreach (string current in enumerable) { MeasuredValue measuredValue = new MeasuredValue(); measuredValue.Name = current; measuredValue.Quality = OPCQuality.Good; measuredValue.TimeStamp = (DateTime)dictionary[timeKeyName]; measuredValue.Description = ""; measuredValue.Value = dictionary[current]; if (measuredValue.Value is long) { measuredValue.Value = Convert.ToInt32(measuredValue.Value.ToString()); } _Logger.DebugFormat("save to local DB: {0}", measuredValue); ValueTableWriter.SaveValueWhenConditionsAreMet(measuredValue, _CompressionConditionManager.GetConfigFor(current)); } dictionary = simpleMessageQueueWrapper.Receive(); } else { _Logger.Error("cannot find a 'MeasureTime' in the message directory. Send message to ErrorQueue"); _ErrorQueue.Send(dictionary); dictionary = simpleMessageQueueWrapper.Receive(); } dictionary = simpleMessageQueueWrapper.Peek(); } ValueTableWriter.TransferDataToDestDB(); } catch (Exception ex) { _Logger.Error(ex.Message, ex); } }
protected MeasureValueBox ReceiveFromQueue() { return(_Queue.Receive()); }