public ViewCameras()
 {
     InitializeComponent();
     media = new MediaStorageConnector();
     getCameras();
     updateList();
 }
Exemple #2
0
 public FloorPlans(User user)
 {
     mainUser = user;
     InitializeComponent();
     sfp   = new SelectFloorPlan(user);
     fs    = new FindSensor(1);
     media = new MediaStorageConnector();
     es    = new EditSensors();
 }
Exemple #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (fpImage.Image == null)
            {
                MessageBox.Show("Must Choose An Image!");
                return;
            }
            if (fpname.Text.Trim() == "")
            {
                MessageBox.Show("Floor Plan must Have a name!");
                return;
            }
            MediaStorageConnector ms = new MediaStorageConnector();
            string   originalName    = openFileDialog1.FileName;
            FileInfo file            = new FileInfo(originalName);
            //new name eliminate duplicate names on server
            string newName = file.Directory.FullName + "\\" + id +
                             string.Format("{0:yyyy-MM-dd_hh-mm-ss-tt}", DateTime.Now) + file.Extension;
            //Console.WriteLine("old: "+originalName +" | new: "+ newName);
            FileInfo copy = new FileInfo(newName);
            Message  m    = HNHWebServer.doJSONPost <Message>("create-floor-plan.php", "name=" +
                                                              fpname.Text + "&id=" + id + "&picture=" + copy.Name);

            if (m != null)
            {
                if (m.status == "success")
                {
                    File.Copy(originalName, newName); //renames file for upload
                    ms.sendImage(newName);
                    File.Delete(newName);             //puts the original name back
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Error Creating Floor Plan\n" +
                                    "Check for duplicate names!\nFloor Plans can't have duplicate names!");
                }
            }
        }