/// <summary> /// <c>AddToQueue</c> /// Stuffs new records into the write queue along with their asociated types and formats them /// </summary> /// <param name="type"></param> /// <param name="fieldList"></param> public void AddToQueue(string type, List <Field> fieldList) { if (DontSend) { return; } var dataLen = 0; if (IsEmpty) { return; } if (LocalWriteQueue == null) { EventLogger.Error("Null Queue"); throw new ArgumentNullException($"Invalid Queue"); } if (fieldList == null) { EventLogger.Error("Null parameters to base.Write()"); throw new ArgumentNullException($"Bad Tag List"); } var record = "<Record>"; try { CheckDependencies(fieldList); foreach (var tag in fieldList) { // Qualify field requirement // if required and when == action && is_blank -> throw record += "<" + tag.TagName + ">" + tag.TagData + "</" + tag.TagName + ">"; // If there's no data other than Table and Action we should ignore it. if (tag.TagName.ToUpper() != "TABLE" && tag.TagName.ToUpper() != "ACTION") { dataLen += tag.TagData.Length; } } record += "</Record>"; if (dataLen > 0) { LocalWriteQueue.Add(type, record); } } catch (Exception ex) { EventLogger.Error("Add To Queue: {0)\n{1}", ex.Message, record); throw; } }
/// <summary> /// <c>Write Queue</c> /// Pushes everything in the queue to the passed stream /// </summary> /// <param name="stream"></param> public void WriteQueue(NetworkStream stream) { try { if (LocalWriteQueue == null) { throw new ArgumentNullException($"Invalid Queue"); } LocalWriteQueue.Write(stream); LocalWriteQueue.Clear(); } catch { throw; } }
/// <summary> /// <c>WriteQueue</c> /// Pushes everything in the queue to the passed socket /// </summary> /// <param name="socket"></param> public void WriteQueue(MotSocket socket) { if (socket == null) { throw new ArgumentNullException(nameof(socket)); } try { if (LocalWriteQueue == null) { throw new ArgumentNullException($"Invalid Queue"); } LocalWriteQueue.Write(socket); LocalWriteQueue.Clear(); } catch (Exception ex) { EventLogger.Error($"WriteQueue: {ex.Message}"); throw; } }