コード例 #1
0
        public ActionResult YoutubeChannelVideos(string profileid)
        {
            //List<object> lstobject = new List<object>();
            //Dictionary<string, List<object>> dictwallposts = new Dictionary<string, List<object>>();
            //Api.Groups.Groups ApiobjGroups = new Api.Groups.Groups();
            //Domain.Socioboard.Domain.Groups objGroups = (Domain.Socioboard.Domain.Groups)(new JavaScriptSerializer().Deserialize(ApiobjGroups.GetGroupDetailsByGroupId(Session["group"].ToString()), typeof(Domain.Socioboard.Domain.Groups)));
            //Api.Youtube.Youtube ApiobjYoutube = new Api.Youtube.Youtube();
            //string channeldetails = ApiobjYoutube.GetYoutubeChannelVideos(objGroups.UserId.ToString(), profileid);
            //JObject obj = JObject.Parse(channeldetails);
            //JArray array = (JArray)obj["items"];

            //foreach (var item in array)
            //{
            //    try
            //    {
            //        lstobject.Add(item["snippet"]["thumbnails"]["maxres"]["url"].ToString());
            //    }
            //    catch (Exception ex)
            //    {
            //        Console.WriteLine(ex.StackTrace);
            //    }
            //}
            //dictwallposts.Add("youtube", lstobject);
            //return PartialView("_ImagePartial", dictwallposts);

            object        lstobject  = new object();
            List <object> lstComment = null;
            Dictionary <string, Dictionary <object, List <object> > > dictwallposts = new Dictionary <string, Dictionary <object, List <object> > >();
            Dictionary <object, List <object> > dic_youtube = new Dictionary <object, List <object> >();

            Api.Groups.Groups ApiobjGroups                = new Api.Groups.Groups();
            Domain.Socioboard.Domain.Groups objGroups     = (Domain.Socioboard.Domain.Groups)(new JavaScriptSerializer().Deserialize(ApiobjGroups.GetGroupDetailsByGroupId(Session["group"].ToString()), typeof(Domain.Socioboard.Domain.Groups)));
            Api.Youtube.Youtube             ApiobjYoutube = new Api.Youtube.Youtube();
            string  channeldetails = ApiobjYoutube.GetYoutubeChannelVideos(objGroups.UserId.ToString(), profileid);
            JObject obj            = JObject.Parse(channeldetails);
            JArray  array          = (JArray)obj["items"];

            foreach (var item in array)
            {
                try
                {
                    lstComment = new List <object>();
                    lstobject  = (object)item["snippet"]["thumbnails"]["maxres"]["url"].ToString();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
                dic_youtube.Add(lstobject, lstComment);
            }
            dictwallposts.Add("youtube", dic_youtube);
            return(PartialView("_ImagePartial", dictwallposts));
        }
コード例 #2
0
        public ActionResult Youtube()
        {
            string AddYoutubeAccount = string.Empty;

            Domain.Socioboard.Domain.User objUser        = (Domain.Socioboard.Domain.User)Session["User"];
            Domain.Socioboard.Domain.User checkuserexist = (Domain.Socioboard.Domain.User)Session["User"];
            string code = (String)Request.QueryString["code"];

            Api.Youtube.Youtube apiobjYoutube = new Api.Youtube.Youtube();
            Api.User.User       ApiobjUser    = new Api.User.User();
            if (Session["googlepluslogin"] != null)
            {
                objUser        = (Domain.Socioboard.Domain.User)(new JavaScriptSerializer().Deserialize(apiobjYoutube.GoogleLogin(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
            {
                try
                {
                    AddYoutubeAccount = apiobjYoutube.AddYoutubeAccount(ConfigurationManager.AppSettings["YtconsumerKey"], ConfigurationManager.AppSettings["YtconsumerSecret"], ConfigurationManager.AppSettings["Ytredirect_uri"], objUser.Id.ToString(), Session["group"].ToString(), code);
                    if (AddYoutubeAccount == "Refresh Token Not Found")
                    {
                        AuthenticateYoutube("");
                    }
                    else
                    {
                        Session["SocialManagerInfo"] = AddYoutubeAccount;
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
            return(RedirectToAction("Index", "Home"));
        }
コード例 #3
0
        public ActionResult Signup()
        {
            logger.Error("Register");
            User _user = (User)Session["User"];
            Domain.Socioboard.Domain.User user = new Domain.Socioboard.Domain.User();
            Session["AjaxLogin"] = "******";
            string retmsg = string.Empty;
            try
            {
                System.IO.StreamReader sr = new System.IO.StreamReader(Request.InputStream);
                string line = "";
                line = sr.ReadToEnd();
                JObject jo = JObject.Parse(line);
                user.PaymentStatus = "unpaid";

                user.AccountType = Server.UrlDecode((string)jo["package"]);
                user.CreateDate = DateTime.Now;
                user.ExpiryDate = DateTime.Now.AddDays(30);
                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 (_user != null)
                {
                    if (_user.ActivationStatus == "1") //If Login from Facebook, then ActivationStatus would be 1, refer to FacebookManager Controller
                    {
                        user.ActivationStatus = "1";
                        user.SocialLogin = _user.SocialLogin;
                        user.ProfileUrl = _user.ProfileUrl;
                    }
                    else
                    {
                        user.ActivationStatus = "0";
                    }
                }
                else
                {
                    user.ActivationStatus = "0";
                }
                string firstName = Server.UrlDecode((string)jo["firstname"]);
                string lastName = Server.UrlDecode((string)jo["lastname"]);
                Api.User.User objApiUser = new Api.User.User();
                //string res_Registration = objApiUser.Register(user.EmailId, user.Password, user.AccountType, user.UserName, user.ActivationStatus);
                string res_Registration = string.Empty;
                if (Session["twitterlogin"] != null)
                {
                    if ((string)Session["twitterlogin"] == "twitterlogin")
                    {
                        res_Registration = objApiUser.RegisterbyTwitter(user.EmailId, user.Password, user.AccountType, user.UserName, user.SocialLogin, user.ProfileUrl, user.ActivationStatus);
                    }
                    else
                    {
                        res_Registration = objApiUser.Register(user.EmailId, user.Password, user.AccountType, user.UserName, user.ActivationStatus);
                    }
                }
                else
                {
                    res_Registration = objApiUser.Register(user.EmailId, user.Password, user.AccountType, user.UserName, user.ActivationStatus);
                }
                logger.Error("res_Registration: " + res_Registration);
                if (res_Registration != "Email Already Exists")
                {
                    if (user != null)
                    {
                        Api.User.User obj = new Api.User.User();
                        user = (User)(new JavaScriptSerializer().Deserialize(obj.Login(user.EmailId, user.Password), typeof(User)));
                        Session["User"] = user;
                        if (Session["fblogin"] != null)
                        {
                            string accesstoken = (string)Session["AccesstokenFblogin"];
                            Api.Facebook.Facebook objfacebook = new Api.Facebook.Facebook();
                            Api.Groups.Groups objgroup = new Api.Groups.Groups();
                            //Domain.Socioboard.Domain.Groups group = (Domain.Socioboard.Domain.Groups)(new JavaScriptSerializer().Deserialize(objgroup.GetGroupDetailsByUserId(user.Id.ToString()), typeof(Domain.Socioboard.Domain.Groups)));
                            Groups obpgrp = (Groups)(new JavaScriptSerializer().Deserialize(objgroup.GetGroupDeUserId(user.Id.ToString()), typeof(Groups)));
                            objfacebook.AddFacebookAccountWithloginAsync(accesstoken, user.Id.ToString(), obpgrp.Id.ToString());
                        }
                        if (Session["googlepluslogin"] != null)
                        {
                            string accesstoken = (string)Session["AccesstokenFblogin"];
                            Api.Youtube.Youtube objYoutube = new Api.Youtube.Youtube();
                            Api.Groups.Groups objgroup = new Api.Groups.Groups();
                            //Domain.Socioboard.Domain.Groups group = (Domain.Socioboard.Domain.Groups)(new JavaScriptSerializer().Deserialize(objgroup.GetGroupDetailsByUserId(user.Id.ToString()), typeof(Domain.Socioboard.Domain.Groups)));
                            Groups grp = (Groups)(new JavaScriptSerializer().Deserialize(objgroup.GetGroupDeUserId(user.Id.ToString()), typeof(Groups)));
                            objYoutube.AddYoutubeAccountwithLoginAsync(ConfigurationManager.AppSettings["YtconsumerKey"], ConfigurationManager.AppSettings["YtconsumerSecret"], ConfigurationManager.AppSettings["Ytredirect_uri"], user.Id.ToString(), grp.Id.ToString(), accesstoken);
                        }
                        retmsg = "user";
                    }

                    //Domain.Socioboard.Domain.Invitation _Invitation = (Domain.Socioboard.Domain.Invitation)Session["InvitationInfo"];
                    Api.Invitation.Invitation ApiInvitation = new Api.Invitation.Invitation();
                    if (Session["InvitationCode"] != null)
                    {
                        string invitationcode = Session["InvitationCode"].ToString();
                        ApiInvitation.AddInvitationInfoBycode(invitationcode, user.EmailId, user.Id.ToString());
                    }

                    //if (_Invitation != null)
                    //{
                    //    if (user.EmailId == _Invitation.FriendEmail)
                    //    {
                    //        string ret = ApiInvitation.UpdateInvitatoinStatus(_Invitation.Id.ToString(), user.Id.ToString());
                    //    }
                    //}

                }
                else
                {
                    retmsg = "Email Already Exists";
                }
                //return Content(retmsg);
                Session.Abandon();
                Session.Clear();
                Session.RemoveAll();
            }
            catch (Exception ex)
            {
                //logger.Error(ex.StackTrace);
                Console.WriteLine(ex.StackTrace);
            }
            //return View("_RegistrationPartial");



            return Content(retmsg);
        }
コード例 #4
0
        public ActionResult UpdateProfileDetails(string Network, string ProfileName)
        {
            if (Session["User"] != null)
            {
                Domain.Socioboard.Domain.User _User = (Domain.Socioboard.Domain.User)Session["User"];
                if (_User.UserType != "SuperAdmin")
                {
                    return RedirectToAction("Index", "Index");
                }
            }
            else
            {
                return RedirectToAction("Index", "Index");
            }
            string ReturnMessage = string.Empty;
            bool Status = false;
            if (Network == "Facebook")
            {
                Domain.Socioboard.Domain.FacebookAccount objfb = (FacebookAccount)Session["UpdateProfileData"];
                objfb.IsActive = 1;
                objfb.FbUserName = ProfileName;
                string objFacebook = new JavaScriptSerializer().Serialize(objfb);
                Api.Facebook.Facebook ApiObjfb = new Api.Facebook.Facebook();
                string FbMessage = (string)(new JavaScriptSerializer().Deserialize(ApiObjfb.UpdateFacebookAccountByAdmin(objFacebook), typeof(string)));
                ReturnMessage = FbMessage;

            }
            if (Network == "Twitter")
            {
                Status = true;
                Domain.Socioboard.Domain.TwitterAccount objfb = (TwitterAccount)Session["UpdateProfileData"];
                objfb.IsActive = Status;
                objfb.TwitterScreenName = ProfileName;
                string objFacebook = new JavaScriptSerializer().Serialize(objfb);
                Api.Twitter.Twitter ApiObjfb = new Api.Twitter.Twitter();
                string FbMessage = (string)(new JavaScriptSerializer().Deserialize(ApiObjfb.UpdateTwitterAccountByAdmin(objFacebook), typeof(string)));
                ReturnMessage = FbMessage;

            }
            if (Network == "Linkedin")
            {
                Status = true;
                Domain.Socioboard.Domain.LinkedInAccount objfb = (LinkedInAccount)Session["UpdateProfileData"];
                objfb.IsActive = Status;
                objfb.LinkedinUserName = ProfileName;
                string objFacebook = new JavaScriptSerializer().Serialize(objfb);
                Api.Twitter.Twitter ApiObjfb = new Api.Twitter.Twitter();
                string FbMessage = (string)(new JavaScriptSerializer().Deserialize(ApiObjfb.UpdateTwitterAccountByAdmin(objFacebook), typeof(string)));
                ReturnMessage = FbMessage;
            }
            if (Network == "Instagram")
            {
                Status = true;
                Domain.Socioboard.Domain.InstagramAccount objfb = (InstagramAccount)Session["UpdateProfileData"];
                objfb.IsActive = Status;
                objfb.InsUserName = ProfileName;
                string objFacebook = new JavaScriptSerializer().Serialize(objfb);
                Api.Instagram.Instagram ApiObjfb = new Api.Instagram.Instagram();
                string FbMessage = (string)(new JavaScriptSerializer().Deserialize(ApiObjfb.UpdateInstagramAccountByAdmin(objFacebook), typeof(string)));
                ReturnMessage = FbMessage;
            }
            //if (Network == "Tumblr")
            //{
            //    Status = true;
            //    Domain.Socioboard.Domain.TwitterAccount objfb = (TwitterAccount)Session["UpdateProfileData"];
            //    objfb.IsActive = Status;
            //    objfb.TwitterScreenName = ProfileName;
            //    string objFacebook = new JavaScriptSerializer().Serialize(objfb);
            //    Api.Twitter.Twitter ApiObjfb = new Api.Twitter.Twitter();
            //    string FbMessage = (string)(new JavaScriptSerializer().Deserialize(ApiObjfb.UpdateTwitterAccountByAdmin(objFacebook), typeof(string)));
            //    ReturnMessage = FbMessage;
            //}
            if (Network == "Youtube")
            {
                Status = true;
                Domain.Socioboard.Domain.YoutubeAccount objfb = (YoutubeAccount)Session["UpdateProfileData"];
                objfb.Isactive = 1;
                objfb.Ytusername = ProfileName;
                string objFacebook = new JavaScriptSerializer().Serialize(objfb);
                Api.Youtube.Youtube ApiObjfb = new Api.Youtube.Youtube();
                string FbMessage = (string)(new JavaScriptSerializer().Deserialize(ApiObjfb.UpdateYouTubeAccountByAdmin(objFacebook), typeof(string)));
                ReturnMessage = FbMessage;
            }
            if (Network == "GooglePlus")
            {
                Status = true;
                Domain.Socioboard.Domain.GooglePlusAccount objfb = (GooglePlusAccount)Session["UpdateProfileData"];
                objfb.IsActive = 1;
                objfb.GpUserName = ProfileName;
                string objFacebook = new JavaScriptSerializer().Serialize(objfb);
                Api.Twitter.Twitter ApiObjfb = new Api.Twitter.Twitter();
                string FbMessage = (string)(new JavaScriptSerializer().Deserialize(ApiObjfb.UpdateTwitterAccountByAdmin(objFacebook), typeof(string)));
                ReturnMessage = FbMessage;
            }
            return Content(ReturnMessage);
        }
コード例 #5
0
        public ActionResult Youtube()
        {
            string AddYoutubeAccount = string.Empty;
            string AddGPlusAccount = string.Empty;
            Domain.Socioboard.Domain.User objUser = (Domain.Socioboard.Domain.User)Session["User"];
            Domain.Socioboard.Domain.User checkuserexist = (Domain.Socioboard.Domain.User)Session["User"];
            string code = (String)Request.QueryString["code"];
            Api.Youtube.Youtube apiobjYoutube = new Api.Youtube.Youtube();
            Api.GooglePlus.GooglePlus ApiobjGooglePlus = new Api.GooglePlus.GooglePlus();
            Api.User.User ApiobjUser = new Api.User.User();
            if (Session["googlepluslogin"] != null)
            {
                if (!string.IsNullOrEmpty(code))
                {
                    if (Session["googlepluslogin"].ToString() == "googlepluslogin")
                    {
                        //objUser = (Domain.Socioboard.Domain.User)(new JavaScriptSerializer().Deserialize(apiobjYoutube.GoogleLogin(code), typeof(Domain.Socioboard.Domain.User)));
                        string Googleloginreturn = apiobjYoutube.GoogleLogin(code);
                        string[] arrgoogleloginreturn = Regex.Split(Googleloginreturn, "_#_");
                        objUser = (Domain.Socioboard.Domain.User)(new JavaScriptSerializer().Deserialize(arrgoogleloginreturn[0], typeof(Domain.Socioboard.Domain.User)));
                        Session["AccesstokenFblogin"] = arrgoogleloginreturn[1];
                        Session["googlepluslogin"] = "******";
                        checkuserexist = (Domain.Socioboard.Domain.User)(new JavaScriptSerializer().Deserialize(ApiobjUser.getUserInfoByEmail(objUser.EmailId.ToString()), typeof(Domain.Socioboard.Domain.User)));
                        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"] = "******";
                            }
                            FormsAuthentication.SetAuthCookie(objUser.UserName, false);
                            ApiobjUser.UpdateLastLoginTime(checkuserexist.Id.ToString());
                            return RedirectToAction("Index", "Home");
                        }
                        else
                        {
                            objUser.ActivationStatus = "1";
                            Session["User"] = objUser;
                            return RedirectToAction("Registration", "Index");
                        }
                    }
                    else if (Session["googlepluslogin"].ToString() == "gplus")
                    {
                        AddGPlusAccount = ApiobjGooglePlus.AddGPlusAccount(ConfigurationManager.AppSettings["YtconsumerKey"], ConfigurationManager.AppSettings["YtconsumerSecret"], ConfigurationManager.AppSettings["Ytredirect_uri"], objUser.Id.ToString(), Session["group"].ToString(), code);
                        if (AddGPlusAccount == "Refresh Token Not Found")
                        {
                            AuthenticateYoutube(Session["googlepluslogin"].ToString());
                        }
                        else
                        {
                            Session["SocialManagerInfo"] = AddGPlusAccount;
                        }
                    }
                }
                else
                {
                    return RedirectToAction("Index", "Index");
                }
            }
            else
            {
                try
                {
                    AddYoutubeAccount = apiobjYoutube.AddYoutubeAccount(ConfigurationManager.AppSettings["YtconsumerKey"], ConfigurationManager.AppSettings["YtconsumerSecret"], ConfigurationManager.AppSettings["Ytredirect_uri"], objUser.Id.ToString(), Session["group"].ToString(), code);
                    if (AddYoutubeAccount == "Refresh Token Not Found")
                    {
                        AuthenticateYoutube("");
                    }
                    else
                    {
                        Session["SocialManagerInfo"] = AddYoutubeAccount;
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
            return RedirectToAction("Index", "Home");
        }
コード例 #6
0
        public ActionResult Youtube()
        {
            string AddYoutubeAccount = string.Empty;

            Domain.Socioboard.Domain.User objUser        = (Domain.Socioboard.Domain.User)Session["User"];
            Domain.Socioboard.Domain.User checkuserexist = (Domain.Socioboard.Domain.User)Session["User"];
            string code = (String)Request.QueryString["code"];

            Api.Youtube.Youtube apiobjYoutube = new Api.Youtube.Youtube();
            Api.User.User       ApiobjUser    = new Api.User.User();
            if (Session["googlepluslogin"] != null)
            {
                if (!string.IsNullOrEmpty(code))
                {
                    objUser        = (Domain.Socioboard.Domain.User)(new JavaScriptSerializer().Deserialize(apiobjYoutube.GoogleLogin(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;
                        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"] = "******";
                        }
                        FormsAuthentication.SetAuthCookie(objUser.UserName, false);
                        return(RedirectToAction("Index", "Home"));
                    }
                    else
                    {
                        Session["User"] = objUser;
                        return(RedirectToAction("Registration", "Index"));
                    }
                }
                else
                {
                    return(RedirectToAction("Index", "Index"));
                }
            }
            else
            {
                try
                {
                    AddYoutubeAccount = apiobjYoutube.AddYoutubeAccount(ConfigurationManager.AppSettings["YtconsumerKey"], ConfigurationManager.AppSettings["YtconsumerSecret"], ConfigurationManager.AppSettings["Ytredirect_uri"], objUser.Id.ToString(), Session["group"].ToString(), code);
                    if (AddYoutubeAccount == "Refresh Token Not Found")
                    {
                        AuthenticateYoutube("");
                    }
                    else
                    {
                        Session["SocialManagerInfo"] = AddYoutubeAccount;
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
            return(RedirectToAction("Index", "Home"));
        }
コード例 #7
0
        public ActionResult Signup()
        {
            logger.Error("Register");
            User _user = (User)Session["User"];

            Domain.Socioboard.Domain.User user = new Domain.Socioboard.Domain.User();
            Session["AjaxLogin"] = "******";
            string retmsg = string.Empty;

            try
            {
                System.IO.StreamReader sr = new System.IO.StreamReader(Request.InputStream);
                string line = "";
                line = sr.ReadToEnd();
                JObject jo = JObject.Parse(line);
                user.PaymentStatus = "unpaid";

                user.AccountType = Server.UrlDecode((string)jo["package"]);
                user.CreateDate  = DateTime.Now;
                user.ExpiryDate  = DateTime.Now.AddDays(30);
                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 (_user != null)
                {
                    if (_user.ActivationStatus == "1") //If Login from Facebook, then ActivationStatus would be 1, refer to FacebookManager Controller
                    {
                        user.ActivationStatus = "1";
                        user.SocialLogin      = _user.SocialLogin;
                        user.ProfileUrl       = _user.ProfileUrl;
                    }
                    else
                    {
                        user.ActivationStatus = "0";
                    }
                }
                else
                {
                    user.ActivationStatus = "0";
                }
                string        firstName  = Server.UrlDecode((string)jo["firstname"]);
                string        lastName   = Server.UrlDecode((string)jo["lastname"]);
                Api.User.User objApiUser = new Api.User.User();
                //string res_Registration = objApiUser.Register(user.EmailId, user.Password, user.AccountType, user.UserName, user.ActivationStatus);
                string res_Registration = string.Empty;
                if (Session["twitterlogin"] != null)
                {
                    if ((string)Session["twitterlogin"] == "twitterlogin")
                    {
                        res_Registration = objApiUser.RegisterbyTwitter(user.EmailId, user.Password, user.AccountType, user.UserName, user.SocialLogin, user.ProfileUrl, user.ActivationStatus);
                    }
                    else
                    {
                        res_Registration = objApiUser.Register(user.EmailId, user.Password, user.AccountType, user.UserName, user.ActivationStatus);
                    }
                }
                else
                {
                    res_Registration = objApiUser.Register(user.EmailId, user.Password, user.AccountType, user.UserName, user.ActivationStatus);
                }
                logger.Error("res_Registration: " + res_Registration);
                if (res_Registration != "Email Already Exists")
                {
                    if (user != null)
                    {
                        Api.User.User obj = new Api.User.User();
                        user            = (User)(new JavaScriptSerializer().Deserialize(obj.Login(user.EmailId, user.Password), typeof(User)));
                        Session["User"] = user;
                        if (Session["fblogin"] != null)
                        {
                            string accesstoken = (string)Session["AccesstokenFblogin"];
                            Api.Facebook.Facebook objfacebook = new Api.Facebook.Facebook();
                            Api.Groups.Groups     objgroup    = new Api.Groups.Groups();
                            //Domain.Socioboard.Domain.Groups group = (Domain.Socioboard.Domain.Groups)(new JavaScriptSerializer().Deserialize(objgroup.GetGroupDetailsByUserId(user.Id.ToString()), typeof(Domain.Socioboard.Domain.Groups)));
                            Groups obpgrp = (Groups)(new JavaScriptSerializer().Deserialize(objgroup.GetGroupDeUserId(user.Id.ToString()), typeof(Groups)));
                            objfacebook.AddFacebookAccountWithloginAsync(accesstoken, user.Id.ToString(), obpgrp.Id.ToString());
                        }
                        if (Session["googlepluslogin"] != null)
                        {
                            string accesstoken             = (string)Session["AccesstokenFblogin"];
                            Api.Youtube.Youtube objYoutube = new Api.Youtube.Youtube();
                            Api.Groups.Groups   objgroup   = new Api.Groups.Groups();
                            //Domain.Socioboard.Domain.Groups group = (Domain.Socioboard.Domain.Groups)(new JavaScriptSerializer().Deserialize(objgroup.GetGroupDetailsByUserId(user.Id.ToString()), typeof(Domain.Socioboard.Domain.Groups)));
                            Groups grp = (Groups)(new JavaScriptSerializer().Deserialize(objgroup.GetGroupDeUserId(user.Id.ToString()), typeof(Groups)));
                            objYoutube.AddYoutubeAccountwithLoginAsync(ConfigurationManager.AppSettings["YtconsumerKey"], ConfigurationManager.AppSettings["YtconsumerSecret"], ConfigurationManager.AppSettings["Ytredirect_uri"], user.Id.ToString(), grp.Id.ToString(), accesstoken);
                        }
                        retmsg = "user";
                    }

                    //Domain.Socioboard.Domain.Invitation _Invitation = (Domain.Socioboard.Domain.Invitation)Session["InvitationInfo"];
                    Api.Invitation.Invitation ApiInvitation = new Api.Invitation.Invitation();
                    if (Session["InvitationCode"] != null)
                    {
                        string invitationcode = Session["InvitationCode"].ToString();
                        ApiInvitation.AddInvitationInfoBycode(invitationcode, user.EmailId, user.Id.ToString());
                    }

                    //if (_Invitation != null)
                    //{
                    //    if (user.EmailId == _Invitation.FriendEmail)
                    //    {
                    //        string ret = ApiInvitation.UpdateInvitatoinStatus(_Invitation.Id.ToString(), user.Id.ToString());
                    //    }
                    //}
                }
                else
                {
                    retmsg = "Email Already Exists";
                }
                //return Content(retmsg);
                Session.Abandon();
                Session.Clear();
                Session.RemoveAll();
            }
            catch (Exception ex)
            {
                //logger.Error(ex.StackTrace);
                Console.WriteLine(ex.StackTrace);
            }
            //return View("_RegistrationPartial");



            return(Content(retmsg));
        }
コード例 #8
0
        public ActionResult UpdateProfileDetails(string Network, string ProfileName)
        {
            if (Session["User"] != null)
            {
                Domain.Socioboard.Domain.User _User = (Domain.Socioboard.Domain.User)Session["User"];
                if (_User.UserType != "SuperAdmin")
                {
                    return(RedirectToAction("Index", "Index"));
                }
            }
            else
            {
                return(RedirectToAction("Index", "Index"));
            }
            string ReturnMessage = string.Empty;
            bool   Status        = false;

            if (Network == "Facebook")
            {
                Domain.Socioboard.Domain.FacebookAccount objfb = (FacebookAccount)Session["UpdateProfileData"];
                objfb.IsActive   = 1;
                objfb.FbUserName = ProfileName;
                string objFacebook             = new JavaScriptSerializer().Serialize(objfb);
                Api.Facebook.Facebook ApiObjfb = new Api.Facebook.Facebook();
                string FbMessage = (string)(new JavaScriptSerializer().Deserialize(ApiObjfb.UpdateFacebookAccountByAdmin(objFacebook), typeof(string)));
                ReturnMessage = FbMessage;
            }
            if (Network == "Twitter")
            {
                Status = true;
                Domain.Socioboard.Domain.TwitterAccount objfb = (TwitterAccount)Session["UpdateProfileData"];
                objfb.IsActive          = Status;
                objfb.TwitterScreenName = ProfileName;
                string objFacebook           = new JavaScriptSerializer().Serialize(objfb);
                Api.Twitter.Twitter ApiObjfb = new Api.Twitter.Twitter();
                string FbMessage             = (string)(new JavaScriptSerializer().Deserialize(ApiObjfb.UpdateTwitterAccountByAdmin(objFacebook), typeof(string)));
                ReturnMessage = FbMessage;
            }
            if (Network == "Linkedin")
            {
                Status = true;
                Domain.Socioboard.Domain.LinkedInAccount objfb = (LinkedInAccount)Session["UpdateProfileData"];
                objfb.IsActive         = Status;
                objfb.LinkedinUserName = ProfileName;
                string objFacebook           = new JavaScriptSerializer().Serialize(objfb);
                Api.Twitter.Twitter ApiObjfb = new Api.Twitter.Twitter();
                string FbMessage             = (string)(new JavaScriptSerializer().Deserialize(ApiObjfb.UpdateTwitterAccountByAdmin(objFacebook), typeof(string)));
                ReturnMessage = FbMessage;
            }
            if (Network == "Instagram")
            {
                Status = true;
                Domain.Socioboard.Domain.InstagramAccount objfb = (InstagramAccount)Session["UpdateProfileData"];
                objfb.IsActive    = Status;
                objfb.InsUserName = ProfileName;
                string objFacebook = new JavaScriptSerializer().Serialize(objfb);
                Api.Instagram.Instagram ApiObjfb = new Api.Instagram.Instagram();
                string FbMessage = (string)(new JavaScriptSerializer().Deserialize(ApiObjfb.UpdateInstagramAccountByAdmin(objFacebook), typeof(string)));
                ReturnMessage = FbMessage;
            }
            //if (Network == "Tumblr")
            //{
            //    Status = true;
            //    Domain.Socioboard.Domain.TwitterAccount objfb = (TwitterAccount)Session["UpdateProfileData"];
            //    objfb.IsActive = Status;
            //    objfb.TwitterScreenName = ProfileName;
            //    string objFacebook = new JavaScriptSerializer().Serialize(objfb);
            //    Api.Twitter.Twitter ApiObjfb = new Api.Twitter.Twitter();
            //    string FbMessage = (string)(new JavaScriptSerializer().Deserialize(ApiObjfb.UpdateTwitterAccountByAdmin(objFacebook), typeof(string)));
            //    ReturnMessage = FbMessage;
            //}
            if (Network == "Youtube")
            {
                Status = true;
                Domain.Socioboard.Domain.YoutubeAccount objfb = (YoutubeAccount)Session["UpdateProfileData"];
                objfb.Isactive   = 1;
                objfb.Ytusername = ProfileName;
                string objFacebook           = new JavaScriptSerializer().Serialize(objfb);
                Api.Youtube.Youtube ApiObjfb = new Api.Youtube.Youtube();
                string FbMessage             = (string)(new JavaScriptSerializer().Deserialize(ApiObjfb.UpdateYouTubeAccountByAdmin(objFacebook), typeof(string)));
                ReturnMessage = FbMessage;
            }
            if (Network == "GooglePlus")
            {
                Status = true;
                Domain.Socioboard.Domain.GooglePlusAccount objfb = (GooglePlusAccount)Session["UpdateProfileData"];
                objfb.IsActive   = 1;
                objfb.GpUserName = ProfileName;
                string objFacebook           = new JavaScriptSerializer().Serialize(objfb);
                Api.Twitter.Twitter ApiObjfb = new Api.Twitter.Twitter();
                string FbMessage             = (string)(new JavaScriptSerializer().Deserialize(ApiObjfb.UpdateTwitterAccountByAdmin(objFacebook), typeof(string)));
                ReturnMessage = FbMessage;
            }
            return(Content(ReturnMessage));
        }
コード例 #9
0
        public async Task<ActionResult> Youtube()
        {
            string AddYoutubeAccount = string.Empty;
            string AddGPlusAccount = string.Empty;
            Domain.Socioboard.Domain.User objUser = (Domain.Socioboard.Domain.User)Session["User"];
            Domain.Socioboard.Domain.User checkuserexist = (Domain.Socioboard.Domain.User)Session["User"];
            string code = (String)Request.QueryString["code"];
            Api.Youtube.Youtube apiobjYoutube = new Api.Youtube.Youtube();
            Api.GooglePlus.GooglePlus ApiobjGooglePlus = new Api.GooglePlus.GooglePlus();
            Api.GoogleAnalytics.GoogleAnalytics ApiGoogleAnalytics = new Api.GoogleAnalytics.GoogleAnalytics();
            Api.User.User ApiobjUser = new Api.User.User();
            if (Session["googlepluslogin"] != "youtube")
            {
                if (!string.IsNullOrEmpty(code))
                {
                    if (Session["googlepluslogin"].ToString() == "googlepluslogin")
                    {
                        string Googleloginreturn = apiobjYoutube.GoogleLogin(code);
                        string[] arrgoogleloginreturn = Regex.Split(Googleloginreturn, "_#_");
                        objUser = (Domain.Socioboard.Domain.User)(new JavaScriptSerializer().Deserialize(arrgoogleloginreturn[0], typeof(Domain.Socioboard.Domain.User)));
                        Session["AccesstokenFblogin"] = arrgoogleloginreturn[1];
                        Session["googlepluslogin"] = "******";
                        checkuserexist = (Domain.Socioboard.Domain.User)(new JavaScriptSerializer().Deserialize(ApiobjUser.getUserInfoByEmail(objUser.EmailId.ToString()), typeof(Domain.Socioboard.Domain.User)));
                        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());
                                    Session["TotalAccount"] = Convert.ToInt16(SBUtils.GetUserPackageProfileCount(objUser.AccountType));
                                }
                                catch (Exception ex)
                                {
                                    logger.Error(ex.StackTrace);
                                }
                                #endregion
                            }
                            else
                            {
                                Session["Paid_User"] = "******";
                            }
                            Response.Cookies.Add(FormsAuthentication.GetAuthCookie(objUser.UserName, true));
                            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 (Session["googlepluslogin"].ToString() == "gplugin")
                    {
                        string Googleloginreturn = apiobjYoutube.GoogleLogin(code);
                        string[] arrgoogleloginreturn = Regex.Split(Googleloginreturn, "_#_");
                        objUser = (Domain.Socioboard.Domain.User)(new JavaScriptSerializer().Deserialize(arrgoogleloginreturn[0], typeof(Domain.Socioboard.Domain.User)));
                        Session["AccesstokenFblogin"] = arrgoogleloginreturn[1];
                      
                        checkuserexist = (Domain.Socioboard.Domain.User)(new JavaScriptSerializer().Deserialize(ApiobjUser.getUserInfoByEmail(objUser.EmailId.ToString()), typeof(Domain.Socioboard.Domain.User)));
                        if (checkuserexist != null)
                        {
                            objUser = checkuserexist;
                            Session["User"] = checkuserexist;
                            FormsAuthentication.SetAuthCookie(objUser.UserName, false);
                            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");
                        }
                        daysremaining = 0;
                        try
                        {
                            daysremaining = (checkuserexist.ExpiryDate.Date - DateTime.Now.Date).Days;
                        }
                        catch (Exception ex)
                        {
                        }
                        #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
                        if (daysremaining > 0)
                        {
                            Session["Paid_User"] = "******";
                        }
                        else
                        {
                            Session["Paid_User"] = "******";
                        }
                        Session["googlepluslogin"] = "******";
                        return RedirectToAction("Index", "Home", new { hint = "plugin" });
                    }
                    else if (Session["googlepluslogin"].ToString() == "gplus")
                    {
                        AddGPlusAccount = ApiobjGooglePlus.AddGPlusAccount(ConfigurationManager.AppSettings["YtconsumerKey"], ConfigurationManager.AppSettings["YtconsumerSecret"], ConfigurationManager.AppSettings["Ytredirect_uri"], objUser.Id.ToString(), Session["group"].ToString(), code);
                        if (AddGPlusAccount == "Refresh Token Not Found")
                        {
                            AuthenticateYoutube(Session["googlepluslogin"].ToString());
                        }
                        else
                        {
                            Session["SocialManagerInfo"] = AddGPlusAccount;
                        }
                    }
                    else if (Session["googlepluslogin"].ToString() == "ga")
                    {
                        string ret_data = ApiGoogleAnalytics.GetAnalyticsProfile(code);

                        if (ret_data == "Refresh Token Not Found")
                        {
                            AuthenticateYoutube(Session["googlepluslogin"].ToString());
                        }
                        else
                        {
                            List<Domain.Socioboard.Helper.GoogleAnalyticsProfiles> lstGoogleAnalyticsProfiles = (List<Domain.Socioboard.Helper.GoogleAnalyticsProfiles>)new JavaScriptSerializer().Deserialize(ret_data, typeof(List<Domain.Socioboard.Helper.GoogleAnalyticsProfiles>));
                            Session["GAProfiles"] = lstGoogleAnalyticsProfiles;
                        }
                        
                        return RedirectToAction("Index", "Home", new { hint = "gaprofile" });
                    }
                }
                else
                {
                    if (Session["googlepluslogin"].ToString() == "gplugin")
                    {
                        Session["googlepluslogin"] = null;
                        return RedirectToAction("Index", "Index", new { hint = "plugin" });
                    }
                    
                    return RedirectToAction("Index", "Index");
                }
            }
            else
            {
                try
                {
                    AddYoutubeAccount = apiobjYoutube.AddYoutubeAccount(ConfigurationManager.AppSettings["YtconsumerKey"], ConfigurationManager.AppSettings["YtconsumerSecret"], ConfigurationManager.AppSettings["Ytredirect_uri"], objUser.Id.ToString(), Session["group"].ToString(), code);
                    if (AddYoutubeAccount == "Refresh Token Not Found")
                    {
                        AuthenticateYoutube("");
                    }
                    else
                    {
                        Session["SocialManagerInfo"] = AddYoutubeAccount;
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
            return RedirectToAction("Index", "Home");
        }
コード例 #10
0
        public ActionResult YoutubeChannelVideos(string profileid)
        {
            //List<object> lstobject = new List<object>();
            //Dictionary<string, List<object>> dictwallposts = new Dictionary<string, List<object>>();
            //Api.Groups.Groups ApiobjGroups = new Api.Groups.Groups();
            //Domain.Socioboard.Domain.Groups objGroups = (Domain.Socioboard.Domain.Groups)(new JavaScriptSerializer().Deserialize(ApiobjGroups.GetGroupDetailsByGroupId(Session["group"].ToString()), typeof(Domain.Socioboard.Domain.Groups)));
            //Api.Youtube.Youtube ApiobjYoutube = new Api.Youtube.Youtube();
            //string channeldetails = ApiobjYoutube.GetYoutubeChannelVideos(objGroups.UserId.ToString(), profileid);
            //JObject obj = JObject.Parse(channeldetails);
            //JArray array = (JArray)obj["items"];

            //foreach (var item in array)
            //{
            //    try
            //    {
            //        lstobject.Add(item["snippet"]["thumbnails"]["maxres"]["url"].ToString());
            //    }
            //    catch (Exception ex)
            //    {
            //        Console.WriteLine(ex.StackTrace);
            //    }
            //}
            //dictwallposts.Add("youtube", lstobject);
            //return PartialView("_ImagePartial", dictwallposts);

            object lstobject = new object();
            List<object> lstComment = null;
            Dictionary<string, Dictionary<object, List<object>>> dictwallposts = new Dictionary<string, Dictionary<object, List<object>>>();
            Dictionary<object, List<object>> dic_youtube = new Dictionary<object, List<object>>();

            Api.Groups.Groups ApiobjGroups = new Api.Groups.Groups();
            Domain.Socioboard.Domain.Groups objGroups = (Domain.Socioboard.Domain.Groups)(new JavaScriptSerializer().Deserialize(ApiobjGroups.GetGroupDetailsByGroupId(Session["group"].ToString()), typeof(Domain.Socioboard.Domain.Groups)));
            Api.Youtube.Youtube ApiobjYoutube = new Api.Youtube.Youtube();
            string channeldetails = ApiobjYoutube.GetYoutubeChannelVideos(objGroups.UserId.ToString(), profileid);
            JObject obj = JObject.Parse(channeldetails);
            JArray array = (JArray)obj["items"];

            foreach (var item in array)
            {
                try
                {
                    lstComment = new List<object>();
                    lstobject = (object)item["snippet"]["thumbnails"]["maxres"]["url"].ToString();
                    dic_youtube.Add(lstobject, lstComment);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
               
            }
            dictwallposts.Add("youtube", dic_youtube);
            return PartialView("_ImagePartial", dictwallposts);
        }
コード例 #11
0
        public ActionResult Youtube()
        {
            string AddYoutubeAccount = string.Empty;
            string status = "";
            string AddGPlusAccount = string.Empty;
            Domain.Myfashion.Domain.User objUser = (Domain.Myfashion.Domain.User)Session["User"];
            Domain.Myfashion.Domain.User checkuserexist = (Domain.Myfashion.Domain.User)Session["User"];
            string code = (String)Request.QueryString["code"];
            Api.Youtube.Youtube apiobjYoutube = new Api.Youtube.Youtube();
            Api.GooglePlus.GooglePlus ApiobjGooglePlus = new Api.GooglePlus.GooglePlus();
            Api.User.User ApiobjUser = new Api.User.User();

            if (Session["googlepluslogin"] != null)
            {
                if (!string.IsNullOrEmpty(code))
                {
                    if (Session["googlepluslogin"].ToString() == "googlepluslogin")
                    {
                        //objUser = (Domain.Myfashion.Domain.User)(new JavaScriptSerializer().Deserialize(apiobjYoutube.GoogleLogin(code), typeof(Domain.Myfashion.Domain.User)));
                        string Googleloginreturn = apiobjYoutube.GoogleLogin(code);
                        string[] arrgoogleloginreturn = Regex.Split(Googleloginreturn, "_#_");
                        objUser = (Domain.Myfashion.Domain.User)(new JavaScriptSerializer().Deserialize(arrgoogleloginreturn[0], typeof(Domain.Myfashion.Domain.User)));
                        Session["AccesstokenFblogin"] = arrgoogleloginreturn[1];
                        Session["googlepluslogin"] = "******";
                        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"]);

                        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"] = "******";
                            }
                            FormsAuthentication.SetAuthCookie(objUser.UserName, false);
                            //ApiobjUser.UpdateLastLoginTime(checkuserexist.Id.ToString());
                            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 (Session["googlepluslogin"].ToString() == "gplus")
                    {
                        AddGPlusAccount = ApiobjGooglePlus.AddGPlusAccount(ConfigurationManager.AppSettings["YtconsumerKey"], ConfigurationManager.AppSettings["YtconsumerSecret"], ConfigurationManager.AppSettings["Ytredirect_uri"], objUser.Id.ToString(), Session["group"].ToString(), code);
                        if (AddGPlusAccount == "Refresh Token Not Found")
                        {
                            AuthenticateYoutube(Session["googlepluslogin"].ToString());
                        }
                        else
                        {
                            Session["SocialManagerInfo"] = AddGPlusAccount;
                        }
                    }
                }
                else
                {
                    return RedirectToAction("SocialMedia", "Index");
                }
            }
            else
            {
                try
                {
                    AddYoutubeAccount = apiobjYoutube.AddYoutubeAccount(ConfigurationManager.AppSettings["YtconsumerKey"], ConfigurationManager.AppSettings["YtconsumerSecret"], ConfigurationManager.AppSettings["Ytredirect_uri"], objUser.Id.ToString(), Session["group"].ToString(), code);
                    if (AddYoutubeAccount == "Refresh Token Not Found")
                    {
                        AuthenticateYoutube("");
                    }
                    else
                    {
                        Session["SocialManagerInfo"] = AddYoutubeAccount;
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
            return RedirectToAction("SocialMedia", "Home");
        }
コード例 #12
0
        public ActionResult Youtube()
        {
            string AddYoutubeAccount = string.Empty;
            string status            = "";
            string AddGPlusAccount   = string.Empty;

            Domain.Myfashion.Domain.User objUser        = (Domain.Myfashion.Domain.User)Session["User"];
            Domain.Myfashion.Domain.User checkuserexist = (Domain.Myfashion.Domain.User)Session["User"];
            string code = (String)Request.QueryString["code"];

            Api.Youtube.Youtube       apiobjYoutube    = new Api.Youtube.Youtube();
            Api.GooglePlus.GooglePlus ApiobjGooglePlus = new Api.GooglePlus.GooglePlus();
            Api.User.User             ApiobjUser       = new Api.User.User();

            if (Session["googlepluslogin"] != null)
            {
                if (!string.IsNullOrEmpty(code))
                {
                    if (Session["googlepluslogin"].ToString() == "googlepluslogin")
                    {
                        //objUser = (Domain.Myfashion.Domain.User)(new JavaScriptSerializer().Deserialize(apiobjYoutube.GoogleLogin(code), typeof(Domain.Myfashion.Domain.User)));
                        string   Googleloginreturn    = apiobjYoutube.GoogleLogin(code);
                        string[] arrgoogleloginreturn = Regex.Split(Googleloginreturn, "_#_");
                        objUser = (Domain.Myfashion.Domain.User)(new JavaScriptSerializer().Deserialize(arrgoogleloginreturn[0], typeof(Domain.Myfashion.Domain.User)));
                        Session["AccesstokenFblogin"] = arrgoogleloginreturn[1];
                        Session["googlepluslogin"]    = "******";
                        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"]);

                        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"] = "******";
                            }
                            FormsAuthentication.SetAuthCookie(objUser.UserName, false);
                            //ApiobjUser.UpdateLastLoginTime(checkuserexist.Id.ToString());
                            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 (Session["googlepluslogin"].ToString() == "gplus")
                    {
                        AddGPlusAccount = ApiobjGooglePlus.AddGPlusAccount(ConfigurationManager.AppSettings["YtconsumerKey"], ConfigurationManager.AppSettings["YtconsumerSecret"], ConfigurationManager.AppSettings["Ytredirect_uri"], objUser.Id.ToString(), Session["group"].ToString(), code);
                        if (AddGPlusAccount == "Refresh Token Not Found")
                        {
                            AuthenticateYoutube(Session["googlepluslogin"].ToString());
                        }
                        else
                        {
                            Session["SocialManagerInfo"] = AddGPlusAccount;
                        }
                    }
                }
                else
                {
                    return(RedirectToAction("SocialMedia", "Index"));
                }
            }
            else
            {
                try
                {
                    AddYoutubeAccount = apiobjYoutube.AddYoutubeAccount(ConfigurationManager.AppSettings["YtconsumerKey"], ConfigurationManager.AppSettings["YtconsumerSecret"], ConfigurationManager.AppSettings["Ytredirect_uri"], objUser.Id.ToString(), Session["group"].ToString(), code);
                    if (AddYoutubeAccount == "Refresh Token Not Found")
                    {
                        AuthenticateYoutube("");
                    }
                    else
                    {
                        Session["SocialManagerInfo"] = AddYoutubeAccount;
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
            return(RedirectToAction("SocialMedia", "Home"));
        }
コード例 #13
0
        public async Task <ActionResult> Youtube()
        {
            string AddYoutubeAccount = string.Empty;
            string AddGPlusAccount   = string.Empty;

            Domain.Socioboard.Domain.User objUser        = (Domain.Socioboard.Domain.User)Session["User"];
            Domain.Socioboard.Domain.User checkuserexist = (Domain.Socioboard.Domain.User)Session["User"];
            string code = (String)Request.QueryString["code"];

            Api.Youtube.Youtube                 apiobjYoutube      = new Api.Youtube.Youtube();
            Api.GooglePlus.GooglePlus           ApiobjGooglePlus   = new Api.GooglePlus.GooglePlus();
            Api.GoogleAnalytics.GoogleAnalytics ApiGoogleAnalytics = new Api.GoogleAnalytics.GoogleAnalytics();
            Api.User.User ApiobjUser = new Api.User.User();
            if (Session["googlepluslogin"] != "youtube")
            {
                if (!string.IsNullOrEmpty(code))
                {
                    if (Session["googlepluslogin"].ToString() == "googlepluslogin")
                    {
                        string   Googleloginreturn    = apiobjYoutube.GoogleLogin(code);
                        string[] arrgoogleloginreturn = Regex.Split(Googleloginreturn, "_#_");
                        objUser = (Domain.Socioboard.Domain.User)(new JavaScriptSerializer().Deserialize(arrgoogleloginreturn[0], typeof(Domain.Socioboard.Domain.User)));
                        Session["AccesstokenFblogin"] = arrgoogleloginreturn[1];
                        Session["googlepluslogin"]    = "******";
                        checkuserexist = (Domain.Socioboard.Domain.User)(new JavaScriptSerializer().Deserialize(ApiobjUser.getUserInfoByEmail(objUser.EmailId.ToString()), typeof(Domain.Socioboard.Domain.User)));
                        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());
                                    Session["TotalAccount"] = Convert.ToInt16(SBUtils.GetUserPackageProfileCount(objUser.AccountType));
                                }
                                catch (Exception ex)
                                {
                                    logger.Error(ex.StackTrace);
                                }
                                #endregion
                            }
                            else
                            {
                                Session["Paid_User"] = "******";
                            }
                            Response.Cookies.Add(FormsAuthentication.GetAuthCookie(objUser.UserName, true));
                            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 (Session["googlepluslogin"].ToString() == "gplugin")
                    {
                        string   Googleloginreturn    = apiobjYoutube.GoogleLogin(code);
                        string[] arrgoogleloginreturn = Regex.Split(Googleloginreturn, "_#_");
                        objUser = (Domain.Socioboard.Domain.User)(new JavaScriptSerializer().Deserialize(arrgoogleloginreturn[0], typeof(Domain.Socioboard.Domain.User)));
                        Session["AccesstokenFblogin"] = arrgoogleloginreturn[1];

                        checkuserexist = (Domain.Socioboard.Domain.User)(new JavaScriptSerializer().Deserialize(ApiobjUser.getUserInfoByEmail(objUser.EmailId.ToString()), typeof(Domain.Socioboard.Domain.User)));
                        if (checkuserexist != null)
                        {
                            objUser         = checkuserexist;
                            Session["User"] = checkuserexist;
                            FormsAuthentication.SetAuthCookie(objUser.UserName, false);
                            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"));
                        }
                        daysremaining = 0;
                        try
                        {
                            daysremaining = (checkuserexist.ExpiryDate.Date - DateTime.Now.Date).Days;
                        }
                        catch (Exception ex)
                        {
                        }
                        #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
                        if (daysremaining > 0)
                        {
                            Session["Paid_User"] = "******";
                        }
                        else
                        {
                            Session["Paid_User"] = "******";
                        }
                        Session["googlepluslogin"] = "******";
                        return(RedirectToAction("Index", "Home", new { hint = "plugin" }));
                    }
                    else if (Session["googlepluslogin"].ToString() == "gplus")
                    {
                        AddGPlusAccount = ApiobjGooglePlus.AddGPlusAccount(ConfigurationManager.AppSettings["YtconsumerKey"], ConfigurationManager.AppSettings["YtconsumerSecret"], ConfigurationManager.AppSettings["Ytredirect_uri"], objUser.Id.ToString(), Session["group"].ToString(), code);
                        if (AddGPlusAccount == "Refresh Token Not Found")
                        {
                            AuthenticateYoutube(Session["googlepluslogin"].ToString());
                        }
                        else
                        {
                            Session["SocialManagerInfo"] = AddGPlusAccount;
                        }
                    }
                    else if (Session["googlepluslogin"].ToString() == "ga")
                    {
                        string ret_data = ApiGoogleAnalytics.GetAnalyticsProfile(code);

                        if (ret_data == "Refresh Token Not Found")
                        {
                            AuthenticateYoutube(Session["googlepluslogin"].ToString());
                        }
                        else
                        {
                            List <Domain.Socioboard.Helper.GoogleAnalyticsProfiles> lstGoogleAnalyticsProfiles = (List <Domain.Socioboard.Helper.GoogleAnalyticsProfiles>) new JavaScriptSerializer().Deserialize(ret_data, typeof(List <Domain.Socioboard.Helper.GoogleAnalyticsProfiles>));
                            Session["GAProfiles"] = lstGoogleAnalyticsProfiles;
                        }

                        return(RedirectToAction("Index", "Home", new { hint = "gaprofile" }));
                    }
                }
                else
                {
                    if (Session["googlepluslogin"].ToString() == "gplugin")
                    {
                        Session["googlepluslogin"] = null;
                        return(RedirectToAction("Index", "Index", new { hint = "plugin" }));
                    }

                    return(RedirectToAction("Index", "Index"));
                }
            }
            else
            {
                try
                {
                    AddYoutubeAccount = apiobjYoutube.AddYoutubeAccount(ConfigurationManager.AppSettings["YtconsumerKey"], ConfigurationManager.AppSettings["YtconsumerSecret"], ConfigurationManager.AppSettings["Ytredirect_uri"], objUser.Id.ToString(), Session["group"].ToString(), code);
                    if (AddYoutubeAccount == "Refresh Token Not Found")
                    {
                        AuthenticateYoutube("");
                    }
                    else
                    {
                        Session["SocialManagerInfo"] = AddYoutubeAccount;
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
            return(RedirectToAction("Index", "Home"));
        }