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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.20