예제 #1
0
        /// <summary>
        /// 获取交换机信息
        /// </summary>
        /// <returns></returns>
        public static List <Jc_MacInfo> GetAllSwitch()
        {
            var res = NetworkModuleService.GetAllNetworkModuleCache();

            if (!res.IsSuccess)
            {
                throw new Exception(res.Message);
            }
            return(res.Data);
        }
예제 #2
0
        public BasicResponse <DataTable> GetDyxMac()
        {
            DataTable     msg  = new DataTable();
            List <string> keys = null;
            Jc_MacInfo    def  = null;

            msg.Columns.Add("mac", typeof(string));
            msg.Columns.Add("wz", typeof(string));
            msg.Columns.Add("fd", typeof(int));
            msg.TableName = "fz";
            try
            {
                //List<Jc_MacInfo> JC_MAC = _CacheMrg.ServerCache.Cache_jc_mac.QueryAllCache();
                var res = _networkModuleService.GetAllNetworkModuleCache();
                if (!res.IsSuccess)
                {
                    throw new Exception(res.Message);
                }
                List <Jc_MacInfo> JC_MAC = res.Data;

                if (JC_MAC.Count > 0)
                {
                    for (int i = 0; i < JC_MAC.Count; i++)
                    {
                        def = JC_MAC[i];
                        if (def.Type == 0 && !string.IsNullOrEmpty(def.Wz) && def.Bz4 == "1")
                        {
                            msg.Rows.Add(def.MAC, def.Wz, 0);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error("获取所有绑定电源箱分站", ex);
            }
            var ret = new BasicResponse <DataTable>
            {
                Data = msg
            };

            return(ret);
        }
        /// <summary>
        /// 查询服务接口端缓存信息,并同步到网关
        /// </summary>
        /// <returns></returns>
        public static QueryCacheDataResponse QueryServiceCacheDataToGateway()
        {
            QueryCacheDataResponse queryCacheDataResponse = new QueryCacheDataResponse();
            //获取定义、设备类型、网络模块、手动/交叉控制缓存信息
            List <Jc_DefInfo>    PointDefineCacheList        = _PointDefineService.GetAllPointDefineCache().Data.FindAll(a => a.Upflag != "1");//修改,不向网关同步由子系统同步的数据  20180131
            List <Jc_DevInfo>    DeviceDefineCacheList       = _DeviceDefineService.GetAllDeviceDefineCache().Data;
            List <Jc_MacInfo>    NetworkModuleCacheList      = _NetworkModuleService.GetAllNetworkModuleCache().Data;
            List <Jc_JcsdkzInfo> ManualCrossControlCacheList = _ManualCrossControlService.GetAllManualCrossControl().Data;
            //数据转换
            List <DeviceInfo>              GatewayPointDefineCacheList        = Basic.Framework.Common.ObjectConverter.CopyList <Jc_DefInfo, DeviceInfo>(PointDefineCacheList).ToList();
            List <DeviceTypeInfo>          GatewayDeviceDefineCacheList       = Basic.Framework.Common.ObjectConverter.CopyList <Jc_DevInfo, DeviceTypeInfo>(DeviceDefineCacheList).ToList();
            List <NetworkDeviceInfo>       GatewayNetworkModuleCacheList      = Basic.Framework.Common.ObjectConverter.CopyList <Jc_MacInfo, NetworkDeviceInfo>(NetworkModuleCacheList).ToList();
            List <DeviceAcrossControlInfo> GatewayManualCrossControlCacheList = Basic.Framework.Common.ObjectConverter.CopyList <Jc_JcsdkzInfo, DeviceAcrossControlInfo>(ManualCrossControlCacheList).ToList();

            //key赋值
            foreach (DeviceInfo PointDefine in GatewayPointDefineCacheList)
            {
                PointDefine.UniqueKey = PointDefine.Point;
            }
            foreach (DeviceTypeInfo DeviceDefine in GatewayDeviceDefineCacheList)
            {
                DeviceDefine.UniqueKey = DeviceDefine.Devid;
            }
            foreach (NetworkDeviceInfo NetworkModule in GatewayNetworkModuleCacheList)
            {
                NetworkModule.UniqueKey = NetworkModule.MAC;
            }
            foreach (DeviceAcrossControlInfo ManualCrossControl in GatewayManualCrossControlCacheList)
            {
                ManualCrossControl.UniqueKey = ManualCrossControl.ID;
            }

            queryCacheDataResponse.DeviceList              = GatewayPointDefineCacheList;
            queryCacheDataResponse.DeviceTypeList          = GatewayDeviceDefineCacheList;
            queryCacheDataResponse.NetworkDeviceList       = GatewayNetworkModuleCacheList;
            queryCacheDataResponse.DeviceAcrossControlList = GatewayManualCrossControlCacheList;

            return(queryCacheDataResponse);
        }
예제 #4
0
 public BasicResponse <List <Jc_MacInfo> > GetAllNetworkModuleCache()
 {
     return(_NetworkModuleService.GetAllNetworkModuleCache());
 }
        public void PowerboxchargeStaticThread()
        {
            DateTime timeNow = DateTime.Now;
            List <PowerboxchargehistoryInfo> PowerboxchargehistoryList = new List <PowerboxchargehistoryInfo>();
            List <Jc_DefInfo> StationList = new List <Jc_DefInfo>();

            while (true)
            {
                try
                {
                    timeNow = DateTime.Now;
                    PowerboxchargehistoryGetByStimeRequest powerboxchargehistoryRequest = new PowerboxchargehistoryGetByStimeRequest();
                    powerboxchargehistoryRequest.Stime = timeNow.AddDays(-1);
                    PowerboxchargehistoryList          = powerboxchargehistoryService.GetPowerboxchargehistoryByStime(powerboxchargehistoryRequest).Data;
                    StationList = pointDefineService.GetPointDefineCacheByDevpropertID(new Request.PointDefine.PointDefineGetByDevpropertIDRequest()
                    {
                        DevpropertID = 0
                    }).Data;
                    List <Jc_MacInfo> macList = networkModuleService.GetAllNetworkModuleCache().Data;
                    foreach (PowerboxchargehistoryInfo powerboxcharge in PowerboxchargehistoryList)
                    {
                        if (powerboxcharge.DischargeStime < DateTime.Parse("2000-01-01"))//放电开始判断
                        {
                            if (string.IsNullOrEmpty(powerboxcharge.Mac))
                            {//分站电源箱
                                Jc_DefInfo station = StationList.Find(a => a.Fzh == short.Parse(powerboxcharge.Fzh));
                                if (station != null)
                                {
                                    TimeSpan ts = station.DttRunStateTime - powerboxcharge.Stime;
                                    if (station.State == 4 && ts.TotalMinutes < 5)//如果操作放电,分站在5分钟内变成直流了,则记录放电的开始时间
                                    {
                                        powerboxcharge.DischargeStime = station.DttRunStateTime;
                                        PowerboxchargehistoryUpdate(powerboxcharge);
                                    }
                                }
                            }
                            else
                            {
                                GetMacPowerboxInfo(powerboxcharge.Mac);
                                //交换机电源箱
                                Jc_MacInfo mac = macList.Find(a => a.MAC == powerboxcharge.Mac);
                                if (mac != null)
                                {
                                    if (mac.BatteryItems != null && mac.BatteryItems.Count > 0)
                                    {
                                        if (mac.BatteryItems[0].BatteryACDC == 2)//如果操作放电,交换机变成直流,则记录放电的开始时间
                                        {
                                            powerboxcharge.DischargeStime = mac.PowerDateTime;
                                            PowerboxchargehistoryUpdate(powerboxcharge);
                                        }
                                    }
                                }
                            }
                        }
                        else if (powerboxcharge.DischargeEtime < DateTime.Parse("2000-01-01"))//放电结束判断
                        {
                            if (string.IsNullOrEmpty(powerboxcharge.Mac))
                            {
                                Jc_DefInfo station = StationList.Find(a => a.Fzh == short.Parse(powerboxcharge.Fzh));
                                if (station != null && station.State == 3)//如果分站变成交流了,则记录放电的结束时间
                                {
                                    powerboxcharge.DischargeEtime = station.DttRunStateTime;
                                    PowerboxchargehistoryUpdate(powerboxcharge);
                                }
                            }
                            else
                            {
                                GetMacPowerboxInfo(powerboxcharge.Mac);
                                //交换机电源箱
                                Jc_MacInfo mac = macList.Find(a => a.MAC == powerboxcharge.Mac);
                                if (mac != null)
                                {
                                    if (mac.BatteryItems != null && mac.BatteryItems.Count > 0)
                                    {
                                        if (mac.BatteryItems[0].BatteryACDC == 1)//如果交换机变成交流了,则记录放电的结束时间
                                        {
                                            powerboxcharge.DischargeEtime = mac.PowerDateTime;
                                            PowerboxchargehistoryUpdate(powerboxcharge);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Basic.Framework.Logging.LogHelper.Error(ex);
                }
                Thread.Sleep(60000);
            }
        }