Beispiel #1
0
 public static void CreateDbFile(string fileName)
 {
     if (!File.Exists(fileName))
     {
         SqliteDB.CreateDbFile(fileName);
     }
 }
Beispiel #2
0
        private void TakeAndPostData(bool initPost = false)
        {
            string       json;
            string       serverIP     = ConfigurationManager.AppSettings["ServerIP"];
            string       customerName = ConfigurationManager.AppSettings["CustomerName"];
            ClientOutput output       = new ClientOutput(getPCName(), getMACAddress(), customerName);

            PluginOutputCollection plugOutput = new PluginOutputCollection();

            json = string.Empty;
            output.CollectionList.Clear();

            if (!initPost)
            {
                foreach (var plugin in _plugins.PluginList)
                {
                    plugOutput = plugin.Output();
                    if (plugOutput != null)
                    {
                        output.CollectionList.Add(plugOutput);
                    }
                }
            }
            else
            {
                output.InitPost = true;
            }

            if (!SendPluginOutput(output))
            {
                SaveOutputToDB(JsonConvert.SerializeObject(output));
                return;
            }

            try
            {
                Dictionary <int, string> dbValues = new Dictionary <int, string>();
                dbValues = SqliteDB.GetStoredJson(_dbName);
                foreach (var item in dbValues)
                {
                    ClientOutput clientOutputDB = JsonConvert.DeserializeObject <ClientOutput>(item.Value);
                    if (SendPluginOutput(output))
                    {
                        SqliteDB.UpdateStatus(_dbName, item.Key);
                    }
                }
            }
            catch (Exception err)
            {
                _log.Error("Read stored values from database", err);
                return;
            }
        }
Beispiel #3
0
        private void SaveOutputToDB(string json)
        {
            SqliteDB.InsertToDb(_dbName, json);

            _log.Warn("Server unreachable, writing into local db");
        }
Beispiel #4
0
 private void CreateDataBaseAndTable()
 {
     SqliteDB.CreateDbFile(_dbName);
     SqliteDB.CreateTable(_dbName);
 }