//for test public void testAddContacts(string fbId) { List <QContact> qcs = new List <QContact>() { new QContact { myIdfriendId = fbId + ",6", FirstName = "Tommy", LastName = "Chen", Mobile = "18734780", Company = "Apple", Birthday = new DateTime(1990, 1, 4), HomePhone = "12345", WorkPhone = "56778", HomeFax = "1111", WorkFax = "2222", URL = "www.yahoo.com", Skype = "ttomy", Facebook = "1235", LinkedIn = "ttt" , Twitter = "www", Instagram = "@adad", Addr = "35s 21st san jose", Email = "*****@*****.**" }, new QContact { myIdfriendId = fbId + ",7", FirstName = "Steven", LastName = "Nash", Mobile = "21591359" }, new QContact { myIdfriendId = fbId + ",8", FirstName = "Jim", LastName = "Duncan", Mobile = "2975917957" }, new QContact { myIdfriendId = fbId + ",9", FirstName = "Roger", LastName = "Clemens", Mobile = "159174810" }, new QContact { myIdfriendId = fbId + ",4", FirstName = "Honus", LastName = "Wagner", Mobile = "82957175" }, new QContact { myIdfriendId = fbId + ",5", FirstName = "Stan", LastName = "Musial", Mobile = "89517957" }, }; QContactDB qcdb = new QContactDB(); for (int i = 0; i < qcs.Count; i++) { qcdb.AddQContact(qcs[i]); } }
private async void fbLoggedin(object sender, WebNavigatedEventArgs e) { FacebookOAuthResult oauthResult; System.Uri tmpUrl = new System.Uri(e.Url); if (fb.TryParseOAuthCallbackUrl(tmpUrl, out oauthResult)) { if (oauthResult.IsSuccess) { fb.AccessToken = oauthResult.AccessToken; var tmp = await fb.GetTaskAsync("me"); var result = (IDictionary <string, object>)tmp; string fbId = result["id"].ToString(); string name = result["name"].ToString(); App app = Application.Current as App; //store user info Helpers.Settings.UserName = name; Helpers.Settings.UserId = fbId; app.FbId = fbId; app.Name = name; app.AccessToken = fb.AccessToken; //save user data into database QContactDB qcdb = new QContactDB(); QContact qc = new QContact(); if (!qcdb.ExistQContact(fbId + "," + fbId)) { qc.myIdfriendId = fbId + "," + fbId; string[] names = name.Split(' '); if (names.Length > 1) { qc.FirstName = names[0]; qc.LastName = names[1]; } qc.LastModified = System.DateTime.Now.ToLocalTime(); qcdb.AddQContact(qc); //for test testAddContacts(fbId); } MainPage nextPage = new MainPage(name + "," + fbId); await Navigation.PushModalAsync(nextPage); } } }
private string AddToDB(string json) { qc = JsonConvert.DeserializeObject <QContact>(json); QContactDB qcdb = new QContactDB(); string[] friendId = qc.myIdfriendId.Split(','); qc.myIdfriendId = Helpers.Settings.UserId + "," + friendId[0]; qc.LastModified = System.DateTime.Now; if (qcdb.ExistQContact(qc.myIdfriendId)) { qcdb.UpdateQContact(qc); } else { qcdb.AddQContact(qc); } return(qc.FirstName + " " + qc.LastName); }
public void onPeOkClicked(object sender, EventArgs args) { QContact qc = new QContact(); QContactDB qcdb = new QContactDB(); qc.myIdfriendId = fbId + "," + fbId; qc.FirstName = peFirstName.Text; qc.LastName = peLastName.Text; qc.Company = peCompany.Text; qc.Mobile = peMobile.Text; qc.HomePhone = peHomePhone.Text; qc.WorkPhone = peWorkFax.Text; qc.HomeFax = peHomeFax.Text; qc.WorkFax = peWorkFax.Text; qc.Addr = peAddr.Text; qc.Email = peEmail.Text; qc.Birthday = peBirthday.Date; qc.URL = peURL.Text; qc.Skype = peSkype.Text; qc.Facebook = peFacebook.Text; qc.LinkedIn = peLinkedIn.Text; qc.Twitter = peTwitter.Text; qc.Instagram = peInstagram.Text; qc.LastModified = DateTime.Now.ToLocalTime(); Debug.WriteLine(DateTime.Now.ToLocalTime().ToString()); if (qcdb.ExistQContact(qc.myIdfriendId)) { qcdb.UpdateQContact(qc); } else { qcdb.AddQContact(qc); } Application.Current.MainPage = new MainPage(); }