init
This commit is contained in:
60
DataPRO/ICommand/CommandLogEntryBase.cs
Normal file
60
DataPRO/ICommand/CommandLogEntryBase.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
namespace DTS.DASLib.Command
|
||||
{
|
||||
/// <summary>
|
||||
/// this is an abstraction of the LogEntryBase classes, I extracted the common
|
||||
/// functionality and put it here
|
||||
/// this class in turn is used by SliceCommandLogEntry and CommonLogEntry(ribeye)
|
||||
/// the reason for the additional classes is the structure of the packets and how the log looks
|
||||
/// differs slightly between ribeye and slice
|
||||
/// I'm not sure these classes are in use?
|
||||
/// 6/14/2010 - dtm
|
||||
/// </summary>
|
||||
public abstract class CommandLogEntryBase
|
||||
{
|
||||
protected StringBuilder sb;
|
||||
protected CommandPacketBase command;
|
||||
/// <summary>
|
||||
/// construct a CommandLogEntryBase object
|
||||
/// </summary>
|
||||
/// <param name="_command">underlying command</param>
|
||||
public CommandLogEntryBase(CommandPacketBase _command)
|
||||
{
|
||||
sb = new StringBuilder();
|
||||
command = _command;
|
||||
sb.AppendFormat("=== {0:08d} ==={1}", _command.SequenceNumber, Environment.NewLine);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// adds command data into log
|
||||
/// </summary>
|
||||
/// <param name="CommandName"></param>
|
||||
public void TagCommonCommandData(string CommandName)
|
||||
{
|
||||
sb.AppendFormat("Log Entry Type:\t\t{0} command{1}", CommandName, Environment.NewLine);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// adds response data into log
|
||||
/// </summary>
|
||||
/// <param name="CommandName"></param>
|
||||
public void TagCommonResponseData(string CommandName)
|
||||
{
|
||||
sb.AppendFormat("Response Status:\t\t{0}{1}", command.Status, Environment.NewLine);
|
||||
sb.AppendFormat("Response Timestamp:\t{0} {1}{2}", DateTime.Now.ToShortDateString(),
|
||||
DateTime.Now.ToLongTimeString(), Environment.NewLine);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// returns the log entry represented as a string
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user