因此我提供了一個後端接口來從呼叫系統收集一些數據並將其顯示到我正在構建的GUI中。我是新手,並將其用作學習項目。我試圖將一些數據過濾到列表中,而不是一個巨大的字符串。下面是我用來在文本塊中顯示數據的代碼。需要幫助將變量的輸出格式化爲列表
public void OnMessageReceived(object sender, MessageReceivedEventArgs e)
{
try
{
if (e == null)
return;
if (e.CmsData != null)
{
Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)(() =>
{
foreach (var item in e.CmsData.Agents)
{
List<string> mylist = new List<string>();
mylist.Add(item.AuxReasonDescription);
}
textBlock.Text = string.Join(Environment.NewLine, e.CmsData.Agents); }));
}
}
catch (Exception ex)
}
,你可以在我的textBlock.Text
看到我期待能夠把變量mylist
旁邊Environment.NewLine
,但它無法找到變量。
下面是.CS文件,如果需要理解這一點,那麼列表將從該文件中提取。
通常情況下,這將顯示所有登錄代理的列表,這些代理是通過未在下面列出的接口提供的。我試圖這樣做,所以每個代理都有一個包含下面agent.cs文件中的數據字段的列。我可能會在這個完全錯誤的方向。任何可以提供的幫助將不勝感激。
public class Agent : IEquatable<Agent>
{
public int Extension { get; set; }
public int WorkModeDirection { get; set; }
public string WorkModeDirectionDescription { get; set; }
public TimeSpan AgTime { get; set; }
public int AuxReason { get; set; }
public string AuxReasonDescription { get; set; }
public int DaInQueue { get; set; }
public int WorkSkill { get; set; }
public int OnHold { get; set; }
public int Acd { get; set; }
public String LoginId { get; set; }
public string AgName { get; set; }
public int EId { get; set; }
public int Preference { get; set; }
public DateTime DateTimeCreated { get; set; }
public DateTime DateTimeUpdated { get; set; }
public int CmId { get; set; }
#region Implementation of IEquatable<Agent>
public bool Equals(Agent other)
{
if (ReferenceEquals(null, other))
return false;
if (ReferenceEquals(this, other))
return true;
return (other.LoginId == LoginId & other.CmId == CmId);
}
#endregion
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
return false;
if (ReferenceEquals(this, obj))
return true;
if (obj.GetType() != typeof(Agent))
return false;
return Equals((Agent)obj);
}
//public override int GetHashCode()
//{
// return LoginId;
//}
public override int GetHashCode()
{
string combinedNumber = "" + CmId + LoginId;
int hash = Convert.ToInt32(combinedNumber);
return hash;
}
public static bool operator ==(Agent left, Agent right)
{
return Equals(left, right);
}
public static bool operator !=(Agent left, Agent right)
{
return !Equals(left, right);
}
public override string ToString()
{
return " Ag: [Ext:" + Extension + " login:" + LoginId + " AgName:" + AgName + " CmId:" + CmId + "]";
}
public bool IsValid()
{
return LoginId != null;
}
}
加1 ,在投票之前,您應該至少發表評論,然後投票拒絕投票。 – tabby