I am working from documentation for a biometrics sdk.Importing the clockings file and reading it line by line and setting it to the correct columns in a Winform listview works fine but doing it in WPF has me completely stumped
This is a line from the file.There are no header columns in the file
18 2012-07-25 12:35:15 1 0 1 0
This is my xaml
<ListView Name="lstAttlog" Margin="10,78,10,10" ItemsSource="{Binding Proccess}">
<ListView.View>
<GridView>
<GridViewColumn Width="80"
DisplayMemberBinding="{Binding PIN2}"
Header="PIN" />
<GridViewColumn Width="120"
DisplayMemberBinding="{Binding Time_second}"
Header="Time" />
<GridViewColumn Width="80"
DisplayMemberBinding="{Binding DeviceID}"
Header="Device ID" />
<GridViewColumn Width="80"
DisplayMemberBinding="{Binding Status}"
Header="Status" />
<GridViewColumn Width="80"
DisplayMemberBinding="{Binding Verify}"
Header="Verify" />
<GridViewColumn Width="80"
DisplayMemberBinding="{Binding WorkCode}"
Header="WorkCode" />
</GridView>
</ListView.View>
</ListView>
This is the class called Usb
public class Udisk
{
public void GetAttLogFromDat(byte[] DataBuf, int OneLogLength, out string PIN2, out string Time_second, out string DeviceID,
out string Status, out string Verified, out string Workcode)
{
int i;
int Index = 0;
PIN2 = "";
Time_second = "";
DeviceID = "";
Status = "";
Verified = "";
Workcode = "";
for (i = Index; i < OneLogLength; i++)
{
if (DataBuf[i] == 9)
{
byte[] PIN2Buf = new byte[i];
Array.Copy(DataBuf, 0, PIN2Buf, 0, i);
PIN2 = System.Text.Encoding.Default.GetString(PIN2Buf);
Index = i;
break;
}
}
for (i = Index + 1; i < OneLogLength; i++)
{
if (DataBuf[i] == 9)
{
byte[] TimeBuf = new byte[i - Index - 1];
Array.Copy(DataBuf, Index + 1, TimeBuf, 0, i - Index - 1);
Time_second = System.Text.Encoding.Default.GetString(TimeBuf);
Index = i;
break;
}
}
for (i = Index + 1; i < OneLogLength; i++)
{
if (DataBuf[i] == 9)
{
byte[] DeviceIDBuf = new byte[i - Index - 1];
Array.Copy(DataBuf, Index + 1, DeviceIDBuf, 0, i - Index - 1);
DeviceID = System.Text.Encoding.Default.GetString(DeviceIDBuf);
Index = i;
break;
}
}
for (i = Index + 1; i < OneLogLength; i++)
{
if (DataBuf[i] == 9)
{
byte[] StatusBuf = new byte[i - Index - 1];
Array.Copy(DataBuf, Index + 1, StatusBuf, 0, i - Index - 1);
Status = System.Text.Encoding.Default.GetString(StatusBuf);
Index = i;
break;
}
}
for (i = Index + 1; i < OneLogLength; i++)
{
if (DataBuf[i] == 9)
{
byte[] VerifiedBuf = new byte[i - Index - 1];
Array.Copy(DataBuf, Index + 1, VerifiedBuf, 0, i - Index - 1);
Verified = System.Text.Encoding.Default.GetString(VerifiedBuf);
Index = i;
break;
}
}
for (i = Index + 1; i < OneLogLength; i++)
{
if (DataBuf[i] == 13)
{
byte[] WorkcodeBuf = new byte[i - Index - 1];
Array.Copy(DataBuf, Index + 1, WorkcodeBuf, 0, i - Index - 1);
Workcode = System.Text.Encoding.Default.GetString(WorkcodeBuf);
break;
}
}
}
This is the class called Proccess
public class Proccess
{
public String PIN2 { get; set; }
public DateTime Time_second { get; set; }
public string DeviceID { get; set; }
public string Status { get; set; }
public string Verify { get; set; }
public string WorkCode { get; set; }
}
and this is the eventhandler to read file into listview
Udisk usb = new Udisk();
byte[] byDataBuf = null;
int iLength;
string sPIN2 = "";
string sVerified = "";
string sTime_second = "";
string sDeviceID = "";
string sStatus = "";
string sWorkcode = "";
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "attlog(*.dat)|*.dat";
ofd.FileName = "attlog.dat";
Nullable<bool> result = ofd.ShowDialog();
if (result == true)
{
FileStream fs = new FileStream(ofd.FileName, FileMode.OpenOrCreate, FileAccess.Read);
byDataBuf = File.ReadAllBytes(ofd.FileName);
iLength = Convert.ToInt32(fs.Length);
lstAttlog.Items.Clear();
int iStartIndex = 0;
int iOneLogLength;
for (int i = iStartIndex; i < iLength; i++)
{
if (byDataBuf[i] == 13 && byDataBuf[i + 1] == 10)
{
iOneLogLength = (i + 1) + 1 - iStartIndex;
byte[] bySSRAttLog = new byte[iOneLogLength];
Array.Copy(byDataBuf, iStartIndex, bySSRAttLog, 0, iOneLogLength);
usb.GetAttLogFromDat(bySSRAttLog, iOneLogLength, out sPIN2, out sTime_second, out sDeviceID, out sStatus, out sVerified, out sWorkcode);
I am struggeling to figure out how to add a
List<Proccess> process = new List<Proccess>();
and adding the the data to a WPF listview
Much appreciated
Gerhard-Louis