0
I’m starting now with C# due to the need where I work, I took a project until it was flowing, however, I’m having great difficulty sending the data to the database (a part of the code another person who did).
TotalRecordNum
would be the total of tests, so I took the tests by bytes (RecNum
, Year
, Month
, Days
, Hr
, Min
, EventBG
, Bg
and mid
) and then pass via parameter to the database.
I put a if
commented inside the is where I determine the value of i
it brings me only the data according to the id
(TotalRecordNum
) and it save normally but would like to save all data.
Thanks in advance, any help, tip, light that gives me.
public void RECRDecode(byte[] RECR_Buf)
{
int RecNum, Year, Month, Days, Hr, Min, EventBG, BG, mid;
TotalRecordNum = RECR_Buf[0] * 256 + RECR_Buf[1];
for (TotalRecordNum = 0; TotalRecordNum < 1152; TotalRecordNum++)
{
if (RECR_Buf[0 + TotalRecordNum * 8] == 0xFF)
break;
if (RECR_Buf[1 + TotalRecordNum * 8] == 0x00)
break;
}
for (int i = 0; i < TotalRecordNum; i++)
{
//if (i == 0)
//{
RecNum = TotalRecordNum - i;
Year = (RECR_Buf[0 + i * 8] & 0xFE) >> 1;
Month = (RECR_Buf[0 + i * 8] & 0x01) << 3 | (RECR_Buf[1 + i * 8] & 0xE0) >> 5;
Days = RECR_Buf[1 + i * 8] & 0x1F;
Hr = (RECR_Buf[2 + i * 8] & 0xF8) >> 3;
Min = (RECR_Buf[2 + i * 8] & 0x07) << 3 | (RECR_Buf[3 + i * 8] & 0xE0) >> 5;
EventBG = (RECR_Buf[5 + i * 8] & 0x03) << 1 | (RECR_Buf[6 + i * 8] & 0x80) >> 7;
BG = (RECR_Buf[6 + i * 8] & 0x03) * 256 + RECR_Buf[7 + i * 8];
mid = Mid1_SN;
dadoGlicemia = BG.ToString("D2");
dadoData += Year.ToString("D2") + "/" + Month.ToString("D2") + "/" + Days.ToString("D2");
dadoHora += Hr.ToString("D2") + ":" + Min.ToString("D2");
AutoSN += MID1.ToString("D5") + mid.ToString("D5");
dadoID += RecNum.ToString("D2");
dadoEvento += EventBG.ToString("D1");
Paciente paciente = new Paciente();
paciente.NO += dadoID.ToString();
paciente.Glicemia += dadoGlicemia.ToString();
//}
}
}