示例#1
0
        public void GetOLStatus(int uID, string subcenterId)
        {
            try
            {
                Subcenter sub = new Subcenter {
                    SubcenterdId = subcenterId
                };

                DtuList list = grpcClient.GetDtuList(sub);

                dtuList = new CDictionary <int, DtuList>();

                if (list != null)
                {
                    if (dtuList.ContainsKey(uID))
                    {
                        dtuList[uID] = list;
                    }
                    else
                    {
                        dtuList.Add(uID, list);
                    }
                }
            }
            catch (Exception exp)
            {
                Debug.WriteLine("RPC failed" + exp);
                throw;
            }
        }
示例#2
0
        public static DtuList GetOnlineStatus(int uID, string subcenter)
        {
            DtuList dtulist = new DtuList();

            Channel             channel = new Channel(Conf.Config.DB_SERVER_IP, ChannelCredentials.Insecure);
            OnlineStatusService client  = new OnlineStatusService(new gRPCServices.gRPCServicesClient(channel));

            client.GetOLStatus(uID, subcenter);
            dtulist = client.GetDtuList.FindValue(uID);

            channel.ShutdownAsync().Wait();
            client.StopGrpcClient();
            return(dtulist);
        }
示例#3
0
        private DtuList FindDtuList(Subcenter subcenter)
        {
            DtuList dtuList = new DtuList();

            List <ModemInfoStruct>               stateList    = new List <ModemInfoStruct>();
            List <CEntityStation>                stations     = new List <CEntityStation>();
            List <CEntitySoilStation>            soilStations = new List <CEntitySoilStation>();
            List <CEntitySubCenter>              subCenters   = new List <CEntitySubCenter>();
            Dictionary <string, ModemInfoStruct> gprsDic      = new Dictionary <string, ModemInfoStruct>();

            stateList    = Clone <ModemInfoStruct>(CProtocolEventManager.Instance.GetOnlineStatusList());
            stations     = CDBDataMgr.Instance.GetAllStation();
            soilStations = CDBSoilDataMgr.Instance.GetAllSoilStation();
            subCenters   = CDBDataMgr.Instance.GetAllSubCenter();

            if (stateList.Count() != 0)
            {
                for (int i = 0; i < stateList.Count(); i++)
                {
                    string uid = ((uint)stateList[i].m_modemId).ToString("X").PadLeft(8, '0');
                    gprsDic.Add(uid, stateList[i]);
                }
            }

            foreach (var s in stations)
            {
                if (subcenter.SubcenterdId == s.SubCenterID.ToString() || subcenter.SubcenterdId == "0")
                {
                    if (gprsDic.Count() != 0)
                    {
                        if (gprsDic.ContainsKey(s.GPRS))
                        {
                            Dtu dtu = new Dtu();

                            ModemInfoStruct state       = gprsDic[s.GPRS];
                            string          phoneno     = CGprsUtil.Byte11ToPhoneNO(state.m_phoneno, 0);
                            string          dynIP       = CGprsUtil.Byte4ToIP(state.m_dynip, 0);
                            string          connectTime = CGprsUtil.ULongToDatetime(state.m_conn_time).ToString();
                            string          refreshTime = CGprsUtil.ULongToDatetime(state.m_refresh_time).ToString();

                            dtu.SubcenterId = s.SubCenterID.ToString();
                            string subName = CDBDataMgr.Instance.GetSubCenterName(s.SubCenterID.ToString());
                            dtu.SubcenterName = subName;
                            dtu.StationId     = s.StationID;
                            dtu.StationName   = s.StationName;
                            dtu.GprsId        = s.GPRS;
                            dtu.GsmNum        = phoneno;
                            dtu.IpAddr        = dynIP;
                            dtu.ConnTime      = connectTime;
                            dtu.RefreshTime   = refreshTime;
                            dtu.State         = "1";
                            dtu.StationType   = CEnumHelper.StationTypeToDBStr(s.StationType);
                            dtuList.Dtu.Add(dtu);
                        }
                    }
                    else
                    {
                        Dtu dtu = new Dtu();
                        dtu.SubcenterId = s.SubCenterID.ToString();
                        string subName = CDBDataMgr.Instance.GetSubCenterName(s.SubCenterID.ToString());
                        dtu.SubcenterName = subName;
                        dtu.StationId     = s.StationID;
                        dtu.StationName   = s.StationName;
                        dtu.GprsId        = s.GPRS;
                        dtu.State         = "2";
                        dtu.StationType   = CEnumHelper.StationTypeToDBStr(s.StationType);
                        dtuList.Dtu.Add(dtu);
                    }
                }
            }

            foreach (var s in stations)
            {
                if (subcenter.SubcenterdId == s.SubCenterID.ToString() || subcenter.SubcenterdId == "0")
                {
                    if (gprsDic.Count() != 0)
                    {
                        if (!gprsDic.ContainsKey(s.GPRS))
                        {
                            Dtu dtu = new Dtu();
                            dtu.SubcenterId = s.SubCenterID.ToString();
                            string subName = CDBDataMgr.Instance.GetSubCenterName(s.SubCenterID.ToString());
                            dtu.SubcenterName = subName;
                            dtu.StationId     = s.StationID;
                            dtu.StationName   = s.StationName;
                            dtu.GprsId        = s.GPRS;
                            dtu.State         = "2";
                            dtu.StationType   = CEnumHelper.StationTypeToDBStr(s.StationType);
                            dtuList.Dtu.Add(dtu);
                        }
                    }
                }
            }

            foreach (var s in soilStations)
            {
                if (subcenter.SubcenterdId == s.SubCenterID.ToString() || subcenter.SubcenterdId == "0")
                {
                    if (gprsDic.Count() != 0)
                    {
                        if (gprsDic.ContainsKey(s.GPRS))
                        {
                            Dtu dtu = new Dtu();

                            ModemInfoStruct state       = gprsDic[s.GPRS];
                            string          phoneno     = CGprsUtil.Byte11ToPhoneNO(state.m_phoneno, 0);
                            string          dynIP       = CGprsUtil.Byte4ToIP(state.m_dynip, 0);
                            string          connectTime = CGprsUtil.ULongToDatetime(state.m_conn_time).ToString();
                            string          refreshTime = CGprsUtil.ULongToDatetime(state.m_refresh_time).ToString();

                            if (subcenter.SubcenterdId == s.SubCenterID.ToString() || subcenter.SubcenterdId == "0")
                            {
                                dtu.SubcenterId = s.SubCenterID.ToString();
                                string subName = CDBDataMgr.Instance.GetSubCenterName(s.SubCenterID.ToString());
                                dtu.SubcenterName = subName;
                                dtu.StationId     = s.StationID;
                                dtu.StationName   = s.StationName;
                                dtu.GprsId        = s.GPRS;
                                dtu.GsmNum        = phoneno;
                                dtu.IpAddr        = dynIP;
                                dtu.ConnTime      = connectTime;
                                dtu.RefreshTime   = refreshTime;
                                dtu.State         = "1";
                                dtu.StationType   = CEnumHelper.StationTypeToDBStr(s.StationType);
                                dtuList.Dtu.Add(dtu);
                            }
                        }
                    }
                    else
                    {
                        Dtu dtu = new Dtu();
                        dtu.SubcenterId = s.SubCenterID.ToString();
                        string subName = CDBDataMgr.Instance.GetSubCenterName(s.SubCenterID.ToString());
                        dtu.SubcenterName = subName;
                        dtu.StationId     = s.StationID;
                        dtu.StationName   = s.StationName;
                        dtu.GprsId        = s.GPRS;
                        dtu.State         = "2";
                        dtu.StationType   = CEnumHelper.StationTypeToDBStr(s.StationType);
                        dtuList.Dtu.Add(dtu);
                    }
                }
            }

            foreach (var s in soilStations)
            {
                if (subcenter.SubcenterdId == s.SubCenterID.ToString() || subcenter.SubcenterdId == "0")
                {
                    if (gprsDic.Count() != 0)
                    {
                        if (!gprsDic.ContainsKey(s.GPRS))
                        {
                            Dtu dtu = new Dtu();
                            dtu.SubcenterId = s.SubCenterID.ToString();
                            string subName = CDBDataMgr.Instance.GetSubCenterName(s.SubCenterID.ToString());
                            dtu.SubcenterName = subName;
                            dtu.StationId     = s.StationID;
                            dtu.StationName   = s.StationName;
                            dtu.GprsId        = s.GPRS;
                            dtu.State         = "2";
                            dtu.StationType   = CEnumHelper.StationTypeToDBStr(s.StationType);
                            dtuList.Dtu.Add(dtu);
                        }
                    }
                }
            }

            return(dtuList);
        }