public BasicResponse <List <EnumcodeInfo> > GetMasterTriDataStateByAssId(LongIdRequest request)
        {
            var req3                  = new EmergencyLinkageConfigCacheGetAllRequest();
            var res3                  = _sysEmergencyLinkageCacheService.GetAllSysEmergencyLinkageCache(req3);
            var linkageInfo           = res3.Data.FirstOrDefault(a => a.MasterTriDataStateAssId == request.Id.ToString());
            var masterTriDataStateAss = linkageInfo == null ? new List <EmergencyLinkageMasterTriDataStateAssInfo>() : linkageInfo.MasterTriDataStates;

            var req = new EnumcodeGetByEnumTypeIDRequest()
            {
                EnumTypeId = 4.ToString()
            };
            var res = _enumcodeService.GetEnumcodeByEnumTypeID(req);

            if (res.Code != 100)
            {
                throw new Exception(res.Message);
            }

            var allDataState = res.Data;
            //var allMasterTriDataStateAss = _emergencyLinkageMasterTriDataStateAssRepository.Datas.ToList();

            var res2 = from a in masterTriDataStateAss
                       join b in allDataState on a.DataStateId equals b.LngEnumValue.ToString() into temp
                       from ab in temp.DefaultIfEmpty()
                       //where a.MasterTriDataStateAssId == request.Id.ToString()
                       select ab;

            var retLis = res2.ToList();
            var ret    = new BasicResponse <List <EnumcodeInfo> >()
            {
                Data = retLis
            };

            return(ret);
        }
        public static IList <EnumcodeInfo> GetListEnumState()
        {
            IList <EnumcodeInfo> list = null;

            try
            {
                if (ClientAlarmConfig.getsererconnectstate())
                {
                    var request = new EnumcodeGetByEnumTypeIDRequest()
                    {
                        EnumTypeId = "4"
                    };
                    var response = enumcodeService.GetEnumcodeByEnumTypeID(request);
                    if (response.Data != null)
                    {
                        list = response.Data;
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex);
            }
            return(list);
        }
Beispiel #3
0
        /// <summary>
        /// 获枚举
        /// </summary>
        /// <returns></returns>
        public static List <EnumcodeInfo> GetEnum(long enumTypeId)
        {
            var req = new EnumcodeGetByEnumTypeIDRequest
            {
                EnumTypeId = enumTypeId.ToString()
            };
            var res = EnumcodeService.GetEnumcodeByEnumTypeID(req);

            if (!res.IsSuccess)
            {
                throw new Exception(res.Message);
            }

            var data = res.Data.OrderBy(a => a.LngRowIndex);

            return(data.ToList());
        }
Beispiel #4
0
 public BasicResponse <List <EnumcodeInfo> > GetEnumcodeByEnumTypeID(EnumcodeGetByEnumTypeIDRequest enumcoderequest)
 {
     return(_enumcodeService.GetEnumcodeByEnumTypeID(enumcoderequest));
 }
Beispiel #5
0
        private void GetCalibrationDue()
        {
            try
            {
                List <EnumcodeInfo>            enumcodeInfos = new List <EnumcodeInfo>();
                EnumcodeInfo                   enumcodeInfo;
                EnumcodeGetByEnumTypeIDRequest enumcoderequest = new EnumcodeGetByEnumTypeIDRequest();
                enumcoderequest.EnumTypeId = "3";
                var result = enumcodeService.GetEnumcodeByEnumTypeID(enumcoderequest);
                if (result.IsSuccess & result.Data != null)
                {
                    enumcodeInfos = result.Data;
                }


                //获取设备类型及测点定义基础数据
                if (deviceDefineList.Count == 0 || bIsDevChange())
                {
                    deviceDefineList = deviceDefineService.GetAllDeviceDefineCache().Data;
                    pointDefineList  = pointDefineService.GetAllPointDefineCache().Data;
                }
                GetRealDataRequest request = new GetRealDataRequest();
                realDataList = realMessageService.GetRealData(request).Data;

                //标效及传感器到期提醒

                //查询近90天内的标效记录(统计前一天,及之前90天的记录)
                DateTime  startTime         = DateTime.Parse(DateTime.Now.AddDays(-91).ToShortDateString());
                DateTime  endTime           = DateTime.Parse(DateTime.Now.ToShortDateString() + " 23:59:59");
                DataTable calibrationRecord = ClientAlarmServer.GetCalibrationRecord(startTime, endTime);
                //按设备类型循环获取未标校、到期的传感器数量
                int NoCalibrationCount = 0;
                int DueCount           = 0;
                foreach (Jc_DevInfo dev in deviceDefineList)
                {
                    //2018.5.9 by AI
                    enumcodeInfo = enumcodeInfos.FirstOrDefault(a => a.LngEnumValue == dev.Bz4);
                    if (enumcodeInfo == null)
                    {
                        //LogHelper.Error("【GetCalibrationDue】枚举中未找到设备:" + dev.Bz4);
                        continue;
                    }
                    int tempCalibrationTime = 0;
                    int.TryParse(dev.Pl4.ToString(), out tempCalibrationTime);//标校周期
                    List <Jc_DefInfo> pointList = pointDefineList.FindAll(a => a.Devid == dev.Devid);
                    if (tempCalibrationTime > 0)
                    {
                        #region 标效周期报警
                        //计算当前设备类型下面的传感器是否到标效期
                        foreach (Jc_DefInfo def in pointList)
                        {
                            DataRow[] dr = calibrationRecord.Select("point='" + def.Point + "' and stime<='" + endTime + "'", "stime desc");
                            if (dr.Length > 0)
                            {
                                TimeSpan ts = endTime - DateTime.Parse(dr[0]["stime"].ToString());
                                if ((int)ts.TotalDays >= tempCalibrationTime)//如果上一次标校记录时间超过了设置的标校时间周期,则记入未标校数量
                                {
                                    NoCalibrationCount++;

                                    SensorCalibrationInfo tempSensorCalibrationInfo = new SensorCalibrationInfo();
                                    tempSensorCalibrationInfo.Point               = def.Point;
                                    tempSensorCalibrationInfo.Position            = def.Wz;
                                    tempSensorCalibrationInfo.DevName             = def.DevName;
                                    tempSensorCalibrationInfo.SetCalibrationTime  = tempCalibrationTime.ToString();
                                    tempSensorCalibrationInfo.LastCalibrationTime = dr[0]["stime"].ToString();
                                    tempSensorCalibrationInfo.CalibrationDays     = ((int)(ts.TotalDays)).ToString();
                                    tempSensorCalibrationInfo.id      = dr[0]["id"].ToString();
                                    tempSensorCalibrationInfo.pointid = def.PointID;
                                    if (ClientAlarmServer.sensorCalibrationInfoList.Find(a => a.Point == tempSensorCalibrationInfo.Point) == null)
                                    {
                                        ClientAlarmServer.sensorCalibrationInfoList.Add(tempSensorCalibrationInfo);
                                    }
                                }
                                else
                                {
                                    int index = ClientAlarmServer.sensorCalibrationInfoList.FindIndex(a => a.Point == def.Point);
                                    if (index >= 0)
                                    {
                                        ClientAlarmServer.sensorCalibrationInfoList.RemoveAt(index);
                                    }
                                }
                            }
                            else//未找到标校记录,则直接记入未标校
                            {
                                NoCalibrationCount++;

                                SensorCalibrationInfo tempSensorCalibrationInfo = new SensorCalibrationInfo();
                                tempSensorCalibrationInfo.Point               = def.Point;
                                tempSensorCalibrationInfo.Position            = def.Wz;
                                tempSensorCalibrationInfo.DevName             = def.DevName;
                                tempSensorCalibrationInfo.SetCalibrationTime  = tempCalibrationTime.ToString();
                                tempSensorCalibrationInfo.LastCalibrationTime = "未记录";
                                tempSensorCalibrationInfo.CalibrationDays     = "-";
                                tempSensorCalibrationInfo.pointid             = def.PointID;
                                //tempSensorCalibrationInfo.id = dr[0]["id"].ToString();
                                if (ClientAlarmServer.sensorCalibrationInfoList.Find(a => a.Point == tempSensorCalibrationInfo.Point) == null)
                                {
                                    ClientAlarmServer.sensorCalibrationInfoList.Add(tempSensorCalibrationInfo);
                                }
                            }
                        }
                        #endregion
                    }
                }
                //清除已删除的测点
                foreach (SensorCalibrationInfo tempSensorCalibrationInfo in ClientAlarmServer.sensorCalibrationInfoList)
                {
                    if (pointDefineList.FindAll(a => a.Point == tempSensorCalibrationInfo.Point).Count == 0)//如果测点定义缓存中不存在测点,则清除未标校集合中的记录
                    {
                        ClientAlarmServer.sensorCalibrationInfoList.Remove(tempSensorCalibrationInfo);
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex);
            }
        }