コード例 #1
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);
            }
        }
コード例 #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;
                    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);
            }
        }
コード例 #3
0
        public void ProcessRequest()
        {
           TeamRepository objTeamRepository = new TeamRepository();
           TeamMemberProfileRepository objTeamMemberProfileRepository=new TeamMemberProfileRepository();
           FacebookAccountRepository fbaccountrepo = new FacebookAccountRepository();
           TwitterAccountRepository twtaccountrepo = new TwitterAccountRepository();
           LinkedInAccountRepository linkedaccrepo = new LinkedInAccountRepository();
           InstagramAccountRepository instagramrepo = new InstagramAccountRepository();
           GroupProfileRepository groupprofilerepo = new GroupProfileRepository();
           BusinessSettingRepository objbsnsrepo = new BusinessSettingRepository();
           TumblrAccountRepository tumblrrepo = new TumblrAccountRepository();





            User user = (User)Session["LoggedUser"];
            if (Request.QueryString["op"] != null)
            {

                if (Request.QueryString["op"] == "SaveGroupName")
                {
                    string groupName = Request.QueryString["groupname"];
                    GroupRepository grouprepo = new GroupRepository();
                    Groups group = new Groups();
                    group.Id = Guid.NewGuid();
                    group.GroupName = groupName;
                    group.UserId = user.Id;
                    group.EntryDate = DateTime.Now;
                  
                    if (!grouprepo.checkGroupExists(user.Id, groupName))
                    {
                        
                        grouprepo.AddGroup(group);
                        Groups grou = grouprepo.getGroupDetails(user.Id, groupName);
                        Session["GroupName"] = grou;
                    }
                    else
                    {
                        Groups grou = grouprepo.getGroupDetails(user.Id, groupName);
                        Session["GroupName"] = grou;
                    }
                }
                else if (Request.QueryString["op"] == "bindGroupProfiles")
                {
                    string bindprofiles = string.Empty;
                    Guid groupid = Guid.Parse(Request.QueryString["groupId"]);
                    Session["GroupId"] = groupid;
                    GroupProfileRepository groupprofilesrepo = new GroupProfileRepository();
                    List<GroupProfile> lstgroupprofile = groupprofilesrepo.getAllGroupProfiles(user.Id, groupid);
                    foreach (GroupProfile item in lstgroupprofile)
                    {
                        if (item.ProfileType == "facebook")
                        {
                           
                            FacebookAccount account = fbaccountrepo.getFacebookAccountDetailsById(item.ProfileId, user.Id);
                            if (account != null)
                            {
                                bindprofiles += "<div id=\"facebook_" + item.ProfileId + "\" class=\"ws_conct\"> <span class=\"img\"><img width=\"48\" height=\"48\" src=\"http://graph.facebook.com/" + item.ProfileId + "/picture?type=small\" alt=\"\"><i><img width=\"16\" height=\"16\" src=\"../Contents/img/fb_icon.png\" alt=\"\"></i></span><div class=\"fourfifth\">" +
                                    "<div class=\"location-container\">" + account.FbUserName + "</div><span onclick=\"AddProfileInInviteTeamMember('" + account.FbUserId + "','" + groupid + "','" + item.ProfileType + "')\" class=\"add remove\">+</span><span onclick=\"RemoveProfileFromGroup('" + item.ProfileId + "')\" class=\"add remove\">✖</span></div></div>";
                            }
                        }
                        else if (item.ProfileType == "twitter")
                        {
                            TwitterAccount twtaccount = twtaccountrepo.getUserInformation(user.Id, item.ProfileId);
                            string profileimgurl = string.Empty;
                            if (twtaccount != null)
                            {
                            if (twtaccount.ProfileImageUrl == string.Empty)
                            {
                                profileimgurl = "../../Contents/img/blank_img.png";
                            }
                            else
                            {
                                profileimgurl = twtaccount.ProfileImageUrl;
                            }
                          
                                bindprofiles +=
                                       "<div id=\"twitter_" + item.ProfileId + "\" class=\"ws_conct active\"> <span class=\"img\"><img width=\"48\" height=\"48\" src=\"" + profileimgurl + "\" alt=\"\"><i><img width=\"16\" height=\"16\" src=\"../Contents/img/twticon.png\" alt=\"\"></i></span><div class=\"fourfifth\">" +
                                       "<div class=\"location-container\">" + twtaccount.TwitterScreenName + "</div><span onclick=\"AddProfileInInviteTeamMember('" + twtaccount.TwitterUserId + "','"+groupid+"','" + item.ProfileType + "')\" class=\"add remove\">+</span><span onclick=\"RemoveProfileFromGroup('" + item.ProfileId + "')\"  class=\"add remove\">✖</span></div></div>";
                            }
                        }
                        else if (item.ProfileType == "linkedin")
                        {                            
                            LinkedInAccount linkedaccount = linkedaccrepo.getUserInformation(user.Id, item.ProfileId);
                            string profileimgurl = string.Empty;
                            if (linkedaccount != null)
                            {
                                if (linkedaccount.ProfileUrl == string.Empty)
                                {
                                    profileimgurl = "../../Contents/img/blank_img.png";
                                }
                                else
                                {
                                    profileimgurl = linkedaccount.ProfileImageUrl;
                                }
                                bindprofiles += "<div id=\"linkedin_" + item.ProfileId + "\" class=\"ws_conct active\"><span class=\"img\"><img width=\"48\" height=\"48\" alt=\"\" src=\"" + profileimgurl + "\" ><i>" +
                                                 "<img width=\"16\" height=\"16\" alt=\"\" src=\"../Contents/img/link_icon.png\"></i></span>" +
                                                 "<div class=\"fourfifth\"><div class=\"location-container\">" + linkedaccount.LinkedinUserName + "</div>" +
                                                 "<span onclick=\"AddProfileInInviteTeamMember('" + linkedaccount.LinkedinUserId + "','" + groupid + "','" + item.ProfileType + "')\" class=\"add remove\">+</span><span onclick=\"RemoveProfileFromGroup('" + item.ProfileId + "')\" class=\"add remove\">✖</span></div></div>";
                            }
                        }

                        else if (item.ProfileType == "tumblr")
                        {
                            TumblrAccount tumblraccount = tumblrrepo.getTumblrAccountDetailsById(item.ProfileId,user.Id);
                            string profileimgurl = string.Empty;
                            if (tumblraccount != null)
                            {
                                if (tumblraccount.tblrProfilePicUrl == string.Empty)
                                {
                                    profileimgurl = "../../Contents/img/blank_img.png";
                                }
                                else
                                {
                                    profileimgurl = "http://api.tumblr.com/v2/blog/" + tumblraccount.tblrUserName + ".tumblr.com/avatar"; 
                                }
                                bindprofiles += "<div id=\"tumblr_" + item.ProfileId + "\" class=\"ws_conct active\"><span class=\"img\"><img width=\"48\" height=\"48\" alt=\"\" src=\"http://api.tumblr.com/v2/blog/" + tumblraccount.tblrUserName + ".tumblr.com/avatar\" ><i>" +
                                                 "<img width=\"16\" height=\"16\" alt=\"\" src=\"../Contents/img/tumblr.png\"></i></span>" +
                                                 "<div class=\"fourfifth\"><div class=\"location-container\">" +tumblraccount.tblrUserName + "</div>" +
                                                 "<span onclick=\"AddProfileInInviteTeamMember('" + tumblraccount.tblrUserName + "','" + groupid + "','" + item.ProfileType + "')\" class=\"add remove\">+</span><span onclick=\"RemoveProfileFromGroup('" + item.ProfileId + "')\" class=\"add remove\">✖</span></div></div>";
                            }
                        }



                        else if (item.ProfileType == "instagram")
                        {
                            string profileimgurl = string.Empty;
                            
                            InstagramAccount instaaccount = instagramrepo.getInstagramAccountDetailsById(item.ProfileId, user.Id);
                            if (instaaccount != null)
                            {
                                if (instaaccount.ProfileUrl == string.Empty)
                                {
                                    profileimgurl = "../../Contents/img/blank_img.png";
                                }
                                else
                                {
                                    profileimgurl = instaaccount.ProfileUrl;
                                }

                                bindprofiles += "<div id=\"instagram_" + item.ProfileId + "\" class=\"ws_conct active\"><span class=\"img\"><img width=\"48\" height=\"48\" src=\"" + profileimgurl + "\" alt=\"\"><i>" +
                                                  "<img width=\"16\" height=\"16\" alt=\"\" src=\"../Contents/img/instagram_24X24.png\"></i></span><div class=\"fourfifth\"><div class=\"location-container\">" + instaaccount.InsUserName + "</div>" +
                                    "<span onclick=\"AddProfileInInviteTeamMember('" + instaaccount.InstagramId + "','" + groupid + "','" + item.ProfileType + "')\" class=\"add remove\">+</span><span onclick=\"RemoveProfileFromGroup('" + item.ProfileId + "')\" class=\"add remove\">✖</span></div></div>";
                            }
                        }
                   }
                    Response.Write(bindprofiles);

                }
                else if (Request.QueryString["op"] == "deleteGroupName")
                {
                    Guid groupid = Guid.Parse(Request.QueryString["groupId"]);
                 
                    GroupRepository grouprepo = new GroupRepository();
                    grouprepo.DeleteGroup(groupid);                  
                    int count = groupprofilerepo.DeleteAllGroupProfile(groupid);
                    int cnt = objbsnsrepo.DeleteBusinessSettingByUserid(groupid);

                    List<Team> objTeamId = objTeamRepository.getAllDetailsUserEmail(groupid);
                    foreach (Team item in objTeamId)
                    {
                        int deteleTeamMember = objTeamMemberProfileRepository.deleteTeamMember(item.Id);
                        
                    }
                    int deleteTeam = objTeamRepository.deleteGroupRelatedTeam(groupid);

                }
                else if (Request.QueryString["op"] == "addProfilestoGroup")
                {
                    string network = Request.QueryString["network"];
                    string id = Request.QueryString["profileid"];
                    Guid groupid = (Guid)Session["GroupId"];
                    GroupProfile groupprofile = new GroupProfile();
                    groupprofile.EntryDate = DateTime.Now;
                    groupprofile.GroupId = groupid;
                    groupprofile.Id = Guid.NewGuid();
                    groupprofile.ProfileId = id;
                    groupprofile.ProfileType = network;
                    groupprofile.GroupOwnerId = user.Id;

                    GroupProfileRepository grouprepo = new GroupProfileRepository();

                    if (!grouprepo.checkGroupProfileExists(user.Id, groupid, id))
                    {
                        grouprepo.AddGroupProfile(groupprofile);
                    }

                    Response.Write(groupid);

                }
                else if (Request.QueryString["op"] == "deleteGroupProfiles")
                {
                    Guid groupid = (Guid)Session["GroupId"];
                    try
                    {
                        string profileid = Request.QueryString["profileid"];
                        GroupProfileRepository grouprepo = new GroupProfileRepository();
                        grouprepo.DeleteGroupProfile(user.Id, profileid, groupid);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    Response.Write(groupid);
                }

                if (Request.QueryString["op"] == "GetInviteMember")
                {
                    string bindprofiles = string.Empty;
                    string profileimgurl = string.Empty;

                    try
                    {
                        string gp = Request.QueryString["groupId"];
                        Guid GroupId = Guid.Parse(gp);
                       // TeamRepository objTeamRepository = new TeamRepository();
                        List<Team> objTeam = objTeamRepository.getAllDetailsUserEmail(GroupId);
                      
                        if (objTeam.Count != 0)
                        {
                            foreach (Team item in objTeam)
                            {
                                UserRepository objUserRepository = new UserRepository();
                                User ObjUserDetails = objUserRepository.getUserInfoByEmail(item.EmailId);
                                if (ObjUserDetails != null)
                                {
                                    if (string.IsNullOrEmpty(ObjUserDetails.ProfileUrl))
                                    {
                                        profileimgurl = "../../Contents/img/blank_img.png";
                                    }
                                    else
                                    {
                                        profileimgurl = ObjUserDetails.ProfileUrl;
                                    }

                                    bindprofiles += "<div style=\"float:left; margin-right:18%\"id=\"" + item.Id + "\">" +
                                                 "<div style=\"float:left\"><span class=\"img\"><img width=\"48\" height=\"48\" src=\"" + profileimgurl + "\" alt=\"\"></span>" +
                                                "</div><div style=\"float:left\" class=\"fourfifth\"><div style=\"font-size:small \">" + ObjUserDetails.UserName + "</div> </div><div style=\"float:left;margin-left:3px\" onclick=\"ShowInviteMemberProfileDetails('" + GroupId + "','" + ObjUserDetails.EmailId + "','" + user.Id + "')\"><input class=\"abc\" type=\"radio\" name=\"sex\" value=" + item.Id + "></div>" +
                                                "<span onclick=\"RemoveInviteMemberFromGroup('" + item.Id + "')\" style=\"margin-left:25px;font-size:small;cursor:pointer;position: absolute; margin-top: 28px;margin-left:10px\">x</span></div>";

                                    //bindprofiles += "<div id=\"" + item.Id + "\" class=\"ws_conct active\"> <span class=\"img\"><img width=\"48\" height=\"48\" src=\"" + profileimgurl + "\" alt=\"\"><i><img width=\"16\" height=\"16\" src=\"../Contents/img/twticon.png\" alt=\"\"></i></span><div class=\"fourfifth\">" +
                                    //  "<div class=\"location-container\">" + ObjUserDetails.UserName + "</div><span class=\"add remove\" onclick=\"ShowInviteMemberProfileDetails('" + GroupId + "','" + ObjUserDetails.EmailId + "','" + user.Id + "')\"><input class=\"abc\" type=\"radio\" name=\"sex\" value=" + item.Id + "></span><span onclick=\"RemoveInviteMemberFromGroup('" + item.Id + "')\"  class=\"add remove\">✖</span></div></div>";
                                    
                                    
                                    
                                                                                                                                                                                                  
                                }
                            }
                        }

                        Response.Write(bindprofiles);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);

                    }
                }

                if (Request.QueryString["op"] == "RemoveInviteMemberFromGroup")
                {
                    if (!string.IsNullOrEmpty(Request.QueryString["Id"]))
                    {
                        try
                        {
                            string ide = Request.QueryString["Id"];
                            Guid id = Guid.Parse(ide);
                            int deleteTeam = objTeamRepository.deleteinviteteamMember(id);
                            int deleteProfiles = objTeamMemberProfileRepository.DeleteTeamMemberProfileByTeamId(id);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);

                        }
                    }
                }

                //modified by hozefa 4-7-2014   
                if (Request.QueryString["op"] == "ShowInviteMemberProfileDetails")
                {
                    string bindprofiles = string.Empty;
                    string gpId = Request.QueryString["groupId"];
                    Guid gpid = Guid.Parse(gpId);
                    string emailId = Request.QueryString["emailid"];
                    string userId = Request.QueryString["userid"];

                    Team teamdata = objTeamRepository.getAllDetails(gpid, emailId);

                    List<TeamMemberProfile> objTeamMemProfile = objTeamMemberProfileRepository.getAllTeamMemberProfilesOfTeam(teamdata.Id);
                    try
                    {
                        foreach (TeamMemberProfile item in objTeamMemProfile)
                        {
                            if (item.ProfileType == "facebook")
                            {

                                FacebookAccount account = fbaccountrepo.getFacebookAccountDetailsById(item.ProfileId);
                                if (account != null)
                                {
                                    bindprofiles += "<div id=\"item\" style=\"float:left;width:170px;margin-top:6px\"  id=\"facebook_" + item.ProfileId + "\"><div style=\"float:left\"<span class=\"img\">" +
                                             "<img width=\"48\" height=\"48\" src=\"http://graph.facebook.com/" + item.ProfileId + "/picture?type=small\" alt=\"\"></img><i><img style=\"margin-left:-18px\" width=\"16\" height=\"16\" src=\"../Contents/img/fb_icon.png\" alt=\"\"></img></i>" +
                                             "</span></div><div style=\"float:left\"><div style=\"font-size:small\">" + account.FbUserName + "</div></div>" +
                                              "<span  onclick=\"RemoveInviteMemberProfileFromTeamMember('" + teamdata.Id + "','" + item.ProfileId + "','" + gpId + "','" + emailId + "','" + userId + "')\" style=\"margin-left:25px;font-size:small;cursor:pointer;position: absolute; margin-top: 28px;margin-left:10px\">x</span></div>";
                                }
                            }
                            else if (item.ProfileType == "twitter")
                            {
                                TwitterAccount twtaccount = twtaccountrepo.getUserInformation(item.ProfileId);
                                string profileimgurl = string.Empty;
                                if (twtaccount != null)
                                {
                                    if (twtaccount.ProfileImageUrl == string.Empty)
                                    {
                                        profileimgurl = "../../Contents/img/blank_img.png";
                                    }
                                    else
                                    {
                                        profileimgurl = twtaccount.ProfileImageUrl;
                                    }

                                    bindprofiles += "<div id=\"item\" style=\"float:left; width:170px;margin-top:6px\"   id=\"twitter_" + item.ProfileId + "\"><div style=\"float:left\"<span class=\"img\">" +
                                             "<img width=\"48\" height=\"48\" src=\"" + profileimgurl + "\" alt=\"\"></img><i><img style=\"margin-left:-18px\" width=\"16\" height=\"16\" src=\"../Contents/img/twticon.png\" alt=\"\"></img></i>" +
                                             "</span></div><div style=\"float:left\"><div style=\"font-size:small\">" + twtaccount.TwitterScreenName + "</div></div>" +
                                              "<span onclick=\"RemoveInviteMemberProfileFromTeamMember('" + teamdata.Id + "','" + item.ProfileId + "','" + gpId + "','" + emailId + "','" + userId + "')\" style=\"margin-left:25px;font-size:small;cursor:pointer;position: absolute; margin-top: 28px;margin-left:10px\">x</span></div>";
                                }
                            }

                            else if (item.ProfileType == "linkedin")
                            {

                                LinkedInAccount linkedaccount = linkedaccrepo.getUserInformation(item.ProfileId);
                                string profileimgurl = string.Empty;
                                if (linkedaccount != null)
                                {
                                    if (linkedaccount.ProfileUrl == string.Empty)
                                    {
                                        profileimgurl = "../../Contents/img/blank_img.png";
                                    }
                                    else
                                    {
                                        profileimgurl = linkedaccount.ProfileImageUrl;
                                    }

                                    bindprofiles += "<div id=\"item\" style=\"float:left;width:170px;margin-top:6px\"   id=\"linkedin_" + item.ProfileId + "\"><div style=\"float:left\"<span class=\"img\">" +
                                              "<img width=\"48\" height=\"48\" src=\"" + profileimgurl + "\" alt=\"\"></img><i><img style=\"margin-left:-18px\" width=\"16\" height=\"16\" src=\"../Contents/img/link_icon.png\" alt=\"\"></img></i>" +
                                              "</span></div><div style=\"float:left\"><div style=\"font-size:small\">" + linkedaccount.LinkedinUserName + "</div></div>" +
                                               "<span onclick=\"RemoveInviteMemberProfileFromTeamMember('" + teamdata.Id + "','" + item.ProfileId + "','" + gpId + "','" + emailId + "','" + userId + "')\" style=\"margin-left:25px;font-size:small;cursor:pointer;position: absolute; margin-top: 28px;margin-left:10px\">x</span></div>";
                                }
                            }

                            else if (item.ProfileType == "instagram")
                            {
                                string profileimgurl = string.Empty;

                                InstagramAccount instaaccount = instagramrepo.getInstagramAccountDetailsById(item.ProfileId);
                                if (instaaccount != null)
                                {
                                    if (instaaccount.ProfileUrl == string.Empty)
                                    {
                                        profileimgurl = "../../Contents/img/blank_img.png";
                                    }
                                    else
                                    {
                                        profileimgurl = instaaccount.ProfileUrl;
                                    }

                                    bindprofiles += "<div id=\"item\" style=\"float:left;width:170px; margin-top:6px\"   id=\"instagram_" + item.ProfileId + "\"><div style=\"float:left\"<span class=\"img\">" +
                                             "<img width=\"48\" height=\"48\" src=\"" + profileimgurl + "\" alt=\"\"></img><i><img style=\"margin-left:-18px\" width=\"16\" height=\"16\" src=\"../Contents/img/instagram_24X24.png\" alt=\"\"></img></i>" +
                                             "</span></div><div style=\"float:left\"><div style=\"font-size:small\">" + instaaccount.InsUserName + "</div></div>" +
                                              "<span onclick=\"RemoveInviteMemberProfileFromTeamMember('" + teamdata.Id + "','" + item.ProfileId + "','" + gpId + "','" + emailId + "','" + userId + "')\" style=\"margin-left:25px;font-size:small;cursor:pointer;position: absolute; margin-top: 28px;margin-left:10px\">x</span></div>";
                                }
                            }



                            else if (item.ProfileType == "tumblr")
                            {
                                string profileimgurl = string.Empty;

                                TumblrAccount tumblraccount = tumblrrepo.getTumblrAccountDetailsById(item.ProfileId);
                                if (tumblraccount != null)
                                {
                                    if (tumblraccount.tblrProfilePicUrl == string.Empty)
                                    {
                                        profileimgurl = "../../Contents/img/blank_img.png";
                                    }
                                    else
                                    {
                                        profileimgurl = "http://api.tumblr.com/v2/blog/" + tumblraccount.tblrUserName + ".tumblr.com/avatar";
                                    }

                                    bindprofiles += "<div id=\"item\" style=\"float:left;width:170px; margin-top:6px\"   id=\"tumblr_" + item.ProfileId + "\"><div style=\"float:left\"<span class=\"img\">" +
                                             "<img width=\"48\" height=\"48\" src=\"" + profileimgurl + "\" alt=\"\"></img><i><img style=\"margin-left:-18px\" width=\"16\" height=\"16\" src=\"../Contents/img/tumblr.png\" alt=\"\"></img></i>" +
                                             "</span></div><div style=\"float:left\"><div style=\"font-size:small\">" +tumblraccount.tblrUserName + "</div></div>" +
                                              "<span onclick=\"RemoveInviteMemberProfileFromTeamMember('" + teamdata.Id + "','" + item.ProfileId + "','" + gpId + "','" + emailId + "','" + userId + "')\" style=\"margin-left:25px;font-size:small;cursor:pointer;position: absolute; margin-top: 28px;margin-left:10px\">x</span></div>";
                                }
                            }





                        }
                    }
                    catch (Exception ex)
                    {

                        Console.WriteLine(ex.StackTrace);
                    }

                    Response.Write(bindprofiles);

                }


                if (Request.QueryString["op"] == "RemoveInviteMemberProfileFromTeamMember")
                {
                    string profileId = Request.QueryString["ProfileId"];
                    Guid teamid = Guid.Parse(Request.QueryString["TeamId"]);
                    try
                    {
                        int deleteTeamMembeProfile = objTeamMemberProfileRepository.DeleteTeamMemberProfileByTeamIdProfileId(profileId,teamid);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }                               
                }

                if (Request.QueryString["op"] == "AddProfileInInviteTeamMember")
                {
                    try
                    {
                        string EmailId = string.Empty;
                        string Result = string.Empty;
                        TeamMemberProfile objteam = new TeamMemberProfile();
                        objteam.ProfileId = Request.QueryString["Profileid"];
                        objteam.ProfileType = Request.QueryString["Profiletype"];
                        string GrpId = Request.QueryString["Groupid"];
                        Guid grpid = Guid.Parse(GrpId);

                        TeamRepository objTeamrepo = new TeamRepository();
                        Team team = new Team();
                        Guid id = Guid.NewGuid();
                        objteam.Id = id;
                        string teamid = Request.QueryString["Teamid"];
                        objteam.TeamId = Guid.Parse(teamid);
                        objteam.StatusUpdateDate = DateTime.Now;
                        objteam.Status = 0;
                        team = objTeamrepo.getAllDetailsByTeamID(objteam.TeamId, grpid);
                        EmailId = team.EmailId;
                        try
                        {
                            if (!objTeamMemberProfileRepository.checkTeamMemberProfile(objteam.TeamId, objteam.ProfileId))
                            {
                                objTeamMemberProfileRepository.addNewTeamMember(objteam);
                                Result = "Success";
                            }
                            else
                            {
                                //ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('This Profile Already Added.');", true);
                                Result = "Fail";
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                        Response.Write(Result + "_" + EmailId);
                    }
                    catch (Exception ex)
                    {

                        Console.WriteLine(ex.StackTrace);
                    }                  
                }                    
            }
        }
コード例 #4
0
        //Getting AccessToken,FacebookMessages,FacebookFeeds and UserProfile for  Authenticated user.
        private void GetAccessToken()
        {
            string code = Request.QueryString["code"];
            User user = null;
            if (Session["login"] != null)
            {
                if (Session["login"].ToString() == "facebook")
                {
                    user = new User();

                    user.CreateDate = DateTime.Now;
                    user.ExpiryDate = DateTime.Now.AddMonths(1);
                    user.Id = Guid.NewGuid();
                    user.PaymentStatus = "unpaid";

                }

            }
            else
            {
                /*User class in SocioBoard.Domain to check authenticated user*/
                 user = (User)Session["LoggedUser"];

            }
                /*Replacing Code With AccessToken*/
                // Facebook.dll using for
                FacebookHelper fbhelper = new FacebookHelper();

            FacebookClient fb = new FacebookClient();
                string profileId = string.Empty;
                Dictionary<string, object> parameters = new Dictionary<string, object>();
                parameters.Add("client_id", ConfigurationManager.AppSettings["ClientId"]);
                parameters.Add("redirect_uri", ConfigurationManager.AppSettings["RedirectUrl"]);
                parameters.Add("client_secret", ConfigurationManager.AppSettings["ClientSecretKey"]);
                parameters.Add("code", code);

                JsonObject result = (JsonObject)fb.Get("/oauth/access_token", parameters);
                string accessToken = result["access_token"].ToString();
                fb.AccessToken = accessToken;

               dynamic profile = fb.Get("me");
            if (Session["login"] != null)
            {
                    if (Session["login"].ToString() == "facebook")
                    {
                        try
                        {
                            user.EmailId = profile["email"].ToString();
                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex.StackTrace);
                            Console.WriteLine(ex.StackTrace);
                        }
                        try
                        {

                            user.UserName = profile["name"].ToString();
                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex.StackTrace);
                            Console.WriteLine(ex.StackTrace);
                        }
                        try
                        {
                            user.ProfileUrl = "https://www.facebook.com/" + profile["id"] + "/picture?type=small";
                            profileId = profile["id"];
                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex.StackTrace);
                            Console.WriteLine(ex.StackTrace);
                        }
                        user.UserStatus = 1;

                        UserRepository userrepo = new UserRepository();

                        if (userrepo.IsUserExist(user.EmailId))
                        {
                            string emailid = user.EmailId;
                            user = null;

                            user = userrepo.getUserInfoByEmail(emailid);

                        }
                        else
                        {
                            UserRepository.Add(user);
                        }

                        Session["LoggedUser"] = user;
                    }

                }

                var feeds = fb.Get("/me/feed");

                var home = fb.Get("/me/home");
                var messages = fb.Get("/me/inbox");

                    long friendscount = 0;
                try
                {
                    fbhelper.getInboxMessages(messages, profile, user.Id);
                }
                catch (Exception ex)
                {
                    logger.Error(ex.StackTrace);
                    Console.WriteLine(ex.StackTrace);
                }

                try
                {
                    dynamic friedscount = fb.Get("fql", new { q = "SELECT friend_count FROM user WHERE uid=me()" });

                    foreach (var friend in friedscount.data)
                    {
                        friendscount = friend.friend_count;
                    }
                }
                catch (Exception ex)
                {
                    logger.Error(ex.StackTrace);
                    Console.WriteLine(ex.StackTrace);

                }

                try
                {

                    fbhelper.getFacebookUserProfile(profile, accessToken, friendscount, user.Id);

                }
                catch (Exception exx)
                {
                    logger.Error(exx.StackTrace);
                    Console.WriteLine(exx.StackTrace);

                }

                try
                {

                fbhelper.getFacebookUserFeeds(feeds, profile);

                }
                catch (Exception exxx)
                {
                    logger.Error(exxx.StackTrace);
                    Console.WriteLine(exxx.StackTrace);

                }

                try
                {

                            fbhelper.getFacebookUserHome(home, profile);

                }
                catch (Exception ex)
                {
                    logger.Error(ex.StackTrace);
                    Console.WriteLine(ex.StackTrace);

                }

                try
                {

                    var friendsgenderstats = fb.Get("me/friends?fields=gender");
                    fbhelper.getfbFriendsGenderStats(friendsgenderstats, profile, user.Id);

                }
                catch (Exception ex)
                {
                    logger.Error(ex.StackTrace);
                    Console.WriteLine(ex.StackTrace);
                }
                try
                {
                    FacebookInsightStatsHelper fbiHelper = new FacebookInsightStatsHelper();
                    fbiHelper.getPageImpresion(profile["id"], user.Id, 15);
                    fbiHelper.getFanPageLikesByGenderAge(profile["id"], user.Id, 15);
                    fbiHelper.getLocation(profile["id"], user.Id, 15);
                    //  fbiHelper.getFanPost("459630637383010", user.Id, 10);
                }
                catch (Exception ex)
                {
                    logger.Error(ex.StackTrace);
                }
        }
コード例 #5
0
        void ProcessRequest()
        { 
            SocioBoard.Domain.Team team = (SocioBoard.Domain.Team)Session["GroupName"];
            TeamMemberProfileRepository objTeamMemberProfileRepository = new TeamMemberProfileRepository();
            TwitterAccountRepository twtaccountrepo = new TwitterAccountRepository();
            FacebookAccountRepository facerepo = new FacebookAccountRepository();
            LinkedInAccountRepository linkrepo = new LinkedInAccountRepository();
            clsFeedsAndMessages clsfeedsandmess = new clsFeedsAndMessages();    

            try
            {
                User user = (User)Session["LoggedUser"];
                if (Request.QueryString["op"] != null)
                {
                    

                    //if (Request.QueryString["op"] == "bindMessages")
                    //{
                    //    DataSet ds = null;
                    //    //if (Session["MessageDataTable"] == null)
                    //    //{
                    //        clsFeedsAndMessages clsfeedsandmess = new clsFeedsAndMessages();
                    //        ds = clsfeedsandmess.bindMessagesIntoDataTable(team.Id);
                    //        FacebookFeedRepository fbFeedRepo = new FacebookFeedRepository();
                    //        Session["MessageDataTable"] = ds;
                    //    //}
                    //    //else
                    //    //{
                    //        ds = (DataSet)Session["MessageDataTable"];
                    //  //  }
                    //    string message = this.BindData(ds.Tables[0]);

                    //    if (string.IsNullOrEmpty(message))
                    //    {
                    //        message = "Sorry no data !";
                    //    }

                    //    Response.Write(message);

                    //}


                    string[] profid = null;


                    if (Request.QueryString["op"] == "bindMessages")
                    {
                        try
                        {
                            string message = string.Empty;


                            try
                            {
                                profid = Request.QueryString["profileid[]"].Split(',');
                                if (Request.QueryString["type"] != null)
                                {
                                    Session["countMesageDataTable_" + profid] = null;
                                }



                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex.StackTrace);
                            }

                            string facebook = string.Empty;

                            foreach (var item in profid)
                            {
                                if (string.IsNullOrEmpty(item))
                                {
                                    facebook = "emptyprofile";
                                }
                                else
                                {
                                    facebook = "profile";
                                }
                            }

                            if (facebook == "emptyprofile")
                            {
                                try
                                {
                                    DataSet ds = null;
                                    Session["countMesageDataTable_" + profid] = null;
                                    ds = clsfeedsandmess.bindMessagesIntoDataTable(team.Id);
                                    FacebookFeedRepository fbFeedRepo = new FacebookFeedRepository();
                                    Session["MessageDataTable"] = ds;

                                    ds = (DataSet)Session["MessageDataTable"];

                                    if (Session["countMessageDataTable"] == null)
                                    {
                                        Session["countMessageDataTable"] = 0;
                                    }
                                    int noOfDataToSkip = (int)Session["countMessageDataTable"];
                                    DataTable records = ds.Tables[0].Rows.Cast<System.Data.DataRow>().Skip(noOfDataToSkip).Take(noOfDataToSkip + 15).CopyToDataTable();
                                    Session["countMessageDataTable"] = noOfDataToSkip + 15;
                                    message = this.BindData(records);//this.BindData(ds.Tables[0]); 
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.StackTrace);
                                }
                            }

                            else
                            {
                                try
                                {
                                    DataSet ds = null;
                                    Session["countMessageDataTable"] = null;

                                    ds = clsfeedsandmess.bindFeedMessageIntoDataTable(profid);
                                    Session["MessageDataTable"] = ds;

                                    ds = (DataSet)Session["MessageDataTable"];



                                    if (Session["countMesageDataTable_" + profid] == null)
                                    {
                                        Session["countMesageDataTable_" + profid] = 0;
                                    }

                                    int noOfDataToSkip = (int)Session["countMesageDataTable_" + profid];

                                 
                                    DataTable records = ds.Tables[0].Rows.Cast<System.Data.DataRow>().Skip(noOfDataToSkip).Take(noOfDataToSkip + 15).CopyToDataTable();
                                    Session["countMesageDataTable_" + profid] = noOfDataToSkip + 15;
                                    message = this.BindData(records);

                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.StackTrace);
                                }
                            }

                            if (string.IsNullOrEmpty(message))
                            {
                               
                            }

                            Response.Write(message);

                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                    }




                    else if (Request.QueryString["op"] == "inbox_messages")
                    {
                        DataSet ds = null;
                        if (Session["InboxMessages"] == null)
                        {
                            clsFeedsAndMessages clsfeedsandmessages = new clsFeedsAndMessages();
                            ds = clsfeedsandmessages.bindSentMessagesToDataTable(user, "");
                            Session["InboxMessages"] = ds;
                        }
                        else
                        {
                            ds = (DataSet)Session["InboxMessages"];
                        }
                        string message = this.BindData(ds.Tables[0]);
                        Response.Write(message);

                    }
                
                    else if (Request.QueryString["op"] == "bindProfiles")
                    {

                        string profiles = string.Empty;
                        int i = 0;
                       // profiles += "<ul class=\"options_list\">";
                        profiles += "<ul >";
                        /*Binding facebook profiles in Accordian*/
                       
                        List<TeamMemberProfile> alstprofiles = objTeamMemberProfileRepository.getAllTeamMemberProfilesOfTeam(team.Id);
                        foreach (TeamMemberProfile item in alstprofiles)
                        {
                            if (item.ProfileType == "facebook")
                            {
                                
                                FacebookAccount alstfacebookprofiles = facerepo.getUserDetails(item.ProfileId);
                                try
                                {
                                   // profiles += "<ul><li><a id=\"checkimg_" + i + "\" href=\"#\" onclick=\"checkprofile('checkimg_" + i + "','" + alstfacebookprofiles.FbUserId + "','message','facebook');\"><img src=\"../Contents/img/admin/fbicon.png\"  width=\"15\" height=\"15\" alt=\"\" >" + alstfacebookprofiles.FbUserName + "</a></li>";

                                    profiles += "<li class=\"messagetype\"><a href=\"#\"><img src=\"../Contents/img/admin/fbicon.png\"  width=\"15\" height=\"15\" alt=\"\"/>" + alstfacebookprofiles.FbUserName + "</a>" +
                                             "<img onclick=\"chkProfilemessage(this.id);\" id=\"fb_" + alstfacebookprofiles.FbUserId + "\" src=\"../Contents/img/uncheck_click.png\" alt=\"\" /></li>";
                                    
                                    
                                    i++;
                                }
                                catch (Exception ex)
                                {
                                    logger.Error(ex.Message);
                                    Console.WriteLine(ex.Message);
                                }

                            }


                            else if (item.ProfileType == "twitter")
                            {
                               
                                TwitterAccount alsttwt = twtaccountrepo.getUserInformation(item.ProfileId);
                                try
                                {
                                    //profiles += "<ul><li><a href=\"#\" id=\"checkimg_" + i + "\" onclick=\"checkprofile('checkimg_" + i + "','" + alsttwt.TwitterUserId + "','message','twitter');\"><img src=\"../Contents/img/admin/twittericon.png\"  width=\"15\" height=\"15\" alt=\"\" >" + alsttwt.TwitterScreenName + "</a></li>";

                                    profiles += "<li class=\"messagetype\"><a href=\"#\"><img src=\"../Contents/img/admin/twittericon.png\"  width=\"15\" height=\"15\" alt=\"\"/>" + alsttwt.TwitterScreenName + "</a>" +
                                                "<img onclick=\"chkProfilemessage(this.id);\" id=\"twt_" + alsttwt.TwitterUserId + "\" src=\"../Contents/img/uncheck_click.png\" alt=\"\" /></li>";
                                    
                                    i++;
                                }
                                catch (Exception ex)
                                {
                                    logger.Error(ex.Message);
                                    Console.WriteLine(ex.Message);
                                }
                            }
                            else if (item.ProfileType == "google")
                            {
                                GooglePlusAccountRepository gpAccRepo = new GooglePlusAccountRepository();
                                GooglePlusAccount alstgp = gpAccRepo.getUserDetails(item.ProfileId);
                                try
                                {
                                    profiles += "<ul><li><a href=\"#\" id=\"checkimg_" + i + "\" onclick=\"checkprofile('checkimg_" + i + "','" + alstgp.GpUserId + "','message','googleplus');\"><img src=\"../Contents/img/google_plus.png\"  width=\"15\" height=\"15\" alt=\"\" >" + alstgp.GpUserName + "</a></li>";
                                    i++;
                                }
                                catch (Exception esx)
                                {
                                    logger.Error(esx.Message);
                                    Console.WriteLine(esx.Message);
                                }

                            }
                            
                        }
                                                                  
                        profiles += "</ul><input type=\"hidden\" id=\"profilecounter\" value=\"" + i + "\">";
                        Response.Write(profiles);
                    }


                    else if (Request.QueryString["op"] == "changeTaskStatus")
                    {
                        Guid taskid = Guid.Parse(Request.QueryString["taskid"]);
                        bool status = bool.Parse(Request.QueryString["status"]);

                        if (status == true)
                            status = false;
                        else
                            status = true;
                        TaskRepository objTaskRepo = new TaskRepository();
                        objTaskRepo.updateTaskStatus(taskid, user.Id, status);

                    }




                    else if (Request.QueryString["op"] == "savetask")
                    {
                        string descritption = Request.QueryString["description"];
                        //string time = Request.QueryString["now"];

                       Guid idtoassign = Guid.Empty;
                        try
                        {
                            if (Request.QueryString["memberid"] != string.Empty)
                            {
                               idtoassign = Guid.Parse(Request.QueryString["memberid"]);
                            }
                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex.Message);
                            // idtoassign = 0;
                        }
                        Tasks objTask = new Tasks();
                        TaskRepository objTaskRepo = new TaskRepository();
                        objTask.AssignDate = Request.QueryString["now"]; //DateTime.Now.ToString("yyyy-MM-dd H:mm:ss").ToString();
                        objTask.GroupId = team.GroupId;
                        objTask.AssignTaskTo = idtoassign;
                        objTask.TaskStatus = false;
                        objTask.TaskMessage = descritption;
                        objTask.UserId = user.Id;
                        Guid taskid = Guid.NewGuid();
                        objTask.Id = taskid;
                        objTaskRepo.addTask(objTask);

  
                        string comment = Request.QueryString["comment"];
                        if (!string.IsNullOrEmpty(comment))
                        {
                            string curdate = Request.QueryString["now"]; //DateTime.Now.ToString("yyyy-MM-dd H:mm:ss").ToString();
                            TaskComment objcmt = new TaskComment();
                            TaskCommentRepository objcmtRepo = new TaskCommentRepository();
                            objcmt.Comment = comment;
                            objcmt.CommentDate = DateTime.Now;
                            objcmt.EntryDate = DateTime.Now;
                            objcmt.Id = Guid.NewGuid();
                            objcmt.TaskId = objTask.Id;
                            objcmt.UserId = user.Id;
                            objcmtRepo.addTaskComment(objcmt);
                        }

                    }

                    else  if (Request.QueryString["op"] == "bindteam")
                    {
                        TeamRepository objTeam = new TeamRepository();
                        string message = string.Empty;
                        message += "<ul>";

                        //IEnumerable<dynamic> result = objTeam.getAllTeamsOfUser(user.Id,team.GroupId);
                        //IEnumerable<dynamic> result = objTeam.getAllTeamsOfUser(user.Id, team.GroupId);
                        BusinessSettingRepository objBsnsSettingRepo = new BusinessSettingRepository();
                        BusinessSetting objbsns = objBsnsSettingRepo.IsNotificationTaskEnable(team.GroupId);
                        if (objbsns.AssigningTasks == true || team.UserId == user.Id)
                        {
                            IEnumerable<dynamic> result = objTeam.getAllTeamsOfUser(user.Id, team.GroupId, user.EmailId);
                            foreach (Team item in result)
                            {
                                try
                                {
                                    //===========================new code added=========================

                                    UserRepository objUserRepository = new UserRepository();
                                    User objdetails = objUserRepository.getUserInfoByEmail(item.EmailId);
                                    if (objdetails != null)
                                    {
                                        message += "<li><a>";
                                        if (objdetails.ProfileUrl == null)
                                        {
                                            message += "<img src=\"../Contents/img/blank_img.png\" alt=\"\" />";
                                        }
                                        else
                                        {
                                            message += "<img src=\"" + objdetails.ProfileUrl + "\" alt=\"\" />";
                                        }


                                        message += "<span class=\"name\">" +
                                                                 objdetails.UserName +
                                                             "</span>" +
                                                          " <span>" +
                                                          "<input id=\"customerid_" + objdetails.Id + "\" type=\"radio\" name=\"team_members\" value=\"customerid_" + objdetails.Id + "\">" +
                                                          "</span>" +
                                                         "</a></li>";

                                        //message += "<li><a>";
                                    }
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine("Error : " + ex.StackTrace);
                                }
                            }

                            //  message += "<li><a>";
                            if (string.IsNullOrEmpty(user.ProfileUrl))
                            {
                                message += "<li><a>";

                                message += "<img src=\"../Contents/img/blank_img.png\" alt=\"\" />";
                            }
                            else
                            {
                                message += "<img src=\"" + user.ProfileUrl + "\" alt=\"\" />";
                            }

                            message += "<span class=\"name\">" +
                                     user.UserName +
                                  "</span>" +
                               " <span>" +
                               "<input id=\"customerid_" + user.Id + "\" type=\"radio\" name=\"team_members\" value=\"customerid_" + user.Id + "\">" +
                               "</span></a></li>";

                        }
                        else
                        {
                            message += "<li><a>";

                            if (string.IsNullOrEmpty(user.ProfileUrl))
                            {

                                message += "<img src=\"../Contents/img/blank_img.png\" alt=\"\" />";
                            }
                            else
                            {
                                message += "<img src=\"" + user.ProfileUrl + "\" alt=\"\" />";
                            }



                            message += "<span class=\"name\">" +
                                                user.UserName +
                                             "</span>" +
                                          " <span>" +
                                          "<input id=\"customerid_" + user.Id + "\" type=\"radio\" name=\"team_members\" value=\"customerid_" + user.Id + "\">" +
                                          "</span>" +
                                         "</a></li>";

                        }
                        message += "</ul>";
                        Response.Write(message);
                    }


                    else if (Request.QueryString["op"] == "sentmsg")
                    {

                       
                        ScheduledMessageRepository objScheduledMessageRepository = new ScheduledMessageRepository();
                    
                        string message = string.Empty;
                     //   message += "<ul  id=\"message-list\">";
                        try
                        {

                            List<TeamMemberProfile> alstprofiles = objTeamMemberProfileRepository.getAllTeamMemberProfilesOfTeam(team.Id);
                            foreach (TeamMemberProfile items in alstprofiles)
                            {
                                List<ScheduledMessage> result = objScheduledMessageRepository.getAllSentMessagesOfUser(items.ProfileId);
                                int sorteddatacount = 0;
                                if (result != null && result.Count > 0)
                                {
                                    foreach (ScheduledMessage item in result)
                                    {
                                        try
                                        {
                                            //message += "<ul  id=\"message-list\">";
                                            //message += "<li>";
                                            sorteddatacount++;
                                            if (item.ProfileType == "twitter")
                                            {
                                                message += "<ul  id=\"message-list\">";
                                                message += "<li>";


                                                TwitterAccountRepository objTwitterAccountRepository = new TwitterAccountRepository();
                                                TwitterAccount objTwitterAccount = objTwitterAccountRepository.getUserInformation(item.ProfileId);
                                                if (string.IsNullOrEmpty(item.PicUrl))
                                                {
                                                    message += "<div id=\"messagetaskable_" + sorteddatacount + "\" class=\"userpictiny\"><div style=\"width:60px;height:60px;float:left\"><img href=\"http://twitter.com/" + objTwitterAccount.TwitterScreenName + "\" target=\"_blank\" id=\"formprofileurl_" + sorteddatacount + "\" src=\"" + objTwitterAccount.ProfileImageUrl + "\" height=\"48\" width=\"48\" alt=\"\" title=\"\" />" +
                                                                 "<a href=\"http://twitter.com/" + objTwitterAccount.TwitterScreenName + "\" target=\"_blank\" class=\"userurlpic\" title=\"\"><img src=\"../Contents/img/twticon.png\" width=\"16\" height=\"16\" alt=\"\"></a></div>" +
                                                                 "</div><div id=\"messagedescription_" + sorteddatacount + "\" class=\"message-list-content\"><div  id=\"msgdescription_" + sorteddatacount + "\" style=\"width:500px;height:auto;float:left\"><p>" + item.ShareMessage + "</p>" +
                                                                     "<div class=\"message-list-info\"><span><a href=\"http://twitter.com/" + objTwitterAccount.TwitterScreenName + "\" target=\"_blank\" id=\"rowname_" + sorteddatacount + "\" >" + objTwitterAccount.TwitterScreenName + "</a> " + item.CreateTime + "</span>" +
                                                                     "<div class=\"scl\">" +
                                                        //"<a id=\"createtasktwt_" + sorteddatacount + "\" href=\"#\" onclick=\"createtask(this.id);\"><img title=\"Task\" src=\"../Contents/img/pin.png\" alt=\"\" width=\"14\" height=\"17\" border=\"none\"></a><a href=\"#\"><img title=\"Comment\" src=\"../Contents/img/admin/goto.png\" width=\"12\" height=\"12\" alt=\"\"/></a></div></div></div></div></li>";
                                                                      "</div></div></div></div></li>";
                                                }
                                                else if(!string.IsNullOrEmpty(item.PicUrl))
                                                {
                                                    string src = item.PicUrl;
                                                    message += "<div id=\"messagetaskable_" + sorteddatacount + "\" class=\"userpictiny\"><div style=\"width:60px;height:60px;float:left\"><img href=\"http://twitter.com/" + objTwitterAccount.TwitterScreenName + "\" target=\"_blank\" id=\"formprofileurl_" + sorteddatacount + "\" src=\"" + objTwitterAccount.ProfileImageUrl + "\" height=\"48\" width=\"48\" alt=\"\" title=\"\" />" +
                                                            "<a href=\"http://twitter.com/" + objTwitterAccount.TwitterScreenName + "\" target=\"_blank\" class=\"userurlpic\" title=\"\"><img src=\"../Contents/img/twticon.png\" width=\"16\" height=\"16\" alt=\"\"></a></div>" +
                                                            "</div><div id=\"messagedescription_" + sorteddatacount + "\" class=\"message-list-content\"><div  id=\"msgdescription_" + sorteddatacount + "\" style=\"width:500px;height:auto;float:left\"><p><img style=\"margin-right:10px;margin-top:10px\" width=\"80px;\" hight=\"80px;\" src=\"" + src + "\">" + item.ShareMessage + "</p>" +
                                                                "<div class=\"message-list-info\"><span><a href=\"http://twitter.com/" + objTwitterAccount.TwitterScreenName + "\" target=\"_blank\" id=\"rowname_" + sorteddatacount + "\" >" + objTwitterAccount.TwitterScreenName + "</a> " + item.CreateTime + "</span>" +
                                                                "<div class=\"scl\">" +
                                                     
                                                                 "</div></div></div></div></li>";
                                                }
                                               



                                                message += "</ul>";


                                            }
                                            else if (item.ProfileType == "facebook")
                                            {
                                                message += "<ul  id=\"message-list\">";
                                                message += "<li>";


                                                FacebookAccountRepository objFacebookAccountRepository = new FacebookAccountRepository();
                                                FacebookAccount objFacebookAccount = objFacebookAccountRepository.getFacebookAccountDetailsById(item.ProfileId);
                                                if (objFacebookAccount != null)
                                                {
                                                    if (string.IsNullOrEmpty(item.PicUrl))
                                                    {
                                                        message += "<div id=\"messagetaskable_" + sorteddatacount + "\" class=\"userpictiny\"><div style=\"width:60px;height:60px;float:left\"><img href=\"http://www.facebook.com/" + objFacebookAccount.FbUserId + "\" target=\"_blank\" id=\"formprofileurl_" + sorteddatacount + "\"  src=\"http://graph.facebook.com/" + objFacebookAccount.FbUserId + "/picture?type=small\" height=\"48\" width=\"48\" alt=\"\" title=\"\" />" +
                                                                    "<a href=\"http://www.facebook.com/" + objFacebookAccount.FbUserId + "\" target=\"_blank\" class=\"userurlpic\" title=\"\"><img src=\"../Contents/img/fb_icon.png\" width=\"16\" height=\"16\" alt=\"\"></a></div>" +
                                                                    "</div><div id=\"messagedescription_" + sorteddatacount + "\" class=\"message-list-content\"><div  id=\"msgdescription_" + sorteddatacount + "\" style=\"width:500px;height:auto;float:left\"><p>" + item.ShareMessage + "</p>" +
                                                                        "<div class=\"message-list-info\"><span><a href=\"http://www.facebook.com/" + objFacebookAccount.FbUserId + "\" target=\"_blank\" id=\"rowname_" + sorteddatacount + "\" >" + objFacebookAccount.FbUserName + "</a> " + item.CreateTime + "</span>" +
                                                                        "<div class=\"scl\">" +
                                                            //"<a id=\"createtasktwt_" + sorteddatacount + "\" href=\"#\" onclick=\"createtask(this.id);\"><img title=\"Task\" src=\"../Contents/img/pin.png\" alt=\"\" width=\"14\" height=\"17\" border=\"none\"></a><a href=\"#\"><img title=\"Comment\" src=\"../Contents/img/admin/goto.png\" width=\"12\" height=\"12\" alt=\"\"/></a></div></div></div></div></li>";
                                                                        "</div></div></div></div></li>";
                                                    }
                                                    else if (!string.IsNullOrEmpty(item.PicUrl))
                                                    {
                                                        string src = item.PicUrl;
                                                        message += "<div id=\"messagetaskable_" + sorteddatacount + "\" class=\"userpictiny\"><div style=\"width:60px;height:60px;float:left\"><img href=\"http://www.facebook.com/" + objFacebookAccount.FbUserId + "\" target=\"_blank\" id=\"formprofileurl_" + sorteddatacount + "\"  src=\"http://graph.facebook.com/" + objFacebookAccount.FbUserId + "/picture?type=small\" height=\"48\" width=\"48\" alt=\"\" title=\"\" />" +
                                                               "<a href=\"http://www.facebook.com/" + objFacebookAccount.FbUserId + "\" target=\"_blank\" class=\"userurlpic\" title=\"\"><img src=\"../Contents/img/fb_icon.png\" width=\"16\" height=\"16\" alt=\"\"></a></div>" +
                                                               "</div><div id=\"messagedescription_" + sorteddatacount + "\" class=\"message-list-content\"><div  id=\"msgdescription_" + sorteddatacount + "\" style=\"width:500px;height:auto;float:left\"><p><img style=\"margin-right:10px;margin-top:10px\" width=\"80px;\" hight=\"80px;\" src=\"" + src + "\">" + item.ShareMessage + "</p>" +
                                                                   "<div class=\"message-list-info\"><span><a href=\"http://www.facebook.com/" + objFacebookAccount.FbUserId + "\" target=\"_blank\" id=\"rowname_" + sorteddatacount + "\" >" + objFacebookAccount.FbUserName + "</a> " + item.CreateTime + "</span>" +
                                                                   "<div class=\"scl\">" +
                                                                   "</div></div></div></div></li>";
                                                    }

                                                    message += "</ul>";


                                                }

                                            }
                                            else if (item.ProfileType == "linkedin")
                                            {
                                                message += "<ul  id=\"message-list\">";
                                                message += "<li>";


                                                LinkedInAccountRepository objLinkedInAccountRepository = new LinkedInAccountRepository();
                                                LinkedInAccount objLinkedInAccount = objLinkedInAccountRepository.getLinkedinAccountDetailsById(item.ProfileId);
                                                if (objLinkedInAccount != null)
                                                {
                                                    if (string.IsNullOrEmpty(item.PicUrl))
                                                    {
                                                        message += "<div id=\"messagetaskable_" + sorteddatacount + "\" class=\"userpictiny\"><div style=\"width:60px;height:60px;float:left\"><img id=\"formprofileurl_" + sorteddatacount + "\"  src=\"" + objLinkedInAccount.ProfileImageUrl + "\" height=\"48\" width=\"48\" alt=\"\" title=\"\" />" +
                                                                    "<span class=\"userurlpic\" title=\"\"><img src=\"../Contents/img/link_icon.png\" width=\"16\" height=\"16\" alt=\"\" ></span></div>" +
                                                                    "</div><div id=\"messagedescription_" + sorteddatacount + "\" class=\"message-list-content\"><div  id=\"msgdescription_" + sorteddatacount + "\" style=\"width:500px;height:auto;float:left\"><p>" + item.ShareMessage + "</p>" +
                                                                        "<div class=\"message-list-info\"><span><a href=\"" + objLinkedInAccount.ProfileUrl + "\" target=\"_blank\" id=\"rowname_" + sorteddatacount + "\" >" + objLinkedInAccount.LinkedinUserName + "</a> " + item.CreateTime + "</span>" +
                                                                        "<div class=\"scl\">" +
                                                            //"<a id=\"createtasktwt_" + sorteddatacount + "\" href=\"#\" onclick=\"createtask(this.id);\"><img title=\"Task\" src=\"../Contents/img/pin.png\" alt=\"\" width=\"14\" height=\"17\" border=\"none\"></a><a href=\"#\"><img title=\"Comment\" src=\"../Contents/img/admin/goto.png\" width=\"12\" height=\"12\" alt=\"\"/></a></div></div></div></div></li>";
                                                                        "</div></div></div></div></li>";
                                                    }
                                                    else if (!string.IsNullOrEmpty(item.PicUrl))
                                                    {
                                                        string src = item.PicUrl;
                                                        message += "<div id=\"messagetaskable_" + sorteddatacount + "\" class=\"userpictiny\"><div style=\"width:60px;height:60px;float:left\"><img id=\"formprofileurl_" + sorteddatacount + "\"  src=\"" + objLinkedInAccount.ProfileImageUrl + "\" height=\"48\" width=\"48\" alt=\"\" title=\"\" />" +
                                                               "<span class=\"userurlpic\" title=\"\"><img src=\"../Contents/img/link_icon.png\" width=\"16\" height=\"16\" alt=\"\" ></span></div>" +
                                                               "</div><div id=\"messagedescription_" + sorteddatacount + "\" class=\"message-list-content\"><div  id=\"msgdescription_" + sorteddatacount + "\" style=\"width:500px;height:auto;float:left\"><p><img style=\"margin-right:10px;margin-top:10px\" width=\"80px;\" hight=\"80px;\" src=\"" + src + "\">" + item.ShareMessage + "</p>" +
                                                                   "<div class=\"message-list-info\"><span><a href=\"" + objLinkedInAccount.ProfileUrl + "\" target=\"_blank\" id=\"rowname_" + sorteddatacount + "\" >" + objLinkedInAccount.LinkedinUserName + "</a> " + item.CreateTime + "</span>" +
                                                                   "<div class=\"scl\">" +
                                                                   "</div></div></div></div></li>";
                                                    }
                                                    message += "</ul>";
                                                }

                                            }
                                        }
                                        catch (Exception ex)
                                        {
                                            Console.WriteLine("Error : " + ex.StackTrace);
                                        }
                                    }

                                   // message += "</ul>";
                                }
                                else
                                {
                                   // message = "Sorry no data !";
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Error : " + ex.StackTrace);
                        }
                       
                        Response.Write(message);
                    }
                    else if (Request.QueryString["op"] == "bindarchive")
                    {
                        ArchiveMessageRepository objArchiveRepo = new ArchiveMessageRepository();

                        string message = string.Empty;
                       

                        try
                        {
                            List<TeamMemberProfile> alstprofiles = objTeamMemberProfileRepository.getAllTeamMemberProfilesOfTeam(team.Id);
                            foreach (TeamMemberProfile items in alstprofiles)
                            {
                                List<ArchiveMessage> result = objArchiveRepo.getAllArchiveMessage(items.ProfileId);
                                int sorteddatacount = 0;
                                if (result != null && result.Count > 0)
                                {
                                    foreach (ArchiveMessage item in result)
                                    {
                                        try
                                        {
                                            message += "<ul  id=\"message-list\">";
                                            message += "<li>";
                                            sorteddatacount++;
                                            if (item.SocialGroup == "twitter")
                                            {
                                                message += "<div id=\"messagetaskable_" + sorteddatacount + "\" class=\"userpictiny\"><div style=\"width:60px;height:60px;float:left\"><img id=\"formprofileurl_" + sorteddatacount + "\" onclick=\"detailsdiscoverytwitter(" + item.ProfileId + ");\" src=\"" + item.ImgUrl + "\" height=\"48\" width=\"48\" alt=\"\" title=\"\" />" +
                                                             "<a href=\"#\" class=\"userurlpic\" title=\"\"><img src=\"../Contents/img/twticon.png\" width=\"16\" height=\"16\" alt=\"\" onclick=\"detailsdiscoverytwitter(\"item.ProfileId\");\"></a></div>" +
                                                             "</div><div id=\"messagedescription_" + sorteddatacount + "\" class=\"message-list-content\"><div  id=\"msgdescription_" + sorteddatacount + "\" style=\"width:500px;height:auto;float:left\"><p>" + item.Message + "</p>" +
                                                                 "<div class=\"message-list-info\"><span><a href=\"#\" id=\"rowname_" + sorteddatacount + "\" onclick=\"detailsdiscoverytwitter(" + item.ProfileId + ");\">" + item.UserName + "</a> " + item.CreatedDateTime + "</span>" +
                                                                 "<div class=\"scl\">" +
                                                    // "<a id=\"createtasktwt_" + sorteddatacount + "\" href=\"#\" onclick=\"createtask(this.id);\"><img title=\"Task\" src=\"../Contents/img/pin.png\" alt=\"\" width=\"14\" height=\"17\" border=\"none\"></a><a href=\"#\"><img title=\"Comment\" src=\"../Contents/img/admin/goto.png\" width=\"12\" height=\"12\" alt=\"\"/></a></div></div></div></div></li>";
                                                "<a><img onclick=replyfunction(" + sorteddatacount + ",'twitter','" + item.MessageId + "','" + item.ProfileId + "') title=\"Comment\" src=\"../Contents/img/admin/goto.png\" width=\"12\" height=\"12\" alt=\"\"/></a></div></div></div></div></li>";

                                            }
                                            else if (item.SocialGroup == "facebook")
                                            {
                                                message += "<div id=\"messagetaskable_" + sorteddatacount + "\" class=\"userpictiny\"><div style=\"width:60px;height:60px;float:left\"><img id=\"formprofileurl_" + sorteddatacount + "\" onclick=\"getFacebookProfiles(" + item.ProfileId + ");\" src=\"" + item.ImgUrl + "\" height=\"48\" width=\"48\" alt=\"\" title=\"\" />" +
                                                            "<a href=\"#\" class=\"userurlpic\" title=\"\"><img src=\"../Contents/img/fb_icon.png\" width=\"16\" height=\"16\" alt=\"\" onclick=\"getFacebookProfiles(\"item.ProfileId\");\"></a></div>" +
                                                            "</div><div id=\"messagedescription_" + sorteddatacount + "\" class=\"message-list-content\"><div  id=\"msgdescription_" + sorteddatacount + "\" style=\"width:500px;height:auto;float:left\"><p>" + item.Message + "</p>" +
                                                                "<div class=\"message-list-info\"><span><a href=\"#\" id=\"rowname_" + sorteddatacount + "\" onclick=\"getFacebookProfiles(" + item.ProfileId + ");\">" + item.UserName + "</a> " + item.CreatedDateTime + "</span>" +
                                                                "<div class=\"scl\">" +
                                                                "<a><img onclick=replyfunction(" + sorteddatacount + ",'facebook','" + item.MessageId + "','" + item.ProfileId + "') title=\"Comment\" src=\"../Contents/img/admin/goto.png\" width=\"12\" height=\"12\" alt=\"\"/></a></div></div></div></div></li>";
                                                //"<a id=\"createtasktwt_" + sorteddatacount + "\" href=\"#\" onclick=\"createtask(this.id);\"><img title=\"Task\" src=\"../Contents/img/pin.png\" alt=\"\" width=\"14\" height=\"17\" border=\"none\"></a><a href=\"#\"><img title=\"Comment\" src=\"../Contents/img/admin/goto.png\" width=\"12\" height=\"12\" alt=\"\"/></a></div></div></div></div></li>";


                                            }
                                            else if (item.SocialGroup == "googleplus")
                                            {
                                                message += "<div id=\"messagetaskable_" + sorteddatacount + "\" class=\"userpictiny\"><div style=\"width:60px;height:60px;float:left\"><img id=\"formprofileurl_" + sorteddatacount + "\" onclick=\"detailsprofile(this.alt);\" src=\"" + item.ImgUrl + "\" height=\"48\" width=\"48\" alt=\"\" title=\"\" />" +
                                                            "<a href=\"#\" class=\"userurlpic\" title=\"\"><img src=\"../Contents/img/google_plus.png\" width=\"16\" height=\"16\" alt=\"\" onclick=\"detailsprofile(this.alt);></a></div>" +
                                                            "</div><div id=\"messagedescription_" + sorteddatacount + "\" class=\"message-list-content\"><div  id=\"msgdescription_" + sorteddatacount + "\" style=\"width:500px;height:auto;float:left\"><p>" + item.Message + "</p>" +
                                                                "<div class=\"message-list-info\"><span><a href=\"#\" id=\"rowname_" + sorteddatacount + "\" onclick=\"detailsprofile(" + item.ProfileId + ");\">" + item.ProfileId + "</a> " + item.CreatedDateTime + "</span>" +
                                                                "<div class=\"scl\">" +
                                                                "<a href=\"#\"><img title=\"Comment\" src=\"../Contents/img/admin/goto.png\" width=\"12\" height=\"12\" alt=\"\"/></a></div></div></div></div></li>";
                                                //"<a id=\"createtasktwt_" + sorteddatacount + "\" href=\"#\" onclick=\"createtask(this.id);\"><img title=\"Task\" src=\"../Contents/img/pin.png\" alt=\"\" width=\"14\" height=\"17\" border=\"none\"></a></div></div></div></div></li>";


                                            }
                                            message += "</li>";
                                            message += "</ul>";
                                        }
                                        catch (Exception ex)
                                        {
                                            Console.WriteLine("Error : " + ex.StackTrace);
                                        }
                                    }

                                    //message += "</ul>";
                                }
                                else
                                {
                                  //  message = "Sorry no data !";
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Error : " + ex.StackTrace);
                        }
                        Response.Write(message);
                    }
                    else if (Request.QueryString["op"] == "savearchivemsg")
                    {
                        User use = (User)Session["LoggedUser"];
                        ArchiveMessage am = new ArchiveMessage();
                        ArchiveMessageRepository objArchiveRepo = new ArchiveMessageRepository();
                        am.UserId = user.Id;
                        am.ImgUrl = Request.QueryString["imgurl"];
                        //am.user_name = Request.QueryString["UserName"];
                        //am.msg = Request.QueryString["Msg"];
                        ////am.sociel_group = Request.QueryString["Network"];
                        //am.createdtime = Request.QueryString["CreatedTime"];

                        System.IO.StreamReader sr = new System.IO.StreamReader(Request.InputStream);
                        string line = "";
                        line = sr.ReadToEnd();
                        // JObject jo = JObject.Parse("[" + line + "]");
                        // am.UserName = Request.QueryString["UserName"];//Server.UrlDecode((string)jo["UserName"]);
                        //am.Message = Request.QueryString["Msg"];//Server.UrlDecode((string)jo["Msg"]);
                        JObject jo = JObject.Parse(line);
                        am.Message = Server.UrlDecode((string)jo["Msg"]);//Server.UrlDecode((string)jo["Msg"]);
                        am.SocialGroup = Request.QueryString["Network"];// Server.UrlDecode((string)jo["Network"]);
                        am.CreatedDateTime = Convert.ToDateTime(Request.QueryString["CreatedTime"]);
                        am.MessageId = Request.QueryString["MessageId"];
                        am.ProfileId = Request.QueryString["ProfileId"];
                        am.UserName = Request.QueryString["Username"];
                        am.UserId = use.Id;

                        // Server.UrlDecode((string)jo["CreatedTime"]);

                        if (am.UserName != string.Empty)
                        {
                            if (!objArchiveRepo.checkArchiveMessageExists(user.Id, am.MessageId))
                            {
                                objArchiveRepo.AddArchiveMessage(am);
                                Response.Write("Message Archive Successfully");
                            }
                            else
                            {
                                Response.Write("Message Already in Archive");
                            }
                        }
                    }
                    else if (Request.QueryString["op"] == "createfacebookcomments")
                    {
                        //FacebookAccountRepository facerepo = new FacebookAccountRepository();
                        string postid = Request.QueryString["replyid"];
                        string message = Request.QueryString["replytext"];
                        string userid = Request.QueryString["userid"];
                        FacebookAccount result = facerepo.getFacebookAccountDetailsById(userid, user.Id);

                        FacebookClient fc = new FacebookClient(result.AccessToken);
                        Dictionary<string, object> parameters = new Dictionary<string, object>();
                        parameters.Add("message", message);
                        JsonObject dyn = (JsonObject)fc.Post("/" + postid + "/comments", parameters);

                    }
                    else if (Request.QueryString["op"] == "getFacebookComments")
                    {
                       // FacebookAccountRepository facerepo = new FacebookAccountRepository();
                        string postid = Request.QueryString["postid"];
                        string userid = Request.QueryString["userid"];
                        FacebookAccount result = facerepo.getFacebookAccountDetailsById(userid, user.Id);

                        FacebookClient fc = new FacebookClient(result.AccessToken);
                        JsonObject dyn = (JsonObject)fc.Get("/" + postid + "/comments");
                        string mess = string.Empty;
                        dynamic jc = dyn["data"];
                        int iii = 0;
                        foreach (dynamic item in jc)
                        {
                            mess += "<div class=\"messages\"><section><aside><section class=\"js-avatar_tip\" data-sstip_class=\"twt_avatar_tip\">" +
                                    "<a class=\"avatar_link view_profile\">" +
                                    "<img width=\"54\" height=\"54\" border=\"0\" id=\"" + item["id"] + "\" class=\"avatar\" src=\"http://graph.facebook.com/" + item["from"]["id"] + "/picture?type=small\"><article class=\"message-type-icon\"></article>" +
                                     "</a></section><ul></ul></aside><article><div class=\"\"><a class=\"language\" href=\"\"></a></div>" +
                                     "<div class=\"message_actions\"><a class=\"gear_small\" href=\"#\"><span title=\"Options\" class=\"ficon\">?</span></a></div><div id=\"messagedescription_" + iii + "\" class=\"message-text font-14\">" + item["message"] + "</div><section class=\"bubble-meta\"><article class=\"threefourth text-overflow\"><section class=\"floatleft\"><a class=\"js-avatar_tip view_profile profile_link\" data-sstip_class=\"twt_avatar_tip\"><span id=\"rowname_" + iii + "\">" + item["from"]["name"] + "</span></a>&nbsp;<a data-msg-time=\"1363926699000\" class=\"time\" target=\"_blank\" title=\"View message on Twitter\">" + item["created_time"] + "</a><span class=\"location\">&nbsp;</span></section></article><ul class=\"message-buttons quarter clearfix\"></ul></section></article></section></div>";
                        }
                        Response.Write(mess);

                    }
                    else if (Request.QueryString["op"] == "twittercomments")
                    {

                        Tweet objTwitterMethod = new Tweet();
                        TwitterAccountRepository objTwtAccRepo = new TwitterAccountRepository();
                        try
                        {
                            string messid = Request.QueryString["messid"];
                            string replytext = Request.QueryString["replytext"];
                            string replyid = Request.QueryString["replyid"];
                            string userid = Request.QueryString["userid"];
                            string username = Request.QueryString["username"];
                            string rowid = Request.QueryString["rowid"];
                            TwitterAccount objTwtAcc = objTwtAccRepo.getUserInformation(user.Id, userid);

                            TwitterHelper twthelper = new TwitterHelper();

                            oAuthTwitter OAuthTwt = new oAuthTwitter();
                            OAuthTwt.AccessToken = objTwtAcc.OAuthToken;
                            OAuthTwt.AccessTokenSecret = objTwtAcc.OAuthSecret;
                            OAuthTwt.TwitterScreenName = objTwtAcc.TwitterScreenName;
                            twthelper.SetCofigDetailsForTwitter(OAuthTwt);
                            Tweet twt = new Tweet();
                            JArray post = twt.Post_Statuses_Update(OAuthTwt, replytext);
                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex.Message);
                        }
                    }
                    else if (Request.QueryString["op"] == "gpProfile")
                    {
                        GooglePlusAccountRepository objgpAccRepo = new GooglePlusAccountRepository();
                        GooglePlusAccount objGpAcc = objgpAccRepo.getGooglePlusAccountDetailsById(Request.QueryString["gpid"].ToString(), user.Id);
                        PeopleController obj = new PeopleController();
                        oAuthToken objgpToken = new oAuthToken();
                        JArray objProfile = null;
                        try
                        {
                            string strAccess = objgpToken.GetAccessToken(objGpAcc.RefreshToken);
                            if (!strAccess.StartsWith("["))
                                strAccess = "[" + strAccess + "]";
                            JArray objArray = JArray.Parse(strAccess);
                            foreach (var itemgp in objArray)
                            {
                                objGpAcc.AccessToken = itemgp["access_token"].ToString();
                            }
                            objProfile = obj.GetPeopleProfile(Request.QueryString["gpid"].ToString(), objGpAcc.AccessToken);
                        }
                        catch (Exception Err)
                        {
                            logger.Error(Err.Message);
                            Console.Write(Err.Message.ToString());
                        }
                        string jas = string.Empty;
                        foreach (var item in objProfile)
                        {
                            jas += "<div class=\"modal-small draggable\">";
                            jas += "<div class=\"modal-content\">";
                            jas += "<button type=\"button\" class=\"modal-btn button b-close\">";
                            jas += "<span class=\"icon close-medium\"><span class=\"visuallyhidden\">X</span></span></button>";
                            jas += "<div class=\"modal-header\"><h3 class=\"modal-title\">Profile summary</h3></div>";
                            jas += "<div class=\"modal-body profile-modal\">";
                            jas += "<div class=\"module profile-card component profile-header\">";
                            jas += "<div style=\"background-image: url('https://pbs.twimg.com/profile_banners/215936249/1371721359');\" class=\"profile-header-inner flex-module clearfix\">";
                            jas += "<div class=\"profile-header-inner-overlay\"></div>";
                            jas += "<a href=\"#\" class=\"profile-picture media-thumbnail js-nav\">";
                            string[] imgurl = item["image"]["url"].ToString().Split('?');
                            jas += "<img src=\"" + imgurl[0] + " alt=\"" + item["name"]["givenName"] + "\" class=\"avatar size73\"></a>";
                            jas += "<div class=\"profile-card-inner\">";
                            jas += "<h1 class=\"fullname editable-group\">";
                            jas += "<a class=\"js-nav\" href=\"#\">" + item["name"]["givenName"] + "</a>";
                            jas += "<a href=\"#\" class=\"verified-link js-tooltip\">";
                            jas += "<span class=\"icon verified verified-large-border\">";
                            jas += "<span class=\"visuallyhidden\"></span></span></a></h1>";
                            jas += "<h2 class=\"username\">";
                            jas += "<a class=\"pretty-link js-nav\" href=\"#\">";
                            jas += "<span class=\"screen-name\"><s></s>" + item["displayName"] + "</span></a></h2>";
                            jas += "<div class=\"bio-container editable-group\"><p class=\"bio profile-field\"></p></div>";
                            jas += "<p class=\"location-and-url\">";
                            jas += "<span class=\"location-container editable-group\">";
                            jas += "<span class=\"location profile-field\"></span></span>";
                            jas += "<span class=\"divider hidden\"></span> ";
                            jas += "<span class=\"url editable-group\">  ";
                            jas += "<span class=\"profile-field\">";
                            jas += "<a target=\"_blank\" rel=\"me nofollow\" href=\"" + item["url"] + "\" title=\"#\">" + item["url"] + " </a></span></span></p>";
                            jas += "<div style=\"cursor: pointer; width: 16px; height: 16px; display: inline-block;\">&nbsp;</div><p></p></div></div>";
                            jas += "<div class=\"clearfix\"><div class=\"default-footer\">";
                            jas += "<div class=\"btn-group\"><div class=\"follow_button\"></div></div></div></div>";
                            jas += "<div class=\"profile-social-proof\">";
                            jas += "<div class=\"follow-bar\"></div></div></div>";
                            jas += "<ol class=\"recent-tweets\"><li class=\"\"><div><i class=\"dogear\"></i></div></li></ol>";
                            jas += "<div class=\"go_to_profile\">";
                            jas += "<small><a class=\"view_profile\" target=\"_blank\" href=\"" + item["url"] + "\">Go to full profile →</a></small></div></div>";
                            jas += "<div class=\"loading\"><span class=\"spinner-bigger\"></span></div></div></div>";
                        }
                        Response.Write(jas);
                    }
                    //else if (Request.QueryString["op"] == "updatedstatus")
                    //{
                    //    try
                    //    {
                    //        TwitterMessageRepository twtmsgRepo = new TwitterMessageRepository();
                    //        int i = twtmsgRepo.updateMessageStatus(user.Id);
                    //        FacebookFeedRepository fbfeedRepo = new FacebookFeedRepository();
                    //        int j = fbfeedRepo.updateMessageStatus(user.Id);

                    //        if (i > 0 || j > 0)
                    //        {
                    //            Session["CountMessages"] = 0;
                    //            Session["MessageDataTable"] = null;


                    //            DataSet ds = null;
                    //            if (Session["MessageDataTable"] == null)
                    //            {
                    //                clsFeedsAndMessages clsfeedsandmess = new clsFeedsAndMessages();
                    //                ds = clsfeedsandmess.bindMessagesIntoDataTable(user);
                    //                FacebookFeedRepository fbFeedRepo = new FacebookFeedRepository();
                    //                Session["MessageDataTable"] = ds;
                    //            }
                    //            else
                    //            {
                    //                ds = (DataSet)Session["MessageDataTable"];
                    //            }
                    //        }


                    //    }
                    //    catch (Exception ex)
                    //    {
                    //        logger.Error(ex.Message);
                    //        Console.WriteLine(ex.Message);

                    //    }
                    //}

                    else if (Request.QueryString["op"] == "updatedstatus")
                    {
                        try
                        {
                            int i = 0;
                            int j=0;
                            List<TeamMemberProfile> alstprofiles = objTeamMemberProfileRepository.getAllTeamMemberProfilesOfTeam(team.Id);
                            foreach (TeamMemberProfile item in alstprofiles)
                            {
                                if (item.ProfileType == "twitter")
                                {
                                    TwitterMessageRepository twtmsgRepo = new TwitterMessageRepository();
                                     i = twtmsgRepo.updateMessageStatus(item.ProfileId);
                                }
                                else if (item.ProfileType == "facebook")
                                {
                                    FacebookFeedRepository fbfeedRepo = new FacebookFeedRepository();
                                     j = fbfeedRepo.updateMessageStatus(item.ProfileId);
 
                                }
                            }                         
                          

                            if (i > 0 || j > 0)
                            {
                                Session["CountMessages"] = 0;
                                Session["MessageDataTable"] = null;


                                DataSet ds = null;
                                if (Session["MessageDataTable"] == null)
                                {
                                    //clsFeedsAndMessages clsfeedsandmess = new clsFeedsAndMessages();
                                    ds = clsfeedsandmess.bindMessagesIntoDataTable(team.Id);
                                    FacebookFeedRepository fbFeedRepo = new FacebookFeedRepository();
                                    Session["MessageDataTable"] = ds;
                                }
                                else
                                {
                                    ds = (DataSet)Session["MessageDataTable"];
                                }
                            }


                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex.Message);
                            Console.WriteLine(ex.Message);

                        }
                    }



                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error : " + ex.StackTrace);
            }
        }
コード例 #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            oAuthToken objToken = new oAuthToken();
            GplusHelper objGpHelper = new GplusHelper();
            UserRepository objUserRepo = new UserRepository();
            PeopleController obj = new PeopleController();
            GooglePlusAccount objgpAcc = new GooglePlusAccount();
            User user = new User();
            try
            {
                string objRefresh = objToken.GetRefreshToken(Request.QueryString["code"]);
                if (!objRefresh.StartsWith("["))
                    objRefresh = "[" + objRefresh + "]";
                JArray objArray = JArray.Parse(objRefresh);
                if (Session["login"] != null)
                {
                    if (Session["login"].ToString() == "googleplus")
                    {
                        user = new User();
                        user.CreateDate = DateTime.Now;
                        user.ExpiryDate = DateTime.Now.AddMonths(1);
                        user.Id = Guid.NewGuid();
                        user.PaymentStatus = "unpaid";
                    }

                }
                else
                {
                    /*User class in SocioBoard.Domain to check authenticated user*/
                    user = (User)Session["LoggedUser"];
                }
                foreach (var item in objArray)
                {
                    try
                    {
                        JArray objEmail = objToken.GetUserInfo("me", item["access_token"].ToString());
                        JArray objProfile = obj.GetPeopleProfile("me", item["access_token"].ToString());
                        // user = (User)HttpContext.Current.Session["LoggedUser"];
                        foreach (var itemEmail in objEmail)
                        {
                            objgpAcc.EmailId = itemEmail["email"].ToString();

                        }
                        foreach (var itemProfile in objProfile)
                        {
                            objgpAcc.GpUserId = itemProfile["id"].ToString();
                            objgpAcc.AccessToken = item["access_token"].ToString();
                            objgpAcc.EntryDate = DateTime.Now;
                            objgpAcc.GpProfileImage = itemProfile["image"]["url"].ToString();
                            objgpAcc.GpUserName = itemProfile["displayName"].ToString();
                            objgpAcc.Id =Guid.NewGuid();
                            objgpAcc.IsActive = 1;
                            objgpAcc.RefreshToken = item["refresh_token"].ToString();
                            objgpAcc.UserId = user.Id;

                        }

                        if (Session["login"] != null)
                        {
                            if (string.IsNullOrEmpty(user.Password))
                            {
                                if (Session["login"].ToString() == "googleplus")
                                {
                                    if (objUserRepo.IsUserExist(user.EmailId))
                                    {
                                        // user = null;
                                        user = objUserRepo.getUserInfoByEmail(user.EmailId);
                                    }
                                    else
                                    {
                                        user.EmailId = objgpAcc.EmailId;
                                        user.UserName = objgpAcc.GpUserName;
                                        user.ProfileUrl = objgpAcc.GpProfileImage;
                                        UserRepository.Add(user);
                                    }
                                    Session["LoggedUser"] = user;
                                    objgpAcc.UserId = user.Id;
                                }
                            }
                        }
                        objGpHelper.GetUerProfile(objgpAcc, item["access_token"].ToString(), item["refresh_token"].ToString(), user.Id);

                        if (Session["login"] != null)
                        {
                            if (string.IsNullOrEmpty(user.Password))
                            {
                                if (Session["login"].ToString() == "googleplus")
                                {
                                    Response.Redirect("Plans.aspx");
                                }
                            }
                            else
                            {
                                Response.Redirect("Home.aspx");
                            }
                        }
                        else
                        {
                            Response.Redirect("Home.aspx");
                        }

                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.StackTrace);
                        Console.WriteLine(ex.StackTrace);
                        Response.Redirect("Home.aspx");
                    }
                }

            }
            catch (Exception Err)
            {
                Console.Write(Err.Message.ToString());
                logger.Error(Err.StackTrace);
                Response.Redirect("Home.aspx");
            }
        }
コード例 #7
0
        //Getting AccessToken,FacebookMessages,FacebookFeeds and UserProfile for  Authenticated user.

        private void GetAccessToken()
        {
            User user = new SocioBoard.Domain.User();
            string code = Request.QueryString["code"];
            if (code == null)
            {
                Response.Redirect("Home.aspx");
            }
            if (Session["login"]!= null)
            {
                if (Session["login"].ToString() == "googleplus")
                {
                    user = (User)Session["LoggedUser"];
                }
                else
                {
                    user = null;
                }
            }
            if (Session["login"] != null)
            {
                if (Session["login"].ToString() == "facebook" )
                {
                    user = new User();

                    user.CreateDate = DateTime.Now;
                    user.ExpiryDate = DateTime.Now.AddDays(30);
                    user.Id = Guid.NewGuid();
                    user.PaymentStatus = "unpaid";
                }
            }
            else
            {
                /*User class in SocioBoard.Domain to check authenticated user*/
                user = (User)Session["LoggedUser"];

            }
            /*Replacing Code With AccessToken*/
            // Facebook.dll using for 
            FacebookHelper fbhelper = new FacebookHelper();


            FacebookClient fb = new FacebookClient();
            string profileId = string.Empty;
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters.Add("client_id", ConfigurationManager.AppSettings["ClientId"]);
            parameters.Add("redirect_uri", ConfigurationManager.AppSettings["RedirectUrl"]);
            parameters.Add("client_secret", ConfigurationManager.AppSettings["ClientSecretKey"]);
            parameters.Add("code", code);

            JsonObject result = (JsonObject)fb.Get("/oauth/access_token", parameters);
            string accessToken = result["access_token"].ToString();
            fb.AccessToken = accessToken;

            // This code is used for posting Begin

            ManageReferrals(fb);

            // This code is used for posting End

            // For long Term Fb access_token

            // GET /oauth/access_token?  
            //grant_type=fb_exchange_token&           
            //client_id={app-id}&
            //client_secret={app-secret}&
            //fb_exchange_token={short-lived-token}


            parameters.Clear();

            parameters.Add("grant_type", "fb_exchange_token");
            parameters.Add("client_id", ConfigurationManager.AppSettings["ClientId"]);
            parameters.Add("client_secret", ConfigurationManager.AppSettings["ClientSecretKey"]);
            parameters.Add("fb_exchange_token", accessToken);

            result = (JsonObject)fb.Get("/oauth/access_token", parameters);
            accessToken = result["access_token"].ToString();
            fb.AccessToken = accessToken;

            dynamic profile = fb.Get("me");

            int res = UpdateFbToken(profile["id"], accessToken);
            bool isfbemailexist = false;
            if (Session["login"] != null)
            {
                if (Session["login"].ToString() == "facebook" )
                {
                    try
                    {
                        user.EmailId = profile["email"].ToString();
                    }
                    catch (Exception ex)
                    {
                        isfbemailexist = true;
                        logger.Error(ex.StackTrace);
                        Console.WriteLine(ex.StackTrace);
                    }
                    if (isfbemailexist)
                    {
                        Session["isemailexist"] = "emailnotexist";
                        Response.Redirect("Default.aspx");
                    }
                    try
                    {

                        user.UserName = profile["name"].ToString();
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.StackTrace);
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        user.ProfileUrl = "https://graph.facebook.com/" + profile["id"] + "/picture?type=small";
                        profileId = profile["id"];
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.StackTrace);
                        Console.WriteLine(ex.StackTrace);
                    }
                    user.UserStatus = 1;

                    UserRepository userrepo = new UserRepository();

                    if (userrepo.IsUserExist(user.EmailId))
                    {
                        string emailid = user.EmailId;
                        user = null;

                        user = userrepo.getUserInfoByEmail(emailid);

                    }
                    else
                    {
                        UserRepository.Add(user);
                    }

                    Session["LoggedUser"] = user;
                }

            }




            var feeds = fb.Get("/me/feed");

            var home = fb.Get("/me/home");
            var messages = fb.Get("/me/inbox");

            long friendscount = 0;
            try
            {
                fbhelper.getInboxMessages(messages, profile, user.Id);
            }
            catch (Exception ex)
            {
                logger.Error(ex.StackTrace);
                Console.WriteLine(ex.StackTrace);
            }

            try
            {
                dynamic friedscount = fb.Get("fql", new { q = "SELECT friend_count FROM user WHERE uid=me()" });

                foreach (var friend in friedscount.data)
                {
                    friendscount = friend.friend_count;
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.StackTrace);
                Console.WriteLine(ex.StackTrace);

            }


            try
            {

                fbhelper.getFacebookUserProfile(profile, accessToken, friendscount, user.Id);

            }
            catch (Exception exx)
            {
                logger.Error(exx.StackTrace);
                Console.WriteLine(exx.StackTrace);

            }

            try
            {

                fbhelper.getFacebookUserFeeds(feeds, profile);

            }
            catch (Exception exxx)
            {
                logger.Error(exxx.StackTrace);
                Console.WriteLine(exxx.StackTrace);

            }

            try
            {

                fbhelper.getFacebookUserHome(home, profile);

            }
            catch (Exception ex)
            {
                logger.Error(ex.StackTrace);
                Console.WriteLine(ex.StackTrace);

            }

            try
            {

                var friendsgenderstats = fb.Get("me/friends?fields=gender");
                fbhelper.getfbFriendsGenderStats(friendsgenderstats, profile, user.Id);

            }
            catch (Exception ex)
            {
                logger.Error(ex.StackTrace);
                Console.WriteLine(ex.StackTrace);
            }
            try
            {
                FacebookInsightStatsHelper fbiHelper = new FacebookInsightStatsHelper();
                fbiHelper.getPageImpresion(profile["id"], user.Id, 15);
                fbiHelper.getFanPageLikesByGenderAge(profile["id"], user.Id, 15);
                fbiHelper.getLocation(profile["id"], user.Id, 15);
                //  fbiHelper.getFanPost("459630637383010", user.Id, 10);
            }
            catch (Exception ex)
            {
                logger.Error(ex.StackTrace);
            }
        }