protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { try { User user = new User(); PackageRepository objPgeRepo = new PackageRepository(); ddlPackage.DataSource = objPgeRepo.getAllPackage(); ddlPackage.DataTextField = "PackageName"; ddlPackage.DataValueField = "PackageName"; ddlPackage.DataBind(); // ddlPackage.Items.Insert(); user = objUerRepo.getUsersById(Guid.Parse(Request.QueryString["id"].ToString())); if (user != null) { txtName.Text = user.UserName; txtEmail.Text = user.EmailId; // txtdatepicker.Text = user.ExpiryDate.ToString(); datepicker.Text = user.ExpiryDate.ToString(); ddlPackage.SelectedValue = user.AccountType.ToString(); //user.PaymentStatus; ddlStatus.SelectedValue = user.UserStatus.ToString(); } } catch (Exception ex) { logger.Error(ex.StackTrace); } } }
public List<UserPackageRelation> getAllUserPackageRelationByUserId(User objuser) { List<UserPackageRelation> alstFBAccounts = null; try { using (NHibernate.ISession session = SessionFactory.GetNewSession()) { using (NHibernate.ITransaction transaction = session.BeginTransaction()) { try { alstFBAccounts = session.CreateQuery("from UserPackageRelation where UserId = : UserId") .SetParameter("UserId", objuser.Id) .List<UserPackageRelation>().ToList<UserPackageRelation>(); } catch (Exception ex) { logger.Error("Error : " + ex.StackTrace); Console.WriteLine("Error : " + ex.StackTrace); } } } } catch (Exception ex) { logger.Error("Error : " + ex.StackTrace); Console.WriteLine("Error : " + ex.StackTrace); } return alstFBAccounts; }
protected void btnninty_Click(object sender, EventArgs e) { try { SocioBoard.Domain.User user = (User)Session["LoggedUser"]; fbpageProfileId = Session["fbprofileId"].ToString(); fbProfileDetails(fbpageProfileId); spandiv.InnerHtml = "from " + DateTime.Now.AddDays(-90).ToShortDateString() + "-" + DateTime.Now.ToShortDateString(); strFbAgeArray = fbiHelper.getLikesByGenderAge(fbpageProfileId, 90); strPageImpression = fbiHelper.getPageImressions(fbpageProfileId, 90); strLocationArray = fbiHelper.getLocationInsight(fbpageProfileId, 90); //divpost.InnerHtml = fbiHelper.getPostDetails(fbpageProfileId, user.Id, 90); strstoriesArray = fbiHelper.getStoriesCount(fbpageProfileId, 90); likeunlikedate = objfbstatsHelper.getlikeUnlike(fbpageProfileId, 90); string stracsfbpg = Session["acstknfnpg"].ToString(); string fanpost = PageFeed(stracsfbpg, fbpageProfileId); divpost.InnerHtml = fanpost; } catch (Exception Err) { Response.Write(Err.StackTrace); } }
protected void Page_Load(object sender, EventArgs e) { SocioBoard.Domain.User user = (User)Session["LoggedUser"]; try { if (user == null) { Response.Write("logout"); } if (Request.QueryString != null) { if (Request.QueryString["op"] == "resendmail") { //SocioBoard.Helper.MailSender.SendEMail(user.UserName, user.Password, user.EmailId, user.AccountType.ToString(), user.Id.ToString()); string msg = SocioBoard.Helper.MailSender.ReSendEMail(user.UserName, user.Password, user.EmailId, user.AccountType.ToString(), user.Id.ToString()).Trim(); Response.Write(msg + "~" + user.EmailId); } } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
protected void Page_Load(object sender, EventArgs e) { try { #region for You can use only 30 days as Unpaid User SocioBoard.Domain.User user = (User)Session["LoggedUser"]; if (user.PaymentStatus.ToLower() == "unpaid") { if (!SBUtils.IsUserWorkingDaysValid(user.ExpiryDate)) { // ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('You can use only 30 days as Unpaid User !');", true); Session["GreaterThan30Days"] = "GreaterThan30Days"; Response.Redirect("../Settings/Billing.aspx"); } } #endregion } catch (Exception ex) { Console.WriteLine("Error : " + ex.StackTrace); } }
public string getNewFollowing(User user, string profileId,int days) { string strTwtFollowing = string.Empty; try { //SocioBoard.Domain.User user = (User)Session["LoggedUser"]; TwitterStatsRepository objtwtStatsRepo = new TwitterStatsRepository(); ArrayList arrTwtStats = objtwtStatsRepo.getTwitterStatsByIdDay(user.Id, profileId, days); string str = string.Empty; foreach (var item in arrTwtStats) { Array temp = (Array)item; strTwtFollowing += (temp.GetValue(3).ToString()) + ","; } if (arrTwtStats.Count < 7) { for (int i = 0; i < 7 - arrTwtStats.Count; i++) { str += "0,"; } } strTwtFollowing = str + strTwtFollowing; strTwtFollowing = strTwtFollowing.Substring(0, strTwtFollowing.Length - 1); // strTwtArray += "]"; } catch (Exception Err) { Console.Write(Err.Message.ToString()); } return strTwtFollowing; }
public void AddUserRefreeRelation(User objReferee, User objReference) { try { logger.Error("Entered AddUserRefreeRelation"); UserRefRelation objUserRefRelation = new UserRefRelation(); UserRefRelationRepository objUserRefRelationRepository = new UserRefRelationRepository(); objUserRefRelation.Id = Guid.NewGuid(); objUserRefRelation.RefereeUserId = objReferee.Id; objUserRefRelation.ReferenceUserId = objReference.Id; objUserRefRelation.ReferenceUserEmail = objReference.EmailId; objUserRefRelation.RefereeUserEmail = objReferee.EmailId; objUserRefRelation.EntryDate = DateTime.Now; objUserRefRelation.Status = "0"; objUserRefRelationRepository.AddUserRefRelation(objUserRefRelation); logger.Error("Coming out of AddUserRefreeRelation"); } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } }
//public User GetById(int id) //{ // using (ISession session = NHibernateHelper.OpenSession()) // { // User user = session // .CreateCriteria(typeof(User)) // .Add(Restrictions.Eq("UserId", id)) // .UniqueResult<User>(); // return user; // } //} public static void Update(User user) { using (NHibernate.ISession session = SessionFactory.GetNewSession()) { using (NHibernate.ITransaction transaction = session.BeginTransaction()) { try { int i = session.CreateQuery("Update User set ProfileUrl =:profileurl, UserName =: username , EmailId=:emailid,UserStatus=:userstatus,ExpiryDate=:expirydate,TimeZone=:timezone where Id = :twtuserid") .SetParameter("twtuserid", user.Id) .SetParameter("profileurl", user.ProfileUrl) .SetParameter("username", user.UserName) .SetParameter("emailid", user.EmailId) .SetParameter("userstatus", user.UserStatus) .SetParameter("expirydate", user.ExpiryDate) .SetParameter("timezone", user.TimeZone) .ExecuteUpdate(); transaction.Commit(); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } } }
public void GetFollowersAgeWise(int days) { try { SocioBoard.Domain.User user = (User)Session["LoggedUser"]; TwitterStatsRepository objtwtStatsRepo = new TwitterStatsRepository(); object arrTwtStats = objtwtStatsRepo.getFollowersAgeCount(user.Id, days); if (arrTwtStats != null) { string[] arr = ((IEnumerable)arrTwtStats).Cast <object>().Select(x => x.ToString()).ToArray(); for (int i = 0; i < arr.Count(); i++) { strTwtAgeArray += arr[i] + ","; } strTwtAgeArray = "[" + strTwtAgeArray.Substring(0, strTwtAgeArray.Length - 1) + "]"; } else { strTwtAgeArray = "[0,0,0,0,0,0,0]"; } //strTwtArray += "]"; } catch (Exception Err) { strTwtAgeArray = "[0,0,0,0,0,0,0]"; //Response.Write(Err.Message.ToString()); } }
protected void Page_Load(object sender, EventArgs e) { try { //string redi = "http://www.facebook.com/dialog/oauth/?scope=publish_stream,read_stream,read_insights,manage_pages,user_checkins,user_photos,read_mailbox,manage_notifications,read_page_mailboxes,email,user_videos,offline_access&client_id=" + ConfigurationManager.AppSettings["ClientId"] + "&redirect_uri=" + ConfigurationManager.AppSettings["RedirectUrl"] + "&response_type=code"; //Session["login"] = "******"; //Response.Redirect(redi,true); SocioBoard.Domain.User user = (User)Session["LoggedUser"]; if (Request.QueryString["type"] != null) { if (Request.QueryString["type"] == "fb") { facebook(Request.QueryString["msg"]); // Response.Write("success"); } if (Request.QueryString["type"] == "twt") { twitter(Request.QueryString["msg"]); // Response.Write("success"); } if (Request.QueryString["type"] == "getuserid") { string sitename = ConfigurationManager.AppSettings["MailSenderDomain"]; Response.Write("success<:>" + sitename + "Registration.aspx?refid=" + user.Id); } } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public void getProfileCount() { SocioBoard.Domain.User user = (User)Session["LoggedUser"]; SocialProfilesRepository objProfile = new SocialProfilesRepository(); List <SocialProfile> lstProfile = objProfile.getAllSocialProfilesOfUser(user.Id); strProfileCOunt = lstProfile.Count().ToString(); }
private string InviteMember(string fname, string lname, string email) { SocioBoard.Domain.User user = (User)Session["LoggedUser"]; UserRepository objUserRepository = new UserRepository(); string res = ""; try { Registration reg = new Registration(); string tid = reg.MD5Hash(email); MailHelper mailhelper = new MailHelper(); string mailpath = HttpContext.Current.Server.MapPath("~/Layouts/Mails/FriendInvitation.htm"); string html = File.ReadAllText(mailpath); string fromemail = ConfigurationManager.AppSettings["fromemail"]; string usernameSend = ConfigurationManager.AppSettings["username"]; string host = ConfigurationManager.AppSettings["host"]; string port = ConfigurationManager.AppSettings["port"]; string pass = ConfigurationManager.AppSettings["password"]; string website = ConfigurationManager.AppSettings["MailSenderDomain"]; string urllogin = website + "Default.aspx"; // string registrationurl = "http://dev.socioboard.com/Registration.aspx?refid=256f9c69-6b6a-4409-a309-b1f6d1f8e43b"; string registrationurl = website + "Registration.aspx?refid=" + user.Id; html = html.Replace("%replink%", registrationurl); // string Body = mailhelper.InvitationMailByCloudSponge(html, fname+" "+lname, "*****@*****.**", "", urllogin, registrationurl); string Body = mailhelper.InvitationMailByCloudSponge(html, fname + " " + lname, user.EmailId, "", urllogin, registrationurl); string Subject = "You have been invited to Socioboard by " + user.EmailId; // MailHelper.SendMailMessage(host, int.Parse(port.ToString()), fromemail, pass, email, string.Empty, string.Empty, Subject, Body); MailHelper objMailHelper = new MailHelper(); if (!objUserRepository.IsUserExist(email)) { res = objMailHelper.SendMailByMandrill(host, Convert.ToInt32(port), fromemail, "", email, "", "", Subject, Body, usernameSend, pass); if (res == "Success") { res = "Mail sent successfully!"; } } else { res = "EmailId Already Exist!"; } //MailHelper.SendSendGridMail(host, Convert.ToInt32(port), fromemail, "", email, "", "", Subject, Body, usernameSend, pass); } catch (Exception ex) { Console.WriteLine("Error : " + ex.StackTrace); } return(res); }
protected void groupsselection_SelectedIndexChanged(object sender, EventArgs e) { SocioBoard.Domain.User user = (User)Session["LoggedUser"]; string GroupNames = string.Empty; TeamRepository objTeamRepository = new TeamRepository(); Team lstDetails = objTeamRepository.getAllGroupsDetails(user.EmailId.ToString(), Guid.Parse(groupsselection.SelectedValue), user.Id); Session["GroupName"] = lstDetails; Session["groupcheck"] = groupsselection.SelectedValue; NewMethod(user); }
/// <summary> /// Add a new student in the database. /// </summary> /// <param name="student">Student object</param> public static void Add(User user) { using (NHibernate.ISession session = SessionFactory.GetNewSession()) { using (NHibernate.ITransaction transaction = session.BeginTransaction()) { session.Save(user); transaction.Commit(); } } }
protected void Page_Load(object sender, EventArgs e) { try { SocioBoard.Domain.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 btnchangestatus.Attributes.Add("onclick", "return checkStatusInfo();"); User loginInfoEmail = (User)Session["LoggedUser"]; if (Session["LoggedUser"] != null) { custid = loginInfoEmail.Id; blackcount.InnerHtml = Convert.ToString((int)Session["CountMessages"]); custname = loginInfoEmail.UserName; } else { Response.Redirect("/Default.aspx", false); } if (!IsPostBack) { this.rdbtnmytask_CheckedChanged(sender, e); } } catch (Exception ex) { logger.Error(ex.Message); } }
protected void Page_Load(object sender, EventArgs e) { try { SocioBoard.Domain.User user = (User)Session["LoggedUser"]; if (user == null) { Response.Redirect("Default.aspx"); } } catch (Exception ex) { Console.WriteLine("Error : " + ex.StackTrace); } }
public void getFollowFollowersMonth() { SocioBoard.Domain.User user = (User)Session["LoggedUser"]; TwitterStatsRepository objtwtStatsRepo = new TwitterStatsRepository(); ArrayList objtwtffMonth = objtwtStatsRepo.getFollowerFollowingCountMonth(user.Id); string[,] arrMon = new string[12, 3]; for (int i = 0; i < objtwtffMonth.Count; i++) { string month = string.Empty; string monfollower = string.Empty; string monfollowing = string.Empty; string[] arr = new string[1]; try { arr = ((IEnumerable)objtwtffMonth[i]).Cast <object>().Select(x => x.ToString()).ToArray(); int m = int.Parse(arr[2].ToString()) - 1; arrMon[m, 2] = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(int.Parse(arr[2].ToString())); arrMon[m, 0] = arr[0]; arrMon[m, 1] = arr[1]; } catch (Exception Err) { } } for (int r = 0; r < 12; r++) { if (arrMon[r, 2] == null) { arrMon[r, 2] = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(r + 1); arrMon[r, 0] = "0"; arrMon[r, 1] = "0"; } } for (int j = 0; j < 12; j++) { strMonth = strMonth + "'" + arrMon[j, 2] + "',"; strFollowerMonth += arrMon[j, 0] + ","; strFollowingMonth += arrMon[j, 1] + ","; } strFollowerMonth = "[" + strFollowerMonth.Substring(0, strFollowerMonth.Length - 1) + "]"; strFollowingMonth = "[" + strFollowingMonth.Substring(0, strFollowingMonth.Length - 1) + "]"; strMonth = "[" + strMonth.Substring(0, strMonth.Length - 1) + "]"; }
/// <summary> /// This function check Is User Exist or Not created by Abhay Kr 5-2-2014 /// </summary> /// <param name="UserId"></param> /// <returns>bool</returns> public bool IsUserValid(string UserId, ref User user) { bool ret = false; try { UserRepository objUserRepository = new UserRepository(); user = objUserRepository.getUsersById(Guid.Parse(UserId)); if (user != null) ret = true; } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } return ret; }
protected void btnSave_Click(object sender, EventArgs e) { try { User user = new User(); user.Id =Guid.Parse(Request.QueryString["id"].ToString()); user.EmailId = txtEmail.Text; user.ExpiryDate = Convert.ToDateTime(datepicker.Text); user.UserName = txtName.Text; user.UserStatus=1; UserRepository.Update(user); } catch (Exception Err) { logger.Error(Err.Message); Console.Write(Err.StackTrace); } }
public int SetPaymentStatus(Guid guid) { int res = 0; try { UserRepository objUserRepository = new UserRepository(); User user = new Domain.User(); user.Id = guid; user.PaymentStatus = "paid"; res = objUserRepository.UpdatePaymentStatusByUserId(user); } catch (Exception ex) { Console.WriteLine("Error : " + ex.StackTrace); } return(res); }
public int SetPaymentStatus(Guid guid) { int res = 0; try { UserRepository objUserRepository = new UserRepository(); User user = new Domain.User(); user.Id = guid; user.PaymentStatus = "paid"; res=objUserRepository.UpdatePaymentStatusByUserId(user); } catch (Exception ex) { Console.WriteLine("Error : " + ex.StackTrace); } return res; }
/// <summary> /// Add a new student in the database. /// </summary> /// <param name="student">Student object</param> public static void Add(User user) { using (NHibernate.ISession session = SessionFactory.GetNewSession()) { using (NHibernate.ITransaction transaction = session.BeginTransaction()) { try { session.Save(user); transaction.Commit(); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } } }
public string Register(string EmailId, string Password, string AccountType, string FirstName, string LastName) { try { UserRepository userrepo = new UserRepository(); if (!userrepo.IsUserExist(EmailId)) { Registration regObject = new Registration(); User user = new User(); user.AccountType = AccountType; user.EmailId = EmailId; user.CreateDate = DateTime.Now; user.ExpiryDate = DateTime.Now.AddMonths(1); user.Password = regObject.MD5Hash(Password); user.PaymentStatus = "unpaid"; user.ProfileUrl = string.Empty; user.TimeZone = string.Empty; user.UserName = FirstName + " " + LastName; user.UserStatus = 1; user.Id = Guid.NewGuid(); UserRepository.Add(user); MailSender.SendEMail(user.UserName,Password, EmailId); return new JavaScriptSerializer().Serialize(user); } else { return "Email Already Exists"; } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return "Something Went Wrong"; } }
public string GetFollowersAgeWise(User user,int days) { string strTwtAgeArray = string.Empty; try { TwitterStatsRepository objtwtStatsRepo = new TwitterStatsRepository(); object arrTwtStats = objtwtStatsRepo.getFollowersAgeCount(user.Id,days); string[] arr = ((IEnumerable)arrTwtStats).Cast<object>().Select(x => x.ToString()).ToArray(); strTwtAgeArray="0,"; for (int i = 0; i < arr.Count(); i++) { strTwtAgeArray += arr[i] + ","; } strTwtAgeArray = strTwtAgeArray.Substring(0, strTwtAgeArray.Length - 1) ; //strTwtArray += "]"; } catch (Exception Err) { Console.Write(Err.Message.ToString()); } return strTwtAgeArray; }
public string ChangePassword(string EmailId, string Password, string NewPassword) { try { User user = new User(); UserRepository userrepo = new UserRepository(); int i = userrepo.ChangePassword(NewPassword, Password, EmailId); if (i == 1) { return "Password Changed Successfully"; } else { return "Invalid EmailId"; } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return "Please Try Again"; } }
public void getNewFriends(int days) { try { SocioBoard.Domain.User user = (User)Session["LoggedUser"]; FacebookStatsRepository objfbStatsRepo = new FacebookStatsRepository(); ArrayList arrFbStats = objfbStatsRepo.getAllFacebookStatsOfUser(user.Id, days); strFBArray = "["; int intdays = 1; // Get facebook page like ... FacebookAccountRepository ObjAcFbAccount = new FacebookAccountRepository(); int TotalLikes = ObjAcFbAccount.getPagelikebyUserId(user.Id); foreach (var item in arrFbStats) { Array temp = (Array)item; strFBArray += int.Parse(temp.GetValue(3).ToString()) + int.Parse(temp.GetValue(4).ToString()) + ","; //spanFbFriends.InnerHtml = (int.Parse(temp.GetValue(3).ToString()) + int.Parse(temp.GetValue(4).ToString())).ToString(); spanFbFriends.InnerHtml = (TotalLikes).ToString(); intdays++; } if (intdays < 7) { for (int j = 0; j < 7 - intdays; j++) { strFBArray = strFBArray + "0,"; } } strFBArray = strFBArray.Substring(0, strFBArray.Length - 1) + "]"; // strFBArray += "]"; } catch (Exception Err) { Response.Write(Err.Message.ToString()); } }
public int UpdateReferenceUserByUserId(User user) { int i = 0; try { using (NHibernate.ISession session = SessionFactory.GetNewSession()) { using (NHibernate.ITransaction transaction = session.BeginTransaction()) { try { i = session.CreateQuery("Update User set ReferenceStatus =:referenceStatus where Id = :id") .SetParameter("referenceStatus", user.ReferenceStatus) .SetParameter("id", user.Id) .ExecuteUpdate(); transaction.Commit(); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } return i; }
protected void btnSignup_Click(object sender, ImageClickEventArgs e) { User user = new User(); UserRepository userrepo = new UserRepository(); try { if (txtPassword.Text == txtConfirmPassword.Text) { user.AccountType = "free"; user.CreateDate = DateTime.Now; user.ExpiryDate = DateTime.Now.AddMonths(1); user.Id = Guid.NewGuid(); user.UserName = txtUserName.Text; user.Password = this.MD5Hash(txtPassword.Text); user.EmailId = txtEmail.Text; user.UserStatus = 1; if (!userrepo.IsUserExist(user.EmailId)) { UserRepository.Add(user); MailSender.SendEMail(txtUserName.Text, txtPassword.Text, txtEmail.Text); lblerror.Text = "registered successfully !" + "<a href=\"login.aspx\">login</a>"; } else { lblerror.Text = "email already exists " + "<a href=\"login.aspx\">login</a>"; } } } catch (Exception ex) { lblerror.Text = "Please Insert Correct Information"; Console.WriteLine(ex.StackTrace); } }
public void getNewFollowers(int days) { try { SocioBoard.Domain.User user = (User)Session["LoggedUser"]; TwitterStatsRepository objtwtStatsRepo = new TwitterStatsRepository(); ArrayList arrTwtStats = objtwtStatsRepo.getAllTwitterStatsOfUser(user.Id, days); strTwtArray = "["; int intdays = 1; int NewTweet_Count = 0; foreach (var item in arrTwtStats) { Array temp = (Array)item; strTwtArray += (temp.GetValue(4)) + ","; //spanTwtFollowers.InnerHtml = temp.GetValue(4).ToString(); //hTwtFollowers.InnerHtml = temp.GetValue(4).ToString(); NewTweet_Count += Convert.ToInt16(temp.GetValue(4)); } spanTwtFollowers.InnerHtml = NewTweet_Count.ToString(); hTwtFollowers.InnerHtml = NewTweet_Count.ToString(); if (intdays < 7) { for (int j = 0; j < 7 - intdays; j++) { strTwtArray = strTwtArray + "0,"; } } strTwtArray = strTwtArray.Substring(0, strTwtArray.Length - 1) + "]"; // strTwtArray += "]"; } catch (Exception Err) { Response.Write(Err.Message.ToString()); } }
protected void Page_Load(object sender, EventArgs e) { string ret = string.Empty; try { User objUser = new User(); UserRepository objUserRepository = new UserRepository(); scheduling objscheduling = new scheduling(); ScheduledMessage objScheduledMessage = new ScheduledMessage(); ScheduledMessageRepository objScheduledMessageRepository = new ScheduledMessageRepository(); List<ScheduledTracker> lstScheduledTracker = objScheduledMessageRepository.GetAllScheduledDetails(); foreach (ScheduledTracker item in lstScheduledTracker) { try { //List<ScheduledMessage> lstScheduledMessage = objScheduledMessageRepository.getAllMessagesOfUser(Guid.Parse(item._Id)); List<ScheduledMessage> lstUnsentScheduledMessage = objScheduledMessageRepository.getAllIUnSentMessagesOfUser(Guid.Parse(item._Id)); objUser = objUserRepository.getUsersById(Guid.Parse(item._Id)); ret += "<tr class=\"gradeX\"><td><a href=\"ScheduledMessageDetail.aspx?id=" + objUser.Id + "\">" + objUser.UserName + "</a></td><td>" + item._count + "</td><td>" + (item._count - lstUnsentScheduledMessage.Count()) + "</td><td>" + lstUnsentScheduledMessage.Count() + "</td></tr>"; } catch (Exception ex) { Console.WriteLine(ex.Message); } } } catch (Exception ex) { Console.WriteLine(ex.Message); } Response.Write(ret); }
protected void Page_Load(object sender, EventArgs e) { try { System.IO.StreamReader sr; Newtonsoft.Json.Linq.JObject jo; try { if (Request.QueryString["op"].ToString() == "postFBGroupFeeds") { sr = new System.IO.StreamReader(Request.InputStream); string data = ""; data = sr.ReadToEnd(); jo = Newtonsoft.Json.Linq.JObject.Parse(data); gid = Server.UrlDecode((string)jo["gid"]); ack = Server.UrlDecode((string)jo["ack"]); string msg = Server.UrlDecode((string)jo["msg"]); string res = PostFBGroupFeeds(ack, gid, msg); Response.Write(res); return; } else if (Request.QueryString["op"].ToString() == "postonselectedgroup") { try { logger.Error("cod is here"); SocioBoard.Domain.User user = (SocioBoard.Domain.User)Session["LoggedUser"]; ScheduledMessageRepository objScheduledMessageRepository = new ScheduledMessageRepository(); GroupScheduleMessageRepository objGroupScheduleMEssageRepository = new GroupScheduleMessageRepository(); ScheduledMessage schmessage = new ScheduledMessage(); GroupScheduleMessage grpschmessage = new GroupScheduleMessage(); string msg = string.Empty; string title = string.Empty; string intrval = string.Empty; string fbuserid = string.Empty; string linuserid = string.Empty; string clienttime = string.Empty; var SelectedGroupId = Request.Form["gid"].ToString().Split(','); title = Request.Form["title"].ToString(); msg = Request.Form["msg"].ToString(); intrval = Request.Form["intervaltime"].ToString(); fbuserid = Request.Form["fbuserid"].ToString(); linuserid = Request.Form["linuserid"].ToString(); clienttime = Request.Form["clienttime"].ToString(); string time = Request.Form["timeforsch"]; string date = Request.Form["dateforsch"]; var files = Request.Files.Count; var fi = Request.Files["files"]; string file = string.Empty; int intervaltime = 0; intervaltime = Convert.ToInt32(intrval); Session["scheduletime"] = null; string filepath = string.Empty; if (Request.Files.Count > 0) { if (fi != null) { var path = Server.MapPath("~/Contents/img/upload"); filepath = path + "/" + fi.FileName; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } fi.SaveAs(filepath); } } foreach (var item in SelectedGroupId) { string[] networkingwithid = item.Split('_'); if (networkingwithid[1] == "lin") { try { string[] arrliusrid = linuserid.Split('_'); string linkuserid = arrliusrid[1]; string groupid = networkingwithid[2]; string profileid = networkingwithid[0]; if (intervaltime != 0) { if (Session["scheduletime"] == null) { string servertime = this.CompareDateWithclient(clienttime, date + " " + time); schmessage.ScheduleTime = Convert.ToDateTime(servertime); DateTime d1 = schmessage.ScheduleTime; DateTime d2 = d1.AddMinutes(intervaltime); Session["scheduletime"] = d2; } else { DateTime d1 = (DateTime)Session["scheduletime"]; schmessage.ScheduleTime = d1; DateTime d2 = d1.AddMinutes(intervaltime); Session["scheduletime"] = d2; } } SocialStream sociostream = new SocialStream(); string message = title + "$%^_^%$" + msg; schmessage.CreateTime = DateTime.Now; schmessage.ProfileType = "linkedingroup"; schmessage.ProfileId = profileid; schmessage.Id = Guid.NewGuid(); if (Request.Files.Count > 0) { // schmessage.PicUrl = ConfigurationManager.AppSettings["MailSenderDomain"] + "Contents/img/upload/" + fi.FileName; var path = System.Configuration.ConfigurationManager.AppSettings["MailSenderDomain"] + "Contents/img/upload"; file = path + "/" + fi.FileName; schmessage.PicUrl = file; } else { schmessage.PicUrl = "Null"; } schmessage.ClientTime = Convert.ToDateTime(clienttime); schmessage.ShareMessage = message;; schmessage.UserId = user.Id; schmessage.Status = false; logger.Error("cod is befor insert in schedule message"); objScheduledMessageRepository.addNewMessage(schmessage); grpschmessage.Id = Guid.NewGuid(); grpschmessage.ScheduleMessageId = schmessage.Id; grpschmessage.GroupId = groupid; objGroupScheduleMEssageRepository.addNewGroupMessage(grpschmessage); } catch (Exception ex) { logger.Error("cod is in exception"); logger.Error(ex.StackTrace); Console.WriteLine(ex.StackTrace); } } else if (networkingwithid[1] == "fb") { try { string facebookgrouppost = string.Empty; string[] arrfbusrid = fbuserid.Split('_'); string acccesstkn = arrfbusrid[1]; string groupid = networkingwithid[2]; string profileid = networkingwithid[0]; if (intervaltime != 0) { if (Session["scheduletime"] == null) { string servertime = this.CompareDateWithclient(clienttime, date + " " + time); schmessage.ScheduleTime = Convert.ToDateTime(servertime); DateTime d1 = schmessage.ScheduleTime; DateTime d2 = d1.AddMinutes(intervaltime); Session["scheduletime"] = d2; } else { DateTime d1 = (DateTime)Session["scheduletime"]; schmessage.ScheduleTime = d1; DateTime d2 = d1.AddMinutes(intervaltime); Session["scheduletime"] = d2; } } schmessage.CreateTime = DateTime.Now; schmessage.ProfileType = "facebookgroup"; schmessage.ProfileId = profileid; schmessage.Id = Guid.NewGuid(); if (Request.Files.Count > 0) { // schmessage.PicUrl = ConfigurationManager.AppSettings["MailSenderDomain"] + "Contents/img/upload/" + fi.FileName; var path = System.Configuration.ConfigurationManager.AppSettings["MailSenderDomain"] + "Contents/img/upload"; file = path + "/" + fi.FileName; schmessage.PicUrl = file; } else { schmessage.PicUrl = "Null"; } schmessage.ClientTime = Convert.ToDateTime(clienttime); schmessage.ShareMessage = msg; schmessage.UserId = user.Id; schmessage.Status = false; objScheduledMessageRepository.addNewMessage(schmessage); grpschmessage.Id = Guid.NewGuid(); grpschmessage.ScheduleMessageId = schmessage.Id; grpschmessage.GroupId = groupid; objGroupScheduleMEssageRepository.addNewGroupMessage(grpschmessage); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } }//End For Each } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } Response.Write("success"); } else if (Request.QueryString["op"].ToString() == "getlinkedInGroupDetails") { string GroupData = string.Empty; string picurl = string.Empty; string summary = string.Empty; string groupid = Request.QueryString["groupid"].ToString(); string LinkedinUserId = Request.QueryString["linkuserid"].ToString(); LinkedInAccount arrLinkedinAccoount = linAccRepo.getLinkedinAccountDetailsById(LinkedinUserId); oAuthLinkedIn objoAuthLinkedIn = new oAuthLinkedIn(); objoAuthLinkedIn.Token = arrLinkedinAccoount.OAuthToken; objoAuthLinkedIn.Verifier = arrLinkedinAccoount.OAuthVerifier; objoAuthLinkedIn.TokenSecret = arrLinkedinAccoount.OAuthSecret; List <GlobusLinkedinLib.App.Core.LinkedInGroup.Group_Updates> lstlinkedinGroup = GetGroupPostDetail(objoAuthLinkedIn, 50, groupid); try { foreach (var item in lstlinkedinGroup) { picurl = ""; if (string.IsNullOrEmpty(item.pictureurl)) { picurl = "../../Contents/img/blank_img.png"; } else { picurl = item.pictureurl; } if (string.IsNullOrEmpty(item.summary)) { summary = "."; } else { summary = item.summary; } GroupData += "<div id=\"abhay\" class=\"storyContent\"><a class=\"actorPhoto\"><img src=\"" + picurl + "\" alt=\"\" style=\"width:56px;height:56px\"></a>" + "<div class=\"storyInnerContent\"><div class=\"actordescription\"><a class=\"passiveName\">" + item.firstname + " " + item.lastname + " - " + item.headline + "</a></div>" + "<div class=\"messagebody\"><div style=\"color: black;font-size: large;margin-bottom: 15\">" + Server.HtmlEncode(item.title) + "</div>" + summary + "</div>" + "</div>" + "<p style=\"margin-left:60px\">comments(" + item.comments_total + ") likes- " + item.likes_total + "</p><p><span class=\"comment\" onclick=\"FollowPosts('" + groupid + "','" + item.GpPostid + "','" + LinkedinUserId + "','" + item.isFollowing + "')\">" + getfollow(item.isFollowing) + "</span></p>" + "<p><span class=\"comment\" onclick=\"LikePosts('" + groupid + "','" + item.GpPostid + "','" + LinkedinUserId + "','" + item.isLiked + "')\">" + getlike(item.isLiked) + "</span></p>" + "<p><span id=\"commentlin_" + item.GpPostid + "\" class=\"comment\" onclick=\"CommentOnPosts('" + item.GpPostid + "')\">Comment</span></p>" + "<p class=\"commeent_box\"><input id=\"textlin_" + item.GpPostid + "\" type=\"text\" class=\"put_comments\"></p>" + "<p><span onclick=\"commentLin('" + groupid + "','" + item.GpPostid + "','" + LinkedinUserId + "')\" id=\"oklin_" + item.GpPostid + "\" class=\"ok\">ok</span><span id=\"cancellin_" + item.GpPostid + "\" onclick=\"cancelLin('" + item.GpPostid + "');\" class=\"cancel\"> cancel</span></p>" + "</div>"; } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } Response.Write(GroupData); return; } else if (Request.QueryString["op"].ToString() == "linkedCommentOnPost") { try { string message = Request.QueryString["message"].ToString(); string groupid = Request.QueryString["groupid"].ToString(); string LinkedinUserId = (Request.QueryString["LinkedinUserId"]); string GpPostid = (Request.QueryString["GpPostid"]); LinkedInAccount arrLinkedinAccoount = linAccRepo.getLinkedinAccountDetailsById(LinkedinUserId); oAuthLinkedIn objoAuthLinkedIn = new oAuthLinkedIn(); objoAuthLinkedIn.Token = arrLinkedinAccoount.OAuthToken; objoAuthLinkedIn.Verifier = arrLinkedinAccoount.OAuthVerifier; objoAuthLinkedIn.TokenSecret = arrLinkedinAccoount.OAuthSecret; SocialStream sociostream = new SocialStream(); string res = sociostream.SetCommentOnPost(objoAuthLinkedIn, GpPostid, message); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } else if (Request.QueryString["op"].ToString() == "FollowPost") { try { string msg = string.Empty; string postid = Request.QueryString["groupid"].ToString(); string LinkedinUserId = (Request.QueryString["LinkedinUserId"]); int isFollowing = Convert.ToInt16(Request.QueryString["isFollowing"]); if (isFollowing == 1) { msg = "false"; } else { msg = "true"; } LinkedInAccount arrLinkedinAccoount = linAccRepo.getLinkedinAccountDetailsById(LinkedinUserId); oAuthLinkedIn objoAuthLinkedIn = new oAuthLinkedIn(); objoAuthLinkedIn.Token = arrLinkedinAccoount.OAuthToken; objoAuthLinkedIn.Verifier = arrLinkedinAccoount.OAuthVerifier; objoAuthLinkedIn.TokenSecret = arrLinkedinAccoount.OAuthSecret; SocialStream sociostream = new SocialStream(); string res = sociostream.SetFollowCountUpdate(objoAuthLinkedIn, postid, msg); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } else if (Request.QueryString["op"].ToString() == "postLinkedInGroupFeeds") { string result = "success"; try { string groupid = Request.QueryString["groupid"].ToString(); string title = Request.QueryString["title"].ToString(); string LinkedinUserId = Request.QueryString["LinkedinUserId"].ToString(); string msg = Request.QueryString["msg"].ToString(); LinkedInAccount arrLinkedinAccoount = linAccRepo.getLinkedinAccountDetailsById(LinkedinUserId); oAuthLinkedIn objoAuthLinkedIn = new oAuthLinkedIn(); objoAuthLinkedIn.Token = arrLinkedinAccoount.OAuthToken; objoAuthLinkedIn.Verifier = arrLinkedinAccoount.OAuthVerifier; objoAuthLinkedIn.TokenSecret = arrLinkedinAccoount.OAuthSecret; SocialStream sociostream = new SocialStream(); string res = sociostream.SetPostUpdate(objoAuthLinkedIn, groupid, msg, title); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } Response.Write(result); } else if (Request.QueryString["op"].ToString() == "LikePost") { try { string msg = string.Empty; string postid = Request.QueryString["groupid"].ToString(); string LinkedinUserId = (Request.QueryString["LinkedinUserId"]); int isLike = Convert.ToInt16(Request.QueryString["isLike"]); if (isLike == 1) { msg = "false"; } else { msg = "true"; } LinkedInAccount arrLinkedinAccoount = linAccRepo.getLinkedinAccountDetailsById(LinkedinUserId); oAuthLinkedIn objoAuthLinkedIn = new oAuthLinkedIn(); objoAuthLinkedIn.Token = arrLinkedinAccoount.OAuthToken; objoAuthLinkedIn.Verifier = arrLinkedinAccoount.OAuthVerifier; objoAuthLinkedIn.TokenSecret = arrLinkedinAccoount.OAuthSecret; SocialStream sociostream = new SocialStream(); string res = sociostream.SetLikeUpdate(objoAuthLinkedIn, postid, msg); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } } catch (Exception ex) { Console.WriteLine("Error : " + ex.StackTrace); } sr = new System.IO.StreamReader(Request.InputStream); string line = ""; line = sr.ReadToEnd(); jo = Newtonsoft.Json.Linq.JObject.Parse(line); gid = Server.UrlDecode((string)jo["gid"]); ack = Server.UrlDecode((string)jo["ack"]); returndata = fgroupfeeds(ack, gid); Response.Write(returndata); } catch (Exception ex) { Console.WriteLine("Error : " + ex.StackTrace); } }
protected void btnRegister_Click(object sender, ImageClickEventArgs e) { User user = new User(); UserRepository userrepo = new UserRepository(); SocioBoard.Helper.SessionFactory.configfilepath = Server.MapPath("~/hibernate.cfg.xml"); try { if (txtPassword.Text == txtConfirmPassword.Text) { user.PaymentStatus = "unpaid"; user.AccountType = Request.QueryString["type"]; if (user.AccountType == string.Empty) { user.AccountType = AccountType.Deluxe.ToString(); } user.CreateDate = DateTime.Now; user.ExpiryDate = DateTime.Now.AddMonths(1); user.Id = Guid.NewGuid(); user.UserName = txtFirstName.Text + " " + txtLastName.Text; user.Password = this.MD5Hash(txtPassword.Text); user.EmailId = txtEmail.Text; user.UserStatus = 1; if (!userrepo.IsUserExist(user.EmailId)) { UserRepository.Add(user); SocialSuitePro.Helper.MailSender.SendEMail(txtFirstName.Text + " " + txtLastName.Text, txtPassword.Text, txtEmail.Text); TeamRepository teamRepo = new TeamRepository(); Team team = teamRepo.getTeamByEmailId(txtEmail.Text); if (team != null) { Guid teamid = Guid.Parse(Request.QueryString["tid"]); teamRepo.updateTeamStatus(teamid); TeamMemberProfileRepository teamMemRepo = new TeamMemberProfileRepository(); List<TeamMemberProfile> lstteammember = teamMemRepo.getAllTeamMemberProfilesOfTeam(team.Id); foreach (TeamMemberProfile item in lstteammember) { try { SocialProfilesRepository socialRepo = new SocialProfilesRepository(); SocialProfile socioprofile = new SocialProfile(); socioprofile.Id = Guid.NewGuid(); socioprofile.ProfileDate = DateTime.Now; socioprofile.ProfileId = item.ProfileId; socioprofile.ProfileType = item.ProfileType; socioprofile.UserId = user.Id; socialRepo.addNewProfileForUser(socioprofile); if (item.ProfileType == "facebook") { try { FacebookAccount fbAccount = new FacebookAccount(); FacebookAccountRepository fbAccountRepo = new FacebookAccountRepository(); FacebookAccount userAccount = fbAccountRepo.getUserDetails(item.ProfileId); fbAccount.AccessToken = userAccount.AccessToken; fbAccount.EmailId = userAccount.EmailId; fbAccount.FbUserId = item.ProfileId; fbAccount.FbUserName = userAccount.FbUserName; fbAccount.Friends = userAccount.Friends; fbAccount.Id = Guid.NewGuid(); fbAccount.IsActive = true; fbAccount.ProfileUrl = userAccount.ProfileUrl; fbAccount.Type = userAccount.Type; fbAccount.UserId = user.Id; fbAccountRepo.addFacebookUser(fbAccount); } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } } else if (item.ProfileType == "twitter") { try { TwitterAccount twtAccount = new TwitterAccount(); TwitterAccountRepository twtAccRepo = new TwitterAccountRepository(); TwitterAccount twtAcc = twtAccRepo.getUserInfo(item.ProfileId); twtAccount.FollowersCount = twtAcc.FollowersCount; twtAccount.FollowingCount = twtAcc.FollowingCount; twtAccount.Id = Guid.NewGuid(); twtAccount.IsActive = true; twtAccount.OAuthSecret = twtAcc.OAuthSecret; twtAccount.OAuthToken = twtAcc.OAuthToken; twtAccount.ProfileImageUrl = twtAcc.ProfileImageUrl; twtAccount.ProfileUrl = twtAcc.ProfileUrl; twtAccount.TwitterName = twtAcc.TwitterName; twtAccount.TwitterScreenName = twtAcc.TwitterScreenName; twtAccount.TwitterUserId = twtAcc.TwitterUserId; twtAccount.UserId = user.Id; twtAccRepo.addTwitterkUser(twtAccount); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); logger.Error(ex.Message); } } else if (item.ProfileType == "instagram") { try { InstagramAccount insAccount = new InstagramAccount(); InstagramAccountRepository insAccRepo = new InstagramAccountRepository(); InstagramAccount InsAcc = insAccRepo.getInstagramAccountById(item.ProfileId); insAccount.AccessToken = InsAcc.AccessToken; insAccount.FollowedBy = InsAcc.FollowedBy; insAccount.Followers = InsAcc.Followers; insAccount.Id = Guid.NewGuid(); insAccount.InstagramId = item.ProfileId; insAccount.InsUserName = InsAcc.InsUserName; insAccount.IsActive = true; insAccount.ProfileUrl = InsAcc.ProfileUrl; insAccount.TotalImages = InsAcc.TotalImages; insAccount.UserId = user.Id; insAccRepo.addInstagramUser(insAccount); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); logger.Error(ex.Message); } } else if (item.ProfileType == "linkedin") { try { LinkedInAccount linkAccount = new LinkedInAccount(); LinkedInAccountRepository linkedAccountRepo = new LinkedInAccountRepository(); LinkedInAccount linkAcc = linkedAccountRepo.getLinkedinAccountDetailsById(item.ProfileId); linkAccount.Id = Guid.NewGuid(); linkAccount.IsActive = true; linkAccount.LinkedinUserId = item.ProfileId; linkAccount.LinkedinUserName = linkAcc.LinkedinUserName; linkAccount.OAuthSecret = linkAcc.OAuthSecret; linkAccount.OAuthToken = linkAcc.OAuthToken; linkAccount.OAuthVerifier = linkAcc.OAuthVerifier; linkAccount.ProfileImageUrl = linkAcc.ProfileImageUrl; linkAccount.ProfileUrl = linkAcc.ProfileUrl; linkAccount.UserId = user.Id; linkedAccountRepo.addLinkedinUser(linkAccount); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); logger.Error(ex.Message); } } } catch (Exception ex) { logger.Error(ex.Message); } } } lblerror.Text = "Registered Successfully !" + "<a href=\"Default.aspx\">Login</a>"; } else { lblerror.Text = "Email Already Exists " + "<a href=\"Default.aspx\">login</a>"; } } } catch (Exception ex) { logger.Error(ex.StackTrace); lblerror.Text = "Please Insert Correct Information"; Console.WriteLine(ex.StackTrace); } }
protected void Page_Load(object sender, EventArgs e) { try { UserRefRelationRepository objUserRefRelationRepository = new UserRefRelationRepository(); UserRepository userrepo = new UserRepository(); Registration regObject = new Registration(); TeamRepository objTeamRepo = new TeamRepository(); NewsRepository objNewsRepo = new NewsRepository(); AdsRepository objAdsRepo = new AdsRepository(); UserActivation objUserActivation = new UserActivation(); UserActivationRepository objUserActivationRepository = new UserActivationRepository(); SocialProfilesRepository objSocioRepo = new SocialProfilesRepository(); GroupRepository objGroupRepository = new GroupRepository(); TeamMemberProfileRepository objTeamMemberProfileRepository = new TeamMemberProfileRepository(); Team team = new Team(); SocioBoard.Domain.User user = (User)Session["LoggedUser"]; try { if (Session["GroupName"] == null) { Groups objGroupDetails = objGroupRepository.getGroupDetail(user.Id); team = objTeamRepo.getAllDetails(objGroupDetails.Id, user.EmailId); Session["GroupName"] = team; } else { team = (SocioBoard.Domain.Team)Session["GroupName"]; } } catch (Exception ex) { logger.Error("Error: " + ex.Message); } Session["facebooktotalprofiles"] = null; if (user.Password == null) { Response.Redirect("/Pricing.aspx"); } #region Days remaining if (Session["days_remaining"] == null) { if (user.PaymentStatus == "unpaid" && user.AccountType != "Free") { int daysremaining = (user.ExpiryDate.Date - DateTime.Now.Date).Days; if (daysremaining < 0) { daysremaining = -1; } Session["days_remaining"] = daysremaining; //ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('You are using '" + user.AccountType + "' account only '" + daysremaining + "' days is remaining !');", true); if (daysremaining <= -1) { } else if (daysremaining == 0) { ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Your trial " + user.AccountType + " account will expire end of the day, please upgrade to paid plan.');", true); } else { ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Your trial " + user.AccountType + " account will expire in " + daysremaining + " days, please upgrade to paid plan.');", true); } } } #endregion #region for You can use only 30 days as Unpaid User if (user.PaymentStatus.ToLower() == "unpaid" && user.AccountType != "Free") { if (!SBUtils.IsUserWorkingDaysValid(user.ExpiryDate)) { // ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('You can use only 30 days as Unpaid User !');", true); Session["GreaterThan30Days"] = "GreaterThan30Days"; Response.Redirect("/Settings/Billing.aspx"); } } Session["GreaterThan30Days"] = null; #endregion if (!IsPostBack) { try { if (user == null) { Response.Redirect("Default.aspx"); } } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.StackTrace); } try { objUserActivation = objUserActivationRepository.GetUserActivationStatus(user.Id.ToString()); } catch (Exception ex) { Session["objUserActivationException"] = "objUserActivationException"; Console.WriteLine(ex.Message); logger.Error(ex.StackTrace); } #region Count Used Accounts try { if (user.AccountType.ToString().ToLower() == AccountType.Deluxe.ToString().ToLower()) { tot_acc = 50; } else if (user.AccountType.ToString().ToLower() == AccountType.Standard.ToString().ToLower()) { tot_acc = 10; } else if (user.AccountType.ToString().ToLower() == AccountType.Premium.ToString().ToLower()) { tot_acc = 20; } else if (user.AccountType.ToString().ToLower() == AccountType.Free.ToString().ToLower()) { tot_acc = 5; } else if (user.AccountType.ToString().ToLower() == AccountType.SocioBasic.ToString().ToLower()) { tot_acc = 100; } else if (user.AccountType.ToString().ToLower() == AccountType.SocioStandard.ToString().ToLower()) { tot_acc = 200; } else if (user.AccountType.ToString().ToLower() == AccountType.SocioPremium.ToString().ToLower()) { tot_acc = 500; } else if (user.AccountType.ToString().ToLower() == AccountType.SocioDeluxe.ToString().ToLower()) { tot_acc = 1000; } profileCount = objSocioRepo.getAllSocialProfilesOfUser(user.Id).Count; Session["ProfileCount"] = profileCount; Session["TotalAccount"] = tot_acc; try { Groups lstDetail = objGroupRepository.getGroupName(team.GroupId); if (lstDetail.GroupName == "Socioboard") { usedAccount.InnerHtml = " using " + profileCount + " of " + tot_acc; } } catch (Exception ex) { logger.Error(ex.StackTrace); } } catch (Exception ex) { logger.Error(ex.StackTrace); } #endregion try { Groups lstDetails = objGroupRepository.getGroupName(team.GroupId); if (lstDetails.GroupName != "Socioboard") { expander.Attributes.CssStyle.Add("display", "none"); } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } //this is used to check whether facebok account Already Exist if (Session["alreadyexist"] != null) { ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('This Profile is Already Added please add aother Account!');", true); Session["alreadyexist"] = null; } if (Session["alreadypageexist"] != null) { ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('This Page is Already Added please add aother Page!');", true); Session["alreadypageexist"] = null; } if (!string.IsNullOrEmpty(Request.QueryString["type"])) { try { userrepo.UpdateAccountType(user.Id, Request.QueryString["type"]); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); logger.Error(ex.StackTrace); } } //acrossProfile.InnerHtml = "Across " + user.UserName + "'s Twitter and Facebook accounts"; teamMem.InnerHtml = "managing " + user.UserName; try { News nws = objNewsRepo.getNewsForHome(); //divNews.InnerHtml = nws.NewsDetail; } catch (Exception Err) { Console.Write(Err.StackTrace); logger.Error(Err.StackTrace); } try { ArrayList lstads = objAdsRepo.getAdsForHome(); if (lstads.Count < 1) { if (user.PaymentStatus.ToUpper() == "PAID") { bindads.InnerHtml = "<img src=\"../Contents/img/admin/ads.png\" alt=\"\" >"; } else { #region ADS Script bindads.InnerHtml = "<script async src=\"//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js\"></script>" + "<!-- socioboard -->" + "<ins class=\"adsbygoogle\"" + "style=\"display:inline-block;width:250px;height:250px\"" + "data-ad-client=\"ca-pub-7073257741073458\"" + "data-ad-slot=\"9533254693\"></ins>" + "<script>" + "(adsbygoogle = window.adsbygoogle || []).push({});" + "</script>"; #endregion } } foreach (var item in lstads) { Array temp = (Array)item; //imgAds.ImageUrl = temp.GetValue(2).ToString(); if (user.PaymentStatus.ToUpper() == "PAID") { bindads.InnerHtml = "<img src=\"" + temp.GetValue(2).ToString() + "\" alt=\"\" style=\"width:246px;height:331px\">"; } else { #region ADS Script bindads.InnerHtml = "<script async src=\"//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js\"></script>" + "<!-- socioboard -->" + "<ins class=\"adsbygoogle\"" + "style=\"display:inline-block;width:250px;height:250px\"" + "data-ad-client=\"ca-pub-7073257741073458\"" + "data-ad-slot=\"9533254693\"></ins>" + "<script>" + "(adsbygoogle = window.adsbygoogle || []).push({});" + "</script>"; #endregion } break; // ads.ImageUrl; } } catch (Exception Err) { Console.Write(Err.StackTrace); logger.Error(Err.StackTrace); } #region Team Member Count try { GroupRepository grouprepo = new GroupRepository(); string groupsofhome = string.Empty; List <Groups> lstgroups = grouprepo.getAllGroups(user.Id); if (lstgroups.Count != 0) { foreach (Groups item in lstgroups) { groupsofhome += "<li><a href=\"../Settings/InviteMember.aspx?q=" + item.Id + "\"><img src=\"../Contents/img/groups_.png\" alt=\"\" style=\" margin-right:5px;\"> " + item.GroupName + "</a></li>"; } getAllGroupsOnHome.InnerHtml = groupsofhome; } } catch (Exception ex) { logger.Error(ex.StackTrace); } #endregion try { string strTeam = string.Empty; List <Team> teams = objTeamRepo.getAllTeamsOfUser(user.Id, team.GroupId, user.EmailId); foreach (Team item in teams) { strTeam += "<div class=\"userpictiny\"><a target=\"_blank\" href=\"#\">" + "<img width=\"48\" height=\"48\" title=\"" + item.FirstName + "\" alt=\"\" src=\"../Contents/img/blank_img.png\">" + "</a></div>"; } team_member.InnerHtml = strTeam; } catch (Exception Err) { Console.Write(Err.StackTrace); } #region Add Fan Page try { if (Session["fbSocial"] != null) { if (Session["fbSocial"] == "p") { FacebookAccount objFacebookAccount = (FacebookAccount)Session["fbpagedetail"]; // string strpageUrl = "https://graph.facebook.com/" + objFacebookAccount.FacebookId + "/accounts"; // objFacebookUrlBuilder = (FacebookUrlBuilder)Session["FacebookInsightUser"]; // string strData = objAuthentication.RequestUrl(strpageUrl, objFacebookAccount.Token); // JObject output = objWebRequest.FacebookRequest(strData, "Get"); FacebookClient fb = new FacebookClient(); fb.AccessToken = objFacebookAccount.AccessToken; dynamic output = fb.Get("/me/accounts"); // JArray data = (JArray)output["data"]; DataTable dtFbPage = new DataTable(); dtFbPage.Columns.Add("Email"); dtFbPage.Columns.Add("PageId"); dtFbPage.Columns.Add("PageName"); dtFbPage.Columns.Add("status"); dtFbPage.Columns.Add("customer_id"); string strPageDiv = string.Empty; if (output != null) { foreach (var item in output["data"]) { if (item.category.ToString() != "Application") { strPageDiv += "<div><a id=\"A1\" onclick=\"getInsights('" + item["id"].ToString() + "','" + item["name"].ToString() + "')\"><span>" + item["name"].ToString() + "</span> </a></div>"; fbpage.InnerHtml = strPageDiv; } } } else { strPageDiv += "<div>No Pages Found</div>"; } Page.ClientScript.RegisterStartupScript(Page.GetType(), "my", " ShowDialogHome(false);", true); Session["fbSocial"] = null; } } } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.StackTrace); } #endregion #region InsightsData try { decimal malecount = 0, femalecount = 0, cnt = 0; FacebookStatsRepository objfbStatsRepo = new FacebookStatsRepository(); double daysSub = (DateTime.Now - user.CreateDate).TotalDays; int userdays; if (daysSub > 0 && daysSub <= 1) { userdays = 1; } else { userdays = (int)daysSub; } ArrayList arrFbStats = objfbStatsRepo.getAllFacebookStatsOfUser(user.Id, userdays); //ArrayList arrFbStats = objfbStatsRepo.getTotalFacebookStatsOfUser(user.Id); Random rNum = new Random(); foreach (var item in arrFbStats) { Array temp = (Array)item; cnt += int.Parse(temp.GetValue(3).ToString()) + int.Parse(temp.GetValue(4).ToString()); malecount += int.Parse(temp.GetValue(3).ToString()); femalecount += int.Parse(temp.GetValue(4).ToString()); } try { decimal mc = (malecount / cnt) * 100; male = Convert.ToInt16(mc); } catch (Exception Err) { Console.Write(Err.StackTrace); logger.Error(Err.StackTrace); } try { decimal fc = (femalecount / cnt) * 100; female = Convert.ToInt16(fc); } catch (Exception Err) { Console.Write(Err.StackTrace); logger.Error(Err.StackTrace); } int twtAccCount = objSocioRepo.getAllSocialProfilesTypeOfUser(user.Id, "twitter").Count; if (twtAccCount > 1) { twtmale = rNum.Next(100); twtfemale = 100 - twtmale; } else if (twtAccCount == 1) { twtmale = 100; twtfemale = 0; } Session["twtGender"] = twtmale + "," + twtfemale; } catch (Exception Err) { Console.Write(Err.Message.ToString()); logger.Error(Err.StackTrace); } //getgrphData(); // getNewFriends(7); // getNewFriends(); // getNewFollowers(); #endregion #region GetFollower try { String TwtProfileId = string.Empty; TwitterStatsRepository objtwtStatsRepo = new TwitterStatsRepository(); List <TeamMemberProfile> objTeamMemberProfile = objTeamMemberProfileRepository.getTwtTeamMemberProfileData(team.Id); foreach (TeamMemberProfile item in objTeamMemberProfile) { TwtProfileId += item.ProfileId + ','; } TwtProfileId = TwtProfileId.Substring(0, TwtProfileId.Length - 1); List <TwitterStats> arrTwtStats = objtwtStatsRepo.getAllAccountDetail(TwtProfileId); //strTwtArray = "["; int NewTweet_Count = 0; string TotalFollower = string.Empty; foreach (TwitterStats item in arrTwtStats) { NewTweet_Count += item.FollowerCount; } if (NewTweet_Count >= 100000) { TotalFollower = (System.Math.Round(((float)NewTweet_Count / 1000000), 2)) + "M"; } else if (NewTweet_Count > 1000 && NewTweet_Count < 100000) { TotalFollower = (System.Math.Round(((float)NewTweet_Count / 1000), 2)) + "K"; } else { TotalFollower = NewTweet_Count.ToString(); } spanNewTweets.InnerHtml = TotalFollower; } catch (Exception Err) { Console.Write(Err.Message.ToString()); logger.Error(Err.StackTrace); } #endregion #region GetFacebookFanPage try { String FbProfileId = string.Empty; FacebookStatsRepository objFacebookStatsRepository = new FacebookStatsRepository(); List <TeamMemberProfile> objTeamMemberProfile = objTeamMemberProfileRepository.getTeamMemberProfileData(team.Id); foreach (TeamMemberProfile item in objTeamMemberProfile) { FbProfileId += item.ProfileId + ','; } FbProfileId = FbProfileId.Substring(0, FbProfileId.Length - 1); List <FacebookStats> arrFbStats = objFacebookStatsRepository.getAllAccountDetail(FbProfileId); //strTwtArray = "["; int NewFbFan_Count = 0; string TotalFriends = string.Empty; foreach (FacebookStats item in arrFbStats) { NewFbFan_Count += item.FanCount; } if (NewFbFan_Count >= 100000) { TotalFriends = (System.Math.Round(((float)NewFbFan_Count / 1000000), 2)) + "M"; } else if (NewFbFan_Count > 1000 && NewFbFan_Count < 100000) { TotalFriends = (System.Math.Round(((float)NewFbFan_Count / 1000), 2)) + "K"; } else { TotalFriends = NewFbFan_Count.ToString(); } spanFbFans.InnerHtml = TotalFriends; } catch (Exception Err) { Console.Write(Err.Message.ToString()); logger.Error(Err.StackTrace); } #endregion #region IncomingMessages try { FacebookFeedRepository fbFeedRepo = new FacebookFeedRepository(); int fbmessagescout = fbFeedRepo.countUnreadMessages(user.Id); TwitterMessageRepository twtMsgRepo = new TwitterMessageRepository(); int twtcount = twtMsgRepo.getCountUnreadMessages(user.Id); Session["CountMessages"] = fbmessagescout + twtcount; } catch (Exception ex) { logger.Error(ex.StackTrace); } #endregion #region NewIncomingMessage try { String FbProfileId = string.Empty; String TwtProfileId = string.Empty; List <TeamMemberProfile> objTeamMemberProfile = objTeamMemberProfileRepository.getAllTeamMemberProfilesOfTeam(team.Id); foreach (TeamMemberProfile item in objTeamMemberProfile) { try { if (item.ProfileType == "facebook") { FbProfileId += item.ProfileId + ','; } else if (item.ProfileType == "twitter") { TwtProfileId += item.ProfileId + ','; } } catch (Exception Err) { Console.Write(Err.StackTrace); logger.Error(Err.StackTrace); } } try { FbProfileId = FbProfileId.Substring(0, FbProfileId.Length - 1); } catch (Exception Err) { Console.Write(Err.StackTrace); logger.Error(Err.StackTrace); } try { TwtProfileId = TwtProfileId.Substring(0, TwtProfileId.Length - 1); } catch (Exception Err) { Console.Write(Err.StackTrace); logger.Error(Err.StackTrace); } FacebookFeedRepository objFacebookFeedRepository = new FacebookFeedRepository(); List <FacebookFeed> alstfb = objFacebookFeedRepository.getAllFeedDetail(FbProfileId); // FacebookMessageRepository objFacebookMessageRepository = new FacebookMessageRepository(); TwitterMessageRepository objtwttatsRepo = new TwitterMessageRepository(); // List<FacebookMessage> alstfb = objFacebookMessageRepository.getAllMessageDetail(FbProfileId); List <TwitterMessage> alstTwt = objtwttatsRepo.getAlltwtMessages(TwtProfileId); int TotalFbMsgCount = 0; int TotalTwtMsgCount = 0; try { TotalFbMsgCount = alstfb.Count; } catch (Exception Err) { Console.Write(Err.StackTrace); logger.Error(Err.StackTrace); } try { TotalTwtMsgCount = alstTwt.Count; } catch (Exception Err) { Console.Write(Err.StackTrace); logger.Error(Err.StackTrace); } spanIncoming.InnerHtml = (TotalFbMsgCount + TotalTwtMsgCount).ToString(); string profileid = string.Empty; ScheduledMessageRepository objScheduledMessageRepository = new ScheduledMessageRepository(); foreach (TeamMemberProfile item in objTeamMemberProfile) { profileid += item.ProfileId + ','; } profileid = profileid.Substring(0, profileid.Length - 1); spanSent.InnerHtml = objScheduledMessageRepository.getAllSentMessageDetails(profileid).Count().ToString(); } catch (Exception Err) { Console.Write(Err.StackTrace); logger.Error(Err.StackTrace); } } #endregion } catch (Exception Err) { Console.Write(Err.StackTrace); } }
protected void Page_Load(object sender, EventArgs e) { try { if (Request.QueryString != null || Request.Form !=null) { } if (HttpContext.Current.Session["PackageDetails"] != null && Session["LoggedUser"] != null) { //ScriptManager.RegisterStartupScript(this, GetType(), "Paypall Success", "<script type=\"text/javascript\">alert('Your transaction has been Suceeded !');</script>", true); //ScriptManager.RegisterStartupScript(this, GetType(), "Script", "MyJavascriptFunction();", true); //if (Session["LoggedUser"] !=null) { User user = (User)Session["LoggedUser"]; Package packageDetails = (Package)HttpContext.Current.Session["PackageDetails"]; UserPackageRelation objUserPackageRelation = new UserPackageRelation(); objUserPackageRelation.Id = new Guid(); objUserPackageRelation.PackageStatus = true; objUserPackageRelation.UserId = user.Id; objUserPackageRelation.PackageId = packageDetails.Id; objUserPackageRelation.ModifiedDate = DateTime.Now; // Code for Update & Insert in UserPackageRelationRepository UserPackageRelationRepository objUserPackageRelationRepository = new UserPackageRelationRepository(); objUserPackageRelationRepository.UpdateUserPackageRelation(user); objUserPackageRelationRepository.AddUserPackageRelation(objUserPackageRelation); // Code for Update in User UserRepository objUserRepository = new UserRepository(); User objUser = new User(); objUser.Id = user.Id; objUser.AccountType = packageDetails.PackageName; objUser.PaymentStatus = "Paid"; objUser.CreateDate = DateTime.Now; objUser.EmailId = user.EmailId; objUser.UserName = user.UserName; objUser.ProfileUrl = user.ProfileUrl; objUser.ExpiryDate = user.ExpiryDate; objUser.UserStatus = user.UserStatus; objUser.Password = user.Password; objUser.TimeZone = user.TimeZone; objUserRepository.UpdateCreatDateByUserId(objUser); Session["LoggedUser"] = objUser; Response.Redirect("../Home.aspx?paymentTransaction=Success"); } } } catch (Exception ex) { Console.WriteLine("Error : " + ex.StackTrace); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { SocioBoard.Domain.User user = (User)Session["LoggedUser"]; if (user == null) { Response.Redirect("/Default.aspx"); } TwitterAccountRepository objtwtAccRepo = new TwitterAccountRepository(); TeamMemberProfileRepository objTeamMemberProfileRepository = new TeamMemberProfileRepository(); SocioBoard.Domain.Team team = (SocioBoard.Domain.Team)Session["GroupName"]; List <TeamMemberProfile> allprofiles = objTeamMemberProfileRepository.getTwtTeamMemberProfileData(team.Id); foreach (TeamMemberProfile item in allprofiles) { TwtProfileId += item.ProfileId + ','; } TwtProfileId = TwtProfileId.Substring(0, TwtProfileId.Length - 1); List <TwitterAccount> arrTwtAcc = objtwtAccRepo.getAllAccountDetail(TwtProfileId); string twtUser = string.Empty; string twtProfileId = string.Empty; spandiv.InnerHtml = "from " + DateTime.Now.AddDays(-15).ToShortDateString() + "-" + DateTime.Now.ToShortDateString(); foreach (TwitterAccount item in arrTwtAcc) { twtUser = twtUser + "<div class=\"teitter\"><ul><li><a id=\"facebook_connect\" onclick='getProfileGraph(\"" + item.TwitterUserId + "\",\"" + item.TwitterScreenName + "\",\"" + item.ProfileImageUrl + "\",\"" + item.FollowersCount + "\")'><span style=\"float:left;margin: 3px 0 0 5px;\" >" + item.TwitterScreenName + "</span></a></li></ul></div>"; twtProfileId = item.TwitterUserId; divnameId.InnerHtml = item.TwitterScreenName; profileImg.ImageUrl = item.ProfileImageUrl; spanFollowers.InnerHtml = item.FollowersCount.ToString(); Session["twtProfileId"] = twtProfileId; } divtwtUser.InnerHtml = twtUser; try { strTwtArray = objtwtStatsHelper.getNewFollowers(twtProfileId, 15); int index = strTwtArray.LastIndexOf(','); divnewFollower.InnerHtml = strTwtArray.Substring(index + 1); } catch (Exception Err) { Console.Write(Err.StackTrace); } try { strTwtFollowing = objtwtStatsHelper.getNewFollowing(twtProfileId, 15); int index = strTwtFollowing.LastIndexOf(','); divFollowed.InnerHtml = strTwtArray.Substring(index + 1); } catch (Exception Err) { Console.Write(Err.StackTrace); } try { strTwtAge = objtwtStatsRepo.getAgeDiffCount(twtProfileId, 15); } catch (Exception Err) { Console.Write(Err.StackTrace); } try { strIncomingMsg = objtwtStatsHelper.getIncomingMsg(twtProfileId, 15); } catch (Exception Err) { Console.Write(Err.StackTrace); } try { strDmRecieve = objtwtStatsHelper.getDirectMessageRecieve(twtProfileId, 15); } catch (Exception Err) { Console.Write(Err.StackTrace); } try { strDMSent = objtwtStatsHelper.getDirectMessageSent(twtProfileId, 15); } catch (Exception Err) { Console.Write(Err.StackTrace); } try { strSentMsg = objtwtStatsHelper.getSentMsg(twtProfileId, 15); } catch (Exception Err) { Console.Write(Err.StackTrace); } try { strRetweet = objtwtStatsHelper.getRetweets(twtProfileId, 15); } catch (Exception Err) { Console.Write(Err.StackTrace); } try { strEngInf = objtwtStatsHelper.getEngagements(twtProfileId, 15) + "@" + objtwtStatsHelper.getInfluence(twtProfileId, 15) + "@" + objtwtStatsHelper.getdate(twtProfileId, 15); } catch (Exception Err) { Console.Write(Err.StackTrace); } try { strAgeDiff = objtwtStatsRepo.getAgeDiffCount(twtProfileId, 15); } catch (Exception Err) { Console.Write(Err.StackTrace); } try { strTwtMention = objtwtStatsHelper.getTwtMention(twtProfileId, 15); } catch (Exception Err) { Console.Write(Err.StackTrace); } var strgenderTwt = Session["twtGender"].ToString().Split(','); //divtwtMale.InnerHtml = strgenderTwt[0] + "%"; // divtwtfeMale.InnerHtml = strgenderTwt[1] + "%"; } }
public string getRetweets(User user, string profileId,int days) { TwitterMessageRepository objretwt = new TwitterMessageRepository(); string strArray = string.Empty; string str = string.Empty; try { int cnt = 0; ArrayList alstTwt = objretwt.getRetweetStatsByProfileId(user.Id, profileId,days); if (alstTwt != null) { // strArray = "["; for (int i = 0; i < alstTwt.Count; i++) { strArray = strArray + alstTwt[i].ToString() + ","; cnt++; } } if (cnt < 7) { for (int j = 0; j < 7 - cnt; j++) { //strArray = strArray + "0,"; str += "0,"; } } //strArray = strArray.Substring(0, strArray.Length - 1); strArray = str + strArray; strArray = strArray.Substring(0, strArray.Length - 1); } catch (Exception Err) { Console.Write(Err.StackTrace); } return strArray; }
public void getgrphData(int days) { try { SocioBoard.Domain.User user = (User)Session["LoggedUser"]; FacebookAccountRepository objfb = new FacebookAccountRepository(); TwitterMessageRepository objtwttatsRepo = new TwitterMessageRepository(); ArrayList alstfb = objfb.getFbMessageStats(user.Id, days); ArrayList alstTwt = objtwttatsRepo.gettwtMessageStats(user.Id, days); strArray = "["; int _spanIncoming = 0; for (int i = 0; i < 7; i++) { string strTwtCnt = string.Empty; string strFbCnt = string.Empty; if (alstTwt.Count <= i) { strTwtCnt = "0"; } else { strTwtCnt = alstTwt[i].ToString(); } if (alstfb.Count <= i) { strFbCnt = "0"; } else { strFbCnt = alstfb[i].ToString(); } strArray = strArray + "[" + strFbCnt + "," + strTwtCnt + "],"; //spanIncoming.InnerHtml = (int.Parse(strTwtCnt) + int.Parse(strFbCnt)).ToString(); _spanIncoming = (int.Parse(strTwtCnt) + int.Parse(strFbCnt)); } spanIncoming.InnerHtml = _spanIncoming.ToString(); strArray = strArray.Substring(0, strArray.Length - 1) + "]"; ArrayList alstTwtFeed = objtwttatsRepo.gettwtFeedsStats(user.Id, days); ArrayList alstFBFeed = objfb.getFbFeedsStats(user.Id, days); strSentArray = "["; int _spanSent = 0; if (alstFBFeed.Count > 0 && alstTwtFeed.Count > 0) { int alstSentCount = 0; for (int i = 0; i < 7; i++) { string strTwtFeedCnt = string.Empty; string strFbFeedCnt = string.Empty; if (alstTwtFeed.Count <= i) { strTwtFeedCnt = "0"; } else { strTwtFeedCnt = alstTwtFeed[i].ToString(); } if (alstFBFeed.Count <= i) { strFbFeedCnt = "0"; } else { strFbFeedCnt = alstFBFeed[i].ToString(); } strSentArray = strSentArray + "[" + strFbFeedCnt + "," + strTwtFeedCnt + "],"; //spanSent.InnerHtml = (int.Parse(strFbFeedCnt) + int.Parse(strTwtFeedCnt)).ToString(); _spanSent = (int.Parse(strFbFeedCnt) + int.Parse(strTwtFeedCnt)); } spanSent.InnerHtml = (_spanSent).ToString(); } if (alstFBFeed.Count == 0 || alstTwtFeed.Count == 0) { for (int i = 0; i < 7; i++) { strSentArray += strSentArray + "[0,0],"; } } strSentArray = strSentArray.Substring(0, strSentArray.Length - 1) + "]"; TwitterStatsRepository objtwtStatsRepo = new TwitterStatsRepository(); ArrayList alstEng = objtwtStatsRepo.getAllTwitterStatsOfUser(user.Id, days); int ii = 1; strEng = "["; foreach (var item in alstEng) { Array temp = (Array)item; strEng = strEng + "{ x: new Date(2012, " + ii + ", " + ii + "), y:" + temp.GetValue(7) + "},"; ii++; } if (alstEng.Count == 0) { for (int i = 0; i < 10; i++) { strEng = strEng + "{ x: new Date(2012, " + ii + ", " + ii + "), y:0},"; } } strEng = strEng.Substring(0, strEng.Length - 1) + "]"; hmsgsent.InnerHtml = alstTwtFeed.Count.ToString(); hretweet.InnerHtml = objtwttatsRepo.getUserRetweetCount(user.Id).ToString(); } catch (Exception Err) { Response.Write(Err.StackTrace); } }
public string getSentMsg(User user, string profileId,int days) { string strArray = string.Empty; try { TwitterMessageRepository objtwttatsRepo = new TwitterMessageRepository(); ArrayList alstTwt = objtwttatsRepo.gettwtFeedsStatsByProfileId(user.Id, profileId,days); // strArray = "["; int cnt = 0; if (alstTwt.Count > 0) { for (int i = 0; i < alstTwt.Count; i++) { strArray = strArray + alstTwt[i].ToString(); cnt++; } } if (cnt < 7) { for (int j = 0; j < 7 - cnt; j++) { strArray = strArray + ",0"; } } // strArray += "]"; } catch (Exception Err) { Console.Write(Err.StackTrace); } return strArray; }
public string getDirectMessageSent(User user, string profileId) { TwitterDirectMessageRepository objtwtdm = new TwitterDirectMessageRepository(); string strArray = string.Empty; try { int cnt = 0; ArrayList alstTwt = objtwtdm.gettwtDMSendStatsByProfileId(user.Id, profileId); if (alstTwt != null) { // strArray = "["; for (int i = 0; i < alstTwt.Count; i++) { strArray = strArray + alstTwt[i].ToString() + ","; cnt++; } } if (cnt < 7) { for (int j = 0; j < 7 - cnt; j++) { strArray = strArray + "0,"; } } strArray = strArray.Substring(0, strArray.Length - 1); } catch (Exception Err) { Console.Write(Err.StackTrace); } return strArray; }
/// <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); } else { socioprofilerepo.updateSocialProfile(socioprofile); } } else { 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); }
protected void btnninty_Click(object sender, EventArgs e) { SocioBoard.Domain.User user = (User)Session["LoggedUser"]; twtProfileId = Session["twtProfileId"].ToString(); TwtProfileDetails(twtProfileId); spandiv.InnerHtml = "from " + DateTime.Now.AddDays(-90).ToShortDateString() + "-" + DateTime.Now.ToShortDateString(); try { strTwtArray = objtwtStatsHelper.getNewFollowers(twtProfileId, 90); } catch (Exception Err) { Console.Write(Err.StackTrace); } try { strTwtFollowing = objtwtStatsHelper.getNewFollowing(twtProfileId, 90); } catch (Exception Err) { Console.Write(Err.StackTrace); } try { strTwtAge = objtwtStatsHelper.GetFollowersAgeWise(user, 90); } catch (Exception Err) { Console.Write(Err.StackTrace); } try { strIncomingMsg = objtwtStatsHelper.getIncomingMsg(twtProfileId, 90); } catch (Exception Err) { Console.Write(Err.StackTrace); } try { strDmRecieve = objtwtStatsHelper.getDirectMessageRecieve(twtProfileId, 90); } catch (Exception Err) { Console.Write(Err.StackTrace); } try { strDMSent = objtwtStatsHelper.getDirectMessageSent(twtProfileId, 90); } catch (Exception Err) { Console.Write(Err.StackTrace); } try { strSentMsg = objtwtStatsHelper.getSentMsg(twtProfileId, 90); } catch (Exception Err) { Console.Write(Err.StackTrace); } try { strRetweet = objtwtStatsHelper.getRetweets(twtProfileId, 90); } catch (Exception Err) { Console.Write(Err.StackTrace); } try { strEngInf = objtwtStatsHelper.getEngagements(twtProfileId, 90) + "@" + objtwtStatsHelper.getInfluence(twtProfileId, 90) + "@" + objtwtStatsHelper.getdate(twtProfileId, 90); } catch (Exception Err) { Console.Write(Err.StackTrace); } try { strAgeDiff = objtwtStatsRepo.getAgeDiffCount(twtProfileId, 90); } catch (Exception Err) { Console.Write(Err.StackTrace); } try { strTwtMention = objtwtStatsHelper.getTwtMention(twtProfileId, 90); } catch (Exception Err) { Console.Write(Err.StackTrace); } }
public User getUserInfoByEmail(string emailId) { User result = new User(); using (NHibernate.ISession session = SessionFactory.GetNewSession()) { using (NHibernate.ITransaction transaction = session.BeginTransaction()) { try { NHibernate.IQuery query = session.CreateQuery("from User u where u.EmailId = : email"); query.SetParameter("email", emailId); try { result = query.UniqueResult<User>(); } catch (Exception) { result = query.List<User>().ToList<User>()[0]; } return result; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return null; } } } }
//public string getRetweets(User user, string profileId) //{ // TwitterMessageRepository objretwt = new TwitterMessageRepository(); // string strArray = string.Empty; // try // { // int cnt = 0; // ArrayList alstTwt = objretwt.getRetweetStatsByProfileId(user.Id, profileId); // if (alstTwt != null) // { // // strArray = "["; // for (int i = 0; i < alstTwt.Count; i++) // { // strArray = strArray + alstTwt[i].ToString() + ","; // cnt++; // } // } // if (cnt < 7) // { // for (int j = 0; j < 7 - cnt; j++) // { // strArray = strArray + "0,"; // } // } // strArray = strArray.Substring(0, strArray.Length - 1); // } // catch (Exception Err) // { // Console.Write(Err.StackTrace); // } // return strArray; //} public string getEngagements(User user, string profileId,int days) { string strArray = string.Empty; try { TwitterStatsRepository objtwtstatsRepo = new TwitterStatsRepository(); ArrayList alstTwt = objtwtstatsRepo.getTwitterStatsById(user.Id, profileId,days); // strArray = "["; int cnt = 0; if (alstTwt.Count > 0) { foreach(var itemTS in alstTwt) { Array temp = (Array)itemTS; strArray = strArray + temp.GetValue(7).ToString(); cnt++; } } if (cnt < 7) { for (int j = 0; j < 7 - cnt; j++) { strArray = strArray + ",0"; } } // strArray += "]"; } catch (Exception Err) { Console.Write(Err.StackTrace); } return strArray; }
public int UpdateCreatDateByUserId(User user) { int i = 0; try { using (NHibernate.ISession session = SessionFactory.GetNewSession()) { using (NHibernate.ITransaction transaction = session.BeginTransaction()) { try { i = session.CreateQuery("Update User set CreateDate =:createDate, AccountType =: accountType , PaymentStatus=:paymentStatus where Id = :id") .SetParameter("createDate", user.CreateDate) .SetParameter("accountType", user.AccountType) .SetParameter("paymentStatus", user.PaymentStatus) .SetParameter("id", user.Id) .ExecuteUpdate(); transaction.Commit(); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } return i; }
public string getInfluence(User user, string profileId,int days) { string strArray = string.Empty; try { TwitterStatsRepository objtwtstatsRepo = new TwitterStatsRepository(); ArrayList alstTwt = objtwtstatsRepo.getTwitterStatsById(user.Id, profileId,days); // strArray = "["; int cnt = 0; string str = string.Empty; if (alstTwt.Count > 0) { foreach(var itemInf in alstTwt) { Array temp = (Array)itemInf; strArray = strArray + temp.GetValue(8).ToString() + ","; cnt++; } } if (cnt < 7) { for (int j = 0; j < 7 - cnt; j++) { str=str + "0,"; } } strArray = str + strArray.Substring(0,strArray.Length-1); } catch (Exception Err) { Console.Write(Err.StackTrace); } return strArray; }
public void UpdateUserReference(User objUser) { try { UserRepository objUserRepository = new UserRepository(); objUser.ReferenceStatus = "1"; objUserRepository.UpdateReferenceUserByUserId(objUser); } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } }
protected void Page_Load(object sender, EventArgs e) { try { if (Session["LoggedUser"] != null) { SocioBoard.Domain.User user = (User)Session["LoggedUser"]; } else { Response.Write("logout"); } if (Request.QueryString != null) { if (Request.QueryString["type"] == "GetMails") { returnresponse = GetFriendsEmail(Request.QueryString["hint"].ToString()); // GetFriendsEmail(Request.QueryString["hint"].ToString()); } if (Request.QueryString["type"] == "sendselectedmail") { string str = Request.Form["selectedmail"].ToString(); // Response.Write(SendAllSelectedMail(Request.Form["selectedmail"].ToString())); returnresponse = SendAllSelectedMail(Request.Form["selectedmail"].ToString()); } if (Request.QueryString["type"] == "sendmail") { string mail = Request.QueryString["mail"].ToString(); // Response.Write(InviteMember("", "", mail)); returnresponse = InviteMember("", "", mail); } if (Request.QueryString["type"] == "getContacts") { if (Session["api"] != null && Session["consent"] != null) { Api api = (Api)Session["api"]; ConsentResponse consent = (ConsentResponse)Session["consent"]; Session["api"] = null; Session["consent"] = null; List <string> lst = new List <string>(); string mails = GetMails(api, consent); //Response.Write(mails); returnresponse = mails; } } } } catch (Exception ex) { Console.WriteLine("Error : " + ex.StackTrace); } Response.Write(returnresponse); }
/// <summary> /// to check user reference and update user expiry , userrefrencerelation status /// created by Abhay Kr 5-3-2014 /// </summary> /// <param name="RefereeId"></param> /// <returns></returns> public bool IsUserReferenceActivated(string RefereeId) { //testing Console.WriteLine("Inside " + RefereeId); bool ret = false; try { User objUser = new User(); Package objPackage=new Package (); UserPackageRelation objUserPackageRelation=new UserPackageRelation (); UserRepository objUserRepository = new UserRepository(); UserPackageRelationRepository objUserPackageRelationRepository = new UserPackageRelationRepository(); UserRefRelation objUserRefRelation = new UserRefRelation(); UserRefRelationRepository objUserRefRelationRepository = new UserRefRelationRepository(); PackageRepository objPackageRepository = new PackageRepository(); objUserRefRelation.ReferenceUserId = (Guid.Parse(RefereeId)); //testing List<UserRefRelation> check =objUserRefRelationRepository.GetUserRefRelationInfo(); //testing List<UserRefRelation> lstUserRefRelation = objUserRefRelationRepository.GetUserRefRelationInfoByRefreeId(objUserRefRelation); if (lstUserRefRelation.Count > 0) { if (lstUserRefRelation[0].Status == "0") { objUserRefRelation = lstUserRefRelation[0]; objUserRefRelation.Status = "1"; objUser = objUserRepository.getUsersById(lstUserRefRelation[0].ReferenceUserId); objUser.ExpiryDate = objUser.ExpiryDate.AddDays(30); objUser.AccountType = "Premium"; objPackage = objPackageRepository.getPackageDetails("Premium"); objUserPackageRelation.Id=Guid.NewGuid(); objUserPackageRelation.UserId=objUser.Id; objUserPackageRelation.PackageId=objPackage.Id; objUserPackageRelation.ModifiedDate=DateTime.Now; objUserPackageRelation.PackageStatus=true; objUserPackageRelationRepository.AddUserPackageRelation(objUserPackageRelation); int objUserRepositoryresponse = objUserRepository.UpdateUserExpiryDateById(objUser); int objUserRefRelationRepositoryresponse = objUserRefRelationRepository.UpdateStatusById(objUserRefRelation); } } } catch (Exception ex) { logger.Error(ex.Message); } return ret; }
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); } }
protected void btnRegister_Click(object sender, ImageClickEventArgs e) { User user = new User(); UserRepository userrepo = new UserRepository(); UserActivation objUserActivation = new UserActivation(); Coupon objCoupon = new Coupon(); CouponRepository objCouponRepository = new CouponRepository(); SocioBoard.Helper.SessionFactory.configfilepath = Server.MapPath("~/hibernate.cfg.xml"); try { if (DropDownList1.SelectedValue == "Basic" || DropDownList1.SelectedValue == "Standard" || DropDownList1.SelectedValue == "Deluxe" || DropDownList1.SelectedValue == "Premium") { if (TextBox1.Text.Trim() != "") { string resp = SBUtils.GetCouponStatus(TextBox1.Text).ToString(); if (resp != "valid") { // ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert(Not valid);", true); ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('" + resp + "');", true); return; } } if (txtPassword.Text == txtConfirmPassword.Text) { user.PaymentStatus = "unpaid"; //user.AccountType = Request.QueryString["type"]; user.AccountType = DropDownList1.SelectedValue.ToString(); if (string.IsNullOrEmpty(user.AccountType)) { user.AccountType = AccountType.Free.ToString(); } user.CreateDate = DateTime.Now; user.ExpiryDate = DateTime.Now.AddMonths(1); user.Id = Guid.NewGuid(); user.UserName = txtFirstName.Text + " " + txtLastName.Text; user.Password = this.MD5Hash(txtPassword.Text); user.EmailId = txtEmail.Text; user.UserStatus = 1; user.ActivationStatus = "0"; if (TextBox1.Text.Trim() != "") { user.CouponCode = TextBox1.Text.Trim().ToString(); } if (!userrepo.IsUserExist(user.EmailId)) { UserRepository.Add(user); if (TextBox1.Text.Trim() != "") { objCoupon.CouponCode = TextBox1.Text.Trim(); List<Coupon> lstCoupon = objCouponRepository.GetCouponByCouponCode(objCoupon); objCoupon.Id = lstCoupon[0].Id; objCoupon.EntryCouponDate = lstCoupon[0].EntryCouponDate; objCoupon.ExpCouponDate = lstCoupon[0].ExpCouponDate; objCoupon.Status = "1"; objCouponRepository.SetCouponById(objCoupon); } Session["LoggedUser"] = user; objUserActivation.Id = Guid.NewGuid(); objUserActivation.UserId = user.Id; objUserActivation.ActivationStatus = "0"; UserActivationRepository.Add(objUserActivation); //add package start UserPackageRelation objUserPackageRelation = new UserPackageRelation(); UserPackageRelationRepository objUserPackageRelationRepository = new UserPackageRelationRepository(); PackageRepository objPackageRepository = new PackageRepository(); Package objPackage = objPackageRepository.getPackageDetails(user.AccountType); objUserPackageRelation.Id = new Guid(); objUserPackageRelation.PackageId = objPackage.Id; objUserPackageRelation.UserId = user.Id; objUserPackageRelation.ModifiedDate = DateTime.Now; objUserPackageRelation.PackageStatus = true; objUserPackageRelationRepository.AddUserPackageRelation(objUserPackageRelation); //end package SocioBoard.Helper.MailSender.SendEMail(txtFirstName.Text, txtPassword.Text, txtEmail.Text, user.AccountType.ToString(),user.Id.ToString()); TeamRepository teamRepo = new TeamRepository(); Team team = teamRepo.getTeamByEmailId(txtEmail.Text); if (team != null) { Guid teamid = Guid.Parse(Request.QueryString["tid"]); teamRepo.updateTeamStatus(teamid); TeamMemberProfileRepository teamMemRepo = new TeamMemberProfileRepository(); List<TeamMemberProfile> lstteammember = teamMemRepo.getAllTeamMemberProfilesOfTeam(team.Id); foreach (TeamMemberProfile item in lstteammember) { try { SocialProfilesRepository socialRepo = new SocialProfilesRepository(); SocialProfile socioprofile = new SocialProfile(); socioprofile.Id = Guid.NewGuid(); socioprofile.ProfileDate = DateTime.Now; socioprofile.ProfileId = item.ProfileId; socioprofile.ProfileType = item.ProfileType; socioprofile.UserId = user.Id; socialRepo.addNewProfileForUser(socioprofile); if (item.ProfileType == "facebook") { try { FacebookAccount fbAccount = new FacebookAccount(); FacebookAccountRepository fbAccountRepo = new FacebookAccountRepository(); FacebookAccount userAccount = fbAccountRepo.getUserDetails(item.ProfileId); fbAccount.AccessToken = userAccount.AccessToken; fbAccount.EmailId = userAccount.EmailId; fbAccount.FbUserId = item.ProfileId; fbAccount.FbUserName = userAccount.FbUserName; fbAccount.Friends = userAccount.Friends; fbAccount.Id = Guid.NewGuid(); fbAccount.IsActive = true; fbAccount.ProfileUrl = userAccount.ProfileUrl; fbAccount.Type = userAccount.Type; fbAccount.UserId = user.Id; fbAccountRepo.addFacebookUser(fbAccount); } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } } else if (item.ProfileType == "twitter") { try { TwitterAccount twtAccount = new TwitterAccount(); TwitterAccountRepository twtAccRepo = new TwitterAccountRepository(); TwitterAccount twtAcc = twtAccRepo.getUserInfo(item.ProfileId); twtAccount.FollowersCount = twtAcc.FollowersCount; twtAccount.FollowingCount = twtAcc.FollowingCount; twtAccount.Id = Guid.NewGuid(); twtAccount.IsActive = true; twtAccount.OAuthSecret = twtAcc.OAuthSecret; twtAccount.OAuthToken = twtAcc.OAuthToken; twtAccount.ProfileImageUrl = twtAcc.ProfileImageUrl; twtAccount.ProfileUrl = twtAcc.ProfileUrl; twtAccount.TwitterName = twtAcc.TwitterName; twtAccount.TwitterScreenName = twtAcc.TwitterScreenName; twtAccount.TwitterUserId = twtAcc.TwitterUserId; twtAccount.UserId = user.Id; twtAccRepo.addTwitterkUser(twtAccount); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); logger.Error(ex.Message); } } else if (item.ProfileType == "instagram") { try { InstagramAccount insAccount = new InstagramAccount(); InstagramAccountRepository insAccRepo = new InstagramAccountRepository(); InstagramAccount InsAcc = insAccRepo.getInstagramAccountById(item.ProfileId); insAccount.AccessToken = InsAcc.AccessToken; insAccount.FollowedBy = InsAcc.FollowedBy; insAccount.Followers = InsAcc.Followers; insAccount.Id = Guid.NewGuid(); insAccount.InstagramId = item.ProfileId; insAccount.InsUserName = InsAcc.InsUserName; insAccount.IsActive = true; insAccount.ProfileUrl = InsAcc.ProfileUrl; insAccount.TotalImages = InsAcc.TotalImages; insAccount.UserId = user.Id; insAccRepo.addInstagramUser(insAccount); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); logger.Error(ex.Message); } } else if (item.ProfileType == "linkedin") { try { LinkedInAccount linkAccount = new LinkedInAccount(); LinkedInAccountRepository linkedAccountRepo = new LinkedInAccountRepository(); LinkedInAccount linkAcc = linkedAccountRepo.getLinkedinAccountDetailsById(item.ProfileId); linkAccount.Id = Guid.NewGuid(); linkAccount.IsActive = true; linkAccount.LinkedinUserId = item.ProfileId; linkAccount.LinkedinUserName = linkAcc.LinkedinUserName; linkAccount.OAuthSecret = linkAcc.OAuthSecret; linkAccount.OAuthToken = linkAcc.OAuthToken; linkAccount.OAuthVerifier = linkAcc.OAuthVerifier; linkAccount.ProfileImageUrl = linkAcc.ProfileImageUrl; linkAccount.ProfileUrl = linkAcc.ProfileUrl; linkAccount.UserId = user.Id; linkedAccountRepo.addLinkedinUser(linkAccount); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); logger.Error(ex.Message); } } } catch (Exception ex) { logger.Error(ex.Message); } } } lblerror.Text = "Registered Successfully !" + "<a href=\"Default.aspx\">Login</a>"; Response.Redirect("~/Home.aspx"); } else { lblerror.Text = "Email Already Exists " + "<a href=\"Default.aspx\">login</a>"; } } } else { ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Please select Account Type!');", true); } } catch (Exception ex) { logger.Error(ex.StackTrace); lblerror.Text = "Please Insert Correct Information"; Console.WriteLine(ex.StackTrace); //Response.Redirect("Home.aspx"); } }
public int AddInvitationInDB(string fname, string lname, string email) { int res = 0; try { if (Session["LoggedUser"] != null) { SocioBoard.Domain.User user = (User)Session["LoggedUser"]; MailHelper mailhelper = new MailHelper(); string mailpath = HttpContext.Current.Server.MapPath("~/Layouts/Mails/FriendInvitation.htm"); string html = File.ReadAllText(mailpath); string fromemail = ConfigurationManager.AppSettings["fromemail"]; string usernameSend = ConfigurationManager.AppSettings["username"]; string host = ConfigurationManager.AppSettings["host"]; string port = ConfigurationManager.AppSettings["port"]; string pass = ConfigurationManager.AppSettings["password"]; string website = ConfigurationManager.AppSettings["MailSenderDomain"]; string urllogin = website + "Default.aspx"; //string registrationurl = "http://dev.socioboard.com/Registration.aspx?refid=256f9c69-6b6a-4409-a309-b1f6d1f8e43b"; string registrationurl = website + "Registration.aspx?refid=" + user.Id; html = html.Replace("%replink%", registrationurl); string Body = mailhelper.InvitationMailByCloudSponge(html, fname + " " + lname, user.EmailId, "", urllogin, registrationurl); string Subject = "You have been invited to Socioboard by " + user.EmailId; InviteMember(fname, lname, email); #region Add Records in Invitation Table Invitation objInvitation = new Invitation(); InvitationRepository objInvitationRepository = new InvitationRepository(); objInvitation.Id = Guid.NewGuid(); objInvitation.InvitationBody = Body; objInvitation.Subject = Subject; objInvitation.FriendEmail = email; objInvitation.SenderEmail = user.EmailId; //"*****@*****.**"; objInvitation.FriendName = fname + " " + lname; objInvitation.SenderName = user.UserName; //"Abhaykumar"; objInvitation.Status = "0"; objInvitation.LastEmailSendDate = DateTime.Now; res = objInvitationRepository.Add(objInvitation); #endregion } //else //{ // ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Plaese login for this activity!');", true); //} } catch (Exception ex) { Console.WriteLine("Error : " + ex.StackTrace); } return(res); }
public void ProcessRequest() { if (Request.QueryString["op"] == "login") { try { string email = Request.QueryString["username"]; string password = Request.QueryString["password"]; Registration regpage = new Registration(); password = regpage.MD5Hash(password); SocioBoard.Helper.SessionFactory.configfilepath = Server.MapPath("~/hibernate.cfg.xml"); UserRepository userrepo = new UserRepository(); LoginLogs objLoginLogs = new LoginLogs(); LoginLogsRepository objLoginLogsRepository = new LoginLogsRepository(); User user = userrepo.GetUserInfo(email, password); if (user == null) { Response.Write("Invalid Email or Password"); } else { if (user.UserStatus == 1) { Session["LoggedUser"] = user; // List<User> lstUser = new List<User>(); if (Session["LoggedUser"] != null) { //SocioBoard.Domain.User.lstUser.Add((User)Session["LoggedUser"]); //Application["OnlineUsers"] = SocioBoard.Domain.User.lstUser; //objLoginLogs.Id = new Guid(); //objLoginLogs.UserId = user.Id; //objLoginLogs.UserName = user.UserName; //objLoginLogs.LoginTime = DateTime.Now.AddHours(11.50); //objLoginLogsRepository.Add(objLoginLogs); Groups objGroups = new Groups(); GroupRepository objGroupRepository = new GroupRepository(); Team objteam = new Team(); TeamRepository objTeamRepository = new TeamRepository(); objGroups = objGroupRepository.getGroupDetail(user.Id); if (objGroups == null) { //================================================================================ //Insert into group try { objGroups = new Groups(); objGroups.Id = Guid.NewGuid(); objGroups.GroupName = ConfigurationManager.AppSettings["DefaultGroupName"]; objGroups.UserId = user.Id; objGroups.EntryDate = DateTime.Now; objGroupRepository.AddGroup(objGroups); objteam.Id = Guid.NewGuid(); objteam.GroupId = objGroups.Id; objteam.UserId = user.Id; objteam.EmailId = user.EmailId; // teams.FirstName = user.UserName; objTeamRepository.addNewTeam(objteam); SocialProfile objSocialProfile = new SocialProfile(); SocialProfilesRepository objSocialProfilesRepository = new SocialProfilesRepository(); List<SocialProfile> lstSocialProfile = objSocialProfilesRepository.getAllSocialProfilesOfUser(user.Id); if (lstSocialProfile != null) { if (lstSocialProfile.Count > 0) { foreach (SocialProfile item in lstSocialProfile) { try { TeamMemberProfile objTeamMemberProfile = new TeamMemberProfile(); TeamMemberProfileRepository objTeamMemberProfileRepository = new TeamMemberProfileRepository(); objTeamMemberProfile.Id = Guid.NewGuid(); objTeamMemberProfile.TeamId = objteam.Id; objTeamMemberProfile.ProfileId = item.ProfileId; objTeamMemberProfile.ProfileType = item.ProfileType; objTeamMemberProfile.Status = item.ProfileStatus; objTeamMemberProfile.StatusUpdateDate = DateTime.Now; objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile); } catch (Exception ex) { Console.WriteLine(ex.Message); } } } } } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error("Error : " + ex.Message); logger.Error("Error : " + ex.StackTrace); } //========================================================================================================== } BusinessSetting objBusinessSetting = new BusinessSetting(); BusinessSettingRepository objBusinessSettingRepository = new BusinessSettingRepository(); List<BusinessSetting> lstBusinessSetting = objBusinessSettingRepository.GetBusinessSettingByUserId(user.Id); if (lstBusinessSetting.Count == 0) { try { List<Groups> lstGroups = objGroupRepository.getAllGroups(user.Id); foreach (Groups item in lstGroups) { objBusinessSetting = new BusinessSetting(); objBusinessSetting.Id = Guid.NewGuid(); objBusinessSetting.BusinessName = item.GroupName; //objbsnssetting.GroupId = team.GroupId; objBusinessSetting.GroupId = item.Id; objBusinessSetting.AssigningTasks = false; objBusinessSetting.AssigningTasks = false; objBusinessSetting.TaskNotification = false; objBusinessSetting.TaskNotification = false; objBusinessSetting.FbPhotoUpload = 0; objBusinessSetting.UserId = user.Id; objBusinessSetting.EntryDate = DateTime.Now; objBusinessSettingRepository.AddBusinessSetting(objBusinessSetting); } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } } Response.Write("user"); } else { Response.Write("You are Blocked by Admin Please contact Admin!"); } } } catch (Exception ex) { Response.Write("Error: " + ex.Message); Console.WriteLine(ex.StackTrace); logger.Error(ex.StackTrace); } } else if (Request.QueryString["op"] == "register") { User user = new User(); UserActivation objUserActivation = new UserActivation(); UserRepository userrepo = new UserRepository(); SocioBoard.Helper.SessionFactory.configfilepath = Server.MapPath("~/hibernate.cfg.xml"); Session["AjaxLogin"] = "******"; try { System.IO.StreamReader sr = new System.IO.StreamReader(Request.InputStream); string line = ""; line = sr.ReadToEnd(); JObject jo = JObject.Parse(line); user.PaymentStatus = "unpaid"; if (!string.IsNullOrEmpty(Request.QueryString["type"])) { user.AccountType = Request.QueryString["type"]; } else { user.AccountType = "deluxe"; } user.CreateDate = DateTime.Now; user.ExpiryDate = DateTime.Now.AddMonths(1); user.Id = Guid.NewGuid(); user.UserName = Server.UrlDecode((string)jo["firstname"]) + " " + Server.UrlDecode((string)jo["lastname"]); user.EmailId = Server.UrlDecode((string)jo["email"]); user.Password = Server.UrlDecode((string)jo["password"]); user.UserStatus = 1; if (!userrepo.IsUserExist(user.EmailId)) { UserRepository.Add(user); Session["LoggedUser"] = user; Response.Write("user"); objUserActivation.Id = Guid.NewGuid(); objUserActivation.UserId = user.Id; objUserActivation.ActivationStatus = "0"; UserActivationRepository.Add(objUserActivation); //add value in userpackage UserPackageRelation objUserPackageRelation = new UserPackageRelation(); UserPackageRelationRepository objUserPackageRelationRepository = new UserPackageRelationRepository(); PackageRepository objPackageRepository = new PackageRepository(); Package objPackage = objPackageRepository.getPackageDetails(user.AccountType); objUserPackageRelation.Id = new Guid(); objUserPackageRelation.PackageId = objPackage.Id; objUserPackageRelation.UserId = user.Id; objUserPackageRelation.PackageStatus = true; objUserPackageRelationRepository.AddUserPackageRelation(objUserPackageRelation); SocioBoard.Helper.MailSender.SendEMail(user.UserName, user.Password, user.EmailId, user.AccountType.ToString(), user.Id.ToString()); //MailSender.SendEMail(user.UserName, user.Password, user.EmailId); // lblerror.Text = "Registered Successfully !" + "<a href=\"login.aspx\">Login</a>"; } else { Response.Write("Email Already Exists !"); } } catch (Exception ex) { logger.Error(ex.StackTrace); Console.WriteLine(ex.StackTrace); } } else if (Request.QueryString["op"] == "facebooklogin") { SessionFactory.configfilepath = Server.MapPath("~/hibernate.cfg.xml"); string redi = "http://www.facebook.com/dialog/oauth/?scope=publish_stream,read_stream,read_insights,manage_pages,user_checkins,user_photos,read_mailbox,manage_notifications,read_page_mailboxes,email,user_videos,offline_access&client_id=" + ConfigurationManager.AppSettings["ClientId"] + "&redirect_uri=" + ConfigurationManager.AppSettings["RedirectUrl"] + "&response_type=code"; Session["login"] = "******"; Response.Write(redi); } else if (Request.QueryString["op"] == "googlepluslogin") { Session["login"] = "******"; oAuthToken objToken = new oAuthToken(); Response.Write(objToken.GetAutherizationLink("https://www.googleapis.com/auth/userinfo.email+https://www.googleapis.com/auth/userinfo.profile+https://www.googleapis.com/auth/plus.me+https://www.googleapis.com/auth/plus.login")); } else if (Request.QueryString["op"] == "removeuser") { try { if (Session["LoggedUser"] != null) { SocioBoard.Domain.User.lstUser.Remove((User)Session["LoggedUser"]); } } catch (Exception Err) { logger.Error(Err.StackTrace); Response.Write(Err.StackTrace); } } }
//Getting AccessToken,FacebookMessages,FacebookFeeds and UserProfile for Authenticated user. private void GetAccessToken() { User user = new SocioBoard.Domain.User(); string code = Request.QueryString["code"]; if (code == null) { Response.Redirect("Home.aspx"); } if (Session["login"] != null) { if (Session["login"].ToString() == "googleplus") { user = (User)Session["LoggedUser"]; } else { user = null; } } if (Session["login"] != null) { if (Session["login"].ToString() == "facebook") { user = new User(); user.CreateDate = DateTime.Now; user.ExpiryDate = DateTime.Now.AddDays(30); user.Id = Guid.NewGuid(); user.PaymentStatus = "unpaid"; } } else { /*User class in SocioBoard.Domain to check authenticated user*/ user = (User)Session["LoggedUser"]; } /*Replacing Code With AccessToken*/ // Facebook.dll using for FacebookHelper fbhelper = new FacebookHelper(); FacebookClient fb = new FacebookClient(); string profileId = string.Empty; Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("client_id", ConfigurationManager.AppSettings["ClientId"]); parameters.Add("redirect_uri", ConfigurationManager.AppSettings["RedirectUrl"]); parameters.Add("client_secret", ConfigurationManager.AppSettings["ClientSecretKey"]); parameters.Add("code", code); JsonObject result = (JsonObject)fb.Get("/oauth/access_token", parameters); string accessToken = result["access_token"].ToString(); fb.AccessToken = accessToken; // This code is used for posting Begin ManageReferrals(fb); // This code is used for posting End // For long Term Fb access_token // GET /oauth/access_token? //grant_type=fb_exchange_token& //client_id={app-id}& //client_secret={app-secret}& //fb_exchange_token={short-lived-token} parameters.Clear(); parameters.Add("grant_type", "fb_exchange_token"); parameters.Add("client_id", ConfigurationManager.AppSettings["ClientId"]); parameters.Add("client_secret", ConfigurationManager.AppSettings["ClientSecretKey"]); parameters.Add("fb_exchange_token", accessToken); result = (JsonObject)fb.Get("/oauth/access_token", parameters); accessToken = result["access_token"].ToString(); fb.AccessToken = accessToken; dynamic profile = fb.Get("me"); int res = UpdateFbToken(profile["id"], accessToken); bool isfbemailexist = false; if (Session["login"] != null) { if (Session["login"].ToString() == "facebook") { try { user.EmailId = profile["email"].ToString(); } catch (Exception ex) { isfbemailexist = true; logger.Error(ex.StackTrace); Console.WriteLine(ex.StackTrace); } if (isfbemailexist) { Session["isemailexist"] = "emailnotexist"; Response.Redirect("Default.aspx"); } try { user.UserName = profile["name"].ToString(); } catch (Exception ex) { logger.Error(ex.StackTrace); Console.WriteLine(ex.StackTrace); } try { user.ProfileUrl = "https://graph.facebook.com/" + profile["id"] + "/picture?type=small"; profileId = profile["id"]; } catch (Exception ex) { logger.Error(ex.StackTrace); Console.WriteLine(ex.StackTrace); } user.UserStatus = 1; UserRepository userrepo = new UserRepository(); if (userrepo.IsUserExist(user.EmailId)) { string emailid = user.EmailId; user = null; user = userrepo.getUserInfoByEmail(emailid); } else { UserRepository.Add(user); } Session["LoggedUser"] = user; } } var feeds = fb.Get("/me/feed"); var home = fb.Get("/me/home"); var messages = fb.Get("/me/inbox"); long friendscount = 0; try { fbhelper.getInboxMessages(messages, profile, user.Id); } catch (Exception ex) { logger.Error(ex.StackTrace); Console.WriteLine(ex.StackTrace); } try { dynamic friedscount = fb.Get("fql", new { q = "SELECT friend_count FROM user WHERE uid=me()" }); foreach (var friend in friedscount.data) { friendscount = friend.friend_count; } } catch (Exception ex) { logger.Error(ex.StackTrace); Console.WriteLine(ex.StackTrace); } try { fbhelper.getFacebookUserProfile(profile, accessToken, friendscount, user.Id); } catch (Exception exx) { logger.Error(exx.StackTrace); Console.WriteLine(exx.StackTrace); } try { fbhelper.getFacebookUserFeeds(feeds, profile); } catch (Exception exxx) { logger.Error(exxx.StackTrace); Console.WriteLine(exxx.StackTrace); } try { fbhelper.getFacebookUserHome(home, profile); } catch (Exception ex) { logger.Error(ex.StackTrace); Console.WriteLine(ex.StackTrace); } try { var friendsgenderstats = fb.Get("me/friends?fields=gender"); fbhelper.getfbFriendsGenderStats(friendsgenderstats, profile, user.Id); } catch (Exception ex) { logger.Error(ex.StackTrace); Console.WriteLine(ex.StackTrace); } try { FacebookInsightStatsHelper fbiHelper = new FacebookInsightStatsHelper(); fbiHelper.getPageImpresion(profile["id"], user.Id, 15); fbiHelper.getFanPageLikesByGenderAge(profile["id"], user.Id, 15); fbiHelper.getLocation(profile["id"], user.Id, 15); // fbiHelper.getFanPost("459630637383010", user.Id, 10); } catch (Exception ex) { logger.Error(ex.StackTrace); } }