예제 #1
0
        public void CheckForDeviceMatch(TheUPnPDeviceInfo tHistory, Uri pLocationUrl)
        {
            if (mUPnpUIDs.Count <= 0)
            {
                return;
            }
            if (pLocationUrl == null || TheCommonUtils.IsGuid(pLocationUrl.Host))
            {
                pLocationUrl = null;
            }
            bool sendOnce   = false;
            bool hasAllFlag = false;

            foreach (string tUID in mUPnpUIDs.Keys)
            {
                if (tUID.Equals("*") && mUPnpUIDs[tUID] == null)
                {
                    if (pLocationUrl == null && mUPnpUIDs[tUID] != null)
                    {
                        mUPnpUIDs[tUID](tHistory);
                    }
                    hasAllFlag = true;
                }
                else
                {
                    string[] stParts = TheCommonUtils.cdeSplit(tUID, ";:;", true, true);
                    if (stParts.Length == 1)
                    {
                        if (!string.IsNullOrEmpty(tHistory?.ST) && (tUID == "*" || tHistory?.ST?.ToUpper().Contains(tUID.ToUpper()) == true))
                        {
                            if ((pLocationUrl == null || !string.IsNullOrEmpty(tHistory.USN)) && mUPnpUIDs[tUID] != null)
                            {
                                mUPnpUIDs[tUID](tHistory);
                            }
                            else
                            {
                                var t = TheThingRegistry.GetThingByMID(tHistory.ScannerID);
                                (t.GetObject() as ICDEDiscoService)?.GetDeviceDetails(tHistory, mUPnpUIDs[tUID]);
                                //if (pLocationUrl!=null)
                                //    TheREST.GetRESTAsync(pLocationUrl, 0, sinkUPnPCustomDeviceFound, mUPnpUIDs[tUID]);
                            }
                            sendOnce = true;
                        }
                    }
                    else
                    {
                        if (CompareUPnPField(tHistory, stParts[0], stParts[1]))
                        {
                            if ((pLocationUrl == null || !string.IsNullOrEmpty(tHistory.USN)) && mUPnpUIDs[tUID] != null)
                            {
                                mUPnpUIDs[tUID](tHistory);
                            }
                            else
                            {
                                var t = TheThingRegistry.GetThingByMID(tHistory.ScannerID);
                                (t.GetObject() as ICDEDiscoService)?.GetDeviceDetails(tHistory, mUPnpUIDs[tUID]);
                                //if (pLocationUrl != null)
                                //    TheREST.GetRESTAsync(pLocationUrl, 0, sinkUPnPCustomDeviceFound, mUPnpUIDs[tUID]);
                            }
                            sendOnce = true;
                        }
                    }
                }
            }
            if (!sendOnce && hasAllFlag && pLocationUrl != null)
            {
                //TheSystemMessageLog.ToCo(string.Format("UPnP Get Meta From: {0}", pLocationUrl));
                var t = TheThingRegistry.GetThingByMID(tHistory.ScannerID);
                (t?.GetObject() as ICDEDiscoService)?.GetDeviceDetails(tHistory, null);
                //TheREST.GetRESTAsync(pLocationUrl, 0, sinkUPnPCustomDeviceFound, null);
            }
        }