public string GetData(object UserId,string youtubeId ) { string ret = string.Empty; try { Guid userId = (Guid)UserId; YoutubeAccount ObjYoutubeAccount = new YoutubeAccount(); Api.YoutubeAccount.YoutubeAccount ApiObjYoutubeAccount = new Api.YoutubeAccount.YoutubeAccount(); List<Domain.Myfashion.Domain.YoutubeAccount> LstYoutubeAccount = (List<Domain.Myfashion.Domain.YoutubeAccount>)(new JavaScriptSerializer().Deserialize(ApiObjYoutubeAccount.GetAllYoutubeAccountDetailsById(userId.ToString()), typeof(List<Domain.Myfashion.Domain.YoutubeAccount>))); List<YoutubeAccount> lstYoutubeAccount = new List<YoutubeAccount>(); foreach (YoutubeAccount Lstitem in LstYoutubeAccount) { try { Api.Youtube.Youtube ApiObjYoutube = new Api.Youtube.Youtube(); ret = ApiObjYoutube.getYoutubeData(Lstitem.UserId.ToString(), Lstitem.Ytuserid); } catch (Exception ex) { Console.WriteLine(ex.Message); } } } catch (Exception ex) { Console.WriteLine(ex.Message); } return ret; }
public string UpdateYouTubeAccountByAdmin(string ObjYouTube) { Domain.Myfashion.Domain.YoutubeAccount ObjYouTubeAccount = (Domain.Myfashion.Domain.YoutubeAccount)(new JavaScriptSerializer().Deserialize(ObjYouTube, typeof(Domain.Myfashion.Domain.YoutubeAccount))); try { objYoutubeAccountRepository.updateYoutubeUser(ObjYouTubeAccount); return(new JavaScriptSerializer().Serialize("Update Successfully")); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return(new JavaScriptSerializer().Serialize("Something went Wrong")); } }
public string SheduleYoutubeMessage(string YoutubeId, string UserId, string sscheduledmsgguid) { string str = string.Empty; try { objScheduledMessage = objScheduledMessageRepository.GetScheduledMessageDetails(Guid.Parse(sscheduledmsgguid)); Domain.Myfashion.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); }
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.Myfashion.Domain.YoutubeAccount ObjYoutubeAccount = ObjYoutubeAccountRepository.getYoutubeAccountDetailsById(youtubeId, userId); AddYouTubeChannels(userId.ToString(), ObjYoutubeAccount.Accesstoken, youtubeId); return("Youtube Channel is added"); } catch (Exception ex) { throw; } }
public string GetYoutubeChannelVideos(string userid, string profileid) { string ret = string.Empty; string strfinaltoken = string.Empty; string channelDetails = string.Empty; Domain.Myfashion.Domain.YoutubeAccount objYoutubeAccount = objYoutubeAccountRepository.getYoutubeAccountDetailsById(profileid, Guid.Parse(userid)); Domain.Myfashion.Domain.YoutubeChannel objYoutubeChannel = objYoutubeChannelRepository.getYoutubeChannelDetailsById(profileid, Guid.Parse(userid)); oAuthTokenYoutube objoAuthTokenYoutube = new oAuthTokenYoutube(); string finaltoken = objoAuthTokenYoutube.GetAccessToken(objYoutubeAccount.Refreshtoken); JObject objArray = JObject.Parse(finaltoken); //foreach (var item in objArray) //{ try { strfinaltoken = objArray["access_token"].ToString(); // break; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } //} PlaylistItems objPlaylistItems = new PlaylistItems(); try { channelDetails = objPlaylistItems.Get_PlaylistItems_List(strfinaltoken, GlobusGooglePlusLib.Authentication.oAuthTokenYoutube.Parts.snippet.ToString(), objYoutubeChannel.Uploadsid); } catch (Exception ex) { } return(channelDetails); }
public string AddYoutubeAccountwithLogin(string client_id, string client_secret, string redirect_uri, string UserId, string GroupId, string access_token) { #region Local variables Inisitalisation string ret = string.Empty; string objRefresh = string.Empty; string refreshToken = string.Empty; oAuthTokenYoutube ObjoAuthTokenYoutube = new oAuthTokenYoutube(); oAuthToken objToken = new oAuthToken(); Domain.Myfashion.Domain.YoutubeAccount objYoutubeAccount = new Domain.Myfashion.Domain.YoutubeAccount(); Domain.Myfashion.Domain.YoutubeChannel objYoutubeChannel; YoutubeChannelRepository objYoutubeChannelRepository = new YoutubeChannelRepository(); YoutubeAccountRepository objYoutubeAccountRepository = new YoutubeAccountRepository(); #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.Myfashion.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.Myfashion.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId)); Domain.Myfashion.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Myfashion.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.Myfashion.Domain.SocialProfile objSocialProfile = new Domain.Myfashion.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); }
public string AddYoutubeAccountwithLogin(string client_id, string client_secret, string redirect_uri, string UserId, string GroupId, string access_token) { #region Local variables Inisitalisation string ret = string.Empty; string objRefresh = string.Empty; string refreshToken = string.Empty; oAuthTokenYoutube ObjoAuthTokenYoutube = new oAuthTokenYoutube(); oAuthToken objToken = new oAuthToken(); Domain.Myfashion.Domain.YoutubeAccount objYoutubeAccount = new Domain.Myfashion.Domain.YoutubeAccount(); Domain.Myfashion.Domain.YoutubeChannel objYoutubeChannel; YoutubeChannelRepository objYoutubeChannelRepository = new YoutubeChannelRepository(); YoutubeAccountRepository objYoutubeAccountRepository = new YoutubeAccountRepository(); #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.Myfashion.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.Myfashion.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId)); Domain.Myfashion.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Myfashion.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.Myfashion.Domain.SocialProfile objSocialProfile = new Domain.Myfashion.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; }
public Domain.Myfashion.Domain.YoutubeAccount getYoutubeAccountDetailsById(string youtubeId,Guid userid) { Domain.Myfashion.Domain.YoutubeAccount result = new Domain.Myfashion.Domain.YoutubeAccount(); //Creates a database connection and opens up a session using (NHibernate.ISession session = SessionFactory.GetNewSession()) { //After Session creation, start Transaction. using (NHibernate.ITransaction transaction = session.BeginTransaction()) { // proceed action, to get all Facebook Account of User by UserId(Guid) and FbUserId(string). List<Domain.Myfashion.Domain.YoutubeAccount> objlstfb = session.CreateQuery("from YoutubeAccount where YtUserId = :Fbuserid and UserId=:userid") .SetParameter("Fbuserid", youtubeId) .SetParameter("userid", userid) .List<Domain.Myfashion.Domain.YoutubeAccount>().ToList<Domain.Myfashion.Domain.YoutubeAccount>(); if (objlstfb.Count > 0) { result = objlstfb[0]; } return result; }//End Transaction }//End session }