SafeNet/.svn/pristine/1a/1a2e04c594b6c552e8184bc14c01685497d71a43.svn-base
2021-02-24 13:50:23 +02:00

72 lines
1.7 KiB
Plaintext

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
namespace SN_Server
{
public class UnitList
{
private Hashtable ht_unitlist;
public int Count;
public UnitList()
{
ht_unitlist = new Hashtable();
}
public void Add(Unit unit)
{
if (ht_unitlist.ContainsKey(unit.RadioID))
{
ht_unitlist.Remove(unit.RadioID);
}
ht_unitlist.Add(unit.RadioID, unit);
Count = ht_unitlist.Count;
}
public void Print()
{
Console.WriteLine("Unit list count: {0}", ht_unitlist.Count);
foreach(DictionaryEntry de in ht_unitlist)
{
Console.WriteLine("unit Key:" + de.Key + " value: DBid:" + ((Unit)de.Value).DBid
+ " RepInterval:" + ((Unit)de.Value).Reporting);
}
}
public Unit getUnitAtPosition(int position)
{
int i = 0;
foreach (DictionaryEntry de in ht_unitlist)
{
if(position == i)
return (Unit)de.Value;
i++;
}
return null;
}
public int GetReportingInterval(string radioID)
{
return ((Unit)ht_unitlist[radioID]).Reporting;
}
public int GetDBid(string radioID)
{
int ret = 0;
lock (ht_unitlist.SyncRoot)
{
if (ht_unitlist.ContainsKey(radioID))
{
ret = ((Unit)ht_unitlist[radioID]).DBid;
}
}
return ret;
}
}
}