Ejemplo n.º 1
0
 public void changePassoword(object sender, EventArgs e)
 {
     if (txtPassword.Text != "" && txtConfirmPassword.Text != "")
     {
         if (txtPassword.Text == txtConfirmPassword.Text)
         {
             User user = (User)Session["LoggedUser"];
             Registration regpage = new Registration();
             string changedpassword = regpage.MD5Hash(txtConfirmPassword.Text);
             UserRepository userrepo = new UserRepository();
             userrepo.ChangePassword(changedpassword, user.Password, user.EmailId);
             txtConfirmPassword.Text = string.Empty;
             txtPassword.Text = string.Empty;
             ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Message", "alert('Your password has been changed successfully.')", true);
         }
         else
         {
         
         }
     }
     else
     { 
     
     }
 }
Ejemplo n.º 2
0
        protected void btnForgotPwd_Click(object sender, ImageClickEventArgs e)
        {
            try
            {
                bool exist = false;
                UserRepository objUserRepo = new UserRepository();
                Registration regObject = new Registration();

                if (!string.IsNullOrEmpty(txtEmail.Text.Trim()))
                {
                    string strUrl = string.Empty;
                    // c.customer_email = txtEmail.Text.Trim();
                    // exist = custrepo.ExistedCustomerEmail(c);
                    User usr = objUserRepo.getUserInfoByEmail(txtEmail.Text);

                    if (usr != null)
                    {
                        string URL = Request.Url.AbsoluteUri;
                        //strUrl = Server.MapPath("~/ChangePassword.aspx") + "?str=" + txtEmail.Text + "&type=forget";
                        strUrl = URL.Replace("ForgetPassword.aspx", "ChangePassword.aspx" + "?str=" + regObject.MD5Hash(txtEmail.Text) + "&type=forget");
                        strUrl = (strUrl + "?userid=" + usr.Id).ToString();

                        string MailBody = "<body bgcolor=\"#FFFFFF\"><!-- Email Notification from SocioBoard.com-->" +
                    "<table id=\"Table_01\" style=\"margin-top: 50px; margin-left: auto; margin-right: auto;\"" +
                    " align=\"center\" width=\"650px\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" ><tr>" +
                   "<td height=\"20px\" style=\"background-color: rgb(222, 222, 222); text-align: center; font-size: 15px; font-weight: bold; font-family: Arial; color: rgb(51, 51, 51); float: left; width: 100%; margin-top: 7px; padding-top: 10px; border-bottom: 1px solid rgb(204, 204, 204); padding-bottom: 10px;\">" +
                       "SocioBoard</td></tr><!--Email content--><tr>" +
                   "<td style=\"background-color: #dedede; padding-top: 10px; padding-left: 25px; padding-right: 25px; padding-bottom: 30px; font-family: Tahoma; font-size: 14px; color: #181818; min-height: auto;\"><p>Hi , " + usr.UserName + "</p><p>" +
                       "Please click <a href=" + strUrl + " style=\"text-decoration:none;\">here</a> to proceed for password Reset</td></tr><tr>" +
                   "<td style=\"background-color: rgb(222, 222, 222); margin-top: 10px; padding-left: 20px; height: 20px; color: rgb(51, 51, 51); font-size: 15px; font-family: Arial; border-top: 1px solid rgb(204, 204, 204); padding-bottom: 10px; padding-top: 10px;\">Thanks" +
                   "</td></tr></table><!-- End Email Notification From SocioBoard.com --></body>";

                        string username = ConfigurationManager.AppSettings["username"];
                        string host = ConfigurationManager.AppSettings["host"];
                        string port = ConfigurationManager.AppSettings["port"];
                        string pass = ConfigurationManager.AppSettings["password"];
                        string from = ConfigurationManager.AppSettings["fromemail"];

                        //   string Body = mailformat.VerificationMail(MailBody, txtEmail.Text.ToString(), "");
                        string Subject = "Forget Password Socio Board account";
                        //MailHelper.SendMailMessage(host, int.Parse(port.ToString()), username, pass, txtEmail.Text.ToString(), string.Empty, string.Empty, Subject, MailBody);
                        MailHelper.SendSendGridMail(host, Convert.ToInt32(port), from, "", txtEmail.Text.ToString(), string.Empty, string.Empty, Subject, MailBody, username, pass);

                        lblerror.Text = "Please check your mail for the instructions.";
                    }
                    else
                    {
                        lblerror.Text = "Your Email is wrong Please try another one";
                    }
                }
                //else
                //{
                //    lblerror.Text = "Please enter your Email-Id";
                //}
            }
            catch (Exception Err)
            {
                logger.Error(Err.StackTrace);
            }
        }
Ejemplo n.º 3
0
        public static void SendInvitationEmail(string username, string sendername, string email, Guid teamid)
        {
            try
            {
                Registration reg = new Registration();
                string tid = reg.MD5Hash(email);
                MailHelper mailhelper = new MailHelper();
                string mailpath = HttpContext.Current.Server.MapPath("~/Layouts/Mails/SendInvitation.htm");
                string html = File.ReadAllText(mailpath);
                string fromemail = ConfigurationManager.AppSettings["fromemail"];
                string usernameSend = ConfigurationManager.AppSettings["username"];
                string host = ConfigurationManager.AppSettings["host"];
                string port = ConfigurationManager.AppSettings["port"];
                string pass = ConfigurationManager.AppSettings["password"];
                string urllogin = "******";
                string registrationurl = "http://ssp.socioboard.com/Registration.aspx?tid=" + teamid;
                string Body = mailhelper.InvitationMail(html, username, sendername, "", urllogin, registrationurl);
                string Subject = "You've been Invited to " + username + " SocialSuitePro Account";
                //   MailHelper.SendMailMessage(host, int.Parse(port.ToString()), fromemail, pass, email, string.Empty, string.Empty, Subject, Body);

                MailHelper.SendSendGridMail(host, Convert.ToInt32(port), fromemail, "", email, "", "", Subject, Body, usernameSend, pass);

            }
            catch (Exception ex)
            {

                logger.Error(ex.Message);
            }
        }
Ejemplo n.º 4
0
        public void changePassoword(object sender, EventArgs e)
        {
            try
            {
                Registration regpage = new Registration();
                string OldPassword = regpage.MD5Hash(txtOldPassword.Text);
                if (txtOldPassword.Text != "")
                {
                    if (txtPassword.Text.Trim() != "" && txtConfirmPassword.Text.Trim() != "" && txtOldPassword.Text != "")
                    {
                        if (txtPassword.Text == txtConfirmPassword.Text)
                        {
                            User user = (User)Session["LoggedUser"];
                            if (OldPassword == user.Password)
                            {

                                string changedpassword = regpage.MD5Hash(txtConfirmPassword.Text);
                                UserRepository userrepo = new UserRepository();
                                userrepo.ChangePassword(changedpassword, user.Password, user.EmailId);
                                txtConfirmPassword.Text = string.Empty;
                                txtPassword.Text = string.Empty;
                                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Message", "alert('Your password has been changed successfully.')", true);
                            }
                            else
                            {
                                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Message", "alert('Your password is Incorrect.')", true);
                            }
                        }
                        else
                        {
                            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Message", "alert('Password Mismatch.')", true);
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Message", "alert('Invalid Password.')", true);
                    }
                }
                else
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Message", "alert('Please enter your old password.')", true);
                }
            }
            catch (Exception ex)
            {

                Console.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 5
0
        protected void btnForgotPwd_Click(object sender, ImageClickEventArgs e)
        {
            try
            {
                bool exist = false;
                UserRepository objUserRepo = new UserRepository();
                Registration regObject = new Registration();

                if (!string.IsNullOrEmpty(txtEmail.Text.Trim()))
                {
                    string strUrl = string.Empty;
                    User usr = objUserRepo.getUserInfoByEmail(txtEmail.Text);
                    if (usr != null)
                    {
                        string URL = Request.Url.AbsoluteUri;
                        strUrl = URL.Replace("ForgetPassword.aspx", "ChangePassword.aspx" + "?str=" + regObject.MD5Hash(txtEmail.Text) + "&type=forget");
                        strUrl = (strUrl + "?userid=" + usr.Id).ToString();
                        string mailpath = HttpContext.Current.Server.MapPath("~/Layouts/Mails/ResetPassword.htm");
                        string MailBody = File.ReadAllText(mailpath);
                        MailBody = MailBody.Replace("%replink%", strUrl);
                        MailBody = MailBody.Replace("%name%", usr.UserName);
                        string username = ConfigurationManager.AppSettings["username"];
                        string host = ConfigurationManager.AppSettings["host"];
                        string port = ConfigurationManager.AppSettings["port"];
                        string pass = ConfigurationManager.AppSettings["password"];
                        string from = ConfigurationManager.AppSettings["fromemail"];

                        //   string Body = mailformat.VerificationMail(MailBody, txtEmail.Text.ToString(), "");
                        string Subject = "Forget Password SocioBoard account";
                        //MailHelper.SendMailMessage(host, int.Parse(port.ToString()), username, pass, txtEmail.Text.ToString(), string.Empty, string.Empty, Subject, MailBody);
                        MailHelper.SendSendGridMail(host, Convert.ToInt32(port), from, "", txtEmail.Text.ToString(), string.Empty, string.Empty, Subject, MailBody, username, pass);
                        lblerror.Text = "Please check your mail for the instructions.";
                    }
                    else
                    {
                        lblerror.Text = "Your Email is wrong Please try another one";
                    }
                }
            }
            catch (Exception Err)
            {
                logger.Error(Err.StackTrace);
            }
        }
Ejemplo n.º 6
0
        protected void btnResetPwd_Click(object sender, ImageClickEventArgs e)
        {
            try
            {
                Registration regpage = new Registration();

                if (txtpass.Text == txtconfirmpass.Text)
                {
                    string changedpassword = regpage.MD5Hash(txtpass.Text);
                    UserRepository userrepo = new UserRepository();
                    if (userrepo.ResetPassword(Guid.Parse(userid.ToString()), changedpassword.ToString()) > 0)
                    {
                        lblerror.Text = "Password Reset Successfully";
                    }
                    else
                    {
                        lblerror.Text = "Problem while resetting password";
                    }
                }
                else
                {
                    lblerror.Text = "Password mismatch!";
                }

            }
            catch (Exception Err)
            {
                logger.Error(Err.StackTrace);
            }
        }
Ejemplo n.º 7
0
        protected void btnResetPwd_Click(object sender, ImageClickEventArgs e)
        {
            UserRepository userrepo = new UserRepository();
            
            try
            {
                Registration regpage = new Registration();

                if (txtpass.Text == txtconfirmpass.Text)
                {
                    string changedpassword = regpage.MD5Hash(txtpass.Text);
                   
                    if (userrepo.ResetPassword(Guid.Parse(userid.ToString()), changedpassword.ToString()) > 0)
                    {
                        User usr = userrepo.getUsersById(Guid.Parse(userid.ToString()));

                        // Code written by Abhay Kr Mondal 8/8/2014
                        ///below block of code is used to send email with user information
                        ///Begin
                        string strUrl = string.Empty;
                        string URL = Request.Url.AbsoluteUri;
                        //strUrl = URL.Replace("ForgetPassword.aspx", "ChangePassword.aspx" + "?str=" + regObject.MD5Hash(txtEmail.Text) + "&type=forget");
                        //strUrl = (strUrl + "?userid=" + usr.Id).ToString();
                        string mailpath = HttpContext.Current.Server.MapPath("~/Layouts/Mails/UserInfo.htm");
                        string MailBody = File.ReadAllText(mailpath);
                        MailBody = MailBody.Replace("%FN%", usr.UserName);
                        MailBody = MailBody.Replace("%UN%", usr.EmailId);
                        MailBody = MailBody.Replace("%PWD%", txtpass.Text.ToString());
                        string username = ConfigurationManager.AppSettings["username"];
                        string host = ConfigurationManager.AppSettings["host"];
                        string port = ConfigurationManager.AppSettings["port"];
                        string pass = ConfigurationManager.AppSettings["password"];
                        string from = ConfigurationManager.AppSettings["fromemail"];

                        //   string Body = mailformat.VerificationMail(MailBody, txtEmail.Text.ToString(), "");
                        string Subject = "New Password for Your Socioboard Account";
                        //MailHelper.SendMailMessage(host, int.Parse(port.ToString()), username, pass, txtEmail.Text.ToString(), string.Empty, string.Empty, Subject, MailBody);
                        MailHelper.SendSendGridMail(host, Convert.ToInt32(port), from, "", usr.EmailId.ToString(), string.Empty, string.Empty, Subject, MailBody, username, pass);
                       // lblerror.Text = "Please check your mail for the instructions.";

                        // Code written by Abhay Kr Mondal 8/8/2014
                        ///below block of code is used to send email with user information

                        lblerror.Text = "Password Reset Successfully";
                    }
                    else
                    {
                        lblerror.Text = "Problem while resetting password";
                    }
                }
                else
                {
                    lblerror.Text = "Password mismatch!";
                }


            }
            catch (Exception Err)
            {
                logger.Error(Err.StackTrace);
            }
        }
Ejemplo n.º 8
0
        public string Register(string EmailId, string Password, string AccountType, string FirstName, string LastName)
        {
            try
            {
                UserRepository userrepo = new UserRepository();
                if (!userrepo.IsUserExist(EmailId))
                {
                    Registration regObject = new Registration();
                    User user = new User();
                    user.AccountType = AccountType;
                    user.EmailId = EmailId;
                    user.CreateDate = DateTime.Now;
                    user.ExpiryDate = DateTime.Now.AddMonths(1);
                    user.Password = regObject.MD5Hash(Password);
                    user.PaymentStatus = "unpaid";
                    user.ProfileUrl = string.Empty;
                    user.TimeZone = string.Empty;
                    user.UserName = FirstName + " " + LastName;
                    user.UserStatus = 1;
                    user.Id = Guid.NewGuid();
                    UserRepository.Add(user);
                    MailSender.SendEMail(user.UserName, Password, EmailId);
                    return new JavaScriptSerializer().Serialize(user);
                }
                else
                {
                    return "Email Already Exists";
                }

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                return "Something Went Wrong";
            }
        }
Ejemplo n.º 9
0
        public string Login(string EmailId, string Password)
        {
            //
            try
            {
                UserRepository userrepo = new UserRepository();
                Registration regObject = new Registration();
                User user = userrepo.GetUserInfo(EmailId, regObject.MD5Hash(Password));

                if (user != null)
                {
                    return new JavaScriptSerializer().Serialize(user);
                }
                else
                {
                    return "Invalid user name or password";
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                return null;
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 
        /// </summary>
        private void getTwitterUserProfile()
        {
            var requestToken = (String)Request.QueryString["oauth_token"];
            var requestSecret = (String)Session["requestSecret"];
            var requestVerifier = (String)Request.QueryString["oauth_verifier"];

            OAuth.AccessToken = requestToken;
            OAuth.AccessTokenSecret = requestVerifier;
            OAuth.AccessTokenGet(requestToken, requestVerifier);

            JArray profile = userinfo.Get_Users_LookUp_ByScreenName(OAuth, OAuth.TwitterScreenName);
            User user = (User)Session["LoggedUser"];
            SocialProfilesRepository socioprofilerepo = new SocialProfilesRepository();
            SocialProfile socioprofile = new SocialProfile();
            foreach (var item in profile)
            {
                try
                {
                    twitterAccount.FollowingCount = Convert.ToInt32(item["friends_count"].ToString());
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
                try
                {
                    twitterAccount.FollowersCount = Convert.ToInt32(item["followers_count"].ToString());
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
                twitterAccount.Id = Guid.NewGuid();
                twitterAccount.IsActive = true;
                twitterAccount.OAuthSecret = OAuth.AccessTokenSecret;
                twitterAccount.OAuthToken = OAuth.AccessToken;
                try
                {
                    twitterAccount.ProfileImageUrl = item["profile_image_url"].ToString().TrimStart('"').TrimEnd('"');
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);

                }
                try
                {
                    twitterAccount.ProfileUrl = string.Empty;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
                try
                {
                    twitterAccount.TwitterUserId = item["id_str"].ToString().TrimStart('"').TrimEnd('"');
                }
                catch (Exception er)
                {
                    try
                    {
                        twitterAccount.TwitterUserId = item["id"].ToString().TrimStart('"').TrimEnd('"');
                    }
                    catch (Exception err)
                    {
                        Console.WriteLine(err.StackTrace);
                    }
                    Console.WriteLine(er.StackTrace);

                }

                try
                {
                    twitterAccount.TwitterScreenName = item["screen_name"].ToString().TrimStart('"').TrimEnd('"');
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
                twitterAccount.UserId = user.Id;

                socioprofile.Id = Guid.NewGuid();
                socioprofile.ProfileDate = DateTime.Now;
                socioprofile.ProfileId = twitterAccount.TwitterUserId;
                socioprofile.ProfileType = "twitter";
                socioprofile.UserId = user.Id;

                if (HttpContext.Current.Session["login"] != null)
                {
                    if (HttpContext.Current.Session["login"].ToString().Equals("twitter"))
                    {
                        User usr = new User();
                        UserRepository userrepo = new UserRepository();
                        Registration regObject = new Registration();
                        usr.AccountType = "free";
                        usr.CreateDate = DateTime.Now;
                        usr.ExpiryDate = DateTime.Now.AddMonths(1);
                        usr.Id = Guid.NewGuid();
                        usr.UserName = twitterAccount.TwitterName;
                        usr.Password = regObject.MD5Hash(twitterAccount.TwitterName);
                        usr.EmailId = "";
                        usr.UserStatus = 1;
                        if (!userrepo.IsUserExist(usr.EmailId))
                        {
                            UserRepository.Add(usr);
                        }
                    }
                }
                TwitterStatsRepository objTwtstats = new TwitterStatsRepository();
                TwitterStats objStats = new TwitterStats();
                Random rNum = new Random();
                objStats.Id = Guid.NewGuid();
                objStats.TwitterId = twitterAccount.TwitterUserId;
                objStats.UserId = user.Id;
                objStats.FollowingCount = twitterAccount.FollowingCount;
                objStats.FollowerCount = twitterAccount.FollowersCount;
                objStats.Age1820 = rNum.Next(twitterAccount.FollowersCount);
                objStats.Age2124 = rNum.Next(twitterAccount.FollowersCount);
                objStats.Age2534 = rNum.Next(twitterAccount.FollowersCount);
                objStats.Age3544 = rNum.Next(twitterAccount.FollowersCount);
                objStats.Age4554 = rNum.Next(twitterAccount.FollowersCount);
                objStats.Age5564 = rNum.Next(twitterAccount.FollowersCount);
                objStats.Age65 = rNum.Next(twitterAccount.FollowersCount);
                objStats.EntryDate = DateTime.Now;
                if (!objTwtstats.checkTwitterStatsExists(twitterAccount.TwitterUserId, user.Id))
                    objTwtstats.addTwitterStats(objStats);
                if (!twtrepo.checkTwitterUserExists(twitterAccount.TwitterUserId, user.Id))
                {
                    twtrepo.addTwitterkUser(twitterAccount);
                    if (!socioprofilerepo.checkUserProfileExist(socioprofile))
                    {
                        socioprofilerepo.addNewProfileForUser(socioprofile);
                    }
                    else
                    {
                        socioprofilerepo.updateSocialProfile(socioprofile);
                    }
                }
                else
                {
                    twtrepo.updateTwitterUser(twitterAccount);
                    if (!socioprofilerepo.checkUserProfileExist(socioprofile))
                    {
                        socioprofilerepo.addNewProfileForUser(socioprofile);
                    }
                    else
                    {
                        socioprofilerepo.updateSocialProfile(socioprofile);
                    }

                }
                if (Session["UserAndGroupsForTwitter"] != null)
                {
                    if (Session["UserAndGroupsForTwitter"].ToString() == "twitter")
                    {
                        try
                        {
                            if (Session["GroupName"] != null)
                            {
                                Groups group = (Groups)Session["GroupName"];
                                GroupProfile groupprofile = new GroupProfile();
                                GroupProfileRepository groupprofilerepo = new GroupProfileRepository();
                                groupprofile.Id = Guid.NewGuid();
                                groupprofile.ProfileId = socioprofile.ProfileId;
                                groupprofile.ProfileType = "twitter";
                                groupprofile.GroupOwnerId = user.Id;
                                groupprofile.EntryDate = DateTime.Now;
                                groupprofile.GroupId = group.Id;
                                if (!groupprofilerepo.checkGroupProfileExists(user.Id, group.Id, groupprofile.ProfileId))
                                {
                                    groupprofilerepo.AddGroupProfile(groupprofile);
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e.StackTrace);
                        }
                    }
                }

            }
        }