Пример #1
0
        public static void httpPostMatchMetric(MatchStat m)
        {
            MWA.Models.MwoAMatchMetric matchtopush = new MWA.Models.MwoAMatchMetric();
            matchtopush.assists            = m.assists;
            matchtopush.damage             = m.damage;
            matchtopush.kills              = m.kills;
            matchtopush.lance              = m.lance;
            matchtopush.level              = m.level;
            matchtopush.matchType          = m.matchType;
            matchtopush.matchscore         = m.matchscore;
            matchtopush.mech               = m.mech;
            matchtopush.name               = m.name;
            matchtopush.ping               = m.ping;
            matchtopush.status             = m.status;
            matchtopush.team               = m.team;
            matchtopush.victory            = m.victory;
            matchtopush.victoryType        = m.victoryType;
            matchtopush.time               = m.time.ToUniversalTime().ToString();
            matchtopush.AssociationId      = 0;
            matchtopush.AssociationName    = associationName;
            matchtopush.MatchHash          = matchHash;
            matchtopush.PublishFlag        = 1;
            matchtopush.PublishingUserName = (playerNameSet) ? (((playerName == null | playerName == "") ? "UNKNOWN" : playerName) == m.name) : false;
            string    api = GetApiUrl("MatchDrop/1");
            MatchDrop md;

            matchDrop             = (MatchDrop)HttpUtility.MakeRequest(api, null, null, null, typeof(MatchDrop));
            matchtopush.MatchDrop = matchDrop;
            api = GetApiUrl("MwoAMatchMetric");

            HttpUtility.MakeRequest(api, matchtopush, null, null, typeof(HttpResponseMessage));
        }
Пример #2
0
        static string GetMatchHash()
        {
            string    MatchMechs = String.Empty;
            int       DMG        = 0;
            MatchStat m          = new MatchStat();
            bool      isFirst    = true;

            foreach (MatchStat lm in friendlyList.OrderBy(o => o).ToList())
            {
                if (isFirst)
                {
                    m       = lm;
                    isFirst = false;
                }
                MatchMechs = MatchMechs + lm.mech + ".";
                DMG       += lm.damage;
            }
            MatchMechs = MatchMechs + "-";
            foreach (MatchStat lm in enemyList.OrderBy(o => o).ToList())
            {
                MatchMechs = MatchMechs + lm.mech + ".";
                DMG       += lm.damage;
            }
            return(String.Format("{0}~{1}~{2}~{3}~{4}", m.time.ToUniversalTime().Year, m.time.ToUniversalTime().DayOfYear, MatchMechs, m.level, DMG).Replace(" ", "_"));
        }
Пример #3
0
        static void LogCSV()
        {
            StringBuilder csv = new StringBuilder();

            if (!File.Exists("player.csv"))
            {
                csv.AppendLine(PlayerStat.GetFieldNames());
            }
            csv.AppendLine(playerStat.ToString());
            File.AppendAllText("player.csv", csv.ToString());

            csv.Clear();
            if (!File.Exists("match.csv"))
            {
                csv.AppendLine(MatchStat.GetFieldNames());
            }
            foreach (MatchStat m in friendlyList)
            {
                httpPostMatchMetricTest(m);
                csv.AppendLine(m.ToString());
            }

            foreach (MatchStat m in enemyList)
            {
                httpPostMatchMetricTest(m);
                csv.AppendLine(m.ToString());
            }

            File.AppendAllText("match.csv", csv.ToString());
        }
Пример #4
0
        static void LogCSV()
        {
            string exePath       = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            string playerCsvPath = Path.Combine(exePath, "player.csv");
            string matchCsvPath  = Path.Combine(exePath, "match.csv");

            StringBuilder csv = new StringBuilder();

            if (!File.Exists(playerCsvPath))
            {
                csv.AppendLine(PlayerStat.GetFieldNames());
            }
            csv.AppendLine(playerStat.ToString());
            File.AppendAllText(playerCsvPath, csv.ToString());
            csv.Clear();
            if (!File.Exists(matchCsvPath))
            {
                csv.AppendLine(MatchStat.GetFieldNames());
            }
            foreach (MatchStat m in friendlyList)
            {
                csv.AppendLine(m.ToString());
            }
            foreach (MatchStat m in enemyList)
            {
                csv.AppendLine(m.ToString());
            }
            File.AppendAllText(matchCsvPath, csv.ToString());
        }
Пример #5
0
        public static void httpPostMatchMetricTest(MatchStat m)
        {
            MwoA.Models.MwoAMatchMetric matchtopush = new MwoA.Models.MwoAMatchMetric();
            matchtopush.assists            = m.assists;
            matchtopush.damage             = m.damage;
            matchtopush.kills              = m.kills;
            matchtopush.lance              = m.lance;
            matchtopush.level              = m.level;
            matchtopush.matchType          = m.matchType;
            matchtopush.matchscore         = m.matchscore;
            matchtopush.mech               = m.mech;
            matchtopush.name               = m.name;
            matchtopush.ping               = m.ping;
            matchtopush.status             = m.status;
            matchtopush.team               = m.team;
            matchtopush.victory            = m.victory;
            matchtopush.victoryType        = m.victoryType;
            matchtopush.time               = m.time.ToUniversalTime().ToString();
            matchtopush.AssociationId      = 0;
            matchtopush.AssociationName    = "PUG";
            matchtopush.MatchHash          = GetMatchHash(m);
            matchtopush.PublishFlag        = 1;
            matchtopush.PublishingUserName = (playerNameSet)?(playerName == m.name):false;



            HttpUtility.MakeRequest("http://localhost/MwoArena/api/MwoAMatchMetric", matchtopush, null,
                                    null, typeof(HttpResponseMessage));
        }
Пример #6
0
        public static void HandleRoundResultFriendly(byte[] message)
        {
            string s = ASCIIEncoding.ASCII.GetString(message);

            MatchStat m = new MatchStat();

            m.team = "friendly";
            m.HandleMatchStat(s);
            lock (friendlyList)
            {
                friendlyList.Add(m);
            }
        }
Пример #7
0
        static void LogCSV()
        {
            string exePath       = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            string playerCsvPath = Path.Combine(exePath, "player.csv");
            string matchCsvPath  = Path.Combine(exePath, "match.csv");

            apiUrl          = (System.Configuration.ConfigurationManager.AppSettings["ApiUrl"] == "" || System.Configuration.ConfigurationManager.AppSettings["ApiUrl"] == null) ? "http://mwarena.azurewebsites.net/api/" : System.Configuration.ConfigurationManager.AppSettings["ApiUrl"];
            associationName = (System.Configuration.ConfigurationManager.AppSettings["AssociationName"] == "" || System.Configuration.ConfigurationManager.AppSettings["AssociationName"] == null) ? "PUG" : System.Configuration.ConfigurationManager.AppSettings["AssociationName"];

            StringBuilder csv = new StringBuilder();

            if (!File.Exists(playerCsvPath))
            {
                csv.AppendLine(PlayerStat.GetFieldNames());
            }
            csv.AppendLine(playerStat.ToString());
            File.AppendAllText(playerCsvPath, csv.ToString());
            csv.Clear();
            if (!File.Exists(matchCsvPath))
            {
                csv.AppendLine(MatchStat.GetFieldNames());
            }


            foreach (MatchStat m in friendlyList)
            {
                //  httpPostMatchMetric(m);
                csv.AppendLine(m.ToString());
            }

            foreach (MatchStat m in enemyList)
            {
                //    httpPostMatchMetric(m);
                csv.AppendLine(m.ToString());
            }

            File.AppendAllText(matchCsvPath, csv.ToString());

            LoggedMatch lm = new LoggedMatch();

            lm.MatchHash          = "";//GetMatchHash();
            lm.FriendlyMatchStats = friendlyList;
            lm.EnemyMatchStats    = enemyList;
            lm.AssociationName    = associationName;
            lm.PublishingUserName = (playerNameSet) ? ((playerName == null | playerName == "") ? "UNKNOWN" : playerName) : "UNKNOWN";

            //MatchCompletedPublisher.Publish(lm);
            httpPostLoggedMatch(lm);
        }
Пример #8
0
        public static void HandleRoundResultFriendly(byte[] message)
        {
            string s = ASCIIEncoding.ASCII.GetString(message);

#if DEBUG
            Log(string.Format("[FRIENDLY TEAM]:{0}\r\n", s));
#endif
            MatchStat m = new MatchStat();
            m.team = "friendly";
            m.HandleMatchStat(s);
            lock (friendlyList)
            {
                friendlyList.Add(m);
            }
        }
Пример #9
0
        public static void HandleRoundResultEnemy(byte[] message)
        {
            string s = ASCIIEncoding.ASCII.GetString(message);

#if DEBUG
            Log(string.Format("[ENEMY TEAM]:{0}\r\n", s));
#endif
            MatchStat m = new MatchStat();
            m.team = "enemy";
            m.HandleMatchStat(s);
            lock (enemyList)
            {
                enemyList.Add(m);
            }
        }
Пример #10
0
        static void LogCSV()
        {
            string exePath       = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            string playerCsvPath = Path.Combine(exePath, "player.csv");
            string matchCsvPath  = Path.Combine(exePath, "match.csv");

            StringBuilder csv = new StringBuilder();

            if (!File.Exists(playerCsvPath))
            {
                csv.AppendLine(PlayerStat.GetFieldNames());
            }
            csv.AppendLine(playerStat.ToString());
            File.AppendAllText(playerCsvPath, csv.ToString());
            csv.Clear();
            if (!File.Exists(matchCsvPath))
            {
                csv.AppendLine(MatchStat.GetFieldNames());
            }
            foreach (MatchStat m in friendlyList)
            {
                csv.AppendLine(m.ToString());
            }
            foreach (MatchStat m in enemyList)
            {
                csv.AppendLine(m.ToString());
            }
            File.AppendAllText(matchCsvPath, csv.ToString());
            LoggedMatch lm = new LoggedMatch
            {
                MatchHash          = "",
                FriendlyMatchStats = friendlyList,
                EnemyMatchStats    = enemyList,
                AssociationName    = "PUG",
                PublishingUserName =
                    (playerNameSet)
                        ? ((playerName == null | playerName == "")
                            ? "UNKNOWN"
                            : playerName)
                        : "UNKNOWN"
            };

            httpPostLoggedMatch(lm);
        }
Пример #11
0
 public static string GetMatchHash(MatchStat m)
 {
     return(String.Format("{0}~{1}~{2}~{3}~{4}~{5}~{6}~{7}", m.time.ToUniversalTime().Year, m.time.ToUniversalTime().DayOfYear, m.name, m.mech, m.status, m.level, m.matchscore, m.damage).Replace(" ", "_"));
 }