Ejemplo n.º 1
0
        public void getGplusData(object UserId)
        {
            try
            {
                Guid userId = (Guid)UserId;
                GooglePlusAccountRepository objgpRepo=new GooglePlusAccountRepository();
                oAuthToken objToken = new oAuthToken();
                ArrayList arrGpAcc = objgpRepo.getAllGooglePlusAccountsOfUser(userId);
                foreach (GooglePlusAccount itemGp in arrGpAcc)
                {
                      string objRefresh = objToken.GetRefreshToken(itemGp.RefreshToken);
                        if (!objRefresh.StartsWith("["))
                            objRefresh = "[" + objRefresh + "]";
                        JArray objArray = JArray.Parse(objRefresh);
                    foreach(var item in objArray)
                    {

                        GetUserActivities(itemGp.GpUserId, item["access_token"].ToString(), userId);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }

        }
Ejemplo n.º 2
0
        public JArray GetBlogInfo(string access)
        {
            oAuthToken objToken = new oAuthToken();
            string RequestUrl = Globals.strUserInfo;


            string response = APIWebRequestToGetUserInfo(RequestUrl, access);
            if (!response.StartsWith("["))
                response = "[" + response + "]";
            return JArray.Parse(response);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// List all of the people who this user has added to one or more circles.
 /// </summary>
 /// <param name="userId"></param>
 /// <param name="access"></param>
 /// <param name="collection"></param>
 /// <returns></returns>
 public JArray Get_People_List(string userId, string access, string collection)
 {
     oAuthToken objToken = new oAuthToken();
     string RequestUrl = Globals.strGetPeopleList + userId + "/people/" + collection + "?access_token=" + access;
     Uri path = new Uri(RequestUrl);
     string[] header = { "token_type", "expires_in" };
     string[] val = { "Bearer", "3600" };
     string response = objToken.WebRequestHeader(path, header, val);
     if (!response.StartsWith("["))
         response = "[" + response + "]";
     return JArray.Parse(response);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Search all public profiles
 /// </summary>
 /// <param name="query"></param>
 /// <param name="access"></param>
 /// <returns></returns>
 public JArray Get_People_Search(string query, string access)
 {
     oAuthToken objToken = new oAuthToken();
     string RequestUrl = Globals.strGetSearchPeople + query + "&access_token=" + access;
     Uri path = new Uri(RequestUrl);
     string[] header = { "token_type", "expires_in" };
     string[] val = { "Bearer", "3600" };
     string response = objToken.WebRequestHeader(path, header, val);
     if (!response.StartsWith("["))
         response = "[" + response + "]";
     return JArray.Parse(response);
 }
Ejemplo n.º 5
0
        public JArray GetBlogInfo(string access)
        {
            oAuthToken objToken   = new oAuthToken();
            string     RequestUrl = Globals.strUserInfo;


            string response = APIWebRequestToGetUserInfo(RequestUrl, access);

            if (!response.StartsWith("["))
            {
                response = "[" + response + "]";
            }
            return(JArray.Parse(response));
        }
Ejemplo n.º 6
0
 public string getAnalyticsData(string strProfileId,string metricDimension,string strdtFrom,string strdtTo,string strToken)
 {
     string strData = string.Empty;
     oAuthToken objToken = new oAuthToken();
     try
     {
         string strDataUrl = Globals.strGetGaAnalytics + strProfileId + "&" + metricDimension + "&start-date=" + strdtFrom + "&end-date=" + strdtTo + "&access_token=" + strToken;
         strData=objToken.WebRequest(GlobusGooglePlusLib.Authentication.oAuthToken.Method.GET, strDataUrl, "");
     }
     catch (Exception Err)
     {
         Console.Write(Err.StackTrace);
     }
     return strData;
 }
Ejemplo n.º 7
0
        public JArray GetUserInfo(string UserId, string access)
        {
            oAuthToken objToken   = new oAuthToken();
            string     RequestUrl = Globals.strUserInfo + "&access_token=" + access;
            Uri        path       = new Uri(RequestUrl);

            string[] header   = { "token_type", "expires_in" };
            string[] val      = { "Bearer", "3600" };
            string   response = WebRequestHeader(path, header, val);

            if (!response.StartsWith("["))
            {
                response = "[" + response + "]";
            }
            return(JArray.Parse(response));
        }
Ejemplo n.º 8
0
        public void GetUerProfile(GooglePlusAccount objgpAcc,string acces_token,string refresh_token,Guid UserId)
        { 
              PeopleController obj = new PeopleController();
              oAuthToken objtoken = new oAuthToken();
              GooglePlusAccountRepository objgpRepo = new GooglePlusAccountRepository();
           
              SocialProfilesRepository socioprofilerepo = new SocialProfilesRepository();
              SocialProfile socioprofile = new SocialProfile();
                     
                    socioprofile.Id = Guid.NewGuid();
                    socioprofile.ProfileDate = DateTime.Now;
                    socioprofile.ProfileId = objgpAcc.GpUserId;
                    socioprofile.ProfileType = "googleplus";
                    socioprofile.UserId = UserId;

                  
                    JArray objPeopleList = obj.GetPeopleList(objgpAcc.GpUserId, acces_token, "visible");
                    objgpAcc.PeopleCount = objPeopleList.Count();


                    if (!objgpRepo.checkGooglePlusUserExists(objgpAcc.GpUserId, UserId))
                    {
                        objgpRepo.addGooglePlusUser(objgpAcc);
                        if (!socioprofilerepo.checkUserProfileExist(socioprofile))
                        {
                            socioprofilerepo.addNewProfileForUser(socioprofile);
                        }
                        else
                        {
                            socioprofilerepo.updateSocialProfile(socioprofile);
                        }
                    }
                    else
                    {
                        objgpRepo.updateGooglePlusUser(objgpAcc);
                        if (!socioprofilerepo.checkUserProfileExist(socioprofile))
                        {
                            socioprofilerepo.addNewProfileForUser(socioprofile);
                        }
                        else
                        {
                            socioprofilerepo.updateSocialProfile(socioprofile);
                        }
                    }
                    GetUserActivities(objgpAcc.GpUserId, acces_token, UserId);
                }
Ejemplo n.º 9
0
        /// <summary>
        /// Delete a moment that your app has written for the authenticated user.
        /// </summary>
        /// <param name="UserId"></param>
        /// <param name="access"></param>
        /// <returns></returns>
        public JArray Remove_Moment(string UserId, string access)
        {
            oAuthToken objToken = new oAuthToken();
            string RequestUrl = Globals.strRemoveMoments + UserId + "?access_token=" + access;
            string response = string.Empty;
            try
            {
                response = objToken.WebRequest(GlobusGooglePlusLib.Authentication.oAuthToken.Method.DELETE, RequestUrl, "");
                if (!response.StartsWith("["))
                    response = "[" + response + "]";
            }
            catch (Exception Err)
            {
                Console.Write(Err.StackTrace);
            }

            return JArray.Parse(response);
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Get an activity by Id.
 /// </summary>
 /// <param name="ActivityId"></param>
 /// <param name="access"></param>
 /// <returns></returns>
 public JArray Get_Activity_By_Id(string ActivityId, string access)
 {
     oAuthToken objToken = new oAuthToken();
     string RequestUrl = Globals.strGetActivityById + ActivityId + "?access_token=" + access;
     Uri path = new Uri(RequestUrl);
     string[] header = { "token_type", "expires_in" };
     string[] val = { "Bearer", "3600" };
     string response = string.Empty;
     try
     {
         response = objToken.WebRequestHeader(path, header, val);
         if (!response.StartsWith("["))
             response = "[" + response + "]";
     }
     catch (Exception Err)
     {
         Console.Write(Err.StackTrace);
     }
     return JArray.Parse(response);
 }
Ejemplo n.º 11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            oAuthToken objToken = new oAuthToken();
            GplusHelper objGpHelper = new GplusHelper();
            string objRefresh= objToken.GetRefreshToken(Request.QueryString["code"]);

            if (!objRefresh.StartsWith("["))
                objRefresh = "[" + objRefresh + "]";
            JArray objArray= JArray.Parse(objRefresh);
            User user=(User)Session["LoggedUser"];
            foreach (var item in objArray)
            {
               //string objAccess = objToken.GetAccessToken(item["refresh_token"].ToString());
                //if (!objAccess.StartsWith("["))
                //    objAccess = "[" + objAccess + "]";
                //JArray objArrayAccess = JArray.Parse(objAccess);
             //   objGpHelper.GetUerProfile(item["access_token"].ToString(), item["refresh_token"].ToString(), user.Id);

            }
        }
Ejemplo n.º 12
0
        public string AddYoutubeAccount(string client_id, string client_secret, string redirect_uri, string UserId, string GroupId, string code)
        {
            #region Local variables Inisitalisation
            string ret = string.Empty;
            string objRefresh = string.Empty;
            string refreshToken = string.Empty;
            string access_token = string.Empty;
            oAuthTokenYoutube ObjoAuthTokenYoutube = new oAuthTokenYoutube();
            oAuthToken objToken = new oAuthToken();
            Domain.Socioboard.Domain.YoutubeAccount objYoutubeAccount = new Domain.Socioboard.Domain.YoutubeAccount();
            Domain.Socioboard.Domain.YoutubeChannel objYoutubeChannel;
            YoutubeChannelRepository objYoutubeChannelRepository = new YoutubeChannelRepository();
            YoutubeAccountRepository objYoutubeAccountRepository = new YoutubeAccountRepository();
            #endregion
            #region Get AccessToken and RefreshToken
            objToken.ConsumerKey = client_id;
            objToken.ConsumerSecret = client_secret;
            try
            {
                objRefresh = ObjoAuthTokenYoutube.GetRefreshToken(code, client_id, client_secret, redirect_uri);
                logger.Error("Abhay: ObjoAuthTokenYoutube()");
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
                logger.Error(ex.StackTrace);
            }
            JObject objaccesstoken = JObject.Parse(objRefresh);
            try
            {
                refreshToken = objaccesstoken["refresh_token"].ToString();

            }
            catch (Exception ex)
            {
                access_token = objaccesstoken["access_token"].ToString();
                ObjoAuthTokenYoutube.RevokeToken(access_token);
                Console.WriteLine(ex.StackTrace);
                return "Refresh Token Not Found";
            }

            try
            {

                access_token = objaccesstoken["access_token"].ToString();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);

            }
            #endregion
            #region Get user Profile and Add Youtube Account
            JArray userinfo = new JArray();
            try
            {
                userinfo = objToken.GetUserInfo("me", access_token.ToString());
            }
            catch (Exception ex)
            {
            }
            foreach (var itemEmail in userinfo)
            {
                try
                {
                    objYoutubeAccount.Id = Guid.NewGuid();
                    objYoutubeAccount.Ytuserid = itemEmail["id"].ToString();
                    objYoutubeAccount.Emailid = itemEmail["email"].ToString();
                    try
                    {
                        objYoutubeAccount.Ytusername = itemEmail["given_name"].ToString();
                    }
                    catch (Exception ex)
                    {
                        objYoutubeAccount.Ytusername = itemEmail["name"].ToString();
                    }
                    objYoutubeAccount.Ytprofileimage = itemEmail["picture"].ToString();
                    objYoutubeAccount.Accesstoken = access_token;
                    objYoutubeAccount.Refreshtoken = refreshToken;
                    objYoutubeAccount.Isactive = 1;
                    objYoutubeAccount.Entrydate = DateTime.Now;
                    objYoutubeAccount.UserId = Guid.Parse(UserId);
                    if (!objYoutubeAccountRepository.checkYoutubeUserExists(objYoutubeAccount))
                    {
                        YoutubeAccountRepository.Add(objYoutubeAccount);
                        ret = "Account Added Successfully";
                    }
                    else
                    {
                        ret = "Account already Exist !";
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }

            }


            #endregion
            #region Add Youtube Channels
            GlobusGooglePlusLib.Youtube.Core.Channels ObjChannel = new GlobusGooglePlusLib.Youtube.Core.Channels();
            JArray objarray = new JArray();
            try
            {
                string part = (oAuthTokenYoutube.Parts.contentDetails.ToString() + "," + oAuthTokenYoutube.Parts.statistics.ToString());
                string Value = ObjChannel.Get_Channel_List(access_token, part, 50, true);
                JObject UserChannels = JObject.Parse(@Value);
                objarray = (JArray)UserChannels["items"];
            }
            catch (Exception ex)
            {
            }

            foreach (var item in objarray)
            {
                objYoutubeChannel = new Domain.Socioboard.Domain.YoutubeChannel();
                try
                {
                    objYoutubeChannel.Id = Guid.NewGuid();
                    objYoutubeChannel.Channelid = item["id"].ToString();
                    objYoutubeChannel.Likesid = item["contentDetails"]["relatedPlaylists"]["likes"].ToString();
                    objYoutubeChannel.Favoritesid = item["contentDetails"]["relatedPlaylists"]["favorites"].ToString();
                    objYoutubeChannel.Uploadsid = item["contentDetails"]["relatedPlaylists"]["uploads"].ToString();
                    objYoutubeChannel.Watchhistoryid = item["contentDetails"]["relatedPlaylists"]["watchHistory"].ToString();
                    objYoutubeChannel.Watchlaterid = item["contentDetails"]["relatedPlaylists"]["watchLater"].ToString();
                    objYoutubeChannel.Googleplususerid = objYoutubeAccount.Ytuserid;
                    objYoutubeChannel.UserId = Guid.Parse(UserId);
                    try
                    {
                        string viewcnt = item["statistics"]["viewCount"].ToString();
                        objYoutubeChannel.ViewCount = Convert.ToInt32(viewcnt);
                        string videocnt = item["statistics"]["videoCount"].ToString();
                        objYoutubeChannel.VideoCount = Convert.ToInt32(videocnt);
                        string commentcnt = item["statistics"]["commentCount"].ToString();
                        objYoutubeChannel.CommentCount = Convert.ToInt32(commentcnt);
                        string Subscribercnt = item["statistics"]["subscriberCount"].ToString();
                        objYoutubeChannel.SubscriberCount = Convert.ToInt32(Subscribercnt);
                        try
                        {
                            string str = item["statistics"]["hiddenSubscriberCount"].ToString();
                            if (str == "false")
                            {
                                objYoutubeChannel.HiddenSubscriberCount = 0;
                            }
                            else
                            {
                                objYoutubeChannel.HiddenSubscriberCount = 1;
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
                if (!objYoutubeChannelRepository.checkYoutubeChannelExists(objYoutubeChannel.Channelid, Guid.Parse(UserId)))
                {
                    YoutubeChannelRepository.Add(objYoutubeChannel);
                }
            }
            #endregion
            #region Add TeamMemberProfile
            Domain.Socioboard.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId));
            Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile();
            objTeamMemberProfile.Id = Guid.NewGuid();
            objTeamMemberProfile.TeamId = objTeam.Id;
            objTeamMemberProfile.Status = 1;
            objTeamMemberProfile.ProfileType = "youtube";
            objTeamMemberProfile.StatusUpdateDate = DateTime.Now;
            objTeamMemberProfile.ProfileId = objYoutubeAccount.Ytuserid;

            objTeamMemberProfile.ProfileName = objYoutubeAccount.Ytusername;
            objTeamMemberProfile.ProfilePicUrl = objYoutubeAccount.Ytprofileimage;

            if (!objTeamMemberProfileRepository.checkTeamMemberProfile(objTeam.Id, objYoutubeAccount.Ytuserid))
            {
                objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile);
            }
            #endregion
            #region SocialProfile
            Domain.Socioboard.Domain.SocialProfile objSocialProfile = new Domain.Socioboard.Domain.SocialProfile();
            objSocialProfile.Id = Guid.NewGuid();
            objSocialProfile.ProfileType = "youtube";
            objSocialProfile.ProfileId = objYoutubeAccount.Ytuserid;
            objSocialProfile.UserId = Guid.Parse(UserId);
            objSocialProfile.ProfileDate = DateTime.Now;
            objSocialProfile.ProfileStatus = 1;
            if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile))
            {
                objSocialProfilesRepository.addNewProfileForUser(objSocialProfile);
            }
            #endregion
            return ret;
        }
Ejemplo n.º 13
0
        public string GoogleLogin(string code)
        {
            string ret = string.Empty;
            string objRefresh = string.Empty;
            string refreshToken = string.Empty;
            string access_token = string.Empty;
            oAuthTokenYoutube ObjoAuthTokenYoutube = new oAuthTokenYoutube();
            oAuthToken objToken = new oAuthToken();
            Domain.Socioboard.Domain.User objuser = new Domain.Socioboard.Domain.User();
            try
            {
                logger.Error("Abhay before ObjoAuthTokenYoutube.GetRefreshToken: " + new System.Diagnostics.StackFrame(0, true).GetFileLineNumber());
                objRefresh = ObjoAuthTokenYoutube.GetRefreshToken(code, ConfigurationManager.AppSettings["YtconsumerKey"], ConfigurationManager.AppSettings["YtconsumerSecret"], ConfigurationManager.AppSettings["Ytredirect_uri"]);
                logger.Error("Abhay: " + new System.Diagnostics.StackFrame(0, true).GetFileLineNumber());

                logger.Error("1 " + code + " " + ConfigurationManager.AppSettings["YtconsumerKey"] + " " + ConfigurationManager.AppSettings["YtconsumerSecret"] + " " + ConfigurationManager.AppSettings["Ytredirect_uri"]);

            }
            catch (Exception ex)
            {
                logger.Error("2 " + code + " " + ConfigurationManager.AppSettings["YtconsumerKey"] + " " + ConfigurationManager.AppSettings["YtconsumerSecret"] + " " + ConfigurationManager.AppSettings["Ytredirect_uri"]);
                logger.Error(ex.Message);
                logger.Error(ex.StackTrace);
            }
            JObject objaccesstoken = JObject.Parse(objRefresh);
            try
            {
                refreshToken = objaccesstoken["refresh_token"].ToString();

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            try
            {

                access_token = objaccesstoken["access_token"].ToString();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);

            }

            JArray userinfo = new JArray();
            try
            {
                userinfo = objToken.GetUserInfo("me", access_token.ToString());
            }
            catch (Exception ex)
            {
            }

            foreach (var itemEmail in userinfo)
            {
                try
                {
                    objuser.EmailId = itemEmail["email"].ToString();
                    objuser.UserName = itemEmail["given_name"].ToString();
                    objuser.ProfileUrl = itemEmail["picture"].ToString();

                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }

            }
            return new JavaScriptSerializer().Serialize(objuser);
        }
Ejemplo n.º 14
0
        public void ProcessRequest()
        {
            if (Request.QueryString["op"] == "login")
            {
                try
                {
                    string email = Request.QueryString["username"];
                    string password = Request.QueryString["password"];
                    Registration regpage = new Registration();
                    password = regpage.MD5Hash(password);
                    SocioBoard.Helper.SessionFactory.configfilepath = Server.MapPath("~/hibernate.cfg.xml");
                    UserRepository userrepo = new UserRepository();
                    LoginLogs objLoginLogs = new LoginLogs();
                    LoginLogsRepository objLoginLogsRepository = new LoginLogsRepository();
                    User user = userrepo.GetUserInfo(email, password);
                    if (user == null)
                    {
                        Response.Write("Invalid Email or Password");
                    }
                    else
                    {
                        if (user.UserStatus == 1)
                        {
                            Session["LoggedUser"] = user;
                            // List<User> lstUser = new List<User>();
                            if (Session["LoggedUser"] != null)
                            {
                                //SocioBoard.Domain.User.lstUser.Add((User)Session["LoggedUser"]);
                                //Application["OnlineUsers"] = SocioBoard.Domain.User.lstUser;
                                //objLoginLogs.Id = new Guid();
                                //objLoginLogs.UserId = user.Id;
                                //objLoginLogs.UserName = user.UserName;
                                //objLoginLogs.LoginTime = DateTime.Now.AddHours(11.50);
                                //objLoginLogsRepository.Add(objLoginLogs);
                                Groups objGroups = new Groups();
                                GroupRepository objGroupRepository = new GroupRepository();
                                Team objteam = new Team();
                                TeamRepository objTeamRepository = new TeamRepository();
                                objGroups = objGroupRepository.getGroupDetail(user.Id);
                                if (objGroups == null)
                                {
                                    //================================================================================
                                    //Insert into group

                                    try
                                    {
                                        objGroups = new Groups();
                                        objGroups.Id = Guid.NewGuid();
                                        objGroups.GroupName = ConfigurationManager.AppSettings["DefaultGroupName"];
                                        objGroups.UserId = user.Id;
                                        objGroups.EntryDate = DateTime.Now;
                                        objGroupRepository.AddGroup(objGroups);

                                        objteam.Id = Guid.NewGuid();
                                        objteam.GroupId = objGroups.Id;
                                        objteam.UserId = user.Id;
                                        objteam.EmailId = user.EmailId;
                                        // teams.FirstName = user.UserName;
                                        objTeamRepository.addNewTeam(objteam);

                                        SocialProfile objSocialProfile = new SocialProfile();
                                        SocialProfilesRepository objSocialProfilesRepository = new SocialProfilesRepository();

                                        List<SocialProfile> lstSocialProfile = objSocialProfilesRepository.getAllSocialProfilesOfUser(user.Id);
                                        if (lstSocialProfile != null)
                                        {
                                            if (lstSocialProfile.Count > 0)
                                            {
                                                foreach (SocialProfile item in lstSocialProfile)
                                                {
                                                    try
                                                    {
                                                        TeamMemberProfile objTeamMemberProfile = new TeamMemberProfile();
                                                        TeamMemberProfileRepository objTeamMemberProfileRepository = new TeamMemberProfileRepository();
                                                        objTeamMemberProfile.Id = Guid.NewGuid();
                                                        objTeamMemberProfile.TeamId = objteam.Id;
                                                        objTeamMemberProfile.ProfileId = item.ProfileId;
                                                        objTeamMemberProfile.ProfileType = item.ProfileType;
                                                        objTeamMemberProfile.Status = item.ProfileStatus;
                                                        objTeamMemberProfile.StatusUpdateDate = DateTime.Now;
                                                        objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile);
                                                    }
                                                    catch (Exception ex)
                                                    {
                                                        Console.WriteLine(ex.Message);
                                                    }

                                                }
                                            }
                                        }



                                    }
                                    catch (Exception ex)
                                    {
                                        Console.WriteLine(ex.Message);
                                        logger.Error("Error : " + ex.Message);
                                        logger.Error("Error : " + ex.StackTrace);
                                    }

                                    //==========================================================================================================

                                }

                                BusinessSetting objBusinessSetting = new BusinessSetting();
                                BusinessSettingRepository objBusinessSettingRepository = new BusinessSettingRepository();
                                List<BusinessSetting> lstBusinessSetting = objBusinessSettingRepository.GetBusinessSettingByUserId(user.Id);
                                if (lstBusinessSetting.Count == 0)
                                {
                                    try
                                    {
                                        List<Groups> lstGroups = objGroupRepository.getAllGroups(user.Id);
                                        foreach (Groups item in lstGroups)
                                        {
                                            objBusinessSetting = new BusinessSetting();
                                            objBusinessSetting.Id = Guid.NewGuid();
                                            objBusinessSetting.BusinessName = item.GroupName;
                                            //objbsnssetting.GroupId = team.GroupId;
                                            objBusinessSetting.GroupId = item.Id;
                                            objBusinessSetting.AssigningTasks = false;
                                            objBusinessSetting.AssigningTasks = false;
                                            objBusinessSetting.TaskNotification = false;
                                            objBusinessSetting.TaskNotification = false;
                                            objBusinessSetting.FbPhotoUpload = 0;
                                            objBusinessSetting.UserId = user.Id;
                                            objBusinessSetting.EntryDate = DateTime.Now;
                                            objBusinessSettingRepository.AddBusinessSetting(objBusinessSetting);
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        Console.WriteLine(ex.StackTrace);
                                    }
                                }

                            }
                            Response.Write("user");
                        }

                        else
                        {
                            Response.Write("You are Blocked by Admin Please contact Admin!");
                        }


                    }
                }
                catch (Exception ex)
                {
                    Response.Write("Error: " + ex.Message);
                    Console.WriteLine(ex.StackTrace);
                    logger.Error(ex.StackTrace);
                }
            }
            else if (Request.QueryString["op"] == "register")
            {
                User user = new User();
                UserActivation objUserActivation = new UserActivation();
                UserRepository userrepo = new UserRepository();
                SocioBoard.Helper.SessionFactory.configfilepath = Server.MapPath("~/hibernate.cfg.xml");
                Session["AjaxLogin"] = "******";
                try
                {
                    System.IO.StreamReader sr = new System.IO.StreamReader(Request.InputStream);
                    string line = "";
                    line = sr.ReadToEnd();
                    JObject jo = JObject.Parse(line);
                    user.PaymentStatus = "unpaid";
                    if (!string.IsNullOrEmpty(Request.QueryString["type"]))
                    {
                        user.AccountType = Request.QueryString["type"];
                    }
                    else
                    {
                        user.AccountType = "deluxe";
                    }
                    user.CreateDate = DateTime.Now;
                    user.ExpiryDate = DateTime.Now.AddMonths(1);
                    user.Id = Guid.NewGuid();
                    user.UserName = Server.UrlDecode((string)jo["firstname"]) + " " + Server.UrlDecode((string)jo["lastname"]);
                    user.EmailId = Server.UrlDecode((string)jo["email"]);
                    user.Password = Server.UrlDecode((string)jo["password"]);
                    user.UserStatus = 1;
                    if (!userrepo.IsUserExist(user.EmailId))
                    {
                        UserRepository.Add(user);
                        Session["LoggedUser"] = user;
                        Response.Write("user");

                        objUserActivation.Id = Guid.NewGuid();
                        objUserActivation.UserId = user.Id;
                        objUserActivation.ActivationStatus = "0";
                        UserActivationRepository.Add(objUserActivation);

                        //add value in userpackage
                        UserPackageRelation objUserPackageRelation = new UserPackageRelation();
                        UserPackageRelationRepository objUserPackageRelationRepository = new UserPackageRelationRepository();
                        PackageRepository objPackageRepository = new PackageRepository();

                        Package objPackage = objPackageRepository.getPackageDetails(user.AccountType);
                        objUserPackageRelation.Id = new Guid();
                        objUserPackageRelation.PackageId = objPackage.Id;
                        objUserPackageRelation.UserId = user.Id;
                        objUserPackageRelation.PackageStatus = true;

                        objUserPackageRelationRepository.AddUserPackageRelation(objUserPackageRelation);


                        SocioBoard.Helper.MailSender.SendEMail(user.UserName, user.Password, user.EmailId, user.AccountType.ToString(), user.Id.ToString());




                        //MailSender.SendEMail(user.UserName, user.Password, user.EmailId);
                        // lblerror.Text = "Registered Successfully !" + "<a href=\"login.aspx\">Login</a>";
                    }
                    else
                    {
                        Response.Write("Email Already Exists !");
                    }
                }


                catch (Exception ex)
                {
                    logger.Error(ex.StackTrace);


                    Console.WriteLine(ex.StackTrace);
                }


            }
            else if (Request.QueryString["op"] == "facebooklogin")
            {
                SessionFactory.configfilepath = Server.MapPath("~/hibernate.cfg.xml");

                string redi = "http://www.facebook.com/dialog/oauth/?scope=publish_stream,read_stream,read_insights,manage_pages,user_checkins,user_photos,read_mailbox,manage_notifications,read_page_mailboxes,email,user_videos,offline_access&client_id=" + ConfigurationManager.AppSettings["ClientId"] + "&redirect_uri=" + ConfigurationManager.AppSettings["RedirectUrl"] + "&response_type=code";
                Session["login"] = "******";
                Response.Write(redi);



            }
            else if (Request.QueryString["op"] == "googlepluslogin")
            {
                Session["login"] = "******";
                oAuthToken objToken = new oAuthToken();
                Response.Write(objToken.GetAutherizationLink("https://www.googleapis.com/auth/userinfo.email+https://www.googleapis.com/auth/userinfo.profile+https://www.googleapis.com/auth/plus.me+https://www.googleapis.com/auth/plus.login"));
            }
            else if (Request.QueryString["op"] == "removeuser")
            {
                try
                {
                    if (Session["LoggedUser"] != null)
                    {
                        SocioBoard.Domain.User.lstUser.Remove((User)Session["LoggedUser"]);
                    }
                }
                catch (Exception Err)
                {
                    logger.Error(Err.StackTrace);
                    Response.Write(Err.StackTrace);
                }
            }


        }
Ejemplo n.º 15
0
        public string AddGPlusAccount(string client_id, string client_secret, string redirect_uri, string UserId, string GroupId, string code)
        {
            string ret = string.Empty;
            string objRefresh = string.Empty;
            string refreshToken = string.Empty;
            string access_token = string.Empty;
            try
            {

                oAuthTokenGPlus ObjoAuthTokenGPlus = new oAuthTokenGPlus();
                oAuthToken objToken = new oAuthToken();
                objToken.ConsumerKey = client_id;
                objToken.ConsumerSecret = client_secret;

                try
                {
                    objRefresh = ObjoAuthTokenGPlus.GetRefreshToken(code, client_id, client_secret, redirect_uri);
                    logger.Error("vikash: ObjoAuthTokenGPlus()");
                }
                catch (Exception ex) { }
                JObject objaccesstoken = JObject.Parse(objRefresh);

                try
                {
                    refreshToken = objaccesstoken["refresh_token"].ToString();

                }
                catch (Exception ex)
                {
                    access_token = objaccesstoken["access_token"].ToString();
                    ObjoAuthTokenGPlus.RevokeToken(access_token);
                    Console.WriteLine(ex.StackTrace);
                    ret = "Refresh Token Not Found";
                    return ret;

                }

                try
                {
                    access_token = objaccesstoken["access_token"].ToString();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);

                }

                JArray userinfo = new JArray();
                try
                {
                    userinfo = objToken.GetUserInfo("self", access_token.ToString());
                }
                catch (Exception ex)
                {
                }
                Domain.Socioboard.Domain.GooglePlusAccount _GooglePlusAccount = new Domain.Socioboard.Domain.GooglePlusAccount();
                foreach (var itemuserinfo in userinfo)
                {

                    try
                    {
                        _GooglePlusAccount.Id = Guid.NewGuid();
                        _GooglePlusAccount.GpUserId = itemuserinfo["id"].ToString();
                        _GooglePlusAccount.GpUserName = itemuserinfo["name"].ToString();
                        _GooglePlusAccount.GpProfileImage = itemuserinfo["picture"].ToString();
                        _GooglePlusAccount.IsActive = 1;
                        _GooglePlusAccount.ProfileType = "gplus";
                        _GooglePlusAccount.AccessToken = access_token;
                        _GooglePlusAccount.RefreshToken = refreshToken;
                        _GooglePlusAccount.EmailId = itemuserinfo["email"].ToString();
                        _GooglePlusAccount.UserId = Guid.Parse(UserId);
                        _GooglePlusAccount.EntryDate = DateTime.Now;


                    }
                    catch (Exception ex)
                    {
                        logger.Error("AddGPlusAccount => GooglePlusAccount =>" + ex.Message);
                    }

                }
                #region Get_InYourCircles
                try
                {
                    string _InyourCircles = ObjoAuthTokenGPlus.APIWebRequestToGetUserInfo(Globals.strGetPeopleList.Replace("[userId]", _GooglePlusAccount.GpUserId).Replace("[collection]", "visible") + "?key=" + ConfigurationManager.AppSettings["Api_Key"].ToString(), access_token);
                    JObject J_InyourCircles = JObject.Parse(_InyourCircles);
                    _GooglePlusAccount.InYourCircles = Convert.ToInt32(J_InyourCircles["totalItems"].ToString());
                }
                catch (Exception ex)
                {
                    _GooglePlusAccount.InYourCircles = 0;
                }
                #endregion

                #region Get_HaveYouInCircles
                try
                {
                    string _HaveYouInCircles = ObjoAuthTokenGPlus.APIWebRequestToGetUserInfo(Globals.strGetPeopleProfile + _GooglePlusAccount.GpUserId + "?key=" + ConfigurationManager.AppSettings["Api_Key"].ToString(), access_token);
                    JObject J_HaveYouInCircles = JObject.Parse(_HaveYouInCircles);
                    _GooglePlusAccount.HaveYouInCircles = Convert.ToInt32(J_HaveYouInCircles["circledByCount"].ToString());
                }
                catch (Exception ex)
                {
                    _GooglePlusAccount.HaveYouInCircles = 0;
                }
                #endregion

                #region Add GPlusAccount
                if (!objGooglePlusAccountRepository.checkGooglePlusUserExists(_GooglePlusAccount.GpUserId, _GooglePlusAccount.UserId))
                {
                    objGooglePlusAccountRepository.addGooglePlusUser(_GooglePlusAccount);
                    #region Add TeamMemberProfile
                    Domain.Socioboard.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId));
                    Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile();
                    objTeamMemberProfile.Id = Guid.NewGuid();
                    objTeamMemberProfile.TeamId = objTeam.Id;
                    objTeamMemberProfile.Status = 1;
                    objTeamMemberProfile.ProfileType = "gplus";
                    objTeamMemberProfile.StatusUpdateDate = DateTime.Now;
                    objTeamMemberProfile.ProfileId = _GooglePlusAccount.GpUserId;
                    objTeamMemberProfile.ProfilePicUrl = _GooglePlusAccount.GpProfileImage;
                    objTeamMemberProfile.ProfileName = _GooglePlusAccount.GpUserName;
                    objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile);
                    #endregion
                    #region SocialProfile
                    Domain.Socioboard.Domain.SocialProfile objSocialProfile = new Domain.Socioboard.Domain.SocialProfile();
                    objSocialProfile.Id = Guid.NewGuid();
                    objSocialProfile.ProfileType = "gplus";
                    objSocialProfile.ProfileId = _GooglePlusAccount.GpUserId;
                    objSocialProfile.UserId = Guid.Parse(UserId);
                    objSocialProfile.ProfileDate = DateTime.Now;
                    objSocialProfile.ProfileStatus = 1;
                    if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile))
                    {
                        objSocialProfilesRepository.addNewProfileForUser(objSocialProfile);
                    }
                    #endregion

                    ret = "Account Added Successfully";
                }
                else
                {
                    ret = "Account already Exist !";
                }

                #endregion
                GetUserActivities(UserId, _GooglePlusAccount.GpUserId, access_token);
                return new JavaScriptSerializer().Serialize(_GooglePlusAccount);
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
                return "";
            }
            
        }
Ejemplo n.º 16
0
        private void AccessToken()
        {
            SocioBoard.Domain.User user = (User)Session["LoggedUser"];
            oAuthTokenYoutube ObjoAuthTokenYoutube = new oAuthTokenYoutube();
            oAuthToken objToken = new oAuthToken();
            //GlobusGooglePlusLib.App.Core.PeopleController obj = new GlobusGooglePlusLib.App.Core.PeopleController();
            logger.Error("Error1:oAuthToken");

            string refreshToken = string.Empty;
            string access_token = string.Empty;


            try
            {
                string objRefresh = string.Empty;
                objRefresh= ObjoAuthTokenYoutube.GetRefreshToken(Request.QueryString["code"]);
                if (!objRefresh.StartsWith("["))
                    objRefresh = "[" + objRefresh + "]";
                JArray objArray = JArray.Parse(objRefresh);

                logger.Error("Error1:GetRefreshToken");

                if (!objRefresh.Contains("refresh_token"))
                {
                    logger.Error("Error0:refresh_token");
                     access_token = objArray[0]["access_token"].ToString();
                     string abc =ObjoAuthTokenYoutube.RevokeToken(access_token);
                     Response.Redirect("https://accounts.google.com/o/oauth2/auth?client_id=" + System.Configuration.ConfigurationManager.AppSettings["YtconsumerKey"] + "&redirect_uri=" + System.Configuration.ConfigurationManager.AppSettings["Ytredirect_uri"] + "&scope=https://www.googleapis.com/auth/youtube+https://www.googleapis.com/auth/youtube.readonly+https://www.googleapis.com/auth/youtubepartner+https://www.googleapis.com/auth/youtubepartner-channel-audit+https://www.googleapis.com/auth/userinfo.email+https://www.googleapis.com/auth/userinfo.profile+https://www.googleapis.com/auth/plus.me&response_type=code&access_type=offline");
                     logger.Error("Error1:refresh_token");
                }


                foreach (var item in objArray)
                {
                    logger.Error("Abhay Item :"+item);
                    try
                    {
                        try
                        {
                            refreshToken = item["refresh_token"].ToString();

                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex.StackTrace);
                            logger.Error(ex.Message);

                            Console.WriteLine(ex.StackTrace);

                        }
                        

                        access_token = item["access_token"].ToString();

                        break;

                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.StackTrace);
                        Console.WriteLine(ex.StackTrace);

                    }
                }


                //Get user Profile 
                #region <<Get user Profile>>
                JArray objEmail = new JArray();
                try
                {
                    objEmail = objToken.GetUserInfo("me", access_token.ToString());
                }
                catch (Exception ex)
                {
                    logger.Error("Email : "+ objEmail);
                    logger.Error(ex.Message);
                }


                #endregion


                GlobusGooglePlusLib.Youtube.Core.Channels ObjChannel = new GlobusGooglePlusLib.Youtube.Core.Channels();
                //Get the Channels of user 

                JArray objarray=new JArray ();
                try
                {

                    string part = (oAuthTokenYoutube.Parts.contentDetails.ToString() + "," + oAuthTokenYoutube.Parts.statistics.ToString());
                    string Value= ObjChannel.Get_Channel_List(access_token, part, 50, true);
                    logger.Error("Successfully GetValus");
                    logger.Error("Value :" +Value);
                    JObject UserChannels = JObject.Parse(@Value);
                     logger.Error("Successfully Convert Jobj");
                    logger.Error("Successfully Convert Jobj");

                    objarray = (JArray)UserChannels["items"];
                    logger.Error("Successfully Convert JArr");

                }
                catch (Exception ex)
                {
                    logger.Error("UserChannels :" + ex.Message);
                }
               

                YoutubeAccount objYoutubeAccount = new YoutubeAccount();
                YoutubeChannel objYoutubeChannel = new YoutubeChannel();
                YoutubeChannelRepository objYoutubeChannelRepository = new YoutubeChannelRepository();
                YoutubeAccountRepository objYoutubeAccountRepository = new YoutubeAccountRepository();

                //put condition here to check is user already exise if exist then update else insert
                string ytuerid = "";
                foreach (var itemEmail in objEmail)
                {
                    logger.Error("itemEmail :" + itemEmail);
                    try
                    {
                        objYoutubeAccount.Id = Guid.NewGuid();
                        ytuerid = itemEmail["id"].ToString();
                        objYoutubeAccount.Ytuserid = itemEmail["id"].ToString();
                        objYoutubeAccount.Emailid = itemEmail["email"].ToString();
                        objYoutubeAccount.Ytusername = itemEmail["given_name"].ToString();
                        objYoutubeAccount.Ytprofileimage = itemEmail["picture"].ToString();
                        objYoutubeAccount.Accesstoken = access_token;
                        objYoutubeAccount.Refreshtoken = refreshToken;
                        objYoutubeAccount.Isactive = 1;
                        objYoutubeAccount.Entrydate = DateTime.Now;
                        objYoutubeAccount.UserId = user.Id;
                    }
                    catch (Exception ex)
                    {
                        logger.Error("itemEmail1 :" + ex.Message);
                        logger.Error("itemEmail1 :" + ex.StackTrace);
                        Console.WriteLine(ex.StackTrace);
                    }

                }

                foreach (var item in objarray)
                {
                    try
                    {    
                        objYoutubeChannel.Id = Guid.NewGuid();
                        objYoutubeChannel.Channelid = item["id"].ToString();
                        objYoutubeChannel.Likesid = item["contentDetails"]["relatedPlaylists"]["likes"].ToString();
                        objYoutubeChannel.Favoritesid = item["contentDetails"]["relatedPlaylists"]["favorites"].ToString();
                        objYoutubeChannel.Uploadsid = item["contentDetails"]["relatedPlaylists"]["uploads"].ToString();
                        objYoutubeChannel.Watchhistoryid = item["contentDetails"]["relatedPlaylists"]["watchHistory"].ToString();
                        objYoutubeChannel.Watchlaterid = item["contentDetails"]["relatedPlaylists"]["watchLater"].ToString();
                        objYoutubeChannel.Googleplususerid = ytuerid;
                        try
                        {
                            string viewcnt = item["statistics"]["viewCount"].ToString();
                            objYoutubeChannel.ViewCount = Convert.ToInt32(viewcnt);

                            string videocnt = item["statistics"]["videoCount"].ToString();
                            objYoutubeChannel.VideoCount = Convert.ToInt32(videocnt);

                            string commentcnt = item["statistics"]["commentCount"].ToString();
                            objYoutubeChannel.CommentCount = Convert.ToInt32(commentcnt);

                            string Subscribercnt = item["statistics"]["subscriberCount"].ToString();
                            objYoutubeChannel.SubscriberCount = Convert.ToInt32(Subscribercnt);

                            try
                            {
                                string str = item["statistics"]["hiddenSubscriberCount"].ToString();
                                if (str == "false")
                                {
                                    objYoutubeChannel.HiddenSubscriberCount = 0;
                                }
                                else
                                {
                                    objYoutubeChannel.HiddenSubscriberCount = 1;
                                }
                            }
                            catch (Exception ex)
                            {
                                logger.Error("aagaya1: " + ex);
                                Console.WriteLine(ex.StackTrace);
                            }
                        }
                        catch (Exception ex)
                        {
                            logger.Error("aagaya2: " + ex);
                            Console.WriteLine(ex.StackTrace);
                        }


                    }
                    catch (Exception ex)
                    {
                        logger.Error("aagaya3: " + ex);
                        Console.WriteLine(ex.StackTrace);
                        logger.Error(ex.StackTrace);
                        logger.Error(ex.Message);
                    }

                }
                //YoutubeChannelRepository.Add(objYoutubeChannel);
                SocialProfile objSocialProfile = new SocialProfile();
                SocialProfilesRepository objSocialProfilesRepository = new SocialProfilesRepository();
                objSocialProfile.Id = Guid.NewGuid();
                objSocialProfile.UserId = user.Id;
                objSocialProfile.ProfileId = ytuerid;
                objSocialProfile.ProfileType = "youtube";
                objSocialProfile.ProfileDate = DateTime.Now;
                objSocialProfile.ProfileStatus = 1;
                logger.Error("aagaya");
                if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile))
                {
                    objSocialProfilesRepository.addNewProfileForUser(objSocialProfile);

                    if (!objYoutubeAccountRepository.checkYoutubeUserExists(objYoutubeAccount))
                    {
                        logger.Error("Abhay");
                        YoutubeAccountRepository.Add(objYoutubeAccount);
                        logger.Error("Abhay account add ho gaya");
                        YoutubeChannelRepository.Add(objYoutubeChannel);
                        logger.Error("Channel account add ho gaya");
                        GroupRepository objGroupRepository = new GroupRepository();
                        SocioBoard.Domain.Team team = (SocioBoard.Domain.Team)HttpContext.Current.Session["GroupName"];
                        Groups lstDetails = objGroupRepository.getGroupName(team.GroupId);
                        if (lstDetails.GroupName == "Socioboard")
                        {
                            TeamMemberProfileRepository objTeamMemberProfileRepository = new TeamMemberProfileRepository();
                            TeamMemberProfile teammemberprofile = new TeamMemberProfile();
                            teammemberprofile.Id = Guid.NewGuid();
                            teammemberprofile.TeamId = team.Id;
                            teammemberprofile.ProfileId = objYoutubeAccount.Ytuserid;
                            teammemberprofile.ProfileType = "youtube";
                            teammemberprofile.StatusUpdateDate = DateTime.Now;
                            objTeamMemberProfileRepository.addNewTeamMember(teammemberprofile);
                        }
                    }
                }
                else
                {
                    logger.Error("Suraj");
                    if (!objYoutubeAccountRepository.checkYoutubeUserExists(objYoutubeAccount))
                    {
                        YoutubeAccountRepository.Add(objYoutubeAccount);
                        YoutubeChannelRepository.Add(objYoutubeChannel);
                    }
                    else
                    {
                        Response.Redirect("Home.aspx");
                    }
                }

                Response.Redirect("Home.aspx");

            }
            catch (Exception Err)
            {
                Console.Write(Err.Message.ToString());
                logger.Error(Err.StackTrace );
                logger.Error(Err.Message);
            }
        }
Ejemplo n.º 17
0
        public void GetGoogleplusCircles(string UserId, string ProfileId,string access_token)
        {
            try
            {
                Domain.Socioboard.Domain.GooglePlusAccount _GooglePlusAccount = objGooglePlusAccountRepository.GetGooglePlusAccount(Guid.Parse(UserId), ProfileId);
                oAuthTokenGPlus ObjoAuthTokenGPlus = new oAuthTokenGPlus();
                oAuthToken objToken = new oAuthToken();

                #region Get_InYourCircles
                try
                {
                    string _InyourCircles = ObjoAuthTokenGPlus.APIWebRequestToGetUserInfo(Globals.strGetPeopleList.Replace("[userId]", _GooglePlusAccount.GpUserId).Replace("[collection]", "visible") + "?key=" + ConfigurationManager.AppSettings["Api_Key"].ToString(), access_token);
                    JObject J_InyourCircles = JObject.Parse(_InyourCircles);
                    _GooglePlusAccount.InYourCircles = Convert.ToInt32(J_InyourCircles["totalItems"].ToString());
                }
                catch (Exception ex)
                {
                    _GooglePlusAccount.InYourCircles = 0;
                }
                #endregion

                #region Get_HaveYouInCircles
                try
                {
                    string _HaveYouInCircles = ObjoAuthTokenGPlus.APIWebRequestToGetUserInfo(Globals.strGetPeopleProfile + _GooglePlusAccount.GpUserId + "?key=" + ConfigurationManager.AppSettings["Api_Key"].ToString(), access_token);
                    JObject J_HaveYouInCircles = JObject.Parse(_HaveYouInCircles);
                    _GooglePlusAccount.HaveYouInCircles = Convert.ToInt32(J_HaveYouInCircles["circledByCount"].ToString());
                }
                catch (Exception ex)
                {
                    _GooglePlusAccount.HaveYouInCircles = 0;
                }
                #endregion
                objGooglePlusAccountRepository.UpdateGooglePlusAccount(_GooglePlusAccount);
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
            }
        }
Ejemplo n.º 18
0
        public void AuthenticateGooglePlus(object sender, EventArgs e)
        {
            try
            {
                int profilecount = (int)Session["ProfileCount"];
                int totalaccount = (int)Session["TotalAccount"];
                if (profilecount < totalaccount)
                {

                    oAuthToken objToken = new oAuthToken();
                    Response.Redirect(objToken.GetAutherizationLink("https://www.googleapis.com/auth/userinfo.email+https://www.googleapis.com/auth/userinfo.profile+https://www.googleapis.com/auth/plus.me+https://www.googleapis.com/auth/plus.login"));
                }
                else
                {
                    Response.Write("<script>SimpleMessageAlert('Change the Plan to Add More Accounts');</script>");
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
            }
        }
Ejemplo n.º 19
0
        void ProcessRequest()
        {
            User user = (User)Session["LoggedUser"];
            if (Request.QueryString["op"] != null)
            {
                if (Request.QueryString["op"] == "bindMessages")
                {
                    DataSet ds = null;
                    if (Session["MessageDataTable"] == null)
                    {
                        clsFeedsAndMessages clsfeedsandmess = new clsFeedsAndMessages();
                        ds = clsfeedsandmess.bindMessagesIntoDataTable(user);
                        FacebookFeedRepository fbFeedRepo = new FacebookFeedRepository();
                        Session["MessageDataTable"] = ds;
                    }
                    else
                    {
                        ds = (DataSet)Session["MessageDataTable"];
                    }
                    string message = "There is no message !";
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        message = this.BindData(ds.Tables[0]);
                    }
                    Response.Write(message);

                }
                else if (Request.QueryString["op"] == "inbox_messages")
                {
                    DataSet ds = null;
                    if (Session["InboxMessages"] == null)
                    {
                        clsFeedsAndMessages clsfeedsandmessages = new clsFeedsAndMessages();
                        ds = clsfeedsandmessages.bindSentMessagesToDataTable(user, "");
                        Session["InboxMessages"] = ds;
                    }
                    else
                    {
                        ds = (DataSet)Session["InboxMessages"];
                    }

                    string message = "There is no message !";
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        message = this.BindData(ds.Tables[0]);
                    }
                    Response.Write(message);

                }
                else if (Request.QueryString["op"] == "bindProfiles")
                {

                    string profiles = string.Empty;
                    int i = 0;
                    profiles += "<ul class=\"options_list\">";

                    /*Binding facebook profiles in Accordian*/
                    FacebookAccountRepository facerepo = new FacebookAccountRepository();
                    ArrayList alstfacebookprofiles = facerepo.getOnlyFacebookAccountsOfUser(user.Id);
                    foreach (FacebookAccount item in alstfacebookprofiles)
                    {
                        try
                        {
                            profiles += "<ul><li><a id=\"checkimg_" + i + "\" href=\"#\" onclick=\"checkprofile('" + item.FbUserId + "','message','facebook');\"><img src=\"../Contents/img/admin/fbicon.png\"  width=\"15\" height=\"15\" alt=\"\" >" + item.FbUserName + "</a></li>";
                            i++;
                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex.Message);
                            Console.WriteLine(ex.Message);
                        }

                    }

                    /*Binding TwitterProfiles in Accordian*/
                    TwitterAccountRepository twtaccountrepo = new TwitterAccountRepository();
                    ArrayList alsttwt = twtaccountrepo.getAllTwitterAccountsOfUser(user.Id);
                    foreach (TwitterAccount item in alsttwt)
                    {
                        try
                        {
                            profiles += "<ul><li><a href=\"#\" id=\"checkimg_" + i + "\" onclick=\"checkprofile('" + item.TwitterUserId + "','message','twitter');\"><img src=\"../Contents/img/admin/twittericon.png\"  width=\"15\" height=\"15\" alt=\"\" >" + item.TwitterScreenName + "</a></li>";
                            i++;
                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex.Message);
                            Console.WriteLine(ex.Message);
                        }
                    }

                    GooglePlusAccountRepository gpAccRepo = new GooglePlusAccountRepository();
                    ArrayList alstgp = gpAccRepo.getAllGooglePlusAccountsOfUser(user.Id);
                    foreach (GooglePlusAccount item in alstgp)
                    {
                        try
                        {
                            profiles += "<ul><li><a href=\"#\" id=\"checkimg_" + i + "\" onclick=\"checkprofile('" + item.GpUserId + "','message','googleplus');\"><img src=\"../Contents/img/google_plus.png\"  width=\"15\" height=\"15\" alt=\"\" >" + item.GpUserName + "</a></li>";
                            i++;
                        }
                        catch (Exception esx)
                        {
                            logger.Error(esx.Message);
                            Console.WriteLine(esx.Message);
                        }
                    }
                    profiles += "</ul><input type=\"hidden\" id=\"profilecounter\" value=\"" + i + "\">";
                    Response.Write(profiles);
                }
                else if (Request.QueryString["op"] == "changeTaskStatus")
                {
                    Guid taskid = Guid.Parse(Request.QueryString["taskid"]);
                    bool status = bool.Parse(Request.QueryString["status"]);

                    if (status == true)
                        status = false;
                    else
                        status = true;
                    TaskRepository objTaskRepo = new TaskRepository();
                    objTaskRepo.updateTaskStatus(taskid, user.Id, status);

                }
                else if (Request.QueryString["op"] == "savetask")
                {
                    string descritption = Request.QueryString["description"];
                    Guid idtoassign = Guid.Empty;
                    try
                    {
                        if (Request.QueryString["memberid"] != string.Empty)
                        {
                            idtoassign = Guid.Parse(Request.QueryString["memberid"].ToString());
                        }
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                        // idtoassign = 0;
                    }
                    Tasks objTask = new Tasks();
                    TaskRepository objTaskRepo = new TaskRepository();
                    objTask.AssignDate = DateTime.Now.ToString("yyyy-MM-dd H:mm:ss").ToString();
                    objTask.AssignTaskTo = idtoassign;
                    objTask.TaskStatus = false;
                    objTask.TaskMessage = descritption;
                    objTask.UserId = user.Id;
                    Guid taskid = Guid.NewGuid();
                    objTask.Id = taskid;
                    objTaskRepo.addTask(objTask);

                    /////////////////
                    string comment = Request.QueryString["comment"];
                    if (!string.IsNullOrEmpty(comment))
                    {
                        string curdate = DateTime.Now.ToString("yyyy-MM-dd H:mm:ss").ToString();
                        TaskComment objcmt = new TaskComment();
                        TaskCommentRepository objcmtRepo = new TaskCommentRepository();
                        objcmt.Comment = comment;
                        objcmt.CommentDate = DateTime.Now;
                        objcmt.EntryDate = DateTime.Now;
                        objcmt.Id = Guid.NewGuid();
                        objcmt.TaskId = objTask.Id;
                        objcmt.UserId = user.Id;
                        objcmtRepo.addTaskComment(objcmt);
                    }

                }
                else if (Request.QueryString["op"] == "bindteam")
                {
                    TeamRepository objTeam = new TeamRepository();
                    string message = string.Empty;
                    message += "<ul>";
                    IEnumerable<dynamic> result = objTeam.getAllTeamsOfUser(user.Id);

                    if (result != null)
                    {
                        foreach (Team item in result)
                        {

                            message += "<li><a>";
                            message += "<img src=\"../Contents/img/blank_img.png\" alt=\"\" />";
                            message += "<span class=\"name\">" +
                                                     item.FirstName + " " + item.LastName +
                                                 "</span>" +
                                              " <span>" +
                                              "<input id=\"customerid_" + item.Id + "\" type=\"radio\" name=\"team_members\" value=\"customerid_" + item.Id + "\">" +
                                              "</span>" +
                                             "</a></li>";
                        }

                        message += "<li><a>";
                        if (string.IsNullOrEmpty(user.ProfileUrl))
                        {

                            message += "<img src=\"../Contents/img/blank_img.png\" alt=\"\" />";
                        }
                        else
                        {
                            message += "<img src=\"" + user.ProfileUrl + "\" alt=\"\" />";
                        }

                        message += "<span class=\"name\">" +
                                 user.UserName +
                              "</span>" +
                           " <span>" +
                           "<input id=\"customerid_" + user.Id + "\" type=\"radio\" name=\"team_members\" value=\"customerid_" + user.Id + "\">" +
                           "</span></a></li>";

                    }
                    else
                    {
                        message += "<li><a>";

                        if (string.IsNullOrEmpty(user.ProfileUrl))
                        {

                            message += "<img src=\"../Contents/img/blank_img.png\" alt=\"\" />";
                        }
                        else
                        {
                            message += "<img src=\"" + user.ProfileUrl + "\" alt=\"\" />";
                        }

                        message += "<span class=\"name\">" +
                                            user.UserName +
                                         "</span>" +
                                      " <span>" +
                                      "<input id=\"customerid_" + user.Id + "\" type=\"radio\" name=\"team_members\" value=\"customerid_" + user.Id + "\">" +
                                      "</span>" +
                                     "</a></li>";

                    }
                    message += "</ul>";
                    Response.Write(message);
                }
                else if (Request.QueryString["op"] == "bindarchive")
                {
                    ArchiveMessageRepository objArchiveRepo = new ArchiveMessageRepository();

                    string message = string.Empty;
                    message += "<ul  id=\"message-list\">";
                    List<ArchiveMessage> result = objArchiveRepo.getAllArchiveMessage(user.Id);
                    int sorteddatacount = 0;
                    if (result != null)
                    {
                        foreach (ArchiveMessage item in result)
                        {
                            message += "<li>";
                            sorteddatacount++;
                            if (item.SocialGroup == "twitter")
                            {
                                message += "<div id=\"messagetaskable_" + sorteddatacount + "\" class=\"userpictiny\"><div style=\"width:60px;height:auto;float:left\"><img id=\"formprofileurl_" + sorteddatacount + "\" onclick=\"detailsprofile(this.alt);\" src=\"" + item.ImgUrl + "\" height=\"48\" width=\"48\" alt=\"\" title=\"\" />" +
                                             "<a href=\"#\" class=\"userurlpic\" title=\"\"><img src=\"../Contents/img/twticon.png\" width=\"16\" height=\"16\" alt=\"\"></a></div>" +
                                             "</div><div id=\"messagedescription_" + sorteddatacount + "\" class=\"message-list-content\"><div  id=\"msgdescription_" + sorteddatacount + "\" style=\"width:500px;height:auto;float:left\"><p>" + item.Message + "</p>" +
                                                 "<div class=\"message-list-info\"><span><a href=\"#\" id=\"rowname_" + sorteddatacount + "\" onclick=\"detailsprofile(" + item.ProfileId + ");\">" + item.ProfileId + "</a> " + item.CreatedDateTime + "</span>" +
                                                 "<div class=\"scl\">" +
                                                 "<a id=\"createtasktwt_" + sorteddatacount + "\" href=\"#\" onclick=\"createtask(this.id);\"><img src= title=\"Task\" \"../Contents/img/pin.png\" alt=\"\" width=\"14\" height=\"17\" border=\"none\"></a><a href=\"#\"><img title=\"comment\" src=\"../Contents/img/admin/goto.png\" width=\"12\" height=\"12\" alt=\"\"/></a></div></div></div></div></li>";
                            }
                            else if (item.SocialGroup == "facebook")
                            {
                                message += "<div id=\"messagetaskable_" + sorteddatacount + "\" class=\"userpictiny\"><div style=\"width:60px;height:auto;float:left\"><img id=\"formprofileurl_" + sorteddatacount + "\" onclick=\"detailsprofile(this.alt);\" src=\"" + item.ImgUrl + "\" height=\"48\" width=\"48\" alt=\"\" title=\"\" />" +
                                            "<a href=\"#\" class=\"userurlpic\" title=\"\"><img src=\"../Contents/img/fb_icon.png\" width=\"16\" height=\"16\" alt=\"\"></a></div>" +
                                            "</div><div id=\"messagedescription_" + sorteddatacount + "\" class=\"message-list-content\"><div  id=\"msgdescription_" + sorteddatacount + "\" style=\"width:500px;height:auto;float:left\"><p>" + item.Message + "</p>" +
                                                "<div class=\"message-list-info\"><span><a href=\"#\" id=\"rowname_" + sorteddatacount + "\" onclick=\"getFacebookProfiles(" + item.ProfileId + ");\">" + item.ProfileId + "</a> " + item.CreatedDateTime + "</span>" +
                                                "<div class=\"scl\">" +
                                                "<a id=\"createtasktwt_" + sorteddatacount + "\" href=\"#\" onclick=\"createtask(this.id);\"><img title=\"Task\" src=\"../Contents/img/pin.png\" alt=\"\" width=\"14\" height=\"17\" border=\"none\"></a><a href=\"#\"><img title=\"comment\" src=\"../Contents/img/admin/goto.png\" width=\"12\" height=\"12\" alt=\"\"/></a></div></div></div></div></li>";

                            }
                            else if (item.SocialGroup == "googleplus")
                            {
                                message += "<div id=\"messagetaskable_" + sorteddatacount + "\" class=\"userpictiny\"><div style=\"width:60px;height:auto;float:left\"><img id=\"formprofileurl_" + sorteddatacount + "\" onclick=\"detailsprofile(this.alt);\" src=\"" + item.ImgUrl + "\" height=\"48\" width=\"48\" alt=\"\" title=\"\" />" +
                                            "<a href=\"#\" class=\"userurlpic\" title=\"\"><img src=\"../Contents/img/google_plus.png\" width=\"16\" height=\"16\" alt=\"\"></a></div>" +
                                            "</div><div id=\"messagedescription_" + sorteddatacount + "\" class=\"message-list-content\"><div  id=\"msgdescription_" + sorteddatacount + "\" style=\"width:500px;height:auto;float:left\"><p>" + item.Message + "</p>" +
                                                "<div class=\"message-list-info\"><span><a href=\"#\" id=\"rowname_" + sorteddatacount + "\" onclick=\"detailsprofile(" + item.ProfileId + ");\">" + item.ProfileId + "</a> " + item.CreatedDateTime + "</span>" +
                                                "<div class=\"scl\">" +
                                                "<a id=\"createtasktwt_" + sorteddatacount + "\" href=\"#\" onclick=\"createtask(this.id);\"><img title=\"Task\" src=\"../Contents/img/pin.png\" alt=\"\" width=\"14\" height=\"17\" border=\"none\"></a></div></div></div></div></li>";

                            }
                            message += "</li>";
                        }

                    }
                    message += "</ul>";
                    Response.Write(message);
                }
                else if (Request.QueryString["op"] == "savearchivemsg")
                {
                    User use = (User)Session["LoggedUser"];
                    ArchiveMessage am = new ArchiveMessage();
                    ArchiveMessageRepository objArchiveRepo = new ArchiveMessageRepository();
                    am.UserId = user.Id;
                    am.ImgUrl = Request.QueryString["imgurl"];
                    //am.user_name = Request.QueryString["UserName"];
                    //am.msg = Request.QueryString["Msg"];
                    ////am.sociel_group = Request.QueryString["Network"];
                    //am.createdtime = Request.QueryString["CreatedTime"];

                    System.IO.StreamReader sr = new System.IO.StreamReader(Request.InputStream);
                    string line = "";
                    line = sr.ReadToEnd();
                    // JObject jo = JObject.Parse("[" + line + "]");
                    // am.UserName = Request.QueryString["UserName"];//Server.UrlDecode((string)jo["UserName"]);
                    //am.Message = Request.QueryString["Msg"];//Server.UrlDecode((string)jo["Msg"]);
                    JObject jo = JObject.Parse(line);
                    am.Message = Server.UrlDecode((string)jo["Msg"]); ;//Server.UrlDecode((string)jo["Msg"]);
                    am.SocialGroup = Request.QueryString["Network"];// Server.UrlDecode((string)jo["Network"]);
                    am.CreatedDateTime = Request.QueryString["CreatedTime"];
                    am.MessageId = Request.QueryString["MessageId"];
                    am.ProfileId = Request.QueryString["ProfileId"];
                    am.UserId = use.Id;

                    // Server.UrlDecode((string)jo["CreatedTime"]);

                    if (am.UserName != string.Empty)
                    {
                        if (!objArchiveRepo.checkArchiveMessageExists(user.Id, am.MessageId))
                        {
                            objArchiveRepo.AddArchiveMessage(am);
                        }
                    }
                }
                else if (Request.QueryString["op"] == "createfacebookcomments")
                {
                    FacebookAccountRepository facerepo = new FacebookAccountRepository();
                    string postid = Request.QueryString["replyid"];
                    string message = Request.QueryString["replytext"];
                    string userid = Request.QueryString["userid"];
                    FacebookAccount result = facerepo.getFacebookAccountDetailsById(userid, user.Id);

                    FacebookClient fc = new FacebookClient(result.AccessToken);
                    Dictionary<string, object> parameters = new Dictionary<string, object>();
                    parameters.Add("message", message);
                    JsonObject dyn = (JsonObject)fc.Post("/" + postid+ "/comments", parameters);

                }
                else if (Request.QueryString["op"] == "getFacebookComments")
                {
                    FacebookAccountRepository facerepo = new FacebookAccountRepository();
                    string postid = Request.QueryString["postid"];
                    string userid = Request.QueryString["userid"];
                    FacebookAccount result = facerepo.getFacebookAccountDetailsById(userid, user.Id);

                    FacebookClient fc = new FacebookClient(result.AccessToken);
                    JsonObject dyn = (JsonObject)fc.Get("/" + postid + "/comments");
                    string mess = string.Empty;
                    dynamic jc = dyn["data"];
                    int iii = 0;
                    foreach (dynamic item in jc)
                    {
                        mess += "<div class=\"messages\"><section><aside><section class=\"js-avatar_tip\" data-sstip_class=\"twt_avatar_tip\">" +
                                "<a class=\"avatar_link view_profile\">" +
                                "<img width=\"54\" height=\"54\" border=\"0\" id=\"" + item["id"] + "\" class=\"avatar\" src=\"http://graph.facebook.com/" + item["from"]["id"] + "/picture?type=small\"><article class=\"message-type-icon\"></article>" +
                                 "</a></section><ul></ul></aside><article><div class=\"\"><a class=\"language\" href=\"\"></a></div>" +
                                 "<div class=\"message_actions\"><a class=\"gear_small\" href=\"#\"><span title=\"Options\" class=\"ficon\">?</span></a></div><div id=\"messagedescription_" + iii + "\" class=\"message-text font-14\">" + item["message"] + "</div><section class=\"bubble-meta\"><article class=\"threefourth text-overflow\"><section class=\"floatleft\"><a class=\"js-avatar_tip view_profile profile_link\" data-sstip_class=\"twt_avatar_tip\"><span id=\"rowname_" + iii + "\">" + item["from"]["name"] + "</span></a>&nbsp;<a data-msg-time=\"1363926699000\" class=\"time\" target=\"_blank\" title=\"View message on Twitter\">" + item["created_time"] + "</a><span class=\"location\">&nbsp;</span></section></article><ul class=\"message-buttons quarter clearfix\"></ul></section></article></section></div>";
                    }
                    Response.Write(mess);

                }
                else if (Request.QueryString["op"] == "twittercomments")
                {

                    Tweet objTwitterMethod = new Tweet();
                    TwitterAccountRepository objTwtAccRepo = new TwitterAccountRepository();
                    try
                    {
                        string messid = Request.QueryString["messid"];
                        string replytext = Request.QueryString["replytext"];
                        string replyid = Request.QueryString["replyid"];
                        string userid = Request.QueryString["userid"];
                        string username = Request.QueryString["username"];
                        string rowid = Request.QueryString["rowid"];
                        TwitterAccount objTwtAcc = objTwtAccRepo.getUserInformation(user.Id, userid);

                        TwitterHelper twthelper = new TwitterHelper();

                        oAuthTwitter OAuthTwt = new oAuthTwitter();
                        OAuthTwt.AccessToken = objTwtAcc.OAuthToken;
                        OAuthTwt.AccessTokenSecret = objTwtAcc.OAuthSecret;
                        OAuthTwt.TwitterScreenName = objTwtAcc.TwitterScreenName;
                        twthelper.SetCofigDetailsForTwitter(OAuthTwt);
                        Tweet twt = new Tweet();
                        JArray post = twt.Post_Statuses_Update(OAuthTwt, replytext);
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                    }
                }
                else if (Request.QueryString["op"] == "gpProfile")
                {
                    GooglePlusAccountRepository objgpAccRepo = new GooglePlusAccountRepository();
                    GooglePlusAccount objGpAcc = objgpAccRepo.getGooglePlusAccountDetailsById(Request.QueryString["gpid"].ToString(), user.Id);
                    PeopleController obj = new PeopleController();
                    oAuthToken objgpToken = new oAuthToken();
                    JArray objProfile = null;
                    try
                    {
                        string strAccess = objgpToken.GetAccessToken(objGpAcc.RefreshToken);
                        if (!strAccess.StartsWith("["))
                            strAccess = "[" + strAccess + "]";
                        JArray objArray = JArray.Parse(strAccess);
                        foreach (var itemgp in objArray)
                        {
                            objGpAcc.AccessToken = itemgp["access_token"].ToString();
                        }
                        objProfile = obj.GetPeopleProfile(Request.QueryString["gpid"].ToString(), objGpAcc.AccessToken);
                    }
                    catch (Exception Err)
                    {
                        logger.Error(Err.Message);
                        Console.Write(Err.Message.ToString());
                    }
                    string jas = string.Empty;
                      foreach (var item in objProfile)
                    {
                        jas += "<div class=\"modal-small draggable\">";
                        jas += "<div class=\"modal-content\">";
                        jas += "<button type=\"button\" class=\"modal-btn button b-close\">";
                        jas += "<span class=\"icon close-medium\"><span class=\"visuallyhidden\">X</span></span></button>";
                        jas += "<div class=\"modal-header\"><h3 class=\"modal-title\">Profile summary</h3></div>";
                        jas += "<div class=\"modal-body profile-modal\">";
                        jas += "<div class=\"module profile-card component profile-header\">";
                        jas += "<div style=\"background-image: url('https://pbs.twimg.com/profile_banners/215936249/1371721359');\" class=\"profile-header-inner flex-module clearfix\">";
                        jas += "<div class=\"profile-header-inner-overlay\"></div>";
                        jas += "<a href=\"#\" class=\"profile-picture media-thumbnail js-nav\">";
                        string[] imgurl = item["image"]["url"].ToString().Split('?');
                        jas += "<img src=\"" + imgurl[0] + " alt=\"" + item["name"]["givenName"] + "\" class=\"avatar size73\"></a>";
                        jas += "<div class=\"profile-card-inner\">";
                        jas += "<h1 class=\"fullname editable-group\">";
                        jas += "<a class=\"js-nav\" href=\"#\">" + item["name"]["givenName"] + "</a>";
                        jas += "<a href=\"#\" class=\"verified-link js-tooltip\">";
                        jas += "<span class=\"icon verified verified-large-border\">";
                        jas += "<span class=\"visuallyhidden\"></span></span></a></h1>";
                        jas += "<h2 class=\"username\">";
                        jas += "<a class=\"pretty-link js-nav\" href=\"#\">";
                        jas += "<span class=\"screen-name\"><s></s>" + item["displayName"] + "</span></a></h2>";
                        jas += "<div class=\"bio-container editable-group\"><p class=\"bio profile-field\"></p></div>";
                        jas += "<p class=\"location-and-url\">";
                        jas += "<span class=\"location-container editable-group\">";
                        jas += "<span class=\"location profile-field\"></span></span>";
                        jas += "<span class=\"divider hidden\"></span> ";
                        jas += "<span class=\"url editable-group\">  ";
                        jas += "<span class=\"profile-field\">";
                        jas += "<a target=\"_blank\" rel=\"me nofollow\" href=\"" + item["url"] + "\" title=\"#\">" + item["url"] + " </a></span></span></p>";
                        jas += "<div style=\"cursor: pointer; width: 16px; height: 16px; display: inline-block;\">&nbsp;</div><p></p></div></div>";
                        jas += "<div class=\"clearfix\"><div class=\"default-footer\">";
                        jas += "<div class=\"btn-group\"><div class=\"follow_button\"></div></div></div></div>";
                        jas += "<div class=\"profile-social-proof\">";
                        jas += "<div class=\"follow-bar\"></div></div></div>";
                        jas += "<ol class=\"recent-tweets\"><li class=\"\"><div><i class=\"dogear\"></i></div></li></ol>";
                        jas += "<div class=\"go_to_profile\">";
                        jas += "<small><a class=\"view_profile\" target=\"_blank\" href=\""+ item["url"] +"\">Go to full profile →</a></small></div></div>";
                        jas += "<div class=\"loading\"><span class=\"spinner-bigger\"></span></div></div></div>";
                    }
                    Response.Write(jas);
                }
                else if (Request.QueryString["op"] == "updatedstatus")
                {
                    try
                    {
                        TwitterMessageRepository twtmsgRepo = new TwitterMessageRepository();
                        int i = twtmsgRepo.updateMessageStatus(user.Id);
                        FacebookFeedRepository fbfeedRepo = new FacebookFeedRepository();
                        int j = fbfeedRepo.updateMessageStatus(user.Id);

                        if (i > 0 || j > 0)
                        {
                            Session["CountMessages"] = 0;
                            Session["MessageDataTable"] = null;

                            DataSet ds = null;
                            if (Session["MessageDataTable"] == null)
                            {
                                clsFeedsAndMessages clsfeedsandmess = new clsFeedsAndMessages();
                                ds = clsfeedsandmess.bindMessagesIntoDataTable(user);
                                FacebookFeedRepository fbFeedRepo = new FacebookFeedRepository();
                                Session["MessageDataTable"] = ds;
                            }
                            else
                            {
                                ds = (DataSet)Session["MessageDataTable"];
                            }
                        }

                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                        Console.WriteLine(ex.Message);

                    }
                }
            }
        }
Ejemplo n.º 20
0
        public void ProcessRequest()
        {
            if (Request.QueryString["op"] == "login")
            {
                try
                {
                    string email = Request.QueryString["username"];
                    string password = Request.QueryString["password"];
                    SocioBoard.Helper.SessionFactory.configfilepath = Server.MapPath("~/hibernate.cfg.xml");
                    UserRepository userrepo = new UserRepository();
                    User user = userrepo.GetUserInfo(email, password);
                    if (user == null)
                    {
                        Response.Write("Invalid Email or Password");
                    }
                    else
                    {

                        Session["LoggedUser"] = user;
                       // List<User> lstUser = new List<User>();
                        if (Session["LoggedUser"] != null)
                        {
                            SocioBoard.Domain.User.lstUser.Add((User)Session["LoggedUser"]);
                            Application["OnlineUsers"] = SocioBoard.Domain.User.lstUser;
                        }
                        Response.Write("user");
                    }
                }
                catch (Exception ex)
                {
                    Response.Write("Error: " + ex.Message);
                    Console.WriteLine(ex.StackTrace);
                    logger.Error(ex.StackTrace);
                }
            }
            else if (Request.QueryString["op"] == "register")
            {
                User user = new User();
                UserRepository userrepo = new UserRepository();
                SocioBoard.Helper.SessionFactory.configfilepath = Server.MapPath("~/hibernate.cfg.xml");
                Session["AjaxLogin"] = "******";

                try
                {
                    System.IO.StreamReader sr = new System.IO.StreamReader(Request.InputStream);
                    string line = "";
                    line = sr.ReadToEnd();
                    JObject jo = JObject.Parse(line);
                    user.PaymentStatus = "unpaid";
                    if (jo["plantype"].ToString() == "standard")
                    {
                        user.AccountType = AccountType.Standard.ToString();
                    }
                    else if (jo["plantype"].ToString() == "deluxe")
                    {
                        user.AccountType = AccountType.Deluxe.ToString();
                    }
                    else if (jo["plantype"].ToString() == "premium")
                    {
                        user.AccountType = AccountType.Premium.ToString();
                    }

                    user.CreateDate = DateTime.Now;
                    user.ExpiryDate = DateTime.Now.AddMonths(1);
                    user.Id = Guid.NewGuid();
                    user.UserName = Server.UrlDecode((string)jo["firstname"]) + " " + Server.UrlDecode((string)jo["lastname"]);
                    user.EmailId = Server.UrlDecode((string)jo["email"]);
                    user.Password = Server.UrlDecode((string)jo["password"]);
                    user.UserStatus = 1;
                    if (!userrepo.IsUserExist(user.EmailId))
                    {
                        UserRepository.Add(user);
                        Session["LoggedUser"] = user;
                        Response.Write("user");
                        blackSheep.Helper.MailSender.SendEMail(user.UserName, user.Password, user.EmailId);
                        // lblerror.Text = "Registered Successfully !" + "<a href=\"login.aspx\">Login</a>";
                    }
                    else
                    {
                        Response.Write("Email Already Exists !");
                    }
                }

                catch (Exception ex)
                {
                    logger.Error(ex.StackTrace);

                    Console.WriteLine(ex.StackTrace);
                }

            }
            else if (Request.QueryString["op"] == "facebooklogin")
            {
                SocioBoard.Helper.SessionFactory.configfilepath = Server.MapPath("~/hibernate.cfg.xml");

                string redi = "http://www.facebook.com/dialog/oauth/?scope=publish_stream,read_stream,read_insights,manage_pages,user_checkins,user_photos,read_mailbox,manage_notifications,read_page_mailboxes,email,user_videos,offline_access&client_id=" + ConfigurationManager.AppSettings["ClientId"] + "&redirect_uri=" + ConfigurationManager.AppSettings["RedirectUrl"] + "&response_type=code";
                Session["login"] = "******";
                Response.Write(redi);

            }
            else if (Request.QueryString["op"] == "googlepluslogin")
            {
                SocioBoard.Helper.SessionFactory.configfilepath = Server.MapPath("~/hibernate.cfg.xml");
                Session["login"] = "******";
                oAuthToken objToken = new oAuthToken();
                Response.Write(objToken.GetAutherizationLink("https://www.googleapis.com/auth/userinfo.email+https://www.googleapis.com/auth/userinfo.profile+https://www.googleapis.com/auth/plus.me+https://www.googleapis.com/auth/plus.login"));
            }
            else if (Request.QueryString["op"] == "removeuser")
            {
                try
                {
                    SocioBoard.Helper.SessionFactory.configfilepath = Server.MapPath("~/hibernate.cfg.xml");
                    if (Session["LoggedUser"] != null)
                    {
                        SocioBoard.Domain.User.lstUser.Remove((User)Session["LoggedUser"]);
                    }
                }
                catch (Exception Err)
                {
                    logger.Error(Err.StackTrace);
                    Response.Write(Err.StackTrace);
                }
            }
        }
Ejemplo n.º 21
0
        public void GooglePlusRedirect(object sender, EventArgs e)
        {
            if (ddlGroup.SelectedItem.Text != "Select")
            {
                Session["UserAndGroupsForFacebook"] = "googleplus";
                oAuthToken objToken = new oAuthToken();
                Response.Redirect(objToken.GetAutherizationLink("https://www.googleapis.com/auth/userinfo.email+https://www.googleapis.com/auth/userinfo.profile+https://www.googleapis.com/auth/plus.me+https://www.googleapis.com/auth/plus.login"));
            }
            else
            {
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "test", "<script type=\"text/javascript\">alert(\"Select the group to add profiles\")</script>", false);

            }
        }
Ejemplo n.º 22
0
        protected void Page_Load(object sender, EventArgs e)
        {
            oAuthToken objToken = new oAuthToken();
            GplusHelper objGpHelper = new GplusHelper();
            UserRepository objUserRepo = new UserRepository();
            PeopleController obj = new PeopleController();
            GooglePlusAccount objgpAcc = new GooglePlusAccount();
            User user = new User();
            try
            {
                string objRefresh = objToken.GetRefreshToken(Request.QueryString["code"]);
                if (!objRefresh.StartsWith("["))
                    objRefresh = "[" + objRefresh + "]";
                JArray objArray = JArray.Parse(objRefresh);
                if (Session["login"] != null)
                {
                    if (Session["login"].ToString() == "googleplus")
                    {
                        user = new User();
                        user.CreateDate = DateTime.Now;
                        user.ExpiryDate = DateTime.Now.AddMonths(1);
                        user.Id = Guid.NewGuid();
                        user.PaymentStatus = "unpaid";
                    }

                }
                else
                {
                    /*User class in SocioBoard.Domain to check authenticated user*/
                    user = (User)Session["LoggedUser"];
                }
                foreach (var item in objArray)
                {
                    try
                    {
                        JArray objEmail = objToken.GetUserInfo("me", item["access_token"].ToString());
                        JArray objProfile = obj.GetPeopleProfile("me", item["access_token"].ToString());
                        // user = (User)HttpContext.Current.Session["LoggedUser"];
                        foreach (var itemEmail in objEmail)
                        {
                            objgpAcc.EmailId = itemEmail["email"].ToString();

                        }
                        foreach (var itemProfile in objProfile)
                        {
                            objgpAcc.GpUserId = itemProfile["id"].ToString();
                            objgpAcc.AccessToken = item["access_token"].ToString();
                            objgpAcc.EntryDate = DateTime.Now;
                            objgpAcc.GpProfileImage = itemProfile["image"]["url"].ToString();
                            objgpAcc.GpUserName = itemProfile["displayName"].ToString();
                            objgpAcc.Id =Guid.NewGuid();
                            objgpAcc.IsActive = 1;
                            objgpAcc.RefreshToken = item["refresh_token"].ToString();
                            objgpAcc.UserId = user.Id;

                        }

                        if (Session["login"] != null)
                        {
                            if (string.IsNullOrEmpty(user.Password))
                            {
                                if (Session["login"].ToString() == "googleplus")
                                {
                                    if (objUserRepo.IsUserExist(user.EmailId))
                                    {
                                        // user = null;
                                        user = objUserRepo.getUserInfoByEmail(user.EmailId);
                                    }
                                    else
                                    {
                                        user.EmailId = objgpAcc.EmailId;
                                        user.UserName = objgpAcc.GpUserName;
                                        user.ProfileUrl = objgpAcc.GpProfileImage;
                                        UserRepository.Add(user);
                                    }
                                    Session["LoggedUser"] = user;
                                    objgpAcc.UserId = user.Id;
                                }
                            }
                        }
                        objGpHelper.GetUerProfile(objgpAcc, item["access_token"].ToString(), item["refresh_token"].ToString(), user.Id);

                        if (Session["login"] != null)
                        {
                            if (string.IsNullOrEmpty(user.Password))
                            {
                                if (Session["login"].ToString() == "googleplus")
                                {
                                    Response.Redirect("Plans.aspx");
                                }
                            }
                            else
                            {
                                Response.Redirect("Home.aspx");
                            }
                        }
                        else
                        {
                            Response.Redirect("Home.aspx");
                        }

                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.StackTrace);
                        Console.WriteLine(ex.StackTrace);
                        Response.Redirect("Home.aspx");
                    }
                }

            }
            catch (Exception Err)
            {
                Console.Write(Err.Message.ToString());
                logger.Error(Err.StackTrace);
                Response.Redirect("Home.aspx");
            }
        }
Ejemplo n.º 23
0
        public string getYoutubeData(string UserId, string youtubeId)
        {
            string ret = string.Empty;
            try
            {
                Guid userId = Guid.Parse(UserId);
                oAuthToken OAuthToken = new oAuthToken();
                OAuthToken.ConsumerKey = ConfigurationManager.AppSettings["YtconsumerKey"];
                OAuthToken.ConsumerSecret = ConfigurationManager.AppSettings["YtconsumerSecret"];
                YoutubeAccountRepository ObjYoutubeAccountRepository = new YoutubeAccountRepository();
                Domain.Socioboard.Domain.YoutubeAccount ObjYoutubeAccount = ObjYoutubeAccountRepository.getYoutubeAccountDetailsById(youtubeId, userId);
                AddYouTubeChannels(userId.ToString(), ObjYoutubeAccount.Accesstoken, youtubeId);
                return "Youtube Channel is added";
            }
            catch (Exception ex)
            {

                throw;
            }
        }
Ejemplo n.º 24
0
 public void AuthenticateGooglePlus(object sender, EventArgs e)
 {
     oAuthToken objToken = new oAuthToken();
     Response.Redirect(objToken.GetAutherizationLink("https://www.googleapis.com/auth/userinfo.email+https://www.googleapis.com/auth/userinfo.profile+https://www.googleapis.com/auth/plus.me+https://www.googleapis.com/auth/plus.login"));
 }
Ejemplo n.º 25
0
        public string SheduleYoutubeMessage(string YoutubeId, string UserId, string sscheduledmsgguid)
        {
            string str = string.Empty;
            try
            {
                objScheduledMessage = objScheduledMessageRepository.GetScheduledMessageDetails(Guid.Parse(sscheduledmsgguid));
                Domain.Socioboard.Domain.YoutubeAccount ObjYoutubeAccount = objYoutubeAccountRepository.getYoutubeAccountDetailsById(YoutubeId, Guid.Parse(UserId));
                oAuthToken OAuthToken = new oAuthToken();
                OAuthToken.ConsumerKey = ConfigurationManager.AppSettings["YtconsumerKey"];
                OAuthToken.ConsumerSecret = ConfigurationManager.AppSettings["YtconsumerSecret"];

            }
            catch (Exception ex)
            {

                throw;
            }
            return str;
        }
Ejemplo n.º 26
0
 public Accounts()
 {
     objToken = new oAuthToken();
 }