1 |
torben |
2169 |
using System;
|
2 |
|
|
using System.Collections.Generic;
|
3 |
|
|
using System.Text;
|
4 |
|
|
|
5 |
|
|
namespace DaoCommon
|
6 |
|
|
{
|
7 |
|
|
public class Salt2Header
|
8 |
|
|
{
|
9 |
|
|
public string afsender;
|
10 |
|
|
public string modtager;
|
11 |
|
|
|
12 |
|
|
public string transaktionForkortelse;
|
13 |
|
|
}
|
14 |
|
|
|
15 |
|
|
public class Salt2Helper
|
16 |
|
|
{
|
17 |
|
|
|
18 |
|
|
public static Salt2Header parseHeader(string salt2String)
|
19 |
|
|
{
|
20 |
|
|
Salt2Header header = new Salt2Header();
|
21 |
|
|
|
22 |
|
|
header.afsender = salt2String.Substring(0, 5);
|
23 |
|
|
header.modtager = salt2String.Substring(5, 5);
|
24 |
|
|
header.transaktionForkortelse = salt2String.Substring(55, 4);
|
25 |
torben |
2170 |
|
26 |
torben |
2174 |
header.afsender = header.afsender.Trim().ToUpper();
|
27 |
|
|
header.modtager = header.modtager.Trim().ToUpper();
|
28 |
|
|
header.transaktionForkortelse = header.transaktionForkortelse.Trim().ToUpper();
|
29 |
torben |
2171 |
|
30 |
torben |
2169 |
return header;
|
31 |
|
|
}
|
32 |
|
|
|
33 |
|
|
|
34 |
|
|
public static bool validateSalt2Header(string salt2String)
|
35 |
|
|
{
|
36 |
torben |
2172 |
if (salt2String.StartsWith("?"))
|
37 |
|
|
{
|
38 |
|
|
//addLogEntry("Illegal start character - discarding");
|
39 |
|
|
return false;
|
40 |
|
|
}
|
41 |
|
|
|
42 |
torben |
2169 |
if (salt2String.Length < 66)
|
43 |
|
|
{
|
44 |
|
|
//addLogEntry("Transaction too short - discarding");
|
45 |
|
|
return false;
|
46 |
|
|
}
|
47 |
|
|
|
48 |
|
|
|
49 |
|
|
int result;
|
50 |
|
|
long result_long;
|
51 |
|
|
|
52 |
torben |
2170 |
//string afsender = salt2String.Substring(0, 5);
|
53 |
|
|
//string modtager = salt2String.Substring(5, 5);
|
54 |
|
|
//string afsenderTegnSaet = salt2String.Substring(10, 6);
|
55 |
|
|
//string standardNavn = salt2String.Substring(16, 6);
|
56 |
torben |
2169 |
string standardVersion = salt2String.Substring(22, 3);
|
57 |
|
|
string afsenderSekvensnr = salt2String.Substring(25, 6);
|
58 |
|
|
string afsenderTidsstempel = salt2String.Substring(31, 14);
|
59 |
torben |
2170 |
//string afsenderBakkeIdent = salt2String.Substring(45, 5);
|
60 |
|
|
//string modtagerBakkeIdent = salt2String.Substring(50, 5);
|
61 |
|
|
//string transaktionForkortelse = salt2String.Substring(55, 4);
|
62 |
torben |
2169 |
string transaktionsLaengde = salt2String.Substring(59, 5);
|
63 |
|
|
string prioritet = salt2String.Substring(64, 1);
|
64 |
|
|
|
65 |
|
|
|
66 |
|
|
|
67 |
|
|
if (int.TryParse(standardVersion.Trim(), out result) == false) // standardVersion _skal_ være en int
|
68 |
|
|
{
|
69 |
|
|
//addLogEntry("standardVersion not an integer, discarding");
|
70 |
|
|
return false;
|
71 |
|
|
}
|
72 |
|
|
|
73 |
|
|
if (int.TryParse(afsenderSekvensnr.Trim(), out result) == false) // afsenderSekvensnr _skal_ være en int
|
74 |
|
|
{
|
75 |
|
|
//addLogEntry("afsenderSekvensnr not an integer, discarding");
|
76 |
|
|
return false;
|
77 |
|
|
}
|
78 |
|
|
|
79 |
|
|
if (long.TryParse(afsenderTidsstempel.Trim(), out result_long) == false) // afsenderTidsstempel _skal_ være en long
|
80 |
|
|
{
|
81 |
|
|
//addLogEntry("afsenderTidsstempel not a long integer, discarding");
|
82 |
|
|
return false;
|
83 |
|
|
}
|
84 |
|
|
|
85 |
|
|
if (int.TryParse(transaktionsLaengde.Trim(), out result) == false) // transaktionsLaengde _skal_ være en int
|
86 |
|
|
{
|
87 |
|
|
//addLogEntry("transaktionsLaengde not an integer, discarding");
|
88 |
|
|
return false;
|
89 |
|
|
}
|
90 |
|
|
|
91 |
|
|
if (int.TryParse(prioritet.Trim(), out result) == false) // prioritet _skal_ være en int
|
92 |
|
|
{
|
93 |
|
|
//addLogEntry("prioritet not an integer, discarding");
|
94 |
|
|
return false;
|
95 |
|
|
}
|
96 |
|
|
|
97 |
|
|
return true;
|
98 |
|
|
}
|
99 |
|
|
}
|
100 |
|
|
}
|