public bool Add(PersonD p)
 {
     try
     {
         var client     = new MongoClient("mongodb://10.13.18.40:27017");
         var database   = client.GetDatabase("foo");
         var collection = database.GetCollection <PersonD>("3,17");
         collection.InsertOne(p);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
        private void RssiAdd(int rssi)
        {
            //Dispatcher.Invoke(new Action(() =>
            //{
            int i;

            //     for (i = 0; gateway[i] != gateway_mac; i++);
            i = gateway.ToList().IndexOf(gateway_mac);
            data[i].Add(rssi);
            AddRs(i, rssi);
            if (data[0].Count >= 80 && data[2].Count >= 80 && data[1].Count >= 80)
            {
                dataFun();
                Calculation.CalculateTheDistance(dictionary);
                Point po = Calculation.threePoints();
                Point pi = Calculation.calculaton();
                DynamicGraph(Calculation.rssi);
                AddR(Calculation.R);
                //Write(System.Text.Encoding.Default.GetBytes("1:" + Calculation.rssi[0] + ";2:" + Calculation.rssi[1] + ";3:" + Calculation.rssi[2] + "\r\n"));
                window.AppPoint(po, pi);
                PersonD personD = new PersonD();
                personD.Factor    = Convert.ToDouble(Variable.getFactor());
                personD.rssi      = Convert.ToInt32(Variable.getCalibration());
                personD.time      = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0);
                personD.RssiA     = data[0];
                personD.RssiB     = data[1];
                personD.RssiC     = data[2];
                personD.DistanceA = Calculation.rssi[0];
                personD.DistanceB = Calculation.rssi[1];
                personD.DistanceC = Calculation.rssi[2];
                personD.point     = po;
                mongodbHandle.Add(personD);
                data = new List <int>[] { new List <int>(), new List <int>(), new List <int>() };
                // Write(System.Text.Encoding.Default.GetBytes("\r" + po.X + "," + po.Y + "\n" + pi.X + "," + pi.Y + "\r\n\n\n"));
            }
            //}));
        }