Exemplo n.º 1
0
        public void Set(string key, byte[] value)
        {
            StringKey stringKey = new StringKey(key);

            StringRecord stringRecord = new StringRecord(stringKey, value);

            int index = KeyHasher.HashKey(stringKey, BucketArraySize);

            BucketArray.Insert(stringRecord, index);
        }
Exemplo n.º 2
0
        public StringCreator(StringRecord record) : this()
        {
            this.StringTextBoxKey.Text   = $"0x{record.Key:X8}";
            this.StringTextBoxLabel.Text = record.Label;
            this.StringTextBoxText.Text  = Utils.UTF8toISO(record.Text);

            if (record.Key != record.Label.BinHash())
            {
                this.StringCheckBoxCustom.Checked = true;
            }
        }
Exemplo n.º 3
0
        public void TestBasic()
        {
            FormulaRecord f = new FormulaRecord();

            f.SetCachedResultTypeString();
            StringRecord s = new StringRecord();

            s.String = ("abc");
            FormulaRecordAggregate fagg = new FormulaRecordAggregate(f, s, SharedValueManager.CreateEmpty());

            Assert.AreEqual("abc", fagg.StringValue);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Disassembles string block array into separate properties.
        /// </summary>
        /// <param name="byteptr_t">Pointer to the string block array.</param>
        protected override unsafe void Disassemble(byte *byteptr_t, int length)
        {
            int  ReaderOffset = 0;
            uint ReaderID     = 0;
            int  BlockSize    = 0;
            bool found        = false;

            // Run through file
            while (ReaderOffset < length)
            {
                ReaderID  = *(uint *)(byteptr_t + ReaderOffset);
                BlockSize = *(int *)(byteptr_t + ReaderOffset + 4);
                if (!found && ReaderID == Global.STRBlocks)
                {
                    this._offset        = ReaderOffset;
                    this._size          = BlockSize;
                    this.CollectionName = BaseArguments.GLOBAL;
                    found = true;
                }
                ReaderOffset += 8 + BlockSize;
            }

            // Check if string block exists
            if (this._offset == -1 || this._size == -1)
            {
                return;
            }

            // Advance position and read through header
            byteptr_t            += this._offset + 8;
            this._unk_data_offset = *(int *)byteptr_t;
            this._num_entries     = *(int *)(byteptr_t + 4);
            this._key_offset      = *(int *)(byteptr_t + 8);
            this._text_offset     = *(int *)(byteptr_t + 12);

            // Get unknown data into memory
            this._unknown = new byte[this._key_offset - this._unk_data_offset];
            for (int a1 = 0; a1 < this._unknown.Length; ++a1)
            {
                this._unknown[a1] = *(byteptr_t + this._unk_data_offset + a1);
            }

            // Begin reading through string records
            for (int a1 = 0; a1 < this._num_entries; ++a1)
            {
                var info = new StringRecord(this);
                info.Key = *(uint *)(byteptr_t + this._key_offset + a1 * 8);
                var pos = this._text_offset + *(int *)(byteptr_t + this._key_offset + a1 * 8 + 4);
                info.Text = ScriptX.NullTerminatedString(byteptr_t + pos);
                this._stringinfo.Add(info);
            }
        }
Exemplo n.º 5
0
        //get modified value
        public object gmv(StringRecord newData, String fieldName, DataRow oldData, String rowName)
        {
            string sd = newData.getField(fieldName);

            if (sd != null)
            {
                return(sd);
            }
            else
            {
                return(oldData[rowName]);
            }
        }
Exemplo n.º 6
0
        public void TestStore()
        {
            StringRecord record = new StringRecord();

            record.String = (/*setter*/ "Fahrzeugtyp");

            byte[] recordBytes = record.Serialize();
            Assert.AreEqual(recordBytes.Length - 4, data.Length);
            for (int i = 0; i < data.Length; i++)
            {
                Assert.AreEqual(data[i], recordBytes[i + 4], "At offset " + i);
            }
        }
Exemplo n.º 7
0
        protected int[] makeTeamData(StringRecord aRecord, int gtype)
        {
            MySqlDataAdapter da;

            try
            {
                if (!openConnection())
                {
                    return(null);
                }

                String       tsql = @"insert into team_data(t_name, g_type, fl_code)  values (@a, @b, @c)";
                MySqlCommand cmd  = new MySqlCommand(tsql, this.conn);
                cmd.Prepare();

                cmd.Parameters.AddWithValue("@a", aRecord.getField("AE"));
                cmd.Parameters.AddWithValue("@b", gtype);
                cmd.Parameters.AddWithValue("@c", "");

                try
                {
                    cmd.ExecuteNonQuery();                     // teamA
                }
                catch (Exception ex) { }

                cmd.Parameters["@a"].Value = aRecord.getField("AF");
                try
                {
                    cmd.ExecuteNonQuery();                     // teamB
                }
                catch (Exception ex) { }


                tsql = @"select t_id from team_data where g_type =" + gtype + " and t_name = '" + aRecord.getField("AE") + "'";
                cmd  = new MySqlCommand(tsql, this.conn);
                int teama = (int)cmd.ExecuteScalar();

                tsql = @"select t_id from team_data where g_type =" + gtype + " and t_name = '" + aRecord.getField("AF") + "'";
                MySqlCommand cmd2  = new MySqlCommand(tsql, this.conn);
                int          teamb = (int)cmd2.ExecuteScalar();
                cmd = null; cmd2 = null;

                int[] result = new int[2] {
                    teama, teamb
                };
                return(result);
            }
            catch (Exception eex) { }
            return(null);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Disassembles string block array into separate properties.
        /// </summary>
        /// <param name="byteptr_t">Pointer to the string block array.</param>
        protected override unsafe void Disassemble(byte *byteptr_t, int length)
        {
            int  ReaderOffset = 0;
            uint ReaderID     = 0;
            int  BlockSize    = 0;

            // Run through file
            while (ReaderOffset < length)
            {
                ReaderID  = *(uint *)(byteptr_t + ReaderOffset);
                BlockSize = *(int *)(byteptr_t + ReaderOffset + 4);
                if (ReaderID == Global.STRBlocks)
                {
                    var categ = ScriptX.NullTerminatedString(byteptr_t + ReaderOffset + 20, 0x10);
                    if (categ == "Global")
                    {
                        this._offset        = ReaderOffset;
                        this._size          = BlockSize;
                        this.CollectionName = BaseArguments.GLOBAL;
                    }
                }
                ReaderOffset += 8 + BlockSize;
            }

            // Check if string block exists
            if (this._offset == -1 || this._size == -1)
            {
                return;
            }

            // Advance position and read through header
            byteptr_t        += this._offset + 8;
            this._num_entries = *(int *)(byteptr_t);
            this._key_offset  = *(int *)(byteptr_t + 4);
            this._text_offset = *(int *)(byteptr_t + 8);
            this._category    = ScriptX.NullTerminatedString(byteptr_t + 12, 0x10);

            // Begin reading through string records
            for (int a1 = 0; a1 < this._num_entries; ++a1)
            {
                var info = new StringRecord(this);
                info.Key = *(uint *)(byteptr_t + this._key_offset + a1 * 8);
                var pos = this._text_offset + *(int *)(byteptr_t + this._key_offset + a1 * 8 + 4);
                info.Text = ScriptX.NullTerminatedString(byteptr_t + pos);
                this._stringinfo.Add(info);
            }
        }
Exemplo n.º 9
0
 /// <summary>
 /// Sets the cached string result.
 /// </summary>
 /// <param name="value">The value.</param>
 public void SetCachedStringResult(String value)
 {
     // Save the string into a String Record, creating one if required
     if (_stringRecord == null)
     {
         _stringRecord = new StringRecord();
     }
     _stringRecord.String = (value);
     if (value.Length < 1)
     {
         _formulaRecord.SetCachedResultTypeEmptyString();
     }
     else
     {
         _formulaRecord.SetCachedResultTypeString();
     }
 }
Exemplo n.º 10
0
        private void AddString_Click(object sender, EventArgs e)
        {
            string global = "GLOBAL_";
            int    index  = 0;

            while (!this._record.ThisSTRBlock.TryAddRecord(BaseArguments.AUTO,
                                                           $"{global}{index}", string.Empty))
            {
                ++index;
            }
            var newkey    = Bin.Hash($"{global}{index}");
            var newrecord = this._record.ThisSTRBlock.GetRecord(newkey);

            this._record = newrecord;
            this.CommandsProcessed.Add($"{eCommands.add} {path} {BaseArguments.AUTO} {global}{index} \"\"");
            this.STREditor_Load(this, EventArgs.Empty);
        }
Exemplo n.º 11
0
        public void TestContinue()
        {
            int           MAX_BIFF_DATA = RecordInputStream.MAX_RECORD_DATA_SIZE;
            int           TEXT_LEN      = MAX_BIFF_DATA + 1000; // deliberately over-size
            string        textChunk     = "ABCDEGGHIJKLMNOP";   // 16 chars
            StringBuilder sb            = new StringBuilder(16384);

            while (sb.Length < TEXT_LEN)
            {
                sb.Append(textChunk);
            }
            sb.Length = (/*setter*/ TEXT_LEN);

            StringRecord sr = new StringRecord();

            sr.String = (/*setter*/ sb.ToString());
            byte[] ser = sr.Serialize();
            Assert.AreEqual(StringRecord.sid, LittleEndian.GetUShort(ser, 0));
            if (LittleEndian.GetUShort(ser, 2) > MAX_BIFF_DATA)
            {
                throw new AssertionException(
                          "StringRecord should have been split with a continue record");
            }
            // Confirm expected size of first record, and ushort strLen.
            Assert.AreEqual(MAX_BIFF_DATA, LittleEndian.GetUShort(ser, 2));
            Assert.AreEqual(TEXT_LEN, LittleEndian.GetUShort(ser, 4));

            // Confirm first few bytes of ContinueRecord
            ILittleEndianInput crIn = new LittleEndianByteArrayInputStream(ser, (MAX_BIFF_DATA + 4));
            int nCharsInFirstRec    = MAX_BIFF_DATA - (2 + 1); // strLen, optionFlags
            int nCharsInSecondRec   = TEXT_LEN - nCharsInFirstRec;

            Assert.AreEqual(ContinueRecord.sid, crIn.ReadUShort());
            Assert.AreEqual(1 + nCharsInSecondRec, crIn.ReadUShort());
            Assert.AreEqual(0, crIn.ReadUByte());
            Assert.AreEqual('N', crIn.ReadUByte());
            Assert.AreEqual('O', crIn.ReadUByte());

            // re-read and make sure string value is the same
            RecordInputStream in1 = TestcaseRecordInputStream.Create(ser);
            StringRecord      sr2 = new StringRecord(in1);

            Assert.AreEqual(sb.ToString(), sr2.String);
        }
Exemplo n.º 12
0
        public void SortedMapStringValueTest()
        {
            var          client = new SessionNoServer(systemDir);
            const string key    = "test";
            const string value  = "string value text";

            client.BeginUpdate();
            var originalRecord = new StringRecord();

            originalRecord.Fields.Add(key, value);
            originalRecord.Persist(client, originalRecord);
            client.Commit();
            client = new SessionNoServer(systemDir);
            client.BeginUpdate();
            var newRecord = client.AllObjects <StringRecord>(false, false).FirstOrDefault(r => r.Id == originalRecord.Id);

            Assert.IsNotNull(newRecord);
            Assert.AreEqual(originalRecord.Fields[key], newRecord.Fields[key]);
            client.Commit();
            client.Dispose();
        }
Exemplo n.º 13
0
        /*
         *
         */
        protected void makeGameName(StringRecord zRecord, int gtype)
        {
            String ZC = zRecord.getField("ZC");             //g_code
            String ZB = zRecord.getField("ZB");             //fl_code
            String ZA = zRecord.getField("ZA");             //game_name

            String sql = "insert into game_name(gn_code, gn_name, g_type, fl_code) values (@1, @2, @3, @4)";

            try
            {
                if (!openConnection())
                {
                    return;
                }

                MySqlCommand cmd = conn.CreateCommand();
                cmd.CommandText = sql;

                cmd.Parameters.AddWithValue("@1", ZC);
                cmd.Parameters.AddWithValue("@2", ZA);
                cmd.Parameters.AddWithValue("@3", gtype);
                cmd.Parameters.AddWithValue("@4", ZB);



                cmd.ExecuteNonQuery();
            }
            catch (Exception e) {
                //System.Console.WriteLine(e.Message);
            }
            finally
            {
                sql = null;
                ZC  = null;
                ZB  = null;
                ZA  = null;
            }
        }
Exemplo n.º 14
0
 public void Construct(CellValueRecordInterface rec, RecordStream rs, SharedValueManager sfh)
 {
     if (rec is FormulaRecord)
     {
         FormulaRecord formulaRec = (FormulaRecord)rec;
         // read optional cached text value
         StringRecord cachedText = null;
         Type         nextClass  = rs.PeekNextClass();
         if (nextClass == typeof(StringRecord))
         {
             cachedText = (StringRecord)rs.GetNext();
         }
         else
         {
             cachedText = null;
         }
         InsertCell(new FormulaRecordAggregate(formulaRec, cachedText, sfh));
     }
     else
     {
         InsertCell(rec);
     }
 }
Exemplo n.º 15
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FormulaRecordAggregate"/> class.
        /// </summary>
        /// <param name="formulaRec">The formula rec.</param>
        /// <param name="stringRec">The string rec.</param>
        /// <param name="svm">The SVM.</param>
        public FormulaRecordAggregate(FormulaRecord formulaRec, StringRecord stringRec, SharedValueManager svm)
        {
            if (svm == null)
            {
                throw new ArgumentException("sfm must not be null");
            }
            if (formulaRec.HasCachedResultString)
            {
                if (stringRec == null)
                {
                    throw new RecordFormatException("Formula record flag is set but String record was not found");
                }
                _stringRecord = stringRec;
            }
            else
            {
                // Usually stringRec is null here (in agreement with what the formula rec says).
                // In the case where an extra StringRecord is erroneously present, Excel (2007)
                // ignores it (see bug 46213).
                _stringRecord = null;
            }

            _formulaRecord      = formulaRec;
            _sharedValueManager = svm;
            if (formulaRec.IsSharedFormula)
            {
                CellReference firstCell = formulaRec.Formula.ExpReference;
                if (firstCell == null)
                {
                    HandleMissingSharedFormulaRecord(formulaRec);
                }
                else
                {
                    _sharedFormulaRecord = svm.LinkSharedFormulaRecord(firstCell, this);
                }
            }
        }
Exemplo n.º 16
0
        public void consoleCommandHandler(string cmd)
        {
            try
            {
                string   tofind = "";
                string[] tofindall = null;
                ushort   modid, stid;
                uint     txid;
                cmd = cmd.Trim();
                this.cmdHistory.Add(cmd);
                cmdIdx = this.cmdHistory.Count - 1;
                string[] splitted = cmd.Split(new char[] { ' ' }, 2);
                switch (splitted[0])
                {
                case "readdb":
                    if (splitted.Length > 1 && splitted[1].Trim() != "")
                    {
                        this.fi = new FileInfo(splitted[1].Trim());
                    }
                    this.checkDB();
                    break;

                case "unloaddb":
                    this.db = null;
                    // We're taking out a huge chunk of memory, so let GC clear it out right away.
                    GC.Collect();
                    break;

                case "stringid":
                    this.checkDB();

                    stid = Util.parseUShort(splitted[1]);

                    StringRecord stringRec = (StringRecord)this.db.tables[Database.TABLE_STRINGS].getRecord(stid);
                    if (stringRec != null)
                    {
                        string toWrite = "text: " + stringRec.text;
                        if (stringRec.obdCodeString != "" && stringRec.obdCodeString != " ")
                        {
                            toWrite += "; OBD: " + stringRec.obdCodeString;
                        }
                        this.writeToConsole(toWrite + Environment.NewLine);
                    }
                    else
                    {
                        this.writeToConsole("(null)" + Environment.NewLine);
                    }

                    break;

                case "stringsearch":
                    this.checkDB();

                    this.writeBulkToConsoleStart();

                    string searching = splitted[1].ToLower();

                    foreach (StringRecord sr in this.db.tables[Database.TABLE_STRINGS].records)
                    {
                        if (sr.text.ToLower().Contains(searching) || sr.obdCodeString.ToLower().Contains(searching))
                        {
                            string toWrite = "0x" + sr.id.ToString("x4") + ": text: " + sr.text;
                            if (sr.obdCodeString != "" && sr.obdCodeString != " ")
                            {
                                toWrite += "; OBD: " + sr.obdCodeString;
                            }
                            this.writeBulkToConsole(toWrite);
                        }
                    }

                    this.writeBulkToConsoleEnd();

                    break;

                case "txid":
                    this.checkDB();

                    txid = Util.parseUInt(splitted[1]);

                    this.writeToConsole(this.db.getDetailedTX(txid) + Environment.NewLine);

                    break;

                case "txrunconverter":
                case "txrunconvertermetric":
                    this.checkDB();

                    string[] txconvsplit = splitted[1].Split(new char[] { ' ' }, 2);
                    long     convdata    = 0;

                    txid     = Util.parseUInt(txconvsplit[0]);
                    convdata = Util.parseLong(txconvsplit[1]);

                    Table    txconvtable = this.db.tables[Database.TABLE_TRANSMIT];
                    TXRecord txconvrec   = (TXRecord)txconvtable.getRecord(txid);

                    string result = txconvrec.converter.processData(convdata, outputMetric: splitted[0].EndsWith("metric"));

                    this.writeToConsole(result + Environment.NewLine);

                    break;

                case "txsearch":
                    this.checkDB();

                    tofind = splitted[1].ToLower();
                    if (tofind.Contains(" && "))
                    {
                        tofindall = tofind.Split(new string[] { " && " }, StringSplitOptions.RemoveEmptyEntries);
                    }

                    this.writeBulkToConsoleStart();
                    for (uint u = 0x80000000; u < 0x80009000; ++u)
                    {
                        try
                        {
                            string temp = this.db.getTX(u);
                            if (temp != null)
                            {
                                string templower = temp.ToLower();

                                if (tofindall != null)
                                {
                                    foreach (string s in tofindall)
                                    {
                                        if (!templower.Contains(s))
                                        {
                                            goto SKIPTX;
                                        }
                                    }
                                    this.writeBulkToConsole(temp + "; 0x" + u.ToString("x"));
                                }
                                else if (templower.Contains(tofind))
                                {
                                    this.writeBulkToConsole(temp + "; 0x" + u.ToString("x"));
                                }
                            }
                        }
                        catch
                        {
                            continue;
                        }

SKIPTX:
                        continue;
                    }
                    this.writeBulkToConsoleEnd();

                    break;

                case "dumpstateconverter":
                case "dumpconverter":
                case "convertertostring":
                    this.checkDB();

                    txid = Util.parseUInt(splitted[1]);

                    Table    ctsTable    = this.db.tables[Database.TABLE_TRANSMIT];
                    TXRecord ctsTxRecord = (TXRecord)ctsTable.getRecord(txid);

                    this.writeToConsole(ctsTxRecord.converter.ToString() + Environment.NewLine);

                    break;

                case "dumptableinfo":
                    this.checkDB();

                    ushort tableNum = Util.parseUShort(splitted[1]);

                    Table  t       = this.db.tables[tableNum];
                    string toPrint = "";

                    toPrint += "Table: " + tableNum + "; Columns: " + t.colCount + "; Rows: " + t.rowCount + ";" + Environment.NewLine;
                    toPrint += "ColSizes: " + BitConverter.ToString(t.colSizes) + "; RowSize: " + t.rowSize + ";" + Environment.NewLine;

                    this.writeToConsole(toPrint);

                    break;

                case "stringidfuzz":
                    this.checkDB();

                    string[] stringfuzzsplit = splitted[1].Split(new char[] { ' ' }, 2);

                    ushort stringfuzzTable    = Util.parseUShort(stringfuzzsplit[0]);
                    byte   stringfuzzTableCol = (byte)Util.parseUShort(stringfuzzsplit[1]);
                    Table  tt              = this.db.tables[stringfuzzTable];
                    int    stringfuzzhits  = 0;
                    int    stringfuzzzeros = 0;

                    foreach (Record stringfuzzrec in tt.records)
                    {
                        ushort stringfuzzfield  = (ushort)tt.readField(stringfuzzrec, stringfuzzTableCol);
                        string stringfuzzstring = this.db.getString(stringfuzzfield);
                        if (stringfuzzstring != "(null)")
                        {
                            ++stringfuzzhits;
                        }
                        if (stringfuzzfield == 0)
                        {
                            ++stringfuzzzeros;
                        }
                    }

                    this.writeToConsole("Records: " + tt.records.Length + "; Hits: " + stringfuzzhits + "; Zeros: " + stringfuzzzeros + Environment.NewLine);

                    break;

                case "genericidfuzz":
                    this.checkDB();

                    string[] fuzzsplit = splitted[1].Split(new char[] { ' ' }, 4);

                    ushort fuzzerTableId   = Util.parseUShort(fuzzsplit[0]);
                    byte   fuzzerTableCol  = (byte)Util.parseUShort(fuzzsplit[1]);
                    ushort fuzzingTableId  = Util.parseUShort(fuzzsplit[2]);
                    byte   fuzzingTableCol = (byte)Util.parseUShort(fuzzsplit[3]);
                    Table  fuzzerTable     = this.db.tables[fuzzerTableId];
                    Table  fuzzingTable    = this.db.tables[fuzzingTableId];
                    int    fuzzhits        = 0;
                    int    fuzzzeros       = 0;

                    foreach (Record fuzzingRec in fuzzingTable.records)
                    {
                        uint   fuzzingRecID = (uint)fuzzingTable.readField(fuzzingRec, fuzzingTableCol);
                        Record fuzzerRec    = fuzzerTable.getRecord(fuzzingRecID, idcol: fuzzerTableCol, sorted: false);
                        if (fuzzerRec != null)
                        {
                            ++fuzzhits;
                        }
                        if (fuzzingRecID == 0)
                        {
                            ++fuzzzeros;
                        }
                    }

                    this.writeToConsole("Records: " + fuzzingTable.records.Length + "; Hits: " + fuzzhits + "; Zeros: " + fuzzzeros + Environment.NewLine);

                    break;

                case "modid":
                    this.checkDB();

                    modid = Util.parseUShort(splitted[1]);

                    string modresult = this.db.getModule(modid);

                    if (modresult != null)
                    {
                        this.writeToConsole(modresult + Environment.NewLine);
                    }
                    else
                    {
                        this.writeToConsole("No such module ID." + Environment.NewLine);
                    }

                    this.txtConsoleInput.Focus();
                    this.txtConsoleInput.AppendText("modid " + splitted[1]);

                    break;

                case "modlist":
                case "modsearch":
                    this.checkDB();

                    if (splitted[0] != "modlist")
                    {
                        tofind = splitted[1].ToLower();
                        if (tofind.Contains(" && "))
                        {
                            tofindall = tofind.Split(new string[] { " && " }, StringSplitOptions.RemoveEmptyEntries);
                        }
                    }

                    this.writeBulkToConsoleStart();
                    for (ushort l = 0x0000; l < 0x2000; ++l)
                    {
                        try
                        {
                            string temp = this.db.getModule(l);

                            if (temp != null)
                            {
                                if (splitted[0] != "modlist")
                                {
                                    string templower = temp.ToLower();

                                    if (tofindall != null)
                                    {
                                        foreach (string s in tofindall)
                                        {
                                            if (!templower.Contains(s))
                                            {
                                                goto SKIPMOD;
                                            }
                                        }
                                        this.writeBulkToConsole(temp + "; 0x" + l.ToString("x"));
                                    }
                                    else if (templower.Contains(tofind))
                                    {
                                        this.writeBulkToConsole(temp + "; 0x" + l.ToString("x"));
                                    }
                                }
                                else
                                {
                                    this.writeBulkToConsole(temp + "; 0x" + l.ToString("x"));
                                }
                            }
                        }
                        catch
                        {
                            continue;
                        }

SKIPMOD:
                        continue;
                    }
                    this.writeBulkToConsoleEnd();

                    break;

                case "modtxlist":
                    this.checkDB();

                    modid = Util.parseUShort(splitted[1]);

                    Record rec = this.db.tables[Database.TABLE_MODULE].getRecord(modid);
                    if (rec != null)
                    {
                        ModuleRecord modrec = (ModuleRecord)rec;
                        this.writeBulkToConsoleStart();

                        foreach (TXRecord txrec in modrec.dataelements)
                        {
                            string temp = this.db.getTX(txrec.id);
                            this.writeBulkToConsole(temp + "; 0x" + txrec.id.ToString("x"));
                        }

                        this.writeBulkToConsoleEnd();
                    }
                    else
                    {
                        this.writeToConsole("No such module." + Environment.NewLine);
                    }

                    break;
                }
            }
            catch (Exception e)
            {
                this.writeToConsole("Exception: " + e.ToString() + Environment.NewLine);
            }
        }
Exemplo n.º 17
0
 /// <summary>
 /// Sets the cached boolean result.
 /// </summary>
 /// <param name="value">if set to <c>true</c> [value].</param>
 public void SetCachedBooleanResult(bool value)
 {
     _stringRecord = null;
     _formulaRecord.SetCachedResultBoolean(value);
 }
Exemplo n.º 18
0
 /// <summary>
 /// Sets the cached error result.
 /// </summary>
 /// <param name="errorCode">The error code.</param>
 public void SetCachedErrorResult(int errorCode)
 {
     _stringRecord = null;
     _formulaRecord.SetCachedResultErrorCode(errorCode);
 }
Exemplo n.º 19
0
 public void SetCachedDoubleResult(double value)
 {
     _stringRecord        = null;
     _formulaRecord.Value = value;
 }
Exemplo n.º 20
0
 public StringRecord(ref StringRecord rhs)
 {
     this.m_str   = rhs.m_str;
     this.m_image = rhs.m_image;
 }
Exemplo n.º 21
0
        /*
         *
         */
        public override bool _registerData(string gameData)
        {
            String[]     AAs     = gameData.Split('~');
            StringRecord zRecord = null;

            try
            {
                if (!openConnection())
                {
                    return(false);
                }
                String sql = "insert into game_log( gn_code, g_time, g_type, g_code, teamA, teamb,  " +
                             "s0, s1, s2, " +
                             "a0, a1, a2, a4,  	b0, b1, b2, b4)" +
                             "values ( @1,@2,@3,@4,@5,@6,    @7,@8,@9,  @10,@11,@12,@13,		@14,@15,@16,@17)";
                // parameter type = :name, @name, ?
                //  calltype = "name", "@name", param1/2/3, parameters["name"] /parameters["@name"]/ parameters[0/1/2].value
                MySqlCommand cmd = new MySqlCommand(sql, conn);

                cmd.Prepare();

                StringRecord aRecord = null;
                int          gType   = GAME_TYPE;      //constant
                foreach (string s in AAs)
                {
                    if (s.StartsWith("SA"))
                    {
                        //delete recored from super
                    }
                    else if (s.StartsWith("ZA"))                     // game name data
                    {
                        zRecord = null;
                        zRecord = new StringRecord(s);
                        makeGameName(zRecord, gType);
                    }
                    else if (s.StartsWith("AA"))                    // specific game data
                    {
                        aRecord = null;
                        aRecord = new StringRecord(s);
                        makeTeamData(aRecord, gType);                         //Team Data extract

                        // start record
                        int i = 1;
                        mysqlSetParam(cmd, "@" + i++, zRecord.getField("ZC"));
                        mysqlSetParam(cmd, "@" + i++, aRecord.getField("AD"));
                        mysqlSetParam(cmd, "@" + i++, gType);

                        mysqlSetParam(cmd, "@" + i++, aRecord.getField("AA"));
                        mysqlSetParam(cmd, "@" + i++, aRecord.getField("AE"));
                        mysqlSetParam(cmd, "@" + i++, aRecord.getField("AF"));

                        mysqlSetParam(cmd, "@" + i++, aRecord.getField("AB"));
                        mysqlSetParam(cmd, "@" + i++, aRecord.getField("AC"));
                        mysqlSetParam(cmd, "@" + i++, aRecord.getField("AO"));

                        mysqlSetParam(cmd, "@" + i++, aRecord.getField("AG"));
                        mysqlSetParam(cmd, "@" + i++, aRecord.getField("BA"));
                        mysqlSetParam(cmd, "@" + i++, aRecord.getField("BC"));
                        mysqlSetParam(cmd, "@" + i++, aRecord.getField("AT"));

                        mysqlSetParam(cmd, "@" + i++, aRecord.getField("AH"));
                        mysqlSetParam(cmd, "@" + i++, aRecord.getField("BB"));
                        mysqlSetParam(cmd, "@" + i++, aRecord.getField("BD"));
                        mysqlSetParam(cmd, "@" + i++, aRecord.getField("AU"));
                        cmd.ExecuteNonQuery();
                    }
                }                // endfor
            }
            catch (Exception e) {
                GrabAgent.trace_log(e.StackTrace);
            }
            finally
            {
            }
            return(true);
        }
Exemplo n.º 22
0
 public override void Dispose()
 {
     _formulaRecord = null;
     _sharedValueManager.Dispose();
     _stringRecord = null;
 }
Exemplo n.º 23
0
        public override bool _registerData(string gameData)
        {
            if (gameData == "")
            {
                return(false);
            }
            if (!openConnection())
            {
                return(false);
            }

            try
            {
                String sql = "insert into game_log( gn_code, g_time, g_type, g_code, teamA, teamB,  " +
                             "s0, s1, s2, " +
                             "a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, " +
                             "b0, b1, b2, b3, b4, b5, b6, b7, b8, b9 ," +
                             "updated )" +
                             "values ( @1,@2,@3,@4,@5, @6, " +
                             "@s0, @s1, @s2, " +
                             "@a0, @a1, @a2, @a3, @a4, @a5, @a6, @a7, @a8, @a9, " +
                             "@b0, @b1, @b2, @b3, @b4, @b5, @b6, @b7, @b8, @b9, " +
                             "unix_timestamp() )";
                // parameter type = :name, @name, ?
                //  calltype = "name", "@name", param1/2/3, parameters["name"] /parameters["@name"]/ parameters[0/1/2].value
                MySqlCommand cmd = new MySqlCommand(sql, conn);

                cmd.Prepare();

                StringRecord aRecord  = null;
                int          gType    = 0;
                String[]     AAs      = gameData.Split('~');
                StringRecord zRecord  = null;
                int          typeCode = 0;
                foreach (string s in AAs)
                {
                    if (s.StartsWith("SA"))
                    {
                        aRecord  = new StringRecord(s);
                        typeCode = int.Parse(aRecord.getField("SA"));
                        gType    = typeCode;
                        //gType = getGameType(typeCode);
                    }
                    else if (s.StartsWith("ZA"))                     // game name data
                    {
                        zRecord = null;
                        zRecord = new StringRecord(s);
                        makeGameName(zRecord, gType);
                    }
                    else if (s.StartsWith("AA"))                    // specific game data
                    {
                        aRecord = null;
                        aRecord = new StringRecord(s);
                        int[] teamIds = makeTeamData(aRecord, gType);                         //Team Data extract
                        if (teamIds == null)
                        {
                            continue;
                        }
                        // start record

                        mysqlSetParam(cmd, "@1", zRecord.getField("ZC"));             //gn_code
                        mysqlSetParam(cmd, "@2", aRecord.getField("AD"));             //start_time
                        mysqlSetParam(cmd, "@3", gType);                              //game_type
                        mysqlSetParam(cmd, "@4", aRecord.getField("AA"));             //game_code
                        mysqlSetParam(cmd, "@5", teamIds[0]);                         //teamA :aRecord.getField("AE")
                        mysqlSetParam(cmd, "@6", teamIds[1]);                         //teamB :aRecord.getField("AF")

                        //status code
                        mysqlSetParam(cmd, "@s0", aRecord.getField("AB"));
                        mysqlSetParam(cmd, "@s1", aRecord.getField("AC"));
                        mysqlSetParam(cmd, "@s2", aRecord.getField("AO"));

                        //teamA data
                        mysqlSetParam(cmd, "@a0", aRecord.getField("AG"));
                        mysqlSetParam(cmd, "@a1", aRecord.getField("BA"));
                        mysqlSetParam(cmd, "@a2", aRecord.getField("BC"));
                        mysqlSetParam(cmd, "@a3", aRecord.getField("BE"));
                        mysqlSetParam(cmd, "@a4", aRecord.getField("BG"));
                        mysqlSetParam(cmd, "@a5", aRecord.getField("BI"));
                        mysqlSetParam(cmd, "@a6", aRecord.getField("DA"));
                        mysqlSetParam(cmd, "@a7", aRecord.getField("DC"));
                        mysqlSetParam(cmd, "@a8", aRecord.getField("DE"));
                        mysqlSetParam(cmd, "@a9", aRecord.getField("AT"));

                        //teamB data
                        mysqlSetParam(cmd, "@b0", aRecord.getField("AH"));
                        mysqlSetParam(cmd, "@b1", aRecord.getField("BB"));
                        mysqlSetParam(cmd, "@b2", aRecord.getField("BD"));
                        mysqlSetParam(cmd, "@b3", aRecord.getField("BF"));
                        mysqlSetParam(cmd, "@b4", aRecord.getField("BH"));
                        mysqlSetParam(cmd, "@b5", aRecord.getField("BJ"));
                        mysqlSetParam(cmd, "@b6", aRecord.getField("DB"));
                        mysqlSetParam(cmd, "@b7", aRecord.getField("DD"));
                        mysqlSetParam(cmd, "@b8", aRecord.getField("DF"));
                        mysqlSetParam(cmd, "@b9", aRecord.getField("AU"));

                        try{
                            cmd.ExecuteNonQuery();
                        }catch (Exception e) {}
                    }
                }                // endfor
            }
            catch (Exception e)
            {
                GrabAgent.trace_log(e.StackTrace);
            }
            finally
            {
            }
            return(true);
        }
Exemplo n.º 24
0
 public STREditor(StringRecord str)
 {
     this._record = str;
     this.InitializeComponent();
 }
Exemplo n.º 25
0
            /// <summary>
            /// Process an HSSF Record. Called when a record occurs in an HSSF file.
            /// </summary>
            /// <param name="record"></param>
            public void ProcessRecord(Record record)
            {
                String thisText = null;
                int    thisRow  = -1;

                switch (record.Sid)
                {
                case BoundSheetRecord.sid:
                    BoundSheetRecord sr = (BoundSheetRecord)record;
                    sheetNames.Add(sr.Sheetname);
                    break;

                case BOFRecord.sid:
                    BOFRecord bof = (BOFRecord)record;
                    if (bof.Type == BOFRecordType.Worksheet)
                    {
                        sheetNum++;
                        rowNum = -1;

                        if (includeSheetNames)
                        {
                            if (text.Length > 0)
                            {
                                text.Append("\n");
                            }
                            text.Append(sheetNames[sheetNum]);
                        }
                    }
                    break;

                case SSTRecord.sid:
                    sstRecord = (SSTRecord)record;
                    break;

                case FormulaRecord.sid:
                    FormulaRecord frec = (FormulaRecord)record;
                    thisRow = frec.Row;

                    if (formulasNotResults)
                    {
                        thisText = HSSFFormulaParser.ToFormulaString((HSSFWorkbook)null, frec.ParsedExpression);
                    }
                    else
                    {
                        if (frec.HasCachedResultString)
                        {
                            // Formula result is a string
                            // This is stored in the next record
                            outputNextStringValue = true;
                            nextRow = frec.Row;
                        }
                        else
                        {
                            thisText = FormatNumberDateCell(frec, frec.Value);
                        }
                    }
                    break;

                case StringRecord.sid:
                    if (outputNextStringValue)
                    {
                        // String for formula
                        StringRecord srec = (StringRecord)record;
                        thisText = srec.String;
                        thisRow  = nextRow;
                        outputNextStringValue = false;
                    }
                    break;

                case LabelRecord.sid:
                    LabelRecord lrec = (LabelRecord)record;
                    thisRow  = lrec.Row;
                    thisText = lrec.Value;
                    break;

                case LabelSSTRecord.sid:
                    LabelSSTRecord lsrec = (LabelSSTRecord)record;
                    thisRow = lsrec.Row;
                    if (sstRecord == null)
                    {
                        throw new Exception("No SST record found");
                    }
                    thisText = sstRecord.GetString(lsrec.SSTIndex).ToString();
                    break;

                case NoteRecord.sid:
                    NoteRecord nrec = (NoteRecord)record;
                    thisRow = nrec.Row;
                    // TODO: Find object to match nrec.GetShapeId()
                    break;

                case NumberRecord.sid:
                    NumberRecord numrec = (NumberRecord)record;
                    thisRow  = numrec.Row;
                    thisText = FormatNumberDateCell(numrec, numrec.Value);
                    break;

                default:
                    break;
                }

                if (thisText != null)
                {
                    if (thisRow != rowNum)
                    {
                        rowNum = thisRow;
                        if (text.Length > 0)
                        {
                            text.Append("\n");
                        }
                    }
                    else
                    {
                        text.Append("\t");
                    }
                    text.Append(thisText);
                }
            }
Exemplo n.º 26
0
        public void readRecords()
        {
            int readOffset = (int)this.offset;

            // NOTE: loop unrolled purposely
            switch (this.id)
            {
            case Database.TABLE_STATE_DATA_SPECIFIER:
                for (ushort i = 0; i < this.rowCount; ++i)
                {
                    records[i] = new SDSRecord(this, this.db.dbReader.ReadBytes(ref readOffset, this.rowSize));
                }
                break;

            case Database.TABLE_BINARY_DATA_SPECIFIER:
                for (ushort i = 0; i < this.rowCount; ++i)
                {
                    records[i] = new BDSRecord(this, this.db.dbReader.ReadBytes(ref readOffset, this.rowSize));
                }
                break;

            case Database.TABLE_NUMERIC_DATA_SPECIFIER:
                for (ushort i = 0; i < this.rowCount; ++i)
                {
                    records[i] = new NDSRecord(this, this.db.dbReader.ReadBytes(ref readOffset, this.rowSize));
                }
                break;

            case Database.TABLE_CONVERTERS_STATE:
                for (ushort i = 0; i < this.rowCount; ++i)
                {
                    records[i] = new SCRecord(this, this.db.dbReader.ReadBytes(ref readOffset, this.rowSize));
                }
                break;

            case Database.TABLE_CONVERTERS_NUMERIC:
                for (ushort i = 0; i < this.rowCount; ++i)
                {
                    records[i] = new NCRecord(this, this.db.dbReader.ReadBytes(ref readOffset, this.rowSize));
                }
                break;

            case Database.TABLE_STATE_ENTRY:
                for (ushort i = 0; i < this.rowCount; ++i)
                {
                    records[i] = new StateEntryRecord(this, this.db.dbReader.ReadBytes(ref readOffset, this.rowSize));
                }
                break;

            case Database.TABLE_STRINGS:
                for (ushort i = 0; i < this.rowCount; ++i)
                {
                    records[i] = new StringRecord(this, this.db.dbReader.ReadBytes(ref readOffset, this.rowSize));
                }
                break;

            case Database.TABLE_DATA_ACQUISITION_DESCRIPTION:
                for (ushort i = 0; i < this.rowCount; ++i)
                {
                    records[i] = new DADRecord(this, this.db.dbReader.ReadBytes(ref readOffset, this.rowSize));
                }
                break;

            case Database.TABLE_DES_INFO:
                for (ushort i = 0; i < this.rowCount; ++i)
                {
                    records[i] = new DESRecord(this, this.db.dbReader.ReadBytes(ref readOffset, this.rowSize));
                }
                break;

            case Database.TABLE_SERIVCE_CAT_STUFFS:
                for (ushort i = 0; i < this.rowCount; ++i)
                {
                    records[i] = new ServiceCatRecord(this, this.db.dbReader.ReadBytes(ref readOffset, this.rowSize));
                }
                break;

            case Database.TABLE_TRANSMIT:
                for (ushort i = 0; i < this.rowCount; ++i)
                {
                    records[i] = new TXRecord(this, this.db.dbReader.ReadBytes(ref readOffset, this.rowSize));
                }
                break;

            case Database.TABLE_MODULE_DATAELEMENT:
                for (ushort i = 0; i < this.rowCount; ++i)
                {
                    records[i] = new ModuleDataElemRecord(this, this.db.dbReader.ReadBytes(ref readOffset, this.rowSize));
                }
                break;

            case Database.TABLE_MODULE:
                for (ushort i = 0; i < this.rowCount; ++i)
                {
                    records[i] = new ModuleRecord(this, this.db.dbReader.ReadBytes(ref readOffset, this.rowSize));
                }
                break;

            case Database.TABLE_DRB_MENU:
                for (ushort i = 0; i < this.rowCount; ++i)
                {
                    records[i] = new MenuRecord(this, this.db.dbReader.ReadBytes(ref readOffset, this.rowSize));
                }
                break;

            case Database.TABLE_UNKNOWN_3:
                for (ushort i = 0; i < this.rowCount; ++i)
                {
                    records[i] = new RecordUnknownWithString(this, this.db.dbReader.ReadBytes(ref readOffset, this.rowSize), 2);
                }
                break;

            case Database.TABLE_UNKNOWN_21:
                for (ushort i = 0; i < this.rowCount; ++i)
                {
                    records[i] = new RecordUnknownWithString(this, this.db.dbReader.ReadBytes(ref readOffset, this.rowSize), 3);
                }
                break;

            default:
                for (ushort i = 0; i < this.rowCount; ++i)
                {
                    records[i] = new Record(this, this.db.dbReader.ReadBytes(ref readOffset, this.rowSize));
                }
                break;
            }
        }
Exemplo n.º 27
0
        public override bool _updateData(string gameData)
        {
            if (gameData == "" || gameData == null)
            {
                GrabAgent.trace_log("No data.");
                return(false);
            }

            if (!openConnection())
            {
                return(false);
            }

            String       sqlRetrieve = "select * from game_log g where g_code=@c1 and g_type=@c2";
            MySqlCommand cmdRetrieve = new MySqlCommand(sqlRetrieve, conn);

            cmdRetrieve.Prepare();

            String sqlUpdate = "update game_log set s0=@s0, s1=@s1, s2=@s2, " +
                               " a0=@a0, a1=@a1, a2=@a2, a3=@a3, a4=@a4, a5=@a5, a6=@a6, a7=@a7, a8=@a8, a9=@a9, " +
                               " b0=@b0, b1=@b1, b2=@b2, b3=@b3, b4=@b4, b5=@b5, b6 =@b6, b7=@b7, b8=@b8, b9=@b9, " +
                               " updated = unix_timestamp() " +
                               " where  1=1 and g_code=@c1  and g_type=@c2";
            MySqlCommand cmdUpdate = new MySqlCommand(sqlUpdate, conn);

            cmdUpdate.CommandTimeout = 2000;

            cmdUpdate.Prepare();


            try
            {
                StringRecord aRecord = null;
                string       sg_type = "";
                String[]     AAs     = gameData.Split('~');
                StringRecord zRecord = null;

                MySqlDataAdapter da = new MySqlDataAdapter(cmdRetrieve);
                DataTable        dt = new DataTable();
                DataRow          dr;
                int typeCode = 0;

                foreach (string s in AAs)
                {
                    aRecord = new StringRecord(s);

                    if (s.StartsWith("SA"))
                    {
                        typeCode = int.Parse(aRecord.getField("SA"));

                        sg_type = getGameType(typeCode);
                    }
                    else if (s.StartsWith("ZA"))
                    {
                        //no such case
                    }
                    else if (s.StartsWith("AA"))
                    {
                        if (sg_type == "")
                        {
                            continue;                                        //unregistered game
                        }
                        try
                        {
                            //retrieve exisiting data
                            mysqlSetParam(cmdRetrieve, "@c1", aRecord.getField("AA"));
                            mysqlSetParam(cmdRetrieve, "@c2", typeCode);

                            dt.Clear();
                            da.Fill(dt);
                            dr = dt.Rows[0];

                            // update operation
//							mysqlSetParam(cmdUpdate, "@s0", aRecord.getField("AB") ?? dr["s0"]); //equivalent as bellow

                            //status data
                            mysqlSetParam(cmdUpdate, "@s0", gmv(aRecord, "AB", dr, "s0"));
                            mysqlSetParam(cmdUpdate, "@s1", gmv(aRecord, "AC", dr, "s1"));
                            mysqlSetParam(cmdUpdate, "@s2", gmv(aRecord, "AO", dr, "s2"));

                            //teamA data
                            mysqlSetParam(cmdUpdate, "@a0", gmv(aRecord, "AG", dr, "a0"));
                            mysqlSetParam(cmdUpdate, "@a1", gmv(aRecord, "BA", dr, "a1"));
                            mysqlSetParam(cmdUpdate, "@a2", gmv(aRecord, "BC", dr, "a2"));
                            mysqlSetParam(cmdUpdate, "@a3", gmv(aRecord, "BE", dr, "a3"));
                            mysqlSetParam(cmdUpdate, "@a4", gmv(aRecord, "BG", dr, "a4"));
                            mysqlSetParam(cmdUpdate, "@a5", gmv(aRecord, "BI", dr, "a5"));
                            mysqlSetParam(cmdUpdate, "@a6", gmv(aRecord, "DA", dr, "a6"));
                            mysqlSetParam(cmdUpdate, "@a7", gmv(aRecord, "DC", dr, "a7"));
                            mysqlSetParam(cmdUpdate, "@a8", gmv(aRecord, "DE", dr, "a8"));
                            mysqlSetParam(cmdUpdate, "@a9", gmv(aRecord, "AT", dr, "a9"));

                            //teamB data
                            mysqlSetParam(cmdUpdate, "@b0", gmv(aRecord, "AH", dr, "b0"));
                            mysqlSetParam(cmdUpdate, "@b1", gmv(aRecord, "BB", dr, "b1"));
                            mysqlSetParam(cmdUpdate, "@b2", gmv(aRecord, "BD", dr, "b2"));
                            mysqlSetParam(cmdUpdate, "@b3", gmv(aRecord, "BF", dr, "b3"));
                            mysqlSetParam(cmdUpdate, "@b4", gmv(aRecord, "BH", dr, "b4"));
                            mysqlSetParam(cmdUpdate, "@b5", gmv(aRecord, "BJ", dr, "b5"));
                            mysqlSetParam(cmdUpdate, "@b6", gmv(aRecord, "DB", dr, "b6"));
                            mysqlSetParam(cmdUpdate, "@b7", gmv(aRecord, "DD", dr, "b7"));
                            mysqlSetParam(cmdUpdate, "@b8", gmv(aRecord, "DF", dr, "b8"));
                            mysqlSetParam(cmdUpdate, "@b9", gmv(aRecord, "AU", dr, "b9"));

                            //game code
                            string ss = aRecord.getField("AA");
                            mysqlSetParam(cmdUpdate, "@c1", ss);
                            mysqlSetParam(cmdUpdate, "@c2", typeCode);
                            int rows = cmdUpdate.ExecuteNonQuery();
                            if (rows > 1)
                            {
                                //System.Windows.Forms.MessageBox.Show(rows + " rows updated. It's strange!!!!!!\r\n" + "G_CODE=" + ss + "G_TYPE=" + sg_type);//???
                            }
                        }
                        catch (IndexOutOfRangeException ie)
                        {
                            //String rd = SiteHelper.getSiteData(urlRetrieveAll);
                            //_registerData(rd);???
                        }
                        catch (Exception e) {
                            GrabAgent.trace_err(e.Message);
                        }
                    }
                }

                GrabAgent.trace_log("Data updated.");
            }
            catch (Exception e)
            {
                GrabAgent.trace_log(e.Message);
            }
            return(true);
        }