Subversion Repository Public Repository

ConnectionOdbcSdk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70

namespace Cisco.UnityConnection.OdbcSdk
{
    //Class used to store and compare any Unity or Unity Connection version - used mostly for the ConnectionServerOdbc class here which 
    //is why it's defined here but it can also be used for other purposes in COBRAS for backed up version checking and the like.
    //The unity version  7.1(2.3) breaks down like this:
    //Major=7
    //Minor=1
    //Rev=2
    //Build=3
    //Version="3.1(2.3)"
    //The ES can be tacked onto the end but it is not necessarily numeric and needs to be treated special
    public class UnityVersionDetails
    {
        public bool IsConnection;
        public int Major;
        public int Minor;
        public int Rev;
        public int Build;
        public string Es; //ESes do not have to be numeric - they should be treated special.
        public int EsInt; //in the case the ES is a number store it here for easy comparison - this won't work with all installs.
        public bool IsCoResident; //true only if we're on a CoRes installation - some restrictions in this mode

        /// <summary>
        /// Returns a human readable string representing the Unity/Connection version.
        /// </summary>
        /// <returns>
        /// Human readable representation of the Unity or Connection version string for logging/display purposes
        /// </returns>
        public override string ToString()
        {
            if (string.IsNullOrEmpty(Es) & EsInt<1)
            {
                return string.Format("{0}.{1}({2}.{3})", Major, Minor, Rev, Build);
            }
            if (string.IsNullOrEmpty(Es))
            {
                return string.Format("{0}.{1}({2}.{3}) ES{4}", Major, Minor, Rev, Build, EsInt);
            }

            return string.Format("{0}.{1}({2}.{3}) {4}", Major, Minor, Rev, Build, Es);
        }

        /// <summary>
        /// checks if a version is equal or more recent than the version passed in.
        /// </summary>
        /// <returns>
        /// TRUE if the version passed in is the same or older than the version details in the class instance.  FALSE otherwise.
        /// </returns>
        public bool IsVersionAtLeast(int pMajor, int pMinor, int pRev, int pBuild, int pEs = 0, bool? pIsConnection = null)
        {
            //only check the Connection/Unity match if it's passed in
            if (pIsConnection != null && pIsConnection != this.IsConnection)
            {
                return false;
            }

            if (this.Major > pMajor
                | this.Major == pMajor & this.Minor > pMinor
                | this.Major == pMajor & this.Minor == pMinor & this.Rev > pRev
                | this.Major == pMajor & this.Minor == pMinor & this.Rev == pRev & this.EsInt==0 & this.Build >= pBuild
                | this.Major == pMajor & this.Minor == pMinor & this.Rev == pRev & this.Build >= pBuild & this.EsInt >= pEs
                )
            {
                return true;
            }
            return false;
        }
    }
}

Commits for ConnectionOdbcSdk/trunk/ConnectionServer/UnityVersionDetails.cs

Diff revisions: vs.
Revision Author Commited Message
9 Diff Diff jlindborg picture jlindborg Fri 30 Aug, 2013 19:10:27 +0000

more unit and integration test setup work.

4 Diff Diff jlindborg picture jlindborg Sat 01 Jun, 2013 02:52:17 +0000

reworking project structure and naming

3 jlindborg picture jlindborg Sat 01 Jun, 2013 02:42:57 +0000

Starting basic ODBC SDK project