예제 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                User user = (User)Session["LoggedUser"];
                SocioBoard.Domain.Team team = (SocioBoard.Domain.Team)Session["GroupName"];
                try
                {
                    #region for You can use only 30 days as Unpaid User

                    if (user.PaymentStatus.ToLower() == "unpaid")
                    {
                        if (!SBUtils.IsUserWorkingDaysValid(user.ExpiryDate))
                        {
                            Session["GreaterThan30Days"] = "GreaterThan30Days";
                            Response.Redirect("../Settings/Billing.aspx");
                        }
                    }
                    #endregion
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error : " + ex.StackTrace);
                }

                //if (!IsPostBack)
                //{
                string profileid         = string.Empty;
                string LinkedINprofileid = string.Empty;
                if (user == null)
                {
                    Response.Redirect("/Default.aspx");
                }

                SocioBoard.Domain.FacebookAccount objFacebookAccount;
                TeamMemberProfileRepository       objTeamMemberProfileRepository = new TeamMemberProfileRepository();
                List <TeamMemberProfile>          allprofiles         = objTeamMemberProfileRepository.getTeamMemberProfileData(team.Id);
                List <TeamMemberProfile>          allLinkedInprofiles = objTeamMemberProfileRepository.getLinkedInTeamMemberProfileData(team.Id);
                oAuthLinkedIn objoAuthLinkedIn = new oAuthLinkedIn();
                try
                {
                    if (allLinkedInprofiles.Count != 0)
                    {
                        foreach (TeamMemberProfile item in allLinkedInprofiles)
                        {
                            LinkedINprofileid += item.ProfileId + ',';
                        }
                        LinkedINprofileid = LinkedINprofileid.Substring(0, LinkedINprofileid.Length - 1);
                        List <LinkedInAccount> arrLinkedInAccount = linkedrepo.getAllAccountDetail(LinkedINprofileid);

                        foreach (var item in arrLinkedInAccount)
                        {
                            objoAuthLinkedIn.Token       = item.OAuthToken;
                            objoAuthLinkedIn.Verifier    = item.OAuthVerifier;
                            objoAuthLinkedIn.TokenSecret = item.OAuthSecret;

                            //if (item.LinkedinUserName.Length > 15)
                            //{
                            //    item.LinkedinUserName = item.LinkedinUserName.Substring(0, 14);
                            //    item.LinkedinUserName = item.LinkedinUserName + "..";
                            //}
                            //else
                            //{
                            //    item.LinkedinUserName = item.LinkedinUserName;
                            //}

                            leftsidedata += "<div class=\"accordion-group\"><div class=\"accordion-heading\">"
                                            + "<a href=\"#" + item.Id + "\" data-parent=\"#accordion2\" data-toggle=\"collapse\" class=\"accordion-toggle\">"
                                            + "<img width=\"19\" class=\"fesim\" src=\"" + item.ProfileImageUrl + "\" /><span class=\"groupname\">" + item.LinkedinUserName + " </span><i class=\"icon-sort-down pull-right hidden\">"
                                            + "</i></a></div><div id=\"" + item.Id + "\" class=\"accordion-body collapse\" ><div class=\"accordion-inner\"><ul>";
                            List <GlobusLinkedinLib.App.Core.LinkedInGroup.Group_Updates> lstlinkedinGroup = GetGroupsName(objoAuthLinkedIn);
                            if (lstlinkedinGroup.Count == 0)
                            {
                                leftsidedata += "<li><a  linkedInUserId=\"" + item.LinkedinUserId + "\">No Group Found</a> </li>";
                            }
                            else
                            {
                                foreach (var item1 in lstlinkedinGroup)
                                {
                                    leftsidedata += "<li class=\"pull-left\"> <input style=\"float: left;\" type=\"checkbox\" id=\"" + item.LinkedinUserId + "_lin_" + item1.id + "\" value=\"lin_" + item.LinkedinUserId + "\"><a gid=\"" + item1.id + "\" onclick=\"linkedingroupdetails('" + item1.id + "','" + item.LinkedinUserId + "');\" linkedInUserId=\"" + item.LinkedinUserId + "\" style=\"margin-left: 20px;\" href=\"#\">" + item1.GroupName + "</a> </li>";
                                }
                            }
                            leftsidedata += "</ul></div></div></div>";
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }

                if (allprofiles.Count != 0)
                {
                    foreach (TeamMemberProfile item in allprofiles)
                    {
                        profileid += item.ProfileId + ',';
                    }
                    profileid = profileid.Substring(0, profileid.Length - 1);
                    List <FacebookAccount> arrFacebookAccount = fbAccRepo.getAllAccountDetail(profileid);

                    foreach (var item in arrFacebookAccount)
                    {
                        objFacebookAccount = new FacebookAccount();
                        objFacebookAccount = (SocioBoard.Domain.FacebookAccount)item;

                        //if (objFacebookAccount.FbUserName.Length > 15)
                        //{
                        //    objFacebookAccount.FbUserName = objFacebookAccount.FbUserName.Substring(0, 14);
                        //    objFacebookAccount.FbUserName = objFacebookAccount.FbUserName + "..";
                        //}
                        //else
                        //{
                        //    objFacebookAccount.FbUserName = objFacebookAccount.FbUserName;
                        //}

                        if (objFacebookAccount.Type != "page")
                        {
                            leftsidedata += "<div class=\"accordion-group\"><div class=\"accordion-heading\">"
                                            + "<a href=\"#" + objFacebookAccount.Id + "\" data-parent=\"#accordion2\" data-toggle=\"collapse\" class=\"accordion-toggle\">"
                                            + "<img width=\"19\" class=\"fesim\" src=\"http://graph.facebook.com/" + objFacebookAccount.FbUserId + "/picture?type=small\" alt=\"\" /><span class=\"groupname\">" + objFacebookAccount.FbUserName + " </span><i class=\"icon-sort-down pull-right hidden\">"
                                            + "</i></a></div><div id=\"" + objFacebookAccount.Id + "\" class=\"accordion-body collapse\" ><div class=\"accordion-inner\"><ul>";

                            List <FacebookGroup> lstFacebookGroup = GetGroupName(objFacebookAccount.AccessToken);
                            if (lstFacebookGroup.Count == 0)
                            {
                                leftsidedata += "<li><a  fbUserId=\"" + objFacebookAccount.FbUserId + "\">No Group Found</a> </li>";
                            }
                            else
                            {
                                foreach (var item1 in lstFacebookGroup)
                                {
                                    //leftsidedata += "<li class=\"grpli\"><a gid=\"" + item1.GroupId + "\" onclick=\"facebookgroupdetails('" + item1.GroupId + "','" + objFacebookAccount.AccessToken + "');\" fbUserId=\"" + objFacebookAccount.FbUserId + "\" href=\"#\">" + item1.Name + "</a> </li>";

                                    leftsidedata += "<li class=\"pull-left\"><input style=\"float: left;\" type=\"checkbox\" id=\"" + objFacebookAccount.FbUserId + "_fb_" + item1.GroupId + "\" value=\"fb_" + objFacebookAccount.AccessToken + "\"><a gid=\"" + item1.GroupId + "\" onclick=\"facebookgroupdetails('" + item1.GroupId + "','" + objFacebookAccount.AccessToken + "');\" fbUserId=\"" + objFacebookAccount.FbUserId + "\" style=\"margin-left: 20px;\" href=\"#\">" + item1.Name + "</a> </li>";
                                }
                            }
                            leftsidedata += "</ul></div></div></div>";
                        }
                    }
                }
                accordion2.InnerHtml = leftsidedata;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
        }
예제 #2
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);
            }
        }
예제 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!IsPostBack)
                {
                    User user = (User)Session["LoggedUser"];

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

                    FacebookAccountRepository   objFbRepo = new FacebookAccountRepository();
                    TeamMemberProfileRepository objTeamMemberProfileRepository = new TeamMemberProfileRepository();

                    SocioBoard.Domain.Team   team        = (SocioBoard.Domain.Team)Session["GroupName"];
                    List <TeamMemberProfile> allprofiles = objTeamMemberProfileRepository.getTeamMemberProfileData(team.Id);

                    //List<FacebookAccount>arrfbPrfile=new List<FacebookAccount>();
                    ArrayList arrfbPrfile = new ArrayList();
                    try
                    {
                        foreach (TeamMemberProfile item in allprofiles)
                        {
                            //fbpId += item.ProfileId + ',';
                            FacebookAccount arrfbProfile = objFbRepo.getAllFbAccountDetail(item.ProfileId);
                            if (arrfbProfile.FbUserId != null)
                            {
                                arrfbPrfile.Add(arrfbProfile);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                    }
                    //fbpId = fbpId.Substring(0, fbpId.Length - 1);

                    //List<FacebookAccount> arrfbProfile = objFbRepo.getAllFbAccountDetail(fbpId);

                    //ArrayList arrfbProfile = fbAccRepo.getAllFacebookPagesOfUser(user.Id);
                    spandiv.InnerHtml = "from " + DateTime.Now.AddDays(-15).ToShortDateString() + "-" + DateTime.Now.ToShortDateString();
                    try
                    {
                        foreach (FacebookAccount item in arrfbPrfile)
                        {
                            string imgPath = "http://graph.facebook.com/" + item.FbUserId + "/picture";
                            fbUser                 = fbUser + "<div  class=\"teitter\"><ul><li><a id=\"facebook_connect\" onclick='getProfilefbGraph(\"" + item.FbUserId + "\",\"" + item.FbUserName + "\",\"" + imgPath + "\",\"" + item.AccessToken + "\")'><span style=\"float:left;margin: 3px 0 0 5px;\" >" + item.FbUserName + "</span></a></li></ul></div>";
                            fbProfileId            = item.FbUserId;
                            Session["fbprofileId"] = fbProfileId;
                            divPageName.InnerHtml  = item.FbUserName;
                            fbProfileImg.Src       = "http://graph.facebook.com/" + item.FbUserId + "/picture";
                            strfbAccess            = item.AccessToken;
                            Session["acstknfnpg"]  = strfbAccess;
                        }
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                    }
                    if (arrfbPrfile.Count > 0)
                    {
                        try
                        {
                            getAllGroupsOnHome.InnerHtml = fbUser;
                            strFbAgeArray     = fbiHelper.getLikesByGenderAge(fbProfileId, 15);
                            strPageImpression = fbiHelper.getPageImressions(fbProfileId, 15);
                            strLocationArray  = fbiHelper.getLocationInsight(fbProfileId, 15);
                            strstoriesArray   = fbiHelper.getStoriesCount(fbProfileId, 15);
                            //divpost.InnerHtml = fbiHelper.getPostDetails(fbProfileId, user.Id, 15);
                            likeunlikedate = objfbstatsHelper.getlikeUnlike(fbProfileId, 15);

                            FacebookClient fb = new FacebookClient();
                            fb.AccessToken = strfbAccess;

                            dynamic pagelikes = fb.Get(fbProfileId);
                            divPageLikes.InnerHtml = pagelikes.likes.ToString() + " Total Likes " + pagelikes.talking_about_count + " People talking about this.";
                            spanTalking.InnerHtml  = pagelikes.talking_about_count.ToString();

                            string fanpost = PageFeed(strfbAccess, fbProfileId);
                            divpost.InnerHtml = fanpost;
                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex.Message);
                        }
                    }
                }
            }
            catch (Exception Err)
            {
                logger.Error(Err.Message);
                Response.Write(Err.Message);
            }
        }