コード例 #1
0
        public void DeleteFavorite(PhoneCall phoneCall)
        {
            DatabaseMgr dbMgr = new DatabaseMgr();

            dbMgr.DeleteFavorite(phoneCall);
            favoritesData = dbMgr.retrieveFavorites();
        }
コード例 #2
0
ファイル: DatabaseMgr.cs プロジェクト: SirishaV88/HelpMate
        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));
        }
コード例 #3
0
ファイル: DatabaseMgr.cs プロジェクト: SirishaV88/HelpMate
        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);
        }
コード例 #4
0
ファイル: DatabaseMgr.cs プロジェクト: SirishaV88/HelpMate
        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);
        }
コード例 #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);
        }
コード例 #6
0
ファイル: DatabaseMgr.cs プロジェクト: SirishaV88/HelpMate
        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);
        }
コード例 #7
0
ファイル: DatabaseMgr.cs プロジェクト: SirishaV88/HelpMate
        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);
        }
コード例 #8
0
ファイル: DatabaseMgr.cs プロジェクト: SirishaV88/HelpMate
        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();
        }
コード例 #9
0
ファイル: CallHistory.cs プロジェクト: SirishaV88/HelpMate
        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);
        }
コード例 #10
0
ファイル: DatabaseMgr.cs プロジェクト: SirishaV88/HelpMate
        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);
        }
コード例 #11
0
        public bool exists(PhoneCall phoneCall)
        {
            DatabaseMgr dbMgr = new DatabaseMgr();

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