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(); }