public Account_Page()
        {
            InitializeComponent();

            StyleChanger();

            try
            {
                var DataRow = SQL_Commander.GetProfileCredentialsById(Settings.User_id);

                UsernameEntry.Text = DataRow.Username;
                EmailEntry.Text    = DataRow.Email;
                PhoneEntry.Text    = DataRow.Phone_number;

                Username     = DataRow.Username;
                Email        = DataRow.Email;
                Phone_number = DataRow.Phone_number;

                if (DataRow.Gender == "Male" || DataRow.Gender == "male" || DataRow.Gender == AppResources.Label_Male)
                {
                    Male.Checked   = true;
                    GenderStatus   = "male";
                    Female.Checked = false;
                }
                else
                {
                    Male.Checked   = false;
                    Female.Checked = true;
                    GenderStatus   = "female";
                }
            }
            catch (Exception)
            {
            }
        }
        public MyProfilePage()
        {
            InitializeComponent();
            try
            {
                var DataRow = SQL_Commander.GetProfileCredentialsById(Settings.User_id);
                AvatarImage.Source           = DependencyService.Get <IPicture>().GetPictureFromDisk(DataRow.Avatar, Settings.User_id);
                CoverImage.Source            = DependencyService.Get <IPicture>().GetPictureFromDisk(DataRow.Cover, Settings.User_id);
                UploadAvatar.BackgroundColor = Color.FromHex(Settings.MainColor);
                UploadCover.BackgroundColor  = Color.FromHex(Settings.MainColor);

                Firstname.Text       = DataRow.First_name;
                LastName.Text        = DataRow.Last_name;
                AboutmeEntry.Text    = DataRow.About;
                LocationEntery.Text  = DataRow.Address;
                Username.Text        = DataRow.name;
                FacebookEntery.Text  = DataRow.Facebook;
                GoogleEntery.Text    = DataRow.Google;
                LinkedinEntery.Text  = DataRow.Linkedin;
                VkEntery.Text        = DataRow.vk;
                InstagramEntery.Text = DataRow.instagram;
                TwitterEntery.Text   = DataRow.Twitter;
                YoutubeEntery.Text   = DataRow.Youtube;
                //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
                Firstname_E      = DataRow.First_name;
                LastName_E       = DataRow.Last_name;
                AboutmeEntry_E   = DataRow.About;
                LocationEntery_E = DataRow.Address;
                Username_E       = DataRow.name;
                Facebook_E       = DataRow.Facebook;
                Google_E         = DataRow.Google;
                Linkedin_E       = DataRow.Linkedin;
                VK_E             = DataRow.vk;
                Instagram_E      = DataRow.instagram;
                Twitter_E        = DataRow.Twitter;
                Youtube_E        = DataRow.Youtube;

                var tapGestureRecognizer      = new TapGestureRecognizer();
                var tapGestureRecognizerCover = new TapGestureRecognizer();

                tapGestureRecognizer.Tapped += (s, ee) =>
                {
                    DependencyService.Get <IMethods>().OpenImage("Disk", DataRow.Avatar, DataRow.UserID);
                };
                tapGestureRecognizerCover.Tapped += (s, ee) =>
                {
                    DependencyService.Get <IMethods>().OpenImage("Disk", DataRow.Cover, DataRow.UserID);
                };

                AvatarImage.GestureRecognizers.Add(tapGestureRecognizer);
                CoverImage.GestureRecognizers.Add(tapGestureRecognizerCover);

                LoginUserFunctions.GetSessionProfileData(Settings.User_id, Settings.Session).ConfigureAwait(false);
            }
            catch (Exception)
            {
            }
        }
        private async Task <string> UpdateSettings(string Data)
        {
            try
            {
                using (var client = new HttpClient())
                {
                    var formContent = new FormUrlEncodedContent(new[]
                    {
                        new KeyValuePair <string, string>("user_id", Settings.User_id),
                        new KeyValuePair <string, string>("type", "profile_settings"),
                        new KeyValuePair <string, string>("s", Settings.Session),
                        new KeyValuePair <string, string>("user_data", Data)
                    });

                    var response = await client.PostAsync(Settings.Website + "/app_api.php?application=phone&type=u_user_data", formContent).ConfigureAwait(false);

                    response.EnsureSuccessStatusCode();
                    string json = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

                    var    data      = JsonConvert.DeserializeObject <Dictionary <string, object> >(json);
                    string apiStatus = data["api_status"].ToString();
                    if (apiStatus == "200")
                    {
                        var DataRow = SQL_Commander.GetProfileCredentialsById(Settings.User_id);
                        DataRow.About      = AboutmeEntry.Text;
                        DataRow.Last_name  = LastName.Text;
                        DataRow.First_name = Firstname.Text;
                        DataRow.Facebook   = FacebookEntery.Text;
                        DataRow.Google     = GoogleEntery.Text;
                        DataRow.Linkedin   = LinkedinEntery.Text;
                        DataRow.instagram  = InstagramEntery.Text;
                        DataRow.vk         = VkEntery.Text;
                        DataRow.Youtube    = YoutubeEntery.Text;
                        SQL_Commander.UpdateProfileCredentials(DataRow);
                    }
                }
                return(null);
            }
            catch (Exception)
            {
                return(null);
            }
        }
Пример #4
0
        public async Task <string> UploadPhoto(Stream stream, string image, string Mimetype, string image_type)
        {
            try
            {
                Headertext = "sssssss";
                string        Imagename = image.Split('/').Last();
                StreamContent scontent  = new StreamContent(stream);
                scontent.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
                {
                    FileName = Imagename,
                    Name     = "image"
                };
                scontent.Headers.ContentType = new MediaTypeHeaderValue(Mimetype);

                var client = new HttpClient();
                var multi  = new MultipartFormDataContent();
                var values = new[]
                {
                    new KeyValuePair <string, string>("user_id", Settings.User_id),
                    new KeyValuePair <string, string>("s", Settings.Session),
                    new KeyValuePair <string, string>("image_type", image_type)
                };
                foreach (var keyValuePair in values)
                {
                    multi.Add(new StringContent(keyValuePair.Value), keyValuePair.Key);
                }
                multi.Add(scontent);
                client.BaseAddress = new Uri(Settings.Website);

                var    result    = client.PostAsync("/app_api.php?application=phone&type=update_profile_picture", multi).Result;
                string json      = result.Content.ReadAsStringAsync().Result;
                var    data      = JsonConvert.DeserializeObject <Dictionary <string, object> >(json);
                string apiStatus = data["api_status"].ToString();

                string ImageFile = data["avatar"].ToString();

                if (apiStatus == "200")
                {
                    var DataRow = SQL_Commander.GetProfileCredentialsById(Settings.User_id);
                    DataRow.Avatar = ImageFile;
                    SQL_Commander.UpdateProfileCredentials(DataRow);

                    Device.BeginInvokeOnMainThread(() =>
                    {
                        Loaderspinner.IsVisible = false;
                    });

                    return(null);
                }
                else
                {
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        Loaderspinner.IsVisible = false;
                    });
                    return(null);
                }
            }
            catch (Exception e)
            {
                Device.BeginInvokeOnMainThread(() =>
                {
                    Loaderspinner.IsVisible = false;
                });
                return(null);
            }
        }
Пример #5
0
        public static async Task <string> GetSessionProfileData(string userid, string session)
        {
            try
            {
                using (var client = new HttpClient())
                {
                    var formContent = new FormUrlEncodedContent(new[]
                    {
                        new KeyValuePair <string, string>("user_id", Settings.User_id),
                        new KeyValuePair <string, string>("user_profile_id", userid),
                        new KeyValuePair <string, string>("s", Settings.Session)
                    });

                    var response =
                        await
                        client.PostAsync(Settings.Website + "/app_api.php?application=phone&type=get_user_data",
                                         formContent);

                    response.EnsureSuccessStatusCode();
                    string json = await response.Content.ReadAsStringAsync();

                    var    data      = JsonConvert.DeserializeObject <Dictionary <string, object> >(json);
                    string apiStatus = data["api_status"].ToString();
                    if (apiStatus == "200")
                    {
                        JObject userdata = JObject.FromObject(data["user_data"]);
                        Settings.UserFullName = userdata["name"].ToString();

                        var avatar     = userdata["avatar"].ToString();
                        var cover      = userdata["cover"].ToString();
                        var First_name = userdata["first_name"].ToString();
                        var Last_name  = userdata["last_name"].ToString();
                        var About      = userdata["about"].ToString();
                        var Website    = userdata["website"].ToString();
                        var School     = userdata["school"].ToString();
                        var name       = userdata["name"].ToString();
                        var username   = userdata["username"].ToString();
                        var gender     = userdata["gender"].ToString();
                        var birthday   = userdata["birthday"].ToString();
                        var email      = userdata["email"].ToString();
                        var address    = userdata["address"].ToString();
                        var user_id    = userdata["user_id"].ToString();
                        var url        = userdata["url"].ToString();

                        var facebook  = userdata["facebook"].ToString();
                        var google    = userdata["google"].ToString();
                        var twitter   = userdata["twitter"].ToString();
                        var linkedin  = userdata["linkedin"].ToString();
                        var youtube   = userdata["youtube"].ToString();
                        var vk        = userdata["vk"].ToString();
                        var instagram = userdata["instagram"].ToString();


                        About   = System.Net.WebUtility.HtmlDecode(About);
                        address = System.Net.WebUtility.HtmlDecode(address);

                        Settings.UserFullName = name;

                        if (DependencyService.Get <IPicture>().GetPictureFromDisk(cover, user_id) == "File Dont Exists")
                        {
                            Settings.Coverimage = new UriImageSource
                            {
                                Uri = new Uri(cover)
                            };

                            DependencyService.Get <IPicture>().SavePictureToDisk(cover, user_id);
                        }
                        else
                        {
                            Settings.Coverimage = DependencyService.Get <IPicture>().GetPictureFromDisk(cover, user_id);
                        }


                        if (DependencyService.Get <IPicture>().GetPictureFromDisk(avatar, user_id) == "File Dont Exists")
                        {
                            Settings.Avatarimage = new UriImageSource
                            {
                                Uri = new Uri(avatar)
                            };
                            DependencyService.Get <IPicture>().SavePictureToDisk(avatar, user_id);
                        }
                        else
                        {
                            Settings.Avatarimage = DependencyService.Get <IPicture>().GetPictureFromDisk(avatar, user_id);
                        }


                        var contact = SQL_Commander.GetProfileCredentialsById(user_id);
                        if (contact != null)
                        {
                            if (contact.UserID == user_id &&
                                ((contact.Cover != cover) || (contact.Avatar != avatar) ||
                                 (contact.Birthday != birthday) || (contact.name != name) ||
                                 (contact.Username != username) || (contact.First_name != First_name) ||
                                 (contact.Last_name != Last_name) || (contact.About != About) ||
                                 (contact.Website != Website) ||
                                 (contact.School != School)))
                            {
                                //Datas.DeleteProfileRow(contact);
                                if ((contact.Avatar != avatar))
                                {
                                    DependencyService.Get <IPicture>().DeletePictureFromDisk(contact.Avatar, user_id);
                                }
                                if ((contact.Cover != cover))
                                {
                                    DependencyService.Get <IPicture>().DeletePictureFromDisk(contact.Cover, user_id);
                                }

                                contact.UserID     = user_id;
                                contact.name       = name;
                                contact.Avatar     = avatar;
                                contact.Cover      = cover;
                                contact.Birthday   = birthday;
                                contact.Address    = address;
                                contact.Gender     = gender;
                                contact.Email      = email;
                                contact.Username   = username;
                                contact.First_name = First_name;
                                contact.Last_name  = Last_name;
                                contact.About      = About;
                                contact.Website    = Website;
                                contact.School     = School;
                                contact.vk         = vk;
                                contact.Facebook   = facebook;
                                contact.Google     = google;
                                contact.Linkedin   = linkedin;
                                contact.Youtube    = youtube;
                                contact.Twitter    = twitter;
                                contact.instagram  = instagram;
                                SQL_Commander.UpdateProfileCredentials(contact);
                            }
                        }
                        else
                        {
                            SQL_Commander.InsertProfileCredentials(new LoginUserProfileTableDB()
                            {
                                UserID     = user_id,
                                name       = name,
                                Avatar     = avatar,
                                Cover      = cover,
                                Birthday   = birthday,
                                Address    = address,
                                Gender     = gender,
                                Email      = email,
                                Username   = username,
                                First_name = First_name,
                                Last_name  = Last_name,
                                About      = About,
                                Website    = Website,
                                School     = School,
                                Facebook   = facebook,
                                vk         = vk,
                                Google     = google,
                                Youtube    = youtube,
                                instagram  = instagram,
                                Linkedin   = linkedin,
                                Twitter    = twitter
                            });
                        }
                    }
                    else if (apiStatus == "400")
                    {
                        json = AppResources.Label_Error;
                    }
                    return(json);
                }
            }
            catch (Exception)
            {
                return(AppResources.Label_Error);
            }
        }
        private async void Save_OnClicked(object sender, EventArgs e)
        {
            try
            {
                var device   = Resolver.Resolve <IDevice>();
                var oNetwork = device.Network; // Create Interface to Network-functions
                var xx       = oNetwork.InternetConnectionStatus() == NetworkStatus.NotReachable;
                if (xx == true)
                {
                    await DisplayAlert(AppResources.Label_Error, AppResources.Label_CheckYourInternetConnection, AppResources.Label_OK);
                }
                else
                {
                    if (NewpasswordEntry.Text != RepeatPasswordEntry.Text)
                    {
                        await DisplayAlert(AppResources.Label_Error, AppResources.Label_Your_Password_Dont_Match, AppResources.Label_OK);

                        return;
                    }
                    else
                    {
                        #region Password Update

                        if (NewpasswordEntry.Text != null && RepeatPasswordEntry.Text != null &&
                            CurrentPasswordEntry.Text != null)
                        {
                            using (var client = new HttpClient())
                            {
                                var Passwords = new Dictionary <string, string>
                                {
                                    { "current_password", CurrentPasswordEntry.Text },
                                    { "new_password", NewpasswordEntry.Text },
                                    { "repeat_new_password", RepeatPasswordEntry.Text }
                                };

                                string Pass = JsonConvert.SerializeObject(Passwords);

                                var formContent = new FormUrlEncodedContent(new[]
                                {
                                    new KeyValuePair <string, string>("user_id", Settings.User_id),
                                    new KeyValuePair <string, string>("type", "password_settings"),
                                    new KeyValuePair <string, string>("s", Settings.Session),
                                    new KeyValuePair <string, string>("user_data", Pass)
                                });

                                var response =
                                    await
                                    client.PostAsync(
                                        Settings.Website + "/app_api.php?application=phone&type=u_user_data",
                                        formContent);

                                response.EnsureSuccessStatusCode();
                                string json = await response.Content.ReadAsStringAsync();

                                var    data      = JsonConvert.DeserializeObject <Dictionary <string, object> >(json);
                                string apiStatus = data["api_status"].ToString();
                                if (apiStatus == "200")
                                {
                                    Save.Text = AppResources.Label_Saved;
                                }

                                else if (apiStatus == "500")
                                {
                                    var    errors_sugParse = JObject.Parse(json).SelectToken("errors").ToString();
                                    Object usersobj        = JsonConvert.DeserializeObject(errors_sugParse);
                                    JArray errors          = JArray.Parse(errors_sugParse);


                                    foreach (var error in errors)
                                    {
                                        await DisplayAlert(AppResources.Label_Error, error.ToString(), AppResources.Label_OK);
                                    }
                                }
                                else
                                {
                                }
                            }
                        }

                        #endregion

                        #region General Settings

                        string Gender = "male";
                        if (Female.Checked == true)
                        {
                            Gender = "female";
                        }

                        if (UsernameEntry.Text != Username || EmailEntry.Text != Email ||
                            PhoneEntry.Text != Phone_number ||
                            Gender != GenderStatus)
                        {
                            var dictionary = new Dictionary <string, string>
                            {
                                { "username", UsernameEntry.Text },
                                { "email", EmailEntry.Text },
                                { "gender", Gender },
                                { "phone_number", PhoneEntry.Text },
                            };

                            string Data = JsonConvert.SerializeObject(dictionary);

                            using (var client = new HttpClient())
                            {
                                var formContent = new FormUrlEncodedContent(new[]
                                {
                                    new KeyValuePair <string, string>("user_id", Settings.User_id),
                                    new KeyValuePair <string, string>("type", "general_settings"),
                                    new KeyValuePair <string, string>("s", Settings.Session),
                                    new KeyValuePair <string, string>("user_data", Data)
                                });

                                var response =
                                    await client.PostAsync(Settings.Website + "/app_api.php?application=phone&type=u_user_data", formContent);

                                response.EnsureSuccessStatusCode();

                                string json = await response.Content.ReadAsStringAsync();

                                var    data      = JsonConvert.DeserializeObject <Dictionary <string, object> >(json);
                                string apiStatus = data["api_status"].ToString();
                                if (apiStatus == "200")
                                {
                                    var Update = SQL_Commander.GetProfileCredentialsById(Settings.User_id);
                                    Update.Email        = EmailEntry.Text;
                                    Update.Username     = UsernameEntry.Text;
                                    Update.Phone_number = PhoneEntry.Text;
                                    Update.Gender       = Gender;
                                    SQL_Commander.UpdateProfileCredentials(Update);



                                    Save.Text = AppResources.Label_Saved;
                                }

                                else if (apiStatus == "500")
                                {
                                    var    errors_sugParse = JObject.Parse(json).SelectToken("errors").ToString();
                                    Object usersobj        = JsonConvert.DeserializeObject(errors_sugParse);
                                    JArray errors          = JArray.Parse(errors_sugParse);

                                    foreach (var error in errors)
                                    {
                                        await DisplayAlert(AppResources.Label_Error, error.ToString(), AppResources.Label_OK);
                                    }
                                }
                                else
                                {
                                }
                            }
                        }

                        #endregion
                    }
                }
            }
            catch (Exception)
            {
            }
        }
Пример #7
0
        public void GetMyprofile()
        {
            try
            {
                var TapGestureRecognizerSettings = new TapGestureRecognizer();
                TapGestureRecognizerSettings.Tapped += async(s, ee) =>
                {
                    Timeline_Pages.SettingsPage SettingsPage = new Timeline_Pages.SettingsPage();
                    await Navigation.PushAsync(SettingsPage);
                };

                var Profile            = SQL_Commander.GetProfileCredentialsById(WowonderPhone.Settings.User_id);
                var device             = Resolver.Resolve <IDevice>();
                var oNetwork           = device.Network;
                var InternetConnection = oNetwork.InternetConnectionStatus() == NetworkStatus.NotReachable;

                if (InternetConnection)
                {
                    if (Profile == null)
                    {
                        WowonderPhone.Settings.Avatarimage = "default_profile_6_400x400.png";

                        //AvatarImage.BorderColor = Color.FromHex("#c72508");
                    }
                    else
                    {
                        var GetAvatarAvailability =
                            DependencyService.Get <IPicture>().GetPictureFromDisk(Profile.Avatar, WowonderPhone.Settings.User_id);
                        if (GetAvatarAvailability != "File Dont Exists")
                        {
                            WowonderPhone.Settings.Avatarimage  = GetAvatarAvailability;
                            WowonderPhone.Settings.UserFullName = Profile.name;
                        }
                    }
                }
                else
                {
                    if (Profile != null)
                    {
                        var GetAvatarAvailability =
                            DependencyService.Get <IPicture>().GetPictureFromDisk(Profile.Avatar, WowonderPhone.Settings.User_id);
                        if (GetAvatarAvailability != "File Dont Exists")
                        {
                            WowonderPhone.Settings.Avatarimage  = GetAvatarAvailability;
                            WowonderPhone.Settings.UserFullName = Profile.name;
                        }
                        else
                        {
                            //AvatarImage.BorderColor = Color.FromHex("#6CDB26");
                            WowonderPhone.Settings.UserFullName = Profile.name;
                        }
                    }
                    else
                    {
                        LoginUserFunctions.GetSessionProfileData(WowonderPhone.Settings.User_id, WowonderPhone.Settings.Session).ConfigureAwait(false);
                    }
                }
            }
            catch (Exception)
            {
            }
        }
        public async Task <string> UploadPhoto(Stream stream, string image, string Mimetype, string image_type)
        {
            try
            {
                string        Imagename = image.Split('/').Last();
                StreamContent scontent  = new StreamContent(stream);
                scontent.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
                {
                    FileName = Imagename,
                    Name     = "image"
                };
                scontent.Headers.ContentType = new MediaTypeHeaderValue(Mimetype);

                var client = new HttpClient();
                var multi  = new MultipartFormDataContent();
                var values = new[]
                {
                    new KeyValuePair <string, string>("user_id", Settings.User_id),
                    new KeyValuePair <string, string>("s", Settings.Session),
                    new KeyValuePair <string, string>("image_type", image_type)
                };
                foreach (var keyValuePair in values)
                {
                    multi.Add(new StringContent(keyValuePair.Value), keyValuePair.Key);
                }
                multi.Add(scontent);
                client.BaseAddress = new Uri(Settings.Website);
                var    result = client.PostAsync("/app_api.php?application=phone&type=set_profile_picture", multi).Result;
                string json   = await result.Content.ReadAsStringAsync().ConfigureAwait(false);

                var    data      = JsonConvert.DeserializeObject <Dictionary <string, object> >(json);
                string apiStatus = data["api_status"].ToString();

                string ImageFile = data["avatar"].ToString();

                if (apiStatus == "200")
                {
                    var DataRow = SQL_Commander.GetProfileCredentialsById(Settings.User_id);
                    if (image_type == "avatar")
                    {
                        DataRow.Avatar = ImageFile;
                        SQL_Commander.UpdateProfileCredentials(DataRow);
                        DependencyService.Get <IPicture>().SavePictureToDisk(ImageFile, Settings.User_id);
                        Settings.Avatarimage = image;
                    }
                    if (image_type == "cover")
                    {
                        DataRow.Cover = ImageFile;
                        SQL_Commander.UpdateProfileCredentials(DataRow);
                        DependencyService.Get <IPicture>().SavePictureToDisk(ImageFile, Settings.User_id);
                        Settings.Coverimage = image;
                    }



                    return("Success");
                }
                else
                {
                    return(AppResources.Label_Error);
                }
            }
            catch (Exception e)
            {
                return(AppResources.Label_Error);
            }
        }