Beispiel #1
0
        public new Dictionary <string, screenRec> readData(string sql)
        {
            string        connectionString;
            SqlConnection cnn;

            connectionString = @"Data Source = LT-JOSEPHHANDSC\MVDATA; Initial Catalog = logger; User ID=sa; Password=pa55w0rd!";
            cnn = new SqlConnection(connectionString);

            try
            {
                cnn.Open();

                SqlCommand    command;
                SqlDataReader dataReader;

                command = new SqlCommand(sql, cnn);

                dataReader = command.ExecuteReader();

                Dictionary <string, screenRec> dicData = new Dictionary <string, screenRec>();

                while (dataReader.Read())
                {
                    screenRec sr = new screenRec();
                    sr.prectype = dataReader.GetString(2);
                    sr.pscrnum  = dataReader.GetString(3);
                    sr.pscrdata = dataReader.GetString(4);
                    sr.pload    = dataReader.GetString(5);
                    dicData.Add(dataReader.GetString(1) + dataReader.GetInt32(0).ToString(), sr);
                }
                dataReader.Close();
                command.Dispose();
                cnn.Close();
                return(dicData);
            }
            catch (Exception dbEx)
            {
                Console.WriteLine(dbEx.ToString());
                return(null);
            }
        }
Beispiel #2
0
        public override void ValidateState(stateRec stateData)
        {
            Dictionary <string, stateRec> resultData = new Dictionary <string, stateRec>();

            base.ValidateState(stateData);

            // validate state data

            /*
             * validate statNum is 000 - 999
             * validate screen:
             *  exist in screen table
             *  is in the range of 000 - 999
             * validate good read next state:
             *  exist in state table
             *  is 000-254 256-999
             * validate misread screen:
             *  exist in screen table
             *  range is 000-999
             * validate read conditions 1, 2, 3
             * validate no fit match:
             *  exist in state table
             *  range is 000-254 256-999
             */
            if (stateData.stateType == "I")
            {
                screenRec sr = new screenRec();
                // validate screen number with db
                bool resp = sr.ValidateScreen(stateData.sta1);

                // validate misread screen to go
                resultData = this.ValidateStateNumber(stateData.sta2);
                //Console.WriteLine("Error stat type A misread screen does not exist");

                // validate Track 2 is sent or not
                resp = this.ValidateYesNo(stateData.sta3);

                // validate Track 1 or 3 is between 0 and 7
                resp = this.ValidateRange(stateData.sta4, 0, 7);

                // validate OpCode Data
                resp = this.ValidateYesNo(stateData.sta5);

                // validate Amount Data
                resp = this.ValidateYesNo(stateData.sta6);
                bool extState = false;

                // validate PIN Buffer/Extended Format
                if (!(stateData.sta7 == "000" || stateData.sta7 == "001" ||
                      stateData.sta7 == "128" || stateData.sta7 == "129"))
                {
                    Console.WriteLine(" PIN Buffer/Extended Format value invalid ");
                }
                else if (stateData.sta7 == "128" || stateData.sta7 == "129")
                {
                    extState = true;
                }

                // validate General Purpose Buffer B or Extension State Number
                if (stateData.sta8 == "255")
                {
                    Console.WriteLine(" General Purpose Buffer B invalid ");
                }
                else
                {
                    if (stateData.sta8 == "000" || stateData.sta8 == "001")
                    {
                        resp = this.ValidateRange(stateData.sta8, 0, 7);
                    }
                    else
                    {
                        resp       = this.ValidateRange(stateData.sta8, 0, 999);
                        resultData = this.ValidateStateNumber(stateData.sta8);
                    }
                }
            }
        }
Beispiel #3
0
        public List <DataTable> getRecord(string logKey, string logID, string projectKey, string recValue)
        {
            List <typeRec> typeList = new List <typeRec>();

            string[]         tmpTypes;
            int              recCount  = 0;
            string           recType   = "";
            DataTable        dataTable = new DataTable();
            List <DataTable> dts       = new List <DataTable>();

            foreach (string recordType in App.Prj.RecordTypes)
            {
                if (recValue.Contains(recordType))
                {
                    if (recCount == 0 || recCount == 1)
                    {
                        recType = recCount.ToString("00");
                    }
                    else
                    {
                        tmpTypes = recValue.Split((char)0x1c);

                        foreach (string subRecordType in App.Prj.SubRecordTypes)
                        {
                            if (tmpTypes[3] == subRecordType)
                            {
                                recType = subRecordType;
                                break;
                            }
                        }
                    }
                    break;
                }
                recCount++;
            }
            switch (recType)
            {
            case "00":
                TRec tr = new TRec();
                dts = tr.getRecord(logKey, logID, projectKey);
                break;

            case "01":
                TReply treply = new TReply();
                dts = treply.getRecord(logKey, logID, projectKey);
                break;

            case "11":
                screenRec scrRec = new screenRec();
                break;

            case "12":
                stateRec staRec = new stateRec();
                dts = staRec.getRecord(logKey, logID, projectKey);
                break;

            case "13":
                configParamsRec cpRec = new configParamsRec();
                break;

            case "15":
                FitRec fitRec = new FitRec();
                dts = fitRec.getRecord(logKey, logID, projectKey);
                break;

            case "16":
                ConfigIdRec cir = new ConfigIdRec();
                dts = cir.getRecord(logKey, logID, projectKey);
                break;

            case "1A":
                EnhancedParamsRec epRec = new EnhancedParamsRec();
                dts = epRec.getRecord(logKey, logID, projectKey);
                break;

            case "1B":
                //writeMAC(typeList);
                break;

            case "1C":
                DateAndTimeRec dt = new DateAndTimeRec();
                break;

            case "1E":
                //writeDispenser(typeList);
                break;

            case "42":
                ExtEncryptionRec xer = new ExtEncryptionRec();
                break;
            }
            return(dts);
        }
Beispiel #4
0
        public override void ValidateState(stateRec stateData)
        {
            Dictionary <string, stateRec> resultData = new Dictionary <string, stateRec>();

            base.ValidateState(stateData);

            // validate state data

            /*
             * validate statNum is 000
             * validate screen:
             *  exist in screen table
             *  is in the range of 000 - 999
             * validate good read next state:
             *  exist in state table
             *  is 000-254 256-999
             * validate misread screen:
             *  exist in screen table
             *  range is 000-999
             * validate read conditions 1, 2, 3
             * validate no fit match:
             *  exist in state table
             *  range is 000-254 256-999
             */
            if (stateData.stateType == "A")
            {
                if (stateData.stateNum != "000")
                {
                    Console.WriteLine("Erorr state type A not 000");
                }
                screenRec sr = new screenRec();
                // validate screen number with db
                bool resp = sr.ValidateScreen(stateData.sta1);

                // validate state number
                resultData = this.ValidateStateNumber(stateData.sta2);

                // validate error screen
                resp = sr.ValidateScreen(stateData.sta3);

                // read conditions

                /*
                 *  bit    binary   decimal   meaning
                 *  0       0001      001       Read T3
                 *  1       0010      002       Read t2
                 *  1-0     0011      003       Read t2 and t3
                 *  2       0100      004       Read t1
                 *  2-0     0101      005       Read t1 and t3
                 *  2-1     0110      006       Read t1 and t2
                 *  2-1-0   0111      007       Read all tracks
                 *  3       1000      008       Chip connect
                 */

                // validate State type A Readcondition 1 between 1 and 7
                resp = this.ValidateRange(stateData.sta4, 1, 7);

                // validate State type A Readcondition 2 between 1 and 7
                resp = this.ValidateRange(stateData.sta5, 1, 7);

                // validate State type A Readcondition 3 between 1 and 8
                resp = this.ValidateRange(stateData.sta6, 1, 8);

                // validate State type A Card Return Flag between 0 and 1
                resp = this.ValidateRange(stateData.sta7, 0, 1);

                // validate state type A No FIT match state does not exist
                resultData = this.ValidateStateNumber(stateData.sta8);
            }
        }
Beispiel #5
0
        public void getData(string regExStr, string recordType, string logID)
        {
            string sql = @"SELECT logkey,id,group8 from [logger].[dbo].[loginfo] " +
                         "WHERE group8 like '" + regExStr + "' " +
                         "AND logID =" + logID;
            Dictionary <string, string> data = readData(sql);

            string[]       dataTypes = null;
            List <typeRec> typeList  = new List <typeRec>();

            string[] tmpTypes;

            foreach (KeyValuePair <string, string> rec in data)
            {
                // tmpTypes = rec.Value.Split((char)0x1c);

                if (recordType == "00" || recordType == "01")
                {
                    typeRec r = new typeRec();
                    r.typeIndex   = rec.Key;
                    r.typeContent = rec.Value;
                    typeList.Add(r);
                }



                tmpTypes = rec.Value.Split((char)0x1c);

                if (tmpTypes[3] == recordType)
                {
                    int    myInd    = tmpTypes[0].Length + tmpTypes[1].Length + tmpTypes[2].Length + tmpTypes[3].Length;
                    string typeData = rec.Value.Substring(myInd + 4, rec.Value.Length - (myInd + 4));

                    dataTypes = typeData.Split((char)0x1c);

                    foreach (string item in dataTypes)
                    {
                        typeRec r = new typeRec();
                        r.typeIndex   = rec.Key;
                        r.typeContent = item;
                        typeList.Add(r);
                    }
                }
            }
            switch (recordType)
            {
            case "00":
                TRec tr = new TRec();
                if (tr.writeData(typeList, Key, logID))
                {
                    setBitToTrue(recordType, logID);
                }

                break;

            case "01":
                TReply treply = new TReply();
                if (treply.writeData(typeList, Key, logID))
                {
                    // set screen bit to true
                    setBitToTrue(recordType, logID);
                }
                break;

            case "11":
                screenRec scrRec = new screenRec();
                if (scrRec.writeData(typeList, Key, logID))
                {
                    setBitToTrue(recordType, logID);
                }
                break;

            case "12":
                stateRec staRec = new stateRec();
                if (staRec.writeData(typeList, Key, logID))
                {
                    setBitToTrue(recordType, logID);
                }
                break;

            case "13":
                configParamsRec cpRec = new configParamsRec();
                if (cpRec.writeData(typeList, Key, logID))
                {
                    setBitToTrue(recordType, logID);
                }
                break;

            case "15":
                FitRec fitRec = new FitRec();
                if (fitRec.writeData(typeList, Key, logID))
                {
                    setBitToTrue(recordType, logID);
                }
                break;

            case "16":
                ConfigIdRec cir = new ConfigIdRec();
                if (cir.writeData(typeList, Key, logID))
                {
                    setBitToTrue(recordType, logID);
                }
                break;

            case "1A":
                EnhancedParamsRec epRec = new EnhancedParamsRec();
                if (epRec.writeData(typeList, Key, logID))
                {
                    setBitToTrue(recordType, logID);
                }
                break;

            case "1B":
                //writeMAC(typeList);
                break;

            case "1C":
                DateAndTimeRec dt = new DateAndTimeRec();
                if (dt.writeData(typeList, Key, logID))
                {
                    setBitToTrue(recordType, logID);
                }
                break;

            case "1E":
                //writeDispenser(typeList);
                break;

            case "42":
                ExtEncryptionRec xer = new ExtEncryptionRec();
                if (xer.writeData(typeList, Key, logID))
                {
                    setBitToTrue(recordType, logID);
                }
                break;
            }
        }