Example #1
0
        messages[] getMessages()
        {
            using (MySqlConnection connection = new MySqlConnection(connectionString))
            {
                string       query = "SELECT * FROM isad157_jharrison.messagesn";
                MySqlCommand cmd   = new MySqlCommand(query, connection);
                connection.Open();
                MySqlDataAdapter sqlDA = new MySqlDataAdapter(cmd);
                DataTable        facebookMessagesTable = new DataTable();
                sqlDA.Fill(facebookMessagesTable);
                int endOfRecord = facebookMessagesTable.Rows.Count;

                int messageID = 0000; string recipientID = "zeep"; string dateTime = "zeep"; string messageContent = "zeep"; int count = 0;

                foreach (DataRow row in facebookMessagesTable.Rows)
                {
                    messageID      = (int)row["UMessageID"];
                    recipientID    = row["Recipient"].ToString();
                    dateTime       = row["Date_Time"].ToString();
                    messageContent = row["Message"].ToString();
                    Array.Resize(ref fbMessages, fbMessages.Length + 1);
                    fbMessages[count] = new messages(messageID, recipientID, dateTime, messageContent);
                    count++;
                }
                connection.Close();
                return(fbMessages);
            }
        }
Example #2
0
        private void getFBUser(string userIDF) // Calling currently selected User ID for reference
        {
            if (userIDF != "Prototype.facebookUsers")
            {
                // Emptying boxes and lists in case any info isn't updated
                lbUserInfoName.Text     = " ";
                lbUserInfoGender.Text   = " ";
                lbUserInfoHometown.Text = " ";
                lbUserInfoCity.Text     = " ";
                lbUserInfoUni.Text      = " ";
                lstUserFriends.Items.Clear();
                lstUserMessages.Items.Clear();

                // User info being called
                facebookUsers selectedfbuser = fbUsers.FirstOrDefault(i => i.identifier == userIDF);
                lbUserInfoName.Text     = selectedfbuser.getFirstName() + " " + selectedfbuser.getLastName();
                lbUserInfoGender.Text   = selectedfbuser.getGender();
                lbUserInfoCity.Text     = selectedfbuser.getCity();
                lbUserInfoHometown.Text = selectedfbuser.getHometown();

                // User uni being called
                universities tempuni = fbUni.FirstOrDefault(u => u.identifier == userIDF.ToString());
                if (tempuni.uniName != " ")
                {
                    lbUserInfoUni.Text = tempuni.uniName;
                }

                // User work place being called
                workplace tempwork = fbWork.FirstOrDefault(w => w.identifier == userIDF.ToString());
                if (tempwork.workName != " ")
                {
                    lbUserInfoWork.Text = tempwork.workName;
                }

                // Message list being called before calling messages
                mList tempList = fbmList.FirstOrDefault(l => l.identifier2 == userIDF.ToString());
                if (tempList.identifier2 == null)
                {
                    lbUserInfoName.Text = "Nope";
                }
                else
                {
                    // Putting each identifier in string
                    string messID = tempList.identifier2;
                    string uID    = tempList.identifier;
                    string combo  = tempList.identifier3;
                    using (MySqlConnection connection = new MySqlConnection(connectionString))
                    {
                        string       query = "SELECT * FROM isad157_jharrison.messagesn WHERE UMessageID =" + messID;
                        MySqlCommand cmd   = new MySqlCommand(query, connection);
                        connection.Open();
                        MySqlDataAdapter sqlDA = new MySqlDataAdapter(cmd);
                        DataTable        facebookUserMessTable = new DataTable();
                        sqlDA.Fill(facebookUserMessTable);
                        int endOfRecord = facebookUserMessTable.Rows.Count;

                        foreach (DataRow row in facebookUserMessTable.Rows)
                        {
                            // User Messages being called
                            messages tempmessages = fbMessages.FirstOrDefault(m => m.identifier == messID.ToString());
                            lstUserMessages.Items.Add(tempmessages.getsetRecipient);
                            lstUserMessages.Items.Add(tempmessages.getsetDateTime);
                            lstUserMessages.Items.Add(tempmessages.getsetMessage);
                        }
                        connection.Close();
                    }
                }

                using (MySqlConnection connection = new MySqlConnection(connectionString))
                {
                    string       query = "SELECT * FROM isad157_jharrison.facebook_friendshipsn WHERE UserID =" + userIDF;
                    MySqlCommand cmd   = new MySqlCommand(query, connection);
                    connection.Open();
                    MySqlDataAdapter sqlDA = new MySqlDataAdapter(cmd);
                    DataTable        facebookFriendsTable = new DataTable();
                    sqlDA.Fill(facebookFriendsTable);
                    int endOfRecord = facebookFriendsTable.Rows.Count;

                    int fbID1 = 0000;
                    int fbID2 = 0000;

                    foreach (DataRow row in facebookFriendsTable.Rows)
                    {
                        fbID1 = (int)row["UserID"];
                        fbID2 = (int)row["UserID_2"];

                        // User Friends being called
                        facebookUsers tempfbuser = fbUsers.FirstOrDefault(i => i.identifier == fbID2.ToString());
                        string        fbfName    = tempfbuser.displayFormat;
                        lstUserFriends.Items.Add(fbfName);
                    }
                    connection.Close();
                }
            }
        }