public Domain.Socioboard.Domain.TwitterAccount getUserInformation(string twtuserid) { //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 get account details by user id and twitter id. List <Domain.Socioboard.Domain.TwitterAccount> objlst = session.CreateQuery("from TwitterAccount where TwitterUserId = :Twtuserid") .SetParameter("Twtuserid", twtuserid) .List <Domain.Socioboard.Domain.TwitterAccount>().ToList <Domain.Socioboard.Domain.TwitterAccount>(); Domain.Socioboard.Domain.TwitterAccount result = new Domain.Socioboard.Domain.TwitterAccount(); if (objlst.Count > 0) { result = objlst[0]; } return(result); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return(null); } } //End Transaction } //End Session }
/// <getUserInformation> /// Get User account Information by screen Name and user id. /// </summary> /// <param name="screenname">Tqitter account screen name.(String)</param> /// <param name="userid">User id.(Guid)</param> /// <returns>Return the object of TwitterAccount class with value.(Domain.TwitterAccount)</returns> public Domain.Socioboard.Domain.TwitterAccount getUserInformation(string screenname, Guid userid) { //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 get twitter account details by screen name and user id. NHibernate.IQuery query = session.CreateQuery("from TwitterAccount where UserId = :userid and TwitterScreenName = :Twtuserid"); query.SetParameter("userid", userid); query.SetParameter("Twtuserid", screenname); Domain.Socioboard.Domain.TwitterAccount result = query.UniqueResult <Domain.Socioboard.Domain.TwitterAccount>(); return(result); //TwitterAccount result= session.QueryOver<TwitterAccount>().Where(x => x.UserId == userid).And(x=>x.TwitterUserId == twtuserid).SingleOrDefault<TwitterAccount>(); //return result; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return(null); } } //End Transaction } //End Session }
/// <updateTwitterUser> /// Update Twitter User /// </summary> /// <param name="TwtAccount">Set Values in a TwitterAccount Class Property and Pass the Object of TwitterAccount Class.(Domein.TwitterAccount)</param> /// <returns>Return 1 for success and 0 for failure.(int) </returns> public int updateTwitterUser(Domain.Socioboard.Domain.TwitterAccount TwtAccount) { //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 Account details. int i = session.CreateQuery("Update TwitterAccount set TwitterScreenName =:twtScreenName,OAuthToken=:twtToken,OAuthSecret=:tokenSecret,FollowersCount=:followerscount,FollowingCount=:followingcount,ProfileImageUrl=:imageurl where TwitterUserId = :id and UserId =:userid") .SetParameter("twtScreenName", TwtAccount.TwitterScreenName) .SetParameter("twtToken", TwtAccount.OAuthToken) .SetParameter("tokenSecret", TwtAccount.OAuthSecret) .SetParameter("followerscount", TwtAccount.FollowersCount) .SetParameter("followingcount", TwtAccount.FollowingCount) .SetParameter("imageurl", TwtAccount.ProfileImageUrl) .SetParameter("id", TwtAccount.TwitterUserId) .SetParameter("userid", TwtAccount.UserId) .ExecuteUpdate(); transaction.Commit(); return(i); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return(0); } } //End Transaction } //End Session }
/// <addTwitterkUser> /// Add new Twitter account. /// </summary> /// <param name="TwtAccount">Set Values in a TwitterAccount Class Property and Pass the Object of TwitterAccount Class.(Domein.TwitterAccount)</param> public void addTwitterkUser(Domain.Socioboard.Domain.TwitterAccount TwtAccount) { //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(TwtAccount); transaction.Commit(); } //End Transaction } //End Session }
public ISocialSiteAccount BindJArray(Newtonsoft.Json.Linq.JObject jObject) { TwitterAccount objTwitterAccount = new TwitterAccount(); //Api.FacebookAccount.FacebookAccount ApiobjFacebookAccount = new Api.FacebookAccount.FacebookAccount(); //JObject FacebookAccountDetails = JObject.Parse(ApiobjFacebookAccount.getFacebookAccountDetailsById(objUser.Id.ToString(), objTeamMemberProfile.ProfileId.ToString())); objTwitterAccount.Id = Guid.Parse(jObject["Id"].ToString()); objTwitterAccount.TwitterUserId = jObject["TwitterUserId"].ToString(); objTwitterAccount.TwitterScreenName = jObject["TwitterScreenName"].ToString(); objTwitterAccount.OAuthToken = jObject["OAuthToken"].ToString(); objTwitterAccount.OAuthSecret = Convert.ToString(jObject["OAuthSecret"]); objTwitterAccount.UserId = Guid.Parse(jObject["UserId"].ToString()); objTwitterAccount.IsActive = Convert.ToBoolean(jObject["IsActive"].ToString()); objTwitterAccount.FollowersCount = Convert.ToInt16(Convert.ToString(jObject["FollowersCount"])); objTwitterAccount.FollowingCount = Convert.ToInt16(Convert.ToString(jObject["FollowingCount"])); objTwitterAccount.ProfileUrl = jObject["ProfileUrl"].ToString(); objTwitterAccount.ProfileImageUrl = jObject["ProfileImageUrl"].ToString(); objTwitterAccount.TwitterName = jObject["TwitterName"].ToString(); return objTwitterAccount; }
/// <getUserInfo> /// getUserAccount Information by profile id. /// </summary> /// <param name="profileid">Account profile id.(String)</param> /// <returns>Return the object of TwitterAccount class with value.(Domain.TwitterAccount)</returns> public Domain.Socioboard.Domain.TwitterAccount getUserInfo(string profileid) { //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 { try { //Proceed action, to get account details by profile id. NHibernate.IQuery query = session.CreateQuery("from TwitterAccount where TwitterUserId = :Twtuserid"); query.SetParameter("Twtuserid", profileid); Domain.Socioboard.Domain.TwitterAccount twtAccount = new Domain.Socioboard.Domain.TwitterAccount(); foreach (Domain.Socioboard.Domain.TwitterAccount item in query.Enumerable <Domain.Socioboard.Domain.TwitterAccount>()) { twtAccount = item; break; } return(twtAccount); //TwitterAccount result= session.QueryOver<TwitterAccount>().Where(x => x.UserId == userid).And(x=>x.TwitterUserId == twtuserid).SingleOrDefault<TwitterAccount>(); //return result; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return(null); } } catch { return(null); } } //End Transaction } //End Session }
public string TwitterProfileDetails(string userid, string profileid) { Domain.Socioboard.Domain.TwitterAccount objTwitterAccount = new Domain.Socioboard.Domain.TwitterAccount(); TwitterAccountRepository _objTwitterAccountRepository = new TwitterAccountRepository(); if (_objTwitterAccountRepository.checkTwitterUserExists(profileid, Guid.Parse(userid))) { objTwitterAccount = _objTwitterAccountRepository.getUserInformation(profileid, Guid.Parse(userid)); } else { objTwitterAccount = _objTwitterAccountRepository.getUserInformation(profileid); } return new JavaScriptSerializer().Serialize(objTwitterAccount); }
public void getUserProile(oAuthTwitter OAuth, string TwitterScreenName, Guid userId) { try { Users userinfo = new Users(); //TwitterAccount twitterAccount = new TwitterAccount(); Domain.Socioboard.Domain.TwitterAccount twitterAccount = new Domain.Socioboard.Domain.TwitterAccount(); TwitterAccountRepository twtrepo = new TwitterAccountRepository(); JArray profile = userinfo.Get_Users_LookUp(OAuth, TwitterScreenName); foreach (var item in profile) { try { twitterAccount.FollowingCount = Convert.ToInt32(item["friends_count"].ToString()); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { twitterAccount.FollowersCount = Convert.ToInt32(item["followers_count"].ToString()); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } twitterAccount.IsActive = true; twitterAccount.OAuthSecret = OAuth.AccessTokenSecret; twitterAccount.OAuthToken = OAuth.AccessToken; try { twitterAccount.ProfileImageUrl = item["profile_image_url"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { twitterAccount.ProfileUrl = string.Empty; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { twitterAccount.TwitterUserId = item["id_str"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception er) { try { twitterAccount.TwitterUserId = item["id"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception err) { Console.WriteLine(err.StackTrace); } Console.WriteLine(er.StackTrace); } try { twitterAccount.TwitterScreenName = item["screen_name"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } twitterAccount.UserId = userId; if (twtrepo.checkTwitterUserExists(twitterAccount.TwitterUserId, userId)) { twtrepo.updateTwitterUser(twitterAccount); } getTwitterStats(twitterAccount); } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } }
public string SheduleTwitterMessage(string TwitterId, string UserId, string sscheduledmsgguid) { string str = string.Empty; string ret = string.Empty; bool rt = false; try { oAuthTwitter OAuthTwt = new oAuthTwitter(); objScheduledMessage = objScheduledMessageRepository.GetScheduledMessageDetails(Guid.Parse(sscheduledmsgguid)); objTwitterAccount = objTwitterAccountRepository.GetUserInformation(Guid.Parse(UserId), TwitterId); //OAuthTwt.AccessToken = objTwitterAccount.OAuthToken; //OAuthTwt.AccessTokenSecret = objTwitterAccount.OAuthSecret; //OAuthTwt.TwitterScreenName = objTwitterAccount.TwitterScreenName; //OAuthTwt.TwitterUserId = objTwitterAccount.TwitterUserId; str = PostTwitterMessage(objScheduledMessage.ShareMessage, objTwitterAccount.TwitterUserId, UserId, objScheduledMessage.PicUrl, true, sscheduledmsgguid); #region Commented //#region For Testing //// For Testing ////OAuthTwt.ConsumerKey = "udiFfPxtCcwXWl05wTgx6w"; ////OAuthTwt.ConsumerKeySecret = "jutnq6N32Rb7cgbDSgfsrUVgRQKMbUB34yuvAfCqTI"; ////OAuthTwt.AccessToken = "1904022338-Ao9chvPouIU8ejE1HMG4yJsP3hOgEoXJoNRYUF7"; ////OAuthTwt.AccessTokenSecret = "Wj93a8csVFfaFS1MnHjbmbPD3V6DJbhEIf4lgSAefORZ5"; ////OAuthTwt.TwitterScreenName = ""; ////OAuthTwt.TwitterUserId = ""; //#endregion //if (objTwitterAccount != null) //{ // try // { // //TwitterUser twtuser = new TwitterUser(); // string message = objScheduledMessage.ShareMessage; // string picurl = objScheduledMessage.PicUrl; // //if (string.IsNullOrEmpty(objScheduledMessage.ShareMessage)) // //{ // // objScheduledMessage.ShareMessage = "There is no data in Share Message !"; // //} // if (string.IsNullOrEmpty(message) && string.IsNullOrEmpty(picurl)) // { // str = "There is no data in Share Message !"; // } // else // { // JArray post = new JArray(); // try // { // Tweet twt = new Tweet(); // if (!string.IsNullOrEmpty(picurl)) // { // PhotoUpload ph = new PhotoUpload(); // string res = string.Empty; // rt = ph.NewTweet(picurl, message, OAuthTwt, ref res); // } // else // { // post = twt.Post_Statuses_Update(OAuthTwt, message); // ret = post[0]["id_str"].ToString(); // } // //post = twtuser.Post_Status_Update(OAuthTwt, objScheduledMessage.ShareMessage); // } // catch (Exception ex) // { // Console.WriteLine(ex.StackTrace); // ret = ""; // } // if (!string.IsNullOrEmpty(ret) || rt == true) // { // str = "Message post on twitter for Id :" + objTwitterAccount.TwitterUserId + " and Message: " + objScheduledMessage.ShareMessage; // ScheduledMessage schmsg = new ScheduledMessage(); // schmsg.UpdateScheduledMessageByMsgId(Guid.Parse(sscheduledmsgguid)); // } // else // { // str = "Message not posted"; // } // } // } // catch (Exception ex) // { // Console.WriteLine(ex.StackTrace); // str = ex.Message; // } //} //else //{ // str = "facebook account not found for id" + objScheduledMessage.ProfileId; //} #endregion } catch (Exception ex) { Console.WriteLine(ex.StackTrace); str = ex.Message; } return str; }
public string ProfilesConnected(string UserId) { try { Guid userid = Guid.Parse(UserId); SocialProfilesRepository socialRepo = new SocialProfilesRepository(); List <Domain.Socioboard.Domain.SocialProfile> lstsocioprofile = socialRepo.getAllSocialProfilesOfUser(userid); List <profileConnected> lstProfile = new List <profileConnected>(); foreach (Domain.Socioboard.Domain.SocialProfile sp in lstsocioprofile) { profileConnected pc = new profileConnected(); pc.Id = sp.Id; pc.ProfileDate = sp.ProfileDate; pc.ProfileId = sp.ProfileId; pc.ProfileStatus = sp.ProfileStatus; pc.ProfileType = sp.ProfileType; pc.UserId = sp.UserId; if (sp.ProfileType == "facebook") { try { FacebookAccountRepository objFbAccRepo = new FacebookAccountRepository(); Domain.Socioboard.Domain.FacebookAccount objFbAcc = objFbAccRepo.getUserDetails(sp.ProfileId); pc.ProfileName = objFbAcc.FbUserName; pc.ProfileImgUrl = "http://graph.facebook.com/" + sp.ProfileId + "/picture?type=small"; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } else if (sp.ProfileType == "twitter") { try { TwitterAccountRepository objTwtAccRepo = new TwitterAccountRepository(); Domain.Socioboard.Domain.TwitterAccount objTwtAcc = objTwtAccRepo.getUserInfo(sp.ProfileId); pc.ProfileName = objTwtAcc.TwitterScreenName; pc.ProfileImgUrl = objTwtAcc.ProfileImageUrl; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } else if (sp.ProfileType == "instagram") { try { InstagramAccountRepository objInsAccRepo = new InstagramAccountRepository(); Domain.Socioboard.Domain.InstagramAccount objInsAcc = objInsAccRepo.getInstagramAccountById(sp.ProfileId); pc.ProfileName = objInsAcc.InsUserName; pc.ProfileImgUrl = objInsAcc.ProfileUrl; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } else if (sp.ProfileType == "linkedin") { try { LinkedInAccountRepository objLiAccRepo = new LinkedInAccountRepository(); Domain.Socioboard.Domain.LinkedInAccount objLiAcc = objLiAccRepo.getLinkedinAccountDetailsById(sp.ProfileId); pc.ProfileName = objLiAcc.LinkedinUserName; pc.ProfileImgUrl = objLiAcc.ProfileImageUrl; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } else if (sp.ProfileType == "googleplus") { try { GooglePlusAccountRepository objGpAccRepo = new GooglePlusAccountRepository(); Domain.Socioboard.Domain.GooglePlusAccount objGpAcc = objGpAccRepo.getUserDetails(sp.ProfileId); pc.ProfileName = objGpAcc.GpUserName; pc.ProfileImgUrl = objGpAcc.GpProfileImage; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } else if (sp.ProfileType == "tumblr") { try { TumblrAccountRepository objTumblrAccountRepository = new TumblrAccountRepository(); Domain.Socioboard.Domain.TumblrAccount objTumblrAccount = objTumblrAccountRepository.getTumblrAccountDetailsById(sp.ProfileId); pc.ProfileName = objTumblrAccount.tblrUserName; pc.ProfileImgUrl = objTumblrAccount.tblrProfilePicUrl; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } else if (sp.ProfileType == "youtube") { try { YoutubeAccountRepository objYoutubeAccountRepository = new YoutubeAccountRepository(); Domain.Socioboard.Domain.YoutubeAccount objYoutubeAccount = objYoutubeAccountRepository.getYoutubeAccountDetailsById(sp.ProfileId); pc.ProfileName = objYoutubeAccount.Ytusername; pc.ProfileImgUrl = objYoutubeAccount.Ytprofileimage; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } lstProfile.Add(pc); } return(new JavaScriptSerializer().Serialize(lstProfile)); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return(new JavaScriptSerializer().Serialize("Please Try Again")); } }
/// <getUserInfo> /// getUserAccount Information by profile id. /// </summary> /// <param name="profileid">Account profile id.(String)</param> /// <returns>Return the object of TwitterAccount class with value.(Domain.TwitterAccount)</returns> public Domain.Socioboard.Domain.TwitterAccount getUserInfo(string profileid) { //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 { try { //Proceed action, to get account details by profile id. NHibernate.IQuery query = session.CreateQuery("from TwitterAccount where TwitterUserId = :Twtuserid"); query.SetParameter("Twtuserid", profileid); Domain.Socioboard.Domain.TwitterAccount twtAccount = new Domain.Socioboard.Domain.TwitterAccount(); foreach (Domain.Socioboard.Domain.TwitterAccount item in query.Enumerable<Domain.Socioboard.Domain.TwitterAccount>()) { twtAccount = item; break; } return twtAccount; //TwitterAccount result= session.QueryOver<TwitterAccount>().Where(x => x.UserId == userid).And(x=>x.TwitterUserId == twtuserid).SingleOrDefault<TwitterAccount>(); //return result; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return null; } } catch { return null; } }//End Transaction }//End Session }
public Domain.Socioboard.Domain.TwitterAccount getUserInformation(string twtuserid) { //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 get account details by user id and twitter id. List<Domain.Socioboard.Domain.TwitterAccount> objlst = session.CreateQuery("from TwitterAccount where TwitterUserId = :Twtuserid") .SetParameter("Twtuserid", twtuserid) .List<Domain.Socioboard.Domain.TwitterAccount>().ToList<Domain.Socioboard.Domain.TwitterAccount>(); Domain.Socioboard.Domain.TwitterAccount result = new Domain.Socioboard.Domain.TwitterAccount(); if (objlst.Count > 0) { result = objlst[0]; } return result; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return null; } }//End Transaction }//End Session }
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; Users userinfo = new 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.Socioboard.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.Socioboard.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId)); Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile(); objTeamMemberProfile.Id = Guid.NewGuid(); objTeamMemberProfile.TeamId = objTeam.Id; objTeamMemberProfile.Status = 1; objTeamMemberProfile.ProfileType = "twitter"; objTeamMemberProfile.StatusUpdateDate = DateTime.Now; objTeamMemberProfile.ProfileId = objTwitterAccount.TwitterUserId; objTeamMemberProfile.ProfileName = objTwitterAccount.TwitterScreenName; objTeamMemberProfile.ProfilePicUrl = objTwitterAccount.ProfileImageUrl; objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile); #endregion #region SocialProfile Domain.Socioboard.Domain.SocialProfile objSocialProfile = new Domain.Socioboard.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.Socioboard.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 ret = "Account Added Successfully"; } else { ret = "Account already Exist !"; } } #region Add Twitter Messages twtuser = new TwitterUser(); try { TimeLine tl = new TimeLine(); JArray data = null; try { data = tl.Get_Statuses_Mentions_Timeline(OAuth); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); logger.Error("tl.Get_Statuses_Mentions_Timeline ex.StackTrace >> " + ex.StackTrace); logger.Error("tl.Get_Statuses_Mentions_Timeline ex.Message >> " + ex.Message); } objTwitterMessage = new Domain.Socioboard.Domain.TwitterMessage(); foreach (var item in data) { objTwitterMessage.UserId = Guid.Parse(UserId); objTwitterMessage.Type = "twt_mentions"; objTwitterMessage.Id = Guid.NewGuid(); try { objTwitterMessage.MessageId = item["id_str"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterMessage.MessageDate = Utility.ParseTwitterTime(item["created_at"].ToString().TrimStart('"').TrimEnd('"')); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterMessage.TwitterMsg = item["text"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterMessage.FromId = item["user"]["id_str"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterMessage.FromScreenName = item["user"]["screen_name"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterMessage.FromProfileUrl = item["user"]["profile_image_url"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterMessage.InReplyToStatusUserId = item["in_reply_to_status_id_str"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterMessage.SourceUrl = item["source"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterMessage.ProfileId = objTwitterAccount.TwitterUserId; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterMessage.ScreenName = item["user"]["screen_name"].ToString(); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterMessage.EntryDate = DateTime.Now; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } if (!objTwitterMessageRepository.checkTwitterMessageExists(objTwitterMessage.MessageId)) { objTwitterMessageRepository.addTwitterMessage(objTwitterMessage); } } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); logger.Error("tl.Get_Statuses_Mentions_Timeline ex.StackTrace >> " + ex.StackTrace); logger.Error("tl.Get_Statuses_Mentions_Timeline ex.Message >> " + ex.Message); } #endregion #region Add User Retweet twtuser = new TwitterUser(); try { JArray Retweet = null; try { Retweet = twtuser.GetStatuses_Retweet_Of_Me(OAuth); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); logger.Error("twtuser.GetStatuses_Retweet_Of_Me ex.StackTrace >> " + ex.StackTrace); logger.Error("twtuser.GetStatuses_Retweet_Of_Me ex.Message >> " + ex.Message); } objTwitterMessage = new Domain.Socioboard.Domain.TwitterMessage(); foreach (var item in Retweet) { objTwitterMessage.UserId = Guid.Parse(UserId); objTwitterMessage.Type = "twt_retweets"; objTwitterMessage.Id = Guid.NewGuid(); try { objTwitterMessage.MessageId = item["id_str"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterMessage.MessageDate = Utility.ParseTwitterTime(item["created_at"].ToString().TrimStart('"').TrimEnd('"')); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterMessage.TwitterMsg = item["text"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterMessage.FromId = item["user"]["id_str"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterMessage.FromScreenName = item["user"]["screen_name"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterMessage.FromProfileUrl = item["user"]["profile_image_url"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterMessage.InReplyToStatusUserId = item["in_reply_to_status_id_str"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterMessage.SourceUrl = item["source"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterMessage.ProfileId = objTwitterAccount.TwitterUserId; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterMessage.EntryDate = DateTime.Now; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } if (!objTwitterMessageRepository.checkTwitterMessageExists(objTwitterMessage.MessageId)) { objTwitterMessageRepository.addTwitterMessage(objTwitterMessage); } } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); logger.Error("twtuser.GetStatuses_Retweet_Of_Me ex.StackTrace >> " + ex.StackTrace); logger.Error("twtuser.GetStatuses_Retweet_Of_Me ex.Message >> " + ex.Message); } #endregion #region Add User Tweets try { JArray Timeline = twtuser.GetStatuses_User_Timeline(OAuth); TwitterMessageRepository twtmsgrepo = new TwitterMessageRepository(); TwitterMessage twtmsg = new TwitterMessage(); foreach (var item in Timeline) { objTwitterMessage.UserId = Guid.Parse(UserId); objTwitterMessage.Type = "twt_usertweets"; try { objTwitterMessage.TwitterMsg = item["text"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterMessage.SourceUrl = item["source"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterMessage.ScreenName = objTwitterAccount.TwitterScreenName; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterMessage.ProfileId = objTwitterAccount.TwitterUserId; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterMessage.MessageId = item["id_str"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterMessage.MessageDate = Utility.ParseTwitterTime(item["created_at"].ToString().TrimStart('"').TrimEnd('"')); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterMessage.InReplyToStatusUserId = item["in_reply_to_status_id_str"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterMessage.Id = Guid.NewGuid(); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterMessage.FromProfileUrl = item["user"]["profile_image_url"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterMessage.FromName = item["user"]["name"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterMessage.FromId = item["user"]["id_str"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } objTwitterMessage.EntryDate = DateTime.Now; try { objTwitterMessage.FromScreenName = item["user"]["screen_name"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } if (!objTwitterMessageRepository.checkTwitterMessageExists(objTwitterMessage.MessageId)) { objTwitterMessageRepository.addTwitterMessage(objTwitterMessage); } } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); logger.Error("twtuser.GetStatuses_User_Timeline ex.StackTrace >> " + ex.StackTrace); logger.Error("twtuser.GetStatuses_User_Timeline ex.Message >> " + ex.Message); } #endregion #region Add Twitter User Feed twtuser = new TwitterUser(); try { JArray Home_Timeline = twtuser.GetStatuses_Home_Timeline(OAuth); objTwitterFeed = new Domain.Socioboard.Domain.TwitterFeed(); foreach (var item in Home_Timeline) { objTwitterFeed.UserId = Guid.Parse(UserId); objTwitterFeed.Type = "twt_feeds"; try { objTwitterFeed.Feed = item["text"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterFeed.SourceUrl = item["source"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterFeed.ScreenName = objTwitterAccount.TwitterScreenName; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterFeed.ProfileId = objTwitterAccount.TwitterUserId; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterFeed.MessageId = item["id_str"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterFeed.FeedDate = Utility.ParseTwitterTime(item["created_at"].ToString().TrimStart('"').TrimEnd('"')); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterFeed.InReplyToStatusUserId = item["in_reply_to_status_id_str"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterFeed.Id = Guid.NewGuid(); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } <<<<<<< HEAD try { objTwitterFeed.FromProfileUrl = item["user"]["profile_image_url"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objTwitterFeed.FromName = item["user"]["name"].ToString().TrimStart('"').TrimEnd('"'); ======= try { objTwitterFeed.FromProfileUrl = item["user"]["profile_image_url"].ToString().TrimStart('"').TrimEnd('"'); >>>>>>> e052534b7a2a3744cad9dddbc3c6acccf394ca7b } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { <<<<<<< HEAD ======= objTwitterFeed.FromName = item["user"]["name"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { >>>>>>> e052534b7a2a3744cad9dddbc3c6acccf394ca7b objTwitterFeed.FromId = item["user"]["id_str"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } objTwitterFeed.EntryDate = DateTime.Now; try { objTwitterFeed.FromScreenName = item["user"]["screen_name"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } if (!objTwitterFeedRepository.checkTwitterFeedExists(objTwitterFeed.MessageId)) { try { objTwitterFeedRepository.addTwitterFeed(objTwitterFeed); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); } } // Edited by Antima[20/12/2014] SentimentalAnalysis _SentimentalAnalysis = new SentimentalAnalysis(); FeedSentimentalAnalysisRepository _FeedSentimentalAnalysisRepository = new FeedSentimentalAnalysisRepository(); try { if (_FeedSentimentalAnalysisRepository.checkFeedExists(objTwitterFeed.ProfileId.ToString(), Guid.Parse(UserId), objTwitterFeed.Id.ToString())) { if (!string.IsNullOrEmpty(objTwitterFeed.Feed)) { string Network = "twitter"; _SentimentalAnalysis.GetPostSentimentsFromUclassify(Guid.Parse(UserId), objTwitterFeed.ProfileId, objTwitterFeed.MessageId, objTwitterFeed.Feed, Network); } } } catch (Exception) { } } }
public ActionResult UpdateProfileDetails(string Network, string ProfileName) { if (Session["User"] != null) { Domain.Socioboard.Domain.User _User = (Domain.Socioboard.Domain.User)Session["User"]; if (_User.UserType != "SuperAdmin") { return(RedirectToAction("Index", "Index")); } } else { return(RedirectToAction("Index", "Index")); } string ReturnMessage = string.Empty; bool Status = false; if (Network == "Facebook") { Domain.Socioboard.Domain.FacebookAccount objfb = (FacebookAccount)Session["UpdateProfileData"]; objfb.IsActive = 1; objfb.FbUserName = ProfileName; string objFacebook = new JavaScriptSerializer().Serialize(objfb); Api.Facebook.Facebook ApiObjfb = new Api.Facebook.Facebook(); string FbMessage = (string)(new JavaScriptSerializer().Deserialize(ApiObjfb.UpdateFacebookAccountByAdmin(objFacebook), typeof(string))); ReturnMessage = FbMessage; } if (Network == "Twitter") { Status = true; Domain.Socioboard.Domain.TwitterAccount objfb = (TwitterAccount)Session["UpdateProfileData"]; objfb.IsActive = Status; objfb.TwitterScreenName = ProfileName; string objFacebook = new JavaScriptSerializer().Serialize(objfb); Api.Twitter.Twitter ApiObjfb = new Api.Twitter.Twitter(); string FbMessage = (string)(new JavaScriptSerializer().Deserialize(ApiObjfb.UpdateTwitterAccountByAdmin(objFacebook), typeof(string))); ReturnMessage = FbMessage; } if (Network == "Linkedin") { Status = true; Domain.Socioboard.Domain.LinkedInAccount objfb = (LinkedInAccount)Session["UpdateProfileData"]; objfb.IsActive = Status; objfb.LinkedinUserName = ProfileName; string objFacebook = new JavaScriptSerializer().Serialize(objfb); Api.Twitter.Twitter ApiObjfb = new Api.Twitter.Twitter(); string FbMessage = (string)(new JavaScriptSerializer().Deserialize(ApiObjfb.UpdateTwitterAccountByAdmin(objFacebook), typeof(string))); ReturnMessage = FbMessage; } if (Network == "Instagram") { Status = true; Domain.Socioboard.Domain.InstagramAccount objfb = (InstagramAccount)Session["UpdateProfileData"]; objfb.IsActive = Status; objfb.InsUserName = ProfileName; string objFacebook = new JavaScriptSerializer().Serialize(objfb); Api.Instagram.Instagram ApiObjfb = new Api.Instagram.Instagram(); string FbMessage = (string)(new JavaScriptSerializer().Deserialize(ApiObjfb.UpdateInstagramAccountByAdmin(objFacebook), typeof(string))); ReturnMessage = FbMessage; } //if (Network == "Tumblr") //{ // Status = true; // Domain.Socioboard.Domain.TwitterAccount objfb = (TwitterAccount)Session["UpdateProfileData"]; // objfb.IsActive = Status; // objfb.TwitterScreenName = ProfileName; // string objFacebook = new JavaScriptSerializer().Serialize(objfb); // Api.Twitter.Twitter ApiObjfb = new Api.Twitter.Twitter(); // string FbMessage = (string)(new JavaScriptSerializer().Deserialize(ApiObjfb.UpdateTwitterAccountByAdmin(objFacebook), typeof(string))); // ReturnMessage = FbMessage; //} if (Network == "Youtube") { Status = true; Domain.Socioboard.Domain.YoutubeAccount objfb = (YoutubeAccount)Session["UpdateProfileData"]; objfb.Isactive = 1; objfb.Ytusername = ProfileName; string objFacebook = new JavaScriptSerializer().Serialize(objfb); Api.Youtube.Youtube ApiObjfb = new Api.Youtube.Youtube(); string FbMessage = (string)(new JavaScriptSerializer().Deserialize(ApiObjfb.UpdateYouTubeAccountByAdmin(objFacebook), typeof(string))); ReturnMessage = FbMessage; } if (Network == "GooglePlus") { Status = true; Domain.Socioboard.Domain.GooglePlusAccount objfb = (GooglePlusAccount)Session["UpdateProfileData"]; objfb.IsActive = 1; objfb.GpUserName = ProfileName; string objFacebook = new JavaScriptSerializer().Serialize(objfb); Api.Twitter.Twitter ApiObjfb = new Api.Twitter.Twitter(); string FbMessage = (string)(new JavaScriptSerializer().Deserialize(ApiObjfb.UpdateTwitterAccountByAdmin(objFacebook), typeof(string))); ReturnMessage = FbMessage; } return(Content(ReturnMessage)); }
public string TwitterLogIn(string client_id, string client_secret, string redirect_uri, string requestToken, string requestSecret, string requestVerifier) { System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls; string ret = string.Empty; Users userinfo = new 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 >> TwitterLogIn >> Twitter profile : " + profile); } else { logger.Error("Twitter.asmx >> TwitterLogIn >> NULL Twitter profile : " + profile); } string TwitterUserId = string.Empty; objTwitterAccount = new Domain.Socioboard.Domain.TwitterAccount(); Domain.Socioboard.Domain.User objUser = new Domain.Socioboard.Domain.User(); foreach (var item in profile) { #region Login Twitter Account try { objUser.ProfileUrl = item["profile_image_url"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { TwitterUserId = item["id_str"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception er) { try { TwitterUserId = item["id"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { logger.Error(ex.StackTrace); } Console.WriteLine(er.StackTrace); } objUser.SocialLogin = "******" + TwitterUserId; try { objUser.UserName = item["name"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { logger.Error(ex.StackTrace); } #endregion } return new JavaScriptSerializer().Serialize(objUser); }
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; Users userinfo = new 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.Socioboard.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.Socioboard.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId)); Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile(); objTeamMemberProfile.Id = Guid.NewGuid(); objTeamMemberProfile.TeamId = objTeam.Id; objTeamMemberProfile.Status = 1; objTeamMemberProfile.ProfileType = "twitter"; objTeamMemberProfile.StatusUpdateDate = DateTime.Now; objTeamMemberProfile.ProfileId = objTwitterAccount.TwitterUserId; objTeamMemberProfile.ProfileName = objTwitterAccount.TwitterScreenName; objTeamMemberProfile.ProfilePicUrl = objTwitterAccount.ProfileImageUrl; objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile); #endregion #region SocialProfile Domain.Socioboard.Domain.SocialProfile objSocialProfile = new Domain.Socioboard.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.Socioboard.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.Socioboard.Domain.TwitterAccountFollowers objTwitterAccountFollowers = new Domain.Socioboard.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 ""; } }
private static async Task<ISocialSiteAccount> GetSocialAccountFromGroupProfile(Guid objUserid, Domain.Socioboard.Domain.GroupProfile objGroupProfile) { ISocialSiteAccount objSocialSiteAccount = null; string accesstoken = string.Empty; try { accesstoken = System.Web.HttpContext.Current.Session["access_token"].ToString(); } catch { } if (objGroupProfile.ProfileType == "facebook" || objGroupProfile.ProfileType == "facebook_page") { //using (Api.FacebookAccount.FacebookAccount ApiobjFacebookAccount = new Api.FacebookAccount.FacebookAccount()) //{ // ApiobjFacebookAccount.Timeout = 300000; // objSocialSiteAccount = (FacebookAccount)(new JavaScriptSerializer().Deserialize(ApiobjFacebookAccount.getFacebookAccountDetailsById(objUserid.ToString(), objGroupProfile.ProfileId.ToString()), typeof(FacebookAccount))); //} FacebookAccount fbaccount = new FacebookAccount(); HttpResponseMessage fbresponse = await WebApiReq.GetReq("api/ApiFacebookAccount/GetFacebookAcoount?ProfileId=" + objGroupProfile.ProfileId, "Bearer", accesstoken); if (fbresponse.IsSuccessStatusCode) { fbaccount = await fbresponse.Content.ReadAsAsync<Domain.Socioboard.Domain.FacebookAccount>(); objSocialSiteAccount = fbaccount; } } else if (objGroupProfile.ProfileType == "twitter") { //using (Api.TwitterAccount.TwitterAccount ApiobjTwitterAccount = new Api.TwitterAccount.TwitterAccount()) //{ // ApiobjTwitterAccount.Timeout = 300000; // objSocialSiteAccount = (TwitterAccount)(new JavaScriptSerializer().Deserialize(ApiobjTwitterAccount.GetTwitterAccountDetailsById(objUserid.ToString(), objGroupProfile.ProfileId.ToString()), typeof(TwitterAccount))); //} TwitterAccount twitterAcc = new TwitterAccount(); HttpResponseMessage twitterresponse = await WebApiReq.GetReq("api/ApiTwitterAccount/GetTwitterAccountDetailsById?ProfileId=" + objGroupProfile.ProfileId, "Bearer", accesstoken); if (twitterresponse.IsSuccessStatusCode) { twitterAcc = await twitterresponse.Content.ReadAsAsync<Domain.Socioboard.Domain.TwitterAccount>(); objSocialSiteAccount = twitterAcc; } } else if (objGroupProfile.ProfileType == "linkedin") { //using (Api.LinkedinAccount.LinkedinAccount ApiobjLinkedinAccount = new Api.LinkedinAccount.LinkedinAccount()) //{ // ApiobjLinkedinAccount.Timeout = 300000; // objSocialSiteAccount = (LinkedInAccount)(new JavaScriptSerializer().Deserialize(ApiobjLinkedinAccount.GetLinkedinAccountDetailsById(objUserid.ToString(), objGroupProfile.ProfileId.ToString()), typeof(LinkedInAccount))); //} LinkedInAccount LinkedinAcc = new LinkedInAccount(); HttpResponseMessage Linkedinresponse = await WebApiReq.GetReq("api/ApiLinkedinAccount/GetLinkedinAccountDetailsById?ProfileId=" + objGroupProfile.ProfileId, "Bearer", accesstoken); if (Linkedinresponse.IsSuccessStatusCode) { LinkedinAcc = await Linkedinresponse.Content.ReadAsAsync<Domain.Socioboard.Domain.LinkedInAccount>(); objSocialSiteAccount = LinkedinAcc; } } else if (objGroupProfile.ProfileType == "instagram") { //using (Api.InstagramAccount.InstagramAccount ApiobjInstagramAccount = new Api.InstagramAccount.InstagramAccount()) //{ // objSocialSiteAccount = (InstagramAccount)(new JavaScriptSerializer().Deserialize(ApiobjInstagramAccount.UserInformation(objUserid.ToString(), objGroupProfile.ProfileId.ToString()), typeof(InstagramAccount))); //} InstagramAccount instAcc = new InstagramAccount(); HttpResponseMessage response = await WebApiReq.GetReq("api/ApiInstagramAccount/GetInstagramAccount?ProfileId=" + objGroupProfile.ProfileId, "Bearer", accesstoken); if (response.IsSuccessStatusCode) { instAcc = await response.Content.ReadAsAsync<Domain.Socioboard.Domain.InstagramAccount>(); objSocialSiteAccount = instAcc; } } else if (objGroupProfile.ProfileType == "youtube") { //using (Api.YoutubeAccount.YoutubeAccount ApiobjYoutubeAccount = new Api.YoutubeAccount.YoutubeAccount()) //{ // ApiobjYoutubeAccount.Timeout = 300000; // objSocialSiteAccount = (YoutubeAccount)(new JavaScriptSerializer().Deserialize(ApiobjYoutubeAccount.GetYoutubeAccountDetailsById(objUserid.ToString(), objGroupProfile.ProfileId.ToString()), typeof(YoutubeAccount))); //} YoutubeAccount ytAcc = new YoutubeAccount(); HttpResponseMessage response = await WebApiReq.GetReq("api/ApiYoutubeAccount/GetYoutubeAccount?ProfileId=" + objGroupProfile.ProfileId, "Bearer", accesstoken); if (response.IsSuccessStatusCode) { ytAcc = await response.Content.ReadAsAsync<Domain.Socioboard.Domain.YoutubeAccount>(); objSocialSiteAccount = ytAcc; } } else if (objGroupProfile.ProfileType == "tumblr") { //using (Api.TumblrAccount.TumblrAccount ApiobjTumblrAccount = new Api.TumblrAccount.TumblrAccount()) //{ // ApiobjTumblrAccount.Timeout = 300000; // objSocialSiteAccount = (TumblrAccount)(new JavaScriptSerializer().Deserialize(ApiobjTumblrAccount.GetTumblrAccountDetailsById(objUserid.ToString(), objGroupProfile.ProfileId.ToString()), typeof(TumblrAccount))); //} TumblrAccount ytAcc = new TumblrAccount(); HttpResponseMessage response = await WebApiReq.GetReq("api/ApiTumblrAccount/GetTumblrAccountDetailsById?ProfileId=" + objGroupProfile.ProfileId, "Bearer", accesstoken); if (response.IsSuccessStatusCode) { ytAcc = await response.Content.ReadAsAsync<Domain.Socioboard.Domain.TumblrAccount>(); objSocialSiteAccount = ytAcc; } } else if (objGroupProfile.ProfileType == "linkedincompanypage") { //using (Api.LinkedinCompanyPage.LinkedinCompanyPage objLinkedinCompanyPage = new Api.LinkedinCompanyPage.LinkedinCompanyPage()) //{ // objLinkedinCompanyPage.Timeout = 300000; // objSocialSiteAccount = (LinkedinCompanyPage)(new JavaScriptSerializer().Deserialize(objLinkedinCompanyPage.GetLinkedinCompanyPageDetailsByUserIdAndPageId(objUserid.ToString(), objGroupProfile.ProfileId.ToString()), typeof(LinkedinCompanyPage))); //} LinkedinCompanyPage licompanypage = new LinkedinCompanyPage(); HttpResponseMessage response = await WebApiReq.GetReq("api/ApiLinkedinCompanyPage/GetLinkedinCompanyPageDetailsByUserIdAndPageId?ProfileId=" + objGroupProfile.ProfileId, "Bearer", accesstoken); if (response.IsSuccessStatusCode) { licompanypage = await response.Content.ReadAsAsync<Domain.Socioboard.Domain.LinkedinCompanyPage>(); objSocialSiteAccount = licompanypage; } } else if (objGroupProfile.ProfileType == "gplus") { //using (Api.GooglePlusAccount.GooglePlusAccount ApiobjGooglePlusAccount = new Api.GooglePlusAccount.GooglePlusAccount()) //{ // ApiobjGooglePlusAccount.Timeout = 300000; // objSocialSiteAccount = (GooglePlusAccount)(new JavaScriptSerializer().Deserialize(ApiobjGooglePlusAccount.GetGooglePlusAccountDetailsById(objUserid.ToString(), objGroupProfile.ProfileId), typeof(GooglePlusAccount))); //} GooglePlusAccount googlePlusAccount = new GooglePlusAccount(); HttpResponseMessage response = await WebApiReq.GetReq("api/ApiGooglePlusAccount/GetGooglePlusAccount?ProfileId=" + objGroupProfile.ProfileId, "Bearer", accesstoken); if (response.IsSuccessStatusCode) { googlePlusAccount = await response.Content.ReadAsAsync<Domain.Socioboard.Domain.GooglePlusAccount>(); objSocialSiteAccount = googlePlusAccount; } } else if (objGroupProfile.ProfileType == "googleanalytics") { //using (Api.GoogleAnalyticsAccount.GoogleAnalyticsAccount ApiobjGoogleAnalyticsAccount = new Api.GoogleAnalyticsAccount.GoogleAnalyticsAccount()) //{ // ApiobjGoogleAnalyticsAccount.Timeout = 300000; // objSocialSiteAccount = (GoogleAnalyticsAccount)(new JavaScriptSerializer().Deserialize(ApiobjGoogleAnalyticsAccount.GetGooglePlusAccountDetailsById(objUserid.ToString(), objGroupProfile.ProfileId), typeof(GoogleAnalyticsAccount))); //} GoogleAnalyticsAccount googlePlusAccount = new GoogleAnalyticsAccount(); HttpResponseMessage response = await WebApiReq.GetReq("api/ApiGoogleAnalyticsAccount/GetGooglePlusAccountDetailsById?ProfileId=" + objGroupProfile.ProfileId + "&UserId=" + objUserid.ToString(), "Bearer", accesstoken); if (response.IsSuccessStatusCode) { googlePlusAccount = await response.Content.ReadAsAsync<Domain.Socioboard.Domain.GoogleAnalyticsAccount>(); objSocialSiteAccount = googlePlusAccount; } } return objSocialSiteAccount; }