コード例 #1
0
        public ActionResult GetEmployeeCounts()
        {
            ReportManager    manager = new ReportManager();
            List <CounterBO> list    = manager.GetBarChartData();
            CounterVO        vo      = fillCounter(list);
            JsonResult       json    = Json(vo);

            json.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            return(json);
        }
コード例 #2
0
        private CounterVO fillCounter(List <CounterBO> list)
        {
            CounterVO vo = new CounterVO();

            vo.Data     = new decimal[list.Count];
            vo.DataAxis = new string[list.Count];
            for (int i = 0; i < list.Count; i++)
            {
                CounterBO bo = list[i];
                vo.Data[i]     = bo.Data;
                vo.DataAxis[i] = bo.DataAxis;
            }

            return(vo);
        }
コード例 #3
0
        private void Counter()
        {
            _counterVOs.Clear();

            // 1. 获取Damage计算结果,找到时间片>1的第一个时间点
            foreach (DamageVO damageVO in _returnDamageVOs)
            {
                // 只要井和车
                if (damageVO.platform != "发射井" && damageVO.platform != "发射车")
                {
                    continue;
                }

                StatusTimeRangesVO statusTime = damageVO.statusTimeRanges.Where(it => it.Status > 1).FirstOrDefault();
                if (statusTime != null)
                {
                    long     startTimeUtc   = (long)statusTime.StartTimeUtc;
                    DateTime?dt             = MyCore.Utils.DataTimeUtil.ToDateTime(startTimeUtc);
                    DateTime?dt0            = null;
                    double   prepareTimeUtc = 0;

                    if (dt != null)
                    {
                        dt0 = dt.Value.AddSeconds(-damageVO.prepareTime);

                        //prepareTimeUtc = DataTimeUtil.ToTimestamp(dt0.Value,false);
                        // 不要基于毫秒算,用秒
                        prepareTimeUtc = startTimeUtc - damageVO.prepareTime;

                        CounterVO counter = new CounterVO();
                        counter.launchUnitInfo = damageVO.launchUnitInfo;
                        counter.timeRanges.Add(new TimeRange(0, prepareTimeUtc, 0));
                        counter.timeRanges.Add(new TimeRange(prepareTimeUtc, startTimeUtc, 1));
                        counter.timeRanges.Add(new TimeRange(startTimeUtc, MyCore.Utils.Const.TimestampMax, 2));
                        counter.nonce    = Guid.NewGuid().ToString();
                        counter.name     = damageVO.name;                                        //2020-10-11
                        counter.useState = damageVO.useState == null ? "未知" : damageVO.useState; //2020-10-13


                        _counterVOs.Add(counter);
                    }
                }
                else
                {
                    // 没有收到打击
                    CounterVO counter = new CounterVO();
                    counter.launchUnitInfo = damageVO.launchUnitInfo;
                    counter.timeRanges.Add(new TimeRange(0, MyCore.Utils.Const.TimestampMax, 0));
                    counter.nonce    = Guid.NewGuid().ToString();
                    counter.name     = damageVO.name;                                        //2020-10-11
                    counter.useState = damageVO.useState == null ? "未知" : damageVO.useState; //2020-10-13

                    _counterVOs.Add(counter);
                }
            }
            // 判断“counters”与“_reallyCounters”的“timeRanges”是否有变化?
            if (_counterVOs.Count() == _returnCounterVOs.Count())
            {
                for (int i = 0; i < _counterVOs.Count(); i++)
                {
                    CounterVO previousCounterVO = _returnCounterVOs[i];
                    CounterVO currentCounterVO  = _counterVOs[i];

                    // 如果没有变化,把上一次的nonce值赋给这次的
                    if (previousCounterVO.Equals(currentCounterVO))
                    {
                        currentCounterVO.nonce = previousCounterVO.nonce;
                    }
                }
            }

            lock (_counterLocker)//锁
            {
                _returnCounterVOs = Clone(_counterVOs);
            }
        }