Beispiel #1
0
        public Hashtable ProcessModel(Hashtable pParams)
        {
            SqliteConnection dbConn = (SqliteConnection)pParams["DatabaseConnection"];


            List <ClientVersionData> clidata    = new List <ClientVersionData>();
            List <ClientVersionData> cliRegData = new List <ClientVersionData>();
            Hashtable regionTotals = new Hashtable();

            Hashtable modeldata = new Hashtable();

            modeldata.Add("Scenes", pParams["Scenes"]);
            modeldata.Add("Reports", pParams["Reports"]);
            int totalclients = 0;
            int totalregions = 0;

            lock (dbConn)
            {
                string sql = "select count(distinct region_id) as regcnt from stats_session_data";

                SqliteCommand    cmd = new SqliteCommand(sql, dbConn);
                SqliteDataReader sdr = cmd.ExecuteReader();
                if (sdr.HasRows)
                {
                    sdr.Read();
                    totalregions = Convert.ToInt32(sdr["regcnt"]);
                }
                sdr.Close();
                cmd.Dispose();

                sql =
                    "select client_version, count(*) as cnt, avg(avg_sim_fps) as simfps from stats_session_data group by client_version order by count(*) desc LIMIT 10;";

                cmd = new SqliteCommand(sql, dbConn);
                sdr = cmd.ExecuteReader();
                if (sdr.HasRows)
                {
                    while (sdr.Read())
                    {
                        ClientVersionData udata = new ClientVersionData();
                        udata.version = sdr["client_version"].ToString();
                        udata.count   = Convert.ToInt32(sdr["cnt"]);
                        udata.fps     = Convert.ToSingle(sdr["simfps"]);
                        clidata.Add(udata);
                        totalclients += udata.count;
                    }
                }
                sdr.Close();
                cmd.Dispose();

                if (totalregions > 1)
                {
                    sql =
                        "select region_id, client_version, count(*) as cnt, avg(avg_sim_fps) as simfps from stats_session_data group by region_id, client_version order by region_id, count(*) desc;";
                    cmd = new SqliteCommand(sql, dbConn);

                    sdr = cmd.ExecuteReader();

                    if (sdr.HasRows)
                    {
                        while (sdr.Read())
                        {
                            ClientVersionData udata = new ClientVersionData();
                            udata.version   = sdr["client_version"].ToString();
                            udata.count     = Convert.ToInt32(sdr["cnt"]);
                            udata.fps       = Convert.ToSingle(sdr["simfps"]);
                            udata.region_id = UUID.Parse(sdr["region_id"].ToString());
                            cliRegData.Add(udata);
                        }
                    }
                    sdr.Close();
                    cmd.Dispose();
                }
            }

            foreach (ClientVersionData cvd in cliRegData)
            {
                if (regionTotals.ContainsKey(cvd.region_id))
                {
                    int regiontotal = (int)regionTotals[cvd.region_id];
                    regiontotal += cvd.count;
                    regionTotals[cvd.region_id] = regiontotal;
                }
                else
                {
                    regionTotals.Add(cvd.region_id, cvd.count);
                }
            }

            modeldata["ClientData"]       = clidata;
            modeldata["ClientRegionData"] = cliRegData;
            modeldata["RegionTotals"]     = regionTotals;
            modeldata["Total"]            = totalclients;

            return(modeldata);
        }