Esempio n. 1
0
        private MemoryStream CreatePlayerCountImageOneMonth(GameServer server, out string fileName)
        {
            LordControl.PlayerCountStatisticInfo[] _infoArray = null;
            DateTime _endTime = DateTime.Now;
            DateTime _startTime = _endTime.AddMonths(-1);

            _infoArray = server.GetPlugInData(0, LordControl.PlugInGuid, LordControl.DataKeyPlayerCountStatistic, _startTime, _endTime) as LordControl.PlayerCountStatisticInfo[];

            if (_infoArray.Length != 0)
            {
                ArrayList playerCountArrayList = new ArrayList();

                LordControl.PlayerCountStatisticInfo tempInfo = new LordControl.PlayerCountStatisticInfo();
                tempInfo.Time = _infoArray[0].Time;

                int countInOneDay = 0;

                for (int i = 0; i < _infoArray.Length; i++)
                {
                    LordControl.PlayerCountStatisticInfo info = _infoArray[i];

                    if (tempInfo.Time.Date == info.Time.Date)
                    {
                        if (info.MaxCount > tempInfo.MaxCount)
                            tempInfo.MaxCount = info.MaxCount;
                        if (info.MinCount < tempInfo.MinCount)
                            tempInfo.MinCount = info.MinCount;
                        tempInfo.AverageCount += info.AverageCount;
                        countInOneDay++;

                        if (i == _infoArray.Length - 1)
                        {
                            tempInfo.AverageCount /= countInOneDay;
                            playerCountArrayList.Add(tempInfo);
                        }
                    }
                    else
                    {
                        tempInfo.AverageCount /= countInOneDay;

                        playerCountArrayList.Add(tempInfo);

                        tempInfo = new LordControl.PlayerCountStatisticInfo();

                        tempInfo.Time = info.Time;
                        tempInfo.AverageCount = info.AverageCount;
                        tempInfo.MaxCount = info.MaxCount;
                        tempInfo.MinCount = info.MinCount;

                        countInOneDay = 1;

                        if (i == _infoArray.Length - 1)
                        {
                            playerCountArrayList.Add(tempInfo);
                        }
                    }
                }

                double[] maxCountArray = new double[playerCountArrayList.Count];
                double[] minCountArray = new double[playerCountArrayList.Count];
                double[] averageCountArray = new double[playerCountArrayList.Count];
                double[] timeArray = new double[playerCountArrayList.Count];

                for (int i = 0; i < playerCountArrayList.Count; i++)
                {
                    LordControl.PlayerCountStatisticInfo info = playerCountArrayList[i] as LordControl.PlayerCountStatisticInfo;
                    maxCountArray[i] = info.MaxCount;
                    minCountArray[i] = info.MinCount;
                    averageCountArray[i] = info.AverageCount;
                    timeArray[i] = new XDate(info.Time);
                }

                GraphPane graphPane = new GraphPane(new Rectangle(0, 0, 840, 450), String.Empty, String.Empty, String.Empty);

                graphPane.Fill = new Fill(Color.FromArgb(212, 208, 200));

                graphPane.Legend.Fill.IsVisible = false;
                graphPane.Legend.Border.IsVisible = false;
                graphPane.Legend.FontSpec.Fill.IsVisible = false;

                graphPane.XAxis.Title.Text = "时间";
                graphPane.XAxis.MajorGrid.Color = Color.DarkGreen;
                graphPane.XAxis.Type = AxisType.Date;
                graphPane.XAxis.Scale.FontSpec.Size = 11;

                graphPane.YAxis.Title.Text = "玩家数量";
                //graphPane.YAxis.MajorGrid.IsVisible = true;
                //graphPane.YAxis.MajorGrid.DashOff = 0;
                //graphPane.YAxis.MajorGrid.Color = Color.Gray;
                //graphPane.YAxis.MinorGrid.IsVisible = true;
                //graphPane.YAxis.MinorGrid.Color = Color.LightGray;
                //graphPane.YAxis.MinorGrid.DashOff = 0;
                graphPane.YAxis.Scale.Min = 0;

                graphPane.Title.Text = string.Format("{0} [ {1}  {2} ]", "玩家数量", _startTime, _endTime);

                graphPane.AddCurve("最大", timeArray, maxCountArray, Color.Red, SymbolType.Triangle);
                graphPane.AddCurve("最小", timeArray, minCountArray, Color.Green, SymbolType.TriangleDown);
                graphPane.AddCurve("平均", timeArray, averageCountArray, Color.Orange, SymbolType.Diamond);

                graphPane.AxisChange();

                fileName = server.Group.Name + "-" + DateTime.Now.Date.ToString("yyyy-MM-dd") + "-(Month)" + ".jpg";

                MemoryStream imageMemoryStream = new MemoryStream();
                graphPane.GetImage().Save(imageMemoryStream, System.Drawing.Imaging.ImageFormat.Jpeg);
                imageMemoryStream.Position = 0;

                return imageMemoryStream;
            }
            else
            {
                fileName = String.Empty;
                return null;
            }
        }
Esempio n. 2
0
        private string GetPlayerCountTextOneMonthOneServer(GameServer server)
        {
            LordControl.PlayerCountStatisticInfo[] _infoArray = null;
            DateTime _endTime = DateTime.Now;
            DateTime _startTime = _endTime.AddMonths(-1);

            string contentString = String.Empty;

            _infoArray = server.GetPlugInData(0, LordControl.PlugInGuid, LordControl.DataKeyPlayerCountStatistic, _startTime, _endTime) as LordControl.PlayerCountStatisticInfo[];

            ArrayList playerCountArrayList = new ArrayList();

            if (_infoArray.Length != 0)
            {
                LordControl.PlayerCountStatisticInfo tempInfo = new LordControl.PlayerCountStatisticInfo();
                tempInfo.Time = _infoArray[0].Time;

                int countInOneDay = 0;

                for (int i = 0; i < _infoArray.Length; i++)
                {
                    LordControl.PlayerCountStatisticInfo info = _infoArray[i];

                    if (tempInfo.Time.Date == info.Time.Date)
                    {
                        if (info.MaxCount > tempInfo.MaxCount)
                            tempInfo.MaxCount = info.MaxCount;
                        if (info.MinCount < tempInfo.MinCount)
                            tempInfo.MinCount = info.MinCount;
                        tempInfo.AverageCount += info.AverageCount;
                        countInOneDay++;

                        if (i == _infoArray.Length - 1)
                        {
                            tempInfo.AverageCount /= countInOneDay;
                            playerCountArrayList.Add(tempInfo);
                        }
                    }
                    else
                    {
                        tempInfo.AverageCount /= countInOneDay;

                        playerCountArrayList.Add(tempInfo);

                        tempInfo = new LordControl.PlayerCountStatisticInfo();

                        tempInfo.Time = info.Time;
                        tempInfo.AverageCount = info.AverageCount;
                        tempInfo.MaxCount = info.MaxCount;
                        tempInfo.MinCount = info.MinCount;

                        countInOneDay = 1;

                        if (i == _infoArray.Length - 1)
                        {
                            playerCountArrayList.Add(tempInfo);
                        }
                    }
                }

                string groupName = server.Group.Name;
                contentString += "<div style=\"font-family:Arial\">" + groupName + "</div>";

                contentString += "<table>";

                string timeString = "<tr><td>时间</td>";
                string maxString = "<tr><td>最大</td>";
                string aveString = "<tr><td>平均</td>";
                string minString = "<tr><td>最小</td>";

                foreach (LordControl.PlayerCountStatisticInfo info in playerCountArrayList)
                {
                    timeString += "<td>" + info.Time.ToString("MM-dd") + "</td>";
                    maxString += "<td>" + info.MaxCount.ToString() + "</td>";
                    aveString += "<td>" + info.AverageCount.ToString() + "</td>";
                    minString += "<td>" + info.MinCount.ToString() + "</td>";
                }

                timeString += "</tr>";
                maxString += "</tr>";
                aveString += "</tr>";
                minString += "</tr>";

                contentString += timeString;
                contentString += maxString;
                contentString += aveString;
                contentString += minString;

                contentString += "</table>";

                contentString += "<br />";
            }

            return contentString;
        }