public async void onCExportClicked(object sender, EventArgs args)
        {
            IAddContactsInfo addContacts = DependencyService.Get <IAddContactsInfo>();

            //get the selected contact list
            List <cItem> selectedList = new List <cItem>();
            bool         hasChecked   = false;

            foreach (cItem c in clist)
            {
                Debug.WriteLine(c.cChecked);
                if (c.cChecked == true)
                {
                    selectedList.Add(c);
                    hasChecked = true;

                    //export data
                    QContact qc = qcdb.GetQContact(c.cId);
                    addContacts.AddContacts(qc);
                }
            }

            if (hasChecked)
            {
                await DisplayAlert("Confirm", "The contact information has been sucessfully exported", "OK");

                var qcs = qcdb.GetQContacts(fbId);
                ShowContacts((List <QContact>)qcs);
                cMultiSelect.IsToggled = false;
            }
            else
            {
                await DisplayAlert("Alert", "No items selected", "OK");
            }
        }
        public ProfilePage()
        {
            InitializeComponent();

            QContactDB qcdb   = new QContactDB();
            var        pItems = new List <pItem>();

            string   fbId  = Helpers.Settings.UserId;
            string   keyId = fbId + "," + fbId;
            QContact qc    = qcdb.GetQContact(keyId);

            if (qc == null)
            {
                qc = new QContact();
            }
            var type       = qc.GetType();
            var properties = type.GetRuntimeProperties();

            foreach (PropertyInfo prop in properties)
            {
                if (!prop.Name.Equals("myIdfriendId"))
                {
                    pItem p = new pItem();
                    // Add space
                    if (!prop.Name.Equals("LinkedIn"))
                    {
                        p.pName = Regex.Replace(prop.Name, "([a-z])_?([A-Z])", "$1 $2");
                    }
                    else
                    {
                        p.pName = prop.Name;
                    }

                    if (p.pName.Equals("Birthday"))
                    {
                        if (prop.GetValue(qc, null) != null)
                        {
                            p.pValue = ((DateTime)prop.GetValue(qc, null)).ToLocalTime().ToString("MM/dd/yyyy");
                        }
                    }
                    else if (p.pName.Equals("LastModified"))
                    {
                        p.pValue = (((DateTime)prop.GetValue(qc, null)).ToString() + " UTC");
                    }
                    else
                    {
                        p.pValue = prop.GetValue(qc, null) != null?prop.GetValue(qc, null).ToString() : "";
                    }
                    pItems.Add(p);
                }
            }
            pListView.ItemsSource = pItems;
            pImage.Source         = ImageSource.FromUri(new Uri("http://graph.facebook.com/" + fbId + "/picture?type=small"));
        }
        public ProfileEditPage()
        {
            InitializeComponent();

            QContactDB qcdb = new QContactDB();
            QContact   qc   = qcdb.GetQContact(fbId + "," + fbId);

            if (qc != null)
            {
                showUsrData(qc);
            }
        }
Example #4
0
        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);
                }
            }
        }
Example #5
0
        //produce user data's json
        private string CreateUserJson(QContact qc)
        {
            string jsonStr = string.Empty;

            if (qc != null)
            {
                jsonStr = JsonConvert.SerializeObject(qc);
            }
            else
            {
                QContact emptyQc = new QContact();
                jsonStr = JsonConvert.SerializeObject(emptyQc);
            }

            Debug.WriteLine("myJson:" + jsonStr);
            return(jsonStr);
        }
Example #6
0
        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);
        }
Example #7
0
        public async void onCdExportClicked(object sender, EventArgs args)
        {
            // export data to mobile contacts
            // export data to contacts
            IAddContactsInfo addContacts = DependencyService.Get <IAddContactsInfo>();
            QContactDB       qcdb        = new QContactDB();
            QContact         qc          = qcdb.GetQContact(keyId);

            Debug.WriteLine(qc.FirstName);
            bool exResult = addContacts.AddContacts(qc);

            if (exResult)
            {
                await DisplayAlert("Confirm", "The contact information has been sucessfully exported", "OK");
            }
            else
            {
                await DisplayAlert("ERROR", "Exporting Fail", "OK");
            }

            await Navigation.PopAsync();
        }
        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();
        }
Example #9
0
        public ContactDetailPage(string keyId)
        {
            InitializeComponent();

            QContactDB qcdb    = new QContactDB();
            var        cdItems = new List <cdItem>();

            this.keyId = keyId;
            QContact qc = qcdb.GetQContact(keyId);

            if (qc == null)
            {
                qc = new QContact();
            }
            var type       = qc.GetType();
            var properties = type.GetRuntimeProperties();

            foreach (PropertyInfo prop in properties)
            {
                if (!prop.Name.Equals("myIdfriendId"))
                {
                    if (prop.Name.Equals("FirstName"))
                    {
                        cdLabel.Text += prop.GetValue(qc, null) != null?prop.GetValue(qc, null).ToString() : "";

                        cdLabel.Text += " ";
                    }
                    else if (prop.Name.Equals("LastName"))
                    {
                        cdLabel.Text += prop.GetValue(qc, null) != null?prop.GetValue(qc, null).ToString() : "";
                    }
                    else
                    {
                        cdItem cd = new cdItem();
                        // Add space
                        if (!prop.Name.Equals("LinkedIn"))
                        {
                            cd.cdName = Regex.Replace(prop.Name, "([a-z])_?([A-Z])", "$1 $2");
                        }
                        else
                        {
                            cd.cdName = prop.Name;
                        }

                        // Not show the time, only show date
                        if (cd.cdName.Equals("Birthday"))
                        {
                            if (prop.GetValue(qc, null) != null)
                            {
                                cd.cdValue = ((DateTime)prop.GetValue(qc, null)).ToLocalTime().ToString("MM/dd/yyyy");
                            }
                        }
                        else if (cd.cdName.Equals("LastModified"))
                        {
                            cd.cdValue = ((DateTime)prop.GetValue(qc, null)).ToString() + "UTC";
                        }
                        else
                        {
                            cd.cdValue = prop.GetValue(qc, null) != null?prop.GetValue(qc, null).ToString() : "";
                        }
                        cdItems.Add(cd);
                    }
                }
            }
            cdListView.ItemsSource = cdItems;
            cdImage.Source
                = ImageSource.FromUri(new Uri("http://graph.facebook.com/" + qc.myIdfriendId.Split(',')[1] + "/picture?type=small"));
        }
Example #10
0
 //Update QContact to DB
 public void UpdateQContact(QContact qcontact)
 {
     _sqlconnection.Update(qcontact);
 }
Example #11
0
 //Add new QContact to DB
 public void AddQContact(QContact qcontact)
 {
     _sqlconnection.Insert(qcontact);
 }
 public void showUsrData(QContact qc)
 {
     if (qc.FirstName != null)
     {
         peFirstName.Text = qc.FirstName;
     }
     if (qc.LastName != null)
     {
         peLastName.Text = qc.LastName;
     }
     if (qc.Company != null)
     {
         peCompany.Text = qc.Company;
     }
     if (qc.Mobile != null)
     {
         peMobile.Text = qc.Mobile;
     }
     if (qc.HomePhone != null)
     {
         peHomePhone.Text = qc.HomePhone;
     }
     if (qc.WorkPhone != null)
     {
         peWorkPhone.Text = qc.WorkPhone;
     }
     if (qc.HomeFax != null)
     {
         peHomeFax.Text = qc.HomeFax;
     }
     if (qc.WorkFax != null)
     {
         peWorkFax.Text = qc.WorkFax;
     }
     if (qc.Addr != null)
     {
         peAddr.Text = qc.Addr;
     }
     if (qc.Email != null)
     {
         peEmail.Text = qc.Email;
     }
     if (qc.Birthday != null)
     {
         peBirthday.Date = qc.Birthday;
     }
     if (qc.URL != null)
     {
         peURL.Text = qc.URL;
     }
     if (qc.Skype != null)
     {
         peSkype.Text = qc.Skype;
     }
     if (qc.Facebook != null)
     {
         peFacebook.Text = qc.Facebook;
     }
     if (qc.LinkedIn != null)
     {
         peLinkedIn.Text = qc.LinkedIn;
     }
     if (qc.Twitter != null)
     {
         peTwitter.Text = qc.Twitter;
     }
     if (qc.Instagram != null)
     {
         peInstagram.Text = qc.Instagram;
     }
 }