Overwrite

Complete Overwrite of the Folder with the free shard. ServUO 57.3 has been added.
This commit is contained in:
Unstable Kitsune
2023-11-28 23:20:26 -05:00
parent 3cd54811de
commit b918192e4e
11608 changed files with 2644205 additions and 47 deletions

View File

@@ -0,0 +1,126 @@
using System;
using Server.Accounting;
namespace Server.Engines.Reports
{
public abstract class BaseInfo : IComparable
{
private static TimeSpan m_SortRange;
private string m_Account;
private string m_Display;
private PageInfoCollection m_Pages;
public BaseInfo(string account)
{
this.m_Account = account;
this.m_Pages = new PageInfoCollection();
}
public static TimeSpan SortRange
{
get
{
return m_SortRange;
}
set
{
m_SortRange = value;
}
}
public string Account
{
get
{
return this.m_Account;
}
set
{
this.m_Account = value;
}
}
public PageInfoCollection Pages
{
get
{
return this.m_Pages;
}
set
{
this.m_Pages = value;
}
}
public string Display
{
get
{
if (this.m_Display != null)
return this.m_Display;
if (this.m_Account != null)
{
IAccount acct = Accounts.GetAccount(this.m_Account);
if (acct != null)
{
Mobile mob = null;
for (int i = 0; i < acct.Length; ++i)
{
Mobile check = acct[i];
if (check != null && (mob == null || check.AccessLevel > mob.AccessLevel))
mob = check;
}
if (mob != null && mob.Name != null && mob.Name.Length > 0)
return (this.m_Display = mob.Name);
}
}
return (this.m_Display = this.m_Account);
}
}
public int GetPageCount(PageResolution res, DateTime min, DateTime max)
{
return StaffHistory.GetPageCount(this.m_Pages, res, min, max);
}
public void Register(PageInfo page)
{
this.m_Pages.Add(page);
}
public void Unregister(PageInfo page)
{
this.m_Pages.Remove(page);
}
public int CompareTo(object obj)
{
BaseInfo cmp = obj as BaseInfo;
int v = cmp.GetPageCount(cmp is StaffInfo ? PageResolution.Handled : PageResolution.None, DateTime.UtcNow - m_SortRange, DateTime.UtcNow) -
this.GetPageCount(this is StaffInfo ? PageResolution.Handled : PageResolution.None, DateTime.UtcNow - m_SortRange, DateTime.UtcNow);
if (v == 0)
v = String.Compare(this.Display, cmp.Display);
return v;
}
}
public class StaffInfo : BaseInfo
{
public StaffInfo(string account)
: base(account)
{
}
}
public class UserInfo : BaseInfo
{
public UserInfo(string account)
: base(account)
{
}
}
}

View File

@@ -0,0 +1,331 @@
using System;
using Server.Engines.Help;
namespace Server.Engines.Reports
{
public enum PageResolution
{
None,
Handled,
Deleted,
Logged,
Canceled
}
public class PageInfo : PersistableObject
{
#region Type Identification
public static readonly PersistableType ThisTypeID = new PersistableType("pi", new ConstructCallback(Construct));
private static PersistableObject Construct()
{
return new PageInfo();
}
public override PersistableType TypeID
{
get
{
return ThisTypeID;
}
}
#endregion
private StaffHistory m_History;
private StaffInfo m_Resolver;
private UserInfo m_Sender;
public StaffInfo Resolver
{
get
{
return this.m_Resolver;
}
set
{
if (this.m_Resolver == value)
return;
lock (StaffHistory.RenderLock)
{
if (this.m_Resolver != null)
this.m_Resolver.Unregister(this);
this.m_Resolver = value;
if (this.m_Resolver != null)
this.m_Resolver.Register(this);
}
}
}
public UserInfo Sender
{
get
{
return this.m_Sender;
}
set
{
if (this.m_Sender == value)
return;
lock (StaffHistory.RenderLock)
{
if (this.m_Sender != null)
this.m_Sender.Unregister(this);
this.m_Sender = value;
if (this.m_Sender != null)
this.m_Sender.Register(this);
}
}
}
private PageType m_PageType;
private PageResolution m_Resolution;
private DateTime m_TimeSent;
private DateTime m_TimeResolved;
private string m_SentBy;
private string m_ResolvedBy;
private string m_Message;
private ResponseInfoCollection m_Responses;
public StaffHistory History
{
get
{
return this.m_History;
}
set
{
if (this.m_History == value)
return;
if (this.m_History != null)
{
this.Sender = null;
this.Resolver = null;
}
this.m_History = value;
if (this.m_History != null)
{
this.Sender = this.m_History.GetUserInfo(this.m_SentBy);
this.UpdateResolver();
}
}
}
public PageType PageType
{
get
{
return this.m_PageType;
}
set
{
this.m_PageType = value;
}
}
public PageResolution Resolution
{
get
{
return this.m_Resolution;
}
}
public DateTime TimeSent
{
get
{
return this.m_TimeSent;
}
set
{
this.m_TimeSent = value;
}
}
public DateTime TimeResolved
{
get
{
return this.m_TimeResolved;
}
}
public string SentBy
{
get
{
return this.m_SentBy;
}
set
{
this.m_SentBy = value;
if (this.m_History != null)
this.Sender = this.m_History.GetUserInfo(this.m_SentBy);
}
}
public string ResolvedBy
{
get
{
return this.m_ResolvedBy;
}
}
public string Message
{
get
{
return this.m_Message;
}
set
{
this.m_Message = value;
}
}
public ResponseInfoCollection Responses
{
get
{
return this.m_Responses;
}
set
{
this.m_Responses = value;
}
}
public void UpdateResolver()
{
string resolvedBy;
DateTime timeResolved;
PageResolution res = this.GetResolution(out resolvedBy, out timeResolved);
if (this.m_History != null && this.IsStaffResolution(res))
this.Resolver = this.m_History.GetStaffInfo(resolvedBy);
else
this.Resolver = null;
this.m_ResolvedBy = resolvedBy;
this.m_TimeResolved = timeResolved;
this.m_Resolution = res;
}
public bool IsStaffResolution(PageResolution res)
{
return (res == PageResolution.Handled);
}
public static PageResolution ResFromResp(string resp)
{
switch ( resp )
{
case "[Handled]":
return PageResolution.Handled;
case "[Deleting]":
return PageResolution.Deleted;
case "[Logout]":
return PageResolution.Logged;
case "[Canceled]":
return PageResolution.Canceled;
}
return PageResolution.None;
}
public PageResolution GetResolution(out string resolvedBy, out DateTime timeResolved)
{
for (int i = this.m_Responses.Count - 1; i >= 0; --i)
{
ResponseInfo resp = this.m_Responses[i];
PageResolution res = ResFromResp(resp.Message);
if (res != PageResolution.None)
{
resolvedBy = resp.SentBy;
timeResolved = resp.TimeStamp;
return res;
}
}
resolvedBy = this.m_SentBy;
timeResolved = this.m_TimeSent;
return PageResolution.None;
}
public static string GetAccount(Mobile mob)
{
if (mob == null)
return null;
Accounting.Account acct = mob.Account as Accounting.Account;
if (acct == null)
return null;
return acct.Username;
}
public PageInfo()
{
this.m_Responses = new ResponseInfoCollection();
}
public PageInfo(PageEntry entry)
{
this.m_PageType = entry.Type;
this.m_TimeSent = entry.Sent;
this.m_SentBy = GetAccount(entry.Sender);
this.m_Message = entry.Message;
this.m_Responses = new ResponseInfoCollection();
}
public override void SerializeAttributes(PersistenceWriter op)
{
op.SetInt32("p", (int)this.m_PageType);
op.SetDateTime("ts", this.m_TimeSent);
op.SetString("s", this.m_SentBy);
op.SetString("m", this.m_Message);
}
public override void DeserializeAttributes(PersistenceReader ip)
{
this.m_PageType = (PageType)ip.GetInt32("p");
this.m_TimeSent = ip.GetDateTime("ts");
this.m_SentBy = ip.GetString("s");
this.m_Message = ip.GetString("m");
}
public override void SerializeChildren(PersistenceWriter op)
{
lock (this)
{
for (int i = 0; i < this.m_Responses.Count; ++i)
this.m_Responses[i].Serialize(op);
}
}
public override void DeserializeChildren(PersistenceReader ip)
{
while (ip.HasChild)
this.m_Responses.Add(ip.GetChild() as ResponseInfo);
}
}
}

View File

@@ -0,0 +1,191 @@
//------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a tool.
// Runtime Version: 1.1.4322.573
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </autogenerated>
//------------------------------------------------------------------------------
namespace Server.Engines.Reports
{
using System;
using System.Collections;
/// <summary>
/// Strongly typed collection of Server.Engines.Reports.PageInfo.
/// </summary>
public class PageInfoCollection : System.Collections.CollectionBase
{
/// <summary>
/// Default constructor.
/// </summary>
public PageInfoCollection()
: base()
{
}
/// <summary>
/// Gets or sets the value of the Server.Engines.Reports.PageInfo at a specific position in the PageInfoCollection.
/// </summary>
public Server.Engines.Reports.PageInfo this[int index]
{
get
{
return ((Server.Engines.Reports.PageInfo)(this.List[index]));
}
set
{
this.List[index] = value;
}
}
/// <summary>
/// Append a Server.Engines.Reports.PageInfo entry to this collection.
/// </summary>
/// <param name="value">Server.Engines.Reports.PageInfo instance.</param>
/// <returns>The position into which the new element was inserted.</returns>
public int Add(Server.Engines.Reports.PageInfo value)
{
return this.List.Add(value);
}
/// <summary>
/// Determines whether a specified Server.Engines.Reports.PageInfo instance is in this collection.
/// </summary>
/// <param name="value">Server.Engines.Reports.PageInfo instance to search for.</param>
/// <returns>True if the Server.Engines.Reports.PageInfo instance is in the collection; otherwise false.</returns>
public bool Contains(Server.Engines.Reports.PageInfo value)
{
return this.List.Contains(value);
}
/// <summary>
/// Retrieve the index a specified Server.Engines.Reports.PageInfo instance is in this collection.
/// </summary>
/// <param name="value">Server.Engines.Reports.PageInfo instance to find.</param>
/// <returns>The zero-based index of the specified Server.Engines.Reports.PageInfo instance. If the object is not found, the return value is -1.</returns>
public int IndexOf(Server.Engines.Reports.PageInfo value)
{
return this.List.IndexOf(value);
}
/// <summary>
/// Removes a specified Server.Engines.Reports.PageInfo instance from this collection.
/// </summary>
/// <param name="value">The Server.Engines.Reports.PageInfo instance to remove.</param>
public void Remove(Server.Engines.Reports.PageInfo value)
{
this.List.Remove(value);
}
/// <summary>
/// Returns an enumerator that can iterate through the Server.Engines.Reports.PageInfo instance.
/// </summary>
/// <returns>An Server.Engines.Reports.PageInfo's enumerator.</returns>
public new PageInfoCollectionEnumerator GetEnumerator()
{
return new PageInfoCollectionEnumerator(this);
}
/// <summary>
/// Insert a Server.Engines.Reports.PageInfo instance into this collection at a specified index.
/// </summary>
/// <param name="index">Zero-based index.</param>
/// <param name="value">The Server.Engines.Reports.PageInfo instance to insert.</param>
public void Insert(int index, Server.Engines.Reports.PageInfo value)
{
this.List.Insert(index, value);
}
/// <summary>
/// Strongly typed enumerator of Server.Engines.Reports.PageInfo.
/// </summary>
public class PageInfoCollectionEnumerator : System.Collections.IEnumerator
{
/// <summary>
/// Collection to enumerate.
/// </summary>
private readonly PageInfoCollection _collection;
/// <summary>
/// Current index
/// </summary>
private int _index;
/// <summary>
/// Current element pointed to.
/// </summary>
private Server.Engines.Reports.PageInfo _currentElement;
/// <summary>
/// Default constructor for enumerator.
/// </summary>
/// <param name="collection">Instance of the collection to enumerate.</param>
internal PageInfoCollectionEnumerator(PageInfoCollection collection)
{
this._index = -1;
this._collection = collection;
}
/// <summary>
/// Gets the Server.Engines.Reports.PageInfo object in the enumerated PageInfoCollection currently indexed by this instance.
/// </summary>
public Server.Engines.Reports.PageInfo Current
{
get
{
if (((this._index == -1) ||
(this._index >= this._collection.Count)))
{
throw new System.IndexOutOfRangeException("Enumerator not started.");
}
else
{
return this._currentElement;
}
}
}
/// <summary>
/// Gets the current element in the collection.
/// </summary>
object IEnumerator.Current
{
get
{
if (((this._index == -1) ||
(this._index >= this._collection.Count)))
{
throw new System.IndexOutOfRangeException("Enumerator not started.");
}
else
{
return this._currentElement;
}
}
}
/// <summary>
/// Reset the cursor, so it points to the beginning of the enumerator.
/// </summary>
public void Reset()
{
this._index = -1;
this._currentElement = null;
}
/// <summary>
/// Advances the enumerator to the next queue of the enumeration, if one is currently available.
/// </summary>
/// <returns>true, if the enumerator was succesfully advanced to the next queue; false, if the enumerator has reached the end of the enumeration.</returns>
public bool MoveNext()
{
if ((this._index <
(this._collection.Count - 1)))
{
this._index = (this._index + 1);
this._currentElement = this._collection[this._index];
return true;
}
this._index = this._collection.Count;
return false;
}
}
}
}

View File

@@ -0,0 +1,72 @@
using System;
namespace Server.Engines.Reports
{
public class QueueStatus : PersistableObject
{
#region Type Identification
public static readonly PersistableType ThisTypeID = new PersistableType("qs", new ConstructCallback(Construct));
private static PersistableObject Construct()
{
return new QueueStatus();
}
public override PersistableType TypeID
{
get
{
return ThisTypeID;
}
}
#endregion
private DateTime m_TimeStamp;
private int m_Count;
public DateTime TimeStamp
{
get
{
return this.m_TimeStamp;
}
set
{
this.m_TimeStamp = value;
}
}
public int Count
{
get
{
return this.m_Count;
}
set
{
this.m_Count = value;
}
}
public QueueStatus()
{
}
public QueueStatus(int count)
{
this.m_TimeStamp = DateTime.UtcNow;
this.m_Count = count;
}
public override void SerializeAttributes(PersistenceWriter op)
{
op.SetDateTime("t", this.m_TimeStamp);
op.SetInt32("c", this.m_Count);
}
public override void DeserializeAttributes(PersistenceReader ip)
{
this.m_TimeStamp = ip.GetDateTime("t");
this.m_Count = ip.GetInt32("c");
}
}
}

View File

@@ -0,0 +1,191 @@
//------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a tool.
// Runtime Version: 1.1.4322.573
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </autogenerated>
//------------------------------------------------------------------------------
namespace Server.Engines.Reports
{
using System;
using System.Collections;
/// <summary>
/// Strongly typed collection of Server.Engines.Reports.QueueStatus.
/// </summary>
public class QueueStatusCollection : System.Collections.CollectionBase
{
/// <summary>
/// Default constructor.
/// </summary>
public QueueStatusCollection()
: base()
{
}
/// <summary>
/// Gets or sets the value of the Server.Engines.Reports.QueueStatus at a specific position in the QueueStatusCollection.
/// </summary>
public Server.Engines.Reports.QueueStatus this[int index]
{
get
{
return ((Server.Engines.Reports.QueueStatus)(this.List[index]));
}
set
{
this.List[index] = value;
}
}
/// <summary>
/// Append a Server.Engines.Reports.QueueStatus entry to this collection.
/// </summary>
/// <param name="value">Server.Engines.Reports.QueueStatus instance.</param>
/// <returns>The position into which the new element was inserted.</returns>
public int Add(Server.Engines.Reports.QueueStatus value)
{
return this.List.Add(value);
}
/// <summary>
/// Determines whether a specified Server.Engines.Reports.QueueStatus instance is in this collection.
/// </summary>
/// <param name="value">Server.Engines.Reports.QueueStatus instance to search for.</param>
/// <returns>True if the Server.Engines.Reports.QueueStatus instance is in the collection; otherwise false.</returns>
public bool Contains(Server.Engines.Reports.QueueStatus value)
{
return this.List.Contains(value);
}
/// <summary>
/// Retrieve the index a specified Server.Engines.Reports.QueueStatus instance is in this collection.
/// </summary>
/// <param name="value">Server.Engines.Reports.QueueStatus instance to find.</param>
/// <returns>The zero-based index of the specified Server.Engines.Reports.QueueStatus instance. If the object is not found, the return value is -1.</returns>
public int IndexOf(Server.Engines.Reports.QueueStatus value)
{
return this.List.IndexOf(value);
}
/// <summary>
/// Removes a specified Server.Engines.Reports.QueueStatus instance from this collection.
/// </summary>
/// <param name="value">The Server.Engines.Reports.QueueStatus instance to remove.</param>
public void Remove(Server.Engines.Reports.QueueStatus value)
{
this.List.Remove(value);
}
/// <summary>
/// Returns an enumerator that can iterate through the Server.Engines.Reports.QueueStatus instance.
/// </summary>
/// <returns>An Server.Engines.Reports.QueueStatus's enumerator.</returns>
public new QueueStatusCollectionEnumerator GetEnumerator()
{
return new QueueStatusCollectionEnumerator(this);
}
/// <summary>
/// Insert a Server.Engines.Reports.QueueStatus instance into this collection at a specified index.
/// </summary>
/// <param name="index">Zero-based index.</param>
/// <param name="value">The Server.Engines.Reports.QueueStatus instance to insert.</param>
public void Insert(int index, Server.Engines.Reports.QueueStatus value)
{
this.List.Insert(index, value);
}
/// <summary>
/// Strongly typed enumerator of Server.Engines.Reports.QueueStatus.
/// </summary>
public class QueueStatusCollectionEnumerator : System.Collections.IEnumerator
{
/// <summary>
/// Collection to enumerate.
/// </summary>
private readonly QueueStatusCollection _collection;
/// <summary>
/// Current index
/// </summary>
private int _index;
/// <summary>
/// Current element pointed to.
/// </summary>
private Server.Engines.Reports.QueueStatus _currentElement;
/// <summary>
/// Default constructor for enumerator.
/// </summary>
/// <param name="collection">Instance of the collection to enumerate.</param>
internal QueueStatusCollectionEnumerator(QueueStatusCollection collection)
{
this._index = -1;
this._collection = collection;
}
/// <summary>
/// Gets the Server.Engines.Reports.QueueStatus object in the enumerated QueueStatusCollection currently indexed by this instance.
/// </summary>
public Server.Engines.Reports.QueueStatus Current
{
get
{
if (((this._index == -1) ||
(this._index >= this._collection.Count)))
{
throw new System.IndexOutOfRangeException("Enumerator not started.");
}
else
{
return this._currentElement;
}
}
}
/// <summary>
/// Gets the current element in the collection.
/// </summary>
object IEnumerator.Current
{
get
{
if (((this._index == -1) ||
(this._index >= this._collection.Count)))
{
throw new System.IndexOutOfRangeException("Enumerator not started.");
}
else
{
return this._currentElement;
}
}
}
/// <summary>
/// Reset the cursor, so it points to the beginning of the enumerator.
/// </summary>
public void Reset()
{
this._index = -1;
this._currentElement = null;
}
/// <summary>
/// Advances the enumerator to the next queue of the enumeration, if one is currently available.
/// </summary>
/// <returns>true, if the enumerator was succesfully advanced to the next queue; false, if the enumerator has reached the end of the enumeration.</returns>
public bool MoveNext()
{
if ((this._index <
(this._collection.Count - 1)))
{
this._index = (this._index + 1);
this._currentElement = this._collection[this._index];
return true;
}
this._index = this._collection.Count;
return false;
}
}
}
}

View File

@@ -0,0 +1,91 @@
using System;
namespace Server.Engines.Reports
{
public class ResponseInfo : PersistableObject
{
#region Type Identification
public static readonly PersistableType ThisTypeID = new PersistableType("rs", new ConstructCallback(Construct));
private static PersistableObject Construct()
{
return new ResponseInfo();
}
public override PersistableType TypeID
{
get
{
return ThisTypeID;
}
}
#endregion
private DateTime m_TimeStamp;
private string m_SentBy;
private string m_Message;
public DateTime TimeStamp
{
get
{
return this.m_TimeStamp;
}
set
{
this.m_TimeStamp = value;
}
}
public string SentBy
{
get
{
return this.m_SentBy;
}
set
{
this.m_SentBy = value;
}
}
public string Message
{
get
{
return this.m_Message;
}
set
{
this.m_Message = value;
}
}
public ResponseInfo()
{
}
public ResponseInfo(string sentBy, string message)
{
this.m_TimeStamp = DateTime.UtcNow;
this.m_SentBy = sentBy;
this.m_Message = message;
}
public override void SerializeAttributes(PersistenceWriter op)
{
op.SetDateTime("t", this.m_TimeStamp);
op.SetString("s", this.m_SentBy);
op.SetString("m", this.m_Message);
}
public override void DeserializeAttributes(PersistenceReader ip)
{
this.m_TimeStamp = ip.GetDateTime("t");
this.m_SentBy = ip.GetString("s");
this.m_Message = ip.GetString("m");
}
}
}

View File

@@ -0,0 +1,196 @@
//------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a tool.
// Runtime Version: 1.1.4322.573
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </autogenerated>
//------------------------------------------------------------------------------
namespace Server.Engines.Reports
{
using System;
using System.Collections;
/// <summary>
/// Strongly typed collection of Server.Engines.Reports.ResponseInfo.
/// </summary>
public class ResponseInfoCollection : System.Collections.CollectionBase
{
/// <summary>
/// Default constructor.
/// </summary>
public ResponseInfoCollection()
: base()
{
}
/// <summary>
/// Gets or sets the value of the Server.Engines.Reports.ResponseInfo at a specific position in the ResponseInfoCollection.
/// </summary>
public Server.Engines.Reports.ResponseInfo this[int index]
{
get
{
return ((Server.Engines.Reports.ResponseInfo)(this.List[index]));
}
set
{
this.List[index] = value;
}
}
public int Add(string sentBy, string message)
{
return this.Add(new ResponseInfo(sentBy, message));
}
/// <summary>
/// Append a Server.Engines.Reports.ResponseInfo entry to this collection.
/// </summary>
/// <param name="value">Server.Engines.Reports.ResponseInfo instance.</param>
/// <returns>The position into which the new element was inserted.</returns>
public int Add(Server.Engines.Reports.ResponseInfo value)
{
return this.List.Add(value);
}
/// <summary>
/// Determines whether a specified Server.Engines.Reports.ResponseInfo instance is in this collection.
/// </summary>
/// <param name="value">Server.Engines.Reports.ResponseInfo instance to search for.</param>
/// <returns>True if the Server.Engines.Reports.ResponseInfo instance is in the collection; otherwise false.</returns>
public bool Contains(Server.Engines.Reports.ResponseInfo value)
{
return this.List.Contains(value);
}
/// <summary>
/// Retrieve the index a specified Server.Engines.Reports.ResponseInfo instance is in this collection.
/// </summary>
/// <param name="value">Server.Engines.Reports.ResponseInfo instance to find.</param>
/// <returns>The zero-based index of the specified Server.Engines.Reports.ResponseInfo instance. If the object is not found, the return value is -1.</returns>
public int IndexOf(Server.Engines.Reports.ResponseInfo value)
{
return this.List.IndexOf(value);
}
/// <summary>
/// Removes a specified Server.Engines.Reports.ResponseInfo instance from this collection.
/// </summary>
/// <param name="value">The Server.Engines.Reports.ResponseInfo instance to remove.</param>
public void Remove(Server.Engines.Reports.ResponseInfo value)
{
this.List.Remove(value);
}
/// <summary>
/// Returns an enumerator that can iterate through the Server.Engines.Reports.ResponseInfo instance.
/// </summary>
/// <returns>An Server.Engines.Reports.ResponseInfo's enumerator.</returns>
public new ResponseInfoCollectionEnumerator GetEnumerator()
{
return new ResponseInfoCollectionEnumerator(this);
}
/// <summary>
/// Insert a Server.Engines.Reports.ResponseInfo instance into this collection at a specified index.
/// </summary>
/// <param name="index">Zero-based index.</param>
/// <param name="value">The Server.Engines.Reports.ResponseInfo instance to insert.</param>
public void Insert(int index, Server.Engines.Reports.ResponseInfo value)
{
this.List.Insert(index, value);
}
/// <summary>
/// Strongly typed enumerator of Server.Engines.Reports.ResponseInfo.
/// </summary>
public class ResponseInfoCollectionEnumerator : System.Collections.IEnumerator
{
/// <summary>
/// Collection to enumerate.
/// </summary>
private readonly ResponseInfoCollection _collection;
/// <summary>
/// Current index
/// </summary>
private int _index;
/// <summary>
/// Current element pointed to.
/// </summary>
private Server.Engines.Reports.ResponseInfo _currentElement;
/// <summary>
/// Default constructor for enumerator.
/// </summary>
/// <param name="collection">Instance of the collection to enumerate.</param>
internal ResponseInfoCollectionEnumerator(ResponseInfoCollection collection)
{
this._index = -1;
this._collection = collection;
}
/// <summary>
/// Gets the Server.Engines.Reports.ResponseInfo object in the enumerated ResponseInfoCollection currently indexed by this instance.
/// </summary>
public Server.Engines.Reports.ResponseInfo Current
{
get
{
if (((this._index == -1) ||
(this._index >= this._collection.Count)))
{
throw new System.IndexOutOfRangeException("Enumerator not started.");
}
else
{
return this._currentElement;
}
}
}
/// <summary>
/// Gets the current element in the collection.
/// </summary>
object IEnumerator.Current
{
get
{
if (((this._index == -1) ||
(this._index >= this._collection.Count)))
{
throw new System.IndexOutOfRangeException("Enumerator not started.");
}
else
{
return this._currentElement;
}
}
}
/// <summary>
/// Reset the cursor, so it points to the beginning of the enumerator.
/// </summary>
public void Reset()
{
this._index = -1;
this._currentElement = null;
}
/// <summary>
/// Advances the enumerator to the next queue of the enumeration, if one is currently available.
/// </summary>
/// <returns>true, if the enumerator was succesfully advanced to the next queue; false, if the enumerator has reached the end of the enumeration.</returns>
public bool MoveNext()
{
if ((this._index <
(this._collection.Count - 1)))
{
this._index = (this._index + 1);
this._currentElement = this._collection[this._index];
return true;
}
this._index = this._collection.Count;
return false;
}
}
}
}

View File

@@ -0,0 +1,451 @@
using System;
using System.Collections;
using System.IO;
namespace Server.Engines.Reports
{
public class StaffHistory : PersistableObject
{
#region Type Identification
public static readonly PersistableType ThisTypeID = new PersistableType("stfhst", new ConstructCallback(Construct));
private static PersistableObject Construct()
{
return new StaffHistory();
}
public override PersistableType TypeID
{
get
{
return ThisTypeID;
}
}
#endregion
private PageInfoCollection m_Pages;
private QueueStatusCollection m_QueueStats;
private Hashtable m_UserInfo;
private Hashtable m_StaffInfo;
public PageInfoCollection Pages
{
get
{
return this.m_Pages;
}
set
{
this.m_Pages = value;
}
}
public QueueStatusCollection QueueStats
{
get
{
return this.m_QueueStats;
}
set
{
this.m_QueueStats = value;
}
}
public Hashtable UserInfo
{
get
{
return this.m_UserInfo;
}
set
{
this.m_UserInfo = value;
}
}
public Hashtable StaffInfo
{
get
{
return this.m_StaffInfo;
}
set
{
this.m_StaffInfo = value;
}
}
public void AddPage(PageInfo info)
{
lock (SaveLock)
this.m_Pages.Add(info);
info.History = this;
}
public StaffHistory()
{
this.m_Pages = new PageInfoCollection();
this.m_QueueStats = new QueueStatusCollection();
this.m_UserInfo = new Hashtable(StringComparer.OrdinalIgnoreCase);
this.m_StaffInfo = new Hashtable(StringComparer.OrdinalIgnoreCase);
}
public StaffInfo GetStaffInfo(string account)
{
lock (RenderLock)
{
if (account == null || account.Length == 0)
return null;
StaffInfo info = this.m_StaffInfo[account] as StaffInfo;
if (info == null)
this.m_StaffInfo[account] = info = new StaffInfo(account);
return info;
}
}
public UserInfo GetUserInfo(string account)
{
if (account == null || account.Length == 0)
return null;
UserInfo info = this.m_UserInfo[account] as UserInfo;
if (info == null)
this.m_UserInfo[account] = info = new UserInfo(account);
return info;
}
public static readonly object RenderLock = new object();
public static readonly object SaveLock = new object();
public void Save()
{
lock (SaveLock)
{
string path = Path.Combine(Core.BaseDirectory, "staffHistory.xml");
PersistenceWriter pw = new XmlPersistenceWriter(path, "Staff");
pw.WriteDocument(this);
pw.Close();
}
}
public void Load()
{
string path = Path.Combine(Core.BaseDirectory, "staffHistory.xml");
if (!File.Exists(path))
return;
PersistenceReader pr = new XmlPersistenceReader(path, "Staff");
pr.ReadDocument(this);
pr.Close();
}
public override void SerializeChildren(PersistenceWriter op)
{
for (int i = 0; i < this.m_Pages.Count; ++i)
this.m_Pages[i].Serialize(op);
for (int i = 0; i < this.m_QueueStats.Count; ++i)
this.m_QueueStats[i].Serialize(op);
}
public override void DeserializeChildren(PersistenceReader ip)
{
DateTime min = DateTime.UtcNow - TimeSpan.FromDays(8.0);
while (ip.HasChild)
{
PersistableObject obj = ip.GetChild();
if (obj is PageInfo)
{
PageInfo pageInfo = obj as PageInfo;
pageInfo.UpdateResolver();
if (pageInfo.TimeSent >= min || pageInfo.TimeResolved >= min)
{
this.m_Pages.Add(pageInfo);
pageInfo.History = this;
}
else
{
pageInfo.Sender = null;
pageInfo.Resolver = null;
}
}
else if (obj is QueueStatus)
{
QueueStatus queueStatus = obj as QueueStatus;
if (queueStatus.TimeStamp >= min)
this.m_QueueStats.Add(queueStatus);
}
}
}
public StaffInfo[] GetStaff()
{
StaffInfo[] staff = new StaffInfo[this.m_StaffInfo.Count];
int index = 0;
foreach (StaffInfo staffInfo in this.m_StaffInfo.Values)
staff[index++] = staffInfo;
return staff;
}
public void Render(ObjectCollection objects)
{
lock (RenderLock)
{
objects.Add(this.GraphQueueStatus());
StaffInfo[] staff = this.GetStaff();
BaseInfo.SortRange = TimeSpan.FromDays(7.0);
Array.Sort(staff);
objects.Add(this.GraphHourlyPages(this.m_Pages, PageResolution.None, "New pages by hour", "graph_new_pages_hr"));
objects.Add(this.GraphHourlyPages(this.m_Pages, PageResolution.Handled, "Handled pages by hour", "graph_handled_pages_hr"));
objects.Add(this.GraphHourlyPages(this.m_Pages, PageResolution.Deleted, "Deleted pages by hour", "graph_deleted_pages_hr"));
objects.Add(this.GraphHourlyPages(this.m_Pages, PageResolution.Canceled, "Canceled pages by hour", "graph_canceled_pages_hr"));
objects.Add(this.GraphHourlyPages(this.m_Pages, PageResolution.Logged, "Logged-out pages by hour", "graph_logged_pages_hr"));
BaseInfo.SortRange = TimeSpan.FromDays(1.0);
Array.Sort(staff);
objects.Add(this.ReportTotalPages(staff, TimeSpan.FromDays(1.0), "1 Day"));
objects.AddRange((PersistableObject[])this.ChartTotalPages(staff, TimeSpan.FromDays(1.0), "1 Day", "graph_daily_pages"));
BaseInfo.SortRange = TimeSpan.FromDays(7.0);
Array.Sort(staff);
objects.Add(this.ReportTotalPages(staff, TimeSpan.FromDays(7.0), "1 Week"));
objects.AddRange((PersistableObject[])this.ChartTotalPages(staff, TimeSpan.FromDays(7.0), "1 Week", "graph_weekly_pages"));
BaseInfo.SortRange = TimeSpan.FromDays(30.0);
Array.Sort(staff);
objects.Add(this.ReportTotalPages(staff, TimeSpan.FromDays(30.0), "1 Month"));
objects.AddRange((PersistableObject[])this.ChartTotalPages(staff, TimeSpan.FromDays(30.0), "1 Month", "graph_monthly_pages"));
for (int i = 0; i < staff.Length; ++i)
objects.Add(this.GraphHourlyPages(staff[i]));
}
}
public static int GetPageCount(StaffInfo staff, DateTime min, DateTime max)
{
return GetPageCount(staff.Pages, PageResolution.Handled, min, max);
}
public static int GetPageCount(PageInfoCollection pages, PageResolution res, DateTime min, DateTime max)
{
int count = 0;
for (int i = 0; i < pages.Count; ++i)
{
if (res != PageResolution.None && pages[i].Resolution != res)
continue;
DateTime ts = pages[i].TimeResolved;
if (ts >= min && ts < max)
++count;
}
return count;
}
private BarGraph GraphQueueStatus()
{
int[] totals = new int[24];
int[] counts = new int[24];
DateTime max = DateTime.UtcNow;
DateTime min = max - TimeSpan.FromDays(7.0);
for (int i = 0; i < this.m_QueueStats.Count; ++i)
{
DateTime ts = this.m_QueueStats[i].TimeStamp;
if (ts >= min && ts < max)
{
DateTime date = ts.Date;
TimeSpan time = ts.TimeOfDay;
int hour = time.Hours;
totals[hour] += this.m_QueueStats[i].Count;
counts[hour]++;
}
}
BarGraph barGraph = new BarGraph("Average pages in queue", "graph_pagequeue_avg", 10, "Time", "Pages", BarGraphRenderMode.Lines);
barGraph.FontSize = 6;
for (int i = 7; i <= totals.Length + 7; ++i)
{
int val;
if (counts[i % totals.Length] == 0)
val = 0;
else
val = (totals[i % totals.Length] + (counts[i % totals.Length] / 2)) / counts[i % totals.Length];
int realHours = i % totals.Length;
int hours;
if (realHours == 0)
hours = 12;
else if (realHours > 12)
hours = realHours - 12;
else
hours = realHours;
barGraph.Items.Add(hours + (realHours >= 12 ? " PM" : " AM"), val);
}
return barGraph;
}
private BarGraph GraphHourlyPages(StaffInfo staff)
{
return this.GraphHourlyPages(staff.Pages, PageResolution.Handled, "Average pages handled by " + staff.Display, "graphs_" + staff.Account.ToLower() + "_avg");
}
private BarGraph GraphHourlyPages(PageInfoCollection pages, PageResolution res, string title, string fname)
{
int[] totals = new int[24];
int[] counts = new int[24];
DateTime[] dates = new DateTime[24];
DateTime max = DateTime.UtcNow;
DateTime min = max - TimeSpan.FromDays(7.0);
bool sentStamp = (res == PageResolution.None);
for (int i = 0; i < pages.Count; ++i)
{
if (res != PageResolution.None && pages[i].Resolution != res)
continue;
DateTime ts = (sentStamp ? pages[i].TimeSent : pages[i].TimeResolved);
if (ts >= min && ts < max)
{
DateTime date = ts.Date;
TimeSpan time = ts.TimeOfDay;
int hour = time.Hours;
totals[hour]++;
if (dates[hour] != date)
{
counts[hour]++;
dates[hour] = date;
}
}
}
BarGraph barGraph = new BarGraph(title, fname, 10, "Time", "Pages", BarGraphRenderMode.Lines);
barGraph.FontSize = 6;
for (int i = 7; i <= totals.Length + 7; ++i)
{
int val;
if (counts[i % totals.Length] == 0)
val = 0;
else
val = (totals[i % totals.Length] + (counts[i % totals.Length] / 2)) / counts[i % totals.Length];
int realHours = i % totals.Length;
int hours;
if (realHours == 0)
hours = 12;
else if (realHours > 12)
hours = realHours - 12;
else
hours = realHours;
barGraph.Items.Add(hours + (realHours >= 12 ? " PM" : " AM"), val);
}
return barGraph;
}
private Report ReportTotalPages(StaffInfo[] staff, TimeSpan ts, string title)
{
DateTime max = DateTime.UtcNow;
DateTime min = max - ts;
Report report = new Report(title + " Staff Report", "400");
report.Columns.Add("65%", "left", "Staff Name");
report.Columns.Add("35%", "center", "Page Count");
for (int i = 0; i < staff.Length; ++i)
report.Items.Add(staff[i].Display, GetPageCount(staff[i], min, max));
return report;
}
private PieChart[] ChartTotalPages(StaffInfo[] staff, TimeSpan ts, string title, string fname)
{
DateTime max = DateTime.UtcNow;
DateTime min = max - ts;
PieChart staffChart = new PieChart(title + " Staff Chart", fname + "_staff", true);
int other = 0;
for (int i = 0; i < staff.Length; ++i)
{
int count = GetPageCount(staff[i], min, max);
if (i < 12 && count > 0)
staffChart.Items.Add(staff[i].Display, count);
else
other += count;
}
if (other > 0)
staffChart.Items.Add("Other", other);
PieChart resChart = new PieChart(title + " Resolutions", fname + "_resol", true);
int countTotal = GetPageCount(this.m_Pages, PageResolution.None, min, max);
int countHandled = GetPageCount(this.m_Pages, PageResolution.Handled, min, max);
int countDeleted = GetPageCount(this.m_Pages, PageResolution.Deleted, min, max);
int countCanceled = GetPageCount(this.m_Pages, PageResolution.Canceled, min, max);
int countLogged = GetPageCount(this.m_Pages, PageResolution.Logged, min, max);
int countUnres = countTotal - (countHandled + countDeleted + countCanceled + countLogged);
resChart.Items.Add("Handled", countHandled);
resChart.Items.Add("Deleted", countDeleted);
resChart.Items.Add("Canceled", countCanceled);
resChart.Items.Add("Logged Out", countLogged);
resChart.Items.Add("Unresolved", countUnres);
return new PieChart[] { staffChart, resChart };
}
}
}