Ejemplo n.º 1
0
        private void PushActualData(JsonReader reader)
        {
            try
            {
                var streaming = new DataKeepersDbConnector();
                var local     = new DataKeepersDbConnector();
                streaming.ConnectToStreamingStorage();
                local.ConnectToLocalStorage();

                var reading     = false;
                var objectLevel = 0;

                while (reader.Read())
                {
                    switch (reader.TokenType)
                    {
                    case JsonToken.StartObject:
                        objectLevel++;
                        if (reading && objectLevel > 1)
                        {
                            objectLevel--;
                            var itemSignature = ReadItemValues(reader);
                            var query         = CreateIntestItemQuery(itemSignature);
                            streaming.Query(query);
                            local.Query(query);
                        }
                        break;

                    case JsonToken.EndObject:
                        objectLevel--;
                        break;

                    case JsonToken.StartArray:
                        if (objectLevel > 0)
                        {
                            reading = true;
                        }
                        break;

                    case JsonToken.EndArray:
                        if (objectLevel == 1)
                        {
                            reading = false;
                        }
                        break;
                    }
                }

                streaming.Close();
                local.Close();
                Debug.Log("Current data pushed successfully!");
            }
            catch (Exception e)
            {
                Debug.LogError("Error when pushing data do db: " + e.Message);
            }
        }
Ejemplo n.º 2
0
        private void RewriteActualDataSignatures(List <Dictionary <string, string> > keepers, List <Dictionary <string, string> > items)
        {
            try
            {
                DataKeepersDbConnector streaming = new DataKeepersDbConnector();
                DataKeepersDbConnector local     = new DataKeepersDbConnector();
                local.ConnectToLocalStorage();
                local.DropTableIfExists(typeof(KeeperSignature).Name);
                local.CreateTable <KeeperSignature>();
                streaming.ConnectToStreamingStorage();
                streaming.DropTableIfExists(typeof(KeeperSignature).Name);
                streaming.CreateTable <KeeperSignature>();
                // generate sql
                foreach (var keeper in keepers)
                {
                    var kSignature = new KeeperSignature
                    {
                        KeeperName = keeper["Type"],
                        ItemType   = keeper["Items"]
                    };
                    local.Insert(kSignature);
                    streaming.Insert(kSignature);
                }

                foreach (var item in items)
                {
                    local.DropTableIfExists(item["Type"]);
                    streaming.DropTableIfExists(item["Type"]);
                    var query = GenerateCreateTableQueryFromSignature(item);
//                    Debug.Log(query);
                    if (!local.Query(query))
                    {
                        Debug.Log("Error when executing creating of table " + item["Type"]);
                    }
                    if (!streaming.Query(query))
                    {
                        Debug.Log("Error when executing creating of table " + item["Type"]);
                    }
                }
                local.Close();
                streaming.Close();
                Debug.Log("Current signatures rewrited successfully!");
            }
            catch (Exception e)
            {
                Debug.LogError("Signature rewriting error: " + e.Message);
            }
        }
Ejemplo n.º 3
0
 public List <KeeperVersion> GetVersions()
 {
     return(_dbEditor.Query <KeeperVersion>("SELECT * FROM KeeperVersion"));
 }