예제 #1
0
        public override void PostScheduleMessage(dynamic data)
        {
            try
            {
                LinkedInAccountRepository linkedinrepo = new LinkedInAccountRepository();

                LinkedInAccount linkedinaccount = linkedinrepo.getLinkedinAccountDetailsById(data.ProfileId);

                Console.WriteLine("=========================================================================");

             //   IEnumerable<LinkedInAccount> lstlinkedinaccount = linkedinrepo.getLinkedinAccountDetailsById(data.ProfileId);

               //foreach (LinkedInAccount item in lstlinkedinaccount)
               //{
               //    linkedinaccount = item;
               //    break;

               //}        

                oAuthLinkedIn Linkedin_oauth = new oAuthLinkedIn();
                Linkedin_oauth.ConsumerKey = System.Configuration.ConfigurationSettings.AppSettings["LiApiKey"].ToString();
                Linkedin_oauth.ConsumerSecret = System.Configuration.ConfigurationSettings.AppSettings["LiSecretKey"].ToString();
                Linkedin_oauth.FirstName = linkedinaccount.LinkedinUserName;
                Linkedin_oauth.Token = linkedinaccount.OAuthToken;
                Linkedin_oauth.TokenSecret = linkedinaccount.OAuthSecret;
                Linkedin_oauth.Verifier = linkedinaccount.OAuthVerifier;
                LinkedInUser linkeduser = new LinkedInUser();
                var response = linkeduser.SetStatusUpdate(Linkedin_oauth, data.ShareMessage);
                Console.WriteLine("Message post on linkedin for Id :" + linkedinaccount.LinkedinUserId + " and Message: " + data.ShareMessage);
                Console.WriteLine("=============================================================");
                ScheduledMessageRepository schrepo = new ScheduledMessageRepository();
                ScheduledMessage schmsg = new ScheduledMessage();
                schmsg.Id = data.Id;
                schmsg.ProfileId = data.ProfileId;
                schmsg.ProfileType = "linkedin";
                schmsg.Status = true;
                schmsg.UserId = data.UserId;
                schmsg.ShareMessage = data.ShareMessage;
                schmsg.ScheduleTime = data.ScheduleTime;
                schmsg.ClientTime = data.ClientTime;
                schmsg.CreateTime = data.CreateTime;
                schmsg.PicUrl = data.PicUrl;
                
                schrepo.updateMessage(data.Id);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }

        }
예제 #2
0
        protected void btnRegister_Click(object sender, ImageClickEventArgs e)
        {
            User user = new User();
            UserRepository userrepo = new UserRepository();
            UserActivation objUserActivation = new UserActivation();
            Coupon objCoupon = new Coupon();
            CouponRepository objCouponRepository = new CouponRepository();
            SocioBoard.Helper.SessionFactory.configfilepath = Server.MapPath("~/hibernate.cfg.xml");
            try
            {

                if (DropDownList1.SelectedValue == "Basic" || DropDownList1.SelectedValue == "Standard" || DropDownList1.SelectedValue == "Deluxe" || DropDownList1.SelectedValue == "Premium")
                {

                if (TextBox1.Text.Trim() != "")
                {
                    string resp = SBUtils.GetCouponStatus(TextBox1.Text).ToString();
                    if (resp != "valid")
                    {
                       // ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert(Not valid);", true);
                        ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('" + resp + "');", true);
                        return;
                    }
                }

                if (txtPassword.Text == txtConfirmPassword.Text)
                {
                    user.PaymentStatus = "unpaid";
                    //user.AccountType = Request.QueryString["type"];
                    user.AccountType = DropDownList1.SelectedValue.ToString();
                    if (string.IsNullOrEmpty(user.AccountType))
                    {
                        user.AccountType = AccountType.Free.ToString();
                    }
                    user.CreateDate = DateTime.Now;
                    user.ExpiryDate = DateTime.Now.AddMonths(1);
                    user.Id = Guid.NewGuid();
                    user.UserName = txtFirstName.Text + " " + txtLastName.Text;
                    user.Password = this.MD5Hash(txtPassword.Text);
                    user.EmailId = txtEmail.Text;
                    user.UserStatus = 1;
                    user.ActivationStatus = "0";
                    if (TextBox1.Text.Trim() != "")
                    {
                        user.CouponCode = TextBox1.Text.Trim().ToString();
                    }

                    if (!userrepo.IsUserExist(user.EmailId))
                    {
                        UserRepository.Add(user);

                        if (TextBox1.Text.Trim() != "")
                        {
                            objCoupon.CouponCode = TextBox1.Text.Trim();
                            List<Coupon> lstCoupon = objCouponRepository.GetCouponByCouponCode(objCoupon);
                            objCoupon.Id = lstCoupon[0].Id;
                            objCoupon.EntryCouponDate = lstCoupon[0].EntryCouponDate;
                            objCoupon.ExpCouponDate = lstCoupon[0].ExpCouponDate;
                            objCoupon.Status = "1";
                            objCouponRepository.SetCouponById(objCoupon);
                        }

                        Session["LoggedUser"] = user;
                        objUserActivation.Id = Guid.NewGuid();
                        objUserActivation.UserId = user.Id;
                        objUserActivation.ActivationStatus = "0";
                        UserActivationRepository.Add(objUserActivation);

                        //add package start

                        UserPackageRelation objUserPackageRelation = new UserPackageRelation();
                        UserPackageRelationRepository objUserPackageRelationRepository = new UserPackageRelationRepository();
                        PackageRepository objPackageRepository = new PackageRepository();

                        Package objPackage = objPackageRepository.getPackageDetails(user.AccountType);
                        objUserPackageRelation.Id = new Guid();
                        objUserPackageRelation.PackageId = objPackage.Id;
                        objUserPackageRelation.UserId = user.Id;
                        objUserPackageRelation.ModifiedDate = DateTime.Now;
                        objUserPackageRelation.PackageStatus = true;

                        objUserPackageRelationRepository.AddUserPackageRelation(objUserPackageRelation);

                        //end package

                        SocioBoard.Helper.MailSender.SendEMail(txtFirstName.Text, txtPassword.Text, txtEmail.Text, user.AccountType.ToString(),user.Id.ToString());
                        TeamRepository teamRepo = new TeamRepository();
                        Team team = teamRepo.getTeamByEmailId(txtEmail.Text);
                        if (team != null)
                        {
                            Guid teamid = Guid.Parse(Request.QueryString["tid"]);
                            teamRepo.updateTeamStatus(teamid);
                            TeamMemberProfileRepository teamMemRepo = new TeamMemberProfileRepository();
                            List<TeamMemberProfile> lstteammember = teamMemRepo.getAllTeamMemberProfilesOfTeam(team.Id);
                            foreach (TeamMemberProfile item in lstteammember)
                            {
                                try
                                {
                                    SocialProfilesRepository socialRepo = new SocialProfilesRepository();
                                    SocialProfile socioprofile = new SocialProfile();
                                    socioprofile.Id = Guid.NewGuid();
                                    socioprofile.ProfileDate = DateTime.Now;
                                    socioprofile.ProfileId = item.ProfileId;
                                    socioprofile.ProfileType = item.ProfileType;
                                    socioprofile.UserId = user.Id;
                                    socialRepo.addNewProfileForUser(socioprofile);

                                    if (item.ProfileType == "facebook")
                                    {
                                        try
                                        {
                                            FacebookAccount fbAccount = new FacebookAccount();
                                            FacebookAccountRepository fbAccountRepo = new FacebookAccountRepository();
                                            FacebookAccount userAccount = fbAccountRepo.getUserDetails(item.ProfileId);
                                            fbAccount.AccessToken = userAccount.AccessToken;
                                            fbAccount.EmailId = userAccount.EmailId;
                                            fbAccount.FbUserId = item.ProfileId;
                                            fbAccount.FbUserName = userAccount.FbUserName;
                                            fbAccount.Friends = userAccount.Friends;
                                            fbAccount.Id = Guid.NewGuid();
                                            fbAccount.IsActive = true;
                                            fbAccount.ProfileUrl = userAccount.ProfileUrl;
                                            fbAccount.Type = userAccount.Type;
                                            fbAccount.UserId = user.Id;
                                            fbAccountRepo.addFacebookUser(fbAccount);
                                        }
                                        catch (Exception ex)
                                        {
                                            Console.WriteLine(ex.Message);
                                            logger.Error(ex.Message);
                                        }
                                    }
                                    else if (item.ProfileType == "twitter")
                                    {
                                        try
                                        {
                                            TwitterAccount twtAccount = new TwitterAccount();
                                            TwitterAccountRepository twtAccRepo = new TwitterAccountRepository();
                                            TwitterAccount twtAcc = twtAccRepo.getUserInfo(item.ProfileId);
                                            twtAccount.FollowersCount = twtAcc.FollowersCount;
                                            twtAccount.FollowingCount = twtAcc.FollowingCount;
                                            twtAccount.Id = Guid.NewGuid();
                                            twtAccount.IsActive = true;
                                            twtAccount.OAuthSecret = twtAcc.OAuthSecret;
                                            twtAccount.OAuthToken = twtAcc.OAuthToken;
                                            twtAccount.ProfileImageUrl = twtAcc.ProfileImageUrl;
                                            twtAccount.ProfileUrl = twtAcc.ProfileUrl;
                                            twtAccount.TwitterName = twtAcc.TwitterName;
                                            twtAccount.TwitterScreenName = twtAcc.TwitterScreenName;
                                            twtAccount.TwitterUserId = twtAcc.TwitterUserId;
                                            twtAccount.UserId = user.Id;
                                            twtAccRepo.addTwitterkUser(twtAccount);
                                        }
                                        catch (Exception ex)
                                        {
                                            Console.WriteLine(ex.StackTrace);
                                            logger.Error(ex.Message);
                                        }
                                    }
                                    else if (item.ProfileType == "instagram")
                                    {
                                        try
                                        {

                                            InstagramAccount insAccount = new InstagramAccount();
                                            InstagramAccountRepository insAccRepo = new InstagramAccountRepository();
                                            InstagramAccount InsAcc = insAccRepo.getInstagramAccountById(item.ProfileId);
                                            insAccount.AccessToken = InsAcc.AccessToken;
                                            insAccount.FollowedBy = InsAcc.FollowedBy;
                                            insAccount.Followers = InsAcc.Followers;
                                            insAccount.Id = Guid.NewGuid();
                                            insAccount.InstagramId = item.ProfileId;
                                            insAccount.InsUserName = InsAcc.InsUserName;
                                            insAccount.IsActive = true;
                                            insAccount.ProfileUrl = InsAcc.ProfileUrl;
                                            insAccount.TotalImages = InsAcc.TotalImages;
                                            insAccount.UserId = user.Id;
                                            insAccRepo.addInstagramUser(insAccount);
                                        }
                                        catch (Exception ex)
                                        {
                                            Console.WriteLine(ex.StackTrace);
                                            logger.Error(ex.Message);
                                        }
                                    }
                                    else if (item.ProfileType == "linkedin")
                                    {
                                        try
                                        {
                                            LinkedInAccount linkAccount = new LinkedInAccount();
                                            LinkedInAccountRepository linkedAccountRepo = new LinkedInAccountRepository();
                                            LinkedInAccount linkAcc = linkedAccountRepo.getLinkedinAccountDetailsById(item.ProfileId);
                                            linkAccount.Id = Guid.NewGuid();
                                            linkAccount.IsActive = true;
                                            linkAccount.LinkedinUserId = item.ProfileId;
                                            linkAccount.LinkedinUserName = linkAcc.LinkedinUserName;
                                            linkAccount.OAuthSecret = linkAcc.OAuthSecret;
                                            linkAccount.OAuthToken = linkAcc.OAuthToken;
                                            linkAccount.OAuthVerifier = linkAcc.OAuthVerifier;
                                            linkAccount.ProfileImageUrl = linkAcc.ProfileImageUrl;
                                            linkAccount.ProfileUrl = linkAcc.ProfileUrl;
                                            linkAccount.UserId = user.Id;
                                            linkedAccountRepo.addLinkedinUser(linkAccount);
                                        }
                                        catch (Exception ex)
                                        {
                                            Console.WriteLine(ex.StackTrace);
                                            logger.Error(ex.Message);
                                        }
                                    }

                                }
                                catch (Exception ex)
                                {
                                    logger.Error(ex.Message);
                                }
                            }
                        }
                        lblerror.Text = "Registered Successfully !" + "<a href=\"Default.aspx\">Login</a>";
                        Response.Redirect("~/Home.aspx");
                    }
                    else
                    {
                        lblerror.Text = "Email Already Exists " + "<a href=\"Default.aspx\">login</a>";
                    }
                }
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Please select Account Type!');", true);
            }
            }

            catch (Exception ex)
            {
                logger.Error(ex.StackTrace);
                lblerror.Text = "Please Insert Correct Information";
                Console.WriteLine(ex.StackTrace);
                //Response.Redirect("Home.aspx");
            }
        }
        protected void btnRegister_Click(object sender, ImageClickEventArgs e)
        {
            User user = new User();
            UserRepository userrepo = new UserRepository();
            SocioBoard.Helper.SessionFactory.configfilepath = Server.MapPath("~/hibernate.cfg.xml");
            try
            {
                if (txtPassword.Text == txtConfirmPassword.Text)
                {

                    user.PaymentStatus = "unpaid";
                    user.AccountType = Request.QueryString["type"];
                    if (user.AccountType == string.Empty)
                    {
                        user.AccountType = AccountType.Deluxe.ToString();
                    }
                    user.CreateDate = DateTime.Now;
                    user.ExpiryDate = DateTime.Now.AddMonths(1);
                    user.Id = Guid.NewGuid();
                    user.UserName = txtFirstName.Text + " " + txtLastName.Text;
                    user.Password = this.MD5Hash(txtPassword.Text);
                    user.EmailId = txtEmail.Text;
                    user.UserStatus = 1;
                    if (!userrepo.IsUserExist(user.EmailId))
                    {
                        UserRepository.Add(user);
                        SocialSuitePro.Helper.MailSender.SendEMail(txtFirstName.Text + " " + txtLastName.Text, txtPassword.Text, txtEmail.Text);

                        TeamRepository teamRepo = new TeamRepository();
                        Team team = teamRepo.getTeamByEmailId(txtEmail.Text);
                        if (team != null)
                        {

                            Guid teamid = Guid.Parse(Request.QueryString["tid"]);
                            teamRepo.updateTeamStatus(teamid);

                            TeamMemberProfileRepository teamMemRepo = new TeamMemberProfileRepository();
                            List<TeamMemberProfile> lstteammember = teamMemRepo.getAllTeamMemberProfilesOfTeam(team.Id);
                            foreach (TeamMemberProfile item in lstteammember)
                            {
                                try
                                {
                                    SocialProfilesRepository socialRepo = new SocialProfilesRepository();
                                    SocialProfile socioprofile = new SocialProfile();
                                    socioprofile.Id = Guid.NewGuid();
                                    socioprofile.ProfileDate = DateTime.Now;
                                    socioprofile.ProfileId = item.ProfileId;
                                    socioprofile.ProfileType = item.ProfileType;
                                    socioprofile.UserId = user.Id;
                                    socialRepo.addNewProfileForUser(socioprofile);

                                    if (item.ProfileType == "facebook")
                                    {
                                        try
                                        {
                                            FacebookAccount fbAccount = new FacebookAccount();
                                            FacebookAccountRepository fbAccountRepo = new FacebookAccountRepository();
                                            FacebookAccount userAccount = fbAccountRepo.getUserDetails(item.ProfileId);
                                            fbAccount.AccessToken = userAccount.AccessToken;
                                            fbAccount.EmailId = userAccount.EmailId;
                                            fbAccount.FbUserId = item.ProfileId;
                                            fbAccount.FbUserName = userAccount.FbUserName;
                                            fbAccount.Friends = userAccount.Friends;
                                            fbAccount.Id = Guid.NewGuid();
                                            fbAccount.IsActive = true;
                                            fbAccount.ProfileUrl = userAccount.ProfileUrl;
                                            fbAccount.Type = userAccount.Type;
                                            fbAccount.UserId = user.Id;
                                            fbAccountRepo.addFacebookUser(fbAccount);
                                        }
                                        catch (Exception ex)
                                        {
                                            Console.WriteLine(ex.Message);
                                            logger.Error(ex.Message);
                                        }
                                    }
                                    else if (item.ProfileType == "twitter")
                                    {
                                        try
                                        {
                                            TwitterAccount twtAccount = new TwitterAccount();
                                            TwitterAccountRepository twtAccRepo = new TwitterAccountRepository();
                                            TwitterAccount twtAcc = twtAccRepo.getUserInfo(item.ProfileId);
                                            twtAccount.FollowersCount = twtAcc.FollowersCount;
                                            twtAccount.FollowingCount = twtAcc.FollowingCount;
                                            twtAccount.Id = Guid.NewGuid();
                                            twtAccount.IsActive = true;
                                            twtAccount.OAuthSecret = twtAcc.OAuthSecret;
                                            twtAccount.OAuthToken = twtAcc.OAuthToken;
                                            twtAccount.ProfileImageUrl = twtAcc.ProfileImageUrl;
                                            twtAccount.ProfileUrl = twtAcc.ProfileUrl;
                                            twtAccount.TwitterName = twtAcc.TwitterName;
                                            twtAccount.TwitterScreenName = twtAcc.TwitterScreenName;
                                            twtAccount.TwitterUserId = twtAcc.TwitterUserId;
                                            twtAccount.UserId = user.Id;
                                            twtAccRepo.addTwitterkUser(twtAccount);
                                        }
                                        catch (Exception ex)
                                        {
                                            Console.WriteLine(ex.StackTrace);
                                            logger.Error(ex.Message);
                                        }
                                    }
                                    else if (item.ProfileType == "instagram")
                                    {
                                        try
                                        {

                                            InstagramAccount insAccount = new InstagramAccount();
                                            InstagramAccountRepository insAccRepo = new InstagramAccountRepository();
                                            InstagramAccount InsAcc = insAccRepo.getInstagramAccountById(item.ProfileId);
                                            insAccount.AccessToken = InsAcc.AccessToken;
                                            insAccount.FollowedBy = InsAcc.FollowedBy;
                                            insAccount.Followers = InsAcc.Followers;
                                            insAccount.Id = Guid.NewGuid();
                                            insAccount.InstagramId = item.ProfileId;
                                            insAccount.InsUserName = InsAcc.InsUserName;
                                            insAccount.IsActive = true;
                                            insAccount.ProfileUrl = InsAcc.ProfileUrl;
                                            insAccount.TotalImages = InsAcc.TotalImages;
                                            insAccount.UserId = user.Id;
                                            insAccRepo.addInstagramUser(insAccount);
                                        }
                                        catch (Exception ex)
                                        {
                                            Console.WriteLine(ex.StackTrace);
                                            logger.Error(ex.Message);
                                        }
                                    }
                                    else if (item.ProfileType == "linkedin")
                                    {
                                        try
                                        {
                                            LinkedInAccount linkAccount = new LinkedInAccount();
                                            LinkedInAccountRepository linkedAccountRepo = new LinkedInAccountRepository();
                                            LinkedInAccount linkAcc = linkedAccountRepo.getLinkedinAccountDetailsById(item.ProfileId);
                                            linkAccount.Id = Guid.NewGuid();
                                            linkAccount.IsActive = true;
                                            linkAccount.LinkedinUserId = item.ProfileId;
                                            linkAccount.LinkedinUserName = linkAcc.LinkedinUserName;
                                            linkAccount.OAuthSecret = linkAcc.OAuthSecret;
                                            linkAccount.OAuthToken = linkAcc.OAuthToken;
                                            linkAccount.OAuthVerifier = linkAcc.OAuthVerifier;
                                            linkAccount.ProfileImageUrl = linkAcc.ProfileImageUrl;
                                            linkAccount.ProfileUrl = linkAcc.ProfileUrl;
                                            linkAccount.UserId = user.Id;
                                            linkedAccountRepo.addLinkedinUser(linkAccount);
                                        }
                                        catch (Exception ex)
                                        {
                                            Console.WriteLine(ex.StackTrace);
                                            logger.Error(ex.Message);
                                        }

                                    }

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

                            }
                        }

                        lblerror.Text = "Registered Successfully !" + "<a href=\"Default.aspx\">Login</a>";
                    }
                    else
                    {
                        lblerror.Text = "Email Already Exists " + "<a href=\"Default.aspx\">login</a>";
                    }
                }

            }
            catch (Exception ex)
            {
                logger.Error(ex.StackTrace);
                lblerror.Text = "Please Insert Correct Information";
                Console.WriteLine(ex.StackTrace);
            }
        }
예제 #4
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);
            }
        }
예제 #5
0
        public string ProfilesConnected(string UserId)
        {
            try
            {

                Guid userid = Guid.Parse(UserId);
                SocialProfilesRepository socialRepo = new SocialProfilesRepository();
                List<SocialProfile> lstsocioprofile = socialRepo.getAllSocialProfilesOfUser(userid);
                List<profileConnected> lstProfile = new List<profileConnected>();
                foreach (SocialProfile sp in lstsocioprofile)
                {
                    profileConnected pc = new profileConnected();
                    pc.Id = sp.Id;
                    pc.ProfileDate = sp.ProfileDate;
                    pc.ProfileId = sp.ProfileId;
                    pc.ProfileStatus = sp.ProfileStatus;
                    pc.ProfileType = sp.ProfileType;
                    pc.UserId = sp.UserId;
                    if (sp.ProfileType == "facebook")
                    {
                        try
                        {
                            FacebookAccountRepository objFbAccRepo = new FacebookAccountRepository();
                            FacebookAccount objFbAcc = objFbAccRepo.getUserDetails(sp.ProfileId);
                            pc.ProfileName = objFbAcc.FbUserName;
                            pc.ProfileImgUrl = "http://graph.facebook.com/" + sp.ProfileId + "/picture?type=small";
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                    }
                    else if (sp.ProfileType == "twitter")
                    {
                        try
                        {
                            TwitterAccountRepository objTwtAccRepo = new TwitterAccountRepository();
                            TwitterAccount objTwtAcc = objTwtAccRepo.getUserInfo(sp.ProfileId);
                            pc.ProfileName = objTwtAcc.TwitterScreenName;
                            pc.ProfileImgUrl = objTwtAcc.ProfileImageUrl;
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                    }
                    else if (sp.ProfileType == "instagram")
                    {
                        try
                        {
                            InstagramAccountRepository objInsAccRepo = new InstagramAccountRepository();
                            InstagramAccount objInsAcc = objInsAccRepo.getInstagramAccountById(sp.ProfileId);
                            pc.ProfileName = objInsAcc.InsUserName;
                            pc.ProfileImgUrl = objInsAcc.ProfileUrl;
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                    }
                    else if (sp.ProfileType == "linkedin")
                    {
                        try
                        {
                            LinkedInAccountRepository objLiAccRepo = new LinkedInAccountRepository();
                            LinkedInAccount objLiAcc = objLiAccRepo.getLinkedinAccountDetailsById(sp.ProfileId);
                            pc.ProfileName = objLiAcc.LinkedinUserName;
                            pc.ProfileImgUrl = objLiAcc.ProfileImageUrl;
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                    }
                    else if (sp.ProfileType == "googleplus")
                    {
                        try
                        {
                            GooglePlusAccountRepository objGpAccRepo = new GooglePlusAccountRepository();
                            GooglePlusAccount objGpAcc = objGpAccRepo.getUserDetails(sp.ProfileId);
                            pc.ProfileName = objGpAcc.GpUserName;
                            pc.ProfileImgUrl = objGpAcc.GpProfileImage;
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                    }
                    lstProfile.Add(pc);
                }
                return new JavaScriptSerializer().Serialize(lstProfile);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                return new JavaScriptSerializer().Serialize("Please Try Again");
            }
        }
예제 #6
0
        void ProcessRequest()
        {
            if (!string.IsNullOrEmpty(Request.QueryString["op"]))
            {
                if (Request.QueryString["op"] == "removedata")
                {

                    string network = Request.QueryString["network"];
                    string message = string.Empty;
                    var users = Request.QueryString["data[]"];
                    SocioBoard.Domain.Messages mstable = new SocioBoard.Domain.Messages();
                    DataSet ds = DataTableGenerator.CreateDataSetForTable(mstable);
                    DataTable dtt = ds.Tables[0];
                    string page = Request.QueryString["page"];
                    if (page == "feed")
                    {
                        AjaxFeeds ajxfed = new AjaxFeeds();
                        DataTable dt = null;
                        if (network == "facebook")
                        {
                            dt = (DataTable)Session["FacebookFeedDataTable"];
                        }
                        else if (network == "twitter")
                        {
                            dt = (DataTable)Session["TwitterFeedDataTable"];
                        }
                        else if (network == "linkedin")
                        {
                            dt = (DataTable)Session["LinkedInFeedDataTable"];
                        }

                        foreach (var parent in users)
                        {
                            DataView dv = new DataView(dtt);
                            DataRow[] foundRows = dt.Select("ProfileId = '" + parent + "'");
                            foreach (var child in foundRows)
                            {
                                dtt.ImportRow(child);
                            }
                        }
                        message = ajxfed.BindData(dtt);

                    }

                    else if (page == "message")
                    {
                        AjaxMessage ajxmes = new AjaxMessage();
                        DataSet dss = (DataSet)Session["MessageDataTable"];
                        //foreach (var parent in users)
                        //{
                        DataView dv = new DataView(dtt);
                        DataRow[] foundRows = dss.Tables[0].Select("ProfileId = '" + users + "'");
                        foreach (var child in foundRows)
                        {
                            dtt.ImportRow(child);
                        }

                        //}
                        message = ajxmes.BindData(dtt);
                    }
                    Response.Write(message);
                }
                else if (Request.QueryString["op"] == "saveRss")
                {
                    try
                    {
                        User user = (User)Session["LoggedUser"];
                        RssFeedsRepository objRssFeedRepo = new RssFeedsRepository();
                        RssFeeds objRssFeeds = new RssFeeds();
                        objRssFeeds.ProfileScreenName = Request.QueryString["user"];
                        objRssFeeds.FeedUrl = Request.QueryString["feedsurl"];
                        objRssFeeds.UserId = user.Id;
                        objRssFeeds.Status = false;
                        objRssFeeds.Message = Request.QueryString["message"];
                        objRssFeeds.Duration = Request.QueryString["duration"];
                        objRssFeeds.CreatedDate = DateTime.Now;
                        objRssFeedRepo.AddRssFeed(objRssFeeds);
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                        Console.WriteLine(ex.Message);
                    }
                }

                else if (Request.QueryString["op"] == "savedrafts")
                {
                    Guid Id = Guid.Parse(Request.QueryString["id"]);
                    string newstr = Request.QueryString["newstr"];
                    DraftsRepository draftsRepo = new DraftsRepository();
                    draftsRepo.UpdateDrafts(Id, newstr);

                }

                else if (Request.QueryString["op"] == "chkrssurl")
                {
                    try
                    {
                        string url = Request.QueryString["url"];
                        var facerequest = (HttpWebRequest)WebRequest.Create(url);
                        facerequest.Method = "GET";
                        string outputface = string.Empty;
                        using (var response = facerequest.GetResponse())
                        {
                            using (var stream = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding(1252)))
                            {
                                outputface = stream.ReadToEnd();
                                if (outputface.Contains("<rss version=\"2.0\""))
                                {
                                    Response.Write("true");
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                        Console.WriteLine(ex.Message);
                        Response.Write("Error");
                    }

                }

                else if (Request.QueryString["op"] == "detailsdiscoveryfacebook")
                {
                    User user = (User)Session["LoggedUser"];
                    string userid = Request.QueryString["profileid"];
                    FacebookAccountRepository fbRepo = new FacebookAccountRepository();
                    ArrayList alst = fbRepo.getAllFacebookAccountsOfUser(user.Id);
                    string accesstoken = string.Empty;

                    foreach (FacebookAccount childnoe in alst)
                    {
                        try
                        {

                            //accesstoken = childnoe.AccessToken;
                            if (CheckFacebookTokenByUserId(childnoe.AccessToken.ToString(), userid))
                            {
                                accesstoken = childnoe.AccessToken;
                                break;
                            }
                            //break;
                        }
                        catch (Exception ex)
                        {

                            Console.WriteLine(ex.Message);
                        }
                    }

                    FacebookClient fbclient = new FacebookClient(accesstoken);
                    string jstring = string.Empty;
                    dynamic item = fbclient.Get(userid);

                    jstring += "<div class=\"modal-small draggable\">";
                    jstring += "<div class=\"modal-content\">";
                    jstring += "<button class=\"modal-btn button b-close\" type=\"button\">";
                    jstring += "<span class=\"icon close-medium\"><span class=\"visuallyhidden\">X</span></span></button>";
                    jstring += "<div class=\"modal-header\"><h3 class=\"modal-title\">Profile summary</h3></div>";
                    jstring += "<div class=\"modal-body profile-modal\">";
                    jstring += "<div class=\"module profile-card component profile-header\">";

                    try
                    {
                        jstring += "<div class=\"profile-header-inner flex-module clearfix\" style=\"background-image: url('" + item["cover"]["source"] + "');\">";
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                        jstring += "<div class=\"profile-header-inner flex-module clearfix\" style=\"background-image: url('https://pbs.twimg.com/profile_banners/215936249/1371721359');\">";
                    }
                    jstring += "<div class=\"profile-header-inner-overlay\"></div>";
                    try
                    {
                        jstring += "<a class=\"profile-picture media-thumbnail js-nav\" href=\"#\"><img class=\"avatar size73\" alt=\"\" src=\"http://graph.facebook.com/" + item["id"] + "/picture?type=small\" /></a>";
                    }
                    catch (Exception)
                    {

                        jstring += "<a class=\"profile-picture media-thumbnail js-nav\" href=\"#\"><img class=\"avatar size73\" alt=\"\" src=\"http://graph.facebook.com/picture?type=small\" /></a>";
                    }
                    jstring += "<div class=\"profile-card-inner\">";
                    jstring += "<h1 class=\"fullname editable-group\">";
                    try
                    {
                        jstring += "<a href=\"#\" class=\"js-nav\">" + item["name"] + "</a>";
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    jstring += "<a class=\"verified-link js-tooltip\" href=\"#\"><span class=\"icon verified verified-large-border\"><span class=\"visuallyhidden\"></span> </span></a>";
                    jstring += "</h1>";
                    try
                    {
                        jstring += "<h2 class=\"username\"><a href=\"#\" class=\"pretty-link js-nav\"><span class=\"screen-name\"><s>@</s>" + item["username"] + "</span> </a></h2>";
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    jstring += "<div class=\"bio-container editable-group\"><p class=\"bio profile-field\">";
                    try
                    {
                        jstring += item["about"];
                    }
                    catch (Exception ex) { logger.Error(ex.Message); }

                    jstring += "</p></div>";
                    jstring += "<p class=\"location-and-url\">";
                    jstring += "<span class=\"location-container editable-group\"><span class=\"location profile-field\"></span></span>";
                    jstring += "<span class=\"divider hidden\"></span> ";
                    jstring += "<span class=\"url editable-group\">  <span class=\"profile-field\"><a title=\"#\" href=\"http://www.facebook.com/" + item["id"] + "\" rel=\"me nofollow\"  </a>";
                    jstring += "<div style=\"cursor: pointer; width: 16px; height: 16px; display: inline-block;\">&nbsp;</div>";
                    jstring += "</span></span></p></div></div>";
                    jstring += "<div class=\"clearfix\">";
                    jstring += "<div class=\"default-footer\">";

                    jstring += "<div class=\"btn-group\">" +
                                  "<div class=\"follow_button\">" +

                                      //"<span class=\"button-text following-text\">Following</span>" +
                        //"<span class=\"button-text unfollow-text\">Unfollow</span>" +
                                  "</div>" +
                               "</div>";
                    jstring += "</div></div>";
                    jstring += "<div class=\"profile-social-proof\"><div class=\"follow-bar\"></div></div></div>";
                    jstring += "<ol class=\"recent-tweets\">" +
                                  "<li class=\"\">" +
                                      "<div>" +
                                        "<i class=\"dogear\"></i>" +

                                      "</div>" +
                                  "</li>" +
                              "</ol>" +
                              "<div class=\"go_to_profile\">" +
                                  "<small><a href=\"http://www.facebook.com/" + item["id"] + "\" target=\"_blank\" class=\"view_profile\">Go to full profile →</a></small>" +
                              "</div>" +
                          "</div>" +
                          "<div class=\"loading\">" +
                              "<span class=\"spinner-bigger\"></span>" +
                          "</div>" +
                      "</div>";
                    jstring += "</div>";

                    Response.Write(jstring);

                }

                else if (Request.QueryString["op"] == "rssusers")
                {
                    try
                    {
                        User user = (User)Session["LoggedUser"];
                        TwitterAccountRepository twtAccRepo = new TwitterAccountRepository();
                        ArrayList alst = twtAccRepo.getAllTwitterAccountsOfUser(user.Id);
                        string message = string.Empty;
                        foreach (TwitterAccount item in alst)
                        {
                            message += "<option value=\"" + item.TwitterScreenName + "\">@" + item.TwitterScreenName + "</option>";
                        }
                        Response.Write(message);
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                        Console.WriteLine(ex.Message);
                    }

                }
                else if (Request.QueryString["op"] == "searchkeyword")
                {
                    User user = (User)Session["LoggedUser"];
                    DiscoverySearchRepository disrepo = new DiscoverySearchRepository();
                    List<string> alst = disrepo.getAllSearchKeywords(user.Id);
                    string message = string.Empty;

                    foreach (var item in alst)
                    {
                        message += "<li onclick=\"getSearchResults('" + item + "');\"><a href=\"#\"><i class=\"show icon-caret-right\" style=\"visibility:visible;margin-right:5px\"></i>" + item + "</a></li>";
                    }
                    Response.Write(message);

                }
                else if (Request.QueryString["op"] == "getResults")
                {
                    string type = Request.QueryString["type"];
                    string key = Request.QueryString["keyword"];
                    Discovery discoverypage = new Discovery();
                    string search = discoverypage.getlistresults(key);
                    string message = "<ul id=\"message-list\">" + search + "</ul>";
                    Response.Write(message);
                }
                else if (Request.QueryString["op"] == "getFollowers")
                {
                    User user = (User)Session["LoggedUser"];
                    Users twtUser = new Users();
                    oAuthTwitter oauth = new oAuthTwitter();
                    TwitterAccountRepository TwtAccRepo = new TwitterAccountRepository();
                    TwitterAccount TwtAccount = TwtAccRepo.getUserInformation(user.Id, Request.QueryString["id"]);
                    oauth.AccessToken = TwtAccount.OAuthToken;
                    oauth.AccessTokenSecret = TwtAccount.OAuthSecret;
                    oauth.ConsumerKey = ConfigurationManager.AppSettings["consumerKey"];
                    oauth.ConsumerKeySecret = ConfigurationManager.AppSettings["consumerSecret"];
                    oauth.TwitterScreenName = TwtAccount.TwitterScreenName;
                    oauth.TwitterUserId = TwtAccount.TwitterUserId;

                    JArray response = twtUser.Get_Followers_ById(oauth, Request.QueryString["id"]);

                    string jquery = string.Empty;

                    foreach (var item in response)
                    {
                        if (item["ids"] != null)
                        {
                            foreach (var child in item["ids"])
                            {
                                JArray userprofile = twtUser.Get_Users_LookUp(oauth, child.ToString());
                                foreach (var items in userprofile)
                                {

                                    try
                                    {

                                        jquery += "<li class=\"shadower\">" +
                                              "<div class=\"disco-feeds\">" +
                                                  "<div class=\"star-ribbon\"></div>" +
                                                  "<div class=\"disco-feeds-img\">" +
                                                      "<img alt=\"\" src=\"" + items["profile_image_url"] + "\" style=\"height: 100px; width: 100px;\" class=\"pull-left\">" +
                                                  "</div>" +
                                                  "<div class=\"disco-feeds-content\">" +
                                                      "<div class=\"disco-feeds-title\">" +
                                                          "<h3 class=\"no-margin\">" + items["name"] + "</h3>" +
                                                          "<span>@" + items["screen_name"] + "</span>" +
                                                      "</div>" +
                                                      "<p>";

                                        try
                                        {
                                            jquery += items["status"]["text"];
                                        }
                                        catch (Exception ex)
                                        {
                                            logger.Error(ex.Message);
                                        }

                                        lnk = "http://www.twitter.com/" + items["screen_name"].ToString();
                                        jquery += "</p>" +
                                            //"<a href=\"#\" class=\"btn\">Hide</a>" +
                                            //"<a href=\"#\" onclick=\"detailsprofile('" + items["id_str"] + "')\" class=\"btn\">Full Profile <i class=\"icon-caret-right\"></i> </a><div class=\"scl\">" +
                                           "<a href=" + lnk + "  class=\"btn\" target=\"_blank\" rel=\"me nofollow\">Full Profile <i class=\"icon-caret-right\"></i> </a><div class=\"scl\">" +
                                          "<a href=\"#\"><img alt=\"\" src=\"../Contents/img/admin/usergrey.png\"></a>" +
                                          "<a href=\"#\"><img alt=\"\" src=\"../Contents/img/admin/goto.png\"></a>" +
                                          "<a href=\"#\"><img alt=\"\" src=\"../Contents/img/admin/setting.png\"></a>" +
                                      "</div></div></div>" +
                                  "<div class=\"disco-feeds-info\">" +
                                      "<ul class=\"no-margin\">" +
                                          "<li><a href=\"#\"><img src=\"../Contents/img/admin/markerbtn2.png\" alt=\"\">";

                                        if (!string.IsNullOrEmpty(items["time_zone"].ToString()))
                                        {
                                            jquery += items["time_zone"];
                                        }
                                        else
                                        {
                                            jquery += "Not Specific";
                                        }
                                        jquery += "</a></li>";

                                        if (string.IsNullOrEmpty(items["url"].ToString()))
                                        {
                                            jquery += "<li><a href=\"#\"><img src=\"../Contents/img/admin/url.png\" alt=\"\">";
                                            jquery += "Not Specific";
                                        }
                                        else
                                        {
                                            jquery += "<li><a target=\"_blank\" href=\"" + items["url"] + "\"><img src=\"../Contents/img/admin/url.png\" alt=\"\">";
                                            jquery += items["url"];
                                        }
                                        jquery += "</a></li></ul>" +
                                        "<ul class=\"no-margin\" style=\"margin-top:20px\">" +
                                            "<li><a href=\"#\"><img src=\"../Contents/img/admin/twittericon-white.png\" alt=\"\">Followers <big><b>" + items["followers_count"] + "</b></big></a></li>" +
                                            "<li><a href=\"#\"><img src=\"../Contents/img/admin/twitter-white.png\" alt=\"\">Following <big><b>" + items["friends_count"] + "</b></big></a></li>" +
                                            "</ul>" +
                                    "</div>" +
                                "</li>";

                                        #region old
                                        //            jquery += "<div class=\"wentbg\">" +
                                        //                          "<div class=\"over\">" +
                                        //                            "<div class=\"topicon\">" +
                                        //                //"<a href=\"#\"><img border=\"none\" alt=\"\" src=\"../Contents/img/manplus.png\"></a>" +
                                        //                //"<a href=\"#\"><img border=\"none\" alt=\"\" src=\"../Contents/img/replay.png\"></a>" +
                                        //                //"<a href=\"#\"><img border=\"none\" alt=\"\" src=\"../Contents/img/setting.png\"></a>" +
                                        //                            "</div>" +
                                        //                                  "<div class=\"botombtn\">" +
                                        //                              "<div class=\"clickbtn\"><a href=\"#\"><img border=\"none\" alt=\"\" src=\"../Contents/img/full_profile.png\" onclick=\"detailsprofile('" + items["id_str"] + "')\"></a></div>" +
                                        //                            "</div>" +
                                        //                            "</div>" +
                                        //                                   "<div class=\"wentbgf\"><img alt=\"\" src=\"" + items["profile_image_url"] + "\"></div>" +

                                        //                                            "<div class=\"wentbgtext\">" +
                                        //"<span class=\"heading\">\"" + items["name"] + "\"</span> <span>@\"" + items["screen_name"] + "\"</span>" +
                                        //"<div class=\"viegil\">\"" + items["status"]["text"] + "\"</div>" +

                                        //            "<div class=\"avenue\">" +
                                        //             "<img alt=\"\" src=\"../Contents/img/avenue.png\">" +
                                        //             "<div class=\"avenuetext\">\"" + items["time_zone"] + "\"</div>" +
                                        //              "<img class=\"link\" alt=\"\" src=\"../Contents/img/url.png\">" +
                                        //             "<div class=\"nourl\">No URL</div>" +
                                        //         "</div>";

                                        //            jquery += "<div class=\"followerbg\">" +
                                        //                     "<div class=\"follower\">Followers <span>\"" + items["followers_count"] + "\"</span></div>" +
                                        //                     "<div class=\"following\">Friends <span>\"" + items["friends_count"] + "\"</span></div>" +
                                        //                  "</div>" +
                                        //              "</div>" +
                                        //          "</div>";
                                        #endregion
                                    }
                                    catch (Exception ex)
                                    {
                                        logger.Error(ex.Message);
                                        Console.WriteLine(ex.Message);
                                    }
                                }
                            }
                        }
                        else
                        {
                            jquery += "None of the User Is Following";
                        }

                    }

                    Response.Write(jquery);
                }
                else if (Request.QueryString["op"] == "deletedrafts")
                {
                    Guid id = Guid.Parse(Request.QueryString["id"]);
                    DraftsRepository draftsRepo = new DraftsRepository();
                    draftsRepo.DeleteDrafts(id);

                }
                else if (Request.QueryString["op"] == "usersearchresults")
                {
                    ArrayList alstallusers = null;
                    if (Session["AllUserList"] == null)
                    {
                        User user = (User)Session["LoggedUser"];
                        alstallusers = new ArrayList();

                        /*facebook*/
                        try
                        {
                            FacebookAccountRepository faceaccount = new FacebookAccountRepository();
                            ArrayList lstfacebookaccount = faceaccount.getAllFacebookAccountsOfUser(user.Id);
                            foreach (FacebookAccount item in lstfacebookaccount)
                            {
                                alstallusers.Add(item.FbUserName + "_fb_" + item.FbUserId);
                            }
                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex.Message);
                            Console.WriteLine(ex.Message);
                        }

                        /*twitter*/
                        try
                        {
                            TwitterAccountRepository twtAccountrepo = new TwitterAccountRepository();
                            ArrayList lsttwitteraccount = twtAccountrepo.getAllTwitterAccountsOfUser(user.Id);

                            foreach (TwitterAccount item in lsttwitteraccount)
                            {
                                alstallusers.Add(item.TwitterScreenName + "_twt_" + item.TwitterUserId);
                            }

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

                        /*linkedin*/
                        try
                        {
                            LinkedInAccountRepository linkedinaccountrepo = new LinkedInAccountRepository();
                            ArrayList lstaccount = linkedinaccountrepo.getAllLinkedinAccountsOfUser(user.Id);

                            foreach (LinkedInAccount item in lstaccount)
                            {
                                alstallusers.Add(item.LinkedinUserName + "_lin_" + item.LinkedinUserId);
                            }

                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex.Message);
                            Console.WriteLine(ex.Message);
                        }
                        /*instagram*/
                        try
                        {
                            InstagramAccountRepository instaaccrepo = new InstagramAccountRepository();
                            ArrayList lstinstagramaccount = instaaccrepo.getAllInstagramAccountsOfUser(user.Id);
                            foreach (InstagramAccount item in lstinstagramaccount)
                            {
                                alstallusers.Add(item.InsUserName + "_ins_" + item.InstagramId);
                            }
                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex.Message);
                            Console.WriteLine(ex.Message);
                        }

                        ///*googleplus*/
                        try
                        {
                            GooglePlusAccountRepository gpaccountrepo = new GooglePlusAccountRepository();
                            ArrayList lstgpaccount = gpaccountrepo.getAllGooglePlusAccountsOfUser(user.Id);
                            foreach (GooglePlusAccount item in lstgpaccount)
                            {
                                alstallusers.Add(item.GpUserName + "_gp_" + item.GpUserId);
                            }
                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex.Message);
                            Console.WriteLine(ex.Message);
                        }

                        Session["AllUserList"] = alstallusers;
                    }
                    else
                    {
                        alstallusers = (ArrayList)Session["AllUserList"];
                    }

                }
                else if (Request.QueryString["op"] == "searchingresults")
                {
                    string txtvalue = Request.QueryString["txtvalue"];
                    string message = string.Empty;
                    if (!string.IsNullOrEmpty(txtvalue))
                    {
                        ArrayList alstall = (ArrayList)Session["AllUserList"];

                        if (alstall.Count != 0)
                        {
                            foreach (string item in alstall)
                            {
                                if (item.ToLower().StartsWith(txtvalue))
                                {
                                    string[] nametype = item.Split('_');

                                    if (nametype[1] == "fb")
                                    {
                                        //message += "<div  class=\"btn srcbtn\">" +
                                        //                "<img width=\"15\" src=\"../Contents/img/facebook.png\" alt=\"\">" +
                                        //          "<span onclick=\"getFacebookProfiles('" + nametype[2] + "')\">" + nametype[0] + "</span>" +
                                        //           "<span data-dismiss=\"alert\" class=\"close pull-right\">×</span>" +
                                        //           "</div>";
                                        lnk = "https://www.facebook.com/" + nametype[2];
                                        message += "<div  class=\"btn srcbtn\">" +
                                                       "<img width=\"15\" src=\"../Contents/img/facebook.png\" alt=\"\">" +
                                                "<a target=\"_blank\" rel=\"me nofollow\" href=" + lnk + ">" + nametype[0] + "</a>" +
                                                  "<span data-dismiss=\"alert\" class=\"close pull-right\">×</span>" +
                                                  "</div>";
                                    }
                                    else if (nametype[1] == "twt" || item.Contains("_twt_"))
                                    {
                                        if (nametype.Count() < 4)
                                        {
                                            //message += "<div class=\"btn srcbtn\">" +
                                            //              "<img width=\"15\" src=\"../Contents/img/twticon.png\" alt=\"\">" +
                                            //                " <span onclick=\"detailsprofile('" + nametype[0] + "');\">" + nametype[0] + "</span>" +
                                            //         "<span data-dismiss=\"alert\" class=\"close pull-right\">×</span>" +
                                            //                 "</div>";
                                            lnk = "https://twitter.com/" + nametype[0];
                                            message += "<div class=\"btn srcbtn\">" +
                                                         "<img width=\"15\" src=\"../Contents/img/twticon.png\" alt=\"\">" +
                                                          "<a target=\"_blank\" rel=\"me nofollow\" href=" + lnk + ">" + nametype[0] + "</a>" +
                                                    "<span data-dismiss=\"alert\" class=\"close pull-right\">×</span>" +
                                                            "</div>";
                                        }
                                        else
                                        {
                                            string[] containstwitter = item.Split(new string[] { "_twt_" }, StringSplitOptions.None);

                                            //message += "<div  class=\"btn srcbtn\">" +
                                            //                 "<img width=\"15\" src=\"../Contents/img/twticon.png\" alt=\"\">" +
                                            //                    "<span onclick=\"detailsprofile('" + containstwitter[0] + "');\"> " + containstwitter[0] + "</span>" +
                                            //            "<span data-dismiss=\"alert\" class=\"close pull-right\">×</span>" +
                                            //                    "</div>";
                                            lnk = "https://twitter.com/" + containstwitter[0];
                                            message += "<div  class=\"btn srcbtn\">" +
                                                            "<img width=\"15\" src=\"../Contents/img/twticon.png\" alt=\"\">" +
                                                             "<a target=\"_blank\" rel=\"me nofollow\" href=" + lnk + ">" + containstwitter[0] + "</a>" +
                                                       "<span data-dismiss=\"alert\" class=\"close pull-right\">×</span>" +
                                                               "</div>";

                                        }
                                    }
                                    else if (nametype[1] == "ins")
                                    {

                                        message += "<div class=\"btn srcbtn\">" +
                                                   "<a target=\"_blank\" rel=\"" + nametype[0] + "\" href=\"http://instagram.com/" + nametype[0] + "\">" +
                                                   "<img width=\"15\" src=\"../Contents/img/instagram_24X24.png\" alt=\"\">" + nametype[0] +
                                                   "<span data-dismiss=\"alert\" class=\"close pull-right\">×</span>" +
                                                   "</a>" +
                                                "</div>";
                                        //message += "<div class=\"btn srcbtn\">" +
                                        //              "<img width=\"15\" src=\"../Contents/img/instagram_24X24.png\" alt=\"\">" +
                                        //         nametype[0] +
                                        //         "<span data-dismiss=\"alert\" class=\"close pull-right\">×</span>" +
                                        //         "</div>";
                                    }
                                    else if (nametype[1] == "lin")
                                    {
                                        LinkedInAccountRepository liRepo = new LinkedInAccountRepository();
                                        LinkedInAccount liaccount = liRepo.getLinkedinAccountDetailsById(nametype[2]);
                                        message += "<div class=\"btn srcbtn\">" +
                                                    "<a target=\"_blank\" rel=\"" + nametype[0] + "\" href=" + liaccount.ProfileUrl + ">" +
                                                    "<img width=\"15\" src=\"../Contents/img/link_icon.png\" alt=\"\">" + nametype[0] +
                                                    "<span data-dismiss=\"alert\" class=\"close pull-right\">×</span>" +
                                                    "</a>" +
                                                 "</div>";
                                        //message += "<div class=\"btn srcbtn\">" +
                                        //              "<img width=\"15\" src=\"../Contents/img/link_icon.png\" alt=\"\">" +
                                        //         nametype[0] +
                                        //         "<span data-dismiss=\"alert\" class=\"close pull-right\">×</span>" +
                                        //         "</div>";
                                    }
                                    else if (nametype[1] == "gp")
                                    {
                                        message += "<div class=\"btn srcbtn\">" +
                                                          "<img width=\"15\" src=\"../Contents/img/google_plus.png\" alt=\"\">" +
                                                     nametype[0] +
                                                     "<span data-dismiss=\"alert\" class=\"close pull-right\">×</span>" +
                                                     "</div>";

                                    }
                                }

                            }
                        }
                        else
                        {
                            message += "<div class=\"btn srcbtn\">" +
                                                  "<img width=\"15\" src=\"../Contents/img/norecord.png\" alt=\"\">" +
                                             "No Records Found" +
                                             "<span data-dismiss=\"alert\" class=\"close pull-right\">×</span>" +
                                             "</div>";

                        }

                        message += "<div class=\"socailtile\">Twitter</div>";

                        /*twitter contact search */

                        #region twitter contact search
                        try
                        {
                            User user = (User)Session["LoggedUser"];
                            Users twtUser = new Users();
                            oAuthTwitter oAuthTwt = new oAuthTwitter();
                            if (Session["oAuthUserSearch"] == null)
                            {
                                oAuthTwitter oauth = new oAuthTwitter();
                                oauth.ConsumerKey = ConfigurationManager.AppSettings["consumerKey"].ToString();
                                oauth.ConsumerKeySecret = ConfigurationManager.AppSettings["consumerSecret"].ToString();
                                oauth.CallBackUrl = ConfigurationManager.AppSettings["callbackurl"].ToString();
                                TwitterAccountRepository twtAccRepo = new TwitterAccountRepository();
                                ArrayList alst = twtAccRepo.getAllTwitterAccountsOfUser(user.Id);
                                foreach (TwitterAccount item in alst)
                                {
                                    oauth.AccessToken = item.OAuthToken;
                                    oauth.AccessTokenSecret = item.OAuthSecret;
                                    oauth.TwitterUserId = item.TwitterUserId;
                                    oauth.TwitterScreenName = item.TwitterScreenName;
                                    if (CheckTwitterToken(oauth, txtvalue))
                                    {
                                        break;
                                    }
                                }
                                Session["oAuthUserSearch"] = oauth;
                                oAuthTwt = oauth;
                            }
                            else
                            {
                                oAuthTwitter oauth = (oAuthTwitter)Session["oAuthUserSearch"];
                                oAuthTwt = oauth;
                            }

                            JArray twtuserjson = twtUser.Get_Users_Search(oAuthTwt, txtvalue, "5");

                            foreach (var item in twtuserjson)
                            {
                                //message += "<div class=\"btn srcbtn\">" +
                                //                         "<img width=\"15\" src=\"../Contents/img/twticon.png\" alt=\"\">" +
                                //                           " <span> " + item["screen_name"].ToString().TrimStart('"').TrimEnd('"') + "</span>" +
                                //                    "<span data-dismiss=\"alert\" class=\"close pull-right\">×</span>" +
                                //                            "</div>";

                                lnk = "https://twitter.com/" + item["screen_name"].ToString().TrimStart('"').TrimEnd('"');

                                message += "<div class=\"btn srcbtn\">" +
                                                        "<img width=\"15\" src=\"../Contents/img/twticon.png\" alt=\"\">" +
                                                          "<a target=\"_blank\" rel=\"me nofollow\" href=" + lnk + ">" + item["screen_name"].ToString().TrimStart('"').TrimEnd('"') + "</a>" +
                                                   "<span data-dismiss=\"alert\" class=\"close pull-right\">×</span>" +
                                                           "</div>";

                            }

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

                        #endregion

                        message += "<div class=\"socailtile\">Facebook</div>";

                        #region Facebook Contact search
                        try
                        {
                            string accesstoken = string.Empty;
                            FacebookAccountRepository facebookaccrepo = new FacebookAccountRepository();
                            ArrayList alstfacbookusers = facebookaccrepo.getAllFacebookAccounts();

                            foreach (FacebookAccount item in alstfacbookusers)
                            {
                                accesstoken = item.AccessToken;
                                if (CheckFacebookToken(accesstoken, txtvalue))
                                {
                                    break;
                                }
                            }

                            string facebookSearchUrl = "https://graph.facebook.com/search?q=" + txtvalue + " &limit=5&type=user&access_token=" + accesstoken;
                            var facerequest = (HttpWebRequest)WebRequest.Create(facebookSearchUrl);
                            facerequest.Method = "GET";
                            string outputface = string.Empty;
                            using (var response = facerequest.GetResponse())
                            {
                                using (var stream = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding(1252)))
                                {
                                    outputface = stream.ReadToEnd();
                                }
                            }
                            if (!outputface.StartsWith("["))
                                outputface = "[" + outputface + "]";

                            JArray facebookSearchResult = JArray.Parse(outputface);

                            foreach (var item in facebookSearchResult)
                            {
                                var data = item["data"];
                                foreach (var chlid in data)
                                {
                                    lnk = "https://www.facebook.com/" + chlid["id"];
                                    message += "<div  class=\"btn srcbtn\">" +
                                                        "<img width=\"15\" src=\"../Contents/img/facebook.png\" alt=\"\">" +
                                                 "<a target=\"_blank\" rel=\"me nofollow\" href=" + lnk + ">" + chlid["name"] + "</a>" +
                                                   "<span data-dismiss=\"alert\" class=\"close pull-right\">×</span>" +
                                                   "</div>";
                                }

                            }

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

                        Response.Write(message);
                    }
                }

                    //start descovery details

                    //start descovery details for twitter
                else if (Request.QueryString["op"] == "detailsdiscoverytwitter")
                {
                    User user = (User)Session["LoggedUser"];
                    string userid = Request.QueryString["profileid"];
                    TwitterAccountRepository twtAccountRepo = new TwitterAccountRepository();
                    ArrayList alst = twtAccountRepo.getAllTwitterAccountsOfUser(user.Id);
                    oAuthTwitter oauth = new oAuthTwitter();
                    foreach (TwitterAccount childnoe in alst)
                    {
                        oauth.AccessToken = childnoe.OAuthToken;
                        oauth.AccessTokenSecret = childnoe.OAuthSecret;
                        oauth.ConsumerKey = ConfigurationManager.AppSettings["consumerKey"];
                        oauth.ConsumerKeySecret = ConfigurationManager.AppSettings["consumerSecret"];
                        oauth.TwitterUserId = childnoe.TwitterUserId;
                        oauth.TwitterScreenName = childnoe.TwitterScreenName;
                        if (CheckTwitterTokenByUserId(oauth, userid))
                        {
                            break;
                        }
                    }

                    Users userinfo = new Users();
                    JArray userlookup = userinfo.Get_Users_LookUp(oauth, userid);
                    string jstring = string.Empty;

                    foreach (var item in userlookup)
                    {

                        jstring += "<div class=\"modal-small draggable\">";
                        jstring += "<div class=\"modal-content\">";
                        jstring += "<button class=\"modal-btn button b-close\" type=\"button\">";
                        jstring += "<span class=\"icon close-medium\"><span class=\"visuallyhidden\">X</span></span></button>";
                        jstring += "<div class=\"modal-header\"><h3 class=\"modal-title\">Profile summary</h3></div>";
                        jstring += "<div class=\"modal-body profile-modal\">";
                        jstring += "<div class=\"module profile-card component profile-header\">";
                        jstring += "<div class=\"profile-header-inner flex-module clearfix\" style=\"background-image: url('" + item["profile_banner_url"] + "');\">";
                        jstring += "<div class=\"profile-header-inner-overlay\"></div>";
                        jstring += "<a class=\"profile-picture media-thumbnail js-nav\" href=\"#\"><img class=\"avatar size73\" alt=\"" + item["name"] + "\" src=\"" + item["profile_image_url"] + "\" /></a>";
                        jstring += "<div class=\"profile-card-inner\">";
                        jstring += "<h1 class=\"fullname editable-group\">";
                        jstring += "<a href=\"www.twitter.com/" + item["name"] + "\" class=\"js-nav\">" + item["name"] + "</a>";
                        jstring += "<a class=\"verified-link js-tooltip\" href=\"#\"><span class=\"icon verified verified-large-border\"><span class=\"visuallyhidden\"></span> </span></a>";
                        jstring += "</h1>";
                        jstring += "<h2 class=\"username\"><a href=\"#\" class=\"pretty-link js-nav\"><span class=\"screen-name\"><s>@</s>" + item["screen_name"] + "</span> </a></h2>";
                        jstring += "<div class=\"bio-container editable-group\"><p class=\"bio profile-field\">";
                        try
                        {
                            jstring += item["status"]["text"];
                        }
                        catch (Exception ex) { logger.Error(ex.Message); }

                        jstring += "</p></div>";
                        jstring += "<p class=\"location-and-url\">";
                        jstring += "<span class=\"location-container editable-group\"><span class=\"location profile-field\"></span></span>";
                        jstring += "<span class=\"divider hidden\"></span> ";
                        jstring += "<span class=\"url editable-group\">  <span class=\"profile-field\"><a title=\"#\" href=\"" + item["url"] + "\" rel=\"me nofollow\" target=\"_blank\">" + item["url"] + " </a>";
                        jstring += "<div style=\"cursor: pointer; width: 16px; height: 16px; display: inline-block;\">&nbsp;</div>";
                        jstring += "</span></span></p></div></div>";
                        jstring += "<div class=\"clearfix\">";
                        jstring += "<div class=\"default-footer\">";
                        jstring += "<ul class=\"stats js-mini-profile-stats\">" +
                            //"<li><a href=\"#\" class=\"js-nav\"><strong> 6,274</strong> Tweets </a></li>" +
                                          "<li><a href=\"#\" class=\"js-nav\"><strong>" + item["friends_count"] + "</strong> Following </a></li>" +
                                          "<li><a href=\"#\" class=\"js-nav\"><strong>" + item["followers_count"] + "</strong> Followers </a></li>";
                        jstring += "</ul>";
                        jstring += "<div class=\"btn-group\">" +
                                      "<div class=\"follow_button\">" +
                            //"<span class=\"button-text follow-text\">Follow</span> " +
                                          "<span class=\"button-text following-text\">Following</span>" +
                                          "<span class=\"button-text unfollow-text\">Unfollow</span>" +
                                      "</div>" +
                                   "</div>";
                        jstring += "</div></div>";
                        jstring += "<div class=\"profile-social-proof\"><div class=\"follow-bar\"></div></div></div>";
                        jstring += "<ol class=\"recent-tweets\">" +
                                      "<li class=\"\">" +
                                          "<div>" +
                                            "<i class=\"dogear\"></i>" +

                                          "</div>" +
                                      "</li>" +
                                  "</ol>" +
                                  "<div class=\"go_to_profile\">" +
                                      "<small><a href=\"https://twitter.com/" + item["screen_name"] + "\" target=\"_blank\" class=\"view_profile\">Go to full profile →</a></small>" +
                                  "</div>" +
                              "</div>" +
                              "<div class=\"loading\">" +
                                  "<span class=\"spinner-bigger\"></span>" +
                              "</div>" +
                          "</div>";
                        jstring += "</div>";

                    }
                    Response.Write(jstring);
                }

                    //twitter Descovery End

                    //facebook start

                else if (Request.QueryString["op"] == "detailsdiscoveryfacebook")
                {
                    User user = (User)Session["LoggedUser"];
                    string userid = Request.QueryString["profileid"];
                    FacebookAccountRepository fbRepo = new FacebookAccountRepository();
                    ArrayList alst = fbRepo.getAllFacebookAccountsOfUser(user.Id);
                    string accesstoken = string.Empty;

                    foreach (FacebookAccount childnoe in alst)
                    {
                        accesstoken = childnoe.AccessToken;

                        break;
                    }

                    FacebookClient fbclient = new FacebookClient(accesstoken);
                    string jstring = string.Empty;
                    dynamic item = fbclient.Get(userid);

                    jstring += "<div class=\"modal-small draggable\">";
                    jstring += "<div class=\"modal-content\">";
                    jstring += "<button class=\"modal-btn button b-close\" type=\"button\">";
                    jstring += "<span class=\"icon close-medium\"><span class=\"visuallyhidden\">X</span></span></button>";
                    jstring += "<div class=\"modal-header\"><h3 class=\"modal-title\">Profile summary</h3></div>";
                    jstring += "<div class=\"modal-body profile-modal\">";
                    jstring += "<div class=\"module profile-card component profile-header\">";

                    try
                    {
                        jstring += "<div class=\"profile-header-inner flex-module clearfix\" style=\"background-image: url('" + item["cover"]["source"] + "');\">";
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                        jstring += "<div class=\"profile-header-inner flex-module clearfix\" style=\"background-image: url('https://pbs.twimg.com/profile_banners/215936249/1371721359');\">";
                    }
                    jstring += "<div class=\"profile-header-inner-overlay\"></div>";
                    try
                    {
                        jstring += "<a class=\"profile-picture media-thumbnail js-nav\" href=\"#\"><img class=\"avatar size73\" alt=\"\" src=\"http://graph.facebook.com/" + item["id"] + "/picture?type=small\" /></a>";
                    }
                    catch (Exception)
                    {

                        jstring += "<a class=\"profile-picture media-thumbnail js-nav\" href=\"#\"><img class=\"avatar size73\" alt=\"\" src=\"http://graph.facebook.com/picture?type=small\" /></a>";
                    }
                    jstring += "<div class=\"profile-card-inner\">";
                    jstring += "<h1 class=\"fullname editable-group\">";
                    try
                    {
                        jstring += "<a href=\"#\" class=\"js-nav\">" + item["name"] + "</a>";
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    jstring += "<a class=\"verified-link js-tooltip\" href=\"#\"><span class=\"icon verified verified-large-border\"><span class=\"visuallyhidden\"></span> </span></a>";
                    jstring += "</h1>";
                    try
                    {
                        jstring += "<h2 class=\"username\"><a href=\"#\" class=\"pretty-link js-nav\"><span class=\"screen-name\"><s>@</s>" + item["username"] + "</span> </a></h2>";
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    jstring += "<div class=\"bio-container editable-group\"><p class=\"bio profile-field\">";
                    try
                    {
                        jstring += item["about"];
                    }
                    catch (Exception ex) { logger.Error(ex.Message); }

                    jstring += "</p></div>";
                    jstring += "<p class=\"location-and-url\">";
                    jstring += "<span class=\"location-container editable-group\"><span class=\"location profile-field\"></span></span>";
                    jstring += "<span class=\"divider hidden\"></span> ";
                    jstring += "<span class=\"url editable-group\">  <span class=\"profile-field\"><a title=\"#\" href=\"http://www.facebook.com/" + item["id"] + "\" rel=\"me nofollow\"  </a>";
                    jstring += "<div style=\"cursor: pointer; width: 16px; height: 16px; display: inline-block;\">&nbsp;</div>";
                    jstring += "</span></span></p></div></div>";
                    jstring += "<div class=\"clearfix\">";
                    jstring += "<div class=\"default-footer\">";

                    jstring += "<div class=\"btn-group\">" +
                                  "<div class=\"follow_button\">" +

                                      //"<span class=\"button-text following-text\">Following</span>" +
                        //"<span class=\"button-text unfollow-text\">Unfollow</span>" +
                                  "</div>" +
                               "</div>";
                    jstring += "</div></div>";
                    jstring += "<div class=\"profile-social-proof\"><div class=\"follow-bar\"></div></div></div>";
                    jstring += "<ol class=\"recent-tweets\">" +
                                  "<li class=\"\">" +
                                      "<div>" +
                                        "<i class=\"dogear\"></i>" +

                                      "</div>" +
                                  "</li>" +
                              "</ol>" +
                              "<div class=\"go_to_profile\">" +
                                  "<small><a href=\"http://www.facebook.com/" + item["id"] + "\" target=\"_blank\" class=\"view_profile\">Go to full profile →</a></small>" +
                              "</div>" +
                          "</div>" +
                          "<div class=\"loading\">" +
                              "<span class=\"spinner-bigger\"></span>" +
                          "</div>" +
                      "</div>";
                    jstring += "</div>";

                    Response.Write(jstring);

                }

                    //facebook end

                    //End descovery details

                else if (Request.QueryString["op"] == "getTwitterUserDetails")
                {
                    User user = (User)Session["LoggedUser"];
                    string userid = Request.QueryString["profileid"];
                    TwitterAccountRepository twtAccountRepo = new TwitterAccountRepository();
                    ArrayList alst = twtAccountRepo.getAllTwitterAccountsOfUser(user.Id);
                    oAuthTwitter oauth = new oAuthTwitter();
                    foreach (TwitterAccount childnoe in alst)
                    {
                        oauth.AccessToken = childnoe.OAuthToken;
                        oauth.AccessTokenSecret = childnoe.OAuthSecret;
                        oauth.ConsumerKey = ConfigurationManager.AppSettings["consumerKey"];
                        oauth.ConsumerKeySecret = ConfigurationManager.AppSettings["consumerSecret"];
                        oauth.TwitterUserId = childnoe.TwitterUserId;
                        oauth.TwitterScreenName = childnoe.TwitterScreenName;
                        if (CheckTwitterTokenByUserId(oauth, userid))
                        {
                            break;
                        }
                    }

                    Users userinfo = new Users();
                    JArray userlookup = userinfo.Get_Users_LookUp(oauth, userid);
                    string jstring = string.Empty;

                    foreach (var item in userlookup)
                    {
                        //jstring = "<div class=\"big-puff\">";
                        //jstring += "<article><dl>";
                        //jstring += "<img src=\"" + item["profile_image_url"] + "\" alt=\"\" class=\"photo\">";
                        //jstring += "<div class=\"descrption\">";
                        //jstring += "<h3 title=\"Carlos Ullon\" class=\"fn\">" + item["name"] + "<span class=\"screenname prof_meta\">" + item["screen_name"];
                        //jstring += "<span class=\"ficon blue_bird_sm nickname\"></span></span>";
                        //jstring += "</h3><p class=\"note\"></p>";
                        //jstring += "<ul class=\"prof_meta\">";
                        //try
                        //{
                        //    jstring += "<li>" + item["status"]["text"] + "</li>";
                        //}
                        //catch { }
                        //jstring += "<li></li>";
                        //jstring += "</ul></div></dl><section class=\"profile_sub_wrap\"><a class=\"klout_link\" target=\"_blank\" href=\"http://www.klout.com/carlosullon\">";
                        //jstring += "<div class=\"klout_container\"><span class=\"score\"></span>";
                        //jstring += "<div class=\"icon klout_score\"></div>";
                        //jstring += "</div></a>";
                        //jstring += "<ul class=\"follow\">";
                        //jstring += "<li><span class=\"followers filter\"><span>Followers</span>";
                        //jstring += "<a data-msg_type=\"followers\" href=\"javascript:void(0)\">" + item["followers_count"] + "</a></span></li>";
                        //jstring += "<li><span class=\"friends filter\"><span>Following</span> <a data-msg_type=\"friends\" href=\"javascript:void(0)\">" + item["friends_count"] + "</a></span></li>";
                        //jstring += "</ul></section></article>";
                        //jstring += "<div class=\"usertweets\">";
                        //jstring += "<div class=\"tweetstitle\">User Tweets</div>";
                        //jstring += "<div id=\"offmessages\" class=\"usertweets_div\">";
                        //jstring += "</div>";
                        //jstring += "</div>";
                        //jstring += "</div></div>";

                        //============================

                        jstring += "<div class=\"modal-small draggable\">";
                        jstring += "<div class=\"modal-content\">";
                        jstring += "<button class=\"modal-btn button b-close\" type=\"button\">";
                        jstring += "<span class=\"icon close-medium\"><span class=\"visuallyhidden\">X</span></span></button>";
                        jstring += "<div class=\"modal-header\"><h3 class=\"modal-title\">Profile summary</h3></div>";
                        jstring += "<div class=\"modal-body profile-modal\">";
                        jstring += "<div class=\"module profile-card component profile-header\">";
                        jstring += "<div class=\"profile-header-inner flex-module clearfix\" style=\"background-image: url('" + item["profile_banner_url"] + "');\">";
                        jstring += "<div class=\"profile-header-inner-overlay\"></div>";
                        jstring += "<a class=\"profile-picture media-thumbnail js-nav\" href=\"#\"><img class=\"avatar size73\" alt=\"" + item["name"] + "\" src=\"" + item["profile_image_url"] + "\" /></a>";
                        jstring += "<div class=\"profile-card-inner\">";
                        jstring += "<h1 class=\"fullname editable-group\">";
                        jstring += "<a href=\"www.twitter.com/" + item["name"] + "\" class=\"js-nav\">" + item["name"] + "</a>";
                        jstring += "<a class=\"verified-link js-tooltip\" href=\"#\"><span class=\"icon verified verified-large-border\"><span class=\"visuallyhidden\"></span> </span></a>";
                        jstring += "</h1>";
                        jstring += "<h2 class=\"username\"><a href=\"#\" class=\"pretty-link js-nav\"><span class=\"screen-name\"><s>@</s>" + item["screen_name"] + "</span> </a></h2>";
                        jstring += "<div class=\"bio-container editable-group\"><p class=\"bio profile-field\">";
                        try
                        {
                            jstring += item["status"]["text"];
                        }
                        catch (Exception ex) { logger.Error(ex.Message); }

                        jstring += "</p></div>";
                        jstring += "<p class=\"location-and-url\">";
                        jstring += "<span class=\"location-container editable-group\"><span class=\"location profile-field\"></span></span>";
                        jstring += "<span class=\"divider hidden\"></span> ";
                        jstring += "<span class=\"url editable-group\">  <span class=\"profile-field\"><a title=\"#\" href=\"" + item["url"] + "\" rel=\"me nofollow\" target=\"_blank\">" + item["url"] + " </a>";
                        jstring += "<div style=\"cursor: pointer; width: 16px; height: 16px; display: inline-block;\">&nbsp;</div>";
                        jstring += "</span></span></p></div></div>";
                        jstring += "<div class=\"clearfix\">";
                        jstring += "<div class=\"default-footer\">";
                        jstring += "<ul class=\"stats js-mini-profile-stats\">" +
                            //"<li><a href=\"#\" class=\"js-nav\"><strong> 6,274</strong> Tweets </a></li>" +
                                          "<li><a href=\"#\" class=\"js-nav\"><strong>" + item["friends_count"] + "</strong> Following </a></li>" +
                                          "<li><a href=\"#\" class=\"js-nav\"><strong>" + item["followers_count"] + "</strong> Followers </a></li>";
                        jstring += "</ul>";
                        jstring += "<div class=\"btn-group\">" +
                                      "<div class=\"follow_button\">" +
                            //"<span class=\"button-text follow-text\">Follow</span> " +
                                          "<span class=\"button-text following-text\">Following</span>" +
                                          "<span class=\"button-text unfollow-text\">Unfollow</span>" +
                                      "</div>" +
                                   "</div>";
                        jstring += "</div></div>";
                        jstring += "<div class=\"profile-social-proof\"><div class=\"follow-bar\"></div></div></div>";
                        jstring += "<ol class=\"recent-tweets\">" +
                                      "<li class=\"\">" +
                                          "<div>" +
                                            "<i class=\"dogear\"></i>" +
                            //"<div class=\"content\">" +
                            //    "<div class=\"stream-item-header\">" +
                            //        "<a href=\"#\" class=\"account-group\"> " +
                            //            "<img alt=\"\" src=\""+item["profile_img_url"]+"\" class=\"avatar js-action-profile-avatar\" />" +
                            //        "</a>" +
                            //        "<div class=\"content_stream\">" +
                            //            "<div class=\"content_time\">" +
                            //                "<a>" +
                            //                    "<strong class=\"fullname\">"+item["name"]+"</strong>" +
                            //                    "<span>&rlm;</span> " +
                            //                    "<span class=\"username_action_name\"><s>@</s><b>"+item["screen_name"]+"</b></span>" +
                            //                "</a>" +
                            //                "<small class=\"time\">" +
                            //                    "<a title=\"11:42 AM - 10 Jul 13 (GMT+05:30)\" class=\"tweet-timestamp js-permalink js-nav\" href=\"#\">" +
                            //                       "<span class=\"_timestamp js-short-timestamp js-relative-timestamp\">33m</span>" +
                            //                    "</a>" +
                            //                "</small>" +
                            //            "</div>" +
                            //            "<p class=\"tweet_text\">" +
                            //               "RT If you watched Bhuvneshwar Kumar's amazing bowling performance in yesterday's" +
                            //               " match. <a dir=\"ltr\" class=\"twitter_hashtag\" href=\"#\"><s>#</s><b>IndvsSL</b></a>" +
                            //            "</p>" +
                            //            "<div class=\"stream_item_footer\">" +
                            //                "<a href=\"#\" class=\"details\">" +
                            //                    "<b><span class=\"simple-details-link\">Details</span> </b>" +
                            //                "</a>" +
                            //            "</div>" +
                            //        "</div>" +
                            //    "</div>" +
                            //"</div>" +
                                          "</div>" +
                                      "</li>" +
                                  "</ol>" +
                                  "<div class=\"go_to_profile\">" +
                                      "<small><a href=\"https://twitter.com/" + item["screen_name"] + "\" target=\"_blank\" class=\"view_profile\">Go to full profile →</a></small>" +
                                  "</div>" +
                              "</div>" +
                              "<div class=\"loading\">" +
                                  "<span class=\"spinner-bigger\"></span>" +
                              "</div>" +
                          "</div>";
                        jstring += "</div>";

                    }
                    Response.Write(jstring);
                }
                else if (Request.QueryString["op"] == "pauseRssMessage")
                {
                    Guid ID = Guid.Parse(Request.QueryString["id"]);
                    RssFeedsRepository rssRepo = new RssFeedsRepository();
                    rssRepo.updateFeedStatus("pause", ID);
                }
                else if (Request.QueryString["op"] == "deleteRssMessage")
                {
                    Guid ID = Guid.Parse(Request.QueryString["id"]);
                    RssFeedsRepository rssRepo = new RssFeedsRepository();
                    rssRepo.DeleteRssMessage(ID);
                }
                else if (Request.QueryString["op"] == "playRssMessage")
                {
                    Guid ID = Guid.Parse(Request.QueryString["id"]);
                    RssFeedsRepository rssRepo = new RssFeedsRepository();
                    rssRepo.updateFeedStatus("play", ID);
                }

                    //below  code is used for facebook

                else if (Request.QueryString["op"] == "facebookProfileDetails")
                {
                    User user = (User)Session["LoggedUser"];
                    string userid = Request.QueryString["profileid"];
                    FacebookAccountRepository fbRepo = new FacebookAccountRepository();
                    ArrayList alst = fbRepo.getAllFacebookAccountsOfUser(user.Id);
                    string accesstoken = string.Empty;

                    foreach (FacebookAccount childnoe in alst)
                    {
                        accesstoken = childnoe.AccessToken;
                        if (CheckFacebookTokenByUserId(accesstoken, userid))
                        {
                            break;
                        }
                    }

                    FacebookClient fbclient = new FacebookClient(accesstoken);
                    string jstring = string.Empty;
                    dynamic item = fbclient.Get(userid);

                    jstring += "<div class=\"modal-small draggable\">";
                    jstring += "<div class=\"modal-content\">";
                    jstring += "<button class=\"modal-btn button b-close\" type=\"button\">";
                    jstring += "<span class=\"icon close-medium\"><span class=\"visuallyhidden\">X</span></span></button>";
                    jstring += "<div class=\"modal-header\"><h3 class=\"modal-title\">Profile summary</h3></div>";
                    jstring += "<div class=\"modal-body profile-modal\">";
                    jstring += "<div class=\"module profile-card component profile-header\">";

                    try
                    {
                        jstring += "<div class=\"profile-header-inner flex-module clearfix\" style=\"background-image: url('" + item["cover"]["source"] + "');\">";
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                        jstring += "<div class=\"profile-header-inner flex-module clearfix\" style=\"background-image: url('https://pbs.twimg.com/profile_banners/215936249/1371721359');\">";
                    }
                    jstring += "<div class=\"profile-header-inner-overlay\"></div>";
                    jstring += "<a class=\"profile-picture media-thumbnail js-nav\" href=\"#\"><img class=\"avatar size73\" alt=\"" + item["name"] + "\" src=\"http://graph.facebook.com/" + item["id"] + "/picture?type=small\" /></a>";
                    jstring += "<div class=\"profile-card-inner\">";
                    jstring += "<h1 class=\"fullname editable-group\">";
                    try
                    {
                        jstring += "<a href=\"#\" class=\"js-nav\">" + item["name"] + "</a>";
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    jstring += "<a class=\"verified-link js-tooltip\" href=\"#\"><span class=\"icon verified verified-large-border\"><span class=\"visuallyhidden\"></span> </span></a>";
                    jstring += "</h1>";
                    try
                    {
                        jstring += "<h2 class=\"username\"><a href=\"#\" class=\"pretty-link js-nav\"><span class=\"screen-name\"><s>@</s>" + item["username"] + "</span> </a></h2>";
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    jstring += "<div class=\"bio-container editable-group\"><p class=\"bio profile-field\">";
                    try
                    {
                        jstring += item["about"];
                    }
                    catch (Exception ex) { logger.Error(ex.Message); }

                    jstring += "</p></div>";
                    jstring += "<p class=\"location-and-url\">";
                    jstring += "<span class=\"location-container editable-group\"><span class=\"location profile-field\"></span></span>";
                    jstring += "<span class=\"divider hidden\"></span> ";
                    jstring += "<span class=\"url editable-group\">  <span class=\"profile-field\"><a title=\"#\" href=\"http://www.facebook.com/" + item["id"] + "\" rel=\"me nofollow\" target=\"_blank\">" + item["link"] + " </a>";
                    jstring += "<div style=\"cursor: pointer; width: 16px; height: 16px; display: inline-block;\">&nbsp;</div>";
                    jstring += "</span></span></p></div></div>";
                    jstring += "<div class=\"clearfix\">";
                    jstring += "<div class=\"default-footer\">";

                    jstring += "<div class=\"btn-group\">" +
                                  "<div class=\"follow_button\">" +

                                      //"<span class=\"button-text following-text\">Following</span>" +
                        //"<span class=\"button-text unfollow-text\">Unfollow</span>" +
                                  "</div>" +
                               "</div>";
                    jstring += "</div></div>";
                    jstring += "<div class=\"profile-social-proof\"><div class=\"follow-bar\"></div></div></div>";
                    jstring += "<ol class=\"recent-tweets\">" +
                                  "<li class=\"\">" +
                                      "<div>" +
                                        "<i class=\"dogear\"></i>" +

                                      "</div>" +
                                  "</li>" +
                              "</ol>" +
                              "<div class=\"go_to_profile\">" +
                                  "<small><a href=\"http://www.facebook.com/" + item["id"] + "\" target=\"_blank\" class=\"view_profile\">Go to full profile →</a></small>" +
                              "</div>" +
                          "</div>" +
                          "<div class=\"loading\">" +
                              "<span class=\"spinner-bigger\"></span>" +
                          "</div>" +
                      "</div>";
                    jstring += "</div>";

                    Response.Write(jstring);

                }
            }
        }
예제 #7
0
        public void ProcessRequest()
        {
            SocioBoard.Domain.Team team = (SocioBoard.Domain.Team)Session["GroupName"];
            TeamMemberProfileRepository objTeamMemberProfileRepository = new TeamMemberProfileRepository();
            TwitterAccountRepository twtaccountrepo = new TwitterAccountRepository();
            FacebookAccountRepository facerepo = new FacebookAccountRepository();
            LinkedInAccountRepository linkaccrepo = new LinkedInAccountRepository();
            InstagramAccountRepository insaccrepo = new InstagramAccountRepository();
            TumblrAccountRepository tumblraccrepo = new TumblrAccountRepository();
            TumblrFeedRepository objTumblrFeedRepository = new TumblrFeedRepository();
            YoutubeAccountRepository ytaccrepo = new YoutubeAccountRepository();
            YoutubeChannelRepository ytrchannelrpo = new YoutubeChannelRepository();


            if (!string.IsNullOrEmpty(Request.QueryString["op"]))
            {
                SocioBoard.Domain.User user = (SocioBoard.Domain.User)Session["LoggedUser"];
                if (Request.QueryString["op"] == "networkprofiles")
                {
                    #region NetworkProfiles
                    string profiles = string.Empty;
                    List<TeamMemberProfile> allprofiles = objTeamMemberProfileRepository.getAllTeamMemberProfilesOfTeam(team.Id);

                    int facebookcount = 0;
                    int twittercount = 0;
                    int linkedincount = 0;
                    int instagramcount = 0;
                    int tumblrcount = 0;
                    int youtubecount = 0;
                    int totalcounts = 0;

                    foreach (TeamMemberProfile items in allprofiles)
                    {
                        totalcounts++;

                        if (Request.QueryString["network"] == "facebook")
                        {

                            if (items.ProfileType == "facebook")
                            {
                                facebookcount++;
                                FacebookAccount faceaccount = facerepo.getFacebookAccountDetailsById(items.ProfileId);
                                if (faceaccount.Type != "page")
                                {
                                    profiles += "<li><a id=\"lifb_" + faceaccount.FbUserId + "\" href=\"#\" onclick=\"facebookdetails('" + faceaccount.FbUserId + "');\" class=\"active\">" + faceaccount.FbUserName + "</a> </li>";
                                }
                            }
                            if (totalcounts == allprofiles.Count)
                            {
                                if (facebookcount == 0)
                                { profiles = "<li>No Records Found !</li>"; }

                            }

                        }

                        else if (Request.QueryString["network"] == "twitter")
                        {
                            if (items.ProfileType == "twitter")
                            {
                                twittercount++;
                                TwitterAccount twtaccount = twtaccountrepo.getUserInformation(items.ProfileId);

                                profiles += "<li><a id=\"litwt_" + twtaccount.TwitterUserId + "\" href=\"#\" onclick=\"twitterdetails('" + twtaccount.TwitterUserId + "');\" class=\"active\">" + twtaccount.TwitterScreenName + "</a> </li>";
                            }
                            if (totalcounts == allprofiles.Count)
                            {
                                if (twittercount == 0)
                                { profiles = "<li>No Records Found !</li>"; }

                            }

                        }

                        else if (Request.QueryString["network"] == "linkedin")
                        {
                            if (items.ProfileType == "linkedin")
                            {
                                linkedincount++;
                                LinkedInAccount linkedinaccount = linkaccrepo.getLinkedinAccountDetailsById(items.ProfileId);

                                profiles += "<li><a id=\"lilin_" + linkedinaccount.LinkedinUserId + "\" href=\"#\" onclick=\"linkedindetails('" + linkedinaccount.LinkedinUserId + "');\" class=\"active\">" + linkedinaccount.LinkedinUserName + "</a> </li>";
                            }
                            if (totalcounts == allprofiles.Count)
                            {
                                if (linkedincount == 0)
                                { profiles = "<li>No Records Found !</li>"; }

                            }


                        }

                        else if (Request.QueryString["network"] == "tumblr")
                        {
                            if (items.ProfileType == "tumblr")
                            {
                                tumblrcount++;
                                TumblrAccount tumblraccount = tumblraccrepo.getTumblrAccountDetailsById(items.ProfileId);

                                profiles += "<li><a id=\"lilin_" + tumblraccount.tblrUserName + "\" href=\"#\" onclick=\"tumblrdetails('" + tumblraccount.tblrUserName + "');\" class=\"active\">" + tumblraccount.tblrUserName + "</a> </li>";
                            }
                            if (totalcounts == allprofiles.Count)
                            {
                                if (tumblrcount == 0)
                                { profiles = "<li>No Records Found !</li>"; }

                            }
                        }


                        else if (Request.QueryString["network"] == "youtube")
                        {
                            if (items.ProfileType == "youtube")
                            {
                                youtubecount++;
                                YoutubeAccount youtubeaccount = ytaccrepo.getYoutubeAccountDetailsById(items.ProfileId);

                                profiles += "<li><a id=\"lilin_" + youtubeaccount.Ytusername + "\" href=\"#\" onclick=\"youtubedetails('" + youtubeaccount.Ytuserid + "','" + youtubeaccount.Refreshtoken + "');\" class=\"active\">" + youtubeaccount.Ytusername + "</a> </li>";
                            }
                            if (totalcounts == allprofiles.Count)
                            {
                                if (youtubecount == 0)
                                { profiles = "<li>No Records Found !</li>"; }

                            }
                        }





                        else if (Request.QueryString["network"] == "instagram")
                        {
                            if (items.ProfileType == "instagram")
                            {
                                instagramcount++;
                                InstagramAccount alstinstagram = insaccrepo.getInstagramAccountDetailsById(items.ProfileId);

                                profiles += "<li><a id=\"liins_" + alstinstagram.InstagramId + "\" href=\"#\" onclick=\"Instagramdetails('" + alstinstagram.InstagramId + "');\" class=\"active\">" + alstinstagram.InsUserName + "</a> </li>";
                            }
                            if (totalcounts == allprofiles.Count)
                            {
                                if (instagramcount == 0)
                                { profiles = "<li>No Records Found !</li>"; }
                            }
                        }

                    }

                    Response.Write(profiles);
                    #endregion
                }


                else if (Request.QueryString["op"] == "facebookwallposts")
                {
                    #region facebookwallposts
                    string messages = string.Empty;
                    string profileid = string.Empty;
                    string load = Request.QueryString["load"];
                    //Session[""] = profileid;
                    if (load == "first")
                    {
                        profileid = Request.QueryString["profileid"];
                        Session["FacebookProfileIdForFeeds"] = profileid;
                        facebookwallcount = 0;
                    }
                    else
                    {
                        profileid = (string)Session["FacebookProfileIdForFeeds"];
                        facebookwallcount = facebookwallcount + 10;
                    }


                    FacebookMessageRepository fbmsgrepo = new FacebookMessageRepository();
                    FacebookAccountRepository fbAccRepo = new FacebookAccountRepository();

                    List<FacebookMessage> lsgfbmsgs = fbmsgrepo.getAllWallpostsOfProfile(profileid, facebookwallcount);

                    UrlExtractor urlext = new UrlExtractor();
                    foreach (FacebookMessage item in lsgfbmsgs)
                    {
                        try
                        {

                            string[] str = urlext.splitUrlFromString(item.Message);
                            messages += "<li><div class=\"feedim pull-left\"><img alt=\"\" width=\"31\" height=\"31\" src=\"" + item.FromProfileUrl + "\" onclick=\"getFacebookProfiles('" + item.FromId + "');\">" +
                                                         "</div><div class=\"pull-left feedcontent\">" +
                                //"<a href=\"#\" class=\"feednm\" onclick=\"getFacebookProfiles('" + item.FromId + "');\">" + item.FromName + "</a> <span>" + item.MessageDate +
                                                            "<a target=\"_blank\" href=\"http://www.facebook.com/" + item.FromId + "\" class=\"feednm\">" + item.FromName + "</a> <span>" + item.MessageDate +
                                                                " </span>" +
                                                             "<p>";

                            if (!string.IsNullOrEmpty(item.Picture))
                            {
                                //string largeimage = item.Picture.Replace("_s.jpg","_n.jpg");

                                messages += "<img src=\"" + item.Picture + "\" alt=\"\" onclick=\"fbimage('" + item.Picture + "');\" /><br/>";
                            }

                            foreach (string substritem in str)
                            {
                                try
                                {
                                    if (!string.IsNullOrEmpty(substritem))
                                    {
                                        if (substritem.Contains("http"))
                                        {
                                            messages += "<a target=\"_blank\" href=\"" + substritem + "\">" + substritem + "</a>";
                                        }
                                        else
                                        {
                                            string hrefPost = string.Empty;

                                            try
                                            {
                                                hrefPost = "https://www.facebook.com/" + item.FromId + "/posts/" + item.MessageId.Replace(item.FromId, string.Empty).Replace("_", string.Empty).Trim();

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

                                            }
                                            if (!string.IsNullOrEmpty(hrefPost))
                                            {
                                                messages += "<a target=\"_blank\" href=\"" + hrefPost + "\">" + substritem + "</a>";//substritem;
                                            }
                                            else
                                            {
                                                messages += substritem;

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

                                }
                            }

                            //    messages += "</p>" +
                            //                "<a class=\"retweets\" href=\"#\">" +
                            //                "</a><p><span onclick=\"facebookLike('" + item.FbLike + "','" + profileid + "','" + item.MessageId + "')\" id=\"likefb_" + item.MessageId + "\" class=\"like\">Like</span><span id=\"commentfb_" + item.MessageId + "\" onclick=\"commentText('" + item.MessageId + "');\" class=\"comment\">Comment</span></p>" +
                            //                "<p class=\"commeent_box\"><input id=\"textfb_" + item.MessageId + "\" type=\"text\" class=\"put_comments\"></p>" +
                            //              "<p><span onclick=\"commentFB('" + item.MessageId + "','" + profileid + "')\" id=\"okfb_" + item.MessageId + "\" class=\"ok\">ok</span><span id=\"cancelfb_" + item.MessageId + "\" onclick=\"cancelFB('" + item.MessageId + "');\" class=\"cancel\"> cancel</span></p>" +
                            //                "</div>" +
                            //                "</li>";
                            //}



                            //messages += "</p>" +
                            //           "<a class=\"retweets\" href=\"#\">" +
                            //           "</a><p><span onclick=\"facebookShare('" + profileid + "','" + item.MessageId + "')\" id=\"likefb_" + item.MessageId + "\" class=\"like\">Share</span><span onclick=\"facebookLike('" + item.FbLike + "','" + profileid + "','" + item.MessageId + "')\" id=\"likefb_" + item.MessageId + "\" class=\"like\">Like</span><span id=\"commentfb_" + item.MessageId + "\" onclick=\"commentText('" + item.MessageId + "');\" class=\"comment\">Comment</span></p>" +
                            //           "<p class=\"commeent_box\"><input id=\"textfb_" + item.MessageId + "\" type=\"text\" class=\"put_comments\"></p>" +
                            //         "<p><span onclick=\"commentFB('" + item.MessageId + "','" + profileid + "')\" id=\"okfb_" + item.MessageId + "\" class=\"ok\">ok</span><span id=\"cancelfb_" + item.MessageId + "\" onclick=\"cancelFB('" + item.MessageId + "');\" class=\"cancel\"> cancel</span></p>" +
                            //           "</div>" +
                            //           "</li>";

                            messages += "</p>" +
                                     "<a class=\"retweets\" href=\"#\">" +
                                     "</a><p><span onclick=\"facebookLike('" + item.FbLike + "','" + profileid + "','" + item.MessageId + "')\" id=\"likefb_" + item.MessageId + "\" class=\"like\">Like</span><span id=\"commentfb_" + item.MessageId + "\" onclick=\"commentText('" + item.MessageId + "');\" class=\"comment\">Comment</span></p>" +
                                     "<p class=\"commeent_box\"><input id=\"textfb_" + item.MessageId + "\" type=\"text\" class=\"put_comments\"></p>" +
                                   "<p><span onclick=\"commentFB('" + item.MessageId + "','" + profileid + "')\" id=\"okfb_" + item.MessageId + "\" class=\"ok\">ok</span><span id=\"cancelfb_" + item.MessageId + "\" onclick=\"cancelFB('" + item.MessageId + "');\" class=\"cancel\"> cancel</span></p>" +
                                     "</div>" +
                                     "</li>";
                        }




                        catch (Exception ex)
                        {
                            logger.Error(ex.Message);
                            Console.WriteLine(ex.Message);
                        }
                    }
                    Response.Write(messages);
                    #endregion
                }
                else if (Request.QueryString["op"] == "fblike")
                {
                    #region fblikes
                    try
                    {
                        //System.IO.StreamReader sr = new System.IO.StreamReader(Request.InputStream);
                        //string line = "";
                        //line = sr.ReadToEnd();
                        //JObject jo = JObject.Parse(line);
                        //string accesstoken = Server.UrlDecode((string)jo["access"]);
                        //string id = Server.UrlDecode((string)jo["fbid"]);
                        string profileid = Request.QueryString["profileid"];
                        FacebookAccountRepository fbAccRepo = new FacebookAccountRepository();
                        FacebookAccount fbAccount = fbAccRepo.getFacebookAccountDetailsById(profileid, user.Id);
                        string id = Request.QueryString["fbid"];
                        FacebookClient fbClient = new FacebookClient(fbAccount.AccessToken);
                        var s = fbClient.Post(id + "/likes", null);
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                    }
                    #endregion
                }


                else if (Request.QueryString["op"] == "fbshare")
                {
                    try
                    {
                        string profileid = Request.QueryString["profileid"];
                        string id = Request.QueryString["msgid"];
                        FacebookAccountRepository fbAccRepo = new FacebookAccountRepository();
                        FacebookAccount fbAccount = fbAccRepo.getFacebookAccountDetailsById(profileid);
                        FacebookClient fbClient = new FacebookClient(fbAccount.AccessToken);
                        var s = fbClient.Post(id + "/sharedposts", null);

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



                else if (Request.QueryString["op"] == "fbcomment")
                {
                    #region fbcomment
                    string profileid = Request.QueryString["profileid"];
                    string message = Request.QueryString["message"];
                    FacebookAccountRepository fbAccRepo = new FacebookAccountRepository();
                    FacebookAccount fbAccount = fbAccRepo.getFacebookAccountDetailsById(profileid, user.Id);
                    string id = Request.QueryString["fbid"];
                    FacebookClient fbClient = new FacebookClient(fbAccount.AccessToken);
                    var args = new Dictionary<string, object>();
                    args["message"] = message;
                    var s = fbClient.Post(id + "/comments", args);

                    #endregion
                }
                else if (Request.QueryString["op"] == "twitternetworkdetails")
                {
                    #region twitternetworkdetails
                    string messages = string.Empty;
                    string profileid = Request.QueryString["profileid"];
                    TwitterFeedRepository fbmsgrepo = new TwitterFeedRepository();
                    List<TwitterFeed> lsgfbmsgs = fbmsgrepo.getTwitterFeedOfProfile(profileid);
                    UrlExtractor urlext = new UrlExtractor();
                    foreach (TwitterFeed item in lsgfbmsgs)
                    {
                        try
                        {
                            messages += "<li><div class=\"feedim pull-left\"><img alt=\"\" width=\"31\" height=\"31\" src=\"" + item.FromProfileUrl + "\" onclick=\"detailsdiscoverytwitter('" + item.FromId + "');\">" +
                                                         "</div><div class=\"pull-left feedcontent\">" +
                                                            "<a href=\"#\" class=\"feednm\" onclick=\"detailsdiscoverytwitter('" + item.FromId + "');\">" + item.FromName + "</a> <span>" + item.FeedDate +
                                                                " </span>" +
                                                             "<p>";

                            string[] str = urlext.splitUrlFromString(item.Feed);

                            foreach (string substritem in str)
                            {
                                try
                                {
                                    if (!string.IsNullOrEmpty(substritem))
                                    {
                                        if (substritem.Contains("http"))
                                        {
                                            messages += "<a target=\"_blank\" href=\"" + substritem + "\">" + substritem + "</a>";
                                        }
                                        else
                                        {
                                            string hrefPost = string.Empty;

                                            try
                                            {
                                                //https://twitter.com/265982289/status/431552741341941760
                                                hrefPost = "https://twitter.com/" + item.FromId + "/status/" + item.MessageId.Replace(item.FromId, string.Empty).Replace("_", string.Empty).Trim();

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

                                            }
                                            if (!string.IsNullOrEmpty(hrefPost))
                                            {
                                                messages += "<a target=\"_blank\" href=\"" + hrefPost + "\">" + substritem + "</a>";//substritem;
                                            }
                                            else
                                            {
                                                messages += substritem;

                                            }
                                        }
                                    }
                                }
                                catch (Exception)
                                {

                                }
                            }

                            messages += "</p>" +
                                   "<a class=\"retweets\" href=\"#\">" +
                                /*"<img alt=\"\" src=\"../contents/img/admin/arrow.png\">*/"</a><span></span>" +
                               "</div>" +
                           "</li>";
                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex.Message);
                            Console.WriteLine(ex.Message);
                        }
                    }
                    Response.Write(messages);
                    #endregion
                }
                else if (Request.QueryString["op"] == "scheduler")
                {
                    #region Schduler
                    string message = string.Empty;
                    string profileid = Request.QueryString["profileid"];
                    string network = Request.QueryString["network"];

                    if (network == "facebook")
                    {
                        ScheduledMessageRepository schmsgrepo = new ScheduledMessageRepository();
                        List<ScheduledMessage> lstschmsg = schmsgrepo.getAllMessagesOfUser(profileid);

                        if (lstschmsg.Count != 0)
                        {
                            foreach (ScheduledMessage item in lstschmsg)
                            {
                                try
                                {
                                    FacebookAccountRepository faceaccrepo = new FacebookAccountRepository();
                                    FacebookAccount faceacc = faceaccrepo.getFacebookAccountDetailsById(profileid);
                                    try
                                    {
                                        message += "<li><div class=\"feedim pull-left\"><img alt=\"\" width=\"31\" height=\"31\"  src=\"https://graph.facebook.com/" + item.ProfileId + "/picture?type=small\">" +
                                                                     "</div><div class=\"pull-left feedcontent\">" +
                                                                        "<a href=\"#\" class=\"feednm\">" + faceacc.FbUserName + "</a> <span>" + item.ScheduleTime +
                                                                            " </span>" +
                                                                         "<p>" + item.ShareMessage + "</p>" +
                                                                         "<a class=\"retweets\" href=\"#\">" +
                                                                          "</a><span></span>" +
                                                                     "</div>" +
                                                                 "</li>";
                                    }
                                    catch (Exception ex)
                                    {
                                        Console.WriteLine(ex.Message);
                                    }
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.Message);
                                }

                            }
                        }
                        else
                        {
                            message = "<li><div class=\"feedim pull-left\"><img alt=\"\" width=\"31\" height=\"31\" src=\"../Contents/img/blank_img.png\">" +
                                                                    "</div><div class=\"pull-left feedcontent\">" +
                                                                       "<a href=\"#\" class=\"feednm\"></a> <span>" +
                                                                           " </span>" +
                                                                        "<p>No Scheduled Messages</p>" +
                                                                        "<a class=\"retweets\" href=\"#\">" +
                                                                         "</a><span></span>" +
                                                                    "</div>" +
                                                                "</li>";
                        }



                    }
                    else if (network == "twitter")
                    {
                        ScheduledMessageRepository schmsgrepo = new ScheduledMessageRepository();
                        List<ScheduledMessage> lstschmsg = schmsgrepo.getAllMessagesOfUser(profileid);

                        if (lstschmsg.Count != 0)
                        {
                            foreach (ScheduledMessage item in lstschmsg)
                            {
                                try
                                {
                                    TwitterAccountRepository twtaccrepo = new TwitterAccountRepository();
                                    TwitterAccount twtacc = twtaccrepo.getUserInformation(profileid);
                                    message += "<li><div class=\"feedim pull-left\"><img alt=\"\" width=\"31\" height=\"31\"  src=\"" + twtacc.ProfileImageUrl + "\">" +
                                                                    "</div><div class=\"pull-left feedcontent\">" +
                                                                       "<a href=\"#\" class=\"feednm\">" + twtacc.TwitterScreenName + "</a> <span>" + item.ScheduleTime +
                                                                           " </span>" +
                                                                        "<p>" + item.ShareMessage + "</p>" +
                                                                        "<a class=\"retweets\" href=\"#\">" +
                                                                         "</a><span></span>" +
                                                                    "</div>" +
                                                                "</li>";
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.Message);
                                }
                            }
                        }
                        else
                        {
                            message = "<li><div class=\"feedim pull-left\"><img alt=\"\" width=\"31\" height=\"31\" src=\"../Contents/img/blank_img.png\">" +
                                                                  "</div><div class=\"pull-left feedcontent\">" +
                                                                     "<a href=\"#\" class=\"feednm\"></a> <span>" +
                                                                         " </span>" +
                                                                      "<p>No Scheduled Messages</p>" +
                                                                      "<a class=\"retweets\" href=\"#\">" +
                                                                       "</a><span></span>" +
                                                                  "</div>" +
                                                              "</li>";
                        }
                    }
                    else if (network == "linkedin")
                    {
                        ScheduledMessageRepository schmsgrepo = new ScheduledMessageRepository();
                        List<ScheduledMessage> lstschmsg = schmsgrepo.getAllMessagesOfUser(profileid);

                        if (lstschmsg.Count != 0)
                        {
                            foreach (ScheduledMessage item in lstschmsg)
                            {
                                try
                                {
                                    LinkedInAccountRepository linkedinrepo = new LinkedInAccountRepository();
                                    LinkedInAccount linkedacc = linkedinrepo.getUserInformation(profileid);
                                    message += "<li><div class=\"feedim pull-left\"><img alt=\"\" width=\"31\" height=\"31\"  src=\"" + linkedacc.ProfileImageUrl + "\">" +
                                                                        "</div><div class=\"pull-left feedcontent\">" +
                                                                           "<a href=\"#\" class=\"feednm\">" + linkedacc.LinkedinUserName + "</a> <span>" + item.ScheduleTime +
                                                                               " </span>" +
                                                                            "<p>" + item.ShareMessage + "</p>" +
                                                                            "<a class=\"retweets\" href=\"#\">" +
                                                                             "</a><span></span>" +
                                                                        "</div>" +
                                                                    "</li>";
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine("Error : " + ex.StackTrace);

                                }
                            }
                        }
                        else
                        {
                            message = "<li><div class=\"feedim pull-left\"><img alt=\"\" width=\"31\" height=\"31\" src=\"../Contents/img/blank_img.png\">" +
                                                                 "</div><div class=\"pull-left feedcontent\">" +
                                                                    "<a href=\"#\" class=\"feednm\"></a> <span>" +
                                                                        " </span>" +
                                                                     "<p>No Scheduled Messages</p>" +
                                                                     "<a class=\"retweets\" href=\"#\">" +
                                                                      "</a><span></span>" +
                                                                 "</div>" +
                                                             "</li>";

                        }

                    }




                    Response.Write(message);
                    #endregion
                }
                else if (Request.QueryString["op"] == "facebookfeeds")
                {
                    #region facebookfeeds
                    string message = string.Empty;
                    string profileid = Request.QueryString["profileid"];
                    FacebookAccountRepository faceaccrepo = new FacebookAccountRepository();
                    FacebookAccount faceaac = faceaccrepo.getFacebookAccountDetailsById(profileid);
                    FacebookFeedRepository facefeedrepo = new FacebookFeedRepository();
                    List<FacebookFeed> lstfbfeed = facefeedrepo.getAllFacebookUserFeeds(profileid);
                    UrlExtractor urlext = new UrlExtractor();
                    foreach (FacebookFeed item in lstfbfeed)
                    {
                        try
                        {
                            message += "<li><div class=\"feedim pull-left\"><img alt=\"\" width=\"31\" height=\"31\" src=\"https://graph.facebook.com/" + item.ProfileId + "/picture?type=small\" onclick=\"getFacebookProfiles('" + item.FromId + "');\">" +
                                                                                     "</div><div class=\"pull-left feedcontent\">" +
                                                                                        "<a href=\"#\" class=\"feednm\" onclick=\"getFacebookProfiles('" + item.FromId + "');\">" + faceaac.FbUserName + "</a> <span>" + item.FeedDate +
                                                                                            " </span>" +
                                                                                         "<p>";

                            string[] str = urlext.splitUrlFromString(item.FeedDescription);

                            foreach (string substritem in str)
                            {
                                try
                                {
                                    if (!string.IsNullOrEmpty(substritem))
                                    {
                                        if (substritem.Contains("http"))
                                        {
                                            message += "<a target=\"_blank\" href=\"" + substritem + "\">" + substritem + "</a>";
                                        }
                                        else
                                        {
                                            string hrefPost = string.Empty;

                                            try
                                            {
                                                hrefPost = "https://www.facebook.com/" + item.FromId + "/posts/" + item.FeedId.Replace(item.FromId, string.Empty).Replace("_", string.Empty).Trim();

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

                                            }
                                            if (!string.IsNullOrEmpty(hrefPost))
                                            {
                                                message += "<a target=\"_blank\" href=\"" + hrefPost + "\">" + substritem + "</a>";//substritem;
                                            }
                                            else
                                            {
                                                message += substritem;

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

                                }
                            }


                            message += "</p>" +
                                         "<a class=\"retweets\" href=\"#\">" +
                                          "</a><span></span>" +
                                     "</div>" +
                                 "</li>";
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Error : " + ex.StackTrace);

                        }
                    }
                    Response.Write(message);
                    #endregion
                }
                else if (Request.QueryString["op"] == "twitterfeeds")
                {
                    #region twitternfeeds
                    string message = string.Empty;
                    string profileid = Request.QueryString["profileid"];
                    TwitterMessageRepository twtmsgreop = new TwitterMessageRepository();
                    List<TwitterMessage> lstmsg = twtmsgreop.getAllTwitterMessagesOfProfile(profileid);
                    //TwitterFeedRepository twtmsgrepo = new TwitterFeedRepository();
                    //List<TwitterFeed>  lstfeed =  twtmsgrepo.getTwitterFeedOfProfile(profileid);
                    UrlExtractor urlext = new UrlExtractor();
                    foreach (TwitterMessage item in lstmsg)
                    {
                        try
                        {
                            message += "<li><div class=\"feedim pull-left\"><img alt=\"\" width=\"31\" height=\"31\" src=\"" + item.FromProfileUrl + "\" onclick=\"detailsdiscoverytwitter('" + item.FromId + "');\">" +
                                                         "</div><div class=\"pull-left feedcontent\">" +
                                                            "<a href=\"#\" class=\"feednm\" onclick=\"detailsdiscoverytwitter('" + item.FromId + "');\">" + item.FromName + "</a> <span>" + item.MessageDate +
                                                                " </span>" +
                                                             "<p>";

                            string[] str = urlext.splitUrlFromString(item.TwitterMsg);

                            foreach (string substritem in str)
                            {
                                try
                                {
                                    if (!string.IsNullOrEmpty(substritem))
                                    {
                                        if (substritem.Contains("http"))
                                        {
                                            message += "<a target=\"_blank\" href=\"" + substritem + "\">" + substritem + "</a>";
                                        }
                                        else
                                        {
                                            string hrefPost = string.Empty;

                                            try
                                            {
                                                //https://twitter.com/265982289/status/431552741341941760

                                                hrefPost = "https://twitter.com/" + item.FromId + "/status/" + item.MessageId.Replace(item.FromId, string.Empty).Replace("_", string.Empty).Trim();

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

                                            }
                                            if (!string.IsNullOrEmpty(hrefPost))
                                            {
                                                message += "<a target=\"_blank\" href=\"" + hrefPost + "\">" + substritem + "</a>";//substritem;
                                            }
                                            else
                                            {
                                                message += substritem;

                                            }
                                        }
                                    }
                                }
                                catch (Exception)
                                {

                                }
                            }
                            message += "</p>" +
                                                              "<a class=\"retweets\" href=\"#\">" +
                                /*"<img alt=\"\" src=\"../Contents/img/admin/arrow.png\">*/"</a><span></span>" +
                                                          "</div>" +
                                                      "</li>";
                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex.Message);
                            Console.WriteLine(ex.Message);
                        }
                    }
                    Response.Write(message);
                    #endregion
                }
                else if (Request.QueryString["op"] == "linkedinwallposts")
                {
                    #region linkedinwallposts
                    string message = string.Empty;
                    string profileid = Request.QueryString["profileid"];

                    LinkedInFeedRepository linkedinfeedrepo = new LinkedInFeedRepository();
                    List<LinkedInFeed> lstfeed = linkedinfeedrepo.getAllLinkedInFeedsOfProfile(profileid);





                    if (lstfeed != null)
                    {
                        if (lstfeed.Count != 0)
                        {
                            if (lstfeed.Count > 500)
                            {
                                int check = 0;
                                foreach (LinkedInFeed item in lstfeed)
                                {

                                    string PicUrl = string.Empty;
                                    if (string.IsNullOrEmpty(item.FromPicUrl))
                                    {
                                        PicUrl = "../Contents/img/blank_img.png";
                                    }
                                    else
                                    {
                                        PicUrl = item.FromPicUrl;
                                    }






                                    check++;
                                    try
                                    {
                                        message += "<li><div class=\"feedim pull-left\"><img alt=\"\" width=\"31\" height=\"31\" src=\"" + PicUrl + "\">" +
                                                                                              "</div><div class=\"pull-left feedcontent\">" +
                                                                                                 "<a style=\"cursor:default\" class=\"feednm\">" + item.FromName + "</a> <span>" + item.FeedsDate +
                                                                                                     " </span>" +
                                                                                                   " <a href=\"#\">" + item.Feeds + "</a>"+
                                                                                                  "<a class=\"retweets\" href=\"#\">" +
                                                                                                  "</a><span></span>" +
                                                                                              "</div>" +
                                                                                          "</li>";
                                    }
                                    catch (Exception ex)
                                    {
                                        logger.Error(ex.Message);
                                        Console.WriteLine(ex.Message);
                                    }
                                    if (check == 500)
                                    {
                                        break;
                                    }
                                }
                            }
                            else
                            {

                                foreach (LinkedInFeed item in lstfeed)
                                {
                                    try
                                    {
                                        string PicUrl = string.Empty;
                                        if (string.IsNullOrEmpty(item.FromPicUrl))
                                        {
                                            PicUrl = "../Contents/img/blank_img.png";
                                        }
                                        else
                                        {
                                            PicUrl = item.FromPicUrl;
                                        }





                                        message += "<li><div class=\"feedim pull-left\"><img alt=\"\" width=\"31\" height=\"31\" src=\"" + PicUrl + "\">" +
                                                                                              "</div><div class=\"pull-left feedcontent\">" +
                                                                                                 "<a style=\"cursor:default\" class=\"feednm\">" + item.FromName + "</a> <span>" + item.FeedsDate +
                                                                                                     " </span>" +
                                                                                                  " <a href=\"#\">" + item.Feeds + "</a>" +
                                                                                                  "<a class=\"retweets\" href=\"#\">" +
                                                                                                  "</a><span></span>" +
                                                                                              "</div>" +
                                                                                          "</li>";
                                    }
                                    catch (Exception ex)
                                    {
                                        logger.Error(ex.Message);
                                        Console.WriteLine(ex.Message);
                                    }
                                }
                            }
                        }
                        else
                        {
                            message = "<li><div class=\"feedim pull-left\"><img alt=\"\" width=\"31\" height=\"31\" src=\"../Contents/img/blank_img.png\">" +
                                                                   "</div><div class=\"pull-left feedcontent\">" +
                                                                      "<a href=\"#\" class=\"feednm\"></a> <span>" +
                                                                          " </span>" +
                                                                       "<p>No Messages Found</p>" +
                                                                       "<a class=\"retweets\" href=\"#\">" +
                                                                        "</a><span></span>" +
                                                                   "</div>" +
                                                               "</li>";
                        }
                    }
                    Response.Write(message);
                    #endregion
                }

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

                    #region tumblrBlog
                    string messages = string.Empty;
                    string profileid = Request.QueryString["profileid"];
                    TumblrAccount objTumblrAccount = tumblraccrepo.getTumblrAccountDetailsById(profileid);
                    List<TumblrFeed> lstfeed = objTumblrFeedRepository.getFeedOfProfile(profileid);

                    string strTumblrImage = string.Empty;
                    string image = string.Empty;
                    try
                    {

                        if (lstfeed.Count != 0)
                        {


                            strTumblrImage += "<div class=\"feedcontainer\"><div class=\"pull-left span\"><div id=\"tumblrcontents\">" +
                       "<a href=\"#\"><img onClick=\"Bpopup()\" src=\"../Contents/img/share.png\" width=\"20\" title=\"Share Content\" /></a>" +
                    "</div></div>";


                            foreach (TumblrFeed feed in lstfeed)
                            {
                                if (string.IsNullOrEmpty(feed.imageurl))
                                {
                                    image = "../../Contents/img/admin/Demo-Image.png";


                                }
                                else
                                {
                                    image = feed.imageurl;
                                }



                                try
                                {
                                    //    strTumblrImage += "<div class=\"span3\" class=\"row-fluid\"><div class=\"span box whitebg tumb_bg feedwrap\"><div class=\"tumb_title\"><span class=\"tumb_span\">" + feed.blogname+ "</span></div><div class=\"pic tumb_pic\"><img onclick=\"tumblrimage('" + feed.imageurl + "')\" alt=\"\" src=\"" + image + "\"></div><div class=\"topicon\">" +
                                    //"<div class=\"pull-right\" id=\"like\"><a title=\"\" href=\"#\" onClick=\"LikePic('" + feed.ProfileId + "','" + feed.Id + "','" + objTumblrAccount.tblrAccessToken + "','" + objTumblrAccount.tblrAccessTokenSecret + "','" + feed.liked + "','" + feed.notes + "')\" >" + getlike(feed.liked, feed.ProfileId) + "</a><a title=\"\" href=\"#\"><img onClick=\"UnfollowBlog('" + feed.ProfileId + "','" + feed.Id + "','" + objTumblrAccount.tblrAccessToken + "','" + objTumblrAccount.tblrAccessTokenSecret + "','" + feed.blogname + "')\"   width=\"14\" alt=\"\" src=\"../Contents/img/admin/speech-bubble-left.png\"  style=\"margin-top: 9px;\"></a>" +
                                    //"</div></div><div class=\"desc\"><p></p><span class=\"pull-left pics_space span4\">" +
                                    //"<img width=\"12\" alt=\"\" src=\"../Contents/img/admin/dil.png\"> " + feed.notes + "</span><div class=\"clearfix\">" +
                                    //"<div class=\"tumb_description\"><p class=\"feed_slug\"><strong>" + feed.slug + "</strong></p><p class=\"teaser\">" + feed.description + "</p></div></div>";





                                    strTumblrImage += "<div class=\"span3\" class=\"row-fluid\"><div class=\"span box whitebg tumb_bg feedwrap\"><div class=\"tumb_title\"><span class=\"tumb_span\">" + feed.blogname + "</span></div><div class=\"pic tumb_pic\"><img onclick=\"tumblrimage('" + feed.imageurl + "')\" alt=\"\" src=\"" + image + "\"></div><div class=\"topicon\">" +
                                                                    "<div class=\"pull-right\" id=\"like\"><a title=\"\" href=\"#\" onClick=\"LikePic('" + feed.ProfileId + "','" + feed.Id + "','" + objTumblrAccount.tblrAccessToken + "','" + objTumblrAccount.tblrAccessTokenSecret + "','" + feed.liked + "','" + feed.notes + "')\" >" + getlike(feed.liked, feed.ProfileId) + "</a><a title=\"\" href=\"#\"><img onClick=\"UnfollowBlog('" + feed.ProfileId + "','" + feed.Id + "','" + objTumblrAccount.tblrAccessToken + "','" + objTumblrAccount.tblrAccessTokenSecret + "','" + feed.blogname + "')\"   width=\"14\" alt=\"\" src=\"../Contents/img/admin/speech-bubble-left.png\"  style=\"margin-top: 9px;\"></a>" +
                                                                    "</div></div><div class=\"desc\"><p></p><span class=\"pull-left pics_space span4\">" +
                                                                    "<img width=\"12\" alt=\"\" src=\"../Contents/img/admin/dil.png\"> " + feed.notes + "</span><div class=\"clearfix\">" +
                                                                    "<div class=\"tumb_description\"><p class=\"feed_slug\"><strong>" + feed.slug + "</strong></p><p class=\"teaser\">" + feed.description + "</p></div></div>";





                                    strTumblrImage += "</div></div></div>";
                                }
                                catch (Exception ex)
                                {
                                    logger.Error(ex.Message);
                                    Console.WriteLine(ex.Message);
                                }
                            }
                            strTumblrImage += "</div>";
                        }
                        else
                        {
                            if (instagramcount == 0)
                            {
                                strTumblrImage = "<div class=\"grid\"><div class=\"box whitebg feedwrap\">" +
                                             "<div class=\"topicon\"><div class=\"pull-left\"></div><div class=\"pull-right\">" +
                                 "<a href=\"#\" title=\"\"></a><a href=\"#\" title=\"\"></a></div></div><div class=\"pic\">" +
                                 "<img src=\"../Contents/img/no_image_found.png\" alt=\"\"></div><div class=\"desc\"><p></p></div></div></div>";
                            }
                        }


                        Response.Write(strTumblrImage);


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



                    #endregion
                }
                //VIDEOS
                else if (Request.QueryString["op"] == "youtubechannel")
                {
                    #region youtube_channel
                    string thumbnail = string.Empty;
                    string videoid = string.Empty;
                    string strYoutubechanell = string.Empty;
                    string GooglePlusUserId = Request.QueryString["profileid"];
                    string accesstoken = Request.QueryString["accesstoken"];
                    oAuthTokenYoutube objoAuthTokenYoutube = new oAuthTokenYoutube();
                    string finaltoken = objoAuthTokenYoutube.GetAccessToken(accesstoken);
                    string strfinaltoken = string.Empty;


                    try
                    {

                        if (!finaltoken.StartsWith("["))
                            finaltoken = "[" + finaltoken + "]";
                        JArray objArray = JArray.Parse(finaltoken);


                        foreach (var item in objArray)
                        {
                            try
                            {
                                strfinaltoken = item["access_token"].ToString();
                                break;
                            }
                            catch (Exception ex)
                            {
                                //logger.Error(ex.StackTrace);
                                Console.WriteLine(ex.StackTrace);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        //logger.Error(ex.StackTrace);
                        Console.WriteLine(ex.StackTrace);
                    }


                    YoutubeChannel objChnnelData = ytrchannelrpo.getYoutubeChannelDetailsById(GooglePlusUserId);
                    PlaylistItems objPlaylistItems = new PlaylistItems();
                    string objDetails = objPlaylistItems.Get_PlaylistItems_List(strfinaltoken, GlobusGooglePlusLib.Authentication.oAuthTokenYoutube.Parts.snippet.ToString(), objChnnelData.Uploadsid);

                    JObject obj = JObject.Parse(objDetails);

                    JArray array = (JArray)obj["items"];


                    //strYoutubechanell = " <div class=\"row\"> ";

                    int rowCount = 0;
                    int columnCount = 0;

                    //strYoutubechanell = "<div class=\"row top_select\"> <div class=\"pull-left\"><a href=\"#\"><div class=\"YtIns\">Hello</div></a></div> <div class=\"pull-right\"><select class=\"form-control\" onchange=\"dropDownChange(this,'" + GooglePlusUserId + "','" + accesstoken + "')\"><option>Video</option> <option>Play list</option> <option>Activities</option></select></div></div><div class=\"container yt_details\">";
                    //strYoutubechanell = "<div class=\"row\">  <div class=\"pull-right\"><select class=\"form-control\" onchange=\"dropDownChange(this,'" + GooglePlusUserId + "','" + accesstoken + "')\"><option>Video</option> <option>Play list</option> <option>Activities</option></select></div></div>";
                    strYoutubechanell = "<div class=\"row top_select\"> <div class=\"pull-left\"><a href=\"#\"><div class=\"YtIns\"></div></a></div> <div class=\"pull-right\">"
                                        + "<ul class=\"nav nav-tabs\"><li class=\"active\"><a href=\"#VIDEO\" onclick=\"dropDownChange(this,'" + GooglePlusUserId + "','" + accesstoken + "')\" data-toggle=\"tab\">VIDEO</a></li><li><a href=\"#ACT\" onclick=\"dropDownChange(this,'" + GooglePlusUserId + "','" + accesstoken + "')\" data-toggle=\"tab\">ACTIVITES</a></li><li>"
                    + "<a href=\"#SUB\" onclick=\"dropDownChange(this,'" + GooglePlusUserId + "','" + accesstoken + "')\" data-toggle=\"tab\">SUBSCRIBTIONS</a></li></ul></div></div><div class=\"tab-content yt_details_container\"><div class=\"tab-pane active\" id=\"ACT\">"
                    + "<div class=\"container yt_details\">";



                    string strYoutubechanell1 = string.Empty;

                    foreach (var item in array)
                    {
                        columnCount++;
                        try
                        {
                            thumbnail = item["snippet"]["thumbnails"]["maxres"]["url"].ToString();
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);

                        }
                        if (string.IsNullOrEmpty(thumbnail))
                        {
                            try
                            {
                                thumbnail = item["snippet"]["thumbnails"]["high"]["url"].ToString();
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex.StackTrace);
                            }
                        }

                        try
                        {
                            videoid = item["snippet"]["resourceId"]["videoId"].ToString();
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);

                        }


                        string viewCount = string.Empty;
                        string likeCount = string.Empty;
                        string dislikeCount = string.Empty;
                        string favoriteCount = string.Empty;
                        string commentCount = string.Empty;
                        if (!string.IsNullOrEmpty(videoid))
                        {

                            try
                            {
                                GlobusGooglePlusLib.Youtube.Core.Video ObjClsVideo = new Video();

                                string videoDetails = ObjClsVideo.Get_VideoDetails_byId(videoid, strfinaltoken, "snippet,statistics");

                                JObject JobjvideoDetails = JObject.Parse(videoDetails);

                                var JArrvideoDetails = (JArray)(JobjvideoDetails["items"]);

                                foreach (var DataVal in JArrvideoDetails)
                                {
                                    viewCount = DataVal["statistics"]["viewCount"].ToString();
                                    likeCount = DataVal["statistics"]["likeCount"].ToString();
                                    dislikeCount = DataVal["statistics"]["dislikeCount"].ToString();
                                    favoriteCount = DataVal["statistics"]["favoriteCount"].ToString();
                                    commentCount = DataVal["statistics"]["commentCount"].ToString();
                                    break;
                                }


                            }
                            catch (Exception)
                            {
                            }

                        }


                        //strYoutubechanell1 += "<div class=\"span4\">" +
                        //                    "<div class=\"well\">" +
                        //                     "<div class=\"video-containers thumbnail\">" +
                        //                     "<img onclick=\"youtubevideo('" + videoid + "')\" alt=\"\" src=\"" + thumbnail + "\">" +
                        //                     "</div><span class=\"pull-left\"><a href=\"#\"> &nbsp;<i class=\"icon-eye-open\"></i></a>" +
                        //                     "</span></div></div>";

                        strYoutubechanell1 += "<div class=\"span3\">" +
                                            "<div class=\"span box whitebg tumb_bg\">" +
                                             "<div class=\"yt_title\"></div><div class=\"video-containers thumbnail\">" +
                                             "<img onclick=\"youtubevideo('" + videoid + "')\" alt=\"\" src=\"" + thumbnail + "\">" +
                                             "</div><div class=\"icons\" style=\"width: 225px; float: left;\"><span class=\"span6 pull-left\">" +
                                             "<a href=\"#\" style=\"float: left;\"> &nbsp;<i style=\"color: green;\" class=\"icon-hand-up\"></i></a><span class=\"pull-left\">" + likeCount + "</span></a><a href=\"#\" style=\"float: left;\"> &nbsp;<i style=\"color: red;\" class=\"icon-hand-down\"></i><span>" + dislikeCount + "</span>" +
                                             "</a></span><span class=\"pull-right\"><a href=\"#\"> &nbsp;<i style=\"color: red;\" class=\"icon-eye-open\"></i><span>" + viewCount + "</span></a></span></div><div class=\"yt_description\"></div></div></div>";


                        try
                        {

                            if (rowCount == 3)
                            {
                                //strYoutubechanell += " <div class=\"row space\">" + strYoutubechanell1 + "</div></div></div>";
                                strYoutubechanell += " <div class=\"row space\">" + strYoutubechanell1 + "</div>";
                                strYoutubechanell1 = string.Empty;
                                rowCount = 0;
                            }
                            else
                            {
                                rowCount++;
                            }
                            if (!strYoutubechanell.Contains(strYoutubechanell1) && array.Count == columnCount)
                            {
                                //strYoutubechanell += " <div class=\"row space\">" + strYoutubechanell1 + "</div></div>";
                                strYoutubechanell += " <div class=\"row space\">" + strYoutubechanell1 + "</div>";
                            }

                        }
                        catch (Exception)
                        {

                        }



                        //strYoutubechanell += "<div class=\"span3\" class=\"row-fluid\"><div class=\"span12 box whitebg feedwrap\"><div class=\"topicon\"><div class=\"pull-left\">" +

                        //                                        "</div><div class=\"pull-right\" id=\"like\"><a title=\"\" href=\"#\" onClick=\"LikePic()\" ></a><a title=\"\" href=\"#\"></a>" +
                        //                                        "</div></div><div class=\"pic\"><img onclick=\"youtubevideo('" + videoid + "')\" alt=\"\" src=\"" + thumbnail + "\"></div><div class=\"desc\"><p></p><span class=\"pull-left span3\">" +
                        //                                        "<img width=\"12\" alt=\"\" src=\"../Contents/img/admin/dil.png\"></span><div class=\"clearfix\">" +
                        //                                        "</div>";



                        //strYoutubechanell += "</div></div></div>";



                    }

                    Response.Write("<div id=\"ACT\" class=\"tab-pane active\"><div class=\"container yt_details\">" + strYoutubechanell + "\"</div></div>");

                    #endregion
                }

                //ACTIVITIES
                else if (Request.QueryString["op"] == "youtubeactivity")
                {
                    #region youtube_ACTIVITIES

                    string strYoutubechanell = string.Empty;
                    string GooglePlusUserId = Request.QueryString["profileid"];
                    string accesstoken = Request.QueryString["accesstoken"];
                    oAuthTokenYoutube objoAuthTokenYoutube = new oAuthTokenYoutube();
                    string finaltoken = objoAuthTokenYoutube.GetAccessToken(accesstoken);
                    string strfinaltoken = string.Empty;

                    try
                    {

                        if (!finaltoken.StartsWith("["))
                            finaltoken = "[" + finaltoken + "]";
                        JArray objArray = JArray.Parse(finaltoken);


                        foreach (var item in objArray)
                        {
                            try
                            {

                                strfinaltoken = item["access_token"].ToString();

                                break;

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

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


                    YoutubeChannel objChnnelData = ytrchannelrpo.getYoutubeChannelDetailsById(GooglePlusUserId);
                    GlobusGooglePlusLib.Youtube.Core.Activities objActivities = new Activities();
                    string objDetails = objActivities.Get_All_Activities(strfinaltoken, oAuthTokenYoutube.Parts.snippet, true, 50);

                    JObject obj = JObject.Parse(objDetails);

                    JArray array = (JArray)obj["items"];

                    int rowCount = 0;
                    int columnCount = 0;

                    strYoutubechanell = "";

                    string strYoutubechanell1 = string.Empty;

                    foreach (var item in array)
                    {
                        string title = string.Empty;
                        string description = string.Empty;
                        string thumbnail = string.Empty;
                        string videoid = string.Empty;

                        columnCount++;

                        #region << Title >>

                        try
                        {
                            title = item["snippet"]["title"].ToString();
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);

                        }
                        #endregion

                        #region << Description >>

                        try
                        {
                            description = item["snippet"]["description"].ToString();
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);

                        }
                        #endregion

                        #region  << Thumbnail >>

                        try
                        {
                            thumbnail = item["snippet"]["thumbnails"]["maxres"]["url"].ToString();
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);

                        }
                        if (string.IsNullOrEmpty(thumbnail))
                        {

                            try
                            {
                                thumbnail = item["snippet"]["thumbnails"]["high"]["url"].ToString();
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex.StackTrace);
                            }
                        }
                        #endregion

                        try
                        {
                            videoid = item["snippet"]["resourceId"]["videoId"].ToString();
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }


                        string viewCount = string.Empty;
                        string likeCount = string.Empty;
                        string dislikeCount = string.Empty;
                        string favoriteCount = string.Empty;
                        string commentCount = string.Empty;
                        if (!string.IsNullOrEmpty(videoid))
                        {

                            try
                            {
                                GlobusGooglePlusLib.Youtube.Core.Video ObjClsVideo = new Video();

                                string videoDetails = ObjClsVideo.Get_VideoDetails_byId(videoid, strfinaltoken, "snippet,statistics");

                                JObject JobjvideoDetails = JObject.Parse(videoDetails);

                                var JArrvideoDetails = (JArray)(JobjvideoDetails["items"]);

                                foreach (var DataVal in JArrvideoDetails)
                                {
                                    viewCount = DataVal["statistics"]["viewCount"].ToString();
                                    likeCount = DataVal["statistics"]["likeCount"].ToString();
                                    dislikeCount = DataVal["statistics"]["dislikeCount"].ToString();
                                    favoriteCount = DataVal["statistics"]["favoriteCount"].ToString();
                                    commentCount = DataVal["statistics"]["commentCount"].ToString();
                                    break;
                                }


                            }
                            catch (Exception)
                            {
                            }

                        }


                        if (string.IsNullOrEmpty(title) && thumbnail.EndsWith("hq1.jpg") && string.IsNullOrEmpty(videoid) && string.IsNullOrEmpty(description))
                        {
                            continue;
                        }



                        strYoutubechanell1 += "<div class=\"span3\">" +
                                              "<div class=\"span box whitebg tumb_bg\">" +
                                             "<div class=\"yt_title\">" + title + "</div><div class=\"video-containers thumbnail\">" +
                                             "<img onclick=\"youtubevideo('" + videoid + "')\" alt=\"\" src=\"" + thumbnail + "\">" +
                                             "</div><div class=\"yt_description\">" + description + "</div></div></div>";



                        try
                        {
                            if (rowCount == 3)
                            {
                                strYoutubechanell += " <div class=\"row space\">" + strYoutubechanell1 + "</div>";
                                strYoutubechanell1 = string.Empty;
                                rowCount = 0;
                            }
                            else
                            {
                                rowCount++;
                            }
                            if (!strYoutubechanell.Contains(strYoutubechanell1) && array.Count == columnCount)
                            {
                                strYoutubechanell += " <div class=\"row space\">" + strYoutubechanell1 + "</div>";
                            }
                        }
                        catch (Exception)
                        {

                        }
                    }

                    Response.Write(strYoutubechanell);

                    #endregion
                }
                //SUBSCRIBTIONS
                else if (Request.QueryString["op"] == "youtubesubscribe")
                {
                    #region youtube_SUBSCRIBE

                    string strYoutubechanell = string.Empty;
                    string GooglePlusUserId = Request.QueryString["profileid"];
                    string accesstoken = Request.QueryString["accesstoken"];
                    oAuthTokenYoutube objoAuthTokenYoutube = new oAuthTokenYoutube();
                    string finaltoken = objoAuthTokenYoutube.GetAccessToken(accesstoken);
                    string strfinaltoken = string.Empty;

                    try
                    {

                        if (!finaltoken.StartsWith("["))
                            finaltoken = "[" + finaltoken + "]";
                        JArray objArray = JArray.Parse(finaltoken);


                        foreach (var item in objArray)
                        {
                            try
                            {

                                strfinaltoken = item["access_token"].ToString();

                                break;

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

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


                    Subscriptions _Subscriptions = new Subscriptions();


                    string _strSubscriptions = _Subscriptions.Get_Subscriptions_List(strfinaltoken, oAuthTokenYoutube.Parts.snippet.ToString());

                    //YoutubeChannel objChnnelData = ytrchannelrpo.getYoutubeChannelDetailsById(GooglePlusUserId);
                    //GlobusGooglePlusLib.Youtube.Core.Activities objActivities = new Activities();
                    //string objDetails = objActivities.Get_All_Activities(strfinaltoken, oAuthTokenYoutube.Parts.snippet, true, 50);

                    JObject obj = JObject.Parse(_strSubscriptions);

                    JArray array = (JArray)obj["items"];

                    int rowCount = 0;
                    int columnCount = 0;

                    strYoutubechanell = "";

                    string strYoutubechanell1 = string.Empty;

                    foreach (var item in array)
                    {
                        string title = string.Empty;
                        string description = string.Empty;
                        string _resoucechannelId = string.Empty;
                        string thumbnail = string.Empty;

                        columnCount++;

                        #region << Title >>

                        try
                        {
                            title = item["snippet"]["title"].ToString();
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);

                        }
                        #endregion

                        #region << Description >>

                        try
                        {
                            description = item["snippet"]["description"].ToString();
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);

                        }
                        #endregion

                        #region  << Thumbnail >>

                        try
                        {
                            thumbnail = item["snippet"]["thumbnails"]["maxres"]["url"].ToString();
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);

                        }
                        if (string.IsNullOrEmpty(thumbnail))
                        {

                            try
                            {
                                thumbnail = item["snippet"]["thumbnails"]["high"]["url"].ToString();
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex.StackTrace);
                            }
                        }
                        #endregion

                        try
                        {
                            _resoucechannelId = item["snippet"]["resourceId"]["channelId"].ToString();
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }


                        string viewCount = string.Empty;
                        string subscriberCount = string.Empty;
                        string hiddenSubscriberCount = string.Empty;
                        string videoCount = string.Empty;
                        string commentCount = string.Empty;
                        if (!string.IsNullOrEmpty(_resoucechannelId))
                        {

                            try
                            {
                                GlobusGooglePlusLib.Youtube.Core.Channels _Channels = new Channels();

                                string videoDetails = _Channels.Get_Channel_List(strfinaltoken, (oAuthTokenYoutube.Parts.snippet.ToString() + "," + oAuthTokenYoutube.Parts.statistics.ToString()), _resoucechannelId);

                                JObject JobjvideoDetails = JObject.Parse(videoDetails);

                                var JArrvideoDetails = (JArray)(JobjvideoDetails["items"]);

                                foreach (var DataVal in JArrvideoDetails)
                                {
                                    viewCount = DataVal["statistics"]["viewCount"].ToString();
                                    subscriberCount = DataVal["statistics"]["subscriberCount"].ToString();
                                    hiddenSubscriberCount = DataVal["statistics"]["hiddenSubscriberCount"].ToString();
                                    videoCount = DataVal["statistics"]["videoCount"].ToString();
                                    commentCount = DataVal["statistics"]["commentCount"].ToString();
                                    break;
                                }


                            }
                            catch (Exception)
                            {
                            }

                        }



                        //strYoutubechanell1 += "<div class=\"span3\">" +
                        //                      "<div class=\"span box whitebg tumb_bg\">" +
                        //                     "<div class=\"yt_title\">" + title + "</div><div class=\"video-containers thumbnail\">" +
                        //                     "<img onclick=\"#\" alt=\"\" src=\"" + thumbnail + "\">" +
                        //                     "</div><div class=\"icons\" style=\"width: 225px; float: left;\"><span class=\"span6 pull-left\">" +
                        //                     "<a href=\"#\" style=\"float: left;\"> &nbsp;<i style=\"color: green;\" class=\"icon-facetime-video\"></i></a>" +
                        //                     "<span class=\"pull-left\">&nbsp;" + videoCount + "</span></a><a href=\"#\" style=\"float: left;\"> &nbsp;<i style=\"color: red;\" class=\"icon-comment\"></i>" +
                        //                     "<span>&nbsp;" + commentCount + "</span></a></span><span class=\"pull-right\"><a href=\"#\"> &nbsp;<i style=\"color: red; padding-right: 5px;\" class=\"icon-eye-open\"></i><span>&nbsp;" + viewCount + "</span></a>" +
                        //                     "</span></div><div class=\"yt_description\">" + description + "</div></div></div>";


                        strYoutubechanell1 += "<div class=\"span3\">" +
                                             "<div class=\"span box whitebg tumb_bg\">" +
                                            "<div class=\"yt_title\">" + title + "</div><div class=\"video-containers thumbnail\">" +
                                            "<img onclick=\"#\" alt=\"\" src=\"" + thumbnail + "\">" +
                                            "</div><div class=\"icons\" style=\"width: 225px; float: left;\"><span class=\"span7 pull-left\">" +
                                            "<a href=\"#\" style=\"float: left;\"> &nbsp;<i style=\"color: green;\" class=\"icon-facetime-video\"></i></a>" +
                                            "<span class=\"pull-left\">&nbsp;" + ConvertMillionAndBillion(videoCount) + "</span></a><a href=\"#\" style=\"float: left;\"> &nbsp;<i style=\"color: red;\" class=\"icon-comment\"></i>" +
                                            "<span>&nbsp;" + ConvertMillionAndBillion(commentCount) + "</span></a></span><span class=\"pull-right\"><a href=\"#\"> &nbsp;<i style=\"color: red; padding-right: 5px;\" class=\"icon-eye-open\"></i><span>&nbsp;" + ConvertMillionAndBillion(viewCount) + "</span></a>" +
                                            "</span></div><div class=\"yt_description\">" + description + "</div></div></div>";


                        try
                        {
                            if (rowCount == 3)
                            {
                                strYoutubechanell += " <div class=\"row space\">" + strYoutubechanell1 + "</div>";
                                strYoutubechanell1 = string.Empty;
                                rowCount = 0;
                            }
                            else
                            {
                                rowCount++;
                            }
                            if (!strYoutubechanell.Contains(strYoutubechanell1) && array.Count == columnCount)
                            {
                                strYoutubechanell += " <div class=\"row space\">" + strYoutubechanell1 + "</div>";
                            }
                        }
                        catch (Exception)
                        {

                        }
                    }

                    Response.Write(strYoutubechanell);

                    #endregion
                }
                else if (Request.QueryString["op"] == "linkedinfeeds")
                {
                    #region linkedinfeeds
                    string profileid = Request.QueryString["profileid"];
                    LinkedInAccountRepository linkedinAccRepo = new LinkedInAccountRepository();
                    LinkedInAccount linkacc = linkedinAccRepo.getUserInformation(profileid);
                    oAuthLinkedIn oauthlin = new oAuthLinkedIn();
                    oauthlin.ConsumerKey = ConfigurationManager.AppSettings["LiApiKey"];
                    oauthlin.ConsumerSecret = ConfigurationManager.AppSettings["LiSecretKey"];
                    oauthlin.FirstName = linkacc.LinkedinUserName;
                    oauthlin.Id = linkacc.LinkedinUserId;
                    oauthlin.Token = linkacc.OAuthToken;
                    oauthlin.TokenSecret = linkacc.OAuthSecret;
                    oauthlin.Verifier = linkacc.OAuthVerifier;


                    LinkedInUser l = new LinkedInUser();
                    List<LinkedInUser.User_Updates> lst = l.GetUserUpdates(oauthlin, linkacc.LinkedinUserId, 10);
                    string message = string.Empty;
                    if (lst.Count != 0)
                    {
                        foreach (LinkedInUser.User_Updates item in lst)
                        {
                            try
                            {
                                string picurl = string.Empty;
                                if (string.IsNullOrEmpty(item.PictureUrl))
                                {
                                    picurl = "../Contents/img/blank_img.png";
                                }
                                else
                                {
                                    picurl = item.PictureUrl;
                                }
                                message += "<li><div class=\"feedim pull-left\"><img alt=\"\" width=\"31\" height=\"31\" src=\"" + picurl + "\">" +
                                                                       "</div><div class=\"pull-left feedcontent\">" +
                                                                          "<a href=\"" + linkacc.ProfileUrl + "\" target=\"_blank\" class=\"feednm\">" + item.PersonFirstName + " " + item.PersonLastName + "</a> <span>" + item.DateTime +
                                                                              " </span>" +
                                                                           "<p>" + item.Message + "</p>" +
                                                                           "<a class=\"retweets\" href=\"#\">" +
                                                                           "</a><span></span>" +
                                                                       "</div>" +
                                                                   "</li>";
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex.Message);
                            }

                        }
                    }
                    else
                    {
                        message += "<li><div class=\"feedim pull-left\"><img alt=\"\" width=\"31\" height=\"31\" src=\"../Contents/img/blank_img.png\">" +
                                                                                             "</div><div class=\"pull-left feedcontent\">" +
                                                                                                "<a href=\"#\" class=\"feednm\"></a> <span>" +
                                                                                                    " </span>" +
                                                                                                 "<p>No Messages Found</p>" +
                                                                                                 "<a class=\"retweets\" href=\"#\">" +
                                                                                                  "</a><span></span>" +
                                                                                             "</div>" +
                                                                                         "</li>";
                    }
                    Response.Write(message);
                    #endregion
                }
                else if (Request.QueryString["op"] == "facebookapi")
                {
                    #region facebookapi
                    try
                    {
                        string profileid = Request.QueryString["profileid"];
                        // FacebookAccountRepository facerepo = new FacebookAccountRepository();
                        FacebookAccount faceaccount = facerepo.getFacebookAccountDetailsById(profileid);
                        FacebookHelper fbhelper = new FacebookHelper();
                        FacebookClient fbclient = new FacebookClient(faceaccount.AccessToken);
                        dynamic profile = fbclient.Get("me");
                        var feeds = fbclient.Get("/me/feed");
                        var home = fbclient.Get("me/home");
                        fbhelper.getFacebookUserFeeds(feeds, profile);
                        fbhelper.getFacebookUserHome(home, profile);
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                        Console.WriteLine(ex.Message);
                    }
                    #endregion
                }
                else if (Request.QueryString["op"] == "twitterapi")
                {
                    string profileid = Request.QueryString["profileid"];
                    TwitterAccountRepository twtAccountRepo = new TwitterAccountRepository();
                    TwitterAccount twtAccount = twtAccountRepo.getUserInformation(user.Id, profileid);
                    oAuthTwitter oAuth = new oAuthTwitter();
                    TwitterHelper twthelper = new TwitterHelper();
                    oAuth.AccessToken = twtAccount.OAuthToken;
                    oAuth.AccessTokenSecret = twtAccount.OAuthSecret;
                    twthelper.SetCofigDetailsForTwitter(oAuth);
                    oAuth.TwitterScreenName = twtAccount.TwitterScreenName;
                    oAuth.TwitterUserId = twtAccount.TwitterUserId;
                    twthelper.getUserTweets(oAuth, twtAccount, user.Id);
                    twthelper.getUserFeed(oAuth, twtAccount, user.Id);
                    twthelper.getSentDirectMessages(oAuth, twtAccount, user.Id);
                    twthelper.getReTweetsOfUser(oAuth, twtAccount, user.Id);

                }
                else if (Request.QueryString["op"] == "instagramlike")
                {
                    string mediaid = Request.QueryString["mediaid"];
                    bool b = this.likefunction(mediaid, Request.QueryString["userid"], Request.QueryString["access"]);
                }
                else if (Request.QueryString["op"] == "instagramunlike")
                {
                    string mediaid = Request.QueryString["mediaid"];
                    bool b = this.unlikefunction(mediaid, Request.QueryString["userid"], Request.QueryString["access"]);

                }
                else if (Request.QueryString["op"] == "instagramimages")
                {
                    if (Request.QueryString["loadtime"] != "first")
                    {
                        instagramcount = instagramcount + 10;
                    }
                    else
                    {
                        instagramcount = 0;
                    }

                    InstagramAccountRepository objInsAccRepo = new InstagramAccountRepository();
                    InstagramFeedRepository objInsFeedRepo = new InstagramFeedRepository();
                    InstagramFeed objInsFeed = new InstagramFeed();
                    InstagramCommentRepository objInsCmtRepo = new InstagramCommentRepository();
                    List<SocioBoard.Domain.InstagramComment> lstInsCmt = new List<SocioBoard.Domain.InstagramComment>();

                    string strInsImage = string.Empty;

                    try
                    {
                        string profileid = Request.QueryString["profileid"];
                        InstagramAccount insaccount = objInsAccRepo.getInstagramAccountDetailsById(profileid, user.Id);
                        List<InstagramFeed> lstInsFeed = objInsFeedRepo.getAllInstagramFeedsOfUser(user.Id, profileid, instagramcount);
                        if (lstInsFeed.Count != 0)
                        {
                            strInsImage += "<div class=\"feedcontainer\">";
                            foreach (InstagramFeed feed in lstInsFeed)
                            {

                                try
                                {
                                    lstInsCmt = objInsCmtRepo.getAllInstagramCommentsOfUser(user.Id, profileid, feed.FeedId);
                                }
                                catch (Exception ex)
                                {
                                    logger.Error(ex.Message);
                                    Console.WriteLine(ex.Message);
                                }
                                try
                                {
                                    strInsImage += "<div class=\"span3\" class=\"row-fluid\"><div class=\"span12 box whitebg feedwrap\"><div class=\"topicon\"><div class=\"pull-left\">" +

                                                                    "</div><div class=\"pull-right\" id=\"like\"><a title=\"\" href=\"#\" onClick=\"insUser('" + feed.FeedId + "','" + insaccount.AccessToken + "')\" ><img id=\"heartEmpty_" + feed.FeedId + "\" width=\"14\" alt=\"\" src=\"../Contents/img/admin/heart-empty.png\"  style=\"margin-top: 9px;\"></a><a title=\"\" href=\"#\"><img width=\"14\" alt=\"\" src=\"../Contents/img/admin/speech-bubble-left.png\"  style=\"margin-top: 9px;\"></a>" +
                                                                    "</div></div><div class=\"pic\"><img alt=\"\" src=\"" + feed.FeedImageUrl + "\"></div><div class=\"desc\"><p></p><span class=\"pull-left span3\">" +
                                                                    "<img width=\"12\" alt=\"\" src=\"../Contents/img/admin/heart-empty.png\"> " + feed.LikeCount + "</span><span class=\"pull-left span3\"><img width=\"12\" alt=\"\" src=\"../Contents/img/admin/speech-bubble-left.png\"> " + lstInsCmt.Count + "</span><div class=\"clearfix\"></div>";

                                    foreach (InstagramComment insCmt in lstInsCmt)
                                    {
                                        try
                                        {
                                            strInsImage += "<div class=\"userprof\"><div class=\"pull-left\"><a href=\"#\">" +
                                              "<img width=\"36\" alt=\"\" src=\"" + insCmt.FromProfilePic + "\"></a></div><div class=\"pull-left descr\"><p>" + insCmt.Comment + "</p>" +
                                               "<span class=\"usert\">" + DateExtension.ToDateTime(DateTime.Now, (long)Convert.ToDouble(insCmt.CommentDate)) + "</span></div></div>";

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

                                    }

                                    strInsImage += "</div></div></div>";
                                }
                                catch (Exception ex)
                                {
                                    logger.Error(ex.Message);
                                    Console.WriteLine(ex.Message);
                                }
                            }
                            strInsImage += "</div>";
                        }
                        else
                        {
                            if (instagramcount == 0)
                            {
                                strInsImage = "<div class=\"grid\"><div class=\"box whitebg feedwrap\">" +
                                             "<div class=\"topicon\"><div class=\"pull-left\"></div><div class=\"pull-right\">" +
                                 "<a href=\"#\" title=\"\"></a><a href=\"#\" title=\"\"></a></div></div><div class=\"pic\">" +
                                 "<img src=\"../Contents/img/no_image_found.png\" alt=\"\"></div><div class=\"desc\"><p></p></div></div></div>";
                            }
                        }


                        Response.Write(strInsImage);


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

                }
                else if (Request.QueryString["op"] == "instagramApi")
                {
                    try
                    {
                        InstagramManager insManager = new InstagramManager();
                        string profileid = Request.QueryString["profileid"];
                        InstagramAccountRepository insAccRepo = new InstagramAccountRepository();
                        InstagramAccount instagramAccount = insAccRepo.getInstagramAccountDetailsById(profileid, user.Id);
                        insManager.getIntagramImages(instagramAccount);
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                        Console.WriteLine(ex.Message);
                    }
                }



                else if (Request.QueryString["op"] == "UnfollowTumblrBlog")
                {
                    try
                    {
                        string blogname = Request.QueryString["blogname"].ToString();
                        string profileid = Request.QueryString["profileid"];
                        string accesstoken = Request.QueryString["accesstoken"];
                        string accesstokensecret = Request.QueryString["accesstokensecret"];
                        Guid id = Guid.Parse(Request.QueryString["id"]);
                        try
                        {
                            string msg = "success";
                            BlogsFollowers objunfollowblog = new BlogsFollowers();
                            objunfollowblog.Unfollowblog(accesstoken, accesstokensecret, blogname);
                            int result = objTumblrFeedRepository.DeleteTumblrDataByProfileid(profileid, blogname);
                            Response.Write(msg);

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

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

                }


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

                    try
                    {
                        string ProfileId = Request.QueryString["profileid"].ToString();
                        string body = Request.QueryString["msg"].ToString();
                        string title = Request.QueryString["title"].ToString();
                        TumblrAccount objTumblrAccount = tumblraccrepo.getTumblrAccountDetailsById(ProfileId);
                        PublishedPosts objPublishedPosts = new PublishedPosts();
                        objPublishedPosts.PostData(objTumblrAccount.tblrAccessToken, objTumblrAccount.tblrAccessTokenSecret, ProfileId, body, title, "text");

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

                }


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

                    try
                    {
                        string ProfileId = Request.QueryString["profileid"].ToString();
                        string source = Request.QueryString["source"].ToString();
                        string quote = Request.QueryString["quote"].ToString();
                        TumblrAccount objTumblrAccount = tumblraccrepo.getTumblrAccountDetailsById(ProfileId);
                        PublishedPosts objPublishedPosts = new PublishedPosts();
                        objPublishedPosts.PostData(objTumblrAccount.tblrAccessToken, objTumblrAccount.tblrAccessTokenSecret, ProfileId, source, quote, "quote");


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

                }

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

                    try
                    {
                        string ProfileId = Request.QueryString["profileid"].ToString();
                        string linkurl = Request.QueryString["linkurl"].ToString();
                        string title = Request.QueryString["title"].ToString();
                        string description = Request.QueryString["description"].ToString();
                        TumblrAccount objTumblrAccount = tumblraccrepo.getTumblrAccountDetailsById(ProfileId);
                        PublishedPosts objPublishedPosts = new PublishedPosts();
                        objPublishedPosts.PostdescriptionData(objTumblrAccount.tblrAccessToken, objTumblrAccount.tblrAccessTokenSecret, ProfileId, linkurl, title, description, "link");


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

                }





                else if (Request.QueryString["op"] == "tumblrImagePost")
                {
                    string caption = string.Empty;

                    try
                    {
                        string ProfileId = Request.QueryString["profileid"].ToString();
                        try
                        {
                            caption = Request.QueryString["caption"].ToString();
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                        var fi = Request.Files["file"];

                        string file = string.Empty;
                        if (fi != null)
                        {
                            var path = Server.MapPath("~/Contents/img/upload");
                            file = path + "/" + fi.FileName;
                            if (!Directory.Exists(path))
                            {
                                Directory.CreateDirectory(path);
                            }
                            fi.SaveAs(file);
                        }

                        string filepath = file;

                        TumblrAccount objTumblrAccount = tumblraccrepo.getTumblrAccountDetailsById(ProfileId);
                        PublishedPosts objPublishedPosts = new PublishedPosts();
                        objPublishedPosts.PostData(objTumblrAccount.tblrAccessToken, objTumblrAccount.tblrAccessTokenSecret, ProfileId, caption, filepath, "photo");

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

                }



                else if (Request.QueryString["op"] == "tumblrAudioPost")
                {
                    string caption = string.Empty;

                    try
                    {
                        string ProfileId = Request.QueryString["profileid"].ToString();

                        var fi = Request.Files["file"];

                        string file = string.Empty;
                        if (fi != null)
                        {
                            var path = Server.MapPath("~/Contents/img/upload");
                            file = path + "/" + fi.FileName;
                            //if (!Directory.Exists(path))
                            //{
                            //    Directory.CreateDirectory(path);
                            //}
                            //fi.SaveAs(file);
                        }

                        string filepath = file;

                        TumblrAccount objTumblrAccount = tumblraccrepo.getTumblrAccountDetailsById(ProfileId);
                        PublishedPosts objPublishedPosts = new PublishedPosts();
                        objPublishedPosts.PostAudioData(objTumblrAccount.tblrAccessToken, objTumblrAccount.tblrAccessTokenSecret, ProfileId, filepath, "audio");

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


                }



                else if (Request.QueryString["op"] == "tumblrVideoPost")
                {
                    string caption = string.Empty;

                    try
                    {
                        string ProfileId = Request.QueryString["profileid"].ToString();
                        string VideoUrl = Request.QueryString["VideoUrl"].ToString();
                        string VideoContent = Request.QueryString["VideoContent"].ToString();

                        var fi = Request.Files["file"];

                        string file = string.Empty;
                        if (fi != null)
                        {
                            var path = Server.MapPath("~/Contents/img/upload");
                            file = path + "/" + fi.FileName;
                            if (!Directory.Exists(path))
                            {
                                Directory.CreateDirectory(path);
                            }
                            fi.SaveAs(file);
                        }

                        string filepath = file;

                        TumblrAccount objTumblrAccount = tumblraccrepo.getTumblrAccountDetailsById(ProfileId);
                        PublishedPosts objPublishedPosts = new PublishedPosts();
                        objPublishedPosts.PostdescriptionData(objTumblrAccount.tblrAccessToken, objTumblrAccount.tblrAccessTokenSecret, ProfileId, filepath, VideoUrl, VideoContent, "video");

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


                }

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

                    try
                    {
                        string ProfileId = Request.QueryString["profileid"].ToString();
                        string body = Request.QueryString["body"].ToString();
                        string title = Request.QueryString["title"].ToString();
                        string tag = Request.QueryString["tag"].ToString();
                        TumblrAccount objTumblrAccount = tumblraccrepo.getTumblrAccountDetailsById(ProfileId);
                        PublishedPosts objPublishedPosts = new PublishedPosts();
                        objPublishedPosts.PostdescriptionData(objTumblrAccount.tblrAccessToken, objTumblrAccount.tblrAccessTokenSecret, ProfileId, body, title, tag, "chat");


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

                }













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

                    int likestatus = Convert.ToInt16(Request.QueryString["likes"]);
                    string profileid = Request.QueryString["profileid"];
                    string accesstoken = Request.QueryString["accesstoken"];
                    string accesstokensecret = Request.QueryString["accesstokensecret"];
                    Guid id = Guid.Parse(Request.QueryString["id"]);
                    int notes = Convert.ToInt16(Request.QueryString["notes"]);


                    try
                    {
                        int like = 0;
                        if (likestatus == 0)
                        {
                            like = 1;
                        }
                        int i = objTumblrFeedRepository.UpdateDashboardOfProfileLikes(profileid, id, like);

                        int s = objTumblrFeedRepository.UpdateDashboardOfProfileNotes(profileid, id, like, notes);

                        TumblrFeed obj = objTumblrFeedRepository.getFeedOfProfilebyIdProfileId(profileid, id);
                        BlogsLikes objBlogsLikes = new BlogsLikes();

                        objBlogsLikes.likeBlog(accesstoken, accesstokensecret, obj.blogId, obj.reblogkey, like);


                        //KeyValuePair<string, string> LoginDetails = new KeyValuePair<string, string>(accesstoken, accesstokensecret);
                        //var prms = new Dictionary<string, object>();
                        //prms.Add("id", obj.blogId);
                        //prms.Add("reblog_key", obj.reblogkey);
                        //var postUrl = "";

                        //if (like == 1)
                        //{
                        //    postUrl = "https://api.tumblr.com/v2/user/like/";
                        //}
                        //else
                        //{
                        //    postUrl = "https://api.tumblr.com/v2/user/unlike/";
                        //}
                        //string result = oAuthTumbler.OAuthData(postUrl, "POST", LoginDetails.Key, LoginDetails.Value, prms);

                        //string result1 = string.Empty;
                        //result1 = result;
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                        Console.WriteLine(ex.Message);
                    }
                }
            }
        }
예제 #8
0
        protected void btnRegister_Click(object sender, ImageClickEventArgs e)
        {
            try
            {
                User user = new User();
                UserRepository userrepo = new UserRepository();
                UserActivation objUserActivation = new UserActivation();
                Coupon objCoupon = new Coupon();
                CouponRepository objCouponRepository = new CouponRepository();
                Groups groups = new Groups();
                GroupRepository objGroupRepository = new GroupRepository();
                Team teams = new Team();
                TeamRepository objTeamRepository = new TeamRepository();
           

                SocioBoard.Helper.SessionFactory.configfilepath = Server.MapPath("~/hibernate.cfg.xml");
                try
                {


                    if (DropDownList1.SelectedValue == "Free" || DropDownList1.SelectedValue == "Standard" || DropDownList1.SelectedValue == "Deluxe" || DropDownList1.SelectedValue == "Premium" || DropDownList1.SelectedValue == "SocioBasic" || DropDownList1.SelectedValue == "SocioStandard" || DropDownList1.SelectedValue == "SocioPremium" || DropDownList1.SelectedValue == "SocioDeluxe")

                   
                    {



                        if (TextBox1.Text.Trim() != "")
                        {
                            string resp = SBUtils.GetCouponStatus(TextBox1.Text).ToString();
                            if (resp != "valid")
                            {
                               
                                ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('" + resp + "');", true);
                                return;
                            }
                        }




                        if (txtPassword.Text == txtConfirmPassword.Text)
                        {



                            user.PaymentStatus = "unpaid";
                            user.AccountType = DropDownList1.SelectedValue.ToString();
                            if (string.IsNullOrEmpty(user.AccountType))
                            {
                                user.AccountType = AccountType.Free.ToString();
                            }


                            user.CreateDate = DateTime.Now;
                            user.ExpiryDate = DateTime.Now.AddDays(30);
                            user.Id = Guid.NewGuid();
                            user.UserName = txtFirstName.Text + " " + txtLastName.Text;
                            user.Password = this.MD5Hash(txtPassword.Text);
                            user.EmailId = txtEmail.Text;
                            user.UserStatus = 1;
                            user.ActivationStatus = "0";
                                                     
                            if (TextBox1.Text.Trim() != "")
                            {
                                user.CouponCode = TextBox1.Text.Trim().ToString();
                            }


                            if (!userrepo.IsUserExist(user.EmailId))
                            {
                                logger.Error("Before User reg");
                                UserRepository.Add(user);

                               

                                try
                                {
                                    groups.Id = Guid.NewGuid();
                                    groups.GroupName = ConfigurationManager.AppSettings["DefaultGroupName"];
                                    groups.UserId = user.Id;
                                    groups.EntryDate = DateTime.Now;
                                    
                                    objGroupRepository.AddGroup(groups);


                                    teams.Id = Guid.NewGuid();
                                    teams.GroupId = groups.Id;
                                    teams.UserId = user.Id;
                                    teams.EmailId = user.EmailId;
                                  
                                    objTeamRepository.addNewTeam(teams);



                                    BusinessSettingRepository busnrepo = new BusinessSettingRepository();
                               
                                    SocioBoard.Domain.BusinessSetting objbsnssetting = new SocioBoard.Domain.BusinessSetting();

                                    if (!busnrepo.checkBusinessExists(user.Id, groups.GroupName))
                                    {
                                        objbsnssetting.Id = Guid.NewGuid();
                                        objbsnssetting.BusinessName = groups.GroupName;
                                        objbsnssetting.GroupId = groups.Id;
                                        objbsnssetting.AssigningTasks = false;
                                        objbsnssetting.AssigningTasks = false;
                                        objbsnssetting.TaskNotification = false;
                                        objbsnssetting.TaskNotification = false;
                                        objbsnssetting.FbPhotoUpload = 0;
                                        objbsnssetting.UserId = user.Id;
                                        objbsnssetting.EntryDate = DateTime.Now;
                                        busnrepo.AddBusinessSetting(objbsnssetting);

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


                                try
                                {
                                    logger.Error("1 Request.QueryString[refid]");
                                    if (Request.QueryString["refid"] != null)
                                    {
                                        logger.Error("3 Request.QueryString[refid]");
                                        User UserValid = null;
                                        if (IsUserValid(Request.QueryString["refid"].ToString(), ref UserValid))
                                        {
                                           
                                            logger.Error("Inside IsUserValid");
                                            user.RefereeStatus = "1";
                                            UpdateUserReference(UserValid);
                                            AddUserRefreeRelation(user, UserValid);
                                          
                                            logger.Error("IsUserValid");
                                        }
                                        else
                                        {
                                            user.RefereeStatus = "0";
                                        }
                                    }
                                    logger.Error("2 Request.QueryString[refid]");
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.Message);
                                    logger.Error("btnRegister_Click" + ex.Message);
                                    logger.Error("btnRegister_Click" + ex.StackTrace);
                                }
                              


                                if (TextBox1.Text.Trim() != "")
                                {
                                    objCoupon.CouponCode = TextBox1.Text.Trim();
                                    List<Coupon> lstCoupon = objCouponRepository.GetCouponByCouponCode(objCoupon);
                                    objCoupon.Id = lstCoupon[0].Id;
                                    objCoupon.EntryCouponDate = lstCoupon[0].EntryCouponDate;
                                    objCoupon.ExpCouponDate = lstCoupon[0].ExpCouponDate;
                                    objCoupon.Status = "1";
                                    objCouponRepository.SetCouponById(objCoupon);
                                }

                                Session["LoggedUser"] = user;
                                objUserActivation.Id = Guid.NewGuid();
                                objUserActivation.UserId = user.Id;
                                objUserActivation.ActivationStatus = "0";
                                UserActivationRepository.Add(objUserActivation);

                                //add package start

                                UserPackageRelation objUserPackageRelation = new UserPackageRelation();
                                UserPackageRelationRepository objUserPackageRelationRepository = new UserPackageRelationRepository();
                                PackageRepository objPackageRepository = new PackageRepository();

                                try
                                {
                                    Package objPackage = objPackageRepository.getPackageDetails(user.AccountType);
                                    objUserPackageRelation.Id = Guid.NewGuid();
                                    objUserPackageRelation.PackageId = objPackage.Id;
                                    objUserPackageRelation.UserId = user.Id;
                                    objUserPackageRelation.ModifiedDate = DateTime.Now;
                                    objUserPackageRelation.PackageStatus = true;

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

                                //end package

                                SocioBoard.Helper.MailSender.SendEMail(txtFirstName.Text, txtPassword.Text, txtEmail.Text, user.AccountType.ToString(), user.Id.ToString());
                                TeamRepository teamRepo = new TeamRepository();
                                try
                                {
                                    Team team = teamRepo.getTeamByEmailId(txtEmail.Text);
                                    if (team != null)
                                    {
                                        Guid teamid = Guid.Parse(Request.QueryString["tid"]);
                                        teamRepo.updateTeamStatus(teamid);
                                        TeamMemberProfileRepository teamMemRepo = new TeamMemberProfileRepository();
                                        List<TeamMemberProfile> lstteammember = teamMemRepo.getAllTeamMemberProfilesOfTeam(team.Id);
                                        foreach (TeamMemberProfile item in lstteammember)
                                        {
                                            try
                                            {
                                                SocialProfilesRepository socialRepo = new SocialProfilesRepository();
                                                SocialProfile socioprofile = new SocialProfile();
                                                socioprofile.Id = Guid.NewGuid();
                                                socioprofile.ProfileDate = DateTime.Now;
                                                socioprofile.ProfileId = item.ProfileId;
                                                socioprofile.ProfileType = item.ProfileType;
                                                socioprofile.UserId = user.Id;
                                                socialRepo.addNewProfileForUser(socioprofile);

                                                if (item.ProfileType == "facebook")
                                                {
                                                    try
                                                    {
                                                        FacebookAccount fbAccount = new FacebookAccount();
                                                        FacebookAccountRepository fbAccountRepo = new FacebookAccountRepository();
                                                        FacebookAccount userAccount = fbAccountRepo.getUserDetails(item.ProfileId);
                                                        fbAccount.AccessToken = userAccount.AccessToken;
                                                        fbAccount.EmailId = userAccount.EmailId;
                                                        fbAccount.FbUserId = item.ProfileId;
                                                        fbAccount.FbUserName = userAccount.FbUserName;
                                                        fbAccount.Friends = userAccount.Friends;
                                                        fbAccount.Id = Guid.NewGuid();
                                                        fbAccount.IsActive = 1;
                                                        fbAccount.ProfileUrl = userAccount.ProfileUrl;
                                                        fbAccount.Type = userAccount.Type;
                                                        fbAccount.UserId = user.Id;
                                                        fbAccountRepo.addFacebookUser(fbAccount);
                                                    }
                                                    catch (Exception ex)
                                                    {
                                                        Console.WriteLine(ex.Message);
                                                        logger.Error(ex.Message);
                                                    }
                                                }
                                                else if (item.ProfileType == "twitter")
                                                {
                                                    try
                                                    {
                                                        TwitterAccount twtAccount = new TwitterAccount();
                                                        TwitterAccountRepository twtAccRepo = new TwitterAccountRepository();
                                                        TwitterAccount twtAcc = twtAccRepo.getUserInfo(item.ProfileId);
                                                        twtAccount.FollowersCount = twtAcc.FollowersCount;
                                                        twtAccount.FollowingCount = twtAcc.FollowingCount;
                                                        twtAccount.Id = Guid.NewGuid();
                                                        twtAccount.IsActive = true;
                                                        twtAccount.OAuthSecret = twtAcc.OAuthSecret;
                                                        twtAccount.OAuthToken = twtAcc.OAuthToken;
                                                        twtAccount.ProfileImageUrl = twtAcc.ProfileImageUrl;
                                                        twtAccount.ProfileUrl = twtAcc.ProfileUrl;
                                                        twtAccount.TwitterName = twtAcc.TwitterName;
                                                        twtAccount.TwitterScreenName = twtAcc.TwitterScreenName;
                                                        twtAccount.TwitterUserId = twtAcc.TwitterUserId;
                                                        twtAccount.UserId = user.Id;
                                                        twtAccRepo.addTwitterkUser(twtAccount);
                                                    }
                                                    catch (Exception ex)
                                                    {
                                                        Console.WriteLine(ex.StackTrace);
                                                        logger.Error(ex.Message);
                                                    }
                                                }
                                                else if (item.ProfileType == "instagram")
                                                {
                                                    try
                                                    {

                                                        InstagramAccount insAccount = new InstagramAccount();
                                                        InstagramAccountRepository insAccRepo = new InstagramAccountRepository();
                                                        InstagramAccount InsAcc = insAccRepo.getInstagramAccountById(item.ProfileId);
                                                        insAccount.AccessToken = InsAcc.AccessToken;
                                                        insAccount.FollowedBy = InsAcc.FollowedBy;
                                                        insAccount.Followers = InsAcc.Followers;
                                                        insAccount.Id = Guid.NewGuid();
                                                        insAccount.InstagramId = item.ProfileId;
                                                        insAccount.InsUserName = InsAcc.InsUserName;
                                                        insAccount.IsActive = true;
                                                        insAccount.ProfileUrl = InsAcc.ProfileUrl;
                                                        insAccount.TotalImages = InsAcc.TotalImages;
                                                        insAccount.UserId = user.Id;
                                                        insAccRepo.addInstagramUser(insAccount);
                                                    }
                                                    catch (Exception ex)
                                                    {
                                                        Console.WriteLine(ex.StackTrace);
                                                        logger.Error(ex.Message);
                                                    }
                                                }
                                                else if (item.ProfileType == "linkedin")
                                                {
                                                    try
                                                    {
                                                        LinkedInAccount linkAccount = new LinkedInAccount();
                                                        LinkedInAccountRepository linkedAccountRepo = new LinkedInAccountRepository();
                                                        LinkedInAccount linkAcc = linkedAccountRepo.getLinkedinAccountDetailsById(item.ProfileId);
                                                        linkAccount.Id = Guid.NewGuid();
                                                        linkAccount.IsActive = true;
                                                        linkAccount.LinkedinUserId = item.ProfileId;
                                                        linkAccount.LinkedinUserName = linkAcc.LinkedinUserName;
                                                        linkAccount.OAuthSecret = linkAcc.OAuthSecret;
                                                        linkAccount.OAuthToken = linkAcc.OAuthToken;
                                                        linkAccount.OAuthVerifier = linkAcc.OAuthVerifier;
                                                        linkAccount.ProfileImageUrl = linkAcc.ProfileImageUrl;
                                                        linkAccount.ProfileUrl = linkAcc.ProfileUrl;
                                                        linkAccount.UserId = user.Id;
                                                        linkedAccountRepo.addLinkedinUser(linkAccount);
                                                    }
                                                    catch (Exception ex)
                                                    {
                                                        Console.WriteLine(ex.StackTrace);
                                                        logger.Error(ex.Message);
                                                    }
                                                }

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

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

                                #region SetInvitationStatusAfterSuccessfulRegistration
                                try
                                {
                                    if (Request.QueryString["refid"] != null)
                                    {
                                        string refid = Request.QueryString["refid"];

                                        int res = SetInvitationStatusAfterSuccessfulRegistration(refid, txtEmail.Text);
                                    }
                                }
                                catch (Exception ex)
                                {
                                    logger.Error(ex.Message);
                                } 
                                #endregion


                                try
                                {
                                    lblerror.Text = "Registered Successfully !" + "<a href=\"Default.aspx\">Login</a>";
                                    Response.Redirect("~/Home.aspx");
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.StackTrace);
                                }
                            }
                            else
                            {
                                lblerror.Text = "Email Already Exists " + "<a id=\"loginlink\"  href=\"#\">login</a>";
                            }
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Please select Account Type!');", true);
                    }
                }

                catch (Exception ex)
                {
                    logger.Error(ex.StackTrace);
                    lblerror.Text = "Success!";
                    Console.WriteLine(ex.StackTrace);
                    //Response.Redirect("Home.aspx");
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.StackTrace);

                Console.WriteLine(ex.StackTrace);
                //Response.Redirect("Home.aspx");
            }
        }