public void getProfileCount()
        {
            SocioBoard.Domain.User   user       = (User)Session["LoggedUser"];
            SocialProfilesRepository objProfile = new SocialProfilesRepository();
            List <SocialProfile>     lstProfile = objProfile.getAllSocialProfilesOfUser(user.Id);

            strProfileCOunt = lstProfile.Count().ToString();
        }
Example #2
0
        public DataSet bindSentMessagesToDataTable(User user, string network)
        {
            SocialProfilesRepository socioprofrepo = new SocialProfilesRepository();
            List <SocialProfile>     alstprofiles  = socioprofrepo.getAllSocialProfilesOfUser(user.Id);
            Messages mstable = new Messages();
            DataSet  ds      = DataTableGenerator.CreateDataSetForTable(mstable);

            foreach (SocialProfile item in alstprofiles)
            {
                if (item.ProfileType == "facebook")
                {
                    FacebookMessageRepository fbmsgrepo  = new FacebookMessageRepository();
                    List <FacebookMessage>    alstfbmsgs = fbmsgrepo.getAllSentMessages(item.ProfileId);

                    if (alstfbmsgs != null)
                    {
                        if (alstfbmsgs.Count != 0)
                        {
                            foreach (FacebookMessage facebookmsg in alstfbmsgs)
                            {
                                ds.Tables[0].Rows.Add(facebookmsg.ProfileId, "facebook", facebookmsg.FromId, facebookmsg.FromName, facebookmsg.FromProfileUrl, facebookmsg.MessageDate, facebookmsg.Message, facebookmsg.FbComment, facebookmsg.FbLike, facebookmsg.MessageId, facebookmsg.Type);
                            }
                        }
                    }
                }
                else if (item.ProfileType == "twitter")
                {
                    TwitterDirectMessageRepository twtmsgrepo    = new TwitterDirectMessageRepository();
                    List <TwitterDirectMessages>   lstmsgtwtuser = twtmsgrepo.getAllDirectMessagesById(item.ProfileId);
                    foreach (TwitterDirectMessages lst in lstmsgtwtuser)
                    {
                        ds.Tables[0].Rows.Add(lst.SenderId, "twitter", lst.SenderId, lst.SenderScreenName, lst.SenderProfileUrl, lst.CreatedDate, lst.Message, "", "", lst.MessageId, lst.Type);
                    }
                }
                else if (item.ProfileType == "googleplus")
                {
                }
            }
            return(ds);
        }
Example #3
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"));
     }
 }
Example #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            HttpContext.Current.Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1));
            HttpContext.Current.Response.Cache.SetValidUntilExpires(false);
            HttpContext.Current.Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
            HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
            HttpContext.Current.Response.Cache.SetNoStore();
            TeamRepository  objTeamRepository  = new TeamRepository();
            GroupRepository objGroupRepository = new GroupRepository();

            try
            {
                User user = (User)Session["LoggedUser"];
                // SocioBoard.Domain.Team team = (SocioBoard.Domain.Team)Session["GroupName"];

                #region check user Activation

                UserRepository objUserRepository = new UserRepository();

                try
                {
                    if (user != null)
                    {
                        if (user.ActivationStatus == "0" || user.ActivationStatus == null)
                        {
                            actdiv.InnerHtml = "<marquee behavior=\"scroll\" direction=\"left\"><span >Your account is not yet activated.Check your E-mail to activate your account.</span><a id=\"resendmail\" uid=\"" + user.Id + "\" href=\"#\">Resend Mail</a></marquee>";
                            if (Request.QueryString["stat"] == "activate")
                            {
                                if (Request.QueryString["id"] != null)
                                {
                                    //objUserActivation = objUserActivationRepository.GetUserActivationStatusbyid(Request.QueryString["id"].ToString());
                                    if (user.Id.ToString() == Request.QueryString["id"].ToString())
                                    {
                                        user.Id = user.Id; //Guid.Parse(Request.QueryString["id"]);
                                        //objUserActivation.UserId = Guid.Parse(Request.QueryString["id"]);// objUserActivation.UserId;
                                        user.ActivationStatus = "1";
                                        //UserActivationRepository.Update(objUserActivation);

                                        int res = objUserRepository.UpdateActivationStatusByUserId(user);

                                        actdiv.Attributes.CssStyle.Add("display", "none");
                                        Console.WriteLine("before");
                                        #region to check/update user Reference Relation
                                        IsUserReferenceActivated(Request.QueryString["id"].ToString());
                                        Console.WriteLine("after");
                                        #endregion
                                    }
                                    else
                                    {
                                        Session["ActivationError"] = "Wrong Activation Link please contact Admin!";
                                        //ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Wrong Activation Link please contact Admin!');", true);
                                        //Response.Redirect("ActivationLink.aspx");
                                    }
                                }
                                else
                                {
                                    Session["ActivationError"] = "Wrong Activation Link please contact Admin!";
                                    //ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Wrong Activation Link please contact Admin!');", true);
                                    //Response.Redirect("ActivationLink.aspx");
                                }
                            }
                            else
                            {
                                // Response.Redirect("ActivationLink.aspx");
                            }
                        }

                        if (user.ActivationStatus == "1")
                        {
                            actdiv.Attributes.CssStyle.Add("display", "none");
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    logger.Error(ex.StackTrace);
                }
                #endregion

                if (!IsPostBack)
                {
                    Page.ClientScript.RegisterStartupScript(Page.GetType(), "my", " logout();", true);

                    if (user == null)
                    {
                        Response.Redirect("/Default.aspx");
                    }
                    else
                    {
                        #region for You can use only 30 days as Unpaid User

                        if (user.PaymentStatus.ToLower() == "unpaid")
                        {
                            if (!SBUtils.IsUserWorkingDaysValid(user.ExpiryDate))
                            {
                                // cmposecontainer.Attributes.Add("display", "none");
                                cmposecontainer.Attributes.CssStyle.Add("display", "none");
                                //topbtn.Attributes.CssStyle.Add("display", "none");
                                cmposecontainer.Attributes.CssStyle.Add("display", "none");
                                searchcontainer.Attributes.CssStyle.Add("display", "none");
                            }
                        }
                        #endregion



                        try
                        {
                            if (Session["IncomingTasks"] != null)
                            {
                                //incom_tasks.InnerHtml = Convert.ToString((int)Session["IncomingTasks"]);
                                //incomTasks.InnerHtml = Convert.ToString((int)Session["IncomingTasks"]);
                            }
                            else
                            {
                                //TaskRepository taskRepo = new TaskRepository();
                                //ArrayList alst = taskRepo.getAllIncompleteTasksOfUser(user.Id,team.GroupId);
                                //Session["IncomingTasks"] = alst.Count;
                                //incom_tasks.InnerHtml = Convert.ToString(alst.Count);
                                //incomTasks.InnerHtml = Convert.ToString(alst.Count);
                            }
                        }
                        catch (Exception es)
                        {
                            logger.Error(es.Message);
                            Console.WriteLine(es.Message);
                        }
                        try
                        {
                            FacebookFeedRepository objFacebookFeedRepository = new FacebookFeedRepository();
                            int alstfeedfb = objFacebookFeedRepository.countUnreadMessages(user.Id);
                            TwitterMessageRepository objTwitterMessageRepository = new TwitterMessageRepository();
                            int alstMsgtwt = objTwitterMessageRepository.getCountUnreadMessages(user.Id);
                            incom_messages.InnerHtml = (alstfeedfb + alstMsgtwt).ToString();


                            if (Session["CountMessages"] != null)
                            {
                                //incom_messages.InnerHtml = Convert.ToString((int)Session["CountMessages"]);
                                //incomMessages.InnerHtml = Convert.ToString((int)Session["CountMessages"]);
                            }
                            else
                            {
                                //incom_messages.InnerHtml = "0";
                                //incomMessages.InnerHtml = "0";
                            }
                        }
                        catch (Exception sx)
                        {
                            logger.Error(sx.Message);
                            Console.WriteLine(sx.Message);
                        }


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

                        try
                        {
                            ArrayList totalAccuount = objTeamRepository.getAllAccountUser(user.EmailId, user.Id);
                            if (totalAccuount.Count != 0)
                            {
                                string drodownselectedvalue = string.Empty;
                                try
                                {
                                    foreach (Guid item in totalAccuount)
                                    {
                                        Guid GroupIde = (Guid)item;

                                        List <Groups> GetData = objGroupRepository.getAllGroupsDetail(GroupIde);
                                        if (GetData.Count != 0)
                                        {
                                            string val = string.Empty;
                                            foreach (var items in GetData)
                                            {
                                                try
                                                {
                                                    if (items.GroupName == "Socioboard")
                                                    {
                                                        drodownselectedvalue = items.Id.ToString();
                                                    }
                                                    groupsselection.Items.Add(new ListItem((string)items.GroupName, items.Id.ToString()));
                                                }
                                                catch { }
                                            }
                                        }
                                    }

                                    if (Session["groupcheck"] == null)
                                    {
                                        int i = 0;
                                        groupsselection.SelectedIndex = groupsselection.Items.IndexOf(groupsselection.Items.FindByText("Socioboard"));
                                        //groupsselection.SelectedIndex = groupsselection.Items.IndexOf(groupsselection.Items.FindByValue("Socioboard"));
                                        //ListItem li =  groupsselection.Items.FindByText(drodownselectedvalue);
                                        //li.Selected = true;
                                        Session["groupcheck"] = groupsselection.Items.FindByText("Socioboard").Value;
                                    }
                                    else
                                    {
                                        groupsselection.SelectedIndex = groupsselection.Items.IndexOf(groupsselection.Items.FindByValue((string)Session["groupcheck"]));
                                        //groupsselection.se.SelectedIndex = Session["groupcheck"];
                                    }

                                    //if (Session["groupcheck"] == null)
                                    //{

                                    //    groupsselection.SelectedValue = (drodownselectedvalue);
                                    //    Session["groupcheck"] = groupsselection.SelectedValue;
                                    //}
                                    //else
                                    //{
                                    //    groupsselection.SelectedIndex = Session["groupcheck"];
                                    //}
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.Message);
                                    logger.Error("Error : " + ex.Message);
                                    logger.Error("Error : " + ex.StackTrace);
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message);
                            logger.Error("Error : " + ex.Message);
                            logger.Error("Error : " + ex.StackTrace);
                        }

//=====================================================================================================================================
                        usernm.InnerHtml = "Hello, " + user.UserName + " ";
                        if (!string.IsNullOrEmpty(user.ProfileUrl))
                        {
                            // Datetime = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.UtcNow, user.TimeZone).ToLongDateString() + " " + TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.UtcNow, user.TimeZone).ToShortTimeString() + " (" + user.TimeZone + ")";
                            //userimg.InnerHtml = "<a href=\"../Settings/PersonalSettings.aspx\"><img id=\"loggeduserimg\" src=\"" + user.ProfileUrl + "\" alt=\"" + user.UserName + "\" /></a></a>";
                            userimg.InnerHtml = "<img id=\"loggeduserimg\" src=\"" + user.ProfileUrl + "\" alt=\"" + user.UserName + "\" />";
                            userimg.InnerHtml = "<img id=\"loggeduserimg\" src=\"" + user.ProfileUrl + "\" alt=\"" + user.UserName + "\" />";
                            //userinf.InnerHtml = Datetime;
                            //{
                            //userimg.InnerHtml = "<a href=\"../Settings/PersonalSettings.aspx\"><img id=\"loggeduserimg\" src=\"" + user.ProfileUrl + "\" alt=\"" + user.UserName + "\" height=\"100\" width=\"100\"/></a></a>";
                            userimg.InnerHtml = "<img id=\"loggeduserimg\" src=\"" + user.ProfileUrl + "\" alt=\"" + user.UserName + "\" height=\"100\" width=\"100\"/>";
                            userimg.InnerHtml = "<img id=\"loggeduserimg\" src=\"" + user.ProfileUrl + "\" alt=\"" + user.UserName + "\" height=\"100\" width=\"100\"/>";
                            if (user.TimeZone != null)
                            {
                                Datetime = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.UtcNow, user.TimeZone).ToLongDateString() + " " + TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.UtcNow, user.TimeZone).ToShortTimeString() + " (" + user.TimeZone + ")";
                                //userinf.InnerHtml = Datetime;
                            }
                            if (user.TimeZone == null)
                            {
                                Datetime = DateTime.Now.ToString();
                                //userinf.InnerHtml = Datetime;
                            }
                        }
                        else
                        {
                            //Datetime = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.UtcNow, user.TimeZone).ToLongDateString() + " " + TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.UtcNow, user.TimeZone).ToShortTimeString() + " (" + user.TimeZone + ")";
                            //userimg.InnerHtml = "<a href=\"../Settings/PersonalSettings.aspx\"><img id=\"loggeduserimg\" src=\"../Contents/img/blank_img.png\" alt=\"" + user.UserName + "\"/></a>";
                            userimg.InnerHtml = "<img id=\"loggeduserimg\" src=\"../Contents/img/blank_img.png\" alt=\"" + user.UserName + "\"/>";
                            userimg.InnerHtml = "<img id=\"loggeduserimg\" src=\"../Contents/img/blank_img.png\" alt=\"" + user.UserName + "\"/>";

                            //userinf.InnerHtml = Datetime;
                            if (user.TimeZone != null)
                            {
                                Datetime = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.UtcNow, user.TimeZone).ToLongDateString() + " " + TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.UtcNow, user.TimeZone).ToShortTimeString() + " (" + user.TimeZone + ")";
                                //userinf.InnerHtml = Datetime;
                            }
                            if (user.TimeZone == null)
                            {
                                Datetime = DateTime.Now.ToString();
                                //userinf.InnerHtml = Datetime;
                            }
                        }

                        try
                        {
                            GroupRepository grouprepo = new GroupRepository();
                            List <Groups>   lstgroups = grouprepo.getAllGroupsCompleteDetails(user.Id);
                            string          totgroups = string.Empty;
                            if (lstgroups.Count != 0)
                            {
                                foreach (Groups item in lstgroups)
                                {
                                    totgroups += "<li><a href=\"../Settings/InviteMember.aspx?q=" + item.Id + "\" id=\"group_" + item.Id + "\"><img src=\"../Contents/img/groups_.png\"  alt=\"\"  style=\" margin-right:5px;\"/>" + item.GroupName + "</a></li>";
                                }
                                inviteRedirect.InnerHtml = totgroups;
                            }
                            if (user.AccountType == AccountType.Deluxe.ToString().ToLower())
                            {
                                tot_acc = 10;
                            }
                            else if (user.AccountType == AccountType.Standard.ToString().ToLower())
                            {
                                tot_acc = 20;
                            }
                            else if (user.AccountType == AccountType.Premium.ToString().ToLower())
                            {
                                tot_acc = 50;
                            }
                            profileCount = objSocioRepo.getAllSocialProfilesOfUser(user.Id).Count;
                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex.Message);
                            Console.WriteLine(ex.Message);
                        }
                    }
                }

                //Team lstDetails = objTeamRepository.getAllGroupsDetails(user.EmailId.ToString(), Guid.Parse(groupsselection.SelectedItem.Value));
                //Session["GroupName"] = lstDetails;
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
                Console.WriteLine(ex.Message);
            }
        }
Example #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                UserRefRelationRepository objUserRefRelationRepository = new UserRefRelationRepository();
                UserRepository            userrepo                         = new UserRepository();
                Registration                regObject                      = new Registration();
                TeamRepository              objTeamRepo                    = new TeamRepository();
                NewsRepository              objNewsRepo                    = new NewsRepository();
                AdsRepository               objAdsRepo                     = new AdsRepository();
                UserActivation              objUserActivation              = new UserActivation();
                UserActivationRepository    objUserActivationRepository    = new UserActivationRepository();
                SocialProfilesRepository    objSocioRepo                   = new SocialProfilesRepository();
                GroupRepository             objGroupRepository             = new GroupRepository();
                TeamMemberProfileRepository objTeamMemberProfileRepository = new TeamMemberProfileRepository();
                Team team = new Team();


                SocioBoard.Domain.User user = (User)Session["LoggedUser"];

                try
                {
                    if (Session["GroupName"] == null)
                    {
                        Groups objGroupDetails = objGroupRepository.getGroupDetail(user.Id);
                        team = objTeamRepo.getAllDetails(objGroupDetails.Id, user.EmailId);
                        Session["GroupName"] = team;
                    }

                    else
                    {
                        team = (SocioBoard.Domain.Team)Session["GroupName"];
                    }
                }
                catch (Exception ex)
                {
                    logger.Error("Error: " + ex.Message);
                }
                Session["facebooktotalprofiles"] = null;

                if (user.Password == null)
                {
                    Response.Redirect("/Pricing.aspx");
                }

                #region Days remaining
                if (Session["days_remaining"] == null)
                {
                    if (user.PaymentStatus == "unpaid" && user.AccountType != "Free")
                    {
                        int daysremaining = (user.ExpiryDate.Date - DateTime.Now.Date).Days;
                        if (daysremaining < 0)
                        {
                            daysremaining = -1;
                        }
                        Session["days_remaining"] = daysremaining;
                        //ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('You are using '" + user.AccountType + "' account only '" + daysremaining + "' days is remaining !');", true);
                        if (daysremaining <= -1)
                        {
                        }
                        else if (daysremaining == 0)
                        {
                            ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Your trial " + user.AccountType + " account will expire end of the day, please upgrade to paid plan.');", true);
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Your trial " + user.AccountType + " account will expire in " + daysremaining + " days, please upgrade to paid plan.');", true);
                        }
                    }
                }

                #endregion

                #region for You can use only 30 days as Unpaid User

                if (user.PaymentStatus.ToLower() == "unpaid" && user.AccountType != "Free")
                {
                    if (!SBUtils.IsUserWorkingDaysValid(user.ExpiryDate))
                    {
                        // ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('You can use only 30 days as Unpaid User !');", true);

                        Session["GreaterThan30Days"] = "GreaterThan30Days";

                        Response.Redirect("/Settings/Billing.aspx");
                    }
                }

                Session["GreaterThan30Days"] = null;
                #endregion

                if (!IsPostBack)
                {
                    try
                    {
                        if (user == null)
                        {
                            Response.Redirect("Default.aspx");
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                        logger.Error(ex.StackTrace);
                    }


                    try
                    {
                        objUserActivation = objUserActivationRepository.GetUserActivationStatus(user.Id.ToString());
                    }
                    catch (Exception ex)
                    {
                        Session["objUserActivationException"] = "objUserActivationException";

                        Console.WriteLine(ex.Message);
                        logger.Error(ex.StackTrace);
                    }


                    #region Count Used Accounts
                    try
                    {
                        if (user.AccountType.ToString().ToLower() == AccountType.Deluxe.ToString().ToLower())
                        {
                            tot_acc = 50;
                        }
                        else if (user.AccountType.ToString().ToLower() == AccountType.Standard.ToString().ToLower())
                        {
                            tot_acc = 10;
                        }
                        else if (user.AccountType.ToString().ToLower() == AccountType.Premium.ToString().ToLower())
                        {
                            tot_acc = 20;
                        }
                        else if (user.AccountType.ToString().ToLower() == AccountType.Free.ToString().ToLower())
                        {
                            tot_acc = 5;
                        }

                        else if (user.AccountType.ToString().ToLower() == AccountType.SocioBasic.ToString().ToLower())
                        {
                            tot_acc = 100;
                        }
                        else if (user.AccountType.ToString().ToLower() == AccountType.SocioStandard.ToString().ToLower())
                        {
                            tot_acc = 200;
                        }
                        else if (user.AccountType.ToString().ToLower() == AccountType.SocioPremium.ToString().ToLower())
                        {
                            tot_acc = 500;
                        }
                        else if (user.AccountType.ToString().ToLower() == AccountType.SocioDeluxe.ToString().ToLower())
                        {
                            tot_acc = 1000;
                        }


                        profileCount            = objSocioRepo.getAllSocialProfilesOfUser(user.Id).Count;
                        Session["ProfileCount"] = profileCount;
                        Session["TotalAccount"] = tot_acc;

                        try
                        {
                            Groups lstDetail = objGroupRepository.getGroupName(team.GroupId);
                            if (lstDetail.GroupName == "Socioboard")
                            {
                                usedAccount.InnerHtml = " using " + profileCount + " of " + tot_acc;
                            }
                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex.StackTrace);
                        }
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.StackTrace);
                    }
                    #endregion



                    try
                    {
                        Groups lstDetails = objGroupRepository.getGroupName(team.GroupId);
                        if (lstDetails.GroupName != "Socioboard")
                        {
                            expander.Attributes.CssStyle.Add("display", "none");
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }


                    //this is used to check whether facebok account Already Exist
                    if (Session["alreadyexist"] != null)
                    {
                        ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('This Profile is Already Added please add aother Account!');", true);
                        Session["alreadyexist"] = null;
                    }
                    if (Session["alreadypageexist"] != null)
                    {
                        ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('This Page is Already Added please add aother Page!');", true);
                        Session["alreadypageexist"] = null;
                    }



                    if (!string.IsNullOrEmpty(Request.QueryString["type"]))
                    {
                        try
                        {
                            userrepo.UpdateAccountType(user.Id, Request.QueryString["type"]);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                            logger.Error(ex.StackTrace);
                        }
                    }

                    //acrossProfile.InnerHtml = "Across " + user.UserName + "'s Twitter and Facebook accounts";
                    teamMem.InnerHtml = "managing " + user.UserName;
                    try
                    {
                        News nws = objNewsRepo.getNewsForHome();
                        //divNews.InnerHtml = nws.NewsDetail;
                    }
                    catch (Exception Err)
                    {
                        Console.Write(Err.StackTrace);
                        logger.Error(Err.StackTrace);
                    }
                    try
                    {
                        ArrayList lstads = objAdsRepo.getAdsForHome();
                        if (lstads.Count < 1)
                        {
                            if (user.PaymentStatus.ToUpper() == "PAID")
                            {
                                bindads.InnerHtml = "<img src=\"../Contents/img/admin/ads.png\"  alt=\"\" >";
                            }
                            else
                            {
                                #region ADS Script
                                bindads.InnerHtml = "<script async src=\"//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js\"></script>" +
                                                    "<!-- socioboard -->" +
                                                    "<ins class=\"adsbygoogle\"" +
                                                    "style=\"display:inline-block;width:250px;height:250px\"" +
                                                    "data-ad-client=\"ca-pub-7073257741073458\"" +
                                                    "data-ad-slot=\"9533254693\"></ins>" +
                                                    "<script>" +
                                                    "(adsbygoogle = window.adsbygoogle || []).push({});" +
                                                    "</script>";
                                #endregion
                            }
                        }


                        foreach (var item in lstads)
                        {
                            Array temp = (Array)item;
                            //imgAds.ImageUrl = temp.GetValue(2).ToString();
                            if (user.PaymentStatus.ToUpper() == "PAID")
                            {
                                bindads.InnerHtml = "<img src=\"" + temp.GetValue(2).ToString() + "\"  alt=\"\" style=\"width:246px;height:331px\">";
                            }
                            else
                            {
                                #region ADS Script
                                bindads.InnerHtml = "<script async src=\"//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js\"></script>" +
                                                    "<!-- socioboard -->" +
                                                    "<ins class=\"adsbygoogle\"" +
                                                    "style=\"display:inline-block;width:250px;height:250px\"" +
                                                    "data-ad-client=\"ca-pub-7073257741073458\"" +
                                                    "data-ad-slot=\"9533254693\"></ins>" +
                                                    "<script>" +
                                                    "(adsbygoogle = window.adsbygoogle || []).push({});" +
                                                    "</script>";
                                #endregion
                            }
                            break;
                            // ads.ImageUrl;
                        }
                    }
                    catch (Exception Err)
                    {
                        Console.Write(Err.StackTrace);
                        logger.Error(Err.StackTrace);
                    }
                    #region Team Member Count
                    try
                    {
                        GroupRepository grouprepo    = new GroupRepository();
                        string          groupsofhome = string.Empty;
                        List <Groups>   lstgroups    = grouprepo.getAllGroups(user.Id);
                        if (lstgroups.Count != 0)
                        {
                            foreach (Groups item in lstgroups)
                            {
                                groupsofhome += "<li><a href=\"../Settings/InviteMember.aspx?q=" + item.Id + "\"><img src=\"../Contents/img/groups_.png\" alt=\"\" style=\" margin-right:5px;\"> " + item.GroupName + "</a></li>";
                            }
                            getAllGroupsOnHome.InnerHtml = groupsofhome;
                        }
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.StackTrace);
                    }
                    #endregion

                    try
                    {
                        string      strTeam = string.Empty;
                        List <Team> teams   = objTeamRepo.getAllTeamsOfUser(user.Id, team.GroupId, user.EmailId);
                        foreach (Team item in teams)
                        {
                            strTeam += "<div class=\"userpictiny\"><a target=\"_blank\" href=\"#\">" +
                                       "<img width=\"48\" height=\"48\" title=\"" + item.FirstName + "\" alt=\"\" src=\"../Contents/img/blank_img.png\">" +
                                       "</a></div>";
                        }
                        team_member.InnerHtml = strTeam;
                    }
                    catch (Exception Err)
                    {
                        Console.Write(Err.StackTrace);
                    }

                    #region Add Fan Page
                    try
                    {
                        if (Session["fbSocial"] != null)
                        {
                            if (Session["fbSocial"] == "p")
                            {
                                FacebookAccount objFacebookAccount = (FacebookAccount)Session["fbpagedetail"];

                                //    string strpageUrl = "https://graph.facebook.com/" + objFacebookAccount.FacebookId + "/accounts";
                                // objFacebookUrlBuilder = (FacebookUrlBuilder)Session["FacebookInsightUser"];
                                //    string strData = objAuthentication.RequestUrl(strpageUrl, objFacebookAccount.Token);
                                //    JObject output = objWebRequest.FacebookRequest(strData, "Get");
                                FacebookClient fb = new FacebookClient();
                                fb.AccessToken = objFacebookAccount.AccessToken;
                                dynamic output = fb.Get("/me/accounts");
                                //  JArray data = (JArray)output["data"];
                                DataTable dtFbPage = new DataTable();
                                dtFbPage.Columns.Add("Email");
                                dtFbPage.Columns.Add("PageId");
                                dtFbPage.Columns.Add("PageName");
                                dtFbPage.Columns.Add("status");
                                dtFbPage.Columns.Add("customer_id");
                                string strPageDiv = string.Empty;
                                if (output != null)
                                {
                                    foreach (var item in output["data"])
                                    {
                                        if (item.category.ToString() != "Application")
                                        {
                                            strPageDiv      += "<div><a id=\"A1\"  onclick=\"getInsights('" + item["id"].ToString() + "','" + item["name"].ToString() + "')\"><span>" + item["name"].ToString() + "</span> </a></div>";
                                            fbpage.InnerHtml = strPageDiv;
                                        }
                                    }
                                }
                                else
                                {
                                    strPageDiv += "<div>No Pages Found</div>";
                                }
                                Page.ClientScript.RegisterStartupScript(Page.GetType(), "my", " ShowDialogHome(false);", true);
                                Session["fbSocial"] = null;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                        logger.Error(ex.StackTrace);
                    }
                    #endregion

                    #region InsightsData
                    try
                    {
                        decimal malecount = 0, femalecount = 0, cnt = 0;

                        FacebookStatsRepository objfbStatsRepo = new FacebookStatsRepository();
                        double daysSub = (DateTime.Now - user.CreateDate).TotalDays;

                        int userdays;
                        if (daysSub > 0 && daysSub <= 1)
                        {
                            userdays = 1;
                        }
                        else
                        {
                            userdays = (int)daysSub;
                        }
                        ArrayList arrFbStats = objfbStatsRepo.getAllFacebookStatsOfUser(user.Id, userdays);
                        //ArrayList arrFbStats = objfbStatsRepo.getTotalFacebookStatsOfUser(user.Id);

                        Random rNum = new Random();
                        foreach (var item in arrFbStats)
                        {
                            Array temp = (Array)item;
                            cnt         += int.Parse(temp.GetValue(3).ToString()) + int.Parse(temp.GetValue(4).ToString());
                            malecount   += int.Parse(temp.GetValue(3).ToString());
                            femalecount += int.Parse(temp.GetValue(4).ToString());
                        }
                        try
                        {
                            decimal mc = (malecount / cnt) * 100;
                            male = Convert.ToInt16(mc);
                        }
                        catch (Exception Err)
                        {
                            Console.Write(Err.StackTrace);
                            logger.Error(Err.StackTrace);
                        }
                        try
                        {
                            decimal fc = (femalecount / cnt) * 100;
                            female = Convert.ToInt16(fc);
                        }
                        catch (Exception Err)
                        {
                            Console.Write(Err.StackTrace);
                            logger.Error(Err.StackTrace);
                        }
                        int twtAccCount = objSocioRepo.getAllSocialProfilesTypeOfUser(user.Id, "twitter").Count;
                        if (twtAccCount > 1)
                        {
                            twtmale   = rNum.Next(100);
                            twtfemale = 100 - twtmale;
                        }
                        else if (twtAccCount == 1)
                        {
                            twtmale   = 100;
                            twtfemale = 0;
                        }
                        Session["twtGender"] = twtmale + "," + twtfemale;
                    }
                    catch (Exception Err)
                    {
                        Console.Write(Err.Message.ToString());
                        logger.Error(Err.StackTrace);
                    }
                    //getgrphData();
                    // getNewFriends(7);
                    //  getNewFriends();
                    //  getNewFollowers();
                    #endregion

                    #region GetFollower


                    try
                    {
                        String TwtProfileId = string.Empty;

                        TwitterStatsRepository objtwtStatsRepo = new TwitterStatsRepository();

                        List <TeamMemberProfile> objTeamMemberProfile = objTeamMemberProfileRepository.getTwtTeamMemberProfileData(team.Id);
                        foreach (TeamMemberProfile item in objTeamMemberProfile)
                        {
                            TwtProfileId += item.ProfileId + ',';
                        }
                        TwtProfileId = TwtProfileId.Substring(0, TwtProfileId.Length - 1);

                        List <TwitterStats> arrTwtStats = objtwtStatsRepo.getAllAccountDetail(TwtProfileId);

                        //strTwtArray = "[";
                        int    NewTweet_Count = 0;
                        string TotalFollower  = string.Empty;
                        foreach (TwitterStats item in arrTwtStats)
                        {
                            NewTweet_Count += item.FollowerCount;
                        }
                        if (NewTweet_Count >= 100000)
                        {
                            TotalFollower = (System.Math.Round(((float)NewTweet_Count / 1000000), 2)) + "M";
                        }
                        else if (NewTweet_Count > 1000 && NewTweet_Count < 100000)
                        {
                            TotalFollower = (System.Math.Round(((float)NewTweet_Count / 1000), 2)) + "K";
                        }
                        else
                        {
                            TotalFollower = NewTweet_Count.ToString();
                        }

                        spanNewTweets.InnerHtml = TotalFollower;
                    }
                    catch (Exception Err)
                    {
                        Console.Write(Err.Message.ToString());
                        logger.Error(Err.StackTrace);
                    }


                    #endregion

                    #region GetFacebookFanPage

                    try
                    {
                        String FbProfileId = string.Empty;

                        FacebookStatsRepository objFacebookStatsRepository = new FacebookStatsRepository();

                        List <TeamMemberProfile> objTeamMemberProfile = objTeamMemberProfileRepository.getTeamMemberProfileData(team.Id);
                        foreach (TeamMemberProfile item in objTeamMemberProfile)
                        {
                            FbProfileId += item.ProfileId + ',';
                        }
                        FbProfileId = FbProfileId.Substring(0, FbProfileId.Length - 1);

                        List <FacebookStats> arrFbStats = objFacebookStatsRepository.getAllAccountDetail(FbProfileId);

                        //strTwtArray = "[";
                        int    NewFbFan_Count = 0;
                        string TotalFriends   = string.Empty;
                        foreach (FacebookStats item in arrFbStats)
                        {
                            NewFbFan_Count += item.FanCount;
                        }
                        if (NewFbFan_Count >= 100000)
                        {
                            TotalFriends = (System.Math.Round(((float)NewFbFan_Count / 1000000), 2)) + "M";
                        }
                        else if (NewFbFan_Count > 1000 && NewFbFan_Count < 100000)
                        {
                            TotalFriends = (System.Math.Round(((float)NewFbFan_Count / 1000), 2)) + "K";
                        }
                        else
                        {
                            TotalFriends = NewFbFan_Count.ToString();
                        }

                        spanFbFans.InnerHtml = TotalFriends;
                    }
                    catch (Exception Err)
                    {
                        Console.Write(Err.Message.ToString());
                        logger.Error(Err.StackTrace);
                    }

                    #endregion



                    #region IncomingMessages
                    try
                    {
                        FacebookFeedRepository fbFeedRepo = new FacebookFeedRepository();
                        int fbmessagescout = fbFeedRepo.countUnreadMessages(user.Id);
                        TwitterMessageRepository twtMsgRepo = new TwitterMessageRepository();
                        int twtcount = twtMsgRepo.getCountUnreadMessages(user.Id);
                        Session["CountMessages"] = fbmessagescout + twtcount;
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.StackTrace);
                    }
                    #endregion



                    #region NewIncomingMessage

                    try
                    {
                        String FbProfileId  = string.Empty;
                        String TwtProfileId = string.Empty;
                        List <TeamMemberProfile> objTeamMemberProfile = objTeamMemberProfileRepository.getAllTeamMemberProfilesOfTeam(team.Id);
                        foreach (TeamMemberProfile item in objTeamMemberProfile)
                        {
                            try
                            {
                                if (item.ProfileType == "facebook")
                                {
                                    FbProfileId += item.ProfileId + ',';
                                }

                                else if (item.ProfileType == "twitter")
                                {
                                    TwtProfileId += item.ProfileId + ',';
                                }
                            }
                            catch (Exception Err)
                            {
                                Console.Write(Err.StackTrace);
                                logger.Error(Err.StackTrace);
                            }
                        }

                        try
                        {
                            FbProfileId = FbProfileId.Substring(0, FbProfileId.Length - 1);
                        }
                        catch (Exception Err)
                        {
                            Console.Write(Err.StackTrace);
                            logger.Error(Err.StackTrace);
                        }

                        try
                        {
                            TwtProfileId = TwtProfileId.Substring(0, TwtProfileId.Length - 1);
                        }
                        catch (Exception Err)
                        {
                            Console.Write(Err.StackTrace);
                            logger.Error(Err.StackTrace);
                        }

                        FacebookFeedRepository objFacebookFeedRepository = new FacebookFeedRepository();
                        List <FacebookFeed>    alstfb = objFacebookFeedRepository.getAllFeedDetail(FbProfileId);
                        // FacebookMessageRepository objFacebookMessageRepository = new FacebookMessageRepository();
                        TwitterMessageRepository objtwttatsRepo = new TwitterMessageRepository();
                        // List<FacebookMessage> alstfb = objFacebookMessageRepository.getAllMessageDetail(FbProfileId);
                        List <TwitterMessage> alstTwt = objtwttatsRepo.getAlltwtMessages(TwtProfileId);

                        int TotalFbMsgCount  = 0;
                        int TotalTwtMsgCount = 0;

                        try
                        {
                            TotalFbMsgCount = alstfb.Count;
                        }
                        catch (Exception Err)
                        {
                            Console.Write(Err.StackTrace);
                            logger.Error(Err.StackTrace);
                        }

                        try
                        {
                            TotalTwtMsgCount = alstTwt.Count;
                        }
                        catch (Exception Err)
                        {
                            Console.Write(Err.StackTrace);
                            logger.Error(Err.StackTrace);
                        }



                        spanIncoming.InnerHtml = (TotalFbMsgCount + TotalTwtMsgCount).ToString();

                        string profileid = string.Empty;
                        ScheduledMessageRepository objScheduledMessageRepository = new ScheduledMessageRepository();
                        foreach (TeamMemberProfile item in objTeamMemberProfile)
                        {
                            profileid += item.ProfileId + ',';
                        }

                        profileid = profileid.Substring(0, profileid.Length - 1);

                        spanSent.InnerHtml = objScheduledMessageRepository.getAllSentMessageDetails(profileid).Count().ToString();
                    }

                    catch (Exception Err)
                    {
                        Console.Write(Err.StackTrace);
                        logger.Error(Err.StackTrace);
                    }
                }


                #endregion
            }

            catch (Exception Err)
            {
                Console.Write(Err.StackTrace);
            }
        }
        public void ProcessRequest()
        {
            if (Request.QueryString["op"] == "login")
            {
                try
                {
                    string       email    = Request.QueryString["username"];
                    string       password = Request.QueryString["password"];
                    Registration regpage  = new Registration();
                    password = regpage.MD5Hash(password);
                    SocioBoard.Helper.SessionFactory.configfilepath = Server.MapPath("~/hibernate.cfg.xml");
                    UserRepository      userrepo               = new UserRepository();
                    LoginLogs           objLoginLogs           = new LoginLogs();
                    LoginLogsRepository objLoginLogsRepository = new LoginLogsRepository();
                    User user = userrepo.GetUserInfo(email, password);
                    if (user == null)
                    {
                        Response.Write("Invalid Email or Password");
                    }
                    else
                    {
                        if (user.UserStatus == 1)
                        {
                            Session["LoggedUser"] = user;
                            // List<User> lstUser = new List<User>();
                            if (Session["LoggedUser"] != null)
                            {
                                //SocioBoard.Domain.User.lstUser.Add((User)Session["LoggedUser"]);
                                //Application["OnlineUsers"] = SocioBoard.Domain.User.lstUser;
                                //objLoginLogs.Id = new Guid();
                                //objLoginLogs.UserId = user.Id;
                                //objLoginLogs.UserName = user.UserName;
                                //objLoginLogs.LoginTime = DateTime.Now.AddHours(11.50);
                                //objLoginLogsRepository.Add(objLoginLogs);
                                Groups          objGroups          = new Groups();
                                GroupRepository objGroupRepository = new GroupRepository();
                                Team            objteam            = new Team();
                                TeamRepository  objTeamRepository  = new TeamRepository();
                                objGroups = objGroupRepository.getGroupDetail(user.Id);
                                if (objGroups == null)
                                {
                                    //================================================================================
                                    //Insert into group

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

                                        objteam.Id      = Guid.NewGuid();
                                        objteam.GroupId = objGroups.Id;
                                        objteam.UserId  = user.Id;
                                        objteam.EmailId = user.EmailId;
                                        // teams.FirstName = user.UserName;
                                        objTeamRepository.addNewTeam(objteam);

                                        SocialProfile            objSocialProfile            = new SocialProfile();
                                        SocialProfilesRepository objSocialProfilesRepository = new SocialProfilesRepository();

                                        List <SocialProfile> lstSocialProfile = objSocialProfilesRepository.getAllSocialProfilesOfUser(user.Id);
                                        if (lstSocialProfile != null)
                                        {
                                            if (lstSocialProfile.Count > 0)
                                            {
                                                foreach (SocialProfile item in lstSocialProfile)
                                                {
                                                    try
                                                    {
                                                        TeamMemberProfile           objTeamMemberProfile           = new TeamMemberProfile();
                                                        TeamMemberProfileRepository objTeamMemberProfileRepository = new TeamMemberProfileRepository();
                                                        objTeamMemberProfile.Id               = Guid.NewGuid();
                                                        objTeamMemberProfile.TeamId           = objteam.Id;
                                                        objTeamMemberProfile.ProfileId        = item.ProfileId;
                                                        objTeamMemberProfile.ProfileType      = item.ProfileType;
                                                        objTeamMemberProfile.Status           = item.ProfileStatus;
                                                        objTeamMemberProfile.StatusUpdateDate = DateTime.Now;
                                                        objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile);
                                                    }
                                                    catch (Exception ex)
                                                    {
                                                        Console.WriteLine(ex.Message);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        Console.WriteLine(ex.Message);
                                        logger.Error("Error : " + ex.Message);
                                        logger.Error("Error : " + ex.StackTrace);
                                    }

                                    //==========================================================================================================
                                }

                                BusinessSetting           objBusinessSetting           = new BusinessSetting();
                                BusinessSettingRepository objBusinessSettingRepository = new BusinessSettingRepository();
                                List <BusinessSetting>    lstBusinessSetting           = objBusinessSettingRepository.GetBusinessSettingByUserId(user.Id);
                                if (lstBusinessSetting.Count == 0)
                                {
                                    try
                                    {
                                        List <Groups> lstGroups = objGroupRepository.getAllGroups(user.Id);
                                        foreach (Groups item in lstGroups)
                                        {
                                            objBusinessSetting              = new BusinessSetting();
                                            objBusinessSetting.Id           = Guid.NewGuid();
                                            objBusinessSetting.BusinessName = item.GroupName;
                                            //objbsnssetting.GroupId = team.GroupId;
                                            objBusinessSetting.GroupId          = item.Id;
                                            objBusinessSetting.AssigningTasks   = false;
                                            objBusinessSetting.AssigningTasks   = false;
                                            objBusinessSetting.TaskNotification = false;
                                            objBusinessSetting.TaskNotification = false;
                                            objBusinessSetting.FbPhotoUpload    = 0;
                                            objBusinessSetting.UserId           = user.Id;
                                            objBusinessSetting.EntryDate        = DateTime.Now;
                                            objBusinessSettingRepository.AddBusinessSetting(objBusinessSetting);
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        Console.WriteLine(ex.StackTrace);
                                    }
                                }
                            }
                            Response.Write("user");
                        }

                        else
                        {
                            Response.Write("You are Blocked by Admin Please contact Admin!");
                        }
                    }
                }
                catch (Exception ex)
                {
                    Response.Write("Error: " + ex.Message);
                    Console.WriteLine(ex.StackTrace);
                    logger.Error(ex.StackTrace);
                }
            }
            else if (Request.QueryString["op"] == "register")
            {
                User           user = new User();
                UserActivation objUserActivation = new UserActivation();
                UserRepository userrepo          = new UserRepository();
                SocioBoard.Helper.SessionFactory.configfilepath = Server.MapPath("~/hibernate.cfg.xml");
                Session["AjaxLogin"] = "******";
                try
                {
                    System.IO.StreamReader sr = new System.IO.StreamReader(Request.InputStream);
                    string line = "";
                    line = sr.ReadToEnd();
                    JObject jo = JObject.Parse(line);
                    user.PaymentStatus = "unpaid";
                    if (!string.IsNullOrEmpty(Request.QueryString["type"]))
                    {
                        user.AccountType = Request.QueryString["type"];
                    }
                    else
                    {
                        user.AccountType = "deluxe";
                    }
                    user.CreateDate = DateTime.Now;
                    user.ExpiryDate = DateTime.Now.AddMonths(1);
                    user.Id         = Guid.NewGuid();
                    user.UserName   = Server.UrlDecode((string)jo["firstname"]) + " " + Server.UrlDecode((string)jo["lastname"]);
                    user.EmailId    = Server.UrlDecode((string)jo["email"]);
                    user.Password   = Server.UrlDecode((string)jo["password"]);
                    user.UserStatus = 1;
                    if (!userrepo.IsUserExist(user.EmailId))
                    {
                        UserRepository.Add(user);
                        Session["LoggedUser"] = user;
                        Response.Write("user");

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

                        //add value in userpackage
                        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.PackageStatus = true;

                        objUserPackageRelationRepository.AddUserPackageRelation(objUserPackageRelation);


                        SocioBoard.Helper.MailSender.SendEMail(user.UserName, user.Password, user.EmailId, user.AccountType.ToString(), user.Id.ToString());



                        //MailSender.SendEMail(user.UserName, user.Password, user.EmailId);
                        // lblerror.Text = "Registered Successfully !" + "<a href=\"login.aspx\">Login</a>";
                    }
                    else
                    {
                        Response.Write("Email Already Exists !");
                    }
                }


                catch (Exception ex)
                {
                    logger.Error(ex.StackTrace);


                    Console.WriteLine(ex.StackTrace);
                }
            }
            else if (Request.QueryString["op"] == "facebooklogin")
            {
                SessionFactory.configfilepath = Server.MapPath("~/hibernate.cfg.xml");

                string redi = "http://www.facebook.com/dialog/oauth/?scope=publish_stream,read_stream,read_insights,manage_pages,user_checkins,user_photos,read_mailbox,manage_notifications,read_page_mailboxes,email,user_videos,offline_access&client_id=" + ConfigurationManager.AppSettings["ClientId"] + "&redirect_uri=" + ConfigurationManager.AppSettings["RedirectUrl"] + "&response_type=code";
                Session["login"] = "******";
                Response.Write(redi);
            }
            else if (Request.QueryString["op"] == "googlepluslogin")
            {
                Session["login"] = "******";
                oAuthToken objToken = new oAuthToken();
                Response.Write(objToken.GetAutherizationLink("https://www.googleapis.com/auth/userinfo.email+https://www.googleapis.com/auth/userinfo.profile+https://www.googleapis.com/auth/plus.me+https://www.googleapis.com/auth/plus.login"));
            }
            else if (Request.QueryString["op"] == "removeuser")
            {
                try
                {
                    if (Session["LoggedUser"] != null)
                    {
                        SocioBoard.Domain.User.lstUser.Remove((User)Session["LoggedUser"]);
                    }
                }
                catch (Exception Err)
                {
                    logger.Error(Err.StackTrace);
                    Response.Write(Err.StackTrace);
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            User user = (User)Session["LoggedUser"];

            try
            {
                #region for You can use only 30 days as Unpaid User

                //SocioBoard.Domain.User user = (User)Session["LoggedUser"];
                if (user.PaymentStatus.ToLower() == "unpaid")
                {
                    if (!SBUtils.IsUserWorkingDaysValid(user.ExpiryDate))
                    {
                        // ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('You can use only 30 days as Unpaid User !');", true);

                        Session["GreaterThan30Days"] = "GreaterThan30Days";

                        Response.Redirect("../Settings/Billing.aspx");
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error : " + ex.StackTrace);
            }

            if (!IsPostBack)
            {
                if (user == null)
                {
                    Response.Redirect("/Default.aspx");
                }
                try
                {
                    getgrphData(7);
                }
                catch (Exception Err)
                {
                    Console.Write(Err.StackTrace);
                }

                try
                {
                    getNewFriends(7);
                }
                catch (Exception Err)
                {
                    Console.Write(Err.StackTrace);
                }
                try
                {
                    getNewFollowers(7);
                }
                catch (Exception Err)
                {
                    Console.Write(Err.StackTrace);
                }
                try
                {
                    GetFollowersAgeWise(7);
                }
                catch (Exception Err)
                {
                    Console.Write(Err.StackTrace);
                }
                try
                {
                    getFollowFollowersMonth();
                }
                catch (Exception Err)
                {
                    Console.Write(Err.StackTrace);
                }
                try
                {
                    FacebookAccountRepository fbAccRepo  = new FacebookAccountRepository();
                    FacebookFeedRepository    fbFeedRepo = new FacebookFeedRepository();
                    ArrayList arrfbProfile = fbAccRepo.getAllFacebookPagesOfUser(user.Id);
                    long      talking      = 0;
                    foreach (FacebookAccount item in arrfbProfile)
                    {
                        FacebookClient fb = new FacebookClient();
                        fb.AccessToken = item.AccessToken;
                        pagelikes      = pagelikes + fbFeedRepo.countInteractions(item.UserId, item.FbUserId, 7);
                        dynamic talkingabout = fb.Get(item.FbUserId);
                        talking = talking + talkingabout.talking_about_count;
                        // strinteractions = pagelikes.Count(); //(long.Parse(strinteractions) + pagelikes.talking_about_count).ToString();
                    }
                    talkingabtcount = (talking / 100) * arrfbProfile.Count;
                }
                catch (Exception Err)
                {
                    Console.Write(Err.StackTrace);
                }
                try
                {
                    SocialProfilesRepository objsocioRepo = new SocialProfilesRepository();
                    profileCount = objsocioRepo.getAllSocialProfilesOfUser(user.Id).Count();
                }
                catch (Exception Err)
                {
                    Console.Write(Err.StackTrace);
                }

                var strgenderTwt = Session["twtGender"].ToString().Split(',');
                divtwtMale.InnerHtml   = strgenderTwt[0] + "%";
                divtwtfeMale.InnerHtml = strgenderTwt[1] + "%";
            }
        }
        public void ProfilesAvailabeforuser(Guid UserId)
        {
            string bindprofiles = string.Empty;

            SocialProfilesRepository socioprofilerepo = new SocialProfilesRepository();
            List <SocialProfile>     lstsocialprofile = socioprofilerepo.getAllSocialProfilesOfUser(UserId);

            foreach (SocialProfile item in lstsocialprofile)
            {
                if (item.ProfileType == "facebook")
                {
                    if (!SelectedGroupProfiles.InnerHtml.Contains("facebook_" + item.ProfileId))
                    {
                        FacebookAccountRepository fbaccreop       = new FacebookAccountRepository();
                        FacebookAccount           facebookaccount = fbaccreop.getFacebookAccountDetailsById(item.ProfileId, UserId);

                        bindprofiles +=
                            "<div onclick=\"transfertoGroup('facebook','" + item.ProfileId + "')\" id=\"usergroups_" + item.ProfileId + "\" class=\"ws_conct active\"> <span class=\"img\"><img width=\"48\" height=\"48\" src=\"http://graph.facebook.com/" + item.ProfileId + "/picture?type=small\" alt=\"\"><i><img width=\"16\" height=\"16\" src=\"../Contents/img/fb_icon.png\" alt=\"\"></i></span><div class=\"fourfifth\">" +
                            "<div class=\"location-container\">" + facebookaccount.FbUserName + "</div><span class=\"add remove\">✖</span></div></div>";
                    }
                }
                else if (item.ProfileType == "twitter")
                {
                    if (!SelectedGroupProfiles.InnerHtml.Contains("twitter_" + item.ProfileId))
                    {
                        string profileimgurl = string.Empty;
                        TwitterAccountRepository twtaccountrepo = new TwitterAccountRepository();
                        TwitterAccount           twtacco        = twtaccountrepo.getUserInformation(UserId, item.ProfileId);
                        if (twtacco.ProfileImageUrl == string.Empty)
                        {
                            profileimgurl = "../../Contents/img/blank_img.png";
                        }
                        else
                        {
                            profileimgurl = twtacco.ProfileImageUrl;
                        }
                        bindprofiles +=
                            "<div onclick=\"transfertoGroup('twitter','" + item.ProfileId + "')\" id=\"usergroups_" + item.ProfileId + "\" class=\"ws_conct active\"> <span class=\"img\"><img width=\"48\" height=\"48\" src=\"" + profileimgurl + "\" alt=\"\"><i><img width=\"16\" height=\"16\" src=\"../Contents/img/twticon.png\" alt=\"\"></i></span><div class=\"fourfifth\">" +
                            "<div class=\"location-container\">" + twtacco.TwitterScreenName + "</div><span class=\"add remove\">✖</span></div></div>";
                    }
                }
                else if (item.ProfileType == "linkedin")
                {
                    if (!SelectedGroupProfiles.InnerHtml.Contains("linkedin_" + item.ProfileId))
                    {
                        LinkedInAccountRepository linkedaccrepo = new LinkedInAccountRepository();
                        LinkedInAccount           linkedaccount = linkedaccrepo.getUserInformation(UserId, item.ProfileId);
                        string profileimgurl = string.Empty;
                        if (linkedaccount.ProfileUrl == string.Empty)
                        {
                            profileimgurl = "../../Contents/img/blank_img.png";
                        }
                        else
                        {
                            profileimgurl = linkedaccount.ProfileImageUrl;
                        }
                        bindprofiles += "<div onclick=\"transfertoGroup('linkedin','" + item.ProfileId + "')\" id=\"usergroups_" + item.ProfileId + "\" class=\"ws_conct active\"><span class=\"img\"><img width=\"48\" height=\"48\" alt=\"\" src=\"" + profileimgurl + "\" ><i>" +
                                        "<img width=\"16\" height=\"16\" alt=\"\" src=\"../Contents/img/link_icon.png\"></i></span>" +
                                        "<div class=\"fourfifth\"><div class=\"location-container\">" + linkedaccount.LinkedinUserName + "</div>" +
                                        "<span class=\"add remove\">✖</span></div></div>";
                    }
                }
                else if (item.ProfileType == "instagram")
                {
                    if (!SelectedGroupProfiles.InnerHtml.Contains("instagram_" + item.ProfileId))
                    {
                        string profileimgurl = string.Empty;
                        InstagramAccountRepository instagramrepo = new InstagramAccountRepository();
                        InstagramAccount           instaaccount  = instagramrepo.getInstagramAccountDetailsById(item.ProfileId, UserId);
                        if (instaaccount.ProfileUrl == string.Empty)
                        {
                            profileimgurl = "../../Contents/img/blank_img.png";
                        }
                        else
                        {
                            profileimgurl = instaaccount.ProfileUrl;
                        }

                        bindprofiles += "<div onclick=\"transfertoGroup('instagram','" + item.ProfileId + "')\" id=\"usergroups_" + item.ProfileId + "\" class=\"ws_conct active\"><span class=\"img\"><img width=\"48\" height=\"48\" src=\"" + profileimgurl + "\" alt=\"\"><i>" +
                                        "<img width=\"16\" height=\"16\" alt=\"\" src=\"../Contents/img/instagram_24X24.png\"></i></span><div class=\"fourfifth\"><div class=\"location-container\">" + instaaccount.InsUserName + "</div>" +
                                        "<span class=\"add remove\">✖</span></div></div>";
                    }
                }
                else if (item.ProfileType == "tumblr")
                {
                    if (!SelectedGroupProfiles.InnerHtml.Contains("tumblr_" + item.ProfileId))
                    {
                        string profileimgurl = string.Empty;
                        TumblrAccountRepository tumblrrepo    = new TumblrAccountRepository();
                        TumblrAccount           tumblraccount = tumblrrepo.getTumblrAccountDetailsById(item.ProfileId, UserId);
                        if (tumblraccount.tblrProfilePicUrl == string.Empty)
                        {
                            profileimgurl = "../../Contents/img/blank_img.png";
                        }
                        else
                        {
                            profileimgurl = "http://api.tumblr.com/v2/blog/" + tumblraccount.tblrUserName + ".tumblr.com/avatar";
                        }

                        bindprofiles += "<div onclick=\"transfertoGroup('tumblr','" + item.ProfileId + "')\" id=\"usergroups_" + item.ProfileId + "\" class=\"ws_conct active\"><span class=\"img\"><img width=\"48\" height=\"48\" src=\"http://api.tumblr.com/v2/blog/" + tumblraccount.tblrUserName + ".tumblr.com/avatar\" alt=\"\"><i>" +
                                        "<img width=\"16\" height=\"16\" alt=\"\" src=\"../Contents/img/tumblr.png\"></i></span><div class=\"fourfifth\"><div class=\"location-container\">" + tumblraccount.tblrUserName + "</div>" +
                                        "<span class=\"add remove\">✖</span></div></div>";
                    }
                }
            }
            AllGroupProfiles.InnerHtml = bindprofiles;
        }