/// <summary>
        /// puts statistic data of all pixels into the buffer
        /// </summary>
        internal void CopyToBuffer(ITexture source, GpuBuffer buffer, int layer = -1, int mipmap = 0)
        {
            // copy pixels from the source image into a texture from the texture cache
            var dev = Device.Get();

            if (source.Is3D)
            {
                dev.Compute.Set(shader3d.Compute);
            }
            else
            {
                dev.Compute.Set(shader.Compute);
            }

            var dim       = source.Size.GetMip(mipmap);
            var numLayers = source.NumLayers;
            var curData   = new StatisticsData
            {
                Level    = mipmap,
                TrueBool = true
            };

            if (layer == -1)
            {
                dev.Compute.SetShaderResource(0, source.View);
            }
            else
            {
                // single layer
                dev.Compute.SetShaderResource(0, source.GetSrView(layer, mipmap));
                curData.Level = 0; // view with single level
                numLayers     = 1;
            }
            cbuffer.SetData(curData);

            // buffer big enough?
            Debug.Assert(buffer.ElementCount >= dim.Product * numLayers);

            dev.Compute.SetUnorderedAccessView(0, buffer.View);
            dev.Compute.SetConstantBuffer(0, cbuffer.Handle);

            dev.Dispatch(Utility.Utility.DivideRoundUp(dim.Width, LocalSizeX),
                         Utility.Utility.DivideRoundUp(dim.Height, LocalSizeY),
                         Math.Max(dim.Depth, numLayers));

            dev.Compute.SetUnorderedAccessView(0, null);
            dev.Compute.SetShaderResource(0, null);
        }
        Paragraph CreateOtherStatisticsParagraph(StatisticsData statisticsData)
        {
            Phrase    titlePhrase = new Phrase("\nOTHER STATISTICS\n\n", bigFont);
            Paragraph otherStatisticsParagraph = new Paragraph();

            otherStatisticsParagraph.Add(titlePhrase);
            float  percentVotingResult = statisticsData.invalidVotesNumber / (float)(statisticsData.validVotesNumber + statisticsData.invalidVotesNumber) * 100;
            Phrase invalidVotes        = new Phrase(string.Format("Number of invalid votes {0} ({1:0.00}%)\n\n", statisticsData.invalidVotesNumber, percentVotingResult), normalFont);

            otherStatisticsParagraph.Add(invalidVotes);
            Phrase withoutRightsVotes = new Phrase("Number of voting attemps by person deprived of its voting rights: " + statisticsData.withoutRightsVotesNumber + "\n\n", normalFont);

            otherStatisticsParagraph.Add(withoutRightsVotes);

            return(otherStatisticsParagraph);
        }
Beispiel #3
0
        public void Reset()
        {
            if (null == Battle)
            {
                Battle = new BattleData();
            }
            else
            {
                Battle.Reset();
            }

            if (null == Statistics)
            {
                Statistics = new StatisticsData();
            }
        }
        public static void SetSrcDataByDamageInfo(this StatisticsData data, PlayerDamageInfo damage)
        {
            switch (damage.WeaponType)
            {
            case EWeaponSubType.BurnBomb:
            case EWeaponSubType.Grenade:
            case EWeaponSubType.FlashBomb:
            case EWeaponSubType.FogBomb:
            case EWeaponSubType.Throw:
                data.KillWithThrowWeapon += 1;
                break;

            case EWeaponSubType.Hand:
            case EWeaponSubType.Melee:
                data.KillWithMelee += 1;
                break;

            case EWeaponSubType.MachineGun:
                data.KillWithMachineGun += 1;
                break;

            case EWeaponSubType.Pistol:
                data.KillWithPistol += 1;
                break;

            case EWeaponSubType.ShotGun:
                data.KillWithShotGun += 1;
                break;

            case EWeaponSubType.Sniper:
                data.KillWithSniper += 1;
                break;

            case EWeaponSubType.SubMachineGun:
                data.KillWithSubmachineGun += 1;
                break;

            case EWeaponSubType.Rifle:
            case EWeaponSubType.AccurateRifle:
                data.KillWithRifle += 1;
                break;

            default:
                break;
            }
        }
        public void ExportData(string fileName, StatisticsData statisticsData)
        {
            Document   doc    = new Document(PageSize.A4);
            FileStream output = new FileStream(fileName, FileMode.Create);
            PdfWriter  writer = PdfWriter.GetInstance(doc, output);

            //Open document to write
            doc.Open();

            //Adding paragraphs to document
            doc.Add(CreateTitleParagraph());
            doc.Add(CreateVotesPerCandidateParagraph(statisticsData));
            doc.Add(CreateVotesPerPartyParagraph(statisticsData));
            doc.Add(CreateOtherStatisticsParagraph(statisticsData));

            //Closing document
            doc.Close();
        }
    public void save()
    {
        BinaryFormatter bf   = new BinaryFormatter();
        FileStream      file = File.Create(Application.persistentDataPath + "/statistics.dat");

        StatisticsData data = new StatisticsData();

        data.weeklyDistances = weeklyDistances;

        data.invalidDates = new long[invalidDates.Length];
        for (int i = 0; i < invalidDates.Length; i++)
        {
            data.invalidDates[i] = invalidDates[i].ToBinary();
        }

        bf.Serialize(file, data);
        file.Close();
    }
        /// <summary>
        /// 服务状态
        /// </summary>
        /// <returns></returns>
        public object Status()
        {
            StatisticsData data = this.gateway.Statistics.GetData();

            ServerCounter.ServerStatus serverStatus       = this.gateway.HttpServer.ServerCounter.Next(false);
            CodeStatisticsData         codeStatisticsData = this.gateway.Statistics.ListStatisticsData(311);

            return(new
            {
                Status = serverStatus,
                SuccessRps = data._2xx.Rps,
                ErrorRps = data._5xx.Rps,
                Times = data.Times,
                Queue = this.gateway.IOQueue.Count,
                Memory = serverStatus.Memory / 1024L,
                Hit = codeStatisticsData.Rps,
                this.gateway.BufferSize,
            });
        }
        Paragraph CreateVotesPerPartyParagraph(StatisticsData statisticsData)
        {
            Phrase    titlePhrase            = new Phrase("\nVOTES PER PARTY\n\n", bigFont);
            Paragraph votesPerPartyParagraph = new Paragraph();

            votesPerPartyParagraph.Add(titlePhrase);

            foreach (KeyValuePair <string, int> partyVotes in statisticsData.partyVotes)
            {
                Chunk  partyChunk          = new Chunk(partyVotes.Key + "    ", normalFont);
                float  percentVotingResult = partyVotes.Value / (float)statisticsData.validVotesNumber * 100;
                Chunk  resultChunk         = new Chunk(string.Format("{0} ({1:0.00}%)\n\n", partyVotes.Value, percentVotingResult), normalFont);
                Phrase partyPhrase         = new Phrase();
                partyPhrase.Add(partyChunk);
                partyPhrase.Add(resultChunk);
                votesPerPartyParagraph.Add(partyPhrase);
            }
            return(votesPerPartyParagraph);
        }
Beispiel #9
0
        private void initChernoffFaceLegend(VoivodeshipNames name)
        {
            if (name == VoivodeshipNames.None)
            {
                faceTabItem.IsEnabled = false;
            }
            else
            {
                faceTabItem.IsEnabled          = true;
                legendTabControl.SelectedIndex = 2;

                StatisticsData minData = holder.GetMinDatasInVoivodeship(name);
                StatisticsData maxData = holder.GetMaxDatasInVoivodeship(name);

                initChernoffFaceColorLegend(ColorScheme.GetValueIntervals(minData.Sections, maxData.Sections));
                initChernoffFaceEyesLegend(ColorScheme.GetValueIntervals(minData.Boys, maxData.Boys));
                initChernoffFaceMustacheLegend(ColorScheme.GetValueIntervals(minData.Womens, maxData.Womens));
                initChernoffFaceLipsLegend(ColorScheme.GetValueIntervals(minData.Girls, maxData.Girls));
            }
        }
        public ChernoffFace(Point centrePoint, int radius, StatisticsData statisticsData,
                            StatisticsData minData, StatisticsData maxData)
        {
            CentrePoint = centrePoint;
            Radius      = radius;
            Data        = statisticsData;

            bkgColor = ColorScheme.GetColorByIndex(
                ColorScheme.GetIndexByValue(statisticsData.Sections, minData.Sections, maxData.Sections),
                ColorScheme.FaceColors);

            facePartTypes = new int[Enum.GetNames(typeof(FacePartNames)).Length];
            facePartTypes[(int)FacePartNames.Face]     = 0;
            facePartTypes[(int)FacePartNames.Eyes]     = ColorScheme.GetIndexByValue(statisticsData.Boys, minData.Boys, maxData.Boys);
            facePartTypes[(int)FacePartNames.Mustache] = ColorScheme.GetIndexByValue(statisticsData.Womens, minData.Womens, maxData.Womens);
            facePartTypes[(int)FacePartNames.Lips]     = ColorScheme.GetIndexByValue(statisticsData.Girls, minData.Girls, maxData.Girls);

            Shapes = new Path[Enum.GetNames(typeof(FacePartNames)).Length][];
            Shapes[(int)FacePartNames.Face]     = getFace();
            Shapes[(int)FacePartNames.Eyes]     = getEyes(facePartTypes[(int)FacePartNames.Eyes]);
            Shapes[(int)FacePartNames.Mustache] = getMustache(facePartTypes[(int)FacePartNames.Mustache]);
            Shapes[(int)FacePartNames.Lips]     = getLips(facePartTypes[(int)FacePartNames.Lips]);
        }
Beispiel #11
0
        private void AppendCsvInformationWithStats(StatisticsData data)
        {
            foreach (var item in data.ElapsedTimesPerFlight)
            {
                var flightToExport = _objectsToExport.FirstOrDefault(f => f.FlightNumber == item.Key);

                flightToExport.TimeElapsed = item.Value;
            }

            foreach (var item in data.PscSucceededBagsPerFlight)
            {
                var flightToExport = _objectsToExport.FirstOrDefault(f => f.FlightNumber == item.Key);

                flightToExport.SucceededBags = item.Value;
            }

            foreach (var item in data.PscFailedBagsPerFlight)
            {
                var flightToExport = _objectsToExport.FirstOrDefault(f => f.FlightNumber == item.Key);

                flightToExport.FailedBags = item.Value;
            }
        }
        Paragraph CreateVotesPerCandidateParagraph(StatisticsData statisticsData)
        {
            Phrase    titlePhrase = new Phrase("\n\nVOTES PER CANDIDATE\n\n", bigFont);
            Paragraph votesPerCandidateParagraph = new Paragraph();

            votesPerCandidateParagraph.Add(titlePhrase);

            //ExportData exportData = new ExportData();
            foreach (KeyValuePair <Candidate, int> candidateVotes in statisticsData.candidateVotes)
            {
                Chunk nameChunk           = new Chunk(candidateVotes.Key.name + "   ", normalFont);
                float percentVotingResult = candidateVotes.Value / (float)statisticsData.validVotesNumber * 100;
                Chunk resultChunk         = new Chunk(string.Format("{0} ({1:0.00}%)\n", candidateVotes.Value, percentVotingResult), normalFont);
                Chunk partyChunk          = new Chunk(candidateVotes.Key.party + "\n\n", smallFont);

                Phrase candidatePhrase = new Phrase();
                candidatePhrase.Add(nameChunk);
                candidatePhrase.Add(resultChunk);
                candidatePhrase.Add(partyChunk);

                votesPerCandidateParagraph.Add(candidatePhrase);
            }
            return(votesPerCandidateParagraph);
        }
        public ActionResult Statistics()
        {
            IQueryable <EnrollmentDateGroup> enrollmentData = from student in db.Students
                                                              group student by student.SchoolEnrollmentDate into dateGroup
                                                              select new EnrollmentDateGroup()
            {
                EnrollmentDate = dateGroup.Key,
                StudentCount   = dateGroup.Count(),
                GradeAverage   = dateGroup.Select(s => s.Enrollments.Average(e => e.Grade)).Average()
            };
            IQueryable <CoursesData> courseData = from course in db.Courses
                                                  select new CoursesData()
            {
                course = course,
                EnrolledStudentsCount = course.Enrollments.Count()
            };

            StatisticsData stats = new StatisticsData()
            {
                EnrollmentData = enrollmentData.ToList(), TopCoursesData = courseData.OrderByDescending(c => c.EnrolledStudentsCount).ToList()
            };

            return(View(stats));
        }
Beispiel #14
0
 /// <summary>
 /// Not implemented.
 /// </summary>
 /// <param name="data"> Not implemented.</param>
 /// <returns> Not implemented.</returns>
 public static int UtilGetStatistics(ref StatisticsData data)
 {
     return((int)Tango.Common.RetCodes.kCAPINotImplemented);
 }
Beispiel #15
0
 public void WriteStatsToCsv(SimulationSettings settings, StatisticsData data)
 {
     _CSVWriteService.WriteToCSV(settings, data);
 }
Beispiel #16
0
        private static List <PlayerEntity> OnePlayerHealthDamage(Contexts contexts, IGameRule gameRule, PlayerEntity srcPlayer, PlayerEntity playerEntity, PlayerDamageInfo damage, IDamageInfoCollector damageInfoCollector, bool isTeam)
        {
            if (playerEntity.gamePlay.IsDead())
            {
                return(null);
            }

            if ((DateTime.Now.Ticks / 10000L) - playerEntity.statisticsData.Statistics.LastHitDownTime <= 1000 && !damage.InstantDeath)
            {
                return(null);
            }

            float curHp      = playerEntity.gamePlay.CurHp;
            float realDamage = damage.damage;

            if (gameRule != null)
            {
                realDamage = gameRule.HandleDamage(srcPlayer, playerEntity, damage);
            }
            if (null != damageInfoCollector)
            {
                damageInfoCollector.SetPlayerDamageInfo(srcPlayer, playerEntity, realDamage, (EBodyPart)damage.part);
            }
            if (!SharedConfig.IsOffline && !SharedConfig.IsServer)
            {
                return(null);
            }

            float ret = playerEntity.gamePlay.DecreaseHp(realDamage);

            _logger.InfoFormat("[hit] after CurrHp :" + playerEntity.gamePlay.CurHp);
            damage.damage = ret;

            //玩家状态
            List <PlayerEntity> teamList = CheckUpdatePlayerStatus(playerEntity, damage, !isTeam && gameRule != null ? gameRule.Contexts : null);

            //保存最后伤害来源
            StatisticsData statisticsData = playerEntity.statisticsData.Statistics;

            if (statisticsData.DataCollectSwitch)
            {
                if (playerEntity.gamePlay.IsLastLifeState(EPlayerLifeState.Alive))
                {
                    statisticsData.IsHited = true;
                    if (null != srcPlayer)
                    {
                        statisticsData.LastHurtKey = srcPlayer.entityKey.Value;
                    }
                    else
                    {
                        statisticsData.LastHurtKey = EntityKey.Default;
                    }
                    statisticsData.LastHurtType     = damage.type;
                    statisticsData.LastHurtPart     = damage.part;
                    statisticsData.LastHurtWeaponId = damage.weaponId;
                }

                //击倒人头
                if (statisticsData.IsHited && (damage.type == (int)EUIDeadType.NoHelp || damage.type == (int)EUIDeadType.Poison || damage.type == (int)EUIDeadType.Bomb ||
                                               damage.type == (int)EUIDeadType.Drown || damage.type == (int)EUIDeadType.Bombing || damage.type == (int)EUIDeadType.Fall))
                {
                    if (gameRule != null)
                    {
                        PlayerEntity lastEntity = gameRule.Contexts.player.GetEntityWithEntityKey(statisticsData.LastHurtKey);
                        if (null != lastEntity)
                        {
                            srcPlayer = lastEntity;
                            if (srcPlayer.playerInfo.TeamId == playerEntity.playerInfo.TeamId)
                            {
                                damage.type     = statisticsData.LastHurtType;
                                damage.part     = statisticsData.LastHurtPart;
                                damage.weaponId = statisticsData.LastHurtWeaponId;
                            }
                            else
                            {
                                damage.type = (int)EUIDeadType.NoHelp;
                            }
                        }
                    }
                }

                if (playerEntity.gamePlay.IsHitDown())
                {
                    statisticsData.LastHitDownTime = (DateTime.Now.Ticks / 10000L);
                    SimpleProto message = FreePool.Allocate();
                    message.Key = FreeMessageConstant.ScoreInfo;
                    int feedbackType = 0;
                    message.Ks.Add(3);
                    message.Bs.Add(true);
                    if (null != srcPlayer)
                    {
                        if (srcPlayer.playerInfo.TeamId != playerEntity.playerInfo.TeamId)
                        {
                            feedbackType |= 1 << (int)EUIKillFeedbackType.Hit;
                        }
                        message.Ss.Add(srcPlayer.playerInfo.PlayerName);
                        message.Ds.Add(srcPlayer.playerInfo.TeamId);
                        message.Ins.Add(damage.weaponId);
                    }
                    else
                    {
                        message.Ss.Add("");
                        message.Ds.Add(-1);
                        message.Ins.Add(0);
                    }
                    message.Ins.Add((int)EUIKillType.Hit);
                    message.Ins.Add(feedbackType);
                    message.Ss.Add(playerEntity.playerInfo.PlayerName);
                    message.Ds.Add(playerEntity.playerInfo.TeamId);
                    message.Ins.Add(damage.type);
                    SendMessageAction.sender.SendMessage(contexts.session.commonSession.FreeArgs as IEventArgs, message, 4, string.Empty);
                }

                if (playerEntity.gamePlay.IsDead())
                {
                    //UI击杀信息
                    int killType = 0;
                    if (damage.part == (int)EBodyPart.Head)
                    {
                        killType |= (int)EUIKillType.Crit;
                    }
                    damage.KillType = killType;
                    playerEntity.playerInfo.SpecialFeedbackType = 0;
                    //UI击杀反馈
                    if (null != srcPlayer && srcPlayer.playerInfo.TeamId != playerEntity.playerInfo.TeamId)
                    {
                        int feedbackType = 0;
                        if (damage.part == (int)EBodyPart.Head)
                        {
                            //爆头
                            feedbackType |= 1 << (int)EUIKillFeedbackType.CritKill;
                        }
                        if (damage.IsOverWall)
                        {
                            //穿墙击杀
                            feedbackType |= 1 << (int)EUIKillFeedbackType.ThroughWall;
                        }
                        if (SharedConfig.IsServer && null != gameRule && gameRule.Contexts.session.serverSessionObjects.DeathOrder == 0 && srcPlayer.playerInfo.TeamId != playerEntity.playerInfo.TeamId)
                        {
                            //一血
                            feedbackType |= 1 << (int)EUIKillFeedbackType.FirstBlood;
                        }
                        if (playerEntity.playerInfo.PlayerId == srcPlayer.statisticsData.Statistics.RevengeKillerId)
                        {
                            //复仇
                            feedbackType |= 1 << (int)EUIKillFeedbackType.Revenge;
                            srcPlayer.statisticsData.Statistics.RevengeKillerId = 0L;
                        }
                        if (srcPlayer.playerInfo.JobAttribute == (int)EJobAttribute.EJob_Hero)
                        {
                            //英雄击杀
                            feedbackType |= 1 << (int)EUIKillFeedbackType.HeroKO;
                            playerEntity.playerInfo.SpecialFeedbackType = (int)EUIKillFeedbackType.HeroKO;
                        }
                        //武器
                        WeaponResConfigItem newConfig = SingletonManager.Get <WeaponResourceConfigManager>().GetConfigById(damage.weaponId);
                        if (null != newConfig)
                        {
                            if (newConfig.SubType == (int)EWeaponSubType.Melee)
                            {
                                feedbackType |= 1 << (int)EUIKillFeedbackType.MeleeWeapon;
                                playerEntity.playerInfo.SpecialFeedbackType = (int)EUIKillFeedbackType.MeleeWeapon;
                            }
                            else if (newConfig.SubType == (int)EWeaponSubType.BurnBomb)
                            {
                                feedbackType |= 1 << (int)EUIKillFeedbackType.Burning;
                            }
                            else if (newConfig.SubType == (int)EWeaponSubType.Grenade)
                            {
                                feedbackType |= 1 << (int)EUIKillFeedbackType.Grenade;
                            }
                        }
                        if (feedbackType == 0)
                        {
                            //普通击杀
                            feedbackType = 1 << (int)EUIKillFeedbackType.Normal;
                        }
                        damage.KillFeedbackType = feedbackType;
                    }
                }

                //数据统计
                ProcessDamageStatistics(contexts, gameRule, srcPlayer, playerEntity, damage);
            }

            //击杀|击倒
            if (null != gameRule && playerEntity.gamePlay.IsDead())
            {
                gameRule.KillPlayer(srcPlayer, playerEntity, damage);
            }

            _logger.DebugFormat("change player hp entityId:{0}, health {1}->{2}, state {3}, srcPlayerId:{4}, playerId:{5}, hurtType:{6}, weaponId:{7}", playerEntity.entityKey.Value.EntityId, curHp, playerEntity.gamePlay.CurHp, playerEntity.gamePlay.LifeState, (srcPlayer != null) ? srcPlayer.playerInfo.PlayerId : 0, playerEntity.playerInfo.PlayerId, damage.type, damage.weaponId);

            return(teamList);
        }
        /// <summary>
        /// 统计按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonStatistics_Click(object sender, EventArgs e)
        {
            if (dataGridView1.Rows.Count == 0)
            {
                return;
            }

            int totalCount  = dataGridView1.Rows.Count;
            int totalGongli = 0;
            int startMile   = 0;
            int endMile     = 0;

            if (bIndex)
            {
                startMile = (int)(waveformMaker.WaveformDataList[0].MileageFix.FixData[0].MarkedStartPoint.UserSetMileage * 1000);
                endMile   = (int)(waveformMaker.WaveformDataList[0].MileageFix.FixData[waveformMaker.WaveformDataList[0].MileageFix.FixData.Count - 1].MarkedEndPoint.UserSetMileage) * 1000;
            }
            else
            {
                Milestone milestone = citHelper.GetStartMilestone(citFilePath);
                startMile = Convert.ToInt32(milestone.mKm * 1000 + milestone.mMeter);
                milestone = citHelper.GetEndMilestone(citFilePath);
                endMile   = Convert.ToInt32(milestone.mKm * 1000 + milestone.mMeter);
            }
            totalGongli = Math.Abs(startMile - endMile);


            List <StatisticsData> dataList = new List <StatisticsData>();

            try
            {
                int typeNum = 0;                                                          //无效区段类型的个数
                Dictionary <int, String> dicInvalidType = new Dictionary <int, String>(); //无效区段类型

                DataTable dt = invalidManager.GetValidDataType();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    dicInvalidType.Add(Convert.ToInt32(dt.Rows[i][0].ToString()), dt.Rows[i][1].ToString());
                }

                typeNum = dicInvalidType.Count;

                List <InvalidData> list = invalidManager.InvalidDataList(idfFilePath);

                for (int i = 0; i < typeNum; i++)
                {
                    List <InvalidData> listNew = list.Where(s => s.iType == i).ToList();

                    StatisticsData statisticsDataCls = null;
                    for (int j = 0; j < listNew.Count; j++)
                    {
                        if (statisticsDataCls == null)
                        {
                            statisticsDataCls = new StatisticsData(totalCount, totalGongli);
                        }
                        statisticsDataCls.reasonType = dicInvalidType[listNew[j].iType];//类型
                        statisticsDataCls.sumcount++;
                        startMile = (int)(float.Parse(listNew[j].sStartMile) * 1000);
                        endMile   = (int)(float.Parse(listNew[j].sEndMile) * 1000);

                        statisticsDataCls.sumGongli = statisticsDataCls.sumGongli + Math.Abs(endMile - startMile);
                    }

                    if (statisticsDataCls != null)
                    {
                        dataList.Add(statisticsDataCls);
                    }
                }
            }
            catch (System.Exception ex)
            {
                MyLogger.LogError("统计无效数据时失败", ex);
                MessageBox.Show(ex.Message);
            }

            //无效区段统计窗体
            InvalidDataStatisticsForm statisticsForm = new InvalidDataStatisticsForm(dataList);

            //statisticsForm.TopLevel = true;
            statisticsForm.Show();
        }
 //return the score by data
 //server with highest score will be choosen
 private static double GetScore(StatisticsData data)
 {
     return (double)data.SuccessTimes / (data.SuccessTimes + data.TimedOutTimes); //simply choose min package loss
 }
        private void StatisticsChartData(StatisticsData data)
        {
            //clean charts
            pieChartBagsSecurity.Series.Clear();
            PrimarySecurityChart.Series.Clear();
            cartesianChart1.Series.Clear();
            cartesianChartSuccBagsPerFlight.Series.Clear();
            cartesianChartFailedBagsPerFlight.Series.Clear();

            //pie chart
            pieChartBagsSecurity.Series.Add(new PieSeries()
            {
                Title = "Succeeded", Values = new ChartValues <int> {
                    data.BagsSucceededPsc.Count
                }, DataLabels = true
            });
            pieChartBagsSecurity.Series.Add(new PieSeries()
            {
                Title = "Failed", Values = new ChartValues <int> {
                    data.BagsFailedPsc.Count
                }, DataLabels = true
            });
            pieChartBagsSecurity.LegendLocation = LegendLocation.Right;

            //column chart bags per dropOff
            foreach (var flight in data.BagsPerFlight)
            {
                PrimarySecurityChart.Series.Add(new ColumnSeries()
                {
                    Title = "DropOff number " + flight.Key, Values = new ChartValues <int> {
                        flight.Value
                    }
                });
            }

            //cartesian chart elapsed times per flight
            foreach (var flight in data.ElapsedTimesPerFlight)
            {
                cartesianChart1.Series.Add(new ColumnSeries()
                {
                    Title = "Flight number " + flight.Key, Values = new ChartValues <int> {
                        int.Parse(flight.Value)
                    }
                });
            }

            foreach (var flight in data.PscSucceededBagsPerFlight)
            {
                cartesianChartSuccBagsPerFlight.Series.Add(new ColumnSeries()
                {
                    Title = "Flight number " + flight.Key, Values = new ChartValues <int> {
                        flight.Value
                    }
                });
            }

            foreach (var flight in data.PscFailedBagsPerFlight)
            {
                cartesianChartFailedBagsPerFlight.Series.Add(new ColumnSeries()
                {
                    Title = "Flight number " + flight.Key, Values = new ChartValues <int> {
                        flight.Value
                    }
                });
            }
        }
Beispiel #20
0
 public static extern int UtilGetStatistics(ref StatisticsData data);
Beispiel #21
0
 private void Start()
 {
     saver = new Saver <StatisticsData>();
     data  = saver.GetData();
 }
        void _BGWTotalDisciplineAndAbsence_DoWork(object sender, DoWorkEventArgs e)
        {
            string reportName = "歷年功過及出席統計";

            _BGWTotalDisciplineAndAbsence.ReportProgress(0);

            #region 取得資料

            AccessHelper         helper   = new AccessHelper();
            List <StudentRecord> students = helper.StudentHelper.GetSelectedStudent();

            helper.StudentHelper.FillSemesterEntryScore(true, students);
            helper.StudentHelper.FillReward(students);
            helper.StudentHelper.FillAttendance(students);

            StatisticsCollection stat = new StatisticsCollection();
            Dictionary <string, List <string> > detailList = new Dictionary <string, List <string> >();

            Dictionary <string, int> rewardDict = new Dictionary <string, int>();

            foreach (StudentRecord each in students)
            {
                StatisticsData data = new StatisticsData();
                List <string>  list = new List <string>();

                //獎懲
                foreach (RewardInfo info in each.RewardList)
                {
                    int schoolyear = info.SchoolYear;
                    int semester   = info.Semester;

                    if (info.UltimateAdmonition == true)
                    {
                        data.AddItem(schoolyear, semester, "留校察看", 1);
                        list.Add(CDATE(info.OccurDate.ToShortDateString()) + " " + info.OccurReason + " 留校察看");
                        continue;
                    }

                    rewardDict.Clear();

                    data.AddItem(schoolyear, semester, "大功", (decimal)info.AwardA);
                    data.AddItem(schoolyear, semester, "小功", (decimal)info.AwardB);
                    data.AddItem(schoolyear, semester, "嘉獎", (decimal)info.AwardC);
                    rewardDict.Add("大功", info.AwardA);
                    rewardDict.Add("小功", info.AwardB);
                    rewardDict.Add("嘉獎", info.AwardC);

                    if (_print_cleared == true || info.Cleared == false)
                    {
                        data.AddItem(schoolyear, semester, "大過", (decimal)info.FaultA);
                        data.AddItem(schoolyear, semester, "小過", (decimal)info.FaultB);
                        data.AddItem(schoolyear, semester, "警告", (decimal)info.FaultC);
                        rewardDict.Add("大過", info.FaultA);
                        rewardDict.Add("小過", info.FaultB);
                        rewardDict.Add("警告", info.FaultC);
                    }

                    string rewardStat = "";
                    foreach (string var in new string[] { "大功", "小功", "嘉獎", "大過", "小過", "警告" })
                    {
                        if (rewardDict.ContainsKey(var) && rewardDict[var] > 0)
                        {
                            if (!string.IsNullOrEmpty(rewardStat))
                            {
                                rewardStat += ", ";
                            }
                            rewardStat += var + rewardDict[var] + "次";
                        }
                    }

                    //兩個條件可加入明細清單
                    //1.如果勾選消過也列印
                    //2.資料未消過
                    if (_print_cleared == true)
                    {
                        string all = "";
                        if (info.Cleared)
                        {
                            all = CDATE(info.OccurDate.ToShortDateString()) + " " + info.OccurReason + " " + rewardStat + " (已銷過)";
                        }
                        else
                        {
                            all = CDATE(info.OccurDate.ToShortDateString()) + " " + info.OccurReason + " " + rewardStat;
                        }
                        list.Add(all);
                    }
                    else if (info.Cleared == false)
                    {
                        string all = CDATE(info.OccurDate.ToShortDateString()) + " " + info.OccurReason + " " + rewardStat;
                        list.Add(all);
                    }

                    #region 註解掉了
                    //if (((info.OccurReason + " " + rewardStat) as string).Length >= 20)
                    //{
                    //    List<string> mini = new List<string>();
                    //    string reason = info.OccurReason;

                    //    while (reason.Length >= 20)
                    //    {
                    //        mini.Add(reason.Substring(0, 19));
                    //        reason = reason.Substring(19);
                    //    }
                    //    if (((reason + " " + rewardStat) as string).Length >= 20)
                    //    {
                    //        mini.Add(reason);
                    //        mini.Add(rewardStat);
                    //    }
                    //    else
                    //        mini.Add(reason + " " + rewardStat);

                    //    //mini.Add(CDATE(info.OccurDate.ToShortDateString()) + " ");

                    //    for (int i = 0; i < mini.Count; i++)
                    //    {
                    //        if (i == 0)
                    //            list.Add(CDATE(info.OccurDate.ToShortDateString()) + " " + mini[i]);
                    //        else
                    //            list.Add("   " + mini[i]);
                    //    }
                    //}
                    //else
                    //    list.Add(all);
                    #endregion
                }
                detailList.Add(each.StudentID, list);

                //缺曠
                foreach (AttendanceInfo info in each.AttendanceList)
                {
                    int schoolyear = info.SchoolYear;
                    int semester   = info.Semester;
                    if (PrintDic.ContainsKey(info.Period))
                    {
                        data.AddItem(schoolyear, semester, PrintDic[info.Period] + "_" + info.Absence, 1);
                    }
                }

                //德行成績
                foreach (SemesterEntryScoreInfo info in each.SemesterEntryScoreList)
                {
                    if (info.Entry == "德行")
                    {
                        int schoolyear = info.SchoolYear;
                        int semester   = info.Semester;

                        data.AddItem(schoolyear, semester, "德行成績", info.Score);
                    }
                }

                data.MendSemester();

                stat.Add(each.StudentID, data);
            }

            #endregion

            #region 產生範本

            int AsbCount = 0;
            foreach (string each in _print_types.Keys)
            {
                AsbCount += _print_types[each].Count;
            }

            totalRow = detailRow + 11 + AsbCount;

            foreach (StudentRecord each in students)
            {
                if (detailRow < detailList[each.StudentID].Count / 2 + 1)
                {
                    detailRow = detailList[each.StudentID].Count / 2 + 1;

                    totalRow = detailRow + 11 + AsbCount;
                }
            }


            Workbook pt1 = GetTemplate(6);
            Workbook pt2 = GetTemplate(8);
            Workbook pt3 = GetTemplate(10);

            Dictionary <int, Workbook> pts = new Dictionary <int, Workbook>();
            pts.Add(6, pt1);
            pts.Add(8, pt2);
            pts.Add(10, pt3);

            Range ptr1 = pt1.Worksheets[0].Cells.CreateRange(0, totalRow, false);
            Range ptr2 = pt2.Worksheets[0].Cells.CreateRange(0, totalRow, false);
            Range ptr3 = pt3.Worksheets[0].Cells.CreateRange(0, totalRow, false);

            Dictionary <int, Range> ptrs = new Dictionary <int, Range>();
            ptrs.Add(6, ptr1);
            ptrs.Add(8, ptr2);
            ptrs.Add(10, ptr3);

            #endregion

            #region 產生報表

            Workbook wb = new Workbook();
            wb.Copy(pt1);
            wb.Worksheets[0].Copy(pt1.Worksheets[0]);

            int wsCount = wb.Worksheets.Count;
            for (int i = wsCount - 1; i > 0; i--)
            {
                wb.Worksheets.RemoveAt(i);
            }
            wb.Worksheets[0].Name = "一般(6學期)";

            Dictionary <int, int>       sheetIndex = new Dictionary <int, int>();
            Dictionary <int, Worksheet> sheets     = new Dictionary <int, Worksheet>();
            sheets.Add(6, wb.Worksheets[0]);
            sheetIndex.Add(6, 0);

            Worksheet ws = wb.Worksheets[0];

            int index = 0;
            int cur   = 6;

            int pages = 500;

            //
            int start = 1;
            int limit = pages;

            int studentCount = 0;

            //學生數
            int allStudentCount = students.Count;

            foreach (StudentRecord each in students)
            {
                //取得學生統計
                StatisticsData data = stat[each.StudentID];

                #region 判斷學期數
                if (data.GetSemesterNumber() > 6 && data.GetSemesterNumber() <= 8)
                {
                    //學期數大於6小於8
                    //特殊報表
                    if (!sheets.ContainsKey(8))
                    {
                        int new_ws_index = wb.Worksheets.Add();
                        wb.Worksheets[new_ws_index].Copy(pt2.Worksheets[0]);
                        wb.Worksheets[new_ws_index].Name = "特殊(8學期)";
                        sheets.Add(8, wb.Worksheets[new_ws_index]);
                        sheetIndex.Add(8, 0);
                    }

                    //變更預設報表位置
                    ws = sheets[8];
                    //取得報表定位
                    index = sheetIndex[8];
                    //取得報表定位?
                    cur = 8;
                    studentCount++;
                }
                else if (data.GetSemesterNumber() == 6)
                {
                    ws    = sheets[6];
                    index = sheetIndex[6];
                    cur   = 6;
                    studentCount++;
                }
                else
                {
                    //學期數大於8小於10
                    //特殊1報表
                    if (!sheets.ContainsKey(10))
                    {
                        int new_ws_index = wb.Worksheets.Add();
                        wb.Worksheets[new_ws_index].Copy(pt3.Worksheets[0]);
                        wb.Worksheets[new_ws_index].Name = "特殊(其它)";
                        sheets.Add(10, wb.Worksheets[new_ws_index]);
                        sheetIndex.Add(10, 0);
                    }
                    ws    = sheets[10];
                    index = sheetIndex[10];
                    cur   = 10;
                    studentCount++;
                }
                #endregion

                //取得畫面範圍 Range(0~TotalRow)
                ws.Cells.CreateRange(index, totalRow, false).Copy(ptrs[cur]);

                //填入標題
                ws.Cells[index + 1, 0].PutValue(string.Format("班級:{0}    學號:{1}    姓名:{2}", (each.RefClass != null) ? each.RefClass.ClassName : "", each.StudentNumber, each.StudentName));

                //第一行位置(標題+2)
                int firstRow = index + 2;

                //第一列位置
                int col = 2;

                //處理每個學期的統計
                foreach (string semsString in data.Semesters)
                {
                    //填入學年度/學期
                    ws.Cells[firstRow, col].PutValue(DisplaySemester(semsString));

                    //取得學期統計資料
                    Dictionary <string, decimal> semsDict = data.GetItem(semsString);

                    foreach (string item in semsDict.Keys)
                    {
                        if (rowIndexTable.ContainsKey(item))
                        {
                            ws.Cells[index + rowIndexTable[item], col].PutValue((semsDict[item] <= 0) ? "" : semsDict[item].ToString());
                        }
                    }

                    col++;
                }

                if (rowIndexTable.ContainsKey("明細"))
                {
                    //資料一律由第二列進行列印
                    int detailColIndex = 2;

                    //
                    int detailIndex = index + rowIndexTable["明細"];

                    //明細定位點
                    int detailCount = 0;

                    //取得學生明細清單
                    foreach (string var in detailList[each.StudentID])
                    {
                        //明細定位點+1
                        detailCount++;
                        //定位點大於明細畫面範圍時
                        //將換為第二區進行列印
                        if (detailCount > detailRow)
                        {
                            detailColIndex += (cur / 2);
                            detailIndex     = index + rowIndexTable["明細"];
                            detailCount     = 0;
                        }
                        ws.Cells[detailIndex++, detailColIndex].PutValue(var);
                    }
                }

                //?
                index          += totalRow;
                sheetIndex[cur] = index;

                //增加列印分割線
                ws.HPageBreaks.Add(index, 0);

                //當學生大於極限值 , 並且列印完所有學生
                if (studentCount >= limit && studentCount < allStudentCount)
                {
                    //取得工作表名稱
                    //string orig_name = ws.Name;

                    //
                    //ws.Name = ws.Name + " (" + start + " ~ " + studentCount + ")";
                    ws = wb.Worksheets[wb.Worksheets.Add()];
                    ws.Copy(pts[cur].Worksheets[0]);
                    //ws.Name = orig_name;
                    start          += pages;
                    limit          += pages;
                    index           = 0;
                    sheetIndex[cur] = index;
                    sheets[cur]     = ws;
                }

                //回報進度
                _BGWTotalDisciplineAndAbsence.ReportProgress((int)(((double)studentCount * 100.0) / (double)allStudentCount));
            }

            //if (cur == 6)
            //ws.Name = ws.Name + " (" + start + " ~ " + studentCount + ")";

            #endregion

            string path = Path.Combine(Application.StartupPath, "Reports");
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            path     = Path.Combine(path, reportName + ".xlt");
            e.Result = new object[] { reportName, path, wb };
        }
Beispiel #23
0
 //Καλείται όταν πατηθέι το κουμπι για τον μηδενισμό των highscores
 public void Reset()
 {
     StatisticsData.ResetHighscores(); //τα μηδενίζει
     ShowScore();                      //τα ξαναεμφανίζει αλλά τώρα πλέον έχουν μηδενικές τιμες
 }
        private static List <PlayerEntity> OnePlayerHealthDamage(Contexts contexts, IGameRule gameRule, PlayerEntity srcPlayer, PlayerEntity playerEntity, PlayerDamageInfo damage, IDamageInfoCollector damageInfoCollector, bool isTeam)
        {
            if (playerEntity.gamePlay.IsDead())
            {
                return(null);
            }

            float curHp      = playerEntity.gamePlay.CurHp;
            float realDamage = damage.damage;

            if (gameRule != null)
            {
                realDamage = gameRule.HandleDamage(srcPlayer, playerEntity, damage);
            }
            if (null != damageInfoCollector)
            {
                damageInfoCollector.SetPlayerDamageInfo(srcPlayer, playerEntity, realDamage, (EBodyPart)damage.part);
            }
            if (!SharedConfig.IsOffline && !SharedConfig.IsServer)
            {
                return(null);
            }

            float ret = playerEntity.gamePlay.DecreaseHp(realDamage);

            damage.damage = ret;

            //玩家状态
            List <PlayerEntity> teamList = CheckUpdatePlayerStatus(playerEntity, damage, !isTeam && gameRule != null ? gameRule.Contexts : null);

            //保存最后伤害来源
            StatisticsData statisticsData = playerEntity.statisticsData.Statistics;

            if (statisticsData.DataCollectSwitch)
            {
                if (playerEntity.gamePlay.IsLastLifeState(EPlayerLifeState.Alive))
                {
                    statisticsData.IsHited = true;
                    if (null != srcPlayer)
                    {
                        statisticsData.LastHurtKey = srcPlayer.entityKey.Value;
                    }
                    else
                    {
                        statisticsData.LastHurtKey = EntityKey.Default;
                    }
                    statisticsData.LastHurtType     = damage.type;
                    statisticsData.LastHurtPart     = damage.part;
                    statisticsData.LastHurtWeaponId = damage.weaponId;
                }

                //谁击倒算谁的人头
                if (statisticsData.IsHited)
                {
                    if (gameRule != null)
                    {
                        PlayerEntity lastEntity = gameRule.Contexts.player.GetEntityWithEntityKey(statisticsData.LastHurtKey);
                        if (null != lastEntity)
                        {
                            srcPlayer = lastEntity;
                        }
                    }
                    damage.type     = statisticsData.LastHurtType;
                    damage.part     = statisticsData.LastHurtPart;
                    damage.weaponId = statisticsData.LastHurtWeaponId;
                }

                if (playerEntity.gamePlay.IsDead())
                {
                    //UI击杀信息
                    int killType = 0;
                    if (damage.part == (int)EBodyPart.Head)
                    {
                        killType |= (int)EUIKillType.Crit;
                    }
                    if (playerEntity.gamePlay.IsHitDown())
                    {
                        killType |= (int)EUIKillType.Hit;
                    }
                    damage.KillType = killType;
                    //UI击杀反馈
                    if (null != srcPlayer && srcPlayer.playerInfo.TeamId != playerEntity.playerInfo.TeamId)
                    {
                        int feedbackType = 0;
                        if (damage.part == (int)EBodyPart.Head)
                        {
                            //爆头
                            feedbackType |= 1 << (int)EUIKillFeedbackType.CritKill;
                        }
                        if (damage.IsOverWall)
                        {
                            //穿墙击杀
                            feedbackType |= 1 << (int)EUIKillFeedbackType.ThroughWall;
                        }
                        if (SharedConfig.IsServer && null != gameRule && gameRule.Contexts.session.serverSessionObjects.DeathOrder == 0 && srcPlayer.playerInfo.TeamId != playerEntity.playerInfo.TeamId)
                        {
                            //一血
                            feedbackType |= 1 << (int)EUIKillFeedbackType.FirstBlood;
                        }
                        if (playerEntity.playerInfo.PlayerId == srcPlayer.statisticsData.Statistics.RevengeKillerId)
                        {
                            //复仇
                            feedbackType |= 1 << (int)EUIKillFeedbackType.Revenge;
                            srcPlayer.statisticsData.Statistics.RevengeKillerId = 0L;
                        }
                        //武器
                        WeaponResConfigItem newConfig = SingletonManager.Get <WeaponResourceConfigManager>().GetConfigById(damage.weaponId);
                        if (null != newConfig)
                        {
                            if (newConfig.SubType == (int)EWeaponSubType.Melee)
                            {
                                feedbackType |= 1 << (int)EUIKillFeedbackType.MeleeWeapon;
                            }
                            else if (newConfig.SubType == (int)EWeaponSubType.BurnBomb)
                            {
                                feedbackType |= 1 << (int)EUIKillFeedbackType.Burning;
                            }
                            else if (newConfig.SubType == (int)EWeaponSubType.Grenade)
                            {
                                feedbackType |= 1 << (int)EUIKillFeedbackType.Grenade;
                            }
                        }
                        if (feedbackType == 0)
                        {
                            //普通击杀
                            feedbackType = 1 << (int)EUIKillFeedbackType.Normal;
                        }
                        damage.KillFeedbackType = feedbackType;
                    }
                }

                //数据统计
                ProcessDamageStatistics(contexts, gameRule, srcPlayer, playerEntity, damage);
            }

            //击杀|击倒
            if (null != gameRule && playerEntity.gamePlay.IsDead())
            {
                gameRule.KillPlayer(srcPlayer, playerEntity, damage);
            }

            _logger.DebugFormat("change player hp entityId:{0}, health {1}->{2}, state {3}, srcPlayerId:{4}, playerId:{5}, hurtType:{6}, weaponId:{7}", playerEntity.entityKey.Value.EntityId, curHp, playerEntity.gamePlay.CurHp, playerEntity.gamePlay.LifeState, (srcPlayer != null) ? srcPlayer.playerInfo.PlayerId : 0, playerEntity.playerInfo.PlayerId, damage.type, damage.weaponId);

            return(teamList);
        }
        private void AddNewestHairColour(StatisticsData data)
        {
            string hairColourString = data.HairColors[data.HairColors.Count - 1].ToString().ToLower();

            Helper.ConsoleLog(hairColourString);
            switch (hairColourString)
            {
            case "blond":
                BlondValues.Remove(BlondValues.Count);
                blondCnt++;
                BlondValues.Add(blondCnt);

                BrownValues.Remove(BrownValues.Count);
                BrownValues.Add(brownCnt);
                BlackValues.Remove(BlackValues.Count);
                BlackValues.Add(blackCnt);
                GrayValues.Remove(GrayValues.Count);
                GrayValues.Add(grayCnt);
                RedValues.Remove(RedValues.Count);
                RedValues.Add(redCnt);
                WhiteValues.Remove(WhiteValues.Count);
                WhiteValues.Add(whiteCnt);
                OtherValues.Remove(OtherValues.Count);
                OtherValues.Add(otherCnt);
                break;

            case "brown":
                BrownValues.Remove(BrownValues.Count);
                brownCnt++;
                BrownValues.Add(brownCnt);



                BlondValues.Remove(BlondValues.Count);
                BlondValues.Add(blondCnt);
                BlackValues.Remove(BlackValues.Count);
                BlackValues.Add(blackCnt);
                GrayValues.Remove(GrayValues.Count);
                GrayValues.Add(grayCnt);
                RedValues.Remove(RedValues.Count);
                RedValues.Add(redCnt);
                WhiteValues.Remove(WhiteValues.Count);
                WhiteValues.Add(whiteCnt);
                OtherValues.Remove(OtherValues.Count);
                OtherValues.Add(otherCnt);
                break;

            case "black":
                BlackValues.Remove(BlackValues.Count);
                blackCnt++;
                BlackValues.Add(blackCnt);



                BlondValues.Remove(BlondValues.Count);
                BlondValues.Add(blondCnt);
                BrownValues.Remove(BrownValues.Count);
                BrownValues.Add(brownCnt);
                GrayValues.Remove(GrayValues.Count);
                GrayValues.Add(grayCnt);
                RedValues.Remove(RedValues.Count);
                RedValues.Add(redCnt);
                WhiteValues.Remove(WhiteValues.Count);
                WhiteValues.Add(whiteCnt);
                OtherValues.Remove(OtherValues.Count);
                OtherValues.Add(otherCnt);
                break;

            case "gray":
                GrayValues.Remove(GrayValues.Count);
                grayCnt++;
                GrayValues.Add(grayCnt);



                BlondValues.Remove(BlondValues.Count);
                BlondValues.Add(blondCnt);
                BlackValues.Remove(BlackValues.Count);
                BlackValues.Add(blackCnt);
                BrownValues.Remove(BrownValues.Count);
                BrownValues.Add(brownCnt);
                RedValues.Remove(RedValues.Count);
                RedValues.Add(redCnt);
                WhiteValues.Remove(WhiteValues.Count);
                WhiteValues.Add(whiteCnt);
                OtherValues.Remove(OtherValues.Count);
                OtherValues.Add(otherCnt);
                break;

            case "red":
                RedValues.Remove(RedValues.Count);
                redCnt++;
                RedValues.Add(redCnt);


                BlondValues.Remove(BlondValues.Count);
                BlondValues.Add(blondCnt);
                BlackValues.Remove(BlackValues.Count);
                BlackValues.Add(blackCnt);
                GrayValues.Remove(GrayValues.Count);
                GrayValues.Add(grayCnt);
                BrownValues.Remove(BrownValues.Count);
                BrownValues.Add(brownCnt);
                WhiteValues.Remove(WhiteValues.Count);
                WhiteValues.Add(whiteCnt);
                OtherValues.Remove(OtherValues.Count);
                OtherValues.Add(otherCnt);
                break;

            case "white":
                WhiteValues.Remove(WhiteValues.Count);
                whiteCnt++;
                WhiteValues.Add(whiteCnt);



                BlondValues.Remove(BlondValues.Count);
                BlondValues.Add(blondCnt);
                BlackValues.Remove(BlackValues.Count);
                BlackValues.Add(blackCnt);
                GrayValues.Remove(GrayValues.Count);
                GrayValues.Add(grayCnt);
                RedValues.Remove(RedValues.Count);
                RedValues.Add(redCnt);
                BrownValues.Remove(BrownValues.Count);
                BrownValues.Add(brownCnt);
                OtherValues.Remove(OtherValues.Count);
                OtherValues.Add(otherCnt);
                break;

            default:
                OtherValues.Remove(OtherValues.Count);
                otherCnt++;
                OtherValues.Add(otherCnt);



                BlondValues.Remove(BlondValues.Count);
                BlondValues.Add(blondCnt);
                BlackValues.Remove(BlackValues.Count);
                BlackValues.Add(blackCnt);
                GrayValues.Remove(GrayValues.Count);
                GrayValues.Add(grayCnt);
                RedValues.Remove(RedValues.Count);
                RedValues.Add(redCnt);
                WhiteValues.Remove(WhiteValues.Count);
                WhiteValues.Add(whiteCnt);
                BrownValues.Remove(BrownValues.Count);
                BrownValues.Add(brownCnt);
                break;
            }
        }
        private static List <PlayerEntity> OnePlayerHealthDamage(Contexts contexts, IGameRule gameRule, PlayerEntity srcPlayer, PlayerEntity playerEntity, PlayerDamageInfo damage, bool isTeam)
        {
            GamePlayComponent gamePlay = playerEntity.gamePlay;

            if (gamePlay.IsDead())
            {
                return(null);
            }

            float realDamage = gameRule == null ? damage.damage : gameRule.HandleDamage(srcPlayer, playerEntity, damage);

            WeaponResConfigItem weaponConfig = SingletonManager.Get <WeaponResourceConfigManager>().GetConfigById(damage.weaponId);

            if (srcPlayer != null)
            {
                try
                {
                    //受伤梯形标记
                    if (SharedConfig.IsServer)
                    {
                        if (damage.type == (int)EUIDeadType.Weapon || damage.type == (int)EUIDeadType.Unarmed)
                        {
                            if (weaponConfig != null && weaponConfig.SubType != (int)EWeaponSubType.Grenade)
                            {
                                BulletStatisticsUtil.SetPlayerDamageInfoS(srcPlayer, playerEntity, realDamage, (EBodyPart)damage.part);
                            }
                        }
                    }
                    else
                    {
                        BulletStatisticsUtil.SetPlayerDamageInfoC(srcPlayer, playerEntity, realDamage, (EBodyPart)damage.part);
                    }
                }
                catch (Exception e)
                {
                    _logger.Error("受伤梯形标记", e);
                }
            }

            if (!SharedConfig.IsOffline && !SharedConfig.IsServer)
            {
                return(null);
            }

            if (!playerEntity.hasStatisticsData)
            {
                return(null);
            }

            StatisticsData statisticsData = playerEntity.statisticsData.Statistics;


            var now = gameRule == null ? playerEntity.time.ClientTime : gameRule.ServerTime;

            if (now - statisticsData.LastHitDownTime <= 1000 && !damage.InstantDeath)
            {
                return(null);
            }

            damage.damage = gamePlay.DecreaseHp(realDamage);

            //玩家状态
            List <PlayerEntity> teamList = CheckUpdatePlayerStatus(playerEntity, damage, isTeam ? null : contexts, (int)now);

            //保存最后伤害来源
            if (statisticsData.DataCollectSwitch)
            {
                try
                {
                    if (gamePlay.IsLastLifeState(EPlayerLifeState.Alive))
                    {
                        //statisticsData.IsHited = true;
                        statisticsData.LastHurtKey      = null != srcPlayer ? srcPlayer.entityKey.Value : EntityKey.Default;
                        statisticsData.LastHurtType     = damage.type;
                        statisticsData.LastHurtPart     = damage.part;
                        statisticsData.LastHurtWeaponId = damage.weaponId;
                    }

                    //击倒人头
                    if ((gamePlay.IsLifeState(EPlayerLifeState.Dying) || gamePlay.IsDead()) &&
                        (damage.type == (int)EUIDeadType.NoHelp || damage.type == (int)EUIDeadType.Poison || damage.type == (int)EUIDeadType.Bomb ||
                         damage.type == (int)EUIDeadType.Drown || damage.type == (int)EUIDeadType.Bombing || damage.type == (int)EUIDeadType.Fall))
                    {
                        PlayerEntity lastEntity = contexts.player.GetEntityWithEntityKey(statisticsData.LastHurtKey);
                        if (null != lastEntity)
                        {
                            srcPlayer = lastEntity;
                            if (srcPlayer.playerInfo.TeamId == playerEntity.playerInfo.TeamId)
                            {
                                damage.type     = statisticsData.LastHurtType;
                                damage.part     = statisticsData.LastHurtPart;
                                damage.weaponId = statisticsData.LastHurtWeaponId;
                            }
                            else
                            {
                                damage.type = (int)EUIDeadType.NoHelp;
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    _logger.Error("计算玩家战报信息失败", e);
                }

                if (gamePlay.IsHitDown())
                {
                    try
                    {
                        statisticsData.LastHitDownTime = now;
                        SimpleProto message = FreePool.Allocate();
                        message.Key = FreeMessageConstant.ScoreInfo;
                        int feedbackType = 0;
                        message.Ks.Add(3);
                        message.Bs.Add(true);
                        if (null != srcPlayer)
                        {
                            if (srcPlayer.playerInfo.TeamId != playerEntity.playerInfo.TeamId)
                            {
                                feedbackType |= 1 << (int)EUIKillFeedbackType.Hit;
                            }
                            message.Ss.Add(srcPlayer.playerInfo.PlayerName);
                            message.Ds.Add(srcPlayer.playerInfo.TeamId);
                            message.Ins.Add(damage.weaponId);
                        }
                        else
                        {
                            message.Ss.Add("");
                            message.Ds.Add(-1);
                            message.Ins.Add(0);
                        }
                        message.Ins.Add((int)EUIKillType.Hit);
                        message.Ins.Add(feedbackType);
                        message.Ss.Add(playerEntity.playerInfo.PlayerName);
                        message.Ds.Add(playerEntity.playerInfo.TeamId);
                        message.Ins.Add(damage.type);
                        SendMessageAction.sender.SendMessage(contexts.session.commonSession.FreeArgs as IEventArgs, message, 4, string.Empty);
                    }
                    catch (Exception e)
                    {
                        _logger.Error("计算玩家ScoreInfo信息失败", e);
                    }
                }

                if (gamePlay.IsDead())
                {
                    try
                    {
                        //UI击杀信息
                        int killType = 0;
                        if (damage.part == (int)EBodyPart.Head)
                        {
                            killType |= (int)EUIKillType.Crit;
                        }
                        damage.KillType = killType;
                        playerEntity.playerInfo.SpecialFeedbackType = 0;
                        //UI击杀反馈
                        if (null != srcPlayer && srcPlayer.playerInfo.TeamId != playerEntity.playerInfo.TeamId)
                        {
                            int feedbackType = 0;
                            if (damage.part == (int)EBodyPart.Head)
                            {
                                //爆头
                                feedbackType |= 1 << (int)EUIKillFeedbackType.CritKill;
                            }
                            if (damage.IsOverWall)
                            {
                                //穿墙击杀
                                feedbackType |= 1 << (int)EUIKillFeedbackType.ThroughWall;
                            }
                            if (SharedConfig.IsServer && null != gameRule && contexts.session.serverSessionObjects.DeathOrder == 0 && srcPlayer.playerInfo.TeamId != playerEntity.playerInfo.TeamId)
                            {
                                //一血
                                feedbackType |= 1 << (int)EUIKillFeedbackType.FirstBlood;
                            }
                            if (playerEntity.playerInfo.PlayerId == srcPlayer.statisticsData.Statistics.RevengeKillerId)
                            {
                                //复仇
                                feedbackType |= 1 << (int)EUIKillFeedbackType.Revenge;
                                srcPlayer.statisticsData.Statistics.RevengeKillerId = 0L;
                            }
                            if (srcPlayer.gamePlay.JobAttribute == (int)EJobAttribute.EJob_Hero)
                            {
                                //英雄击杀
                                feedbackType |= 1 << (int)EUIKillFeedbackType.HeroKO;
                                playerEntity.playerInfo.SpecialFeedbackType = (int)EUIKillFeedbackType.HeroKO;
                            }
                            //武器
                            if (null != weaponConfig)
                            {
                                switch ((EWeaponSubType)weaponConfig.SubType)
                                {
                                case EWeaponSubType.Melee:
                                    feedbackType |= 1 << (int)EUIKillFeedbackType.MeleeWeapon;
                                    playerEntity.playerInfo.SpecialFeedbackType = (int)EUIKillFeedbackType.MeleeWeapon;
                                    break;

                                case EWeaponSubType.BurnBomb:
                                    feedbackType |= 1 << (int)EUIKillFeedbackType.Burning;
                                    break;

                                case EWeaponSubType.Grenade:
                                    feedbackType |= 1 << (int)EUIKillFeedbackType.Grenade;
                                    break;

                                default:
                                    break;
                                }
                            }
                            if (feedbackType == 0)
                            {
                                //普通击杀
                                feedbackType = 1 << (int)EUIKillFeedbackType.Normal;
                            }
                            damage.KillFeedbackType = feedbackType;
                        }
                    }
                    catch (Exception e)
                    {
                        _logger.Error("计算玩家战报信息失败", e);
                    }
                }

                //数据统计
                ProcessDamageStatistics(contexts, gameRule, srcPlayer, playerEntity, damage);
            }

            //击杀|击倒
            if (gamePlay.IsDead())
            {
                gameRule.KillPlayer(srcPlayer, playerEntity, damage);
                try
                {
                    if (damage.HitPoint != Vector3.zero && damage.HitDirection != Vector3.zero && playerEntity.hasRagDoll)
                    {
                        playerEntity.ragDoll.ForceAtPosition = Vector3.zero;
                        switch (damage.type)
                        {
                        case (int)EUIDeadType.Weapon:
                            var config = SingletonManager.Get <WeaponConfigManagement>().FindConfigById(damage.weaponId);
                            if (weaponConfig.Type == (int)EWeaponType_Config.ThrowWeapon)
                            {
                                playerEntity.ragDoll.RigidBodyTransformName = "Bip01 Spine1";
                                playerEntity.ragDoll.Impulse = (damage.HitDirection.normalized + new Vector3(0, 1.732f)).normalized *
                                                               config.S_Ragdoll.RagdollForce * DamageFactor(realDamage);
                            }
                            else
                            {
                                foreach (var pair in Joint2BodyPart)
                                {
                                    if (pair.Value == (EBodyPart)damage.part)
                                    {
                                        playerEntity.ragDoll.RigidBodyTransformName = pair.Key.Substring(0, pair.Key.LastIndexOf("_"));
                                        break;
                                    }
                                }

                                playerEntity.ragDoll.Impulse = damage.HitDirection.normalized * config.S_Ragdoll.RagdollForce *
                                                               DamageFactor(realDamage);
                            }

                            break;

                        default:
                            var explosionConfig = SingletonManager.Get <WeaponConfigManagement>().FindConfigById(46);
                            playerEntity.ragDoll.RigidBodyTransformName = "Bip01 Spine1";
                            playerEntity.ragDoll.Impulse = (damage.HitDirection.normalized + new Vector3(0, 1.732f)).normalized *
                                                           explosionConfig.S_Ragdoll.RagdollForce * DamageFactor(realDamage);
                            break;
                        }
                    }
                }
                catch (Exception e)
                {
                    _logger.Error("计算玩家死亡ragdoll运动信息失败", e);
                }
            }

            //_logger.DebugFormat("change player hp entityId:{0}, health {1}->{2}, state {3}, srcPlayerId:{4}, playerId:{5}, hurtType:{6}, weaponId:{7}",
            //    playerEntity.entityKey.Value.EntityId, playerEntity.gamePlay.CurHp, playerEntity.gamePlay.CurHp, playerEntity.gamePlay.LifeState, (srcPlayer != null) ? srcPlayer.playerInfo.PlayerId : 0, playerEntity.playerInfo.PlayerId, damage.type, damage.weaponId);
            return(teamList);
        }
Beispiel #27
0
        public static async Task <int> CallStatisticsService()
        {
            var service = new StatisticsClient();

            var header = new MessageHeader()
            {
                MessageID           = "101",
                TransactionID       = "101",
                SenderID            = "101",
                SenderApplication   = "Debug",
                ReceiverID          = "101",
                ReceiverApplication = "Effica",
                CharacterSet        = "UTF-16"
            };

            var common = new LisCommon()
            {
                ContractKey   = ContractKey,
                UserId        = UserId,
                CallingSystem = CallingSystem,
                CallingUserId = UserId
            };

            // Initialize Request
            var req = new CommonRequestData()
            {
                Area = new Code()
                {
                    CodeSetName = "Effica/Lifecare", CodeValue = "Kkesk"
                },                                                                          // Department ID
                ContactAuthor = new ContactAuthor()
                {
                    ContactAuthorCodeId = CaCodeId.EfficaUserId, ContactAuthorCode = UserId
                }
                // FunctionType = new Code() { CodeSetName = "Effica/Lifecare", CodeValue = "08" } // Optional
            };

            var commonStats = new CommonStatisticsData()
            {
                /*
                 * EventType = new EventType()
                 * {
                 *  Event="ADD", // ADD/MOD/DEL
                 *  PatientId = new PatientId() { Identifier = "010101-0101" },
                 *  StartDateTime = DateTime.Now,
                 *  UserId = UserId
                 * }
                 */
            };

            var StatsData = new StatisticsData()
            {
                PatientId = new PatientId()
                {
                    Identifier = "010101-0101"
                },
                UserId = UserId,
                Area   = new Code()
                {
                    CodeSetName = "Effica/Lifecare", CodeValue = "Kkesk"
                },
                RequestArea = new Code()
                {
                    CodeSetName = "Effica/Lifecare", CodeValue = "Kkesk"
                },
                Function = new Code()
                {
                    CodeSetName = "Effica/Lifecare", CodeValue = "kotih"
                },
                ContactType = new Code()
                {
                    CodeSetName = "Effica/Lifecare", CodeValue = "1"
                },                                                                             // 1 = doctor appointment, 2 = home visit
                VisitType = new Code()
                {
                    CodeSetName = "Effica/Lifecare", CodeValue = "2"
                },                                                                           // Visit type data as numeral value, E.g 1 = first time visit 2= revisit
                ContentNotes = new ContentNote[] { new ContentNote()
                                                   {
                                                       Content = "INFL1", Amount = 1
                                                   } },                                               // Content note for Influenza flue shot
                ProcedureClasses = new Code[] { new Code()
                                                {
                                                    CodeSetName = "", CodeValue = "SPAT1009"
                                                } },                                                       // SPAT codes, see coding in "koodistopalvelu", http://koodistopalvelu.kanta.fi/codeserver/pages/classification-view-page.xhtml?classificationKey=310&versionKey=387
                StartDateTime = DateTime.Now.AddDays(-1.0),
                EndDateTime   = DateTime.Now,
                VisitUrgency  = new Code()
                {
                    CodeSetName = "Effica/Lifecare", CodeValue = "E"
                },                                                                              // E - No, K - Yes
                IsFirstVisit = new Code()
                {
                    CodeSetName = "Effica/Lifecare", CodeValue = "E"
                },                                                                               // E - No, K - Yes
                FollowUpCares = new Code[] { new Code()
                                             {
                                                 CodeSetName = "", CodeValue = "SPAT1334"
                                             } },                                                       // SPAT codes (SPAT1334 no follow-up actions)
                VisitReasons = new Code[] { new Code()
                                            {
                                                CodeSetName = "Effica/Lifecare", CodeValue = "A25"
                                            } }                                                                 // ICPC2 code
            };

            var GenericStats = new GenericStatData()
            {
            };                                           // Not in use

            // Structure for return data
            var rsp = new StatisticsOperation();

            try
            {
                service.AddStatistics(ref header, common, req, commonStats, StatsData, GenericStats, out rsp);
            }
            catch (Exception e)
            {
                Debug.Write(e.Message);
            }

            return(0);
        }
Beispiel #28
0
 private void Start()
 {
     data = new Saver <StatisticsData>().GetData();
     Show();
 }
        private void Timer_Tick(object sender, EventArgs e)
        {
            statisticsData = _calculateStatistics();

            // PSC Failed or Succeed Chart
            pscFailSuccChart.Add(new StatisticsModel()
            {
                Category = "Failed", Number = statisticsData?.PscFailedBags?.Count ?? 0
            });
            pscFailSuccChart.Add(new StatisticsModel()
            {
                Category = "Succeeded", Number = statisticsData?.PscSucceededBags?.Count ?? 0
            });

            // ASC Failed or Succeed Chart
            ascFailSuccChart.Add(new StatisticsModel()
            {
                Category = "Failed", Number = statisticsData?.AscFailedBags?.Count ?? 0
            });
            ascFailSuccChart.Add(new StatisticsModel()
            {
                Category = "Succeeded", Number = statisticsData?.AscSucceededBags?.Count ?? 0
            });

            // Overall Security Chart
            overalPercSecurityChart.Add(new StatisticsModel()
            {
                Category = "Advanced", Number = (float)statisticsData.AscInvalidationPercentage
            });
            overalPercSecurityChart.Add(new StatisticsModel()
            {
                Category = "Primary", Number = (float)statisticsData.PscInvalidationPercentage
            });

            // Total Bags at BSU
            totalBsuChart.Add(new StatisticsModel()
            {
                Category = "Total Bags That Went To BSU", Number = statisticsData?.TotalBagsThatWentToBsu?.Count ?? 0
            });

            // Total Transfer Bags
            totalTransferBags.Add(new StatisticsModel()
            {
                Category = "Total Transferred Bags", Number = statisticsData?.TotalTransferredBags?.Count ?? 0
            });

            // Total Delays at Airport Security
            delaysAtAaChart.Add(new StatisticsModel()
            {
                Category = "Delays per Flight", Number = statisticsData?.TotalBagsArrivedLateAtAa?.Count ?? 0
            });

            //Collected Bags
            //collectedBags.Add(new StatisticsModel() { Category = "First", Number = Convert.ToInt32(statisticsData?.FirstCollectedBag?.Log?.FirstOrDefault()) });
            collectedBags.Add(new StatisticsModel()
            {
                Category = "First", Number = Convert.ToInt32(statisticsData?.FirstCollectedBag)
            });
            collectedBags.Add(new StatisticsModel()
            {
                Category = "Last", Number = Convert.ToInt32(statisticsData?.LastCollectedBag)
            });

            //Dispatched Bags
            dispatchedBags.Add(new StatisticsModel()
            {
                Category = "First", Number = Convert.ToInt32(statisticsData?.FirstDispatchedBag?.Log?.FirstOrDefault()?.LogCreated.TotalSeconds)
            });
            dispatchedBags.Add(new StatisticsModel()
            {
                Category = "Last", Number = Convert.ToInt32(statisticsData?.LastDispatchedBag?.Log?.LastOrDefault()?.LogCreated.TotalSeconds)
            });


            //BSU Stay Time

            bsuStayTimeChart.Add(new StatisticsModel()
            {
                Category = "Average", Number = (float)statisticsData?.AverageBsuStayTimeInSeconds
            });
            bsuStayTimeChart.Add(new StatisticsModel()
            {
                Category = "Max", Number = (float)statisticsData?.MaxBsuStayTimeInSeconds
            });
            bsuStayTimeChart.Add(new StatisticsModel()
            {
                Category = "Min", Number = (float)statisticsData?.MinBsuStayTimeInSeconds
            });


            //System Stay Without BSU.
            noBsuChart.Add(new StatisticsModel()
            {
                Category = "Longest", Number = (float)statisticsData?.LongestSystemStayWithoutBsu
            });
            noBsuChart.Add(new StatisticsModel()
            {
                Category = "Shortest", Number = (float)statisticsData?.ShortestSystemStayWithoutBsu
            });

            transportingTimeChart.Add(new StatisticsModel()
            {
                Category = "Shortest", Number = (float)statisticsData?.ShortestTransportingTime
            });
            transportingTimeChart.Add(new StatisticsModel()
            {
                Category = "Longest", Number = (float)statisticsData?.LongestTransportingTime
            });


            //foreach (var flight in Series)
            //{
            //    totalBsuChart.Add(new StatisticsModel() { Category = flight.Key.FlightNumber, Number = (float)flight.Value });
            //}
        }