Пример #1
0
        public Stats getStats()
        {
            Stats          stats   = new Stats();
            List <LogStat> logList = new List <LogStat>();
            DatabaseStat   ds      = null;

            string sendCommand;

            sendCommand = "http://" + conn.Server + "/" + "SQLLogger/getStats" + "?token=" + token;

            JObject results = Utils.GetHTTP(sendCommand);
            JArray  rowList;
            // this can be a string or null
            string status = (string)results["status"];

            if (status.Equals("200"))
            {
                // this can be a string or array, how can we tell which it is
                JToken dbStats = results["Stats"];

                ds = new DatabaseStat((double)dbStats["DBSize"], (int)dbStats["TableRows"], (double)dbStats["TableSize"], (string)results["version"], (string)dbStats["DBType"]);

                // this can be a string or array, how can we tell which it is
                JToken rows = results["Rows"];

                if (rows is JArray)
                {
                    // can pick one, or flatten array to a string
                    rowList = (JArray)rows;
                    foreach (var row in rowList)
                    {
                        LogStat ll = new LogStat((int)row["Count"], (int)row["Year"], (int)row["Month"]);
                        logList.Add(ll);
                    }
                }
            }
            else
            {
                MessageBox.Show("SQL Log database not correctly setup.\r\nDo you have UseSqlLogs set to true?", "Remote Log Maintenance", MessageBoxButtons.OK, MessageBoxIcon.Error);
                if (System.Windows.Forms.Application.MessageLoop)
                {
                    // WinForms app
                    System.Windows.Forms.Application.Exit();
                }
                else
                {
                    // Console app
                    System.Environment.Exit(1);
                }
            }
            stats.DBStats  = ds;
            stats.LogStats = logList;

            return(stats);
        }
Пример #2
0
 public Stats(DatabaseStat dbStats, List <LogStat> logStats)
 {
     DBStats  = dbStats;
     LogStats = logStats;
 }