Beispiel #1
0
    public List<BookInfo> GetBookListByCommand(string command)
    {
        //the result
        List<BookInfo> res = new List<BookInfo>();

        //init the command
        MySqlCommand dbcmd  = new MySqlCommand( command , connection );

        // execute the command
        // turn the result to the List<BookInfo>
        using(MySqlDataReader reader = dbcmd.ExecuteReader())
        {
            try
            {
                while(reader.Read())
                {
                    BookInfo info = new BookInfo();

                    for ( int i = 0 ; i < reader.FieldCount; ++ i )
                    {
                        info.AddData(i, reader.GetString(i));
                    }

                    res.Add(info);
                }
            }
            catch(Exception e)
            {
                 Debug.LogError(e.Message);
            }
        }

        //Debug.Log("Get " + res.Count + " books in total");

        return res;
    }
Beispiel #2
0
    // this is only called when database is not connected; creates placeholder data for testing only
    List<WhirlwindBeltInfo> OfflinePlaceHolderSearch(int numBelts)
    {
        string[] filenames = WhirlwindItem.GetAllItemFileNames();
        List<WhirlwindBeltInfo> retVal = new List<WhirlwindBeltInfo>();

        Debug.Assert(filenames.Length > 0);

        string[] columns = {"title", "title_subtitle", "name", "pub_date", "pub_place", "note", "scope_content", "history"};

        for (int i = 0; i < numBelts; i++) {
            int amount = (int)UnityEngine.Random.Range(15f, 30f);
            List<BookInfo> b = new List<BookInfo>();
            for (int j = 0; j < amount; j++) {
                BookInfo bi = new BookInfo();
                string fn = "placeholder";
                while (fn.Equals("placeholder")) {
                    fn = filenames[UnityEngine.Random.Range(0, filenames.Length)];
                }

                bi.AddData("file_name", fn);
                for (int c = 0; c < columns.Length; c++) {
                    bi.AddData(columns[c], "PLACEHOLDER");
                }
                b.Add(bi);
            }
            retVal.Add(new WhirlwindBeltInfo(b, "PLACEHOLDER " + i));
        }

        return retVal;
    }