Exemplo n.º 1
0
 /// <summary>
 /// 创建人:张辽阔
 /// 创建时间:2016-09-20
 /// 创建记录:初始化缓存
 /// </summary>
 /// <param name="dataContext">增加该参数,防止事务死锁</param>
 private void InitCacheType(iCMSDbContext dataContext = null)
 {
     lock (M_DICT_Lock)
     {
         Dictionary <string, IEnumerable <EntityBase> > Temp_Dict = HttpRuntime.Cache["CacheDICTKey"] as Dictionary <string, IEnumerable <EntityBase> >;
         if (Temp_Dict == null)
         {
             Temp_Dict = new Dictionary <string, IEnumerable <EntityBase> >();
             //连接状态类型
             if (dataContext == null)
             {
                 Temp_Dict[typeof(ConnectStatusType).FullName] = DBServices.GetInstance().ConnectStatusTypeProxy
                                                                 .GetDatas <ConnectStatusType>(p => true, false);
             }
             else
             {
                 Temp_Dict[typeof(ConnectStatusType).FullName] = dataContext.ConnectStatusType
                                                                 .ToList().AsQueryable();
             }
             //设备类型
             if (dataContext == null)
             {
                 Temp_Dict[typeof(DeviceType).FullName] = DBServices.GetInstance().DeviceTypeProxy
                                                          .GetDatas <DeviceType>(p => true, false);
             }
             else
             {
                 Temp_Dict[typeof(DeviceType).FullName] = dataContext.DeviceType
                                                          .ToList().AsQueryable();
             }
             //特征值类型
             if (dataContext == null)
             {
                 Temp_Dict[typeof(EigenValueType).FullName] = DBServices.GetInstance().EigenValueTypeProxy
                                                              .GetDatas <EigenValueType>(p => true, false);
             }
             else
             {
                 Temp_Dict[typeof(EigenValueType).FullName] = dataContext.EigenValueType
                                                              .ToList().AsQueryable();
             }
             //测量位置监测类型
             if (dataContext == null)
             {
                 Temp_Dict[typeof(MeasureSiteMonitorType).FullName] = DBServices.GetInstance().MeasureSiteMonitorTypeProxy
                                                                      .GetDatas <MeasureSiteMonitorType>(p => true, false);
             }
             else
             {
                 Temp_Dict[typeof(MeasureSiteMonitorType).FullName] = dataContext.MeasureSiteMonitorType
                                                                      .ToList().AsQueryable();
             }
             //测量位置类型
             if (dataContext == null)
             {
                 Temp_Dict[typeof(MeasureSiteType).FullName] = DBServices.GetInstance().MeasureSiteTypeProxy
                                                               .GetDatas <MeasureSiteType>(p => true, false);
             }
             else
             {
                 Temp_Dict[typeof(MeasureSiteType).FullName] = dataContext.MeasureSiteType
                                                               .ToList().AsQueryable();
             }
             //监测树类型
             if (dataContext == null)
             {
                 Temp_Dict[typeof(MonitorTreeType).FullName] = DBServices.GetInstance().MonitorTreeTypeProxy
                                                               .GetDatas <MonitorTreeType>(p => true, false);
             }
             else
             {
                 Temp_Dict[typeof(MonitorTreeType).FullName] = dataContext.MonitorTreeType
                                                               .ToList().AsQueryable();
             }
             //传感器类型
             if (dataContext == null)
             {
                 Temp_Dict[typeof(SensorType).FullName] = DBServices.GetInstance().SensorTypeProxy
                                                          .GetDatas <SensorType>(p => true, false);
             }
             else
             {
                 Temp_Dict[typeof(SensorType).FullName] = dataContext.SensorType
                                                          .ToList().AsQueryable();
             }
             //振动信号类型
             if (dataContext == null)
             {
                 Temp_Dict[typeof(VibratingSingalType).FullName] = DBServices.GetInstance().VibratingSingalTypeProxy
                                                                   .GetDatas <VibratingSingalType>(p => true, false);
             }
             else
             {
                 Temp_Dict[typeof(VibratingSingalType).FullName] = dataContext.VibratingSingalType
                                                                   .ToList().AsQueryable();
             }
             //波形长度数值
             if (dataContext == null)
             {
                 Temp_Dict[typeof(WaveLengthValues).FullName] = DBServices.GetInstance().WaveLengthValuesProxy
                                                                .GetDatas <WaveLengthValues>(p => true, false);
             }
             else
             {
                 Temp_Dict[typeof(WaveLengthValues).FullName] = dataContext.WaveLengthValues
                                                                .ToList().AsQueryable();
             }
             //波形下限频率值
             if (dataContext == null)
             {
                 Temp_Dict[typeof(WaveLowerLimitValues).FullName] = DBServices.GetInstance().WaveLowerLimitValuesProxy
                                                                    .GetDatas <WaveLowerLimitValues>(p => true, false);
             }
             else
             {
                 Temp_Dict[typeof(WaveLowerLimitValues).FullName] = dataContext.WaveLowerLimitValues
                                                                    .ToList().AsQueryable();
             }
             //波形上限频率值
             if (dataContext == null)
             {
                 Temp_Dict[typeof(WaveUpperLimitValues).FullName] = DBServices.GetInstance().WaveUpperLimitValuesProxy
                                                                    .GetDatas <WaveUpperLimitValues>(p => true, false);
             }
             else
             {
                 Temp_Dict[typeof(WaveUpperLimitValues).FullName] = dataContext.WaveUpperLimitValues
                                                                    .ToList().AsQueryable();
             }
             //无线网关类型
             if (dataContext == null)
             {
                 Temp_Dict[typeof(WirelessGatewayType).FullName] = DBServices.GetInstance().WirelessGatewayTypeProxy
                                                                   .GetDatas <WirelessGatewayType>(p => true, false);
             }
             else
             {
                 Temp_Dict[typeof(WirelessGatewayType).FullName] = dataContext.WirelessGatewayType
                                                                   .ToList().AsQueryable();
             }
             HttpRuntime.Cache["CacheDICTKey"] = Temp_Dict;
         }
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// 更新缓存
 /// </summary>
 /// <param name="dataContext">增加该参数,防止事务死锁</param>
 public void UpdateCacheType <TEntity>(iCMSDbContext dataContext = null) where TEntity : EntityBase
 {
     lock (M_DICT_Lock)
     {
         //连接状态类型
         if (typeof(TEntity) == typeof(ConnectStatusType))
         {
             if (dataContext == null)
             {
                 UpdateCacheType <ConnectStatusType>(DBServices.GetInstance().ConnectStatusTypeProxy.GetDatas <ConnectStatusType>(p => true, false));
             }
             else
             {
                 UpdateCacheType <ConnectStatusType>(dataContext.ConnectStatusType.ToList().AsQueryable());
             }
         }
         //设备类型
         else if (typeof(TEntity) == typeof(DeviceType))
         {
             if (dataContext == null)
             {
                 UpdateCacheType <DeviceType>(DBServices.GetInstance().DeviceTypeProxy.GetDatas <DeviceType>(p => true, false));
             }
             else
             {
                 UpdateCacheType <DeviceType>(dataContext.DeviceType.ToList().AsQueryable());
             }
         }
         //特征值类型
         else if (typeof(TEntity) == typeof(EigenValueType))
         {
             if (dataContext == null)
             {
                 UpdateCacheType <EigenValueType>(DBServices.GetInstance().EigenValueTypeProxy.GetDatas <EigenValueType>(p => true, false));
             }
             else
             {
                 UpdateCacheType <EigenValueType>(dataContext.EigenValueType.ToList().AsQueryable());
             }
         }
         //测量位置监测类型
         else if (typeof(TEntity) == typeof(MeasureSiteMonitorType))
         {
             if (dataContext == null)
             {
                 UpdateCacheType <MeasureSiteMonitorType>(DBServices.GetInstance().MeasureSiteMonitorTypeProxy.GetDatas <MeasureSiteMonitorType>(p => true, false));
             }
             else
             {
                 UpdateCacheType <MeasureSiteMonitorType>(dataContext.MeasureSiteMonitorType.ToList().AsQueryable());
             }
         }
         //测量位置类型
         else if (typeof(TEntity) == typeof(MeasureSiteType))
         {
             if (dataContext == null)
             {
                 UpdateCacheType <MeasureSiteType>(DBServices.GetInstance().MeasureSiteTypeProxy.GetDatas <MeasureSiteType>(p => true, false));
             }
             else
             {
                 UpdateCacheType <MeasureSiteType>(dataContext.MeasureSiteType.ToList().AsQueryable());
             }
         }
         //监测树类型
         else if (typeof(TEntity) == typeof(MonitorTreeType))
         {
             if (dataContext == null)
             {
                 UpdateCacheType <MonitorTreeType>(DBServices.GetInstance().MonitorTreeTypeProxy.GetDatas <MonitorTreeType>(p => true, false));
             }
             else
             {
                 UpdateCacheType <MonitorTreeType>(dataContext.MonitorTreeType.ToList().AsQueryable());
             }
         }
         //传感器类型
         else if (typeof(TEntity) == typeof(SensorType))
         {
             if (dataContext == null)
             {
                 UpdateCacheType <SensorType>(DBServices.GetInstance().SensorTypeProxy.GetDatas <SensorType>(p => true, false));
             }
             else
             {
                 UpdateCacheType <SensorType>(dataContext.SensorType.ToList().AsQueryable());
             }
         }
         //振动信号类型
         else if (typeof(TEntity) == typeof(VibratingSingalType))
         {
             if (dataContext == null)
             {
                 UpdateCacheType <VibratingSingalType>(DBServices.GetInstance().VibratingSingalTypeProxy.GetDatas <VibratingSingalType>(p => true, false));
             }
             else
             {
                 UpdateCacheType <VibratingSingalType>(dataContext.VibratingSingalType.ToList().AsQueryable());
             }
         }
         //波形长度数值
         else if (typeof(TEntity) == typeof(WaveLengthValues))
         {
             if (dataContext == null)
             {
                 UpdateCacheType <WaveLengthValues>(DBServices.GetInstance().WaveLengthValuesProxy.GetDatas <WaveLengthValues>(p => true, false));
             }
             else
             {
                 UpdateCacheType <WaveLengthValues>(dataContext.WaveLengthValues.ToList().AsQueryable());
             }
         }
         //波形下限频率值
         else if (typeof(TEntity) == typeof(WaveLowerLimitValues))
         {
             if (dataContext == null)
             {
                 UpdateCacheType <WaveLowerLimitValues>(DBServices.GetInstance().WaveLowerLimitValuesProxy.GetDatas <WaveLowerLimitValues>(p => true, false));
             }
             else
             {
                 UpdateCacheType <WaveLowerLimitValues>(dataContext.WaveLowerLimitValues.ToList().AsQueryable());
             }
         }
         //波形上限频率值
         else if (typeof(TEntity) == typeof(WaveUpperLimitValues))
         {
             if (dataContext == null)
             {
                 UpdateCacheType <WaveUpperLimitValues>(DBServices.GetInstance().WaveUpperLimitValuesProxy.GetDatas <WaveUpperLimitValues>(p => true, false));
             }
             else
             {
                 UpdateCacheType <WaveUpperLimitValues>(dataContext.WaveUpperLimitValues.ToList().AsQueryable());
             }
         }
         //无线网关类型
         else if (typeof(TEntity) == typeof(WirelessGatewayType))
         {
             if (dataContext == null)
             {
                 UpdateCacheType <WirelessGatewayType>(DBServices.GetInstance().WirelessGatewayTypeProxy.GetDatas <WirelessGatewayType>(p => true, false));
             }
             else
             {
                 UpdateCacheType <WirelessGatewayType>(dataContext.WirelessGatewayType.ToList().AsQueryable());
             }
         }
     }
 }