public ActionResult Facebook(string code) { if (Session["fblogin"] != null) { if ((string)Session["fblogin"] == "fblogin") { Domain.Socioboard.Domain.User objUser = (Domain.Socioboard.Domain.User)Session["User"]; Domain.Socioboard.Domain.User checkuserexist = (Domain.Socioboard.Domain.User)Session["User"]; // string facebookcode = Request.QueryString["code"].ToString(); string facebookcode = code; Api.Facebook.Facebook apiobjFacebook = new Api.Facebook.Facebook(); Api.User.User ApiobjUser = new Api.User.User(); objUser = (Domain.Socioboard.Domain.User)(new JavaScriptSerializer().Deserialize(apiobjFacebook.FacebookLogin(code), typeof(Domain.Socioboard.Domain.User))); checkuserexist = (Domain.Socioboard.Domain.User)(new JavaScriptSerializer().Deserialize(ApiobjUser.getUserInfoByEmail(objUser.EmailId.ToString()), typeof(Domain.Socioboard.Domain.User))); if (checkuserexist != null) { Session["User"] = checkuserexist; return(RedirectToAction("Index", "Home")); } else { Session["User"] = objUser; return(RedirectToAction("Registration", "Index")); } } else if ((string)Session["fblogin"] == "page") { Api.Facebook.Facebook apiobjFacebook = new Api.Facebook.Facebook(); List <Domain.Socioboard.Domain.AddFacebookPage> lstAddFacebookPage = new List <Domain.Socioboard.Domain.AddFacebookPage>(); lstAddFacebookPage = (List <Domain.Socioboard.Domain.AddFacebookPage>)(new JavaScriptSerializer().Deserialize(apiobjFacebook.GetFacebookPages(code), typeof(List <Domain.Socioboard.Domain.AddFacebookPage>))); Session["fbpage"] = lstAddFacebookPage; return(RedirectToAction("Index", "Home", new{ hint = "fbpage" })); } else if ((string)Session["fblogin"] == "fbgroup") { Api.Facebook.Facebook apiobjFacebook = new Api.Facebook.Facebook(); List <Domain.Socioboard.Domain.AddFacebookGroup> lstAddFacebookGroup = new List <Domain.Socioboard.Domain.AddFacebookGroup>(); lstAddFacebookGroup = (List <Domain.Socioboard.Domain.AddFacebookGroup>)(new JavaScriptSerializer().Deserialize(apiobjFacebook.GetFacebookGroups(code), typeof(List <Domain.Socioboard.Domain.AddFacebookGroup>))); Session["fbgrp"] = lstAddFacebookGroup; return(RedirectToAction("Index", "Home", new { hint = "fbgrp" })); } } else { Domain.Socioboard.Domain.User objUser = (Domain.Socioboard.Domain.User)Session["User"]; // string facebookcode = Request.QueryString["code"].ToString(); string facebookcode = code; Api.Facebook.Facebook apiobjFacebook = new Api.Facebook.Facebook(); string AddfacebookAccount = apiobjFacebook.AddFacebookAccount(facebookcode, objUser.Id.ToString(), Session["group"].ToString()); Session["SocialManagerInfo"] = AddfacebookAccount; } return(RedirectToAction("Index", "Home")); }
public ActionResult Facebook(string code) { if (Session["fblogin"] != null) { if ((string)Session["fblogin"] == "fblogin") { Session["fblogin"] = null; if (String.IsNullOrEmpty(code)) { return RedirectToAction("Index", "Index"); } Domain.Socioboard.Domain.User objUser = (Domain.Socioboard.Domain.User)Session["User"]; Domain.Socioboard.Domain.User checkuserexist = (Domain.Socioboard.Domain.User)Session["User"]; // string facebookcode = Request.QueryString["code"].ToString(); string facebookcode = code; Api.Facebook.Facebook apiobjFacebook = new Api.Facebook.Facebook(); Api.User.User ApiobjUser = new Api.User.User(); string fbloginreturn = apiobjFacebook.FacebookLogin(code); string[] arrfbloginreturn = Regex.Split(fbloginreturn, "_#_"); //objUser = (Domain.Socioboard.Domain.User)(new JavaScriptSerializer().Deserialize(apiobjFacebook.FacebookLogin(code), typeof(Domain.Socioboard.Domain.User))); objUser = (Domain.Socioboard.Domain.User)(new JavaScriptSerializer().Deserialize(arrfbloginreturn[0], typeof(Domain.Socioboard.Domain.User))); Session["AccesstokenFblogin"] = arrfbloginreturn[1]; Session["fblogin"] = "******"; try { Response.Write("Facebook Returned email : " + objUser.EmailId); } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.StackTrace); logger.Error(ex.Message); } try { // objUser = (Domain.Socioboard.Domain.User)(new JavaScriptSerializer().Deserialize(apiobjFacebook.FacebookLogin(code), typeof(Domain.Socioboard.Domain.User))); checkuserexist = (Domain.Socioboard.Domain.User)(new JavaScriptSerializer().Deserialize(ApiobjUser.getUserInfoByEmail(objUser.EmailId.ToString()), typeof(Domain.Socioboard.Domain.User))); FormsAuthentication.SetAuthCookie(checkuserexist.UserName, false); } catch (Exception e) { checkuserexist = null; } if (checkuserexist != null) { Session["User"] = checkuserexist; int daysremaining = 0; daysremaining = (checkuserexist.ExpiryDate.Date - DateTime.Now.Date).Days; if (daysremaining > 0) { #region Count Used Accounts try { Session["Paid_User"] = "******"; Api.SocialProfile.SocialProfile apiobjSocialProfile = new Api.SocialProfile.SocialProfile(); Session["ProfileCount"] = Convert.ToInt32(apiobjSocialProfile.GetAllSocialProfilesOfUserCount(objUser.Id.ToString()).ToString()); } catch (Exception ex) { Console.WriteLine(ex.Message); } #endregion } else { Session["Paid_User"] = "******"; } ApiobjUser.UpdateLastLoginTime(checkuserexist.Id.ToString()); return RedirectToAction("Index", "Home"); } else { objUser.ActivationStatus = "1"; Session["User"] = objUser; return RedirectToAction("Registration", "Index"); } } else if ((string)Session["fblogin"] == "page") { Session["fblogin"] = null; Api.Facebook.Facebook apiobjFacebook = new Api.Facebook.Facebook(); List<Domain.Socioboard.Domain.AddFacebookPage> lstAddFacebookPage = new List<Domain.Socioboard.Domain.AddFacebookPage>(); lstAddFacebookPage = (List<Domain.Socioboard.Domain.AddFacebookPage>)(new JavaScriptSerializer().Deserialize(apiobjFacebook.GetFacebookPages(code), typeof(List<Domain.Socioboard.Domain.AddFacebookPage>))); Session["fbpage"] = lstAddFacebookPage; return RedirectToAction("Index", "Home", new { hint = "fbpage" }); } else if ((string)Session["fblogin"] == "fbgroup") { Session["fblogin"] = null; Api.Facebook.Facebook apiobjFacebook = new Api.Facebook.Facebook(); List<Domain.Socioboard.Domain.AddFacebookGroup> lstAddFacebookGroup = new List<Domain.Socioboard.Domain.AddFacebookGroup>(); lstAddFacebookGroup = (List<Domain.Socioboard.Domain.AddFacebookGroup>)(new JavaScriptSerializer().Deserialize(apiobjFacebook.GetFacebookGroups(code), typeof(List<Domain.Socioboard.Domain.AddFacebookGroup>))); Session["fbgrp"] = lstAddFacebookGroup; return RedirectToAction("Index", "Home", new { hint = "fbgrp" }); } } else { Domain.Socioboard.Domain.User objUser = (Domain.Socioboard.Domain.User)Session["User"]; string facebookcode = code; Api.Facebook.Facebook apiobjFacebook = new Api.Facebook.Facebook(); apiobjFacebook.Timeout = 120 * 1000; //string AddfacebookAccount = apiobjFacebook.AddFacebookAccount(facebookcode, objUser.Id.ToString(), Session["group"].ToString()); string AddfacebookAccount = ""; Domain.Socioboard.Domain.FacebookAccount objfacebookAccount = new Domain.Socioboard.Domain.FacebookAccount(); try { var res_addFacebook = apiobjFacebook.AddFacebookAccount(facebookcode, objUser.Id.ToString(), Session["group"].ToString()); AddfacebookAccount = res_addFacebook; try { objfacebookAccount = (Domain.Socioboard.Domain.FacebookAccount)new JavaScriptSerializer().Deserialize(res_addFacebook, typeof(Domain.Socioboard.Domain.FacebookAccount)); AddfacebookAccount = objfacebookAccount.FbUserId; } catch (Exception) { } } catch (Exception) { AddfacebookAccount = "issue_access_token"; } if (AddfacebookAccount == "issue_access_token") { Response.Redirect(Helper.SBUtils.GetFacebookRedirectLink()); } else if (AddfacebookAccount == "Account already Exist !") { } else { Session["SocialManagerInfo"] = AddfacebookAccount; //To enable the Facebook Message Pop up TempData["IsFacebookAccountAdded"] = 1; TempData["FacebookAccount"] = objfacebookAccount; } } return RedirectToAction("Index", "Home"); }
//[CustomAuthorize] public async Task <ActionResult> Facebook(string code) { if (Session["fblogin"] != null) { if ((string)Session["fblogin"] == "fblogin") { Session["fblogin"] = null; if (String.IsNullOrEmpty(code)) { return(RedirectToAction("Index", "Index")); } Domain.Socioboard.Domain.User objUser = (Domain.Socioboard.Domain.User)Session["User"]; Domain.Socioboard.Domain.User checkuserexist = (Domain.Socioboard.Domain.User)Session["User"]; string facebookcode = code; string fbloginreturn = apiobjFacebook.FacebookLogin(code); string[] arrfbloginreturn = Regex.Split(fbloginreturn, "_#_"); objUser = (Domain.Socioboard.Domain.User)(new JavaScriptSerializer().Deserialize(arrfbloginreturn[0], typeof(Domain.Socioboard.Domain.User))); Session["AccesstokenFblogin"] = arrfbloginreturn[1]; Session["fblogin"] = "******"; try { checkuserexist = (Domain.Socioboard.Domain.User)(new JavaScriptSerializer().Deserialize(ApiobjUser.getUserInfoByEmail(objUser.EmailId.ToString()), typeof(Domain.Socioboard.Domain.User))); FormsAuthentication.SetAuthCookie(checkuserexist.UserName, false); } catch (Exception e) { checkuserexist = null; } if (checkuserexist != null) { objUser = checkuserexist; Session["User"] = checkuserexist; Session["group"] = await SBHelper.LoadGroups(objUser.Id); Socioboard.Helper.apiClientProvider ac = new Socioboard.Helper.apiClientProvider(System.Configuration.ConfigurationManager.AppSettings["ApiDomainName"] + "/token"); try { Dictionary <string, string> re = await ac.GetTokenDictionary(checkuserexist.EmailId, checkuserexist.Password); Session["access_token"] = re["access_token"]; } catch (Exception e) { return(RedirectToAction("Index", "Home")); } daysremaining = 0; daysremaining = (checkuserexist.ExpiryDate.Date - DateTime.Now.Date).Days; if (daysremaining > 0) { #region Count Used Accounts try { Session["Paid_User"] = "******"; Session["ProfileCount"] = Convert.ToInt32(apiobjSocialProfile.GetAllSocialProfilesOfUserCount(objUser.Id.ToString()).ToString()); } catch (Exception ex) { logger.Error(ex.StackTrace); } #endregion } else { Session["Paid_User"] = "******"; } ApiobjUser.UpdateLastLoginTime(checkuserexist.Id.ToString()); HttpCookie myCookie = new HttpCookie("referal_url"); myCookie = Request.Cookies["referal_url"]; if (myCookie != null) { Response.Redirect(".." + myCookie.Value); } return(RedirectToAction("Index", "Home")); } else { objUser.ActivationStatus = "1"; Session["User"] = objUser; return(RedirectToAction("Registration", "Index")); } } else if ((string)Session["fblogin"] == "page") { Session["fblogin"] = null; Api.Facebook.Facebook apiobjFacebook = new Api.Facebook.Facebook(); List <Domain.Socioboard.Domain.AddFacebookPage> lstAddFacebookPage = new List <Domain.Socioboard.Domain.AddFacebookPage>(); lstAddFacebookPage = (List <Domain.Socioboard.Domain.AddFacebookPage>)(new JavaScriptSerializer().Deserialize(apiobjFacebook.GetFacebookPages(code), typeof(List <Domain.Socioboard.Domain.AddFacebookPage>))); Session["fbpage"] = lstAddFacebookPage; return(RedirectToAction("Index", "Home", new { hint = "fbpage" })); } else if ((string)Session["fblogin"] == "fbgroup") { Session["fblogin"] = null; Api.Facebook.Facebook apiobjFacebook = new Api.Facebook.Facebook(); List <Domain.Socioboard.Domain.AddFacebookGroup> lstAddFacebookGroup = new List <Domain.Socioboard.Domain.AddFacebookGroup>(); lstAddFacebookGroup = (List <Domain.Socioboard.Domain.AddFacebookGroup>)(new JavaScriptSerializer().Deserialize(apiobjFacebook.GetFacebookGroups(code), typeof(List <Domain.Socioboard.Domain.AddFacebookGroup>))); Session["fbgrp"] = lstAddFacebookGroup; return(RedirectToAction("Index", "Home", new { hint = "fbgrp" })); } else if ((string)Session["fblogin"] == "fbplugin") { Session["fblogin"] = null; if (String.IsNullOrEmpty(code)) { return(RedirectToAction("Index", "Index", new { hint = "plugin" })); } Domain.Socioboard.Domain.User objUser = (Domain.Socioboard.Domain.User)Session["User"]; Domain.Socioboard.Domain.User checkuserexist = (Domain.Socioboard.Domain.User)Session["User"]; Api.Facebook.Facebook apiobjFacebook = new Api.Facebook.Facebook(); Api.User.User ApiobjUser = new Api.User.User(); string fbloginreturn = apiobjFacebook.FacebookLogin(code); string[] arrfbloginreturn = Regex.Split(fbloginreturn, "_#_"); objUser = (Domain.Socioboard.Domain.User)(new JavaScriptSerializer().Deserialize(arrfbloginreturn[0], typeof(Domain.Socioboard.Domain.User))); Session["AccesstokenFblogin"] = arrfbloginreturn[1]; try { checkuserexist = (Domain.Socioboard.Domain.User)(new JavaScriptSerializer().Deserialize(ApiobjUser.getUserInfoByEmail(objUser.EmailId.ToString()), typeof(Domain.Socioboard.Domain.User))); FormsAuthentication.SetAuthCookie(checkuserexist.UserName, false); } catch (Exception e) { checkuserexist = null; } if (checkuserexist != null) { objUser = checkuserexist; Session["User"] = checkuserexist; ApiobjUser.UpdateLastLoginTime(checkuserexist.Id.ToString()); } else { if (!string.IsNullOrEmpty(objUser.EmailId)) { string user = ApiobjUser.Register(objUser.EmailId, "", "Free", objUser.UserName, "1"); objUser = (Domain.Socioboard.Domain.User) new JavaScriptSerializer().Deserialize(user, typeof(Domain.Socioboard.Domain.User)); Session["User"] = objUser; } else { return(RedirectToAction("Index", "Index", new { hint = "plugin" })); } } Session["group"] = await SBHelper.LoadGroups(objUser.Id); Socioboard.Helper.apiClientProvider ac = new Socioboard.Helper.apiClientProvider(System.Configuration.ConfigurationManager.AppSettings["ApiDomainName"] + "/token"); try { Dictionary <string, string> re = await ac.GetTokenDictionary(checkuserexist.EmailId, checkuserexist.Password); Session["access_token"] = re["access_token"]; } catch (Exception e) { return(RedirectToAction("Index", "Home")); } #region Count Used Accounts try { Session["ProfileCount"] = Convert.ToInt32(apiobjSocialProfile.GetAllSocialProfilesOfUserCount(objUser.Id.ToString()).ToString()); Session["TotalAccount"] = Convert.ToInt16(SBUtils.GetUserPackageProfileCount(objUser.AccountType)); } catch (Exception ex) { Session["ProfileCount"] = 0; Session["TotalAccount"] = 0; } #endregion daysremaining = 0; daysremaining = (objUser.ExpiryDate.Date - DateTime.Now.Date).Days; if (daysremaining > 0) { Session["Paid_User"] = "******"; } else { Session["Paid_User"] = "******"; } Session["fblogin"] = "******"; return(RedirectToAction("Index", "Home", new { hint = "plugin" })); } } else { Domain.Socioboard.Domain.User objUser = (Domain.Socioboard.Domain.User)Session["User"]; string facebookcode = code; Api.Facebook.Facebook apiobjFacebook = new Api.Facebook.Facebook(); apiobjFacebook.Timeout = 120 * 1000; //string AddfacebookAccount = apiobjFacebook.AddFacebookAccount(facebookcode, objUser.Id.ToString(), Session["group"].ToString()); string AddfacebookAccount = ""; Domain.Socioboard.Domain.FacebookAccount objfacebookAccount = new Domain.Socioboard.Domain.FacebookAccount(); try { var res_addFacebook = apiobjFacebook.AddFacebookAccount(facebookcode, objUser.Id.ToString(), Session["group"].ToString()); AddfacebookAccount = res_addFacebook; try { objfacebookAccount = (Domain.Socioboard.Domain.FacebookAccount) new JavaScriptSerializer().Deserialize(res_addFacebook, typeof(Domain.Socioboard.Domain.FacebookAccount)); AddfacebookAccount = objfacebookAccount.FbUserId; } catch (Exception) { } } catch (Exception) { AddfacebookAccount = "issue_access_token"; } if (AddfacebookAccount == "issue_access_token") { Response.Redirect(Helper.SBUtils.GetFacebookRedirectLink()); } else if (AddfacebookAccount == "Account already Exist !") { } else { Session["SocialManagerInfo"] = AddfacebookAccount; //To enable the Facebook Message Pop up TempData["IsFacebookAccountAdded"] = 1; TempData["FacebookAccount"] = objfacebookAccount; } } return(RedirectToAction("Index", "Home")); }
public ActionResult Facebook(string code) { string status = ""; if (Session["fblogin"] != null) { if ((string)Session["fblogin"] == "fblogin") { Session["fblogin"] = null; if (String.IsNullOrEmpty(code)) { return(RedirectToAction("Index", "Index")); } Domain.Myfashion.Domain.User objUser = (Domain.Myfashion.Domain.User)Session["User"]; Domain.Myfashion.Domain.User checkuserexist = (Domain.Myfashion.Domain.User)Session["User"]; string facebookcode = code; Api.Facebook.Facebook apiobjFacebook = new Api.Facebook.Facebook(); Api.User.User ApiobjUser = new Api.User.User(); string fbloginreturn = apiobjFacebook.FacebookLogin(code); string[] arrfbloginreturn = Regex.Split(fbloginreturn, "_#_"); objUser = (Domain.Myfashion.Domain.User)(new JavaScriptSerializer().Deserialize(arrfbloginreturn[0], typeof(Domain.Myfashion.Domain.User))); Session["AccesstokenFblogin"] = arrfbloginreturn[1]; Session["fblogin"] = "******"; try { Response.Write("Facebook Returned email : " + objUser.EmailId); } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.StackTrace); logger.Error(ex.Message); } try { checkuserexist = (Domain.Myfashion.Domain.User)(new JavaScriptSerializer().Deserialize(ApiobjUser.getUserInfoByEmail(objUser.EmailId.ToString()), typeof(Domain.Myfashion.Domain.User))); string pid = checkuserexist.PuId; string puid = pid.Substring(36, pid.Length - 36); SortedDictionary <string, string> strdic = new SortedDictionary <string, string>(); strdic.Add("username", checkuserexist.EmailId); strdic.Add("password", puid); string data = CustomHttpWebRequest.HttpWebRequest("GET", "myfashion/loginService.action", strdic); data = data.Replace("func({", "{"); data = data.Replace("});", "}"); JObject jo = JObject.Parse(data); status = Server.UrlDecode((string)jo["code"]); } catch (Exception e) { checkuserexist = null; } if (checkuserexist != null) { Session["User"] = checkuserexist; int daysremaining = 0; daysremaining = (checkuserexist.ExpiryDate.Date - DateTime.Now.Date).Days; if (daysremaining > 0) { #region Count Used Accounts try { Session["Paid_User"] = "******"; Api.SocialProfile.SocialProfile apiobjSocialProfile = new Api.SocialProfile.SocialProfile(); //Session["ProfileCount"] = Convert.ToInt32(apiobjSocialProfile.GetAllSocialProfilesOfUserCount(objUser.Id.ToString()).ToString()); } catch (Exception ex) { Console.WriteLine(ex.Message); } #endregion } else { Session["Paid_User"] = "******"; } if (status == "101") { return(RedirectToAction("Index", "Home")); } else { return(RedirectToAction("Index", "Index")); } } else { objUser.ActivationStatus = "1"; Session["User"] = objUser; return(RedirectToAction("SignUp", "Index")); } } else if ((string)Session["fblogin"] == "page") { Session["fblogin"] = null; Api.Facebook.Facebook apiobjFacebook = new Api.Facebook.Facebook(); List <Domain.Myfashion.Domain.AddFacebookPage> lstAddFacebookPage = new List <Domain.Myfashion.Domain.AddFacebookPage>(); lstAddFacebookPage = (List <Domain.Myfashion.Domain.AddFacebookPage>)(new JavaScriptSerializer().Deserialize(apiobjFacebook.GetFacebookPages(code), typeof(List <Domain.Myfashion.Domain.AddFacebookPage>))); Session["fbpage"] = lstAddFacebookPage; return(RedirectToAction("Index", "Home", new { hint = "fbpage" })); } else if ((string)Session["fblogin"] == "fbgroup") { Session["fblogin"] = null; Api.Facebook.Facebook apiobjFacebook = new Api.Facebook.Facebook(); List <Domain.Myfashion.Domain.AddFacebookGroup> lstAddFacebookGroup = new List <Domain.Myfashion.Domain.AddFacebookGroup>(); lstAddFacebookGroup = (List <Domain.Myfashion.Domain.AddFacebookGroup>)(new JavaScriptSerializer().Deserialize(apiobjFacebook.GetFacebookGroups(code), typeof(List <Domain.Myfashion.Domain.AddFacebookGroup>))); Session["fbgrp"] = lstAddFacebookGroup; return(RedirectToAction("Index", "Home", new { hint = "fbgrp" })); } } else { Domain.Myfashion.Domain.User objUser = (Domain.Myfashion.Domain.User)Session["User"]; string facebookcode = code; Api.Facebook.Facebook apiobjFacebook = new Api.Facebook.Facebook(); apiobjFacebook.Timeout = 120 * 1000; //string AddfacebookAccount = apiobjFacebook.AddFacebookAccount(facebookcode, objUser.Id.ToString(), Session["group"].ToString()); string AddfacebookAccount = ""; Domain.Myfashion.Domain.FacebookAccount objfacebookAccount = new Domain.Myfashion.Domain.FacebookAccount(); try { var res_addFacebook = apiobjFacebook.AddFacebookAccount(facebookcode, objUser.Id.ToString(), Session["group"].ToString()); AddfacebookAccount = res_addFacebook; try { objfacebookAccount = (Domain.Myfashion.Domain.FacebookAccount) new JavaScriptSerializer().Deserialize(res_addFacebook, typeof(Domain.Myfashion.Domain.FacebookAccount)); AddfacebookAccount = objfacebookAccount.FbUserId; } catch (Exception) { } } catch (Exception) { AddfacebookAccount = "issue_access_token"; } if (AddfacebookAccount == "issue_access_token") { Response.Redirect(Helper.SBUtils.GetFacebookRedirectLink()); } else if (AddfacebookAccount == "Account already Exist !") { } else { Session["SocialManagerInfo"] = AddfacebookAccount; //To enable the Facebook Message Pop up TempData["IsFacebookAccountAdded"] = 1; TempData["FacebookAccount"] = objfacebookAccount; } } return(RedirectToAction("SocialMedia", "Home")); }
public ActionResult Facebook(string code) { if (Session["fblogin"] != null) { if ((string)Session["fblogin"] == "fblogin") { Session["fblogin"] = null; if (String.IsNullOrEmpty(code)) { return(RedirectToAction("Index", "Index")); } Domain.Socioboard.Domain.User objUser = (Domain.Socioboard.Domain.User)Session["User"]; Domain.Socioboard.Domain.User checkuserexist = (Domain.Socioboard.Domain.User)Session["User"]; // string facebookcode = Request.QueryString["code"].ToString(); string facebookcode = code; Api.Facebook.Facebook apiobjFacebook = new Api.Facebook.Facebook(); Api.User.User ApiobjUser = new Api.User.User(); objUser = (Domain.Socioboard.Domain.User)(new JavaScriptSerializer().Deserialize(apiobjFacebook.FacebookLogin(code), typeof(Domain.Socioboard.Domain.User))); try { // objUser = (Domain.Socioboard.Domain.User)(new JavaScriptSerializer().Deserialize(apiobjFacebook.FacebookLogin(code), typeof(Domain.Socioboard.Domain.User))); checkuserexist = (Domain.Socioboard.Domain.User)(new JavaScriptSerializer().Deserialize(ApiobjUser.getUserInfoByEmail(objUser.EmailId.ToString()), typeof(Domain.Socioboard.Domain.User))); FormsAuthentication.SetAuthCookie(checkuserexist.UserName, false); } catch (Exception e) { } if (checkuserexist != null) { Session["User"] = checkuserexist; int daysremaining = 0; daysremaining = (checkuserexist.ExpiryDate.Date - DateTime.Now.Date).Days; if (daysremaining > 0) { #region Count Used Accounts try { Session["Paid_User"] = "******"; Api.SocialProfile.SocialProfile apiobjSocialProfile = new Api.SocialProfile.SocialProfile(); Session["ProfileCount"] = Convert.ToInt32(apiobjSocialProfile.GetAllSocialProfilesOfUserCount(objUser.Id.ToString()).ToString()); } catch (Exception ex) { Console.WriteLine(ex.Message); } #endregion } else { Session["Paid_User"] = "******"; } return(RedirectToAction("Index", "Home")); } else { objUser.ActivationStatus = "1"; Session["User"] = objUser; return(RedirectToAction("Registration", "Index")); } } else if ((string)Session["fblogin"] == "page") { Session["fblogin"] = null; Api.Facebook.Facebook apiobjFacebook = new Api.Facebook.Facebook(); List <Domain.Socioboard.Domain.AddFacebookPage> lstAddFacebookPage = new List <Domain.Socioboard.Domain.AddFacebookPage>(); lstAddFacebookPage = (List <Domain.Socioboard.Domain.AddFacebookPage>)(new JavaScriptSerializer().Deserialize(apiobjFacebook.GetFacebookPages(code), typeof(List <Domain.Socioboard.Domain.AddFacebookPage>))); Session["fbpage"] = lstAddFacebookPage; return(RedirectToAction("Index", "Home", new { hint = "fbpage" })); } else if ((string)Session["fblogin"] == "fbgroup") { Session["fblogin"] = null; Api.Facebook.Facebook apiobjFacebook = new Api.Facebook.Facebook(); List <Domain.Socioboard.Domain.AddFacebookGroup> lstAddFacebookGroup = new List <Domain.Socioboard.Domain.AddFacebookGroup>(); lstAddFacebookGroup = (List <Domain.Socioboard.Domain.AddFacebookGroup>)(new JavaScriptSerializer().Deserialize(apiobjFacebook.GetFacebookGroups(code), typeof(List <Domain.Socioboard.Domain.AddFacebookGroup>))); Session["fbgrp"] = lstAddFacebookGroup; return(RedirectToAction("Index", "Home", new { hint = "fbgrp" })); } } else { Domain.Socioboard.Domain.User objUser = (Domain.Socioboard.Domain.User)Session["User"]; string facebookcode = code; Api.Facebook.Facebook apiobjFacebook = new Api.Facebook.Facebook(); string AddfacebookAccount = apiobjFacebook.AddFacebookAccount(facebookcode, objUser.Id.ToString(), Session["group"].ToString()); //string AddfacebookAccount = apiobjFacebook.AddFacebookAccountAsync(facebookcode, objUser.Id.ToString(), Session["group"].ToString()); if (AddfacebookAccount == "issue_access_token") { Response.Redirect(Helper.SBUtils.GetFacebookRedirectLink()); } else { Session["SocialManagerInfo"] = AddfacebookAccount; //try //{ // apiobjFacebook.AddFacebookAccountWithPaginationAsync(facebookcode, objUser.Id.ToString(), Session["group"].ToString()); //} //catch (Exception ex) //{ // logger.Error(ex.StackTrace); // logger.Error(ex.Message); //} } } return(RedirectToAction("Index", "Home")); }
public ActionResult Facebook(string code) { string status=""; if (Session["fblogin"] != null) { if ((string)Session["fblogin"] == "fblogin") { Session["fblogin"] = null; if (String.IsNullOrEmpty(code)) { return RedirectToAction("Index", "Index"); } Domain.Myfashion.Domain.User objUser = (Domain.Myfashion.Domain.User)Session["User"]; Domain.Myfashion.Domain.User checkuserexist = (Domain.Myfashion.Domain.User)Session["User"]; string facebookcode = code; Api.Facebook.Facebook apiobjFacebook = new Api.Facebook.Facebook(); Api.User.User ApiobjUser = new Api.User.User(); string fbloginreturn = apiobjFacebook.FacebookLogin(code); string[] arrfbloginreturn = Regex.Split(fbloginreturn,"_#_"); objUser = (Domain.Myfashion.Domain.User)(new JavaScriptSerializer().Deserialize(arrfbloginreturn[0], typeof(Domain.Myfashion.Domain.User))); Session["AccesstokenFblogin"] = arrfbloginreturn[1]; Session["fblogin"] = "******"; try { Response.Write("Facebook Returned email : " + objUser.EmailId); } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.StackTrace); logger.Error(ex.Message); } try { checkuserexist = (Domain.Myfashion.Domain.User)(new JavaScriptSerializer().Deserialize(ApiobjUser.getUserInfoByEmail(objUser.EmailId.ToString()), typeof(Domain.Myfashion.Domain.User))); string pid = checkuserexist.PuId; string puid = pid.Substring(36, pid.Length - 36); SortedDictionary<string, string> strdic = new SortedDictionary<string, string>(); strdic.Add("username", checkuserexist.EmailId); strdic.Add("password", puid); string data = CustomHttpWebRequest.HttpWebRequest("GET", "myfashion/loginService.action", strdic); data = data.Replace("func({", "{"); data = data.Replace("});", "}"); JObject jo = JObject.Parse(data); status = Server.UrlDecode((string)jo["code"]); } catch (Exception e) { checkuserexist = null; } if (checkuserexist != null) { Session["User"] = checkuserexist; int daysremaining = 0; daysremaining = (checkuserexist.ExpiryDate.Date - DateTime.Now.Date).Days; if (daysremaining > 0) { #region Count Used Accounts try { Session["Paid_User"] = "******"; Api.SocialProfile.SocialProfile apiobjSocialProfile = new Api.SocialProfile.SocialProfile(); //Session["ProfileCount"] = Convert.ToInt32(apiobjSocialProfile.GetAllSocialProfilesOfUserCount(objUser.Id.ToString()).ToString()); } catch (Exception ex) { Console.WriteLine(ex.Message); } #endregion } else { Session["Paid_User"] = "******"; } if (status == "101") { return RedirectToAction("Index", "Home"); } else { return RedirectToAction("Index", "Index"); } } else { objUser.ActivationStatus = "1"; Session["User"] = objUser; return RedirectToAction("SignUp", "Index"); } } else if ((string)Session["fblogin"] == "page") { Session["fblogin"] = null; Api.Facebook.Facebook apiobjFacebook = new Api.Facebook.Facebook(); List<Domain.Myfashion.Domain.AddFacebookPage> lstAddFacebookPage = new List<Domain.Myfashion.Domain.AddFacebookPage>(); lstAddFacebookPage = (List<Domain.Myfashion.Domain.AddFacebookPage>)(new JavaScriptSerializer().Deserialize(apiobjFacebook.GetFacebookPages(code), typeof(List<Domain.Myfashion.Domain.AddFacebookPage>))); Session["fbpage"] = lstAddFacebookPage; return RedirectToAction("Index", "Home", new { hint = "fbpage" }); } else if ((string)Session["fblogin"] == "fbgroup") { Session["fblogin"] = null; Api.Facebook.Facebook apiobjFacebook = new Api.Facebook.Facebook(); List<Domain.Myfashion.Domain.AddFacebookGroup> lstAddFacebookGroup = new List<Domain.Myfashion.Domain.AddFacebookGroup>(); lstAddFacebookGroup = (List<Domain.Myfashion.Domain.AddFacebookGroup>)(new JavaScriptSerializer().Deserialize(apiobjFacebook.GetFacebookGroups(code), typeof(List<Domain.Myfashion.Domain.AddFacebookGroup>))); Session["fbgrp"] = lstAddFacebookGroup; return RedirectToAction("Index", "Home", new { hint = "fbgrp" }); } } else { Domain.Myfashion.Domain.User objUser = (Domain.Myfashion.Domain.User)Session["User"]; string facebookcode = code; Api.Facebook.Facebook apiobjFacebook = new Api.Facebook.Facebook(); apiobjFacebook.Timeout = 120 * 1000; //string AddfacebookAccount = apiobjFacebook.AddFacebookAccount(facebookcode, objUser.Id.ToString(), Session["group"].ToString()); string AddfacebookAccount = ""; Domain.Myfashion.Domain.FacebookAccount objfacebookAccount = new Domain.Myfashion.Domain.FacebookAccount(); try { var res_addFacebook = apiobjFacebook.AddFacebookAccount(facebookcode, objUser.Id.ToString(), Session["group"].ToString()); AddfacebookAccount = res_addFacebook; try { objfacebookAccount = (Domain.Myfashion.Domain.FacebookAccount)new JavaScriptSerializer().Deserialize(res_addFacebook, typeof(Domain.Myfashion.Domain.FacebookAccount)); AddfacebookAccount = objfacebookAccount.FbUserId; } catch (Exception) { } } catch (Exception) { AddfacebookAccount = "issue_access_token"; } if (AddfacebookAccount == "issue_access_token") { Response.Redirect(Helper.SBUtils.GetFacebookRedirectLink()); } else if (AddfacebookAccount == "Account already Exist !") { } else { Session["SocialManagerInfo"] = AddfacebookAccount; //To enable the Facebook Message Pop up TempData["IsFacebookAccountAdded"] = 1; TempData["FacebookAccount"] = objfacebookAccount; } } return RedirectToAction("SocialMedia", "Home"); }
public ActionResult Facebook(string code) { if (Session["fblogin"] != null) { if ((string)Session["fblogin"] == "fblogin") { Session["fblogin"] = null; if (String.IsNullOrEmpty(code)) { return(RedirectToAction("Index", "Index")); } Domain.Socioboard.Domain.User objUser = (Domain.Socioboard.Domain.User)Session["User"]; Domain.Socioboard.Domain.User checkuserexist = (Domain.Socioboard.Domain.User)Session["User"]; // string facebookcode = Request.QueryString["code"].ToString(); string facebookcode = code; Api.Facebook.Facebook apiobjFacebook = new Api.Facebook.Facebook(); Api.User.User ApiobjUser = new Api.User.User(); string fbloginreturn = apiobjFacebook.FacebookLogin(code); string[] arrfbloginreturn = Regex.Split(fbloginreturn, "_#_"); //objUser = (Domain.Socioboard.Domain.User)(new JavaScriptSerializer().Deserialize(apiobjFacebook.FacebookLogin(code), typeof(Domain.Socioboard.Domain.User))); objUser = (Domain.Socioboard.Domain.User)(new JavaScriptSerializer().Deserialize(arrfbloginreturn[0], typeof(Domain.Socioboard.Domain.User))); Session["AccesstokenFblogin"] = arrfbloginreturn[1]; Session["fblogin"] = "******"; try { Response.Write("Facebook Returned email : " + objUser.EmailId); } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.StackTrace); logger.Error(ex.Message); } try { // objUser = (Domain.Socioboard.Domain.User)(new JavaScriptSerializer().Deserialize(apiobjFacebook.FacebookLogin(code), typeof(Domain.Socioboard.Domain.User))); checkuserexist = (Domain.Socioboard.Domain.User)(new JavaScriptSerializer().Deserialize(ApiobjUser.getUserInfoByEmail(objUser.EmailId.ToString()), typeof(Domain.Socioboard.Domain.User))); FormsAuthentication.SetAuthCookie(checkuserexist.UserName, false); } catch (Exception e) { checkuserexist = null; } if (checkuserexist != null) { Session["User"] = checkuserexist; int daysremaining = 0; daysremaining = (checkuserexist.ExpiryDate.Date - DateTime.Now.Date).Days; if (daysremaining > 0) { #region Count Used Accounts try { Session["Paid_User"] = "******"; Api.SocialProfile.SocialProfile apiobjSocialProfile = new Api.SocialProfile.SocialProfile(); Session["ProfileCount"] = Convert.ToInt32(apiobjSocialProfile.GetAllSocialProfilesOfUserCount(objUser.Id.ToString()).ToString()); } catch (Exception ex) { Console.WriteLine(ex.Message); } #endregion } else { Session["Paid_User"] = "******"; } ApiobjUser.UpdateLastLoginTime(checkuserexist.Id.ToString()); return(RedirectToAction("Index", "Home")); } else { objUser.ActivationStatus = "1"; Session["User"] = objUser; return(RedirectToAction("Registration", "Index")); } } else if ((string)Session["fblogin"] == "page") { Session["fblogin"] = null; Api.Facebook.Facebook apiobjFacebook = new Api.Facebook.Facebook(); List <Domain.Socioboard.Domain.AddFacebookPage> lstAddFacebookPage = new List <Domain.Socioboard.Domain.AddFacebookPage>(); lstAddFacebookPage = (List <Domain.Socioboard.Domain.AddFacebookPage>)(new JavaScriptSerializer().Deserialize(apiobjFacebook.GetFacebookPages(code), typeof(List <Domain.Socioboard.Domain.AddFacebookPage>))); Session["fbpage"] = lstAddFacebookPage; return(RedirectToAction("Index", "Home", new { hint = "fbpage" })); } else if ((string)Session["fblogin"] == "fbgroup") { Session["fblogin"] = null; Api.Facebook.Facebook apiobjFacebook = new Api.Facebook.Facebook(); List <Domain.Socioboard.Domain.AddFacebookGroup> lstAddFacebookGroup = new List <Domain.Socioboard.Domain.AddFacebookGroup>(); lstAddFacebookGroup = (List <Domain.Socioboard.Domain.AddFacebookGroup>)(new JavaScriptSerializer().Deserialize(apiobjFacebook.GetFacebookGroups(code), typeof(List <Domain.Socioboard.Domain.AddFacebookGroup>))); Session["fbgrp"] = lstAddFacebookGroup; return(RedirectToAction("Index", "Home", new { hint = "fbgrp" })); } } else { Domain.Socioboard.Domain.User objUser = (Domain.Socioboard.Domain.User)Session["User"]; string facebookcode = code; Api.Facebook.Facebook apiobjFacebook = new Api.Facebook.Facebook(); apiobjFacebook.Timeout = 120 * 1000; //string AddfacebookAccount = apiobjFacebook.AddFacebookAccount(facebookcode, objUser.Id.ToString(), Session["group"].ToString()); string AddfacebookAccount = ""; Domain.Socioboard.Domain.FacebookAccount objfacebookAccount = new Domain.Socioboard.Domain.FacebookAccount(); try { var res_addFacebook = apiobjFacebook.AddFacebookAccount(facebookcode, objUser.Id.ToString(), Session["group"].ToString()); AddfacebookAccount = res_addFacebook; try { objfacebookAccount = (Domain.Socioboard.Domain.FacebookAccount) new JavaScriptSerializer().Deserialize(res_addFacebook, typeof(Domain.Socioboard.Domain.FacebookAccount)); AddfacebookAccount = objfacebookAccount.FbUserId; } catch (Exception) { } } catch (Exception) { AddfacebookAccount = "issue_access_token"; } if (AddfacebookAccount == "issue_access_token") { Response.Redirect(Helper.SBUtils.GetFacebookRedirectLink()); } else if (AddfacebookAccount == "Account already Exist !") { } else { Session["SocialManagerInfo"] = AddfacebookAccount; //To enable the Facebook Message Pop up TempData["IsFacebookAccountAdded"] = 1; TempData["FacebookAccount"] = objfacebookAccount; } } return(RedirectToAction("Index", "Home")); }
//[CustomAuthorize] public async Task<ActionResult> Facebook(string code) { if (Session["fblogin"] != null) { if ((string)Session["fblogin"] == "fblogin") { Session["fblogin"] = null; if (String.IsNullOrEmpty(code)) { return RedirectToAction("Index", "Index"); } Domain.Socioboard.Domain.User objUser = (Domain.Socioboard.Domain.User)Session["User"]; Domain.Socioboard.Domain.User checkuserexist = (Domain.Socioboard.Domain.User)Session["User"]; string facebookcode = code; string fbloginreturn = apiobjFacebook.FacebookLogin(code); string[] arrfbloginreturn = Regex.Split(fbloginreturn, "_#_"); objUser = (Domain.Socioboard.Domain.User)(new JavaScriptSerializer().Deserialize(arrfbloginreturn[0], typeof(Domain.Socioboard.Domain.User))); Session["AccesstokenFblogin"] = arrfbloginreturn[1]; Session["fblogin"] = "******"; try { checkuserexist = (Domain.Socioboard.Domain.User)(new JavaScriptSerializer().Deserialize(ApiobjUser.getUserInfoByEmail(objUser.EmailId.ToString()), typeof(Domain.Socioboard.Domain.User))); FormsAuthentication.SetAuthCookie(checkuserexist.UserName, false); } catch (Exception e) { checkuserexist = null; } if (checkuserexist != null) { objUser = checkuserexist; Session["User"] = checkuserexist; Session["group"] = await SBHelper.LoadGroups(objUser.Id); Socioboard.Helper.apiClientProvider ac = new Socioboard.Helper.apiClientProvider(System.Configuration.ConfigurationManager.AppSettings["ApiDomainName"] + "/token"); try { Dictionary<string, string> re = await ac.GetTokenDictionary(checkuserexist.EmailId, checkuserexist.Password); Session["access_token"] = re["access_token"]; } catch (Exception e) { return RedirectToAction("Index", "Home"); } daysremaining = 0; daysremaining = (checkuserexist.ExpiryDate.Date - DateTime.Now.Date).Days; if (daysremaining > 0) { #region Count Used Accounts try { Session["Paid_User"] = "******"; Session["ProfileCount"] = Convert.ToInt32(apiobjSocialProfile.GetAllSocialProfilesOfUserCount(objUser.Id.ToString()).ToString()); } catch (Exception ex) { logger.Error(ex.StackTrace); } #endregion } else { Session["Paid_User"] = "******"; } ApiobjUser.UpdateLastLoginTime(checkuserexist.Id.ToString()); HttpCookie myCookie = new HttpCookie("referal_url"); myCookie = Request.Cookies["referal_url"]; if (myCookie != null) { Response.Redirect(".." + myCookie.Value); } return RedirectToAction("Index", "Home"); } else { objUser.ActivationStatus = "1"; Session["User"] = objUser; return RedirectToAction("Registration", "Index"); } } else if ((string)Session["fblogin"] == "page") { Session["fblogin"] = null; Api.Facebook.Facebook apiobjFacebook = new Api.Facebook.Facebook(); List<Domain.Socioboard.Domain.AddFacebookPage> lstAddFacebookPage = new List<Domain.Socioboard.Domain.AddFacebookPage>(); lstAddFacebookPage = (List<Domain.Socioboard.Domain.AddFacebookPage>)(new JavaScriptSerializer().Deserialize(apiobjFacebook.GetFacebookPages(code), typeof(List<Domain.Socioboard.Domain.AddFacebookPage>))); Session["fbpage"] = lstAddFacebookPage; return RedirectToAction("Index", "Home", new { hint = "fbpage" }); } else if ((string)Session["fblogin"] == "fbgroup") { Session["fblogin"] = null; Api.Facebook.Facebook apiobjFacebook = new Api.Facebook.Facebook(); List<Domain.Socioboard.Domain.AddFacebookGroup> lstAddFacebookGroup = new List<Domain.Socioboard.Domain.AddFacebookGroup>(); lstAddFacebookGroup = (List<Domain.Socioboard.Domain.AddFacebookGroup>)(new JavaScriptSerializer().Deserialize(apiobjFacebook.GetFacebookGroups(code), typeof(List<Domain.Socioboard.Domain.AddFacebookGroup>))); Session["fbgrp"] = lstAddFacebookGroup; return RedirectToAction("Index", "Home", new { hint = "fbgrp" }); } else if ((string)Session["fblogin"] == "fbplugin") { Session["fblogin"] = null; if (String.IsNullOrEmpty(code)) { return RedirectToAction("Index", "Index", new { hint = "plugin" }); } Domain.Socioboard.Domain.User objUser = (Domain.Socioboard.Domain.User)Session["User"]; Domain.Socioboard.Domain.User checkuserexist = (Domain.Socioboard.Domain.User)Session["User"]; Api.Facebook.Facebook apiobjFacebook = new Api.Facebook.Facebook(); Api.User.User ApiobjUser = new Api.User.User(); string fbloginreturn = apiobjFacebook.FacebookLogin(code); string[] arrfbloginreturn = Regex.Split(fbloginreturn, "_#_"); objUser = (Domain.Socioboard.Domain.User)(new JavaScriptSerializer().Deserialize(arrfbloginreturn[0], typeof(Domain.Socioboard.Domain.User))); Session["AccesstokenFblogin"] = arrfbloginreturn[1]; try { checkuserexist = (Domain.Socioboard.Domain.User)(new JavaScriptSerializer().Deserialize(ApiobjUser.getUserInfoByEmail(objUser.EmailId.ToString()), typeof(Domain.Socioboard.Domain.User))); FormsAuthentication.SetAuthCookie(checkuserexist.UserName, false); } catch (Exception e) { checkuserexist = null; } if (checkuserexist != null) { objUser = checkuserexist; Session["User"] = checkuserexist; ApiobjUser.UpdateLastLoginTime(checkuserexist.Id.ToString()); } else { if (!string.IsNullOrEmpty(objUser.EmailId)) { string user = ApiobjUser.Register(objUser.EmailId, "", "Free", objUser.UserName, "1"); objUser = (Domain.Socioboard.Domain.User)new JavaScriptSerializer().Deserialize(user, typeof(Domain.Socioboard.Domain.User)); Session["User"] = objUser; } else { return RedirectToAction("Index", "Index", new { hint = "plugin" }); } } Session["group"] = await SBHelper.LoadGroups(objUser.Id); Socioboard.Helper.apiClientProvider ac = new Socioboard.Helper.apiClientProvider(System.Configuration.ConfigurationManager.AppSettings["ApiDomainName"] + "/token"); try { Dictionary<string, string> re = await ac.GetTokenDictionary(checkuserexist.EmailId, checkuserexist.Password); Session["access_token"] = re["access_token"]; } catch (Exception e) { return RedirectToAction("Index", "Home"); } #region Count Used Accounts try { Session["ProfileCount"] = Convert.ToInt32(apiobjSocialProfile.GetAllSocialProfilesOfUserCount(objUser.Id.ToString()).ToString()); Session["TotalAccount"] = Convert.ToInt16(SBUtils.GetUserPackageProfileCount(objUser.AccountType)); } catch (Exception ex) { Session["ProfileCount"] = 0; Session["TotalAccount"] = 0; } #endregion daysremaining = 0; daysremaining = (objUser.ExpiryDate.Date - DateTime.Now.Date).Days; if (daysremaining > 0) { Session["Paid_User"] = "******"; } else { Session["Paid_User"] = "******"; } Session["fblogin"] = "******"; return RedirectToAction("Index", "Home", new { hint = "plugin" }); } } else { Domain.Socioboard.Domain.User objUser = (Domain.Socioboard.Domain.User)Session["User"]; string facebookcode = code; Api.Facebook.Facebook apiobjFacebook = new Api.Facebook.Facebook(); apiobjFacebook.Timeout = 120 * 1000; //string AddfacebookAccount = apiobjFacebook.AddFacebookAccount(facebookcode, objUser.Id.ToString(), Session["group"].ToString()); string AddfacebookAccount = ""; Domain.Socioboard.Domain.FacebookAccount objfacebookAccount = new Domain.Socioboard.Domain.FacebookAccount(); try { var res_addFacebook = apiobjFacebook.AddFacebookAccount(facebookcode, objUser.Id.ToString(), Session["group"].ToString()); AddfacebookAccount = res_addFacebook; try { objfacebookAccount = (Domain.Socioboard.Domain.FacebookAccount)new JavaScriptSerializer().Deserialize(res_addFacebook, typeof(Domain.Socioboard.Domain.FacebookAccount)); AddfacebookAccount = objfacebookAccount.FbUserId; } catch (Exception) { } } catch (Exception) { AddfacebookAccount = "issue_access_token"; } if (AddfacebookAccount == "issue_access_token") { Response.Redirect(Helper.SBUtils.GetFacebookRedirectLink()); } else if (AddfacebookAccount == "Account already Exist !") { } else { Session["SocialManagerInfo"] = AddfacebookAccount; //To enable the Facebook Message Pop up TempData["IsFacebookAccountAdded"] = 1; TempData["FacebookAccount"] = objfacebookAccount; } } return RedirectToAction("Index", "Home"); }
public ActionResult Facebook(string code) { if (Session["fblogin"] != null) { if ((string)Session["fblogin"] == "fblogin") { Session["fblogin"] = null; if (String.IsNullOrEmpty(code)) { return RedirectToAction("Index", "Index"); } Domain.Socioboard.Domain.User objUser = (Domain.Socioboard.Domain.User)Session["User"]; Domain.Socioboard.Domain.User checkuserexist = (Domain.Socioboard.Domain.User)Session["User"]; // string facebookcode = Request.QueryString["code"].ToString(); string facebookcode = code; Api.Facebook.Facebook apiobjFacebook = new Api.Facebook.Facebook(); Api.User.User ApiobjUser = new Api.User.User(); objUser = (Domain.Socioboard.Domain.User)(new JavaScriptSerializer().Deserialize(apiobjFacebook.FacebookLogin(code), typeof(Domain.Socioboard.Domain.User))); try { // objUser = (Domain.Socioboard.Domain.User)(new JavaScriptSerializer().Deserialize(apiobjFacebook.FacebookLogin(code), typeof(Domain.Socioboard.Domain.User))); checkuserexist = (Domain.Socioboard.Domain.User)(new JavaScriptSerializer().Deserialize(ApiobjUser.getUserInfoByEmail(objUser.EmailId.ToString()), typeof(Domain.Socioboard.Domain.User))); FormsAuthentication.SetAuthCookie(checkuserexist.UserName, false); } catch (Exception e) { } if (checkuserexist != null) { Session["User"] = checkuserexist; int daysremaining = 0; daysremaining = (checkuserexist.ExpiryDate.Date - DateTime.Now.Date).Days; if (daysremaining > 0) { #region Count Used Accounts try { Session["Paid_User"] = "******"; Api.SocialProfile.SocialProfile apiobjSocialProfile = new Api.SocialProfile.SocialProfile(); Session["ProfileCount"] = Convert.ToInt32(apiobjSocialProfile.GetAllSocialProfilesOfUserCount(objUser.Id.ToString()).ToString()); } catch (Exception ex) { Console.WriteLine(ex.Message); } #endregion } else { Session["Paid_User"] = "******"; } return RedirectToAction("Index", "Home"); } else { objUser.ActivationStatus = "1"; Session["User"] = objUser; return RedirectToAction("Registration", "Index"); } } else if ((string)Session["fblogin"] == "page") { Session["fblogin"] = null; Api.Facebook.Facebook apiobjFacebook = new Api.Facebook.Facebook(); List<Domain.Socioboard.Domain.AddFacebookPage> lstAddFacebookPage = new List<Domain.Socioboard.Domain.AddFacebookPage>(); lstAddFacebookPage = (List<Domain.Socioboard.Domain.AddFacebookPage>)(new JavaScriptSerializer().Deserialize(apiobjFacebook.GetFacebookPages(code), typeof(List<Domain.Socioboard.Domain.AddFacebookPage>))); Session["fbpage"] = lstAddFacebookPage; return RedirectToAction("Index", "Home", new { hint = "fbpage" }); } else if ((string)Session["fblogin"] == "fbgroup") { Session["fblogin"] = null; Api.Facebook.Facebook apiobjFacebook = new Api.Facebook.Facebook(); List<Domain.Socioboard.Domain.AddFacebookGroup> lstAddFacebookGroup = new List<Domain.Socioboard.Domain.AddFacebookGroup>(); lstAddFacebookGroup = (List<Domain.Socioboard.Domain.AddFacebookGroup>)(new JavaScriptSerializer().Deserialize(apiobjFacebook.GetFacebookGroups(code), typeof(List<Domain.Socioboard.Domain.AddFacebookGroup>))); Session["fbgrp"] = lstAddFacebookGroup; return RedirectToAction("Index", "Home", new { hint = "fbgrp" }); } } else { Domain.Socioboard.Domain.User objUser = (Domain.Socioboard.Domain.User)Session["User"]; string facebookcode = code; Api.Facebook.Facebook apiobjFacebook = new Api.Facebook.Facebook(); string AddfacebookAccount = apiobjFacebook.AddFacebookAccount(facebookcode, objUser.Id.ToString(), Session["group"].ToString()); //string AddfacebookAccount = apiobjFacebook.AddFacebookAccountAsync(facebookcode, objUser.Id.ToString(), Session["group"].ToString()); if (AddfacebookAccount == "issue_access_token") { Response.Redirect(Helper.SBUtils.GetFacebookRedirectLink()); } else { Session["SocialManagerInfo"] = AddfacebookAccount; //try //{ // apiobjFacebook.AddFacebookAccountWithPaginationAsync(facebookcode, objUser.Id.ToString(), Session["group"].ToString()); //} //catch (Exception ex) //{ // logger.Error(ex.StackTrace); // logger.Error(ex.Message); //} } } return RedirectToAction("Index", "Home"); }