/// <checkUserProfileExist> /// Check User Profile Exist /// </summary> /// <param name="socio">Set Values in a SocialProfile Class Property and Pass the Object of SocialProfile Class.(Domein.SocialProfile)</param> /// <returns>True or False.(bool)</returns> public bool checkUserProfileExist(Domain.Myfashion.Domain.SocialProfile socio) { //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()) { try { //Proceed action, to check Data. List <Domain.Myfashion.Domain.SocialProfile> alst = session.CreateQuery("from SocialProfile where UserId = :userid and ProfileId = :profileid and ProfileType = :profiletype") .SetParameter("userid", socio.UserId) .SetParameter("profileid", socio.ProfileId) .SetParameter("profiletype", socio.ProfileType) .List <Domain.Myfashion.Domain.SocialProfile>() .ToList <Domain.Myfashion.Domain.SocialProfile>(); if (alst == null || alst.Count == 0) { return(false); } else { return(true); } } catch (Exception ex) { Console.Write(ex.StackTrace); return(true); } } //End Transaction } //End Session }
public int updateSocialProfileStatus(Domain.Myfashion.Domain.SocialProfile socio) { //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()) { try { //Proceed action, to update existing data from new profile value. NHibernate.IQuery query = session.CreateQuery("Update SocialProfile set ProfileStatus=:profilestaus where UserId = :userid and ProfileId = :profileid") .SetParameter("profilestaus", socio.ProfileStatus) .SetParameter("userid", socio.UserId) .SetParameter("profileid", socio.ProfileId); int isUpdated = query.ExecuteUpdate(); transaction.Commit(); return(isUpdated); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return(0); } } //End Transaction } //End Session }
/// <addNewProfileForUser> /// Add New Profile For User /// </summary> /// <param name="socio">Set Values in a SocialProfile Class Property and Pass the Object of SocialProfile Class.(Domein.SocialProfile)</param> public void addNewProfileForUser(Domain.Myfashion.Domain.SocialProfile socio) { //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 Save data. session.Save(socio); transaction.Commit(); } //End Transaction } //End Session }
public string GetAllSocialProfiles() { try { Domain.Myfashion.Domain.SocialProfile objSocialProfile = new Domain.Myfashion.Domain.SocialProfile(); List <Domain.Myfashion.Domain.SocialProfile> lstSocialProfile = new List <Domain.Myfashion.Domain.SocialProfile>(); lstSocialProfile = objSocialProfilesRepository.getAllSocialProfiles(); //FacebookAccountRepository facebookAccountRepo = new FacebookAccountRepository(); //FacebookAccount facebook = facebookAccountRepo.getFacebookAccountDetailsById(FacebookId, userid); return(new JavaScriptSerializer().Serialize(lstSocialProfile)); //return lstScheduledMessages; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return(new JavaScriptSerializer().Serialize("Please try Again")); } }
public Domain.Myfashion.Domain.SocialProfile GetSocialProfileByProfileId(string SocialProfile) { using (NHibernate.ISession session = SessionFactory.GetNewSession()) { using (NHibernate.ITransaction transaction = session.BeginTransaction()) { try { NHibernate.IQuery query = session.CreateQuery("from SocialProfile where ProfileId = : ProfileId"); query.SetParameter("ProfileId", SocialProfile); Domain.Myfashion.Domain.SocialProfile result = (Domain.Myfashion.Domain.SocialProfile)query.UniqueResult(); return(result); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return(null); } } } }
public string AddInstagramAccount(string client_id, string client_secret, string redirect_uri, string UserId, string GroupId, string code) { string ret = string.Empty; oAuthInstagram objInsta = new oAuthInstagram(); GlobusInstagramLib.Authentication.ConfigurationIns configi = new GlobusInstagramLib.Authentication.ConfigurationIns("https://api.instagram.com/oauth/authorize/", client_id, client_secret, redirect_uri, "http://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", ""); oAuthInstagram _api = new oAuthInstagram(); _api = oAuthInstagram.GetInstance(configi); AccessToken access = new AccessToken(); access = _api.AuthGetAccessToken(code); #region InstagramAccount UserController objusercontroller = new UserController(); InstagramResponse <GlobusInstagramLib.App.Core.User> objuser = objusercontroller.GetUserDetails(access.user.id, access.access_token); objInstagramAccount = new Domain.Myfashion.Domain.InstagramAccount(); objInstagramAccount.AccessToken = access.access_token; objInstagramAccount.InstagramId = access.user.id; try { objInstagramAccount.ProfileUrl = access.user.profile_picture; } catch (Exception ex) { logger.Error("Instagram.asmx.cs >> AddInstagramAccount >> " + ex.StackTrace); } try { objInstagramAccount.InsUserName = access.user.username; } catch (Exception ex) { logger.Error("Instagram.asmx.cs >> AddInstagramAccount >> " + ex.StackTrace); } try { objInstagramAccount.TotalImages = objuser.data.counts.media; } catch (Exception ex) { logger.Error("Instagram.asmx.cs >> AddInstagramAccount >> " + ex.StackTrace); } try { objInstagramAccount.FollowedBy = objuser.data.counts.followed_by; } catch (Exception ex) { logger.Error("Instagram.asmx.cs >> AddInstagramAccount >> " + ex.StackTrace); } try { objInstagramAccount.Followers = objuser.data.counts.follows; } catch (Exception ex) { logger.Error("Instagram.asmx.cs >> AddInstagramAccount >> " + ex.StackTrace); } objInstagramAccount.UserId = Guid.Parse(UserId); #endregion if (!objInstagramAccountRepository.checkInstagramUserExists(objInstagramAccount.InstagramId, Guid.Parse(UserId))) { objInstagramAccountRepository.addInstagramUser(objInstagramAccount); #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 = "instagram"; objTeamMemberProfile.StatusUpdateDate = DateTime.Now; objTeamMemberProfile.ProfileId = objInstagramAccount.InstagramId; //Modified [13-02-15] objTeamMemberProfile.ProfilePicUrl = objInstagramAccount.ProfileUrl; objTeamMemberProfile.ProfileName = objInstagramAccount.InsUserName; objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile); #endregion #region SocialProfile Domain.Myfashion.Domain.SocialProfile objSocialProfile = new Domain.Myfashion.Domain.SocialProfile(); objSocialProfile.Id = Guid.NewGuid(); objSocialProfile.ProfileType = "instagram"; objSocialProfile.ProfileId = objInstagramAccount.InstagramId; objSocialProfile.UserId = Guid.Parse(UserId); objSocialProfile.ProfileDate = DateTime.Now; objSocialProfile.ProfileStatus = 1; #endregion #region Add SocialProfile if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile)) { objSocialProfilesRepository.addNewProfileForUser(objSocialProfile); } #endregion ret = "Account Added Successfully"; } else { ret = "Account already Exist !"; } //GetIntagramImages(objInstagramAccount); GetInstagramFeeds(objInstagramAccount); return(ret); }
public void GetPageProfile(dynamic data, oAuthLinkedIn _OAuth, string UserId, string CompanyPageId, string GroupId) { Domain.Myfashion.Domain.SocialProfile socioprofile = new Domain.Myfashion.Domain.SocialProfile(); SocialProfilesRepository socioprofilerepo = new SocialProfilesRepository(); Domain.Myfashion.Domain.LinkedinCompanyPage objLinkedincmpnypage = new Domain.Myfashion.Domain.LinkedinCompanyPage(); LinkedinCompanyPageRepository objLinkedCmpnyPgeRepo = new LinkedinCompanyPageRepository(); try { objLinkedincmpnypage.UserId = Guid.Parse(UserId); try { objLinkedincmpnypage.LinkedinPageId = data.Pageid.ToString(); } catch { } objLinkedincmpnypage.Id = Guid.NewGuid(); try { objLinkedincmpnypage.EmailDomains = data.EmailDomains.ToString(); } catch { } objLinkedincmpnypage.LinkedinPageName = data.name.ToString(); objLinkedincmpnypage.OAuthToken = _OAuth.Token; objLinkedincmpnypage.OAuthSecret = _OAuth.TokenSecret; objLinkedincmpnypage.OAuthVerifier = _OAuth.Verifier; try { objLinkedincmpnypage.Description = data.description.ToString(); } catch { } try { objLinkedincmpnypage.FoundedYear = data.founded_year.ToString(); } catch { } try { objLinkedincmpnypage.EndYear = data.end_year.ToString(); } catch { } try { objLinkedincmpnypage.Locations = data.locations.ToString(); } catch { } try { objLinkedincmpnypage.Specialties = data.Specialties.ToString(); } catch { } try { objLinkedincmpnypage.WebsiteUrl = data.website_url.ToString(); } catch { } try { objLinkedincmpnypage.Status = data.status.ToString(); } catch { } try { objLinkedincmpnypage.EmployeeCountRange = data.employee_count_range.ToString(); } catch { } try { objLinkedincmpnypage.Industries = data.industries.ToString(); } catch { } try { string NuberOfFollower = data.num_followers.ToString(); objLinkedincmpnypage.NumFollowers = Convert.ToInt16(NuberOfFollower); } catch { } try { objLinkedincmpnypage.CompanyType = data.company_type.ToString(); } catch { } try { objLinkedincmpnypage.LogoUrl = data.logo_url.ToString(); } catch { } try { objLinkedincmpnypage.SquareLogoUrl = data.square_logo_url.ToString(); } catch { } try { objLinkedincmpnypage.BlogRssUrl = data.blog_rss_url.ToString(); } catch { } try { objLinkedincmpnypage.UniversalName = data.universal_name.ToString(); } catch { } #region SocialProfiles socioprofile.UserId = Guid.Parse(UserId); socioprofile.ProfileType = "linkedincompanypage"; socioprofile.ProfileId = data.Pageid.ToString();; socioprofile.ProfileStatus = 1; socioprofile.ProfileDate = DateTime.Now; socioprofile.Id = Guid.NewGuid(); #endregion #region TeamMemberProfile Domain.Myfashion.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId)); objTeamMemberProfile = new Domain.Myfashion.Domain.TeamMemberProfile(); objTeamMemberProfile.Id = Guid.NewGuid(); objTeamMemberProfile.TeamId = objTeam.Id; objTeamMemberProfile.Status = 1; objTeamMemberProfile.ProfileType = "linkedincompanypage"; objTeamMemberProfile.StatusUpdateDate = DateTime.Now; objTeamMemberProfile.ProfileId = socioprofile.ProfileId; #endregion } catch { } try { if (!objSocialProfilesRepository.checkUserProfileExist(socioprofile)) { objSocialProfilesRepository.addNewProfileForUser(socioprofile); } if (!objTeamMemberProfileRepository.checkTeamMemberProfile(objTeamMemberProfile.TeamId, objLinkedincmpnypage.LinkedinPageId)) { objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile); } if (!objLinkedCmpnyPgeRepo.checkLinkedinPageExists(CompanyPageId, Guid.Parse(UserId))) { objLinkedCmpnyPgeRepo.addLinkenCompanyPage(objLinkedincmpnypage); } else { objLinkedincmpnypage.LinkedinPageId = CompanyPageId; objLinkedCmpnyPgeRepo.updateLinkedinPage(objLinkedincmpnypage); } } catch { } }
public string AddLinkedinAccount(string oauth_token, string oauth_verifier, string reuqestTokenSecret, string consumerKey, string consumerSecret, string UserId, string GroupId) { try { logger.Error("AddLinkedinAccount()"); System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls; string ret = string.Empty; LinkedInProfile objProfile = new LinkedInProfile(); LinkedInProfile.UserProfile objUserProfile = new LinkedInProfile.UserProfile(); objSocialProfile = new Domain.Myfashion.Domain.SocialProfile(); oAuthLinkedIn _oauth = new oAuthLinkedIn(); objLinkedInAccount = new LinkedInAccount(); #region Get linkedin Profile data from Api try { _oauth.ConsumerKey = consumerKey; } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } try { _oauth.ConsumerSecret = consumerSecret; } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } try { _oauth.Token = oauth_token; } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } try { _oauth.TokenSecret = reuqestTokenSecret; } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } try { _oauth.Verifier = oauth_verifier; } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } try { _oauth.AccessTokenGet(oauth_token); } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } try { objUserProfile = objProfile.GetUserProfile(_oauth); } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } #endregion dynamic data = objUserProfile; try { #region LinkedInAccount objLinkedInAccount.UserId = Guid.Parse(UserId); objLinkedInAccount.LinkedinUserId = data.id.ToString(); try { objLinkedInAccount.EmailId = data.email.ToString(); } catch (Exception ex) { logger.Error(ex.StackTrace); } objLinkedInAccount.LinkedinUserName = data.first_name.ToString() + data.last_name.ToString(); objLinkedInAccount.OAuthToken = _oauth.Token; objLinkedInAccount.OAuthSecret = _oauth.TokenSecret; objLinkedInAccount.OAuthVerifier = _oauth.Verifier; try { objLinkedInAccount.ProfileImageUrl = data.picture_url.ToString(); } catch (Exception ex) { logger.Error(ex.StackTrace); } try { objLinkedInAccount.ProfileUrl = data.profile_url.ToString(); } catch (Exception ex) { logger.Error(ex.StackTrace); } #endregion #region SocialProfiles try { objLinkedInAccount.Connections = data.connections; objLinkedInAccount.IsActive = true; objSocialProfile.UserId = Guid.Parse(UserId); objSocialProfile.ProfileType = "linkedin"; objSocialProfile.ProfileId = data.id.ToString(); objSocialProfile.ProfileStatus = 1; objSocialProfile.ProfileDate = DateTime.Now; objSocialProfile.Id = Guid.NewGuid(); } catch (Exception ex) { logger.Error(ex.Message); } #endregion SocialProfiles #region Add TeamMemberProfile try { Domain.Myfashion.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId)); objTeamMemberProfile = new Domain.Myfashion.Domain.TeamMemberProfile(); objTeamMemberProfile.Id = Guid.NewGuid(); objTeamMemberProfile.TeamId = objTeam.Id; objTeamMemberProfile.Status = 1; objTeamMemberProfile.ProfileType = "linkedin"; objTeamMemberProfile.StatusUpdateDate = DateTime.Now; objTeamMemberProfile.ProfileId = objLinkedInAccount.LinkedinUserId; objTeamMemberProfile.ProfileName = objLinkedInAccount.LinkedinUserName; objTeamMemberProfile.ProfilePicUrl = objLinkedInAccount.ProfileImageUrl; } catch (Exception ex) { logger.Error(ex.Message); } #endregion } catch (Exception ex) { logger.Error(ex.StackTrace); } try { if (!objLinkedInAccountRepository.checkLinkedinUserExists(objLinkedInAccount.LinkedinUserId, Guid.Parse(UserId))) { objLinkedInAccountRepository.addLinkedinUser(objLinkedInAccount); ret = "LinkedIn Account Added Successfully"; } else { ret = "LinkedIn Account Already Exist"; } if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile)) { objSocialProfilesRepository.addNewProfileForUser(objSocialProfile); } if (!objTeamMemberProfileRepository.checkTeamMemberProfile(objTeamMemberProfile.TeamId, objLinkedInAccount.LinkedinUserId)) { objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile); } #region Add LinkedIn Feeds LinkedInNetwork objln = new LinkedInNetwork(); List <LinkedInNetwork.Network_Updates> userUPdate = objln.GetNetworkUpdates(_oauth, 20); foreach (var item in userUPdate) { try { objLinkedInFeed = new Domain.Myfashion.Domain.LinkedInFeed(); objLinkedInFeed.Feeds = item.Message; objLinkedInFeed.FromId = item.PersonId; objLinkedInFeed.FromName = item.PersonFirstName + " " + item.PersonLastName; objLinkedInFeed.FeedsDate = Convert.ToDateTime(item.DateTime); objLinkedInFeed.EntryDate = DateTime.Now; objLinkedInFeed.ProfileId = objLinkedInAccount.LinkedinUserId; objLinkedInFeed.Type = item.UpdateType; objLinkedInFeed.UserId = Guid.Parse(UserId); objLinkedInFeed.FromPicUrl = item.PictureUrl; objLinkedInFeed.ImageUrl = item.ImageUrl; objLinkedInFeed.FromUrl = item.url; } catch (Exception ex) { logger.Error(ex.StackTrace); } if (!objLinkedInFeedRepository.checkLinkedInFeedExists(objLinkedInFeed.FeedId, Guid.Parse(UserId))) { objLinkedInFeedRepository.addLinkedInFeed(objLinkedInFeed); } } #endregion #region Add LinkedIn UserUpdates GlobusLinkedinLib.App.Core.LinkedInUser l = new GlobusLinkedinLib.App.Core.LinkedInUser(); List <Domain.Myfashion.Domain.LinkedIn_Update_Messages> lst_Messages = l.GetUserUpdateNew(_oauth, objLinkedInAccount.LinkedinUserId, 10); foreach (var item_Messages in lst_Messages) { try { objLinkedInMessage = new Domain.Myfashion.Domain.LinkedInMessage(); objLinkedInMessage.Id = Guid.NewGuid(); objLinkedInMessage.Message = item_Messages.Message; objLinkedInMessage.ProfileId = item_Messages.ProfileId; objLinkedInMessage.ProfileName = item_Messages.ProfileName; objLinkedInMessage.CreatedDate = Convert.ToDateTime(item_Messages.CreatedDate); objLinkedInMessage.EntryDate = DateTime.Now; objLinkedInMessage.Type = item_Messages.Type; objLinkedInMessage.UserId = Guid.Parse(UserId); objLinkedInMessage.ImageUrl = item_Messages.ImageUrl; objLinkedInMessage.FeedId = item_Messages.FeedId; objLinkedInMessage.ProfileUrl = item_Messages.ProfileUrl; objLinkedInMessage.Comments = item_Messages.Comments; objLinkedInMessage.Likes = item_Messages.Likes; objLinkedInMessage.ProfileImageUrl = item_Messages.ProfileImageUrl; } catch (Exception ex) { logger.Error(ex.StackTrace); } if (!objLinkedInMessageRepository.checkLinkedInMessageExists(objLinkedInAccount.LinkedinUserId, objLinkedInMessage.FeedId, Guid.Parse(UserId))) { objLinkedInMessageRepository.addLinkedInMessage(objLinkedInMessage); } } #endregion } catch (Exception ex) { logger.Error(ex.StackTrace); } return(""); } catch (Exception ex) { logger.Error(ex.StackTrace); return(""); } }
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 AddTumblrAccount(string client_id, string client_secret, string redirect_uri, string UserId, string GroupId, string code) { string ret = string.Empty; string AccessTokenResponse = string.Empty; try { oAuthTumbler requestHelper = new oAuthTumbler(); oAuthTumbler.TumblrConsumerKey = client_id; oAuthTumbler.TumblrConsumerSecret = client_secret; requestHelper.TumblrCallBackUrl = redirect_uri; AccessTokenResponse = requestHelper.GetAccessToken(oAuthTumbler.TumblrToken, code); logger.Error(AccessTokenResponse); string[] tokens = AccessTokenResponse.Split('&'); //extract access token & secret from response logger.Error(tokens); string accessToken = tokens[0].Split('=')[1]; logger.Error(accessToken); string accessTokenSecret = tokens[1].Split('=')[1]; logger.Error(accessTokenSecret); KeyValuePair<string, string> LoginDetails = new KeyValuePair<string, string>(accessToken, accessTokenSecret); JObject profile = new JObject(); try { profile = JObject.Parse(oAuthTumbler.OAuthData(Globals.UsersInfoUrl, "GET", LoginDetails.Key, LoginDetails.Value, null)); } catch (Exception ex) { } #region Add Tumblr Account objTumblrAccount = new Domain.Myfashion.Domain.TumblrAccount(); objTumblrAccount.Id = Guid.NewGuid(); objTumblrAccount.tblrUserName = profile["response"]["user"]["name"].ToString(); objTumblrAccount.UserId = Guid.Parse(UserId); objTumblrAccount.tblrAccessToken = accessToken; objTumblrAccount.tblrAccessTokenSecret = accessTokenSecret; objTumblrAccount.tblrProfilePicUrl = "http://api.tumblr.com/v2/blog/" + objTumblrAccount.tblrUserName + ".tumblr.com/avatar";//profile["response"]["user"]["name"].ToString(); objTumblrAccount.IsActive = 1; if (!objTumblrAccountRepository.checkTubmlrUserExists(objTumblrAccount)) { TumblrAccountRepository.Add(objTumblrAccount); #region Add Socialprofiles objSocialProfile = new Domain.Myfashion.Domain.SocialProfile(); objSocialProfile.Id = Guid.NewGuid(); objSocialProfile.UserId = Guid.Parse(UserId); objSocialProfile.ProfileId = profile["response"]["user"]["name"].ToString(); objSocialProfile.ProfileType = "tumblr"; objSocialProfile.ProfileDate = DateTime.Now; objSocialProfile.ProfileStatus = 1; if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile)) { objSocialProfilesRepository.addNewProfileForUser(objSocialProfile); } #endregion #region Add TeamMemeberProfile 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 = "tumblr"; objTeamMemberProfile.StatusUpdateDate = DateTime.Now; objTeamMemberProfile.ProfileId = objTumblrAccount.tblrUserName; //Modified [13-02-15] objTeamMemberProfile.ProfilePicUrl = objTumblrAccount.tblrProfilePicUrl; objTeamMemberProfile.ProfileName = objTumblrAccount.tblrUserName; objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile); #endregion } #endregion //if (!objTeamMemberProfileRepository.checkTeamMemberProfile(objTeam.Id, objTumblrAccount.tblrUserName)) //{ // objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile); //} #region Add Tumblr Feeds AddTunblrFeeds(UserId, LoginDetails, profile["response"]["user"]["name"].ToString()); #endregion } catch (Exception ex) { logger.Error("AddTumblrAccount => "+ex.StackTrace); } return ret; }
public string AddTwitterAccount(string client_id, string client_secret, string redirect_uri, string UserId, string GroupId, string requestToken, string requestSecret, string requestVerifier) { try { System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls; string ret = string.Empty; GlobusTwitterLib.Twitter.Core.UserMethods.Users userinfo = new GlobusTwitterLib.Twitter.Core.UserMethods.Users(); oAuthTwitter OAuth = new oAuthTwitter(client_id, client_secret, redirect_uri); OAuth.AccessToken = requestToken; OAuth.AccessTokenSecret = requestVerifier; OAuth.AccessTokenGet(requestToken, requestVerifier); JArray profile = userinfo.Get_Users_LookUp_ByScreenName(OAuth, OAuth.TwitterScreenName); if (profile != null) { logger.Error("Twitter.asmx >> AddTwitterAccount >> Twitter profile : " + profile); } else { logger.Error("Twitter.asmx >> AddTwitterAccount >> NULL Twitter profile : " + profile); } objTwitterAccount = new Domain.Myfashion.Domain.TwitterAccount(); TwitterUser twtuser; foreach (var item in profile) { #region Add Twitter Account try { objTwitterAccount.FollowingCount = Convert.ToInt32(item["friends_count"].ToString()); } catch (Exception ex) { logger.Error(ex.StackTrace); } try { objTwitterAccount.FollowersCount = Convert.ToInt32(item["followers_count"].ToString()); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } objTwitterAccount.Id = Guid.NewGuid(); objTwitterAccount.IsActive = true; objTwitterAccount.OAuthSecret = OAuth.AccessTokenSecret; objTwitterAccount.OAuthToken = OAuth.AccessToken; try { objTwitterAccount.ProfileImageUrl = item["profile_image_url"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterAccount.ProfileUrl = string.Empty; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterAccount.TwitterUserId = item["id_str"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception er) { try { objTwitterAccount.TwitterUserId = item["id"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { logger.Error(ex.StackTrace); } Console.WriteLine(er.StackTrace); } try { objTwitterAccount.TwitterScreenName = item["screen_name"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { logger.Error(ex.StackTrace); } objTwitterAccount.UserId = Guid.Parse(UserId); #endregion if (!objTwitterAccountRepository.checkTwitterUserExists(objTwitterAccount.TwitterUserId, Guid.Parse(UserId))) { objTwitterAccountRepository.addTwitterkUser(objTwitterAccount); #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 = "twitter"; objTeamMemberProfile.StatusUpdateDate = DateTime.Now; objTeamMemberProfile.ProfileId = objTwitterAccount.TwitterUserId; objTeamMemberProfile.ProfileName = objTwitterAccount.TwitterScreenName; objTeamMemberProfile.ProfilePicUrl = objTwitterAccount.ProfileImageUrl; objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile); #endregion #region SocialProfile Domain.Myfashion.Domain.SocialProfile objSocialProfile = new Domain.Myfashion.Domain.SocialProfile(); objSocialProfile.Id = Guid.NewGuid(); objSocialProfile.ProfileType = "twitter"; objSocialProfile.ProfileId = objTwitterAccount.TwitterUserId; objSocialProfile.UserId = Guid.Parse(UserId); objSocialProfile.ProfileDate = DateTime.Now; objSocialProfile.ProfileStatus = 1; #endregion #region Add Twitter Stats if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile)) { objSocialProfilesRepository.addNewProfileForUser(objSocialProfile); } objTwitterStats = new Domain.Myfashion.Domain.TwitterStats(); Random rNum = new Random(); objTwitterStats.Id = Guid.NewGuid(); objTwitterStats.TwitterId = objTwitterAccount.TwitterUserId; objTwitterStats.UserId = Guid.Parse(UserId); objTwitterStats.FollowingCount = objTwitterAccount.FollowingCount; objTwitterStats.FollowerCount = objTwitterAccount.FollowersCount; objTwitterStats.Age1820 = rNum.Next(objTwitterAccount.FollowersCount); objTwitterStats.Age2124 = rNum.Next(objTwitterAccount.FollowersCount); objTwitterStats.Age2534 = rNum.Next(objTwitterAccount.FollowersCount); objTwitterStats.Age3544 = rNum.Next(objTwitterAccount.FollowersCount); objTwitterStats.Age4554 = rNum.Next(objTwitterAccount.FollowersCount); objTwitterStats.Age5564 = rNum.Next(objTwitterAccount.FollowersCount); objTwitterStats.Age65 = rNum.Next(objTwitterAccount.FollowersCount); objTwitterStats.EntryDate = DateTime.Now; if (!objTwtstats.checkTwitterStatsExists(objTwitterAccount.TwitterUserId, Guid.Parse(UserId))) { objTwtstats.addTwitterStats(objTwitterStats); } #endregion #region AddTwitterFollowerCount Domain.Myfashion.Domain.TwitterAccountFollowers objTwitterAccountFollowers = new Domain.Myfashion.Domain.TwitterAccountFollowers(); TwitterAccountFollowersRepository objTwitterAccountFollowersRepository = new TwitterAccountFollowersRepository(); objTwitterAccountFollowers.Id = Guid.NewGuid(); objTwitterAccountFollowers.UserId = Guid.Parse(UserId); objTwitterAccountFollowers.EntryDate = DateTime.Now; objTwitterAccountFollowers.FollowingsCount = Convert.ToInt32(item["friends_count"].ToString()); objTwitterAccountFollowers.FollowersCount = Convert.ToInt32(item["followers_count"].ToString()); try { objTwitterAccountFollowers.ProfileId = item["id_str"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception er) { try { objTwitterAccountFollowers.ProfileId = item["id"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { logger.Error(ex.StackTrace); } Console.WriteLine(er.StackTrace); } objTwitterAccountFollowersRepository.addTwitterAccountFollower(objTwitterAccountFollowers); #endregion ret = "Account Added Successfully"; } else { ret = "Account already Exist !"; } } getTwitterMessages(UserId, OAuth); getUserRetweets(UserId, OAuth); //edited by avinash[24-03-15] getTwitterEngagement(UserId, OAuth); getUserTweets(UserId, OAuth); getTwitterFeeds(UserId, OAuth); getTwitterDirectMessageSent(UserId, OAuth); getTwittwrDirectMessageRecieved(OAuth,UserId); getUserMentions(OAuth, objTwitterAccount.TwitterUserId, Guid.Parse(UserId)); getUserFollowers(OAuth, objTwitterAccount.TwitterScreenName, objTwitterAccount.TwitterUserId, Guid.Parse(UserId)); getUserRetweet(OAuth, objTwitterAccount.TwitterUserId, Guid.Parse(UserId)); //return ret; return new JavaScriptSerializer().Serialize(objTwitterAccount); } catch (Exception ex) { logger.Error(ex.StackTrace); return ""; } }
public string AddFacebookPagesInfo(string userid, string profileId, string accessToken, string groupId, string email) { string ret = string.Empty; try { FacebookClient fb = new FacebookClient(); fb.AccessToken = accessToken; int fancountPage = 0; try { System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls; //dynamic fancount = fb.Get("fql", new { q = " SELECT fan_count FROM page WHERE page_id =" + profileId }); //foreach (var friend in fancount.data) //{ // fancountPage = Convert.ToInt32(friend.fan_count); //} // dynamic friends = fb.Get("v2.0/me/friends"); dynamic friends = fb.Get("v2.0/" + profileId); //fancountPage = Convert.ToInt16(friends["summary"]["total_count"].ToString()); fancountPage = Convert.ToInt16(friends["likes"].ToString()); } catch (Exception) { fancountPage = 0; } if (accessToken != null) { System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls; dynamic profile = fb.Get("v2.0/me"); #region Add FacebookAccount objFacebookAccount = new Domain.Myfashion.Domain.FacebookAccount(); objFacebookAccount.Id = Guid.NewGuid(); objFacebookAccount.FbUserId = (Convert.ToString(profile["id"])); objFacebookAccount.FbUserName = (Convert.ToString(profile["name"])); objFacebookAccount.AccessToken = accessToken; objFacebookAccount.Friends = Convert.ToInt32(fancountPage); objFacebookAccount.EmailId = email; objFacebookAccount.Type = "Page"; objFacebookAccount.ProfileUrl = (Convert.ToString(profile["link"])); objFacebookAccount.IsActive = 1; objFacebookAccount.UserId = Guid.Parse(userid); if (!objFacebookAccountRepository.checkFacebookUserExists(objFacebookAccount.FbUserId, objFacebookAccount.UserId)) { objFacebookAccountRepository.addFacebookUser(objFacebookAccount); } #endregion #region SocialProfile Domain.Myfashion.Domain.SocialProfile objSocialProfile = new Domain.Myfashion.Domain.SocialProfile(); objSocialProfile.Id = Guid.NewGuid(); objSocialProfile.ProfileType = "facebook_page"; objSocialProfile.ProfileId = (Convert.ToString(profile["id"])); objSocialProfile.UserId = Guid.Parse(userid); objSocialProfile.ProfileDate = DateTime.Now; objSocialProfile.ProfileStatus = 1; if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile)) { objSocialProfilesRepository.addNewProfileForUser(objSocialProfile); } #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 = "facebook_page"; objTeamMemberProfile.StatusUpdateDate = DateTime.Now; objTeamMemberProfile.ProfileId = Convert.ToString(profile["id"]); objTeamMemberProfile.ProfileName = objFacebookAccount.FbUserName; objTeamMemberProfile.ProfilePicUrl = "http://graph.facebook.com/" + objTeamMemberProfile.ProfileId + "/picture?type=small"; if (!objTeamMemberProfileRepository.checkTeamMemberProfile(objTeamMemberProfile.TeamId, objTeamMemberProfile.ProfileId)) { objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile); } #endregion #region Add Facebook Feeds AddFacebookFeeds(userid, fb, profile); #endregion #region AddFacebook FanPge Domain.Myfashion.Domain.FacebookFanPage objFacebookFanPage = new Domain.Myfashion.Domain.FacebookFanPage(); FacebookFanPageRepository objFacebookFanPageRepository = new FacebookFanPageRepository(); objFacebookFanPage.Id = Guid.NewGuid(); objFacebookFanPage.UserId = Guid.Parse(userid); objFacebookFanPage.ProfilePageId = (Convert.ToString(profile["id"])); objFacebookFanPage.FanpageCount = fancountPage.ToString(); objFacebookFanPage.EntryDate = DateTime.Now; objFacebookFanPageRepository.addFacebookUser(objFacebookFanPage); #endregion AddFbPagePost(userid, accessToken, profileId); getPageConversations(userid, fb, profile); } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } return ret; }
public string AddTumblrAccount(string client_id, string client_secret, string redirect_uri, string UserId, string GroupId, string code) { string ret = string.Empty; string AccessTokenResponse = string.Empty; try { oAuthTumbler requestHelper = new oAuthTumbler(); oAuthTumbler.TumblrConsumerKey = client_id; oAuthTumbler.TumblrConsumerSecret = client_secret; requestHelper.TumblrCallBackUrl = redirect_uri; AccessTokenResponse = requestHelper.GetAccessToken(oAuthTumbler.TumblrToken, code); logger.Error(AccessTokenResponse); string[] tokens = AccessTokenResponse.Split('&'); //extract access token & secret from response logger.Error(tokens); string accessToken = tokens[0].Split('=')[1]; logger.Error(accessToken); string accessTokenSecret = tokens[1].Split('=')[1]; logger.Error(accessTokenSecret); KeyValuePair <string, string> LoginDetails = new KeyValuePair <string, string>(accessToken, accessTokenSecret); JObject profile = new JObject(); try { profile = JObject.Parse(oAuthTumbler.OAuthData(Globals.UsersInfoUrl, "GET", LoginDetails.Key, LoginDetails.Value, null)); } catch (Exception ex) { } #region Add Tumblr Account objTumblrAccount = new Domain.Myfashion.Domain.TumblrAccount(); objTumblrAccount.Id = Guid.NewGuid(); objTumblrAccount.tblrUserName = profile["response"]["user"]["name"].ToString(); objTumblrAccount.UserId = Guid.Parse(UserId); objTumblrAccount.tblrAccessToken = accessToken; objTumblrAccount.tblrAccessTokenSecret = accessTokenSecret; objTumblrAccount.tblrProfilePicUrl = "http://api.tumblr.com/v2/blog/" + objTumblrAccount.tblrUserName + ".tumblr.com/avatar";//profile["response"]["user"]["name"].ToString(); objTumblrAccount.IsActive = 1; if (!objTumblrAccountRepository.checkTubmlrUserExists(objTumblrAccount)) { TumblrAccountRepository.Add(objTumblrAccount); #region Add Socialprofiles objSocialProfile = new Domain.Myfashion.Domain.SocialProfile(); objSocialProfile.Id = Guid.NewGuid(); objSocialProfile.UserId = Guid.Parse(UserId); objSocialProfile.ProfileId = profile["response"]["user"]["name"].ToString(); objSocialProfile.ProfileType = "tumblr"; objSocialProfile.ProfileDate = DateTime.Now; objSocialProfile.ProfileStatus = 1; if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile)) { objSocialProfilesRepository.addNewProfileForUser(objSocialProfile); } #endregion #region Add TeamMemeberProfile 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 = "tumblr"; objTeamMemberProfile.StatusUpdateDate = DateTime.Now; objTeamMemberProfile.ProfileId = objTumblrAccount.tblrUserName; //Modified [13-02-15] objTeamMemberProfile.ProfilePicUrl = objTumblrAccount.tblrProfilePicUrl; objTeamMemberProfile.ProfileName = objTumblrAccount.tblrUserName; objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile); #endregion } #endregion //if (!objTeamMemberProfileRepository.checkTeamMemberProfile(objTeam.Id, objTumblrAccount.tblrUserName)) //{ // objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile); //} #region Add Tumblr Feeds AddTunblrFeeds(UserId, LoginDetails, profile["response"]["user"]["name"].ToString()); #endregion } catch (Exception ex) { logger.Error("AddTumblrAccount => " + ex.StackTrace); } return(ret); }
public string SheduleFacebookGroupMessage(string FacebookId, string UserId, string sscheduledmsgguid) { string str = string.Empty; try { objScheduledMessage = objScheduledMessageRepository.GetScheduledMessageDetails(Guid.Parse(sscheduledmsgguid)); GroupScheduleMessageRepository grpschedulemessagerepo = new GroupScheduleMessageRepository(); Domain.Myfashion.Domain.GroupScheduleMessage _GroupScheduleMessage = grpschedulemessagerepo.GetScheduleMessageId(objScheduledMessage.Id); if (objFacebookAccountRepository.checkFacebookUserExists(FacebookId, Guid.Parse(UserId))) { objFacebookAccount = objFacebookAccountRepository.getFacebookAccountDetailsById(FacebookId, Guid.Parse(UserId)); } else { objFacebookAccount = objFacebookAccountRepository.getFacebookAccountDetailsById(FacebookId); } if (objFacebookAccount != null) { FacebookClient fbclient = new FacebookClient(objFacebookAccount.AccessToken); var args = new Dictionary<string, object>(); args["message"] = objScheduledMessage.ShareMessage; string imagepath = objScheduledMessage.PicUrl; var facebookpost = ""; try { if (!string.IsNullOrEmpty(imagepath)) { var media = new FacebookMediaObject { FileName = "filename", ContentType = "image/jpeg" }; byte[] img = System.IO.File.ReadAllBytes(imagepath); media.SetValue(img); args["source"] = media; facebookpost = fbclient.Post("v2.0/" + _GroupScheduleMessage.GroupId + "/photos", args).ToString(); } else { facebookpost = fbclient.Post("v2.0/" + _GroupScheduleMessage.GroupId + "/feed", args).ToString(); } } catch (Exception ex) { objFacebookAccountRepository = new FacebookAccountRepository(); objFacebookAccount.IsActive = 2; objFacebookAccountRepository.updateFacebookUserStatus(objFacebookAccount); Domain.Myfashion.Domain.SocialProfile objSocialProfile = new Domain.Myfashion.Domain.SocialProfile(); SocialProfilesRepository objSocialProfilesRepository = new SocialProfilesRepository(); string errormsg = ex.Message; if (errormsg.Contains("access token")) { objSocialProfile.UserId = objFacebookAccount.UserId; objSocialProfile.ProfileId = objFacebookAccount.FbUserId; objSocialProfile.ProfileStatus = 2; objSocialProfilesRepository.updateSocialProfileStatus(objSocialProfile); } Console.WriteLine(ex.Message); str = ex.Message; } if (!string.IsNullOrEmpty(facebookpost)) { str = "Message post on facebook for Id :" + objFacebookAccount.FbUserId + " and Message: " + objScheduledMessage.ShareMessage; ScheduledMessage schmsg = new ScheduledMessage(); schmsg.UpdateScheduledMessageByMsgId(Guid.Parse(sscheduledmsgguid)); } } else { str = "facebook account not found for id" + objScheduledMessage.ProfileId; } } catch (Exception ex) { str = ex.Message; } return str; }
public string AddInstagramAccount(string client_id, string client_secret, string redirect_uri, string UserId, string GroupId, string code) { string ret = string.Empty; oAuthInstagram objInsta = new oAuthInstagram(); GlobusInstagramLib.Authentication.ConfigurationIns configi = new GlobusInstagramLib.Authentication.ConfigurationIns("https://api.instagram.com/oauth/authorize/", client_id, client_secret, redirect_uri, "http://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", ""); oAuthInstagram _api = new oAuthInstagram(); _api = oAuthInstagram.GetInstance(configi); AccessToken access = new AccessToken(); access = _api.AuthGetAccessToken(code); #region InstagramAccount UserController objusercontroller = new UserController(); InstagramResponse<GlobusInstagramLib.App.Core.User> objuser = objusercontroller.GetUserDetails(access.user.id, access.access_token); objInstagramAccount = new Domain.Myfashion.Domain.InstagramAccount(); objInstagramAccount.AccessToken = access.access_token; objInstagramAccount.InstagramId = access.user.id; try { objInstagramAccount.ProfileUrl = access.user.profile_picture; } catch (Exception ex) { logger.Error("Instagram.asmx.cs >> AddInstagramAccount >> " + ex.StackTrace); } try { objInstagramAccount.InsUserName = access.user.username; } catch (Exception ex) { logger.Error("Instagram.asmx.cs >> AddInstagramAccount >> " + ex.StackTrace); } try { objInstagramAccount.TotalImages = objuser.data.counts.media; } catch (Exception ex) { logger.Error("Instagram.asmx.cs >> AddInstagramAccount >> " + ex.StackTrace); } try { objInstagramAccount.FollowedBy = objuser.data.counts.followed_by; } catch (Exception ex) { logger.Error("Instagram.asmx.cs >> AddInstagramAccount >> " + ex.StackTrace); } try { objInstagramAccount.Followers = objuser.data.counts.follows; } catch (Exception ex) { logger.Error("Instagram.asmx.cs >> AddInstagramAccount >> " + ex.StackTrace); } objInstagramAccount.UserId = Guid.Parse(UserId); #endregion if (!objInstagramAccountRepository.checkInstagramUserExists(objInstagramAccount.InstagramId, Guid.Parse(UserId))) { objInstagramAccountRepository.addInstagramUser(objInstagramAccount); #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 = "instagram"; objTeamMemberProfile.StatusUpdateDate = DateTime.Now; objTeamMemberProfile.ProfileId = objInstagramAccount.InstagramId; //Modified [13-02-15] objTeamMemberProfile.ProfilePicUrl = objInstagramAccount.ProfileUrl; objTeamMemberProfile.ProfileName = objInstagramAccount.InsUserName; objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile); #endregion #region SocialProfile Domain.Myfashion.Domain.SocialProfile objSocialProfile = new Domain.Myfashion.Domain.SocialProfile(); objSocialProfile.Id = Guid.NewGuid(); objSocialProfile.ProfileType = "instagram"; objSocialProfile.ProfileId = objInstagramAccount.InstagramId; objSocialProfile.UserId = Guid.Parse(UserId); objSocialProfile.ProfileDate = DateTime.Now; objSocialProfile.ProfileStatus = 1; #endregion #region Add SocialProfile if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile)) { objSocialProfilesRepository.addNewProfileForUser(objSocialProfile); } #endregion ret = "Account Added Successfully"; } else { ret = "Account already Exist !"; } //GetIntagramImages(objInstagramAccount); GetInstagramFeeds(objInstagramAccount); return ret; }
public string AddFacebookGroupsInfo(string userid, string fbgroupid, string accessToken, string groupId, string email, string fbgroupname) { string ret = string.Empty; try { FacebookClient fb = new FacebookClient(); if (accessToken != null) { fb.AccessToken = accessToken; System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls; dynamic profile = fb.Get("v2.0/me"); #region Add FacebookAccount objFacebookAccount = new Domain.Myfashion.Domain.FacebookAccount(); objFacebookAccount.Id = Guid.NewGuid(); objFacebookAccount.FbUserId = fbgroupid; objFacebookAccount.FbUserName = fbgroupname; objFacebookAccount.AccessToken = accessToken; objFacebookAccount.Friends = 0; objFacebookAccount.EmailId = email; objFacebookAccount.Type = "group"; objFacebookAccount.ProfileUrl = (Convert.ToString(profile["link"])); objFacebookAccount.IsActive = 2; objFacebookAccount.UserId = Guid.Parse(userid); if (!objFacebookAccountRepository.checkFacebookUserExists(objFacebookAccount.FbUserId, objFacebookAccount.UserId)) { objFacebookAccountRepository.addFacebookUser(objFacebookAccount); } //objFacebookAccountRepository.addFacebookUser(objFacebookAccount); #endregion #region SocialProfile Domain.Myfashion.Domain.SocialProfile objSocialProfile = new Domain.Myfashion.Domain.SocialProfile(); objSocialProfile.Id = Guid.NewGuid(); objSocialProfile.ProfileType = "facebook_group"; objSocialProfile.ProfileId = fbgroupid; objSocialProfile.UserId = Guid.Parse(userid); objSocialProfile.ProfileDate = DateTime.Now; objSocialProfile.ProfileStatus = 1; if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile)) { objSocialProfilesRepository.addNewProfileForUser(objSocialProfile); } #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 = "facebook_group"; objTeamMemberProfile.StatusUpdateDate = DateTime.Now; objTeamMemberProfile.ProfileId = fbgroupid; if (!objTeamMemberProfileRepository.checkTeamMemberProfile(objTeamMemberProfile.TeamId, objTeamMemberProfile.ProfileId)) { objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile); } #endregion #region Add Facebook Feeds AddFacebookFeeds(userid, fb, profile); #endregion } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } return ret; }
public string AddFacebookPagesByUrl(string userid, string profileId, string groupId, string name) { logger.Error("AddFacebookPagesByUrllllllll"); logger.Error(userid + ", " + profileId + ", " + groupId + ", " + name); string ret = string.Empty; FacebookAccount _FacebookAccount = new FacebookAccount(); // string token = _FacebookAccount.getFbToken(); string token = "CAAKYvwDVmnUBACyqUsvADWoAfBYTxi0kbz2gcw0sDWbBVJCXmIUG6rGez4BFSCE4hKV8eNE86eCD2iOwEWADvYuNlYupZCL4WUAGhFmRIZA6nTkdUOFeiUVHuri571QxhZA3YfSk5YkjhYy81pYtPj9FNM2mENtjCWRr5tN9zWZAKpUkw3gzsXRuEH9ZBTBwZD"; try { #region fancount FacebookClient fb = new FacebookClient(); fb.AccessToken = token; int fancountPage = 0; try { System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls; //dynamic fancount = fb.Get("fql", new { q = " SELECT fan_count FROM page WHERE page_id =" + profileId }); //foreach (var friend in fancount.data) //{ // fancountPage = Convert.ToInt32(friend.fan_count); //} //dynamic friends = fb.Get("v2.0/me/friends"); //fancountPage = Convert.ToInt16(friends["summary"]["total_count"].ToString()); dynamic friends = fb.Get("v2.0/" + profileId); fancountPage = Convert.ToInt32(friends["likes"].ToString()); } catch (Exception) { fancountPage = 0; fb.AccessToken = "CAAKYvwDVmnUBAFvCcZCQDL53q82jfR5mvgF2whNsFHgR4NmeSSUeRVpdEUpcVVgK1ERs2GZCNhJAwRHtq6MEWiRtBQnxBmZAML6dnwgpsCbjUmyT7ws6EKZBxuWbxhJqjeNCsxhac00b3L9Bf7LLlYa3PG94Uouj7vXZAZC6djZCme5BuszE3vibNFLKQqaLcgZD"; try { System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls; //dynamic fancount = fb.Get("fql", new { q = " SELECT fan_count FROM page WHERE page_id =" + profileId }); //foreach (var friend in fancount.data) //{ // fancountPage = Convert.ToInt32(friend.fan_count); //} //dynamic friends = fb.Get("v2.0/me/friends"); //fancountPage = Convert.ToInt16(friends["summary"]["total_count"].ToString()); dynamic friends = fb.Get("v2.0/" + profileId); fancountPage = Convert.ToInt32(friends["likes"].ToString()); } catch (Exception ex) { logger.Error("fancount : " + ex.Message); } } #endregion #region Add FacebookAccount objFacebookAccount = new Domain.Myfashion.Domain.FacebookAccount(); objFacebookAccount.Id = Guid.NewGuid(); objFacebookAccount.FbUserId = profileId; objFacebookAccount.FbUserName = name; objFacebookAccount.AccessToken = ""; objFacebookAccount.Friends = Convert.ToInt32(fancountPage); objFacebookAccount.EmailId = ""; objFacebookAccount.Type = "Page"; objFacebookAccount.ProfileUrl = ""; objFacebookAccount.IsActive = 1; objFacebookAccount.UserId = Guid.Parse(userid); if (!objFacebookAccountRepository.checkFacebookUserExists(objFacebookAccount.FbUserId, objFacebookAccount.UserId)) { objFacebookAccountRepository.addFacebookUser(objFacebookAccount); } #endregion #region SocialProfile Domain.Myfashion.Domain.SocialProfile objSocialProfile = new Domain.Myfashion.Domain.SocialProfile(); objSocialProfile.Id = Guid.NewGuid(); objSocialProfile.ProfileType = "facebook_page"; objSocialProfile.ProfileId = profileId; objSocialProfile.UserId = Guid.Parse(userid); objSocialProfile.ProfileDate = DateTime.Now; objSocialProfile.ProfileStatus = 1; if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile)) { objSocialProfilesRepository.addNewProfileForUser(objSocialProfile); } #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 = "facebook_page"; objTeamMemberProfile.StatusUpdateDate = DateTime.Now; objTeamMemberProfile.ProfileId = profileId; if (!objTeamMemberProfileRepository.checkTeamMemberProfile(objTeamMemberProfile.TeamId, objTeamMemberProfile.ProfileId)) { objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile); } #endregion try { logger.Error(" Token:" + token); if (token != null) { FacebookClient _FacebookClient = new FacebookClient(); _FacebookClient.AccessToken = token; dynamic profile = null; try { profile = fb.Get("v2.0/" + profileId); logger.Error("AddFacebookPagesByUrl Token 1"); } catch (Exception ex) { logger.Error("fb.Get(profileId)"); logger.Error(ex.StackTrace); Console.WriteLine(ex.StackTrace); try { fb.AccessToken = "CAAKYvwDVmnUBAFvCcZCQDL53q82jfR5mvgF2whNsFHgR4NmeSSUeRVpdEUpcVVgK1ERs2GZCNhJAwRHtq6MEWiRtBQnxBmZAML6dnwgpsCbjUmyT7ws6EKZBxuWbxhJqjeNCsxhac00b3L9Bf7LLlYa3PG94Uouj7vXZAZC6djZCme5BuszE3vibNFLKQqaLcgZD"; profile = fb.Get("v2.0/" + profileId); logger.Error("AddFacebookPagesByUrl Token 2"); } catch (Exception ex2) { try { fb.AccessToken = "CAAKYvwDVmnUBAAR2O9hxFkHzfNG8H6KbQLaiGFMRshJkbttdzhDeprklcb1yaV0rwtC7N8Xz1rsL1cykiRv2ouXtBUFxvOZCNnpFELnQGFV8jGUWjm1GYsZA40IKAORLGoAcSaa2lJkuuSoLBksB8LFPHI4cqW7VVqxgDwZCRwObxqR4Qp9QEDHxa7j1yoZD"; profile = fb.Get("v2.0/" + profileId); logger.Error("AddFacebookPagesByUrl Token 3"); } catch (Exception ex3) { try { fb.AccessToken = "CAAKYvwDVmnUBAFtZB8pvVrqYQonmq7MD90oNdoipDc0Te4onP2XlbZAYT4bzOZAKTr8jdhw0P1PclgLOtVxJ9g2qx4vxZAzh2CXqXAZBZAZBwkgWIVjc2B4rcXAp6O5B3gXqd8Ko5ITL9VCZCMOkMZCPc1hBsp0n8zgPt6e3Dd0vaodPBS8nMz7RD"; profile = fb.Get("v2.0/" + profileId); logger.Error("AddFacebookPagesByUrl Token 4"); } catch (Exception ex4) { try { fb.AccessToken = "CAAKYvwDVmnUBALvjTAKIrVKnL719aVDB7BmMRn7e08ySJQwHYtLDZBBjx5yBZBaMeJ04lIT8bCzX2A685YLXR9d8PukZCBZA2LiwZAmj6qhMZC8F0od7NBircdMZAOZAD1xukXDhd24RQRvVk9GyJNRmmGTiZAhMJzXBVczH3TlYb37qi8FRXfTGDRTZAyxjyYSt8ZD"; profile = fb.Get("v2.0/" + profileId); logger.Error("AddFacebookPagesByUrl Token 5"); } catch (Exception ex5) { logger.Error("Finally :" + fb.AccessToken); logger.Error(ex5.Message); logger.Error(ex5.Message); } } } } } try { //Edited by Sumit Gupta [10/27/2014] //AddFacebookStats(userid, _FacebookClient, profile); AddFacebookStats(userid, fb, profile); } catch (Exception ex) { logger.Error(ex.StackTrace); Console.WriteLine(ex.StackTrace); } //Edited by Sumit Gupta [10/29/2014] AddFbPagePost(userid, fb.AccessToken, profileId); // AddFbPagePost(userid, token, profileId); } } catch (Exception ex) { logger.Error("dynamic profile"); logger.Error(ex.StackTrace); Console.WriteLine(ex.StackTrace); } } catch (Exception ex) { logger.Error(ex.Message); logger.Error(ex.StackTrace); Console.WriteLine(ex.StackTrace); } 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 string AddFacebookAccountWithlogin(string accessToken, string UserId, string GroupId) { string ret = string.Empty; string client_id = ConfigurationManager.AppSettings["ClientId"]; string redirect_uri = ConfigurationManager.AppSettings["RedirectUrl"]; string client_secret = ConfigurationManager.AppSettings["ClientSecretKey"]; long friendscount = 0; try { FacebookClient fb = new FacebookClient(); string profileId = string.Empty; Dictionary<string, object> parameters = new Dictionary<string, object>(); parameters.Add("client_id", client_id); parameters.Add("redirect_uri", redirect_uri); parameters.Add("client_secret", client_secret); if (accessToken != null) { fb.AccessToken = accessToken; System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls; dynamic profile = fb.Get("v2.0/me"); dynamic friends = fb.Get("v2.0/me/friends"); try { friendscount = Convert.ToInt16(friends["summary"]["total_count"].ToString()); } catch (Exception ex) { //try //{ // dynamic frndscount = fb.Get("fql", new { q = "SELECT friend_count FROM user WHERE uid=me()" }); // foreach (var friend in frndscount.data) // { // frndscount = friend.friend_count; // } // friendscount = Convert.ToInt16(frndscount); //} //catch (Exception ex) //{ // friendscount = 0; // logger.Error(ex.Message); // logger.Error(ex.StackTrace); //} friendscount = 0; logger.Error("friendscount >> " + ex.Message); logger.Error("friendscount >> " + ex.StackTrace); logger.Error("friendscount >> " + friends.ToString()); logger.Error("friendscount >> " + friends["paging"]["next"].ToString()); } if (!objFacebookAccountRepository.checkFacebookUserExists(Convert.ToString(profile["id"]), Guid.Parse(UserId))) { #region Add FacebookAccount objFacebookAccount = new Domain.Myfashion.Domain.FacebookAccount(); objFacebookAccount.Id = Guid.NewGuid(); objFacebookAccount.FbUserId = (Convert.ToString(profile["id"])); objFacebookAccount.FbUserName = (Convert.ToString(profile["name"])); objFacebookAccount.AccessToken = accessToken; objFacebookAccount.Friends = Convert.ToInt16(friendscount); try { objFacebookAccount.EmailId = (Convert.ToString(profile["email"])); } catch (Exception ex) { } objFacebookAccount.Type = "account"; objFacebookAccount.ProfileUrl = (Convert.ToString(profile["link"])); objFacebookAccount.IsActive = 1; objFacebookAccount.UserId = Guid.Parse(UserId); objFacebookAccountRepository.addFacebookUser(objFacebookAccount); #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 = "facebook"; objTeamMemberProfile.StatusUpdateDate = DateTime.Now; objTeamMemberProfile.ProfileId = Convert.ToString(profile["id"]); objTeamMemberProfile.ProfileName = (Convert.ToString(profile["name"])); objTeamMemberProfile.ProfilePicUrl = "http://graph.facebook.com/" + objTeamMemberProfile.ProfileId + "/picture?type=small"; objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile); #endregion #region SocialProfile Domain.Myfashion.Domain.SocialProfile objSocialProfile = new Domain.Myfashion.Domain.SocialProfile(); objSocialProfile.Id = Guid.NewGuid(); objSocialProfile.ProfileType = "facebook"; objSocialProfile.ProfileId = (Convert.ToString(profile["id"])); objSocialProfile.UserId = Guid.Parse(UserId); objSocialProfile.ProfileDate = DateTime.Now; objSocialProfile.ProfileStatus = 1; #endregion if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile)) { objSocialProfilesRepository.addNewProfileForUser(objSocialProfile); } #region Add Facebook Feeds AddFacebookFeeds(UserId, fb, profile); #endregion #region Add Facebook User Home AddFacebookUserHome(UserId, fb, profile); #endregion #region Add Facebook User Inbox Message //AddFacebookMessage(UserId, fb, profile); AddFacebookMessageWithPagination(UserId, fb, profile); #endregion #region Add Facebook Stats AddFacebookStats(UserId, fb, profile); #endregion //getUserNotifications(UserId, fb, profile); ret = "Account Added Successfully"; ret = new JavaScriptSerializer().Serialize(objFacebookAccount); } else { objFacebookAccount = objFacebookAccountRepository.getFacebookAccountDetailsById(Convert.ToString(profile["id"]), Guid.Parse(UserId)); if (objFacebookAccount.IsActive == 2) { objFacebookAccount.IsActive = 1; objFacebookAccount.AccessToken = accessToken; objFacebookAccountRepository.updateFacebookUser(objFacebookAccount); Domain.Myfashion.Domain.SocialProfile objSocialProfile = new Domain.Myfashion.Domain.SocialProfile(); objSocialProfile.Id = Guid.NewGuid(); objSocialProfile.ProfileType = "facebook"; objSocialProfile.ProfileId = objFacebookAccount.FbUserId; objSocialProfile.UserId = Guid.Parse(UserId); objSocialProfile.ProfileDate = DateTime.Now; objSocialProfile.ProfileStatus = 1; objSocialProfilesRepository.updateSocialProfileStatus(objSocialProfile); ret = "Account Updated successfully !"; } else { ret = "Account already Exist !"; } } } //return new JavaScriptSerializer().Serialize(ret); return ret; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return "Something Went Wrong"; } }
public string AddLinkedinAccount(string oauth_token, string oauth_verifier, string reuqestTokenSecret, string consumerKey, string consumerSecret, string UserId, string GroupId) { try { logger.Error("AddLinkedinAccount()"); System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls; string ret = string.Empty; LinkedInProfile objProfile = new LinkedInProfile(); LinkedInProfile.UserProfile objUserProfile = new LinkedInProfile.UserProfile(); objSocialProfile = new Domain.Myfashion.Domain.SocialProfile(); oAuthLinkedIn _oauth = new oAuthLinkedIn(); objLinkedInAccount = new LinkedInAccount(); #region Get linkedin Profile data from Api try { _oauth.ConsumerKey = consumerKey; } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } try { _oauth.ConsumerSecret = consumerSecret; } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } try { _oauth.Token = oauth_token; } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } try { _oauth.TokenSecret = reuqestTokenSecret; } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } try { _oauth.Verifier = oauth_verifier; } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } try { _oauth.AccessTokenGet(oauth_token); } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } try { objUserProfile = objProfile.GetUserProfile(_oauth); } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } #endregion dynamic data = objUserProfile; try { #region LinkedInAccount objLinkedInAccount.UserId = Guid.Parse(UserId); objLinkedInAccount.LinkedinUserId = data.id.ToString(); try { objLinkedInAccount.EmailId = data.email.ToString(); } catch (Exception ex) { logger.Error(ex.StackTrace); } objLinkedInAccount.LinkedinUserName = data.first_name.ToString() + data.last_name.ToString(); objLinkedInAccount.OAuthToken = _oauth.Token; objLinkedInAccount.OAuthSecret = _oauth.TokenSecret; objLinkedInAccount.OAuthVerifier = _oauth.Verifier; try { objLinkedInAccount.ProfileImageUrl = data.picture_url.ToString(); } catch (Exception ex) { logger.Error(ex.StackTrace); } try { objLinkedInAccount.ProfileUrl = data.profile_url.ToString(); } catch (Exception ex) { logger.Error(ex.StackTrace); } #endregion #region SocialProfiles try { objLinkedInAccount.Connections = data.connections; objLinkedInAccount.IsActive = true; objSocialProfile.UserId = Guid.Parse(UserId); objSocialProfile.ProfileType = "linkedin"; objSocialProfile.ProfileId = data.id.ToString(); objSocialProfile.ProfileStatus = 1; objSocialProfile.ProfileDate = DateTime.Now; objSocialProfile.Id = Guid.NewGuid(); } catch (Exception ex) { logger.Error(ex.Message); } #endregion SocialProfiles #region Add TeamMemberProfile try { Domain.Myfashion.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId)); objTeamMemberProfile = new Domain.Myfashion.Domain.TeamMemberProfile(); objTeamMemberProfile.Id = Guid.NewGuid(); objTeamMemberProfile.TeamId = objTeam.Id; objTeamMemberProfile.Status = 1; objTeamMemberProfile.ProfileType = "linkedin"; objTeamMemberProfile.StatusUpdateDate = DateTime.Now; objTeamMemberProfile.ProfileId = objLinkedInAccount.LinkedinUserId; objTeamMemberProfile.ProfileName = objLinkedInAccount.LinkedinUserName; objTeamMemberProfile.ProfilePicUrl = objLinkedInAccount.ProfileImageUrl; } catch (Exception ex) { logger.Error(ex.Message); } #endregion } catch (Exception ex) { logger.Error(ex.StackTrace); } try { if (!objLinkedInAccountRepository.checkLinkedinUserExists(objLinkedInAccount.LinkedinUserId, Guid.Parse(UserId))) { objLinkedInAccountRepository.addLinkedinUser(objLinkedInAccount); ret = "LinkedIn Account Added Successfully"; } else { ret = "LinkedIn Account Already Exist"; } if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile)) { objSocialProfilesRepository.addNewProfileForUser(objSocialProfile); } if (!objTeamMemberProfileRepository.checkTeamMemberProfile(objTeamMemberProfile.TeamId, objLinkedInAccount.LinkedinUserId)) { objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile); } #region Add LinkedIn Feeds LinkedInNetwork objln = new LinkedInNetwork(); List<LinkedInNetwork.Network_Updates> userUPdate = objln.GetNetworkUpdates(_oauth, 20); foreach (var item in userUPdate) { try { objLinkedInFeed = new Domain.Myfashion.Domain.LinkedInFeed(); objLinkedInFeed.Feeds = item.Message; objLinkedInFeed.FromId = item.PersonId; objLinkedInFeed.FromName = item.PersonFirstName + " " + item.PersonLastName; objLinkedInFeed.FeedsDate = Convert.ToDateTime(item.DateTime); objLinkedInFeed.EntryDate = DateTime.Now; objLinkedInFeed.ProfileId = objLinkedInAccount.LinkedinUserId; objLinkedInFeed.Type = item.UpdateType; objLinkedInFeed.UserId = Guid.Parse(UserId); objLinkedInFeed.FromPicUrl = item.PictureUrl; objLinkedInFeed.ImageUrl = item.ImageUrl; objLinkedInFeed.FromUrl = item.url; } catch (Exception ex) { logger.Error(ex.StackTrace); } if (!objLinkedInFeedRepository.checkLinkedInFeedExists(objLinkedInFeed.FeedId, Guid.Parse(UserId))) { objLinkedInFeedRepository.addLinkedInFeed(objLinkedInFeed); } } #endregion #region Add LinkedIn UserUpdates GlobusLinkedinLib.App.Core.LinkedInUser l = new GlobusLinkedinLib.App.Core.LinkedInUser(); List<Domain.Myfashion.Domain.LinkedIn_Update_Messages> lst_Messages = l.GetUserUpdateNew(_oauth, objLinkedInAccount.LinkedinUserId, 10); foreach (var item_Messages in lst_Messages) { try { objLinkedInMessage = new Domain.Myfashion.Domain.LinkedInMessage(); objLinkedInMessage.Id = Guid.NewGuid(); objLinkedInMessage.Message = item_Messages.Message; objLinkedInMessage.ProfileId = item_Messages.ProfileId; objLinkedInMessage.ProfileName = item_Messages.ProfileName; objLinkedInMessage.CreatedDate = Convert.ToDateTime(item_Messages.CreatedDate); objLinkedInMessage.EntryDate = DateTime.Now; objLinkedInMessage.Type = item_Messages.Type; objLinkedInMessage.UserId = Guid.Parse(UserId); objLinkedInMessage.ImageUrl = item_Messages.ImageUrl; objLinkedInMessage.FeedId = item_Messages.FeedId; objLinkedInMessage.ProfileUrl = item_Messages.ProfileUrl; objLinkedInMessage.Comments = item_Messages.Comments; objLinkedInMessage.Likes = item_Messages.Likes; objLinkedInMessage.ProfileImageUrl = item_Messages.ProfileImageUrl; } catch (Exception ex) { logger.Error(ex.StackTrace); } if (!objLinkedInMessageRepository.checkLinkedInMessageExists(objLinkedInAccount.LinkedinUserId, objLinkedInMessage.FeedId, Guid.Parse(UserId))) { objLinkedInMessageRepository.addLinkedInMessage(objLinkedInMessage); } } #endregion } catch (Exception ex) { logger.Error(ex.StackTrace); } return ""; } catch (Exception ex) { logger.Error(ex.StackTrace); return ""; } }
public string GetAllSocialProfiles() { try { Domain.Myfashion.Domain.SocialProfile objSocialProfile = new Domain.Myfashion.Domain.SocialProfile(); List<Domain.Myfashion.Domain.SocialProfile> lstSocialProfile = new List<Domain.Myfashion.Domain.SocialProfile>(); lstSocialProfile = objSocialProfilesRepository.getAllSocialProfiles(); //FacebookAccountRepository facebookAccountRepo = new FacebookAccountRepository(); //FacebookAccount facebook = facebookAccountRepo.getFacebookAccountDetailsById(FacebookId, userid); return new JavaScriptSerializer().Serialize(lstSocialProfile); //return lstScheduledMessages; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return new JavaScriptSerializer().Serialize("Please try Again"); } }
public void GetPageProfile(dynamic data, oAuthLinkedIn _OAuth, string UserId, string CompanyPageId, string GroupId) { Domain.Myfashion.Domain.SocialProfile socioprofile = new Domain.Myfashion.Domain.SocialProfile(); SocialProfilesRepository socioprofilerepo = new SocialProfilesRepository(); Domain.Myfashion.Domain.LinkedinCompanyPage objLinkedincmpnypage = new Domain.Myfashion.Domain.LinkedinCompanyPage(); LinkedinCompanyPageRepository objLinkedCmpnyPgeRepo = new LinkedinCompanyPageRepository(); try { objLinkedincmpnypage.UserId = Guid.Parse(UserId); try { objLinkedincmpnypage.LinkedinPageId = data.Pageid.ToString(); } catch { } objLinkedincmpnypage.Id = Guid.NewGuid(); try { objLinkedincmpnypage.EmailDomains = data.EmailDomains.ToString(); } catch { } objLinkedincmpnypage.LinkedinPageName = data.name.ToString(); objLinkedincmpnypage.OAuthToken = _OAuth.Token; objLinkedincmpnypage.OAuthSecret = _OAuth.TokenSecret; objLinkedincmpnypage.OAuthVerifier = _OAuth.Verifier; try { objLinkedincmpnypage.Description = data.description.ToString(); } catch { } try { objLinkedincmpnypage.FoundedYear = data.founded_year.ToString(); } catch { } try { objLinkedincmpnypage.EndYear = data.end_year.ToString(); } catch { } try { objLinkedincmpnypage.Locations = data.locations.ToString(); } catch { } try { objLinkedincmpnypage.Specialties = data.Specialties.ToString(); } catch { } try { objLinkedincmpnypage.WebsiteUrl = data.website_url.ToString(); } catch { } try { objLinkedincmpnypage.Status = data.status.ToString(); } catch { } try { objLinkedincmpnypage.EmployeeCountRange = data.employee_count_range.ToString(); } catch { } try { objLinkedincmpnypage.Industries = data.industries.ToString(); } catch { } try { string NuberOfFollower = data.num_followers.ToString(); objLinkedincmpnypage.NumFollowers = Convert.ToInt16(NuberOfFollower); } catch { } try { objLinkedincmpnypage.CompanyType = data.company_type.ToString(); } catch { } try { objLinkedincmpnypage.LogoUrl = data.logo_url.ToString(); } catch { } try { objLinkedincmpnypage.SquareLogoUrl = data.square_logo_url.ToString(); } catch { } try { objLinkedincmpnypage.BlogRssUrl = data.blog_rss_url.ToString(); } catch { } try { objLinkedincmpnypage.UniversalName = data.universal_name.ToString(); } catch { } #region SocialProfiles socioprofile.UserId = Guid.Parse(UserId); socioprofile.ProfileType = "linkedincompanypage"; socioprofile.ProfileId = data.Pageid.ToString(); ; socioprofile.ProfileStatus = 1; socioprofile.ProfileDate = DateTime.Now; socioprofile.Id = Guid.NewGuid(); #endregion #region TeamMemberProfile Domain.Myfashion.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId)); objTeamMemberProfile = new Domain.Myfashion.Domain.TeamMemberProfile(); objTeamMemberProfile.Id = Guid.NewGuid(); objTeamMemberProfile.TeamId = objTeam.Id; objTeamMemberProfile.Status = 1; objTeamMemberProfile.ProfileType = "linkedincompanypage"; objTeamMemberProfile.StatusUpdateDate = DateTime.Now; objTeamMemberProfile.ProfileId = socioprofile.ProfileId; #endregion } catch { } try { if (!objSocialProfilesRepository.checkUserProfileExist(socioprofile)) { objSocialProfilesRepository.addNewProfileForUser(socioprofile); } if (!objTeamMemberProfileRepository.checkTeamMemberProfile(objTeamMemberProfile.TeamId, objLinkedincmpnypage.LinkedinPageId)) { objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile); } if (!objLinkedCmpnyPgeRepo.checkLinkedinPageExists(CompanyPageId, Guid.Parse(UserId))) { objLinkedCmpnyPgeRepo.addLinkenCompanyPage(objLinkedincmpnypage); } else { objLinkedincmpnypage.LinkedinPageId = CompanyPageId; objLinkedCmpnyPgeRepo.updateLinkedinPage(objLinkedincmpnypage); } } catch { } }
private void UpdateSocialprofileStatus(string UserId, string profile) { Domain.Myfashion.Domain.SocialProfile objSocialProfile = new Domain.Myfashion.Domain.SocialProfile(); objSocialProfile.Id = Guid.NewGuid(); objSocialProfile.ProfileType = "facebook"; objSocialProfile.ProfileId = profile; objSocialProfile.UserId = Guid.Parse(UserId); objSocialProfile.ProfileDate = DateTime.Now; objSocialProfile.ProfileStatus = 2; objSocialProfilesRepository.updateSocialProfileStatus(objSocialProfile); }