示例#1
0
 public object Convert(object value, Type targetType, object parameter, string language)
 {
     if (string.IsNullOrEmpty((string)value))
     {
         return("");
     }
     else
     {
         return(AESCipher.AES_Decrypt((string)value));
     }
 }
示例#2
0
        public static async Task <string> GetCCTVType(IOTOI.Model.CCTV cctv)
        {
            foreach (var IPCameraUri in IPCameraUris)
            {
                try
                {
                    using (HttpClient httpClient = new HttpClient())
                    {
                        httpClient.Timeout     = TimeSpan.FromMilliseconds(2000);
                        httpClient.BaseAddress = new Uri("http://" + cctv.IpAddress);
                        string requestUri = String.Format(IPCameraUri.Value, cctv.AccountId, AESCipher.AES_Decrypt(cctv.AccountPass));

                        Debug.WriteLine("requestUri :: " + httpClient.BaseAddress + requestUri);

                        //Send the GET request
                        HttpResponseMessage httpResponse = await httpClient.GetAsync(requestUri);

                        if (httpResponse != null && httpResponse.StatusCode == HttpStatusCode.OK)
                        {
                            string ResponseText = await httpResponse.Content.ReadAsStringAsync();

                            XmlDocument xml = new XmlDocument();
                            xml.LoadXml(ResponseText);

                            if (xml.GetElementsByTagName("result")[0].InnerText == "0")
                            {
                                return(IPCameraUri.Key);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("GetCCTVType Exception " + ex.Message);
                    continue;
                }
            }

            return("");
        }