public void GetFollowersAgeWise(int days) { try { SocioBoard.Domain.User user = (User)Session["LoggedUser"]; TwitterStatsRepository objtwtStatsRepo = new TwitterStatsRepository(); object arrTwtStats = objtwtStatsRepo.getFollowersAgeCount(user.Id, days); if (arrTwtStats != null) { string[] arr = ((IEnumerable)arrTwtStats).Cast <object>().Select(x => x.ToString()).ToArray(); for (int i = 0; i < arr.Count(); i++) { strTwtAgeArray += arr[i] + ","; } strTwtAgeArray = "[" + strTwtAgeArray.Substring(0, strTwtAgeArray.Length - 1) + "]"; } else { strTwtAgeArray = "[0,0,0,0,0,0,0]"; } //strTwtArray += "]"; } catch (Exception Err) { strTwtAgeArray = "[0,0,0,0,0,0,0]"; //Response.Write(Err.Message.ToString()); } }
public void getFollowFollowersMonth() { SocioBoard.Domain.User user = (User)Session["LoggedUser"]; TwitterStatsRepository objtwtStatsRepo = new TwitterStatsRepository(); ArrayList objtwtffMonth = objtwtStatsRepo.getFollowerFollowingCountMonth(user.Id); string[,] arrMon = new string[12, 3]; for (int i = 0; i < objtwtffMonth.Count; i++) { string month = string.Empty; string monfollower = string.Empty; string monfollowing = string.Empty; string[] arr = new string[1]; try { arr = ((IEnumerable)objtwtffMonth[i]).Cast <object>().Select(x => x.ToString()).ToArray(); int m = int.Parse(arr[2].ToString()) - 1; arrMon[m, 2] = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(int.Parse(arr[2].ToString())); arrMon[m, 0] = arr[0]; arrMon[m, 1] = arr[1]; } catch (Exception Err) { } } for (int r = 0; r < 12; r++) { if (arrMon[r, 2] == null) { arrMon[r, 2] = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(r + 1); arrMon[r, 0] = "0"; arrMon[r, 1] = "0"; } } for (int j = 0; j < 12; j++) { strMonth = strMonth + "'" + arrMon[j, 2] + "',"; strFollowerMonth += arrMon[j, 0] + ","; strFollowingMonth += arrMon[j, 1] + ","; } strFollowerMonth = "[" + strFollowerMonth.Substring(0, strFollowerMonth.Length - 1) + "]"; strFollowingMonth = "[" + strFollowingMonth.Substring(0, strFollowingMonth.Length - 1) + "]"; strMonth = "[" + strMonth.Substring(0, strMonth.Length - 1) + "]"; }
public void getTwitterStats(TwitterAccount twitterAccount) { TwitterStatsRepository objTwtstats = new TwitterStatsRepository(); TwitterMessageRepository objTweetMsgRepo = new TwitterMessageRepository(); TwitterStats objStats = new TwitterStats(); Random rNum = new Random(); objStats.Id = Guid.NewGuid(); objStats.TwitterId = twitterAccount.TwitterUserId; objStats.UserId = twitterAccount.UserId; objStats.FollowingCount = twitterAccount.FollowingCount; objStats.FollowerCount = twitterAccount.FollowersCount; objStats.Age1820 = rNum.Next(twitterAccount.FollowersCount); objStats.Age2124 = rNum.Next(twitterAccount.FollowersCount); objStats.Age2534 = rNum.Next(twitterAccount.FollowersCount); objStats.Age3544 = rNum.Next(twitterAccount.FollowersCount); objStats.Age4554 = rNum.Next(twitterAccount.FollowersCount); objStats.Age5564 = rNum.Next(twitterAccount.FollowersCount); objStats.Age65 = rNum.Next(twitterAccount.FollowersCount); int replies = objTweetMsgRepo.getRepliesCount(twitterAccount.UserId, twitterAccount.TwitterUserId); int retweets = objTweetMsgRepo.getRetweetCount(twitterAccount.UserId, twitterAccount.TwitterUserId); if (twitterAccount.FollowersCount != 0) { objStats.Engagement = (replies + retweets) / twitterAccount.FollowersCount; } else { objStats.Engagement = 0; } // objStats.Influence= // objStats.Engagement= objStats.EntryDate = DateTime.Now; if (!objTwtstats.checkTwitterStatsExists(twitterAccount.TwitterUserId, twitterAccount.UserId)) { objTwtstats.addTwitterStats(objStats); } }
public string GetFollowersAgeWise(User user, int days) { string strTwtAgeArray = string.Empty; try { TwitterStatsRepository objtwtStatsRepo = new TwitterStatsRepository(); object arrTwtStats = objtwtStatsRepo.getFollowersAgeCount(user.Id, days); string[] arr = ((IEnumerable)arrTwtStats).Cast <object>().Select(x => x.ToString()).ToArray(); strTwtAgeArray = "0,"; for (int i = 0; i < arr.Count(); i++) { strTwtAgeArray += arr[i] + ","; } strTwtAgeArray = strTwtAgeArray.Substring(0, strTwtAgeArray.Length - 1); //strTwtArray += "]"; } catch (Exception Err) { Console.Write(Err.Message.ToString()); } return(strTwtAgeArray); }
public void getNewFollowers(int days) { try { SocioBoard.Domain.User user = (User)Session["LoggedUser"]; TwitterStatsRepository objtwtStatsRepo = new TwitterStatsRepository(); ArrayList arrTwtStats = objtwtStatsRepo.getAllTwitterStatsOfUser(user.Id, days); strTwtArray = "["; int intdays = 1; int NewTweet_Count = 0; foreach (var item in arrTwtStats) { Array temp = (Array)item; strTwtArray += (temp.GetValue(4)) + ","; //spanTwtFollowers.InnerHtml = temp.GetValue(4).ToString(); //hTwtFollowers.InnerHtml = temp.GetValue(4).ToString(); NewTweet_Count += Convert.ToInt16(temp.GetValue(4)); } spanTwtFollowers.InnerHtml = NewTweet_Count.ToString(); hTwtFollowers.InnerHtml = NewTweet_Count.ToString(); if (intdays < 7) { for (int j = 0; j < 7 - intdays; j++) { strTwtArray = strTwtArray + "0,"; } } strTwtArray = strTwtArray.Substring(0, strTwtArray.Length - 1) + "]"; // strTwtArray += "]"; } catch (Exception Err) { Response.Write(Err.Message.ToString()); } }
public void getTwitterStats(Domain.Socioboard.Domain.TwitterAccount twitterAccount) { //TwitterStatsRepository objTwtstats = new TwitterStatsRepository(); TwitterStatsRepository objTwtstats = new TwitterStatsRepository(); TwitterMessageRepository objTweetMsgRepo = new TwitterMessageRepository(); //TwitterStats objStats = new TwitterStats(); Domain.Socioboard.Domain.TwitterStats objStats = new Domain.Socioboard.Domain.TwitterStats(); Random rNum = new Random(); objStats.Id = Guid.NewGuid(); objStats.TwitterId = twitterAccount.TwitterUserId; objStats.UserId = twitterAccount.UserId; objStats.FollowingCount = twitterAccount.FollowingCount; objStats.FollowerCount = twitterAccount.FollowersCount; objStats.Age1820 = rNum.Next(twitterAccount.FollowersCount); objStats.Age2124 = rNum.Next(twitterAccount.FollowersCount); objStats.Age2534 = rNum.Next(twitterAccount.FollowersCount); objStats.Age3544 = rNum.Next(twitterAccount.FollowersCount); objStats.Age4554 = rNum.Next(twitterAccount.FollowersCount); objStats.Age5564 = rNum.Next(twitterAccount.FollowersCount); objStats.Age65 = rNum.Next(twitterAccount.FollowersCount); int replies = objTweetMsgRepo.getRepliesCount(twitterAccount.UserId, twitterAccount.TwitterUserId); int retweets = objTweetMsgRepo.getRetweetCount(twitterAccount.UserId, twitterAccount.TwitterUserId); if (twitterAccount.FollowersCount != 0) objStats.Engagement = (replies + retweets) / twitterAccount.FollowersCount; else objStats.Engagement = 0; objStats.EntryDate = DateTime.Now; if (!objTwtstats.checkTwitterStatsExists(twitterAccount.TwitterUserId, twitterAccount.UserId, objStats.FollowerCount, objStats.FollowingCount)) objTwtstats.addTwitterStats(objStats); }
public string getNewFollowing(string profileId, int days) { string strTwtFollowing = string.Empty; int strTwtFollowing1 = 0; int strnewTwtFollowing = 0; try { TwitterStatsRepository objtwtStatsRepo = new TwitterStatsRepository(); ArrayList arrTwtStats = objtwtStatsRepo.getTwitterStatsByIdDay(profileId, days); ArrayList arrTwtBeforestats = objtwtStatsRepo.getTwitterStatsByIdbeforeDay(profileId, days); if (arrTwtBeforestats.Count == 0) { ArrayList arrTwtBeforestat = objtwtStatsRepo.getTwitterStByIdbeforeDay(profileId, days); Array temp1 = (Array)arrTwtBeforestat[0]; strnewTwtFollowing = Convert.ToInt16(temp1.GetValue(3)); } else { Array temp = (Array)arrTwtBeforestats[0]; strnewTwtFollowing = Convert.ToInt16(temp.GetValue(3)); } try { Array temp2 = (Array)arrTwtStats[0]; strTwtFollowing1 = Convert.ToInt16(temp2.GetValue(3)); } catch (Exception Err) { Console.Write(Err.Message.ToString()); } strTwtFollowing1 = (strTwtFollowing1 - strnewTwtFollowing); if (strTwtFollowing1 > 0) { strTwtFollowing1 = strTwtFollowing1; } else { strTwtFollowing1 = 0; } strTwtFollowing = (strTwtFollowing1.ToString()) + ","; string str = string.Empty; if (arrTwtStats.Count < 7) { for (int i = 0; i < 7 - arrTwtStats.Count; i++) { str += "0,"; } } strTwtFollowing = str + strTwtFollowing; strTwtFollowing = strTwtFollowing.Substring(0, strTwtFollowing.Length - 1); } catch (Exception Err) { Console.Write(Err.Message.ToString()); } return(strTwtFollowing); }
/// <summary> /// /// </summary> private void getTwitterUserProfile() { var requestToken = (String)Request.QueryString["oauth_token"]; var requestSecret = (String)Session["requestSecret"]; var requestVerifier = (String)Request.QueryString["oauth_verifier"]; OAuth.AccessToken = requestToken; OAuth.AccessTokenSecret = requestVerifier; OAuth.AccessTokenGet(requestToken, requestVerifier); JArray profile = userinfo.Get_Users_LookUp_ByScreenName(OAuth, OAuth.TwitterScreenName); User user = (User)Session["LoggedUser"]; SocialProfilesRepository socioprofilerepo = new SocialProfilesRepository(); SocialProfile socioprofile = new SocialProfile(); #region for managing referrals ManageReferrals(OAuth); #endregion foreach (var item in profile) { try { twitterAccount.FollowingCount = Convert.ToInt32(item["friends_count"].ToString()); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { twitterAccount.FollowersCount = Convert.ToInt32(item["followers_count"].ToString()); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } twitterAccount.Id = Guid.NewGuid(); twitterAccount.IsActive = true; twitterAccount.OAuthSecret = OAuth.AccessTokenSecret; twitterAccount.OAuthToken = OAuth.AccessToken; try { twitterAccount.ProfileImageUrl = item["profile_image_url"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { twitterAccount.ProfileUrl = string.Empty; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { twitterAccount.TwitterUserId = item["id_str"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception er) { try { twitterAccount.TwitterUserId = item["id"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception err) { Console.WriteLine(err.StackTrace); } Console.WriteLine(er.StackTrace); } try { twitterAccount.TwitterScreenName = item["screen_name"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } twitterAccount.UserId = user.Id; socioprofile.Id = Guid.NewGuid(); socioprofile.ProfileDate = DateTime.Now; socioprofile.ProfileId = twitterAccount.TwitterUserId; socioprofile.ProfileType = "twitter"; socioprofile.UserId = user.Id; if (HttpContext.Current.Session["login"] != null) { if (HttpContext.Current.Session["login"].ToString().Equals("twitter")) { User usr = new User(); UserRepository userrepo = new UserRepository(); Registration regObject = new Registration(); usr.AccountType = "free"; usr.CreateDate = DateTime.Now; usr.ExpiryDate = DateTime.Now.AddMonths(1); usr.Id = Guid.NewGuid(); usr.UserName = twitterAccount.TwitterName; usr.Password = regObject.MD5Hash(twitterAccount.TwitterName); usr.EmailId = ""; usr.UserStatus = 1; if (!userrepo.IsUserExist(usr.EmailId)) { UserRepository.Add(usr); } } } TwitterStatsRepository objTwtstats = new TwitterStatsRepository(); TwitterStats objStats = new TwitterStats(); Random rNum = new Random(); objStats.Id = Guid.NewGuid(); objStats.TwitterId = twitterAccount.TwitterUserId; objStats.UserId = user.Id; objStats.FollowingCount = twitterAccount.FollowingCount; objStats.FollowerCount = twitterAccount.FollowersCount; objStats.Age1820 = rNum.Next(twitterAccount.FollowersCount); objStats.Age2124 = rNum.Next(twitterAccount.FollowersCount); objStats.Age2534 = rNum.Next(twitterAccount.FollowersCount); objStats.Age3544 = rNum.Next(twitterAccount.FollowersCount); objStats.Age4554 = rNum.Next(twitterAccount.FollowersCount); objStats.Age5564 = rNum.Next(twitterAccount.FollowersCount); objStats.Age65 = rNum.Next(twitterAccount.FollowersCount); objStats.EntryDate = DateTime.Now; if (!objTwtstats.checkTwitterStatsExists(twitterAccount.TwitterUserId, user.Id)) { objTwtstats.addTwitterStats(objStats); } if (!twtrepo.checkTwitterUserExists(twitterAccount.TwitterUserId, user.Id)) { twtrepo.addTwitterkUser(twitterAccount); if (!socioprofilerepo.checkUserProfileExist(socioprofile)) { socioprofilerepo.addNewProfileForUser(socioprofile); GroupRepository objGroupRepository = new GroupRepository(); SocioBoard.Domain.Team team = (SocioBoard.Domain.Team)HttpContext.Current.Session["GroupName"]; Groups lstDetails = objGroupRepository.getGroupName(team.GroupId); if (lstDetails.GroupName == "Socioboard") { TeamMemberProfileRepository objTeamMemberProfileRepository = new TeamMemberProfileRepository(); TeamMemberProfile teammemberprofile = new TeamMemberProfile(); teammemberprofile.Id = Guid.NewGuid(); teammemberprofile.TeamId = team.Id; teammemberprofile.ProfileId = twitterAccount.TwitterUserId; teammemberprofile.ProfileType = "twitter"; teammemberprofile.StatusUpdateDate = DateTime.Now; objTeamMemberProfileRepository.addNewTeamMember(teammemberprofile); } } else { socioprofilerepo.updateSocialProfile(socioprofile); } } else { HttpContext.Current.Session["alreadyexist"] = twitterAccount; twtrepo.updateTwitterUser(twitterAccount); TwitterMessageRepository twtmsgreponew = new TwitterMessageRepository(); twtmsgreponew.updateScreenName(twitterAccount.TwitterUserId, twitterAccount.TwitterScreenName); if (!socioprofilerepo.checkUserProfileExist(socioprofile)) { socioprofilerepo.addNewProfileForUser(socioprofile); } else { socioprofilerepo.updateSocialProfile(socioprofile); } } if (Session["UserAndGroupsForTwitter"] != null) { if (Session["UserAndGroupsForTwitter"].ToString() == "twitter") { try { if (Session["GroupName"] != null) { Groups group = (Groups)Session["GroupName"]; GroupProfile groupprofile = new GroupProfile(); GroupProfileRepository groupprofilerepo = new GroupProfileRepository(); groupprofile.Id = Guid.NewGuid(); groupprofile.ProfileId = socioprofile.ProfileId; groupprofile.ProfileType = "twitter"; groupprofile.GroupOwnerId = user.Id; groupprofile.EntryDate = DateTime.Now; groupprofile.GroupId = group.Id; if (!groupprofilerepo.checkGroupProfileExists(user.Id, group.Id, groupprofile.ProfileId)) { groupprofilerepo.AddGroupProfile(groupprofile); } } } catch (Exception e) { Console.WriteLine(e.StackTrace); } } } } }
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 string DeleteAllUsersByCreateDate(string date) { int i = 0; int count = 0; UserRepository objUserRepository = new UserRepository(); List <User> lstuser = objUserRepository.GetAllUsersByCreateDate(date); ArchiveMessageRepository objArchiveMessageRepository = new ArchiveMessageRepository(); DiscoverySearchRepository objDiscoverySearchRepository = new DiscoverySearchRepository(); DraftsRepository objDraftsRepository = new DraftsRepository(); FacebookAccountRepository objFacebookAccountRepository = new FacebookAccountRepository(); FacebookFeedRepository objFacebookFeedRepository = new FacebookFeedRepository(); FacebookInsightPostStatsRepository objFacebookInsightPostStatsRepository = new FacebookInsightPostStatsRepository(); FacebookInsightStatsRepository objFacebookInsightStatsRepository = new FacebookInsightStatsRepository(); FacebookMessageRepository objFacebookMessageRepository = new FacebookMessageRepository(); FacebookStatsRepository objFacebookStatsRepository = new FacebookStatsRepository(); GoogleAnalyticsAccountRepository objGoogleAnalyticsAccountRepository = new GoogleAnalyticsAccountRepository(); GoogleAnalyticsStatsRepository objGoogleAnalyticsStatsRepository = new GoogleAnalyticsStatsRepository(); GooglePlusAccountRepository objGooglePlusAccountRepository = new GooglePlusAccountRepository(); GooglePlusActivitiesRepository objGooglePlusActivitiesRepository = new GooglePlusActivitiesRepository(); GroupProfileRepository objGroupProfileRepository = new GroupProfileRepository(); GroupRepository objGroupRepository = new GroupRepository(); InstagramAccountRepository objInstagramAccountRepository = new InstagramAccountRepository(); InstagramCommentRepository objInstagramCommentRepository = new InstagramCommentRepository(); InstagramFeedRepository objInstagramFeedRepository = new InstagramFeedRepository(); LinkedInAccountRepository objLinkedInAccountRepository = new LinkedInAccountRepository(); LinkedInFeedRepository objLinkedInFeedRepository = new LinkedInFeedRepository(); LogRepository objLogRepository = new LogRepository(); RssFeedsRepository objRssFeedsRepository = new RssFeedsRepository(); RssReaderRepository objRssReaderRepository = new RssReaderRepository(); ScheduledMessageRepository objScheduledMessageRepository = new ScheduledMessageRepository(); SocialProfilesRepository objSocialProfilesRepository = new SocialProfilesRepository(); TaskCommentRepository objTaskCommentRepository = new TaskCommentRepository(); TaskRepository objTaskRepository = new TaskRepository(); TeamRepository objTeamRepository = new TeamRepository(); TeamMemberProfileRepository objTeamMemberProfileRepository = new TeamMemberProfileRepository(); TwitterAccountRepository objTwitterAccountRepository = new TwitterAccountRepository(); TwitterDirectMessageRepository objTwitterDirectMessageRepository = new TwitterDirectMessageRepository(); TwitterFeedRepository objTwitterFeedRepository = new TwitterFeedRepository(); TwitterMessageRepository objTwitterMessageRepository = new TwitterMessageRepository(); TwitterStatsRepository objTwitterStatsRepository = new TwitterStatsRepository(); UserActivationRepository objUserActivationRepository = new UserActivationRepository(); UserPackageRelationRepository objUserPackageRelationRepository = new UserPackageRelationRepository(); count = lstuser.Count(); foreach (var item in lstuser) { i++; try { if (item.EmailId == "*****@*****.**" || item.EmailId == "*****@*****.**" || item.EmailId == "*****@*****.**" || item.EmailId == "*****@*****.**" || item.EmailId == "*****@*****.**" || item.EmailId == "*****@*****.**" || item.EmailId == "*****@*****.**" || item.EmailId == "*****@*****.**" || item.EmailId == "*****@*****.**" || item.EmailId == "*****@*****.**") { } else { objArchiveMessageRepository.DeleteArchiveMessageByUserid(item.Id); objDiscoverySearchRepository.DeleteDiscoverySearchByUserid(item.Id); objDraftsRepository.DeleteDraftsByUserid(item.Id); objFacebookAccountRepository.DeleteFacebookAccountByUserid(item.Id); objFacebookFeedRepository.DeleteFacebookFeedByUserid(item.Id); objFacebookInsightPostStatsRepository.DeleteFacebookInsightPostStatsByUserid(item.Id); objFacebookInsightStatsRepository.DeleteFacebookInsightStatsByUserid(item.Id); objFacebookMessageRepository.DeleteFacebookMessageByUserid(item.Id); objFacebookStatsRepository.DeleteFacebookStatsByUserid(item.Id); objGoogleAnalyticsAccountRepository.DeleteGoogleAnalyticsAccountByUserid(item.Id); objGoogleAnalyticsStatsRepository.DeleteGoogleAnalyticsStatsByUserid(item.Id); objGooglePlusAccountRepository.DeleteGooglePlusAccountByUserid(item.Id); objGooglePlusActivitiesRepository.DeleteGooglePlusActivitiesByUserid(item.Id); objGroupProfileRepository.DeleteGroupProfileByUserid(item.Id); objGroupRepository.DeleteGroupsByUserid(item.Id); objInstagramAccountRepository.DeleteInstagramAccountByUserid(item.Id); objInstagramCommentRepository.DeleteInstagramCommentByUserid(item.Id); objInstagramFeedRepository.DeleteInstagramFeedByUserid(item.Id); objLinkedInAccountRepository.DeleteLinkedInAccountByUserid(item.Id); objLinkedInFeedRepository.DeleteLinkedInFeedByUserid(item.Id); objLogRepository.DeleteLogByUserid(item.Id); objRssFeedsRepository.DeleteRssFeedsByUserid(item.Id); objRssReaderRepository.DeleteRssReaderByUserid(item.Id); objScheduledMessageRepository.DeleteScheduledMessageByUserid(item.Id); objSocialProfilesRepository.DeleteSocialProfileByUserid(item.Id); objTaskCommentRepository.DeleteTaskCommentByUserid(item.Id); objTaskRepository.DeleteTasksByUserid(item.Id); objTeamRepository.DeleteTeamByUserid(item.Id); objTeamMemberProfileRepository.DeleteTeamMemberProfileByUserid(item.Id); objTwitterAccountRepository.DeleteTwitterAccountByUserid(item.Id); objTwitterDirectMessageRepository.DeleteTwitterDirectMessagesByUserid(item.Id); objTwitterFeedRepository.DeleteTwitterFeedByUserid(item.Id); objTwitterMessageRepository.DeleteTwitterMessageByUserid(item.Id); objTwitterStatsRepository.DeleteTwitterStatsByUserid(item.Id); objUserActivationRepository.DeleteUserActivationByUserid(item.Id); objUserPackageRelationRepository.DeleteuserPackageRelationByUserid(item.Id); objUserRepository.DeleteUserByUserid(item.Id); } } catch (Exception ex) { Console.WriteLine(ex.Message); } } return(i + " " + count); }
public void getgrphData(int days) { try { SocioBoard.Domain.User user = (User)Session["LoggedUser"]; FacebookAccountRepository objfb = new FacebookAccountRepository(); TwitterMessageRepository objtwttatsRepo = new TwitterMessageRepository(); ArrayList alstfb = objfb.getFbMessageStats(user.Id, days); ArrayList alstTwt = objtwttatsRepo.gettwtMessageStats(user.Id, days); strArray = "["; int _spanIncoming = 0; for (int i = 0; i < 7; i++) { string strTwtCnt = string.Empty; string strFbCnt = string.Empty; if (alstTwt.Count <= i) { strTwtCnt = "0"; } else { strTwtCnt = alstTwt[i].ToString(); } if (alstfb.Count <= i) { strFbCnt = "0"; } else { strFbCnt = alstfb[i].ToString(); } strArray = strArray + "[" + strFbCnt + "," + strTwtCnt + "],"; //spanIncoming.InnerHtml = (int.Parse(strTwtCnt) + int.Parse(strFbCnt)).ToString(); _spanIncoming = (int.Parse(strTwtCnt) + int.Parse(strFbCnt)); } spanIncoming.InnerHtml = _spanIncoming.ToString(); strArray = strArray.Substring(0, strArray.Length - 1) + "]"; ArrayList alstTwtFeed = objtwttatsRepo.gettwtFeedsStats(user.Id, days); ArrayList alstFBFeed = objfb.getFbFeedsStats(user.Id, days); strSentArray = "["; int _spanSent = 0; if (alstFBFeed.Count > 0 && alstTwtFeed.Count > 0) { int alstSentCount = 0; for (int i = 0; i < 7; i++) { string strTwtFeedCnt = string.Empty; string strFbFeedCnt = string.Empty; if (alstTwtFeed.Count <= i) { strTwtFeedCnt = "0"; } else { strTwtFeedCnt = alstTwtFeed[i].ToString(); } if (alstFBFeed.Count <= i) { strFbFeedCnt = "0"; } else { strFbFeedCnt = alstFBFeed[i].ToString(); } strSentArray = strSentArray + "[" + strFbFeedCnt + "," + strTwtFeedCnt + "],"; //spanSent.InnerHtml = (int.Parse(strFbFeedCnt) + int.Parse(strTwtFeedCnt)).ToString(); _spanSent = (int.Parse(strFbFeedCnt) + int.Parse(strTwtFeedCnt)); } spanSent.InnerHtml = (_spanSent).ToString(); } if (alstFBFeed.Count == 0 || alstTwtFeed.Count == 0) { for (int i = 0; i < 7; i++) { strSentArray += strSentArray + "[0,0],"; } } strSentArray = strSentArray.Substring(0, strSentArray.Length - 1) + "]"; TwitterStatsRepository objtwtStatsRepo = new TwitterStatsRepository(); ArrayList alstEng = objtwtStatsRepo.getAllTwitterStatsOfUser(user.Id, days); int ii = 1; strEng = "["; foreach (var item in alstEng) { Array temp = (Array)item; strEng = strEng + "{ x: new Date(2012, " + ii + ", " + ii + "), y:" + temp.GetValue(7) + "},"; ii++; } if (alstEng.Count == 0) { for (int i = 0; i < 10; i++) { strEng = strEng + "{ x: new Date(2012, " + ii + ", " + ii + "), y:0},"; } } strEng = strEng.Substring(0, strEng.Length - 1) + "]"; hmsgsent.InnerHtml = alstTwtFeed.Count.ToString(); hretweet.InnerHtml = objtwttatsRepo.getUserRetweetCount(user.Id).ToString(); } catch (Exception Err) { Response.Write(Err.StackTrace); } }