public void saveDictionary(Dnary dnary)
        {
            using (DataBaseContext context = new DataBaseContext(DataBaseContext.DBConnectionString))
            {
                DictionaryTable dT = new DictionaryTable();

                dT.DataKey = dnary.DataKey;
                //Debug.WriteLine("Dnary in DataBaseAdd.saveDictionary :"+ dnary.DataKey+","+ dnary.DataValue);
                dT.value = dnary.DataValue;
                dT.dataEntrydate = dnary.datetimeDataEntry;
                dT.activity = dnary.activity;

                //Debug.WriteLine("before insert on sumbit saveDictionary ");
                context.dnary.InsertOnSubmit(dT);
                //Debug.WriteLine("after insert on sumbit saveDictionary");
                context.SubmitChanges();
            }
        }
        public List<Dnary> getListAllDictionary()
        {
            IList<DictionaryTable> dt = this.GetAllDictionary();
            List<Dnary> AllDictionary = new List<Dnary>();
            foreach (DictionaryTable m in dt)
            {
                Dnary dn = new Dnary();
                dn.DataKey = m.DataKey;
                dn.DataValue = m.value;
                DateTime date = Convert.ToDateTime(m.dataEntrydate);
                dn.datetimeDataEntry = date;
                dn.activity = m.activity;

                //n.datas =

                AllDictionary.Add(dn);
            }
            return AllDictionary;
        }
 public static void addDictionaryToList(Dnary dn)
 {
     dictionaryList.Add(dn);
     //return dataEntries.Count();
 }
        //new ??
        public DataEntry filterOne(List<String> filter)
        {
            DataEntry dE = new DataEntry();

            dE.dateTime = this.dateTime;
            dE.activity = this.activity;
            for (int i = 0; i < filter.Count; i++)
            {
                String key = filter.ElementAt<string>(i);
                dE.datas.Add(key, this.datas[key]);
                Dnary dn = new Dnary();
                dn.DataKey = key;
                dn.DataValue = this.datas[key];

                filtredDictionaryList.Add(dn);
            }
            foreach (Dnary dn in filtredDictionaryList)
            {
                Debug.WriteLine("dn key value  DataEntry.filter  :" + dn.DataKey + "," + dn.DataValue+","+dn.datetimeDataEntry+","+dn.activity);

            }

            return new DataEntry() ;
        }
        private void checkTimeToLog()
        {
            if (started)
            {
                DateTime dt = DateTime.Now;
                if (lastTime != null)
                {
                    if ((dt - lastTime).Seconds > 0)
                    {
                        DataEntry dE = new DataEntry();

                        if (this.activities.Count > 0)
                        {
                            dE.activity = this.activities.ElementAt<string>(this.activities.Count - 1);
                        }
                        dE.datas.Add("accelX", accelX);
                        Dnary dnaccelX = new Dnary();
                        dnaccelX.DataKey = "accelX";
                        dnaccelX.DataValue = accelX;
                        dnaccelX.datetimeDataEntry = dE.dateTime;
                        dnaccelX.activity = dE.activity;
                        DataEntry.addDictionaryToList(dnaccelX);
                        dE.datas.Add("accelY", accelY);
                        Dnary dnaccelY = new Dnary();
                        dnaccelY.DataKey = "accelY";
                        dnaccelY.DataValue = accelY;
                        dnaccelY.datetimeDataEntry = dE.dateTime;
                        dnaccelY.activity = dE.activity;
                        DataEntry.addDictionaryToList(dnaccelY);
                        dE.datas.Add("accelZ", accelZ);
                        Dnary dnaccelZ = new Dnary();
                        dnaccelZ.DataKey = "accelZ";
                        dnaccelZ.DataValue = accelZ;
                        dnaccelZ.datetimeDataEntry = dE.dateTime;
                        dnaccelZ.activity = dE.activity;
                        DataEntry.addDictionaryToList(dnaccelZ);
                        dE.datas.Add("compass", comp);
                        Dnary dncompass = new Dnary();
                        dncompass.DataKey = "compass";
                        dncompass.DataValue = comp;
                        dncompass.datetimeDataEntry = dE.dateTime;
                        dncompass.activity = dE.activity;
                        DataEntry.addDictionaryToList(dncompass);
                        dE.datas.Add("gyroX", gyroX);
                        Dnary dngyroX = new Dnary();
                        dngyroX.DataKey = "gyroX";
                        dngyroX.DataValue = gyroX;
                        dngyroX.datetimeDataEntry = dE.dateTime;
                        dngyroX.activity = dE.activity;
                        DataEntry.addDictionaryToList(dngyroX);
                        dE.datas.Add("gyroY", gyroY);
                        Dnary dngyroY = new Dnary();
                        dngyroY.DataKey = "gyroY";
                        dngyroY.DataValue = gyroY;
                        dngyroY.datetimeDataEntry = dE.dateTime;
                        dngyroY.activity = dE.activity;
                        DataEntry.addDictionaryToList(dngyroY);
                        dE.datas.Add("gyroZ", gyroZ);
                        Dnary dngyroZ = new Dnary();
                        dngyroZ.DataKey = "gyroZ";
                        dngyroZ.DataValue = gyroZ;
                        dngyroZ.datetimeDataEntry = dE.dateTime;
                        dngyroZ.activity = dE.activity;
                        DataEntry.addDictionaryToList(dngyroZ);
                        dE.datas.Add("incliYaw", incliYaw);
                        Dnary dnincliYaw = new Dnary();
                        dnincliYaw.DataKey = "incliYaw";
                        dnincliYaw.DataValue = incliYaw;
                        dnincliYaw.datetimeDataEntry = dE.dateTime;
                        dnincliYaw.activity = dE.activity;
                        DataEntry.addDictionaryToList(dnincliYaw);
                        dE.datas.Add("incliPitch", incliPitch);
                        Dnary dnincliPitch = new Dnary();
                        dnincliPitch.DataKey = "incliPitch";
                        dnincliPitch.DataValue = incliPitch;
                        dnincliPitch.datetimeDataEntry = dE.dateTime;
                        dnincliPitch.activity = dE.activity;
                        DataEntry.addDictionaryToList(dnincliPitch);
                        dE.datas.Add("incliRoll", incliRoll);
                        Dnary dnincliRoll = new Dnary();
                        dnincliRoll.DataKey = "incliRoll";
                        dnincliRoll.DataValue = incliRoll;
                        dnincliRoll.datetimeDataEntry = dE.dateTime;
                        dnincliRoll.activity = dE.activity;
                        DataEntry.addDictionaryToList(dnincliRoll);
                        dE.datas.Add("light", light);
                        Dnary dnlight = new Dnary();
                        dnlight.DataKey = "light";
                        dnlight.DataValue = light;
                        dnlight.datetimeDataEntry = dE.dateTime;
                        dnlight.activity = dE.activity;
                        DataEntry.addEntryToList(dE);
                        DataEntry.addDictionaryToList(dnlight);
                        lastTime = dt;
                        this.textBlock_logquantity.Text = DataEntry.dataEntries.Count().ToString("0.0");
                    }
                }
                else
                {
                    lastTime = dt;
                }
            }
        }