public void AuthenticateFacebook(object sender, EventArgs e) { try { GroupRepository objGroupRepository = new GroupRepository(); SocioBoard.Domain.Team team = (SocioBoard.Domain.Team)Session["GroupName"]; Groups lstDetails = objGroupRepository.getGroupName(team.GroupId); try { int profilecount = (int)Session["ProfileCount"]; int totalaccount = (int)Session["TotalAccount"]; if (lstDetails.GroupName == "Socioboard") { if (profilecount < totalaccount) { Session["fbSocial"] = "a"; fb_account.HRef = "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,user_groups,offline_access,publish_actions,manage_pages&client_id=" + ConfigurationManager.AppSettings["ClientId"] + "&redirect_uri=" + ConfigurationManager.AppSettings["RedirectUrl"] + "&response_type=code"; //fb_account.HRef = "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"; // fb_cont.HRef = fb_account.HRef; Response.Redirect(fb_account.HRef); } else { // Response.Write("<script>SimpleMessageAlert('Change the Plan to Add More Accounts');</script>"); ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Change the Plan to Add More Accounts');", true); } } } catch (Exception ex) { logger.Error(ex.Message); } } catch (Exception ex) { logger.Error(ex.Message); } }
private void GetAccessToken() { try { User user = (User)Session["LoggedUser"]; if (user == null) { Response.Redirect("Default.aspx"); } oAuthTumbler requestHelper = new oAuthTumbler(); string code = Request.QueryString["oauth_verifier"]; string AccessTokenResponse = string.Empty; try { AccessTokenResponse = requestHelper.GetAccessToken(oAuthTumbler.TumblrToken, code); } catch (Exception ex) { logger.Error("AccessTokenResponse: " + ex.Message); logger.Error("AccessTokenResponse: " + ex.StackTrace); } string[] tokens = AccessTokenResponse.Split('&'); //extract access token & secret from response string accessToken = tokens[0].Split('=')[1]; string accessTokenSecret = tokens[1].Split('=')[1]; KeyValuePair<string, string> LoginDetails = new KeyValuePair<string, string>(accessToken, accessTokenSecret); string sstr = string.Empty; try { sstr = oAuthTumbler.OAuthData(Globals.UsersDashboardUrl, "GET", LoginDetails.Key, LoginDetails.Value, null); } catch (Exception ex) { logger.Error("sstr: " + ex.Message); logger.Error("sstr: " + ex.StackTrace); } JObject profile = new JObject(); try { profile = JObject.Parse(oAuthTumbler.OAuthData(Globals.UsersInfoUrl, "GET", LoginDetails.Key, LoginDetails.Value, null)); } catch (Exception ex) { logger.Error("profile: " + ex.Message); logger.Error("profile: " + ex.StackTrace); } JObject UserDashboard = JObject.Parse(oAuthTumbler.OAuthData(Globals.UsersDashboardUrl, "GET", LoginDetails.Key, LoginDetails.Value, null)); TumblrAccount objTumblrAccount = new TumblrAccount(); TumblrAccountRepository objTumblrAccountRepository = new TumblrAccountRepository(); SocialProfile objSocialProfile = new SocialProfile(); SocialProfilesRepository objSocialProfilesRepository = new SocialProfilesRepository(); objSocialProfile.Id = Guid.NewGuid(); objSocialProfile.UserId = user.Id; objSocialProfile.ProfileId = profile["response"]["user"]["name"].ToString(); objSocialProfile.ProfileType = "tumblr"; objSocialProfile.ProfileDate = DateTime.Now; objSocialProfile.ProfileStatus = 1; objTumblrAccount.Id = Guid.NewGuid(); objTumblrAccount.tblrUserName = profile["response"]["user"]["name"].ToString(); objTumblrAccount.UserId = user.Id; objTumblrAccount.tblrAccessToken = accessToken; objTumblrAccount.tblrAccessTokenSecret = accessTokenSecret; objTumblrAccount.tblrProfilePicUrl = profile["response"]["user"]["name"].ToString(); objTumblrAccount.IsActive = 1; if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile)) { objSocialProfilesRepository.addNewProfileForUser(objSocialProfile); if (!objTumblrAccountRepository.checkTubmlrUserExists(objTumblrAccount)) { TumblrAccountRepository.Add(objTumblrAccount); 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 = objTumblrAccount.tblrUserName; teammemberprofile.ProfileType = "tumblr"; teammemberprofile.StatusUpdateDate = DateTime.Now; objTeamMemberProfileRepository.addNewTeamMember(teammemberprofile); } } } else { if (!objTumblrAccountRepository.checkTubmlrUserExists(objTumblrAccount)) { TumblrAccountRepository.Add(objTumblrAccount); } else { Response.Redirect("Home.aspx"); } } JArray objJarray = (JArray)UserDashboard["response"]["posts"]; logger.Error("objJarray: " + objJarray); if (objJarray != null) { logger.Error("objJarray lenght : " + objJarray.Count); } else { logger.Error("objJarray is NULL"); } TumblrFeed objTumblrFeed = new TumblrFeed(); TumblrFeedRepository objTumblrFeedRepository = new TumblrFeedRepository(); foreach (var item in objJarray) { objTumblrFeed.Id = Guid.NewGuid(); objTumblrFeed.UserId = user.Id; try { objTumblrFeed.ProfileId = profile["response"]["user"]["name"].ToString(); logger.Error("objTumblrFeed.ProfileId : " + objTumblrFeed.ProfileId); } catch (Exception ex) { logger.Error(ex.Message); logger.Error(ex.StackTrace); Console.WriteLine(ex.Message); } try { objTumblrFeed.blogname = item["blog_name"].ToString(); } catch (Exception ex) { logger.Error(ex.Message); logger.Error(ex.StackTrace); Console.WriteLine(ex.Message); } try { objTumblrFeed.blogId = item["id"].ToString(); } catch (Exception ex) { logger.Error(ex.Message); logger.Error(ex.StackTrace); Console.WriteLine(ex.Message); } try { objTumblrFeed.blogposturl = item["post_url"].ToString(); } catch (Exception ex) { logger.Error(ex.Message); logger.Error(ex.StackTrace); Console.WriteLine(ex.Message); } try { String result = item["caption"].ToString(); objTumblrFeed.description = Regex.Replace(result, @"<[^>]*>", String.Empty); } catch (Exception ex) { objTumblrFeed.description = null; logger.Error(ex.Message); logger.Error(ex.StackTrace); Console.WriteLine(ex.Message); } try { objTumblrFeed.slug = item["slug"].ToString(); } catch (Exception ex) { logger.Error(ex.Message); logger.Error(ex.StackTrace); Console.WriteLine(ex.Message); } try { objTumblrFeed.type = item["type"].ToString(); } catch (Exception ex) { logger.Error(ex.Message); logger.Error(ex.StackTrace); Console.WriteLine(ex.Message); } try { string test = item["date"].ToString(); DateTime dt; if (test.Contains("GMT")) { test = test.Replace("GMT", "").Trim().ToString(); dt = Convert.ToDateTime(test); } else { test = test.Replace("GMT", "").Trim().ToString(); dt = Convert.ToDateTime(test); } objTumblrFeed.date = dt; } catch (Exception ex) { logger.Error(ex.Message); logger.Error(ex.StackTrace); Console.WriteLine(ex.Message); } try { objTumblrFeed.reblogkey = item["reblog_key"].ToString(); } catch (Exception ex) { logger.Error(ex.Message); logger.Error(ex.StackTrace); Console.WriteLine(ex.Message); } try { string str = item["liked"].ToString(); if (str == "False") { objTumblrFeed.liked = 0; } else { objTumblrFeed.liked = 1; } } catch (Exception ex) { logger.Error(ex.Message); logger.Error(ex.StackTrace); Console.WriteLine(ex.Message); } try { string str = item["followed"].ToString(); if (str == "false") { objTumblrFeed.followed = 0; } else { objTumblrFeed.followed = 1; } // objTumblrDashboard.followed = Convert.ToInt16(item["followed"]); } catch (Exception ex) { logger.Error(ex.Message); logger.Error(ex.StackTrace); Console.WriteLine(ex.Message); } try { objTumblrFeed.canreply = Convert.ToInt16(item["can_reply"]); } catch (Exception ex) { logger.Error(ex.Message); logger.Error(ex.StackTrace); Console.WriteLine(ex.Message); } try { objTumblrFeed.sourceurl = item["source_url"].ToString(); } catch (Exception ex) { logger.Error(ex.Message); logger.Error(ex.StackTrace); Console.WriteLine(ex.Message); } try { objTumblrFeed.sourcetitle = item["source_title"].ToString(); } catch (Exception ex) { logger.Error(ex.Message); logger.Error(ex.StackTrace); Console.WriteLine(ex.Message); } try { JArray asdasd12 = (JArray)item["photos"]; foreach (var item1 in asdasd12) { objTumblrFeed.imageurl = item1["original_size"]["url"].ToString(); } } catch (Exception ex) { logger.Error(ex.Message); logger.Error(ex.StackTrace); Console.WriteLine(ex.Message); } try { objTumblrFeed.videourl = item["permalink_url"].ToString(); } catch (Exception ex) { logger.Error(ex.Message); logger.Error(ex.StackTrace); Console.WriteLine(ex.Message); } try { string str = item["note_count"].ToString(); objTumblrFeed.notes = Convert.ToInt16(str); } catch (Exception ex) { logger.Error(ex.Message); logger.Error(ex.StackTrace); Console.WriteLine(ex.Message); } objTumblrFeed.timestamp = DateTime.Now; if (!objTumblrFeedRepository.checkTumblrMessageExists(objTumblrFeed)) { try { logger.Error("objTumblrFeedRepository.checkTumblrMessageExists " + objTumblrAccount.Id); TumblrFeedRepository.Add(objTumblrFeed); } catch (Exception ex) { logger.Error("Exception : objTumblrFeedRepository.checkTumblrMessageExists " + objTumblrAccount.Id); logger.Error(ex.Message); logger.Error(ex.StackTrace); } } } Response.Redirect("Home.aspx"); } catch (Exception ex) { logger.Error(ex.Message); logger.Error(ex.StackTrace); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { User user = (User)Session["LoggedUser"]; #region for You can use only 30 days as Unpaid User 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"); } } Session["GreaterThan30Days"] = null; #endregion SocioBoard.Domain.Team team = (SocioBoard.Domain.Team)Session["GroupName"]; BusinessSettingRepository objBsnsSettingRepo = new BusinessSettingRepository(); SocioBoard.Domain.BusinessSetting objbsns = objBsnsSettingRepo.IsAssignTaskEnable(team.GroupId); if (team.UserId == user.Id) { GroupRepository objGroupRepo = new GroupRepository(); Groups grps = objGroupRepo.getGroupName(team.GroupId); txtBusnName.Text = grps.GroupName; memberName.Text = user.UserName; if (objbsns.AssigningTasks == true) { rbEnableAssignTask.Checked = true; rbDisableAssignTask.Checked = false; } else { rbEnableAssignTask.Checked = false; rbDisableAssignTask.Checked = true; } if (objbsns.TaskNotification == true) { rbEnableTaskNoti.Checked = true; rbDisableTaskNoti.Checked = false; } else { rbEnableTaskNoti.Checked = false; rbDisableTaskNoti.Checked = true; } } else { GroupRepository objGroupRepo = new GroupRepository(); Groups grps = objGroupRepo.getGroupName(team.GroupId); txtBusnName.Text = grps.GroupName; memberName.Text = user.UserName; txtBusnName.Enabled = false; btnSubmit.Enabled = false; rbDisableAssignTask.Enabled = false; rbEnableAssignTask.Enabled = false; rbDisableTaskNoti.Enabled = false; rbEnableTaskNoti.Enabled = false; //rbDoNotShowPromt.Enabled = false; //rbShowPromt.Enabled = false; //rbFbTimeLine.Enabled = false; //rbFbWooSuitePhotos.Enabled = false; if (objbsns.AssigningTasks == true) { rbEnableAssignTask.Checked = true; rbDisableAssignTask.Checked = false; } else { rbEnableAssignTask.Checked = false; rbDisableAssignTask.Checked = true; } if (objbsns.TaskNotification == true) { rbEnableTaskNoti.Checked = true; rbDisableTaskNoti.Checked = false; } else { rbEnableTaskNoti.Checked = false; rbDisableTaskNoti.Checked = true; } } } }
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; SocioBoard.Domain.User user = (User)Session["LoggedUser"]; 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"]; } 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; 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); 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; 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 AuthenticateLinkedin(object sender, EventArgs e) { try { GroupRepository objGroupRepository = new GroupRepository(); SocioBoard.Domain.Team team = (SocioBoard.Domain.Team)Session["GroupName"]; Groups lstDetails = objGroupRepository.getGroupName(team.GroupId); try { int profilecount = (int)Session["ProfileCount"]; int totalaccount = (int)Session["TotalAccount"]; if (lstDetails.GroupName == "Socioboard") { if (profilecount < totalaccount) { oAuthLinkedIn Linkedin_oauth = new oAuthLinkedIn(); string authLink = Linkedin_oauth.AuthorizationLinkGet(); Session["reuqestToken"] = Linkedin_oauth.Token; Session["reuqestTokenSecret"] = Linkedin_oauth.TokenSecret; this.LinkedInLink.HRef = ""; this.LinkedInLink.HRef = authLink; Response.Redirect(authLink); } else { //Response.Write("<script>SimpleMessageAlert('Change the Plan to Add More Accounts');</script>"); ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Change the Plan to Add More Accounts');", true); } } } catch (Exception ex) { logger.Error(ex.Message); } } catch (Exception ex) { logger.Error(ex.Message); } }
public void AuthenticateTwitter(object sender, EventArgs e) { try { GroupRepository objGroupRepository = new GroupRepository(); SocioBoard.Domain.Team team = (SocioBoard.Domain.Team)Session["GroupName"]; Groups lstDetails = objGroupRepository.getGroupName(team.GroupId); try { int profilecount = (int)Session["ProfileCount"]; int totalaccount = (int)Session["TotalAccount"]; if (lstDetails.GroupName == "Socioboard") { if (profilecount < totalaccount) { TwitterHelper twthelper = new TwitterHelper(); string twtredirecturl = twthelper.TwitterRedirect(ConfigurationManager.AppSettings["consumerKey"], ConfigurationManager.AppSettings["consumerSecret"], ConfigurationManager.AppSettings["callbackurl"]); Response.Redirect(twtredirecturl); } else { //Response.Write("<script>SimpleMessageAlert('Change the Plan to Add More Accounts');</script>"); ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Change the Plan to Add More Accounts');", true); } } } catch (Exception ex) { logger.Error(ex.Message); } } catch (Exception ex) { logger.Error(ex.Message); } }
public void ProcessRequest() { //experimental code selected index changed of dropdown if (!string.IsNullOrEmpty(Request.QueryString["groupsselection"])) { SocioBoard.Domain.User user = (SocioBoard.Domain.User)Session["LoggedUser"]; string selectedValue = Request.QueryString["groupsselection"]; TeamRepository objTeamRepository = new TeamRepository(); Team lstDetails = objTeamRepository.getAllGroupsDetails(user.EmailId.ToString(), Guid.Parse(selectedValue),user.Id); Session["GroupName"] = lstDetails; Session["groupcheck"] = selectedValue; SocioBoard.Domain.Team team = (SocioBoard.Domain.Team)Session["GroupName"]; Response.Write(selectedValue); return; } SocialProfilesRepository socio = new SocialProfilesRepository(); List<SocialProfile> alstsocioprofiles = new List<SocialProfile>(); TeamRepository objTeamRepo = new TeamRepository(); if (!string.IsNullOrEmpty(Request.QueryString["op"])) { SocioBoard.Domain.User user = (SocioBoard.Domain.User)Session["LoggedUser"]; Team team = (SocioBoard.Domain.Team)Session["GroupName"]; TeamRepository objTeamRepository = new TeamRepository(); TeamMemberProfileRepository objTeamMemberProfileRepository = new TeamMemberProfileRepository(); GroupRepository objGroupRepository = new GroupRepository(); if (Request.QueryString["op"] == "social_connectivity") { List<TeamMemberProfile> allprofiles = objTeamMemberProfileRepository.getAllTeamMemberProfilesOfTeam(team.Id); string profiles = string.Empty; profiles += "<ul class=\"rsidebar-profile\">"; foreach (TeamMemberProfile item in allprofiles) { try { if (item.ProfileType == "facebook") { try { FacebookAccountRepository facerepo = new FacebookAccountRepository(); FacebookAccount faceaccount = facerepo.getFacebookAccountDetailsById(item.ProfileId); if (faceaccount != null) { profiles += "<li id=\"so_" + item.ProfileId + "\"><div id=\"" + item.ProfileId + "\" class=\"userpictiny\"><div class=\"delet_icon\" onclick=\"confirmDel('" + item.ProfileId + "','" + faceaccount.Type + "','fb');\"></div><a href=\"http://www.facebook.com/" + faceaccount.FbUserId + "\" target=\"_blank\"><img src=\"http://graph.facebook.com/" + item.ProfileId + "/picture?type=small\" height=\"48\" width=\"48\" alt=\"\" title=\""+ faceaccount.FbUserName + "\" /></a>" + "<a href=\"#\" class=\"userurlpic\" title=\"\"><img src=\"../Contents/img/fb_icon.png\" width=\"16\" height=\"16\" alt=\"\"></a></div></li>"; } } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } } else if (item.ProfileType == "youtube") { try { YoutubeAccountRepository facerepo = new YoutubeAccountRepository(); YoutubeAccount youtube = facerepo.getYoutubeAccountDetailsById(item.ProfileId); if (youtube != null) { profiles += "<li id=\"so_" + item.ProfileId + "\"><div id=\"" + item.ProfileId + "\" class=\"userpictiny\"><div class=\"delet_icon\" onclick=\"confirmDel('" + item.ProfileId + "','youtube','youtube');\"></div><a href=\"https://plus.google.com/" + youtube.Ytuserid + "\" target=\"_blank\"><img src=\"" + youtube.Ytprofileimage + " height=\"48\" width=\"48\" alt=\"\" title=\"" + youtube.Ytusername + "\" /></a>" + "<a href=\"#\" class=\"userurlpic\" title=\"\"><img src=\"../Contents/img/youtube.png\" width=\"16\" height=\"16\" alt=\"\"></a></div></li>"; } } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } } else if (item.ProfileType == "tumblr") { try { TumblrAccountRepository tumbrepo = new TumblrAccountRepository(); TumblrAccount tumblraccount = tumbrepo.getTumblrAccountDetailsById(item.ProfileId); if (tumblraccount != null) { //if (tumblraccount!=null) //{ // profiles += "<li id=\"so_" + item.ProfileId + "\"><div id=\"" + item.ProfileId + "\" class=\"userpictiny\"><div class=\"delet_icon\" onClick=\"confirmDel('" + item.ProfileId + "','tumblr','tumblr')\"></div><a href=\"http://twitter.com/" + tumblraccount.tblrUserName + "\" target=\"_blank\"><img src=\"http://api.tumblr.com/v2/blog/" + tumblraccount.tblrUserName + ".tumblr.com/avatar\" height=\"48\" width=\"48\" alt=\"\" title=\"" + tumblraccount.tblrUserName + "\" /></a>" + // "<a href=\"#\" class=\"userurlpic\" title=\"\"><img src=\"../Contents/img/tumblr.png\" width=\"16\" height=\"16\" alt=\"\"></a></div></li>"; //} //else //{ profiles += "<li id=\"so_" + item.ProfileId + "\"><div id=\"" + item.ProfileId + "\" class=\"userpictiny\"><div class=\"delet_icon\" onClick=\"confirmDel('" + item.ProfileId + "','tumblr','tumblr')\"></div><a href=\"http://" + tumblraccount.tblrUserName + ".tumblr.com\" target=\"_blank\"><img src=\"http://api.tumblr.com/v2/blog/" + tumblraccount.tblrUserName + ".tumblr.com/avatar\" height=\"48\" width=\"48\" alt=\"\" title=\"" + tumblraccount.tblrUserName + "\" /></a>" + "<a href=\"#\" class=\"userurlpic\" title=\"\"><img src=\"../Contents/img/tumblr.png\" width=\"16\" height=\"16\" alt=\"\"></a></div></li>"; // } } } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } } else if (item.ProfileType == "twitter") { try { TwitterAccountRepository twtrepo = new TwitterAccountRepository(); SocioBoard.Domain.TwitterAccount twtaccount = twtrepo.getUserInformation(item.ProfileId); if (twtaccount != null) { profiles += "<li id=\"so_" + item.ProfileId + "\"><div id=\"" + item.ProfileId + "\" class=\"userpictiny\"><div class=\"delet_icon\" onClick=\"confirmDel('" + item.ProfileId + "','twt','twt')\"></div><a href=\"http://twitter.com/" + twtaccount.TwitterScreenName + "\" target=\"_blank\"><img src=\"" + twtaccount.ProfileImageUrl + "\" height=\"48\" width=\"48\" alt=\"\" title=\"" + twtaccount.TwitterScreenName + "\" /></a>" + "<a href=\"#\" class=\"userurlpic\" title=\"\"><img src=\"../Contents/img/twticon.png\" width=\"16\" height=\"16\" alt=\"\"></a></div></li>"; } } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } } else if (item.ProfileType == "linkedin") { try { LinkedInAccountRepository liRepo = new LinkedInAccountRepository(); string access = string.Empty, tokenSecrate = string.Empty, LdprofileName = string.Empty, LdPreofilePic = string.Empty; LinkedInAccount liaccount = liRepo.getUserInformation(item.ProfileId); if (liaccount != null) { if (!string.IsNullOrEmpty(liaccount.ProfileImageUrl)) { LdPreofilePic = liaccount.ProfileImageUrl; } else { LdPreofilePic = "../../Contents/img/blank_img.png"; } profiles += "<li id=\"so_" + item.ProfileId + "\"><div id=\"" + item.ProfileId + "\" class=\"userpictiny\"><div class=\"delet_icon\" onClick=\"confirmDel('" + item.ProfileId + "','linkedin')\"></div><a href=\"" + liaccount.ProfileUrl + "\" target=\"_blank\"><img src=\"" + LdPreofilePic + "\" height=\"48\" width=\"48\" alt=\"\" title=\"" + liaccount.LinkedinUserName + "\" /></a>" + "<a href=\"#\" class=\"userurlpic\" title=\"\"><img src=\"../Contents/img/link_icon.png\" width=\"16\" height=\"16\" alt=\"\"></a></div></li>"; } } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } } else if (item.ProfileType == "instagram") { try { InstagramAccountRepository objInsAccRepo = new InstagramAccountRepository(); InstagramAccount objInsAcc = objInsAccRepo.getInstagramAccountDetailsById(item.ProfileId); string accessToken = string.Empty; if (objInsAcc != null) { profiles += "<li id=\"so_" + item.ProfileId + "\"><div id=\"" + item.ProfileId + "\" class=\"userpictiny\"><div class=\"delet_icon\" onClick=\"confirmDel('" + item.ProfileId + "','instagram')\"></div><a href=\"http://instagram.com/" + objInsAcc.InsUserName + "\" target=\"_blank\"><img src=\"" + objInsAcc.ProfileUrl + "\" height=\"48\" width=\"48\" alt=\"\" title=\"" + objInsAcc.InsUserName + "\" /></a>" + "<a href=\"#\" class=\"userurlpic\" title=\"\"><img src=\"../Contents/img/instagram_24X24.png\" width=\"16\" height=\"16\" alt=\"\"></a></div></li>"; } } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } } else if (item.ProfileType == "googleplus") { try { //GooglePlusAccountRepository objgpAccRepo = new GooglePlusAccountRepository(); //GooglePlusAccount objgpAcc = objgpAccRepo.getGooglePlusAccountDetailsById(item.ProfileId, user.Id); //string accessToken = string.Empty; //profiles += "<li id=\"so_" + item.ProfileId + "\"><div id=\"" + item.ProfileId + "\" class=\"userpictiny\"><div class=\"delet_icon\" onClick=\"confirmDel('" + item.ProfileId + "','googleplus')\"></div><a href=\"http://plus.google.com/" + item.ProfileId + "\" target=\"_blank\"><img src=\"" + objgpAcc.GpProfileImage + "\" height=\"48\" width=\"48\" alt=\"\" title=\"" + objgpAcc.GpUserName + "\" /></a>" + // "<a href=\"#\" class=\"userurlpic\" title=\"\"><img src=\"../Contents/img/google_plus.png\" width=\"16\" height=\"16\" alt=\"\"></a></div></li>"; } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } } else if (item.ProfileType == "googleanalytics") { try { //GoogleAnalyticsAccountRepository objgaAccRepo = new GoogleAnalyticsAccountRepository(); //GoogleAnalyticsAccount objgaAcc = objgaAccRepo.getGoogelAnalyticsAccountHomeDetailsById(user.Id,item.ProfileId); //string accessToken = string.Empty; //profiles += "<li id=\"so_" + item.ProfileId + "\"><div id=\"" + item.ProfileId + "\" class=\"userpictiny\"><div class=\"delet_icon\" onClick=\"confirmDel('" + item.ProfileId + "','googleanalytics')\"></div><a href=\"http://plus.google.com/" + item.ProfileId + "\" target=\"_blank\"><img src=\"../Contents/img/google_analytics.png\" height=\"48\" width=\"48\" alt=\"\" title=\"" + objgaAcc.GaAccountName + "\" /></a>" + // "<a href=\"#\" class=\"userurlpic\" title=\"\"><img src=\"\" width=\"16\" height=\"16\" alt=\"\"></a></div></li>"; } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } } } catch (Exception ex) { logger.Error(ex.Message); } } profiles += "</ul>"; Response.Write(profiles); } else if (Request.QueryString["op"] == "woodrafts") { string message = string.Empty; try { DraftsRepository draftsRepository = new DraftsRepository(); List<Drafts> lstDrafts = draftsRepository.getAllDrafts(team.GroupId); string profurl = string.Empty; if (string.IsNullOrEmpty(user.ProfileUrl)) { profurl = "../Contents/img/blank_img.png"; } else { profurl = user.ProfileUrl; } if (lstDrafts.Count != 0) { foreach (Drafts item in lstDrafts) { try { message += "<section class=\"section\" style=\"width:648px;\">" + "<div class=\"js-task-cont read\"><section class=\"task-owner\">" + "<img width=\"32\" height=\"32\" border=\"0\" class=\"avatar\" src=\"../Contents/img/task_pin.png\">" + // "<img width=\"32\" height=\"32\" border=\"0\" class=\"avatar\" src=\"" + profurl + "\" />" + "</section><section class=\"task-activity third\" style=\"width: 19.6%;\"><p>" + user.UserName + "</p><div>" + item.CreatedDate + " </div><p>" + //"</p></section><section style=\"margin-right: 6px; height: auto; width: 35%;\" class=\"task-message font-13 third\"><a onclick=\"writemessage(this.innerHTML);\" class=\"tip_left\">" + item.Message + "</a></section>" + "</p></section><section style=\"margin-right: 6px; height: auto; width: 31%;\" class=\"task-message font-13 third\"><span class=\"tip_left\">" + gethtmlfromstring(item.Message) + "</span></section>" + "<div class=\"userpictiny\" style=\"height:70px; margin-top: 0;\"><img alt=\"\" src=\"" + profurl + "\" />" + "</div>" + "<a class=\"small_remove icon publish_delete\" href=\"#\" style=\"top: 7px; float: right; margin-top: 13px; margin-right: 10px;\" title=\"Delete\" onclick=\"deleteDraftMessage('" + item.Id + "')\"></a>" + "<section style=\"margin-top: 18px; width: 45px; margin-right: 17px;\" class=\"task-status\"><div class=\"ui_light floating task_status_change\"><a class=\"ui-sproutmenu\" href=\"#nogo\">" + "<span onclick=\"editDraftsMessage('" + item.Id + "','" + item.Message + "');\" class=\"ui-sproutmenu-status\">" + "<img class=\"edit_button\" src=\"../Contents/img/icon_edit.png\" alt=\"\" />" + "</span>" + "</a></div></section></div></section>"; } catch (Exception ex) { logger.Error(ex.Message); } } } else { message += "<div style=\"margin-left: 2%; margin-top: 3%;\">No Messages in Drafts</div>"; } } catch (Exception ex) { logger.Error(ex.Message); } Response.Write(message); } else if (Request.QueryString["op"] == "savedrafts") { try { string message = Request.QueryString["message"]; message = Request.Form["messagee"]; Drafts d = new Drafts(); d.CreatedDate = DateTime.Now; d.Message = message; d.ModifiedDate = DateTime.Now; d.UserId = user.Id; d.GroupId = team.GroupId; d.Id = Guid.NewGuid(); DraftsRepository dRepo = new DraftsRepository(); if (!dRepo.IsDraftsMessageExist(user.Id, message)) { dRepo.AddDrafts(d); } } catch (Exception ex) { logger.Error(ex.Message); } Response.Write("added successfully"); } else if (Request.QueryString["op"] == "midsnaps") { try { Random rNum = new Random(); string loadtype = Request.QueryString["loadtype"]; string midsnaps = string.Empty; if (loadtype == "load") profilelimit = 0; if (profilelimit != -1) { // Team lstDetails = objTeamRepository.getAllDetails(team.GroupId, team.EmailId); List<TeamMemberProfile> alst = objTeamMemberProfileRepository.getAllTeamMemberProfilesOfTeam(team.Id); // ArrayList alst = socio.getLimitProfilesOfUser(user.Id, profilelimit); if (alst.Count == 0) profilelimit = -1; else if (profilelimit == 0) //profilelimit += 2; profilelimit += 6; else profilelimit += 6; midsnaps += "<div class=\"row-fluid\" >"; if (loadtype == "load") { AdsRepository objAdsRepo = new AdsRepository(); ArrayList lstads = objAdsRepo.getAdsForHome(); int i = 0; if (lstads.Count <= 1) { if (user.PaymentStatus.ToUpper() == "PAID") { midsnaps += ""; } } else { foreach (var item in lstads) { Array temp = (Array)item; i++; if (temp != null) { if (i == 2) { if (user.AccountType == "Paid") { midsnaps += "<div class=\"span4 rounder recpro\"><button data-dismiss=\"alert\" class=\"close pull-right\" type=\"button\">×</button>" + "<a href=\"#\"><img src=\"" + temp.GetValue(2).ToString() + "\" alt=\"\" style=\"width:246px;height:331px\"></a></div>"; } } } } } } foreach (TeamMemberProfile item in alst) { if (item.ProfileType == "facebook") { try { FacebookAccountRepository fbrepo = new FacebookAccountRepository(); FacebookFeedRepository facefeedrepo = new FacebookFeedRepository(); List<FacebookFeed> fbmsgs = facefeedrepo.getAllFacebookUserFeeds(item.ProfileId); FacebookAccount fbaccount = fbrepo.getFacebookAccountDetailsById(item.ProfileId); midsnaps += "<div id=\"mid_" + item.ProfileId + "\" style=\"height:213px;\" class=\"span4 rounder recpro\"><div class=\"concotop\">" + "<div onclick=\"detailsdiscoveryfacebook('" + fbaccount.FbUserId + "');\" class=\"userpictiny\"><img width=\"56\" height=\"56\" title=\"" + fbaccount.FbUserName + "\" alt=\"\" src=\"http://graph.facebook.com/" + item.ProfileId + "/picture?type=small\"\">" + "<a title=\"\" class=\"userurlpic\" href=\"#\"><img alt=\"\" src=\"../Contents/img/fb_icon.png\" width=\"16\" height=\"16\"></a></div>" + "<div onclick=\"detailsdiscoveryfacebook('" + fbaccount.FbUserId + "');\" class=\"useraccname\">" + getsortpofilename(fbaccount.FbUserName) + "</div><div class=\"usercounter\">" + "<div class=\"userfoll\">" + fbaccount.Friends; if (fbaccount.Type == "page") { midsnaps += "<span><b style=\"font-size: 13px;\">Fans</b></span>"; } else { midsnaps += "<span><b style=\"font-size: 13px;\">Friends</b></span>"; } midsnaps += "</div>" + "<div class=\"userppd\">" + Math.Round(rNum.NextDouble(), 2) + "<span>Avg. Post <br> Per Day</span></div></div><h5>Recent message</h5></div>" + "<div class=\"concoteng\"> <ul class=\"mess\">"; if (fbmsgs.Count != 0) { int msgcount = 0; foreach (FacebookFeed child in fbmsgs) { string mess = string.Empty; if (msgcount < 2) { if (child.FeedDescription.Length > 40) { mess = child.FeedDescription.Substring(0, 39); mess = mess + "..........."; } else { mess = child.FeedDescription; } midsnaps += "<li><div class=\"messpic\"><img title=\"\" alt=\"\" src=\"http://graph.facebook.com/" + child.FromId + "/picture?type=small\"></div>" + "<div class=\"messtext\">" + mess + "</div></li>"; } else { break; } msgcount++; } } else { midsnaps += "<strong>No messages were found within the past few days.</strong> \"Messages will be displayed once there is activity in this date range.\""; } midsnaps += "</ul></div></div>"; } catch (Exception ex) { logger.Error(ex.Message); } } else if (item.ProfileType == "googleplus") { } else if (item.ProfileType == "twitter") { TwitterAccountRepository twtrepo = new TwitterAccountRepository(); SocioBoard.Domain.TwitterAccount twtaccount = twtrepo.getUserInformation(item.ProfileId); TwitterMessageRepository twtmsgrepo = new TwitterMessageRepository(); List<TwitterMessage> lsttwtmsgs = twtmsgrepo.getAllTwitterMessagesOfProfile(item.ProfileId); int tweetcount = 0; midsnaps += "<div id=\"mid_" + item.ProfileId + "\" style=\"height:213px;\" class=\"span4 rounder recpro\"><div class=\"concotop\">" + "<div onclick=\"detailsdiscoverytwitter('" + item.ProfileId + "');\" class=\"userpictiny\"><img width=\"56\" height=\"56\" title=\"" + twtaccount.TwitterScreenName + "\" alt=\"\" src=\"" + twtaccount.ProfileImageUrl + "\">" + "<a title=\"\" class=\"userurlpic\" href=\"#\"><img alt=\"\" src=\"../Contents/img/twticon.png\" width=\"16\" height=\"16\"></a></div>" + "<div onclick=\"detailsdiscoverytwitter('" + twtaccount.TwitterUserId + "');\" class=\"useraccname\">" + getsortpofilename(twtaccount.TwitterScreenName) + "</div><div class=\"usercounter\">" + "<div class=\"userfoll\">" + twtaccount.FollowersCount + "<span><b style=\"font-size: 13px;\">Followers</b></span></div>" + "<div class=\"userppd\">" + Math.Round(rNum.NextDouble(), 2) + "<span>Avg. tweet <br> Per Day</span></div></div><h5>Recent message</h5></div>" + "<div class=\"concoteng\"> <ul class=\"mess\">"; try { if (lsttwtmsgs.Count == 0) { midsnaps += "<strong>No messages were found within the past few days.</strong> \"Messages will be displayed once there is activity in this date range.\""; } else { foreach (TwitterMessage msg in lsttwtmsgs) { if (tweetcount < 2) { try { string ms = string.Empty; if (msg.TwitterMsg.Length > 20) { ms = msg.TwitterMsg.Substring(0, 20) + "..."; } else { ms = msg.TwitterMsg; } midsnaps += "<li><div class=\"messpic\"><img title=\"\" alt=\"\" src=\"" + msg.FromProfileUrl + "\"></div>" + "<div class=\"messtext\">" + ms + "</div></li>"; } catch (Exception ex) { Console.WriteLine(ex.Message); } } else { break; } tweetcount++; } } } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } midsnaps += "</ul></div></div>"; } else if (item.ProfileType == "tumblr") { try { string PostCount = string.Empty; string LikesCount = string.Empty; TumblrAccountRepository tumblrrepo = new TumblrAccountRepository(); SocioBoard.Domain.TumblrAccount tumblrccount = tumblrrepo.getTumblrAccountDetailsById(item.ProfileId); TumblrFeedRepository tumblrfeedrepo = new TumblrFeedRepository(); List<TumblrFeed> lsttumblrmsgs = tumblrfeedrepo.getFeedOfProfile(item.ProfileId); BlogInfo objBlogInfo = new BlogInfo(); string objData = objBlogInfo.getTumblrUserInfo(tumblrccount.tblrUserName); //string objFollower = objBlogInfo.getTumblrUserfollower(tumblrccount.tblrUserName); string[] words = objData.Split('&'); PostCount = words[1].ToString(); LikesCount = words[0].ToString(); midsnaps += "<div id=\"mid_" + item.ProfileId + "\" style=\"height:213px;\" class=\"span4 rounder recpro\"><div class=\"concotop\">" + "<a href=\"http://"+ item.ProfileId + ".tumblr.com\" target=\"_blank\"><div class=\"userpictiny\"><img width=\"56\" height=\"56\" title=\"" + tumblrccount.tblrUserName + "\" alt=\"\" src=\"http://api.tumblr.com/v2/blog/" + tumblrccount.tblrUserName + ".tumblr.com/avatar\"></a>" + "<a title=\"\" class=\"userurlpic\" href=\"#\"><img alt=\"\" src=\"../Contents/img/tumblr.png\" width=\"16\" height=\"16\"></a></div>" + "<a href=\"http://" + item.ProfileId + ".tumblr.com\" target=\"_blank\"><div class=\"useraccname\">" + getsortpofilename(tumblrccount.tblrUserName) + "</div></a></div>" + "<div class=\"concoteng\"><div class=\"pillow_fade\">" + " <div class=\"fb_notifications\">" + "<ul class=\"user-stats\"> " + "<li><div class=\"photo_stat\"> post</div> <div class=\"number-stat\">" + PostCount + "</div></li>" + "<li><div class=\"photo_stat\">likes</div><div class=\"number-stat\">" + LikesCount + "</div></li>" + "</ul></div></div></div></div>"; } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } } else if (item.ProfileType == "youtube") { try { YoutubeAccountRepository ytrepo = new YoutubeAccountRepository(); YoutubeChannelRepository objYoutubeChannelRepository=new YoutubeChannelRepository(); SocioBoard.Domain.YoutubeAccount ytacount = ytrepo.getYoutubeAccountDetailsById(item.ProfileId); YoutubeChannel objYoutubeChannel = objYoutubeChannelRepository.getYoutubeChannelDetailsById(item.ProfileId); if (string.IsNullOrEmpty(ytacount.Ytprofileimage)) { ytacount.Ytprofileimage = "../../Contents/img/blank_img.png"; } midsnaps += "<div id=\"mid_" + item.ProfileId + "\" style=\"height:213px;\" class=\"span4 rounder recpro\"><div class=\"concotop\">" + "<a href=\"#\" target=\"_blank\"><div class=\"userpictiny\"><img width=\"56\" height=\"56\" title=\"" + ytacount.Ytuserid + "\" alt=\"\" src=\"" + ytacount.Ytprofileimage + "\"></a>" + "<a title=\"\" class=\"userurlpic\" href=\"#\"><img alt=\"\" src=\"../Contents/img/youtube.png\" width=\"16\" height=\"16\"></a></div>" + "<a href=\"#\" target=\"_blank\"><div class=\"useraccname\">" + getsortpofilename(ytacount.Ytusername) + "</div></a></div>" + "<div class=\"concoteng\"><div class=\"pillow_fade\">" + " <div class=\"fb_notifications\">" + "<ul class=\"user-stats\"> " + "<li><div class=\"photo_stat\">Total View</div> <div class=\"number-stat\">" + objYoutubeChannel.ViewCount + "</div></li>" + "<li><div class=\"photo_stat\">Total Subcriber</div><div class=\"number-stat\">" + objYoutubeChannel.SubscriberCount + "</div></li>" + "<li><div class=\"photo_stat\">Total Video</div><div class=\"number-stat\">" + objYoutubeChannel.VideoCount + "</div></li>" + "</ul></div></div></div></div>"; } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } } else if (item.ProfileType == "linkedin") { try { string access = string.Empty, tokenSecrate = string.Empty, LdprofileName = string.Empty, LdPreofilePic = string.Empty; LinkedInAccountRepository objLiRepo = new LinkedInAccountRepository(); LinkedInFeedRepository objliFeedRepo = new LinkedInFeedRepository(); LinkedInAccount liAccount = objLiRepo.getUserInformation(item.ProfileId); LinkedInFeedRepository lifeedrepo = new LinkedInFeedRepository(); List<LinkedInFeed> alstliaccount = lifeedrepo.getAllLinkedInFeedsOfProfile(item.ProfileId); if (liAccount != null) { LdprofileName = liAccount.LinkedinUserName; LdPreofilePic = liAccount.ProfileImageUrl; } if (string.IsNullOrEmpty(LdPreofilePic)) { LdPreofilePic = "../../Contents/img/blank_img.png"; } int linkedinConcount = 0; try { linkedinConcount = liAccount.Connections; } catch (Exception ex) { Console.WriteLine(ex.Message); } midsnaps += "<div id=\"mid_" + item.ProfileId + "\" style=\"height:213px;\" class=\"span4 rounder recpro\"><div class=\"concotop\">" + "<div class=\"userpictiny\"><a target=\"_blank\" href=\"" + liAccount.ProfileUrl + "\"><img width=\"56\" height=\"56\" title=\"" + LdprofileName + "\" alt=\"\" src=\"" + LdPreofilePic + "\"></a>" + "<a title=\"\" class=\"userurlpic\" href=\"#\"><img alt=\"\" src=\"../Contents/img/link_icon.png\" width=\"16\" height=\"16\"></a></div>" + "<div class=\"useraccname\">" + getsortpofilename(LdprofileName) + "</div><div class=\"usercounter\">" + "<div class=\"userfoll\">" + linkedinConcount + "<span>Connections</span></div>" + "<div class=\"userppd\">" + Math.Round(rNum.NextDouble(), 2) + "<span>Avg. Post <br> Per Day</span></div></div><h5>Recent message</h5></div>" + "<div class=\"concoteng\"> <ul class=\"mess\">"; int link = 0; if (alstliaccount.Count == 0) { midsnaps += "<strong>No messages were found within the past 14 days.</strong> \"Messages will be displayed once there is activity in this date range.\""; } else { try { foreach (LinkedInFeed liFeed in alstliaccount) { try { if (link < 2) { string ms = string.Empty; if (liFeed.Feeds.Length > 20) { ms = liFeed.Feeds.Substring(0, 20) + "..."; } else { ms = liFeed.Feeds; } midsnaps += "<li><div class=\"messpic\"><img title=\"\" alt=\"\" src=\"" + liFeed.FromPicUrl + "\"></div>" + "<div class=\"messtext\">" + ms + "</div></li>"; link++; } else { break; } } catch (Exception ex) { logger.Error(ex.Message); } } } catch (Exception ex) { logger.Error(ex.Message); } } midsnaps += "</ul></div></div>"; } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } } else if (item.ProfileType == "instagram") { try { InstagramAccountRepository objInsAccRepo = new InstagramAccountRepository(); InstagramAccount objInsAcc = objInsAccRepo.getInstagramAccountDetailsById(item.ProfileId); midsnaps += "<div id=\"mid_" + item.ProfileId + "\" style=\"height:213px;\" class=\"span4 rounder recpro\"><div class=\"concotop\">" + "<a href=\"http://instagram.com/" + objInsAcc.InsUserName + "\" target=\"_blank\"><div class=\"userpictiny\"><img width=\"56\" height=\"56\" title=\"" + objInsAcc.InsUserName + "\" alt=\"\" src=\"" + objInsAcc.ProfileUrl + "\"></a>" + "<a title=\"\" class=\"userurlpic\" href=\"#\"><img alt=\"\" src=\"../Contents/img/instagram_24X24.png\" width=\"16\" height=\"16\"></a></div>" + "<a href=\"http://instagram.com/" + objInsAcc.InsUserName + "\" target=\"_blank\"><div class=\"useraccname\">" + getsortpofilename(objInsAcc.InsUserName) + "</div></a></div>" + "<div class=\"concoteng\"><div class=\"pillow_fade\">" + " <div class=\"fb_notifications\">" + "<ul class=\"user-stats\"> " + "<li><div class=\"photo_stat\"> photos</div> <div class=\"number-stat\">" + objInsAcc.TotalImages + "</div></li>" + "<li><div class=\"photo_stat\">following</div><div class=\"number-stat\">" + objInsAcc.Followers + "</div></li>" + "<li><div class=\"photo_stat\">followers</div><div class=\"number-stat\">" + objInsAcc.FollowedBy + "</div></li>" + "</ul></div></div></div></div>"; } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } } else if (item.ProfileType == "googleanalytics") { } } midsnaps += "</div>"; Response.Write(midsnaps); } } catch (Exception ex) { logger.Error(ex.Message); } } else if (Request.QueryString["op"] == "accountdelete") { Groups lstDetails = objGroupRepository.getGroupName(team.GroupId); if (lstDetails.GroupName == "Socioboard") { Session["facebooktotalprofiles"] = null; SocialProfilesRepository socioprofilerepo = new SocialProfilesRepository(); string Profiletype = Request.QueryString["profile"]; string profileid = Request.QueryString["profileid"]; if (Profiletype == "fb") { try { FacebookAccountRepository fbrepo = new FacebookAccountRepository(); int delaccFromTeamMemberProfile = objTeamMemberProfileRepository.DeleteTeamMemberProfileByUserid(profileid); int delacc = fbrepo.deleteFacebookUser(profileid, user.Id); if (delacc > 0) { socioprofilerepo.deleteProfile(user.Id, profileid); List<SocialProfile> lstsocioprofile = socioprofilerepo.checkProfileExistsMoreThanOne(profileid); if (lstsocioprofile.Count >= 0) { try { FacebookMessageRepository fbmsgrepo = new FacebookMessageRepository(); fbmsgrepo.deleteAllMessagesOfUser(profileid, user.Id); FacebookFeedRepository fbfeedrepo = new FacebookFeedRepository(); fbfeedrepo.deleteAllFeedsOfUser(profileid, user.Id); FacebookStatsRepository fbstatsrepo = new FacebookStatsRepository(); fbstatsrepo.deleteFacebookStats(profileid, user.Id); ScheduledMessageRepository schedulemsgrepo = new ScheduledMessageRepository(); schedulemsgrepo.deleteMessage(user.Id, profileid); ArchiveMessageRepository archmsgrepo = new ArchiveMessageRepository(); int del = archmsgrepo.DeleteArchiveMessage(user.Id, profileid); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } } } catch (Exception exx) { Console.WriteLine(exx.Message); logger.Error(exx.Message); } } else if (Profiletype == "tumblr") { try { TumblrAccountRepository tumblraccountrepo = new TumblrAccountRepository(); TumblrFeedRepository objTumblrFeedRepository = new TumblrFeedRepository(); int deltwtacc = tumblraccountrepo.deleteTumblrUser(profileid, user.Id); int delaccFromTeamMemberProfile = objTeamMemberProfileRepository.DeleteTeamMemberProfileByUserid(profileid); if (deltwtacc > 0) { try { socioprofilerepo.deleteProfile(user.Id, profileid); objTumblrFeedRepository.DeleteTumblrDataByUserid(user.Id, profileid); ScheduledMessageRepository schedulemsgrepo = new ScheduledMessageRepository(); schedulemsgrepo.deleteMessage(user.Id, profileid); ArchiveMessageRepository archmsgrepo = new ArchiveMessageRepository(); int del = archmsgrepo.DeleteArchiveMessage(user.Id, profileid); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } } catch (Exception ex) { logger.Error(ex.Message); Console.WriteLine(ex.Message); } } else if (Profiletype == "youtube") { try { YoutubeAccountRepository youtubeaccountrepo = new YoutubeAccountRepository(); YoutubeChannelRepository objYoutubeChannelRepository = new YoutubeChannelRepository(); int deltwtacc = youtubeaccountrepo.deleteYoutubeUser(user.Id,profileid); int delaccFromTeamMemberProfile = objTeamMemberProfileRepository.DeleteTeamMemberProfileByUserid(profileid); if (deltwtacc > 0) { socioprofilerepo.deleteProfile(user.Id, profileid); objYoutubeChannelRepository.DeleteProfileDataByUserid(profileid); } } catch (Exception ex) { logger.Error(ex.Message); Console.WriteLine(ex.Message); } } else if (Profiletype == "twt") { try { TwitterAccountRepository twtaccountrepo = new TwitterAccountRepository(); int deltwtacc = twtaccountrepo.deleteTwitterUser(user.Id, profileid); int delaccFromTeamMemberProfile = objTeamMemberProfileRepository.DeleteTeamMemberProfileByUserid(profileid); if (deltwtacc > 0) { socioprofilerepo.deleteProfile(user.Id, profileid); List<SocialProfile> lstsocioprofile = socioprofilerepo.checkProfileExistsMoreThanOne(profileid); if (lstsocioprofile.Count >= 0) { try { TwitterMessageRepository twtmsgrepo = new TwitterMessageRepository(); int d = twtmsgrepo.deleteTwitterMessage(profileid, user.Id); TwitterFeedRepository twtfeedrepo = new TwitterFeedRepository(); int s = twtfeedrepo.deleteTwitterFeed(profileid, user.Id); TwitterStatsRepository twtstatsrepo = new TwitterStatsRepository(); int a = twtstatsrepo.deleteTwitterStats(user.Id, profileid); TwitterDirectMessageRepository twtdirectmsgrepo = new TwitterDirectMessageRepository(); int f = twtdirectmsgrepo.deleteDirectMessage(user.Id, profileid); ScheduledMessageRepository schedulemsgrepo = new ScheduledMessageRepository(); schedulemsgrepo.deleteMessage(user.Id, profileid); ArchiveMessageRepository archmsgrepo = new ArchiveMessageRepository(); int del = archmsgrepo.DeleteArchiveMessage(user.Id, profileid); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } } } catch (Exception ex) { logger.Error(ex.Message); Console.WriteLine(ex.Message); } } else if (Profiletype == "linkedin") { try { LinkedInAccountRepository linkedaccrepo = new LinkedInAccountRepository(); int delaccFromTeamMemberProfile = objTeamMemberProfileRepository.DeleteTeamMemberProfileByUserid(profileid); int dellinacc = linkedaccrepo.deleteLinkedinUser(profileid, user.Id); if (dellinacc > 0) { socioprofilerepo.deleteProfile(user.Id, profileid); List<SocialProfile> lstsocioprofile = socioprofilerepo.checkProfileExistsMoreThanOne(profileid); if (lstsocioprofile.Count >= 0) { try { LinkedInFeedRepository linkedfeedrepo = new LinkedInFeedRepository(); int s = linkedfeedrepo.deleteAllFeedsOfUser(profileid, user.Id); ScheduledMessageRepository schedulemsgrepo = new ScheduledMessageRepository(); schedulemsgrepo.deleteMessage(user.Id, profileid); ArchiveMessageRepository archmsgrepo = new ArchiveMessageRepository(); int del = archmsgrepo.DeleteArchiveMessage(user.Id, profileid); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } } } catch (Exception ex) { logger.Error(ex.Message); } } else if (Profiletype == "instagram") { try { InstagramAccountRepository insaccrepo = new InstagramAccountRepository(); int delaccFromTeamMemberProfile = objTeamMemberProfileRepository.DeleteTeamMemberProfileByUserid(profileid); int insacc = insaccrepo.deleteInstagramUser(profileid, user.Id); if (insacc > 0) { socioprofilerepo.deleteProfile(user.Id, profileid); List<SocialProfile> lstsocioprofile = socioprofilerepo.checkProfileExistsMoreThanOne(profileid); if (lstsocioprofile.Count >= 0) { try { ScheduledMessageRepository schedulemsgrepo = new ScheduledMessageRepository(); schedulemsgrepo.deleteMessage(user.Id, profileid); ArchiveMessageRepository archmsgrepo = new ArchiveMessageRepository(); int del = archmsgrepo.DeleteArchiveMessage(user.Id, profileid); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } } } catch (Exception ex) { logger.Error(ex.Message); } } else if (Profiletype == "googleplus") { try { GooglePlusAccountRepository googleplusaccrepo = new GooglePlusAccountRepository(); int delaccFromTeamMemberProfile = objTeamMemberProfileRepository.DeleteTeamMemberProfileByUserid(profileid); int gplusacc = googleplusaccrepo.deleteGooglePlusUser(profileid, user.Id); if (gplusacc > 0) { socioprofilerepo.deleteProfile(user.Id, profileid); List<SocialProfile> lstsocioprofile = socioprofilerepo.checkProfileExistsMoreThanOne(profileid); if (lstsocioprofile.Count >= 0) { } } } catch (Exception ex) { logger.Error(ex.Message); } } string profiles = string.Empty; profiles += "<div class=\"drop_top\"></div><div class=\"drop_mid\">"; /*facebook users binding*/ FacebookAccountRepository fbprepo = new FacebookAccountRepository(); ArrayList lstfbaccounts = fbprepo.getFacebookAccountsOfUser(user.Id); profiles += "<div class=\"twitte_text\">FACEBOOK</div><div class=\"teitter\"><ul>"; if (lstfbaccounts.Count == 0) { profiles += "<li>No Records Found</li>"; } else { foreach (FacebookAccount fbacc in lstfbaccounts) { profiles += "<li id=\"liid_" + fbacc.FbUserId + "\" onclick=\"composemessage(this.id,'fb')\"><a><img id=\"img_" + fbacc.FbUserId + "\" src=\"../Contents/img/facebook.png\" alt=\"" + fbacc.AccessToken + "\" border=\"none\" width=\"18\" style=\"float:left;\" /><span id=\"composename_" + fbacc.FbUserId + "\" style=\"float:left;margin: 3px 0 0 5px;\">" + fbacc.FbUserName + "</span><span id=\"imgurl_" + fbacc.FbUserId + "\" style=\"display:none;\">http://graph.facebook.com/" + fbacc.FbUserId + "/picture?type=small</span></a></li>"; } } profiles += "</ul> </div>"; /*twitter users binding*/ TwitterAccountRepository twtpaccountrepo = new TwitterAccountRepository(); ArrayList alsttwtaccounts = twtpaccountrepo.getAllTwitterAccountsOfUser(user.Id); profiles += "<div class=\"twitte_text\">TWITTER</div><div class=\"teitter\"><ul>"; if (alsttwtaccounts.Count == 0) { profiles += "<li>No Records Found</li>"; } else { foreach (SocioBoard.Domain.TwitterAccount item in alsttwtaccounts) { profiles += "<li id=\"liid_" + item.TwitterUserId + "\" onclick=\"composemessage(this.id,'twt')\"><a><img id=\"img_" + item.TwitterUserId + "\" src=\"../Contents/img/twitter.png\" alt=\"" + item.OAuthToken + "\" border=\"none\" width=\"18\" style=\"float:left;\" /><span id=\"imgurl_" + item.TwitterUserId + "\" style=\"display:none;\">" + item.ProfileImageUrl + "</span><span id=\"composename_" + item.TwitterUserId + "\" style=\"float:left;margin: 3px 0 0 5px;\">" + item.TwitterScreenName + "</span></a></li>"; } } profiles += "</ul> </div>"; /*linkedinuserbinding*/ LinkedInAccountRepository linkaccountrepo = new LinkedInAccountRepository(); ArrayList alstlinkacc = linkaccountrepo.getAllLinkedinAccountsOfUser(user.Id); profiles += "<div class=\"twitte_text\">LINKEDIN</div><div class=\"teitter\"><ul>"; if (alstlinkacc.Count == 0) { profiles += "<li>No Records Found</li>"; } else { foreach (LinkedInAccount item in alstlinkacc) { string profileurl = string.Empty; if (!string.IsNullOrEmpty(item.ProfileImageUrl)) { profileurl = item.ProfileImageUrl; } else { profileurl = "../../Contents/img/blank_img.png"; } profiles += "<li id=\"liid_" + item.LinkedinUserId + "\" onclick=\"composemessage(this.id,'lin')\"><a><img id=\"img_" + item.LinkedinUserId + "\" src=\"../Contents/img/link.png\" alt=\"" + item.OAuthToken + "\" border=\"none\" width=\"18\" style=\"float:left;\" /><span id=\"imgurl_" + item.LinkedinUserId + "\" style=\"display:none;\">" + profileurl + "</span><span id=\"composename_" + item.LinkedinUserId + "\" style=\"float:left;margin: 3px 0 0 5px;\">" + item.LinkedinUserName + "</span></a></li>"; } } profiles += "</ul> </div>"; Response.Write(RemainingAccount(user)); } } else if (Request.QueryString["op"] == "MasterCompose") { string profiles = string.Empty; string FbprofileId = string.Empty; string TwtprofileId = string.Empty; string TumblrprofileId = string.Empty; string LinkedInprofileId = string.Empty; profiles += "<div class=\"drop_top\"></div><div class=\"drop_mid\">"; try { List<TeamMemberProfile> allprofiles = objTeamMemberProfileRepository.getTeamMemberProfileData(team.Id); foreach (TeamMemberProfile item in allprofiles) { FbprofileId += item.ProfileId + ','; } FbprofileId = FbprofileId.Substring(0, FbprofileId.Length - 1); /*facebook users binding*/ FacebookAccountRepository fbrepo = new FacebookAccountRepository(); List<FacebookAccount> lstfbaccounts = fbrepo.getAllAccountDetail(FbprofileId); profiles += "<div class=\"twitte_text\">FACEBOOK</div><div class=\"teitter\"><ul>"; if (lstfbaccounts.Count == 0) { profiles += "<li>No Records Found</li>"; } else { foreach (FacebookAccount fbacc in lstfbaccounts) { profiles += "<li nwtk='fb' class=\"getAllNetworkProfile\" id=\"liid_" + fbacc.FbUserId + "\" onclick=\"composemessage(this.id,'fb')\"><a><img id=\"img_" + fbacc.FbUserId + "\" src=\"../Contents/img/facebook.png\" alt=\"" + fbacc.AccessToken + "\" border=\"none\" width=\"18\" style=\"float:left;\" /><span id=\"composename_" + fbacc.FbUserId + "\" style=\"float:left;margin: 3px 0 0 5px;\">" + fbacc.FbUserName + "</span><span id=\"imgurl_" + fbacc.FbUserId + "\" style=\"display:none;\">http://graph.facebook.com/" + fbacc.FbUserId + "/picture?type=small</span></a></li>"; } } profiles += "</ul> </div>"; } catch (Exception ex) { logger.Error(ex.Message); } /*tumbler users binding*/ try { List<TeamMemberProfile> allTumblrprofiles = objTeamMemberProfileRepository.getTumblrTeamMemberProfileData(team.Id); foreach (TeamMemberProfile item in allTumblrprofiles) { TumblrprofileId += item.ProfileId + ','; } TumblrprofileId = TumblrprofileId.Substring(0, TumblrprofileId.Length - 1); TumblrAccountRepository tumblrtaccountrepo = new TumblrAccountRepository(); List<TumblrAccount> alsttumblrtaccounts = tumblrtaccountrepo.getAllAccountDetail(TumblrprofileId); profiles += "<div class=\"twitte_text\">TUMBLR</div><div class=\"teitter\"><ul>"; if (alsttumblrtaccounts.Count == 0) { profiles += "<li>No Records Found</li>"; } else { foreach (TumblrAccount item in alsttumblrtaccounts) { profiles += "<li nwtk='tumb' class=\"getAllNetworkProfile\" id=\"liid_" + item.tblrUserName + "\" onclick=\"composemessage(this.id,'tumb')\"><a><img id=\"img_" + item.tblrUserName + "\" src=\"../Contents/img/tumblr.png\" alt=\"" + item.tblrAccessToken + "\" border=\"none\" width=\"18\" style=\"float:left;\" /><span id=\"imgurl_" + item.tblrUserName + "\" style=\"display:none;\">http://api.tumblr.com/v2/blog/" + item.tblrProfilePicUrl + ".tumblr.com/avatar</span><span id=\"composename_" + item.tblrUserName + "\" style=\"float:left;margin: 3px 0 0 5px;\">" + item.tblrUserName + "</span></a></li>"; } } profiles += "</ul> </div>"; } catch (Exception ex) { logger.Error(ex.Message); } /*twitter users binding*/ try { List<TeamMemberProfile> allTwtprofiles = objTeamMemberProfileRepository.getTwtTeamMemberProfileData(team.Id); foreach (TeamMemberProfile item in allTwtprofiles) { TwtprofileId += item.ProfileId + ','; } TwtprofileId = TwtprofileId.Substring(0, TwtprofileId.Length - 1); TwitterAccountRepository twtaccountrepo = new TwitterAccountRepository(); List<TwitterAccount> alsttwtaccounts = twtaccountrepo.getAllAccountDetail(TwtprofileId); profiles += "<div class=\"twitte_text\">TWITTER</div><div class=\"teitter\"><ul>"; if (alsttwtaccounts.Count == 0) { profiles += "<li>No Records Found</li>"; } else { foreach (TwitterAccount item in alsttwtaccounts) { profiles += "<li nwtk='twt' class=\"getAllNetworkProfile\" id=\"liid_" + item.TwitterUserId + "\" onclick=\"composemessage(this.id,'twt')\"><a><img id=\"img_" + item.TwitterUserId + "\" src=\"../Contents/img/twitter.png\" alt=\"" + item.OAuthToken + "\" border=\"none\" width=\"18\" style=\"float:left;\" /><span id=\"imgurl_" + item.TwitterUserId + "\" style=\"display:none;\">" + item.ProfileImageUrl + "</span><span id=\"composename_" + item.TwitterUserId + "\" style=\"float:left;margin: 3px 0 0 5px;\">" + item.TwitterScreenName + "</span></a></li>"; } } profiles += "</ul> </div>"; } catch (Exception ex) { logger.Error(ex.Message); } /*linkedinuserbinding*/ try { List<TeamMemberProfile> allLinkedInprofiles = objTeamMemberProfileRepository.getLinkedInTeamMemberProfileData(team.Id); foreach (TeamMemberProfile item in allLinkedInprofiles) { LinkedInprofileId += item.ProfileId + ','; } LinkedInprofileId = LinkedInprofileId.Substring(0, LinkedInprofileId.Length - 1); LinkedInAccountRepository linkaccountrepo = new LinkedInAccountRepository(); List<LinkedInAccount> alstlinkacc = linkaccountrepo.getAllAccountDetail(LinkedInprofileId); profiles += "<div class=\"twitte_text\">LINKEDIN</div><div class=\"teitter\"><ul>"; if (alstlinkacc.Count == 0) { profiles += "<li>No Records Found</li>"; } else { foreach (LinkedInAccount item in alstlinkacc) { string profileurl = string.Empty; if (!string.IsNullOrEmpty(item.ProfileImageUrl)) { profileurl = item.ProfileImageUrl; } else { profileurl = "../../Contents/img/blank_img.png"; } profiles += "<li nwtk='lin' class=\"getAllNetworkProfile\" id=\"liid_" + item.LinkedinUserId + "\" onclick=\"composemessage(this.id,'lin')\"><a><img id=\"img_" + item.LinkedinUserId + "\" src=\"../Contents/img/link.png\" alt=\"" + item.OAuthToken + "\" border=\"none\" width=\"18\" style=\"float:left;\" /><span id=\"imgurl_" + item.LinkedinUserId + "\" style=\"display:none;\">" + profileurl + "</span><span id=\"composename_" + item.LinkedinUserId + "\" style=\"float:left;margin: 3px 0 0 5px;\">" + item.LinkedinUserName + "</span></a></li>"; } } profiles += "</ul> </div>"; } catch (Exception ex) { logger.Error(ex.Message); } Response.Write(profiles); } //============================================================= else if (Request.QueryString["op"] == "MasterComposesc") { string profiles = string.Empty; string FbprofileId = string.Empty; string TwtprofileId = string.Empty; string LinkedInprofileId = string.Empty; string TumblrprofileId = string.Empty; //if (Session["profilesforcomposemessage"] == null) //{ profiles += "<div class=\"drop_top\"></div><div class=\"drop_mid\">"; try { List<TeamMemberProfile> allprofiles = objTeamMemberProfileRepository.getTeamMemberProfileData(team.Id); foreach (TeamMemberProfile item in allprofiles) { FbprofileId += item.ProfileId + ','; } FbprofileId = FbprofileId.Substring(0, FbprofileId.Length - 1); /*facebook users binding*/ FacebookAccountRepository fbrepo = new FacebookAccountRepository(); List<FacebookAccount> lstfbaccounts = fbrepo.getAllAccountDetail(FbprofileId); profiles += "<div class=\"twitte_text\">FACEBOOK</div><div class=\"teitter\"><ul>"; if (lstfbaccounts.Count == 0) { profiles += "<li>No Records Found</li>"; } else { foreach (FacebookAccount fbacc in lstfbaccounts) { profiles += "<li nwtk='fb' class=\"getAllNetworkProfile\" id=\"liid_" + fbacc.FbUserId + "\" onclick=\"composemessage(this.id,'fb')\"><a><img id=\"img_" + fbacc.FbUserId + "\" src=\"../Contents/img/facebook.png\" alt=\"" + fbacc.AccessToken + "\" border=\"none\" width=\"18\" style=\"float:left;\" /><span id=\"composename_" + fbacc.FbUserId + "\" style=\"float:left;margin: 3px 0 0 5px;\">" + fbacc.FbUserName + "</span><span id=\"imgurl_" + fbacc.FbUserId + "\" style=\"display:none;\">http://graph.facebook.com/" + fbacc.FbUserId + "/picture?type=small</span></a></li>"; } } profiles += "</ul> </div>"; } catch (Exception ex) { logger.Error(ex.Message); } /*tumbler users binding*/ try { List<TeamMemberProfile> allTumblrprofiles = objTeamMemberProfileRepository.getTumblrTeamMemberProfileData(team.Id); foreach (TeamMemberProfile item in allTumblrprofiles) { TumblrprofileId += item.ProfileId + ','; } TumblrprofileId = TumblrprofileId.Substring(0, TumblrprofileId.Length - 1); TumblrAccountRepository tumblrtaccountrepo = new TumblrAccountRepository(); List<TumblrAccount> alsttumblrtaccounts = tumblrtaccountrepo.getAllAccountDetail(TumblrprofileId); profiles += "<div class=\"twitte_text\">TUMBLR</div><div class=\"teitter\"><ul>"; if (alsttumblrtaccounts.Count == 0) { profiles += "<li>No Records Found</li>"; } else { foreach (TumblrAccount item in alsttumblrtaccounts) { profiles += "<li nwtk='twt' class=\"getAllNetworkProfile\" id=\"liid_" + item.tblrUserName + "\" onclick=\"composemessage(this.id,'twt')\"><a><img id=\"img_" + item.tblrUserName + "\" src=\"../Contents/img/twitter.png\" alt=\"" + item.tblrAccessToken + "\" border=\"none\" width=\"18\" style=\"float:left;\" /><span id=\"imgurl_" + item.tblrUserName + "\" style=\"display:none;\">" + item.tblrProfilePicUrl + "</span><span id=\"composename_" + item.tblrUserName + "\" style=\"float:left;margin: 3px 0 0 5px;\">" + item.tblrUserName + "</span></a></li>"; } } profiles += "</ul> </div>"; } catch (Exception ex) { logger.Error(ex.Message); } /*twitter users binding*/ try { List<TeamMemberProfile> allTwtprofiles = objTeamMemberProfileRepository.getTwtTeamMemberProfileData(team.Id); foreach (TeamMemberProfile item in allTwtprofiles) { TwtprofileId += item.ProfileId + ','; } TwtprofileId = TwtprofileId.Substring(0, TwtprofileId.Length - 1); TwitterAccountRepository twtaccountrepo = new TwitterAccountRepository(); List<TwitterAccount> alsttwtaccounts = twtaccountrepo.getAllAccountDetail(TwtprofileId); profiles += "<div class=\"twitte_text\">TWITTER</div><div class=\"teitter\"><ul>"; if (alsttwtaccounts.Count == 0) { profiles += "<li>No Records Found</li>"; } else { foreach (TwitterAccount item in alsttwtaccounts) { profiles += "<li nwtk='twt' class=\"getAllNetworkProfile\" id=\"liid_" + item.TwitterUserId + "\" onclick=\"composemessage(this.id,'twt')\"><a><img id=\"img_" + item.TwitterUserId + "\" src=\"../Contents/img/twitter.png\" alt=\"" + item.OAuthToken + "\" border=\"none\" width=\"18\" style=\"float:left;\" /><span id=\"imgurl_" + item.TwitterUserId + "\" style=\"display:none;\">" + item.ProfileImageUrl + "</span><span id=\"composename_" + item.TwitterUserId + "\" style=\"float:left;margin: 3px 0 0 5px;\">" + item.TwitterScreenName + "</span></a></li>"; } } profiles += "</ul> </div>"; } catch (Exception ex) { logger.Error(ex.Message); } /*linkedinuserbinding*/ try { List<TeamMemberProfile> allLinkedInprofiles = objTeamMemberProfileRepository.getLinkedInTeamMemberProfileData(team.Id); foreach (TeamMemberProfile item in allLinkedInprofiles) { LinkedInprofileId += item.ProfileId + ','; } LinkedInprofileId = LinkedInprofileId.Substring(0, LinkedInprofileId.Length - 1); LinkedInAccountRepository linkaccountrepo = new LinkedInAccountRepository(); List<LinkedInAccount> alstlinkacc = linkaccountrepo.getAllAccountDetail(LinkedInprofileId); profiles += "<div class=\"twitte_text\">LINKEDIN</div><div class=\"teitter\"><ul>"; if (alstlinkacc.Count == 0) { profiles += "<li>No Records Found</li>"; } else { foreach (LinkedInAccount item in alstlinkacc) { string profileurl = string.Empty; if (!string.IsNullOrEmpty(item.ProfileImageUrl)) { profileurl = item.ProfileImageUrl; } else { profileurl = "../../Contents/img/blank_img.png"; } profiles += "<li nwtk='lin' class=\"getAllNetworkProfile\" id=\"liid_" + item.LinkedinUserId + "\" onclick=\"composemessage(this.id,'lin')\"><a><img id=\"img_" + item.LinkedinUserId + "\" src=\"../Contents/img/link.png\" alt=\"" + item.OAuthToken + "\" border=\"none\" width=\"18\" style=\"float:left;\" /><span id=\"imgurl_" + item.LinkedinUserId + "\" style=\"display:none;\">" + profileurl + "</span><span id=\"composename_" + item.LinkedinUserId + "\" style=\"float:left;margin: 3px 0 0 5px;\">" + item.LinkedinUserName + "</span></a></li>"; } } profiles += "</ul> </div>"; } catch (Exception ex) { logger.Error(ex.Message); } Response.Write(profiles); } else if (Request.QueryString["op"] == "sendmessage") { string messagecount = string.Empty; string message = Request.QueryString["message"]; string time = Request.QueryString["now"]; //message = Request.Form["massagee"]; var userid = Request.QueryString["userid[]"].Split(','); //var userid = Request.Form["userid[]"].Split(','); var files = Request.Files.Count; var fi = Request.Files["file"]; string file = string.Empty; try { if (Request.Files.Count > 0) { if (fi != null) { var path = Server.MapPath("~/Contents/img/upload"); // var path = System.Configuration.ConfigurationManager.AppSettings["MailSenderDomain"]+"Contents/img/upload"; file = path + "/" + fi.FileName; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } fi.SaveAs(file); } } } catch (Exception ex) { logger.Error(ex.Message); } foreach (var item in userid) { string[] networkingwithid = item.Split('_'); if (networkingwithid[0] == "fb") { try { //for (int i = 0; i < 5000; i++) // { FacebookAccountRepository fbaccountrepo = new FacebookAccountRepository(); FacebookAccount fbaccount = fbaccountrepo.getFacebookAccountDetailsById(networkingwithid[1]); var args = new Dictionary<string, object>(); args["message"] = message; if (Request.Files.Count > 0) { string strPathAndQuery = HttpContext.Current.Request.Url.PathAndQuery; string strUrl = HttpContext.Current.Request.Url.AbsoluteUri.Replace(strPathAndQuery, "/"); string filepath = strUrl + "/Contents/img/upload/" + fi.FileName; args["picture"] = filepath; } FacebookClient fc = new FacebookClient(fbaccount.AccessToken); string facebookpost = string.Empty; if (fbaccount.Type == "page") { facebookpost = fc.Post("/" + fbaccount.FbUserId + "/feed", args).ToString(); } else { facebookpost = fc.Post("/me/feed", args).ToString(); } //} } catch (Exception ex) { logger.Error(ex.Message); Console.WriteLine(ex.Message); } } else if (networkingwithid[0] == "twt") { try { TwitterAccountRepository twtaccountrepo = new TwitterAccountRepository(); SocioBoard.Domain.TwitterAccount twtaccount = twtaccountrepo.getUserInformation(networkingwithid[1]); TwitterHelper twthelper = new TwitterHelper(); oAuthTwitter OAuthTwt = new oAuthTwitter(); OAuthTwt.AccessToken = twtaccount.OAuthToken; OAuthTwt.AccessTokenSecret = twtaccount.OAuthSecret; OAuthTwt.TwitterScreenName = twtaccount.TwitterScreenName; OAuthTwt.TwitterUserId = twtaccount.TwitterUserId; twthelper.SetCofigDetailsForTwitter(OAuthTwt); #region For Testing // For Testing //OAuthTwt.ConsumerKey = "udiFfPxtCcwXWl05wTgx6w"; //OAuthTwt.ConsumerKeySecret = "jutnq6N32Rb7cgbDSgfsrUVgRQKMbUB34yuvAfCqTI"; //OAuthTwt.AccessToken = "1453351098-Lz4H7cHKp26pXarF6l9zEwdiHDnwH7D0H4zteH3"; //OAuthTwt.AccessTokenSecret = "dGBPxR9wxhQMioIcj5P4Wemxo5EZIZ8wlvDz7i39lSNFg"; //OAuthTwt.TwitterScreenName = ""; //OAuthTwt.TwitterUserId = ""; #endregion Tweet twt = new Tweet(); if (Request.Files.Count > 0) { PhotoUpload ph = new PhotoUpload(); //ph.Tweet(file, message, OAuthTwt); string res = string.Empty; ph.NewTweet(file, message, OAuthTwt, ref res); // for testing Response.Write(res); Console.WriteLine(res); } else { JArray post = twt.Post_Statuses_Update(OAuthTwt, message); } } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } } else if (networkingwithid[0] == "lin") { try { LinkedInAccountRepository linkedinaccrepo = new LinkedInAccountRepository(); LinkedInAccount linkedaccount = linkedinaccrepo.getUserInformation(networkingwithid[1]); oAuthLinkedIn Linkedin_oauth = new oAuthLinkedIn(); Linkedin_oauth.Verifier = linkedaccount.OAuthVerifier; Linkedin_oauth.TokenSecret = linkedaccount.OAuthSecret; Linkedin_oauth.Token = linkedaccount.OAuthToken; Linkedin_oauth.Id = linkedaccount.LinkedinUserId; Linkedin_oauth.FirstName = linkedaccount.LinkedinUserName; SocialStream sociostream = new SocialStream(); string res = sociostream.SetStatusUpdate(Linkedin_oauth, message); } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } } else if (networkingwithid[0] == "tumb") { string title = string.Empty; try { TumblrAccountRepository objTumblrAccountRepository = new TumblrAccountRepository(); TumblrAccount tumblraccount = objTumblrAccountRepository.getTumblrAccountDetailsById(networkingwithid[1]); PublishedPosts objPublishedPosts = new PublishedPosts(); objPublishedPosts.PostData(tumblraccount.tblrAccessToken, tumblraccount.tblrAccessTokenSecret, networkingwithid[1], message, title, "text"); } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } } string profiletype=""; if(networkingwithid[0] == "fb") { profiletype="facebook"; } else if(networkingwithid[0] == "twt") { profiletype="twitter"; } else if(networkingwithid[0] == "lin") { profiletype="linkedin"; } else if (networkingwithid[0] == "tumb") { profiletype = "tumblr"; } ScheduledMessageRepository objScheduledMessageRepository = new ScheduledMessageRepository(); ScheduledMessage objScheduledMessage = new ScheduledMessage(); try { objScheduledMessage.ShareMessage = message; objScheduledMessage.ClientTime = Convert.ToDateTime(time); objScheduledMessage.ScheduleTime = Convert.ToDateTime(time); objScheduledMessage.CreateTime = Convert.ToDateTime(time); objScheduledMessage.Status = true; objScheduledMessage.UserId = user.Id; objScheduledMessage.ProfileType = profiletype; try { var path = System.Configuration.ConfigurationManager.AppSettings["MailSenderDomain"]+"Contents/img/upload"; file = path + "/" + fi.FileName; objScheduledMessage.PicUrl = file; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } objScheduledMessage.ProfileId = networkingwithid[1]; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } objScheduledMessageRepository.addNewMessage(objScheduledMessage); messagecount = objScheduledMessageRepository.getAllSentMessagesOfUser(user.Id).Count().ToString(); } Response.Write("~"+messagecount); } else if (Request.QueryString["op"] == "wooqueue_messages") { ScheduledMessageRepository schmsgrepo = new ScheduledMessageRepository(); } else if (Request.QueryString["op"] == "schedulemessage") { var userid = Request.QueryString["users[]"].Split(','); var datearr = Request.QueryString["datearr[]"].Split(','); string message = Request.QueryString["message"]; message = Request.Form["messagee"]; ScheduledMessageRepository schmsgrepo = new ScheduledMessageRepository(); string time = Request.QueryString["time"]; string clienttime = Request.QueryString["clittime"]; foreach (var item in userid) { if (!string.IsNullOrEmpty(item.ToString())) { foreach (var child in datearr) { ScheduledMessage schmessage = new ScheduledMessage(); string[] networkingwithid = item.Split('_'); if (networkingwithid[0] == "fbscheduler") { schmessage.CreateTime = DateTime.Now; schmessage.ProfileType = "facebook"; schmessage.ProfileId = networkingwithid[1]; schmessage.Id = Guid.NewGuid(); schmessage.PicUrl = string.Empty; schmessage.ClientTime = Convert.ToDateTime(clienttime); string servertime = this.CompareDateWithclient(clienttime, child + " " + time); schmessage.ScheduleTime = Convert.ToDateTime(servertime); schmessage.ShareMessage = message; schmessage.UserId = user.Id; schmessage.Status = false; } else if (networkingwithid[0] == "twtscheduler") { schmessage.CreateTime = DateTime.Now; schmessage.ProfileType = "twitter"; schmessage.ProfileId = networkingwithid[1]; schmessage.Id = Guid.NewGuid(); schmessage.PicUrl = string.Empty; schmessage.ClientTime = Convert.ToDateTime(clienttime); string servertime = this.CompareDateWithServer(clienttime, child + " " + time); schmessage.ScheduleTime = Convert.ToDateTime(servertime); schmessage.ShareMessage = message; schmessage.UserId = user.Id; schmessage.Status = false; } else if (networkingwithid[0] == "linscheduler") { schmessage.ClientTime = Convert.ToDateTime(clienttime); schmessage.CreateTime = DateTime.Now; schmessage.ProfileType = "linkedin"; schmessage.ProfileId = networkingwithid[1]; schmessage.Id = Guid.NewGuid(); schmessage.PicUrl = string.Empty; string servertime = this.CompareDateWithServer(clienttime, child + " " + time); schmessage.ScheduleTime = Convert.ToDateTime(servertime); schmessage.ShareMessage = message; schmessage.UserId = user.Id; schmessage.Status = false; } if (!string.IsNullOrEmpty(message)) { if (!schmsgrepo.checkMessageExistsAtTime(user.Id, schmessage.ShareMessage, schmessage.ScheduleTime, schmessage.ProfileId)) { schmsgrepo.addNewMessage(schmessage); } } } } } } else if (Request.QueryString["op"] == "insight") { string check = ""; FacebookAccount objFacebookAccount = (FacebookAccount)Session["fbpagedetail"]; FacebookHelper objFbHelper = new FacebookHelper(); SocialProfile socioprofile = new SocialProfile(); SocialProfilesRepository socioprofilerepo = new SocialProfilesRepository(); FacebookAccountRepository fbrepo = new FacebookAccountRepository(); FacebookClient fbClient = new FacebookClient(objFacebookAccount.AccessToken); int fancountPage = 0; dynamic fancount = fbClient.Get("fql", new { q = " SELECT fan_count FROM page WHERE page_id =" + Request["id"].ToString() }); foreach (var friend in fancount.data) { fancountPage = Convert.ToInt32(friend.fan_count); } objFacebookAccount.Friends = Convert.ToInt32(fancountPage); objFacebookAccount.FbUserId = Request["id"].ToString(); objFacebookAccount.FbUserName = Request["name"].ToString(); objFacebookAccount.Type = "page"; objFacebookAccount.UserId = user.Id; socioprofile.Id = Guid.NewGuid(); socioprofile.ProfileDate = DateTime.Now; socioprofile.ProfileId = Request["id"].ToString(); socioprofile.ProfileStatus = 1; socioprofile.ProfileType = "facebook"; socioprofile.UserId = user.Id; if (!fbrepo.checkFacebookUserExists(objFacebookAccount.FbUserId, user.Id)) { fbrepo.addFacebookUser(objFacebookAccount); Groups lstDetails = objGroupRepository.getGroupName(team.GroupId); if (lstDetails.GroupName == "Socioboard") { TeamMemberProfile teammemberprofile = new TeamMemberProfile(); teammemberprofile.Id = Guid.NewGuid(); teammemberprofile.TeamId = team.Id; teammemberprofile.ProfileId = objFacebookAccount.FbUserId; teammemberprofile.ProfileType = "facebook"; teammemberprofile.StatusUpdateDate = DateTime.Now; objTeamMemberProfileRepository.addNewTeamMember(teammemberprofile); } if (!socioprofilerepo.checkUserProfileExist(socioprofile)) { socioprofilerepo.addNewProfileForUser(socioprofile); } else { socioprofilerepo.updateSocialProfile(socioprofile); } } else { check = "exist"; Session["alreadypageexist"] = objFacebookAccount; fbrepo.updateFacebookUser(objFacebookAccount); if (!socioprofilerepo.checkUserProfileExist(socioprofile)) { socioprofilerepo.addNewProfileForUser(socioprofile); } else { socioprofilerepo.updateSocialProfile(socioprofile); } } //get facebookpagefeeds fbClient = new FacebookClient(objFacebookAccount.AccessToken); FacebookHelper fbhelper = new FacebookHelper(); FacebookInsightStatsHelper fbiHelper = new FacebookInsightStatsHelper(); var feeds = fbClient.Get("/" + Request["id"].ToString() + "/feed"); fbiHelper.getPageImpresion(Request["id"].ToString(), user.Id, 15); fbiHelper.getFanPageLikesByGenderAge(Request["id"].ToString(), user.Id, 15); fbiHelper.getLocation(Request["id"].ToString(), user.Id, 15); // fbiHelper.getFanPost("459630637383010", user.Id, 10); dynamic profile = fbClient.Get(Request["id"].ToString()); fbhelper.getFacebookUserFeeds(feeds, profile); //end facebookpagefeeds string id = "id"; string value = Request["id"].ToString(); Dictionary<string, string> Did = new Dictionary<string, string>(); Did.Add(id, value); dynamic Pageid = Did; // var friendgenderstats=fbClient.Get("me/friends?fields=gender"); objFbHelper.getfbFriendsGenderStatsForFanPage(Pageid, user.Id, ref objFacebookAccount); Session["fbSocial"] = null; Response.Write(RemainingAccount(user)); } else if (Request.QueryString["op"] == "countmessages") { try { int val = 0; /*facebook*/ FacebookAccountRepository fbAccoutsRepo = new FacebookAccountRepository(); ArrayList lstfacebookAccounts = fbAccoutsRepo.getAllFacebookAccountsOfUser(user.Id); foreach (FacebookAccount item in lstfacebookAccounts) { try { FacebookClient fb = new FacebookClient(item.AccessToken); dynamic unreadcount = fb.Get("fql", new { q = "SELECT unread_count FROM mailbox_folder WHERE folder_id = 0 AND viewer_id = " + item.FbUserId + "" }); foreach (var chile in unreadcount.data) { var count = chile.unread_count; int countable = Convert.ToInt32(count.ToString()); val = val + countable; } } catch (Exception ex) { logger.Error(ex.Message); Console.WriteLine(ex.Message); } } /*Twitter*/ Session["CountMessages"] = val; Response.Write(val); } catch (Exception ex) { Console.WriteLine(ex.Message); } } else if (Request.QueryString["op"] == "recentfollowers") { string recentfollowers = string.Empty; #region RecentFollowers Users twtUsers = new Users(); TwitterAccountRepository twtAccRepo = new TwitterAccountRepository(); ArrayList lstAccRepo = twtAccRepo.getAllTwitterAccountsOfUser(user.Id); oAuthTwitter oauth = null; foreach (TwitterAccount itemTwt in lstAccRepo) { oauth = new oAuthTwitter(); oauth.AccessToken = itemTwt.OAuthToken; oauth.AccessTokenSecret = itemTwt.OAuthSecret; oauth.ConsumerKey = ConfigurationManager.AppSettings["consumerKey"]; oauth.ConsumerKeySecret = ConfigurationManager.AppSettings["consumerSecret"]; oauth.TwitterScreenName = itemTwt.TwitterScreenName; oauth.TwitterUserId = itemTwt.TwitterUserId; JArray jarresponse = twtUsers.Get_Followers_ById(oauth, itemTwt.TwitterUserId); foreach (var item in jarresponse) { int resposecount = 0; if (item["ids"] != null) { foreach (var child in item["ids"]) { if (resposecount < 2) { JArray userprofile = twtUsers.Get_Users_LookUp(oauth, child.ToString()); foreach (var items in userprofile) { resposecount++; try { recentfollowers += "<li><a href=\"https://twitter.com/" + items["screen_name"] + "\" target=\"_blank\"><img style=\"border:3px solid #FCFCFC;\" title=\"" + items["name"] + "\" width=\"48\" height=\"48\" alt=\"\" src=\"" + items["profile_image_url"] + "\"></a></li>"; } catch (Exception ex) { Console.WriteLine(ex.Message); } } } } } } } Response.Write(recentfollowers); #endregion } else if (Request.QueryString["op"] == "removefollowers") { string removeid = Request.QueryString["removeid"]; string userid = Request.QueryString["userid"]; Friendship friendship = new Friendship(); oAuthTwitter oauth = new oAuthTwitter(); TwitterAccountRepository twtaccrepo = new TwitterAccountRepository(); TwitterAccount twtAccount = twtaccrepo.getUserInformation(user.Id, userid); oauth.TwitterUserId = twtAccount.TwitterUserId; oauth.TwitterScreenName = twtAccount.TwitterScreenName; oauth.ConsumerKey = ConfigurationManager.AppSettings["consumerKey"]; oauth.ConsumerKeySecret = ConfigurationManager.AppSettings["consumerSecret"]; oauth.AccessToken = twtAccount.OAuthToken; oauth.AccessTokenSecret = twtAccount.OAuthSecret; JArray responseremove = friendship.Post_Friendship_Destroy(oauth, removeid); } //for Deleting socialqueue Message else if (Request.QueryString["op"] == "deletequeuemsg") { try { string res = string.Empty; string messageId = Request.QueryString["messageid"].ToString(); Guid userid = user.Id; ScheduledMessageRepository obj = new ScheduledMessageRepository(); bool check = obj.deleteScheduleMessage(userid, messageId); if (check == true) { res = "success"; } else { } } catch (Exception ex) { logger.Error(ex.Message); } } //for Editing socialqueue Message else if (Request.QueryString["op"] == "Editqueuemsg") { try { string messageId = Request.QueryString["messageid"].ToString(); string newstr = Request.QueryString["newstr"]; Guid userid = user.Id; DateTime dt = DateTime.Now; ScheduledMessageRepository obj = new ScheduledMessageRepository(); obj.UpdateScheduleMessage(userid, messageId, newstr, dt); } catch (Exception ex) { logger.Error(ex.Message); } } else if (Request.QueryString["op"] == "wooqueuemessages") { string profileid = string.Empty; ScheduledMessageRepository schmsgRepo = new ScheduledMessageRepository(); List<TeamMemberProfile> allprofiles = objTeamMemberProfileRepository.getAllTeamMemberProfilesOfTeam(team.Id); foreach (TeamMemberProfile item in allprofiles) { profileid += item.ProfileId + ','; } profileid = profileid.Substring(0, profileid.Length - 1); List<ScheduledMessage> lstschMsg = schmsgRepo.getAllMessagesDetail(profileid); string schmessages = string.Empty; //string profurl = string.Empty; //if (string.IsNullOrEmpty(user.ProfileUrl)) //{ string profurls = "../Contents/img/blank_img.png"; //} //else //{ // // profurl = "../Contents/img/blank_img.png"; // profurl = user.ProfileUrl; //} if (lstschMsg.Count != 0) { foreach (ScheduledMessage item in lstschMsg) try { UserRepository objUserRepository=new UserRepository(); User objuser = objUserRepository.getUsersById(item.UserId); string profurl = string.Empty; if (string.IsNullOrEmpty(objuser.ProfileUrl)) { profurl = "../Contents/img/blank_img.png"; } else { // profurl = "../Contents/img/blank_img.png"; profurl = objuser.ProfileUrl; } { schmessages += "<section class=\"section\"><div class=\"js-task-cont read\">" + "<section class=\"task-owner\">" + "<img width=\"32\" height=\"32\" border=\"0\" src=\"" + profurl + "\" class=\"avatar\">" + "</section>" + "<section class=\"task-activity third\">" + "<p>" + objuser.UserName + "</p>" + "<div>" + CompareDateWithServerNew(item.ClientTime, item.CreateTime, item.ScheduleTime) + "</div>" + "<input type=\"hidden\" value=\"#\" id=\"hdntaskid_1\">" + "<p></p>" + "</section>" + "<section class=\"task-message font-13 third\" style=\"height: auto; width: 31%; margin-right: 9px;\"><a id=\"edit_" + item.Id + "\" onclick=\"Editqueue('" + item.Id + "','" + item.ShareMessage + "');\" class=\"tip_left\">" + gethtmlfromstring(item.ShareMessage) + "</a></section>"; if (item.ProfileType == "facebook") { schmessages += "<div style=\"height:70px; margin-top: 0;\" class=\"userpictiny\">" + "<img width=\"48\" height=\"48\" src=\"http://graph.facebook.com/" + item.ProfileId + "/picture?type=small\" alt=\"\">" + "<a style=\"right: 2px; top: 40px;\" title=\"\" class=\"userurlpic\" href=\"#\">" + "<img alt=\"\" src=\"../Contents/img/facebook.png\" style=\"height: 16px;width: 16x;\"></a></div>"; } else if (item.ProfileType == "twitter") { TwitterAccountRepository twtAccRepo = new TwitterAccountRepository(); TwitterAccount twtAccount = twtAccRepo.getUserInformation(item.ProfileId); if (twtAccount != null) { schmessages += "<div style=\"height:70px; margin-top: 0;\" class=\"userpictiny\">" + "<img width=\"48\" height=\"48\" src=\"" + twtAccount.ProfileImageUrl + "\" alt=\"\">" + "<a style=\"right: 2px; top: 40px;\" title=\"\" class=\"userurlpic\" href=\"#\">" + "<img alt=\"\" src=\"../Contents/img/twitter.png\" style=\"height: 16px;width: 16x;\"></a></div>"; } } else if (item.ProfileType == "linkedin") { LinkedInAccountRepository linkAccRepo = new LinkedInAccountRepository(); LinkedInAccount linkedAccount = linkAccRepo.getUserInformation(item.ProfileId); if (linkedAccount != null) { schmessages += "<div style=\"height:70px; margin-top: 0;\" class=\"userpictiny\">" + "<img width=\"48\" height=\"48\" src=\"" + linkedAccount.ProfileImageUrl + "\" alt=\"\">" + "<a style=\"right: 2px; top: 40px;\" title=\"\" class=\"userurlpic\" href=\"#\">" + "<img alt=\"\" src=\"../Contents/img/link.png\" style=\"height: 16px;width: 16x;\"></a></div>"; } } string status = (item.Status == true) ? "Completed" : "Pending"; schmessages += "<section class=\"task-status\" style=\"width:34px;\"><div class=\"ui_light floating task_status_change\">" + //"<a href=\"#nogo\" class=\"ui-sproutmenu\"><span class=\"ui-sproutmenu-status\"><img title=\"Edit Status\" onclick=\"PerformClick(this.id)\" src=\"../Contents/img/icon_edit.png\" class=\"edit_button\" id=\"img_" + item.Id + "_" + item.Status + "\"></span></a></div></section>" + "<a class=\"ui-sproutmenu\"><span class=\"ui-sproutmenu-status\"><img title=\"Edit Status\" onclick=\"PerformClick(this.id)\" src=\"../Contents/img/icon_edit.png\" class=\"edit_button\" id=\"img_" + item.Id + "_" + item.Status + "\"></span></a></div></section>" + "<section class=\"task-status\" style=\"width: 65px; margin-right: 39px;\">" + "<div class=\"ui_light floating task_status_change\">" + "<span class=\"ui-sproutmenu-status\">" + status + "</span>" + "</div>" + "</section>" + "<section class=\"task-status\" style=\"width: 65px; margin-right: 39px;\">" + "<div class=\"ui_light floating task_status_change\">" + "<span class=\"ui-sproutmenu-status\"><img title=\"Delete\" onclick=\"deletequeue(this.id)\" style=\"width:33px;margin-left:60px;margin-top:-10px;\" img src=\"../Contents/img/deleteimage.png\" img id=\"" + item.Id + "\"></span>" + "</div>" + "</section>" + "</div></section>"; } } catch (Exception ex) { logger.Error(ex.Message); Console.WriteLine(ex.Message); Response.Write(schmessages); } } else { schmessages = "<section class=\"section\"><div class=\"js-task-cont read\"><section class=\"task-owner\">" + "<img width=\"32\" height=\"32\" border=\"0\" class=\"avatar\" src=\"" + profurls + "\">" + "</section><section class=\"task-activity third\"><p>" + user.UserName + "</p><div></div><p></p></section><section style=\"margin-right: 6px; width: 31%; height: auto;\" class=\"task-message font-13 third\">" + "<a class=\"tip_left\">No Scheduled Messages</a></section><section style=\"width:113px;\" class=\"task-status\"><span class=\"ficon task_active\"></span>" + //"<div class=\"ui_light floating task_status_change\"><a class=\"ui-sproutmenu\" href=\"#nogo\">" + "<div class=\"ui_light floating task_status_change\"><a class=\"ui-sproutmenu\">" + "<span class=\"ui-sproutmenu-status\"></span></a></div></section></div></section>"; } Response.Write(schmessages); } else if (Request.QueryString["op"] == "drafts_messages") { } else if (Request.QueryString["op"] == "updatequeue") { updatequeue(Request.QueryString["id"], Request.QueryString["status"]); } else if (Request.QueryString["op"] == "messagechk") { SocioBoard.Domain.Messages mstable = new SocioBoard.Domain.Messages(); string[] types = Request.QueryString["type[]"].Split(','); DataSet ds = (DataSet)Session["MessageDataTable"]; DataSet dss = DataTableGenerator.CreateDataSetForTable(mstable); DataTable dtt = dss.Tables[0]; DataView dv = new DataView(dtt); AjaxMessage ajxfed = new AjaxMessage(); string message = string.Empty; foreach (var item in types) { try { DataRow[] foundRows = ds.Tables[0].Select("Type = '" + item + "'"); foreach (var child in foundRows) { dtt.ImportRow(child); } } catch (Exception ex) { logger.Error(ex.Message); Console.WriteLine(ex.Message); } } message = ajxfed.BindData(dtt); Response.Write(message); } } }
public void AuthenticateInstagram(object sender, EventArgs e) { try { GroupRepository objGroupRepository = new GroupRepository(); SocioBoard.Domain.Team team = (SocioBoard.Domain.Team)Session["GroupName"]; Groups lstDetails = objGroupRepository.getGroupName(team.GroupId); try { int profilecount = (int)Session["ProfileCount"]; int totalaccount = (int)Session["TotalAccount"]; if (lstDetails.GroupName == "Socioboard") { if (profilecount < totalaccount) { GlobusInstagramLib.Authentication.ConfigurationIns config = new GlobusInstagramLib.Authentication.ConfigurationIns("https://instagram.com/oauth/authorize/", ConfigurationManager.AppSettings["InstagramClientKey"].ToString(), ConfigurationManager.AppSettings["InstagramClientSec"].ToString(), ConfigurationManager.AppSettings["InstagramCallBackURL"].ToString(), "https://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", ""); oAuthInstagram _api = oAuthInstagram.GetInstance(config); InstagramConnect.HRef = _api.AuthGetUrl("likes+comments+basic+relationships"); Response.Redirect(_api.AuthGetUrl("likes+comments+basic+relationships")); } else { // Response.Write("<script>SimpleMessageAlert('Change the Plan to Add More Accounts');</script>"); ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Change the Plan to Add More Accounts');", true); } } } catch (Exception ex) { logger.Error(ex.Message); } } catch (Exception ex) { logger.Error(ex.Message); } }
public void GetLinkedInUserProfile(dynamic data, oAuthLinkedIn _oauth, Guid user, string LinkedinUserId) { SocialProfile socioprofile = new SocialProfile(); SocialProfilesRepository socioprofilerepo = new SocialProfilesRepository(); LinkedInAccount objLinkedInAccount = new LinkedInAccount(); LinkedInAccountRepository objLiRepo = new LinkedInAccountRepository(); try { objLinkedInAccount.UserId = user; objLinkedInAccount.LinkedinUserId = data.id.ToString(); try { objLinkedInAccount.EmailId = data.email.ToString(); } catch { } objLinkedInAccount.LinkedinUserName = data.first_name.ToString() + data.last_name.ToString(); objLinkedInAccount.OAuthToken = _oauth.Token; objLinkedInAccount.OAuthSecret = _oauth.TokenSecret; objLinkedInAccount.OAuthVerifier = _oauth.Verifier; try { objLinkedInAccount.ProfileImageUrl = data.picture_url.ToString(); } catch { } try { objLinkedInAccount.ProfileUrl = data.profile_url.ToString(); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } objLinkedInAccount.Connections = data.connections; objLinkedInAccount.IsActive = true; socioprofile.UserId = user; socioprofile.ProfileType = "linkedin"; socioprofile.ProfileId = LinkedinUserId; socioprofile.ProfileStatus = 1; socioprofile.ProfileDate = DateTime.Now; socioprofile.Id = Guid.NewGuid(); } catch { } try { 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 = socioprofile.ProfileId; teammemberprofile.ProfileType = "linkedin"; teammemberprofile.StatusUpdateDate = DateTime.Now; objTeamMemberProfileRepository.addNewTeamMember(teammemberprofile); } } else { socioprofile.ProfileId = data.id.ToString(); socioprofilerepo.updateSocialProfile(socioprofile); } if (!objLiRepo.checkLinkedinUserExists(LinkedinUserId, user)) { objLiRepo.addLinkedinUser(objLinkedInAccount); } else { objLinkedInAccount.LinkedinUserId = LinkedinUserId; objLiRepo.updateLinkedinUser(objLinkedInAccount); } // GetLinkedInFeeds(_oauth, data.id, user.Id); } catch { } }
public void getFacebookUserProfile(dynamic data, string accesstoken, long friends, Guid user) { SocialProfile socioprofile = new SocialProfile(); SocialProfilesRepository socioprofilerepo = new SocialProfilesRepository(); FacebookAccount fbAccount = new FacebookAccount(); FacebookAccountRepository fbrepo = new FacebookAccountRepository(); try { try { fbAccount.AccessToken = accesstoken; } catch { } try { fbAccount.EmailId = data["email"].ToString(); } catch { } try { fbAccount.FbUserId = data["id"].ToString(); } catch { } try { fbAccount.ProfileUrl = data["link"].ToString(); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { fbAccount.FbUserName = data["name"].ToString(); } catch { } try { fbAccount.Friends = Convert.ToInt32(friends); } catch { } try { fbAccount.Id = Guid.NewGuid(); } catch { } fbAccount.IsActive = 1; try { if (HttpContext.Current.Session["fbSocial"] != null) { if (HttpContext.Current.Session["fbSocial"] == "p") { //FacebookClient fbClient = new FacebookClient(accesstoken); //int fancountPage = 0; //dynamic fancount = fbClient.Get("fql", new { q = " SELECT fan_count FROM page WHERE page_id =" + fbAccount.FbUserId }); //foreach (var friend in fancount.data) //{ // fancountPage = friend.fan_count; //} //fbAccount.Friends = Convert.ToInt32(fancountPage); fbAccount.Type = "page"; } else { fbAccount.Type = "account"; } fbAccount.UserId = user; } if (HttpContext.Current.Session["UserAndGroupsForFacebook"] != null) { try { fbAccount.UserId = user; fbAccount.Type = "account"; } catch (Exception ex) { } } } catch { } #region unused //if (HttpContext.Current.Session["login"] != null) //{ // if (HttpContext.Current.Session["login"].ToString().Equals("facebook")) // { // 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 = data["name"].ToString(); // usr.Password = regObject.MD5Hash(data["name"].ToString()); // usr.EmailId = data["email"].ToString(); // usr.UserStatus = 1; // if (!userrepo.IsUserExist(data["email"].ToString())) // { // UserRepository.Add(usr); // } // } //} #endregion try { socioprofile.UserId = user; } catch { } try { socioprofile.ProfileType = "facebook"; } catch { } try { socioprofile.ProfileId = data["id"].ToString(); } catch { } try { socioprofile.ProfileStatus = 1; } catch { } try { socioprofile.ProfileDate = DateTime.Now; } catch { } try { socioprofile.Id = Guid.NewGuid(); } catch { } if (HttpContext.Current.Session["fbSocial"] != null) { if (HttpContext.Current.Session["fbSocial"] == "p") { HttpContext.Current.Session["fbpagedetail"] = fbAccount; } else { if (!fbrepo.checkFacebookUserExists(fbAccount.FbUserId, user)) { fbrepo.addFacebookUser(fbAccount); 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 = fbAccount.FbUserId; teammemberprofile.ProfileType = "facebook"; teammemberprofile.StatusUpdateDate = DateTime.Now; objTeamMemberProfileRepository.addNewTeamMember(teammemberprofile); } } else { socioprofilerepo.updateSocialProfile(socioprofile); } } else { HttpContext.Current.Session["alreadyexist"] = fbAccount; fbrepo.updateFacebookUser(fbAccount); if (!socioprofilerepo.checkUserProfileExist(socioprofile)) { socioprofilerepo.addNewProfileForUser(socioprofile); } else { socioprofilerepo.updateSocialProfile(socioprofile); } } } } if (HttpContext.Current.Session["UserAndGroupsForFacebook"] != null) { if (HttpContext.Current.Session["UserAndGroupsForFacebook"].ToString() == "facebook") { try { if (!fbrepo.checkFacebookUserExists(fbAccount.FbUserId, user)) { fbrepo.addFacebookUser(fbAccount); if (!socioprofilerepo.checkUserProfileExist(socioprofile)) { socioprofilerepo.addNewProfileForUser(socioprofile); } else { socioprofilerepo.updateSocialProfile(socioprofile); } } else { fbrepo.updateFacebookUser(fbAccount); if (!socioprofilerepo.checkUserProfileExist(socioprofile)) { socioprofilerepo.addNewProfileForUser(socioprofile); } else { socioprofilerepo.updateSocialProfile(socioprofile); } } if (HttpContext.Current.Session["GroupName"] != null) { GroupProfile groupprofile = new GroupProfile(); GroupProfileRepository groupprofilerepo = new GroupProfileRepository(); Groups group = (Groups)HttpContext.Current.Session["GroupName"]; groupprofile.Id = Guid.NewGuid(); groupprofile.GroupOwnerId = user; groupprofile.ProfileId = socioprofile.ProfileId; groupprofile.ProfileType = "facebook"; groupprofile.GroupId = group.Id; groupprofile.EntryDate = DateTime.Now; if (!groupprofilerepo.checkGroupProfileExists(user, group.Id, groupprofile.ProfileId)) { groupprofilerepo.AddGroupProfile(groupprofile); } } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } }
/// <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); } } } } }
public void getAccessToken() { GlobusInstagramLib.Authentication.ConfigurationIns configi = new GlobusInstagramLib.Authentication.ConfigurationIns("https://api.instagram.com/oauth/authorize/", ConfigurationManager.AppSettings["InstagramClientKey"].ToString(), ConfigurationManager.AppSettings["InstagramClientSec"].ToString(), ConfigurationManager.AppSettings["InstagramCallBackURL"].ToString(), "http://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", ""); SocialProfilesRepository socioprofilerepo = new SocialProfilesRepository(); SocialProfile socioprofile = new SocialProfile(); _api = oAuthInstagram.GetInstance(configi); AccessToken access = new AccessToken(); string code = Request.QueryString["code"].ToString(); SocioBoard.Domain.User user = (SocioBoard.Domain.User)Session["LoggedUser"]; access = _api.AuthGetAccessToken(code); UserController objusercontroller = new UserController(); InstagramResponse<GlobusInstagramLib.App.Core.User> objuser = objusercontroller.GetUserDetails(access.user.id, access.access_token); InstagramAccount objInsAccount = new InstagramAccount(); objInsAccount.AccessToken = access.access_token; //objInsAccount.FollowedBy=access.user. objInsAccount.InstagramId = access.user.id; objInsAccount.ProfileUrl = access.user.profile_picture; objInsAccount.InsUserName = access.user.username; objInsAccount.TotalImages = objuser.data.counts.media; objInsAccount.FollowedBy = objuser.data.counts.followed_by; objInsAccount.Followers = objuser.data.counts.follows; objInsAccount.UserId = user.Id; socioprofile.UserId = user.Id; socioprofile.ProfileType = "instagram"; socioprofile.ProfileId = access.user.id; socioprofile.ProfileStatus = 1; socioprofile.ProfileDate = DateTime.Now; socioprofile.Id = Guid.NewGuid(); if (objInsRepo.checkInstagramUserExists(access.user.id, user.Id)) { HttpContext.Current.Session["alreadyexist"] = objInsAccount; objInsRepo.updateInstagramUser(objInsAccount); if (!socioprofilerepo.checkUserProfileExist(socioprofile)) { socioprofilerepo.addNewProfileForUser(socioprofile); } } else { objInsRepo.addInstagramUser(objInsAccount); 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 = socioprofile.ProfileId; teammemberprofile.ProfileType = "instagram"; teammemberprofile.StatusUpdateDate = DateTime.Now; objTeamMemberProfileRepository.addNewTeamMember(teammemberprofile); } } } string messages = getIntagramImages(objInsAccount); Response.Write(messages); }
private void AccessToken() { SocioBoard.Domain.User user = (User)Session["LoggedUser"]; oAuthTokenYoutube ObjoAuthTokenYoutube = new oAuthTokenYoutube(); oAuthToken objToken = new oAuthToken(); //GlobusGooglePlusLib.App.Core.PeopleController obj = new GlobusGooglePlusLib.App.Core.PeopleController(); logger.Error("Error1:oAuthToken"); string refreshToken = string.Empty; string access_token = string.Empty; try { string objRefresh = string.Empty; objRefresh= ObjoAuthTokenYoutube.GetRefreshToken(Request.QueryString["code"]); if (!objRefresh.StartsWith("[")) objRefresh = "[" + objRefresh + "]"; JArray objArray = JArray.Parse(objRefresh); logger.Error("Error1:GetRefreshToken"); if (!objRefresh.Contains("refresh_token")) { logger.Error("Error0:refresh_token"); access_token = objArray[0]["access_token"].ToString(); string abc =ObjoAuthTokenYoutube.RevokeToken(access_token); Response.Redirect("https://accounts.google.com/o/oauth2/auth?client_id=" + System.Configuration.ConfigurationManager.AppSettings["YtconsumerKey"] + "&redirect_uri=" + System.Configuration.ConfigurationManager.AppSettings["Ytredirect_uri"] + "&scope=https://www.googleapis.com/auth/youtube+https://www.googleapis.com/auth/youtube.readonly+https://www.googleapis.com/auth/youtubepartner+https://www.googleapis.com/auth/youtubepartner-channel-audit+https://www.googleapis.com/auth/userinfo.email+https://www.googleapis.com/auth/userinfo.profile+https://www.googleapis.com/auth/plus.me&response_type=code&access_type=offline"); logger.Error("Error1:refresh_token"); } foreach (var item in objArray) { logger.Error("Abhay Item :"+item); try { try { refreshToken = item["refresh_token"].ToString(); } catch (Exception ex) { logger.Error(ex.StackTrace); logger.Error(ex.Message); Console.WriteLine(ex.StackTrace); } access_token = item["access_token"].ToString(); break; } catch (Exception ex) { logger.Error(ex.StackTrace); Console.WriteLine(ex.StackTrace); } } //Get user Profile #region <<Get user Profile>> JArray objEmail = new JArray(); try { objEmail = objToken.GetUserInfo("me", access_token.ToString()); } catch (Exception ex) { logger.Error("Email : "+ objEmail); logger.Error(ex.Message); } #endregion GlobusGooglePlusLib.Youtube.Core.Channels ObjChannel = new GlobusGooglePlusLib.Youtube.Core.Channels(); //Get the Channels of user JArray objarray=new JArray (); try { string part = (oAuthTokenYoutube.Parts.contentDetails.ToString() + "," + oAuthTokenYoutube.Parts.statistics.ToString()); string Value= ObjChannel.Get_Channel_List(access_token, part, 50, true); logger.Error("Successfully GetValus"); logger.Error("Value :" +Value); JObject UserChannels = JObject.Parse(@Value); logger.Error("Successfully Convert Jobj"); logger.Error("Successfully Convert Jobj"); objarray = (JArray)UserChannels["items"]; logger.Error("Successfully Convert JArr"); } catch (Exception ex) { logger.Error("UserChannels :" + ex.Message); } YoutubeAccount objYoutubeAccount = new YoutubeAccount(); YoutubeChannel objYoutubeChannel = new YoutubeChannel(); YoutubeChannelRepository objYoutubeChannelRepository = new YoutubeChannelRepository(); YoutubeAccountRepository objYoutubeAccountRepository = new YoutubeAccountRepository(); //put condition here to check is user already exise if exist then update else insert string ytuerid = ""; foreach (var itemEmail in objEmail) { logger.Error("itemEmail :" + itemEmail); try { objYoutubeAccount.Id = Guid.NewGuid(); ytuerid = itemEmail["id"].ToString(); objYoutubeAccount.Ytuserid = itemEmail["id"].ToString(); objYoutubeAccount.Emailid = itemEmail["email"].ToString(); objYoutubeAccount.Ytusername = itemEmail["given_name"].ToString(); objYoutubeAccount.Ytprofileimage = itemEmail["picture"].ToString(); objYoutubeAccount.Accesstoken = access_token; objYoutubeAccount.Refreshtoken = refreshToken; objYoutubeAccount.Isactive = 1; objYoutubeAccount.Entrydate = DateTime.Now; objYoutubeAccount.UserId = user.Id; } catch (Exception ex) { logger.Error("itemEmail1 :" + ex.Message); logger.Error("itemEmail1 :" + ex.StackTrace); Console.WriteLine(ex.StackTrace); } } foreach (var item in objarray) { try { objYoutubeChannel.Id = Guid.NewGuid(); objYoutubeChannel.Channelid = item["id"].ToString(); objYoutubeChannel.Likesid = item["contentDetails"]["relatedPlaylists"]["likes"].ToString(); objYoutubeChannel.Favoritesid = item["contentDetails"]["relatedPlaylists"]["favorites"].ToString(); objYoutubeChannel.Uploadsid = item["contentDetails"]["relatedPlaylists"]["uploads"].ToString(); objYoutubeChannel.Watchhistoryid = item["contentDetails"]["relatedPlaylists"]["watchHistory"].ToString(); objYoutubeChannel.Watchlaterid = item["contentDetails"]["relatedPlaylists"]["watchLater"].ToString(); objYoutubeChannel.Googleplususerid = ytuerid; try { string viewcnt = item["statistics"]["viewCount"].ToString(); objYoutubeChannel.ViewCount = Convert.ToInt32(viewcnt); string videocnt = item["statistics"]["videoCount"].ToString(); objYoutubeChannel.VideoCount = Convert.ToInt32(videocnt); string commentcnt = item["statistics"]["commentCount"].ToString(); objYoutubeChannel.CommentCount = Convert.ToInt32(commentcnt); string Subscribercnt = item["statistics"]["subscriberCount"].ToString(); objYoutubeChannel.SubscriberCount = Convert.ToInt32(Subscribercnt); try { string str = item["statistics"]["hiddenSubscriberCount"].ToString(); if (str == "false") { objYoutubeChannel.HiddenSubscriberCount = 0; } else { objYoutubeChannel.HiddenSubscriberCount = 1; } } catch (Exception ex) { logger.Error("aagaya1: " + ex); Console.WriteLine(ex.StackTrace); } } catch (Exception ex) { logger.Error("aagaya2: " + ex); Console.WriteLine(ex.StackTrace); } } catch (Exception ex) { logger.Error("aagaya3: " + ex); Console.WriteLine(ex.StackTrace); logger.Error(ex.StackTrace); logger.Error(ex.Message); } } //YoutubeChannelRepository.Add(objYoutubeChannel); SocialProfile objSocialProfile = new SocialProfile(); SocialProfilesRepository objSocialProfilesRepository = new SocialProfilesRepository(); objSocialProfile.Id = Guid.NewGuid(); objSocialProfile.UserId = user.Id; objSocialProfile.ProfileId = ytuerid; objSocialProfile.ProfileType = "youtube"; objSocialProfile.ProfileDate = DateTime.Now; objSocialProfile.ProfileStatus = 1; logger.Error("aagaya"); if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile)) { objSocialProfilesRepository.addNewProfileForUser(objSocialProfile); if (!objYoutubeAccountRepository.checkYoutubeUserExists(objYoutubeAccount)) { logger.Error("Abhay"); YoutubeAccountRepository.Add(objYoutubeAccount); logger.Error("Abhay account add ho gaya"); YoutubeChannelRepository.Add(objYoutubeChannel); logger.Error("Channel account add ho gaya"); 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 = objYoutubeAccount.Ytuserid; teammemberprofile.ProfileType = "youtube"; teammemberprofile.StatusUpdateDate = DateTime.Now; objTeamMemberProfileRepository.addNewTeamMember(teammemberprofile); } } } else { logger.Error("Suraj"); if (!objYoutubeAccountRepository.checkYoutubeUserExists(objYoutubeAccount)) { YoutubeAccountRepository.Add(objYoutubeAccount); YoutubeChannelRepository.Add(objYoutubeChannel); } else { Response.Redirect("Home.aspx"); } } Response.Redirect("Home.aspx"); } catch (Exception Err) { Console.Write(Err.Message.ToString()); logger.Error(Err.StackTrace ); logger.Error(Err.Message); } }