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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.20