示例#1
0
        public BasicResponse <List <ShowDataInfo> > GetReleaseAlarmRecords(GetReleaseAlarmRecordsRequest alarmRequest)
        {
            var response = new BasicResponse <List <ShowDataInfo> >();
            var runLogCacheGetAllRequest  = new RunLogCacheGetAllRequest();
            var runLogCacheGetAllResponse = runLogCacheService.GetAllRunLogCache(runLogCacheGetAllRequest);
            //var pointDefineCacheGetAllRequest = new PointDefineCacheGetAllRequest();
            var pointDefineCacheGetAllResponse = pointDefineCacheService.GetAllPointDefineCache();//从多系统缓存中查找  20171213

            if (runLogCacheGetAllResponse.Data != null && runLogCacheGetAllResponse.Data.Count > 0)
            {
                //跨天0点的记录不查询
                var listR    = runLogCacheGetAllResponse.Data.Where(a => a.Counter > alarmRequest.Id && a.Timer > DateTime.Parse(DateTime.Now.ToShortDateString() + " 00:00:00")).ToList();
                var listData = new List <ShowDataInfo>();
                try
                {
                    foreach (var item in listR)
                    {
                        if (item.Point == "000000")
                        {
                            continue;
                        }
                        ShowDataInfo sd      = new ShowDataInfo();
                        var          defInfo = pointDefineCacheGetAllResponse.Data.Find(x => x.Point == item.Point && x.Wzid == item.Wzid && x.Devid == item.Devid);
                        if (defInfo == null)
                        {
                            continue;
                        }
                        sd.ID       = long.Parse(item.ID);
                        sd.Counter  = item.Counter;
                        sd.Fzh      = item.Fzh;
                        sd.Kh       = item.Kh;
                        sd.Devid    = item.Devid;
                        sd.Wzid     = item.Wzid;
                        sd.Property = defInfo.DevPropertyID;
                        sd.Class    = defInfo.DevClassID;
                        sd.Type     = item.Type;
                        sd.Point    = item.Point;
                        sd.Devname  = defInfo.DevName;
                        sd.Wz       = defInfo.Wz;
                        sd.Ssz      = item.Val;
                        sd.Unit     = defInfo.Unit;
                        sd.State    = item.State;
                        sd.Timer    = item.Timer;
                        sd.Flag     = 0;
                        listData.Add(sd);
                    }
                    response.Data = listData;
                }
                catch (Exception ex)
                {
                    response.Code    = -100;
                    response.Message = ex.Message;
                    this.ThrowException("GetReleaseAlarmRecords-发生异常", ex);;
                }
            }

            return(response);
        }
示例#2
0
        protected override void DoWork()
        {
            var runlogResponse = runLogCacheService.GetAllRunLogCache(new RunLogCacheGetAllRequest());

            if (runlogResponse.IsSuccess && runlogResponse.Data != null)
            {
                var runlogItems = runlogResponse.Data;

                var count = runlogItems.Count - _delayCounter;
                if (count > 0)
                {
                    var cleanItems = runlogItems.OrderBy(runlog => runlog.Counter).Take(count).ToList();
                    RunLogBatchDeleteRequest deleteRequest = new RunLogBatchDeleteRequest
                    {
                        RunLogInfos = cleanItems
                    };
                    runLogCacheService.BatchDeleteRunLogCache(deleteRequest);
                }
            }
            base.DoWork();
        }