Example #1
0
        private void ButtonMenuCameras_Click(object sender, RoutedEventArgs e)
        {
            CamerasPageView cams = new CamerasPageView();

            MenuPage.Content = cams;
            lblTitle.Content = "CAMERAS";
        }
        private void BtnConfirmDelete_Click(object sender, RoutedEventArgs e)
        {
            var tableName = "Cameras";
            //load DynamoDB table
            var table = Table.LoadTable(client, tableName);
            var item  = table.GetItem(DeleteCamId);

            try
            {
                if (item != null)
                {
                    table.DeleteItem(item);
                    MessageBox.Show("Successfully Deleted!");
                }
                else
                {
                    MessageBox.Show("There is no such a Camera!");
                }
                MainView        mainv = new MainView();
                CamerasPageView cams  = new CamerasPageView();
                mainv.MenuPage.Content = cams;
                mainv.Show();
            }
            catch (AmazonDynamoDBException ex)
            {
                MessageBox.Show("Message : Server Error", ex.Message);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Message : Unknown Error", ex.Message);
            }
        }
Example #3
0
        private void AddCamera(string camid, string loc, string qlty)
        {
            try
            {
                string tableName = "Cameras";

                var table  = Table.LoadTable(client, tableName);
                var search = table.Scan(new Amazon.DynamoDBv2.DocumentModel.Expression());

                if (search.Count != 0)
                {
                    var item = table.GetItem(camid);

                    if (item == null)
                    {
                        //Console.WriteLine("search  = ", search);
                        //Console.WriteLine("search.count  = ", search.Count);


                        this.Close();
                        MessageBox.Show("New Camera Was Successfully Added!");
                    }
                    else
                    {
                        CreateCameraTable(tableName);
                        MessageBox.Show("Camera ID is already exist! (Please try a different one)");
                    }

                    Document camObj = new Document();
                    camObj["camId"]    = camid;
                    camObj["location"] = loc;
                    camObj["quality"]  = qlty;
                    table.PutItem(camObj);
                }
                else
                {
                    MessageBox.Show("Table scan doesn't gives results");
                }

                MainView        mainv = new MainView();
                CamerasPageView cams  = new CamerasPageView();
                mainv.MenuPage.Content = cams;
                mainv.Show();
            }
            catch (AmazonDynamoDBException ex)
            {
                MessageBox.Show("Message : Server Error", ex.Message);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Message : Unknown Error", ex.Message);
            }
        }
        private void UpdateCamera(string cid, string loc, string qlty)
        {
            var tableName = "Cameras";
            //load DynamoDB table
            var table = Table.LoadTable(client, tableName);
            var item  = table.GetItem(cid);

            try
            {
                //Console.WriteLine(item["aPassword"]);

                if (item != null)
                {
                    Document camObj = new Document();
                    camObj["camId"]    = cid;
                    camObj["location"] = loc;
                    camObj["quality"]  = qlty;
                    table.PutItem(camObj);
                    MessageBox.Show("Successfully Updated!");
                }
                else
                {
                    MessageBox.Show("There is no such a Camera!");
                }

                MainView        mainv = new MainView();
                CamerasPageView cams  = new CamerasPageView();
                mainv.MenuPage.Content = cams;
                mainv.Show();
            }
            catch (AmazonDynamoDBException ex)
            {
                MessageBox.Show("Message : Server Error", ex.Message);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Message : Unknown Error", ex.Message);
            }
        }