Ejemplo n.º 1
0
        private async void Delete()
        {
            if (CCTVSelectedItem == null || CCTVSelectedItem.CCTVId == 0)
            {
                return;
            }

            ContentDialog deleteCCTVDialog = new ContentDialog
            {
                Title             = "Are you sure you want to delete?",
                PrimaryButtonText = "Delete",
                CloseButtonText   = "Cancel"
            };
            ContentDialogResult result = await deleteCCTVDialog.ShowAsync();

            if (result == ContentDialogResult.Primary)
            {
                using (var db = new Context())
                {
                    db.Remove(CCTVSelectedItem);
                    db.SaveChanges();
                }

                CCTVSelectedItem.IpAddress   = "";
                CCTVSelectedItem.AccountId   = "";
                CCTVSelectedItem.AccountPass = "******";
                CCTVSelectedItem.CCTVName    = "";
                CCTVSelectedItem             = new IOTOI.Model.CCTV();
                SelectDefaultCCTV();

                FooterVM.CheckCCTVStreaming();
            }
        }
Ejemplo n.º 2
0
        public void SelectDefaultCCTV()
        {
            CCTVListVM.GetCCTVList();

            if (CCTVListVM.CCTVListSources.Count > 0)
            {
                CCTVSelectedItem = CCTVListVM.CCTVListSources[0];
            }

            if (CCTVSelectedItem == null)
            {
                _cCTVSelectedItem = new IOTOI.Model.CCTV();
            }
        }
Ejemplo n.º 3
0
        private void AddCCTV()
        {
            foreach (IOTOI.Model.CCTV cctv in CCTVListVM.CCTVListSources)
            {
                if (cctv.CCTVId == 0)
                {
                    CCTVSelectedItem = cctv;
                    return;
                }
            }

            IOTOI.Model.CCTV NewCCTV = new IOTOI.Model.CCTV
            {
                CCTVName = "..."
            };
            CCTVListVM.CCTVListSources.Add(NewCCTV);
            CCTVSelectedItem = NewCCTV;
        }
Ejemplo n.º 4
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("");
        }