Example #1
0
        public void DeleteFavorite(PhoneCall phoneCall)
        {
            DatabaseMgr dbMgr = new DatabaseMgr();

            dbMgr.DeleteFavorite(phoneCall);
            favoritesData = dbMgr.retrieveFavorites();
        }
Example #2
0
        public KeyValuePair <List <string>, List <PhoneCall> > retrieveCallLog()
        {
            SQLiteConnection conn = new SQLiteConnection(DB_PATH);
            //List<CallLogDB> retrievedTasks = conn.Table<CallLogDB>().ToList<CallLogDB>();

            string           query      = "SELECT * FROM CallLog WHERE NOT EXISTS (SELECT * FROM FAVORITE WHERE FAVORITE.PHONENUMBER = CALLLOG.PHONENUMBER)";
            List <CallLogDB> newCallLog = conn.Query <CallLogDB>(query);

            List <string>    phoneNumberList  = new List <string>();
            List <PhoneCall> phoneCallObjList = new List <PhoneCall>();

            foreach (CallLogDB record in newCallLog)
            {
                PhoneCall phoneCall = new PhoneCall()
                {
                    Name            = record.Name,
                    CallDateTime    = record.CallDateTime,
                    CallDateTimeStr = record.CallDateTime.ToString("d"),
                    PhoneNumber     = record.PhoneNumber
                };

                phoneNumberList.Add(record.PhoneNumber);
                phoneCallObjList.Add(phoneCall);
            }

            return(new KeyValuePair <List <string>, List <PhoneCall> >(phoneNumberList, phoneCallObjList));
        }
Example #3
0
        public bool exists(PhoneCall phoneCall)
        {
            bool             exists = false;
            SQLiteConnection conn   = new SQLiteConnection(DB_PATH);

            string query = "SELECT * FROM Favorite WHERE FAVORITE.PHONENUMBER = " + phoneCall.PhoneNumber;

            exists = conn.Find <FavoriteDB>(phoneCall.PhoneNumber) != null;

            return(exists);
        }
Example #4
0
        public void DeleteFavorite(PhoneCall phoneCall)
        {
            SQLiteConnection conn        = new SQLiteConnection(DB_PATH);
            FavoriteDB       newfavorite = new FavoriteDB()
            {
                Name        = phoneCall.Name,
                PhoneNumber = phoneCall.PhoneNumber
            };

            conn.Delete <FavoriteDB>(newfavorite.PhoneNumber);
        }
Example #5
0
        private void DeleteFavorite(object sender, RoutedEventArgs e)
        {
            MenuItem  menuItem         = (MenuItem)sender;
            PhoneCall phoneDataContext = menuItem.DataContext as PhoneCall;

            favorites.DeleteFavorite(phoneDataContext);
            populateFavoritesList();

            //var selected = (sender as MenuItem);
            //MessageBox.Show("You chose to  " + menuItem.Header.ToString(),"Result",MessageBoxButton.OK);
        }
Example #6
0
        public void UpdateFavorite(PhoneCall phoneCall)
        {
            SQLiteConnection conn        = new SQLiteConnection(DB_PATH);
            FavoriteDB       newfavorite = new FavoriteDB()
            {
                Name            = phoneCall.Name,
                PhoneNumber     = phoneCall.PhoneNumber,
                CallDateTimeStr = phoneCall.CallDateTimeStr
            };

            conn.Update(newfavorite);
        }
Example #7
0
        public void AddCallLog(PhoneCall phoneCall)
        {
            SQLiteConnection conn       = new SQLiteConnection(DB_PATH);
            CallLogDB        newCallLog = new CallLogDB()
            {
                Name         = phoneCall.Name,
                PhoneNumber  = phoneCall.PhoneNumber,
                CallDateTime = phoneCall.CallDateTime
            };

            conn.Insert(newCallLog);
        }
Example #8
0
        public void AddFavorite(PhoneCall phoneCall)
        {
            SQLiteConnection conn        = new SQLiteConnection(DB_PATH);
            FavoriteDB       newfavorite = new FavoriteDB()
            {
                Name            = phoneCall.Name,
                PhoneNumber     = phoneCall.PhoneNumber,
                CallDateTimeStr = phoneCall.CallDateTimeStr
            };

            conn.Insert(newfavorite);

            //this.retrieveFavorites();
        }
Example #9
0
        private List <PhoneCall> mineCallLog()
        {
            Dictionary <string, int> allCalls = new Dictionary <string, int>();

            foreach (PhoneCall result in allCallLog)
            {
                if (!allCalls.ContainsKey(result.PhoneNumber))
                {
                    allCalls.Add(result.PhoneNumber, 1);
                }
                else
                {
                    int val = allCalls[result.PhoneNumber];
                    allCalls[result.PhoneNumber] = val + 1;
                }
            }

            // Reverse sort.
            // ... Can be looped over in the same way as above.
            var items = from pair in allCalls
                        orderby pair.Value descending
                        select pair;

            int count = 0;

            mostFrequentNCalls = new List <PhoneCall>();
            foreach (KeyValuePair <string, int> pair in items)
            {
                if (count < TopNFrequent)
                {
                    int       index = allPhoneNumList.IndexOf(pair.Key);
                    PhoneCall tmp   = allCallLog[index];
                    mostFrequentNCalls.Add(tmp);
                }
                else
                {
                    break;
                }
                count++;

                Console.WriteLine("{0}: {1}", pair.Key, pair.Value);
            }

            return(mostFrequentNCalls);
        }
Example #10
0
        public List <PhoneCall> retrieveFavorites()
        {
            SQLiteConnection  conn           = new SQLiteConnection(DB_PATH);
            List <FavoriteDB> retrievedTasks = conn.Table <FavoriteDB>().ToList <FavoriteDB>();
            List <PhoneCall>  phoneCallList  = new List <PhoneCall>();

            foreach (FavoriteDB record in retrievedTasks)
            {
                PhoneCall phoneCall = new PhoneCall()
                {
                    Name            = record.Name,
                    PhoneNumber     = record.PhoneNumber,
                    CallDateTimeStr = record.CallDateTimeStr
                };

                phoneCallList.Add(phoneCall);
            }

            return(phoneCallList);
        }
Example #11
0
        public bool exists(PhoneCall phoneCall)
        {
            DatabaseMgr dbMgr = new DatabaseMgr();

            return(dbMgr.exists(phoneCall));
        }
Example #12
0
 public static void Update(PhoneCall phoneCall)
 {
     phoneCall.CallDateTimeStr = DateTime.Today.ToString("d");
     new DatabaseMgr().UpdateFavorite(phoneCall);
 }
Example #13
0
 public void AddFavorite(PhoneCall phoneCall)
 {
     new DatabaseMgr().AddFavorite(phoneCall);
     favoritesData.Add(phoneCall);
 }