/[projects]/dao/DaoMqPump2/DaoCommon/Salt2Helper.cs
ViewVC logotype

Contents of /dao/DaoMqPump2/DaoCommon/Salt2Helper.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2171 - (show annotations) (download)
Fri May 16 21:50:17 2014 UTC (10 years ago) by torben
File size: 3259 byte(s)
Theoretically this should work
1 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
26
27 header.transaktionForkortelse = header.transaktionForkortelse.Trim();
28
29 return header;
30 }
31
32
33 public static bool validateSalt2Header(string salt2String)
34 {
35 if (salt2String.Length < 66)
36 {
37 //addLogEntry("Transaction too short - discarding");
38 return false;
39 }
40
41
42 int result;
43 long result_long;
44
45 //string afsender = salt2String.Substring(0, 5);
46 //string modtager = salt2String.Substring(5, 5);
47 //string afsenderTegnSaet = salt2String.Substring(10, 6);
48 //string standardNavn = salt2String.Substring(16, 6);
49 string standardVersion = salt2String.Substring(22, 3);
50 string afsenderSekvensnr = salt2String.Substring(25, 6);
51 string afsenderTidsstempel = salt2String.Substring(31, 14);
52 //string afsenderBakkeIdent = salt2String.Substring(45, 5);
53 //string modtagerBakkeIdent = salt2String.Substring(50, 5);
54 //string transaktionForkortelse = salt2String.Substring(55, 4);
55 string transaktionsLaengde = salt2String.Substring(59, 5);
56 string prioritet = salt2String.Substring(64, 1);
57
58
59
60 if (int.TryParse(standardVersion.Trim(), out result) == false) // standardVersion _skal_ være en int
61 {
62 //addLogEntry("standardVersion not an integer, discarding");
63 return false;
64 }
65
66 if (int.TryParse(afsenderSekvensnr.Trim(), out result) == false) // afsenderSekvensnr _skal_ være en int
67 {
68 //addLogEntry("afsenderSekvensnr not an integer, discarding");
69 return false;
70 }
71
72 if (long.TryParse(afsenderTidsstempel.Trim(), out result_long) == false) // afsenderTidsstempel _skal_ være en long
73 {
74 //addLogEntry("afsenderTidsstempel not a long integer, discarding");
75 return false;
76 }
77
78 if (int.TryParse(transaktionsLaengde.Trim(), out result) == false) // transaktionsLaengde _skal_ være en int
79 {
80 //addLogEntry("transaktionsLaengde not an integer, discarding");
81 return false;
82 }
83
84 if (int.TryParse(prioritet.Trim(), out result) == false) // prioritet _skal_ være en int
85 {
86 //addLogEntry("prioritet not an integer, discarding");
87 return false;
88 }
89
90 return true;
91 }
92 }
93 }

  ViewVC Help
Powered by ViewVC 1.1.20