コード例 #1
0
        public string LinkedinComposeMessage(String message, String profileid, string userid, string currentdatetime, string picurl)
        {
            string ret = "";

            Domain.Socioboard.Domain.LinkedInAccount LinkedAccount = objLinkedInAccountRepository.getUserInformation(Guid.Parse(userid), profileid);
            oAuthLinkedIn Linkedin_oauth = new oAuthLinkedIn();

            Linkedin_oauth.Verifier    = LinkedAccount.OAuthVerifier;
            Linkedin_oauth.TokenSecret = LinkedAccount.OAuthSecret;
            Linkedin_oauth.Token       = LinkedAccount.OAuthToken;
            Linkedin_oauth.Id          = LinkedAccount.LinkedinUserId;
            Linkedin_oauth.FirstName   = LinkedAccount.LinkedinUserName;
            SocialStream sociostream = new SocialStream();

            if (!string.IsNullOrEmpty(picurl))
            {
                string res = sociostream.SetImageStatusUpdate(Linkedin_oauth, message, picurl);
            }
            else
            {
                string res = sociostream.SetStatusUpdate(Linkedin_oauth, message);
            }

            //string res = sociostream.SetStatusUpdate(Linkedin_oauth, message);
            return(ret);
        }
コード例 #2
0
 /// <updateLinkedinUser>
 /// Update Linkedin User account details.
 /// </summary>
 /// <param name="liaccount">Set Values in a LinkedInAccount Class Property and Pass the Object of LinkedInAccount Class (SocioBoard.Domain.LinkedInAccount).</param>
 public void updateLinkedinUser(Domain.Socioboard.Domain.LinkedInAccount liaccount)
 {
     using (NHibernate.ISession session = SessionFactory.GetNewSession())
     {
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             try
             {
                 session.CreateQuery("Update LinkedInAccount set LinkedinUserName =:LinkedinUserName,OAuthToken =:OAuthToken,OAuthSecret=:OAuthSecret,OAuthVerifier=:OAuthVerifier,EmailId=:EmailId,Connections=:Connections,ProfileUrl =:profileurl,ProfileImageUrl=:profilepicurl where LinkedinUserId = :LinkedinUserId and UserId = :UserId")
                 .SetParameter("LinkedinUserName", liaccount.LinkedinUserName)
                 .SetParameter("OAuthToken", liaccount.OAuthToken)
                 .SetParameter("OAuthSecret", liaccount.OAuthSecret)
                 .SetParameter("OAuthVerifier", liaccount.OAuthVerifier)
                 .SetParameter("EmailId", liaccount.EmailId)
                 .SetParameter("LinkedinUserId", liaccount.LinkedinUserId)
                 .SetParameter("UserId", liaccount.UserId)
                 .SetParameter("profileurl", liaccount.ProfileUrl)
                 .SetParameter("profilepicurl", liaccount.ProfileImageUrl)
                 .SetParameter("Connections", liaccount.Connections)
                 .ExecuteUpdate();
                 transaction.Commit();
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.StackTrace);
                 // return 0;
             }
         }
     }
 }
コード例 #3
0
 /// <getLinkedinAccountDetailsById>
 /// Get linkedin account details by id
 /// </summary>
 /// <param name="liuserid"></param>
 /// <returns>Return object of LinkedInAccount Class with  value of each member.(Domain.LinkedInAccount)</returns>
 public Domain.Socioboard.Domain.LinkedInAccount getLinkedinAccountDetailsById(string liuserid)
 {
     //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.
                 NHibernate.IQuery query = session.CreateQuery("from LinkedInAccount where LinkedinUserId = :userid");
                 query.SetParameter("userid", liuserid);
                 Domain.Socioboard.Domain.LinkedInAccount result = new Domain.Socioboard.Domain.LinkedInAccount();
                 foreach (Domain.Socioboard.Domain.LinkedInAccount item in query.Enumerable <Domain.Socioboard.Domain.LinkedInAccount>())
                 {
                     result = item;
                     break;
                 }
                 return(result);
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.Message);
                 return(null);
             }
         } //End Transaction
     }     //End Session
 }
コード例 #4
0
 /// <getUserInformation>
 /// Get user linkedin account information
 /// </summary>
 /// <param name="userid">User id (Guid)</param>
 /// <param name="liuserid">Linkedin account Id (String)</param>
 /// <returns>Return object of LinkedInAccount Class with  value of each member.(Domain.LinkedInAccount)</returns>
 public Domain.Socioboard.Domain.LinkedInAccount getUserInformation(Guid userid, string liuserid)
 {
     //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 details of account.
                 NHibernate.IQuery query = session.CreateQuery("from LinkedInAccount where LinkedinUserId = :LinkedinUserId And UserId=:UserId");
                 query.SetParameter("UserId", userid);
                 query.SetParameter("LinkedinUserId", liuserid);
                 Domain.Socioboard.Domain.LinkedInAccount result = query.UniqueResult <Domain.Socioboard.Domain.LinkedInAccount>();
                 return(result);
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.StackTrace);
                 return(null);
             }
         } //End Transaction
     }     //End Session
 }
コード例 #5
0
        public string getLinkedInData(string UserId, string LinkedinId)
        {
            string ret = string.Empty;

            try
            {
                Guid userId = Guid.Parse(UserId);
                //oAuthTwitter OAuth = new oAuthTwitter(ConfigurationManager.AppSettings["consumerKey"], ConfigurationManager.AppSettings["consumerSecret"], ConfigurationManager.AppSettings["callbackurl"]);

                oAuthLinkedIn Linkedin_Oauth = new oAuthLinkedIn();
                Linkedin_Oauth.ConsumerKey    = ConfigurationManager.AppSettings["LiApiKey"];
                Linkedin_Oauth.ConsumerSecret = ConfigurationManager.AppSettings["LiSecretKey"];
                LinkedInAccountRepository objLinkedInAccountRepository   = new LinkedInAccountRepository();
                Domain.Socioboard.Domain.LinkedInAccount LinkedinAccount = objLinkedInAccountRepository.getUserInformation(userId, LinkedinId);

                Linkedin_Oauth.Token       = LinkedinAccount.OAuthToken;
                Linkedin_Oauth.TokenSecret = LinkedinAccount.OAuthSecret;
                Linkedin_Oauth.Verifier    = LinkedinAccount.OAuthVerifier;
                GetUserProfile(Linkedin_Oauth, LinkedinAccount.LinkedinUserId, userId);
                GetLinkedInFeeds(Linkedin_Oauth, LinkedinId, userId);
                return("linkedin Info Updated");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }


            return(ret);
        }
コード例 #6
0
 public Domain.Socioboard.Domain.LinkedInAccount getUserInformation(string liuserid)
 {
     //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 details of account.
                 List <Domain.Socioboard.Domain.LinkedInAccount> objlst = session.CreateQuery("from LinkedInAccount where LinkedinUserId = :LinkedinUserId ")
                                                                          .SetParameter("LinkedinUserId", liuserid)
                                                                          .List <Domain.Socioboard.Domain.LinkedInAccount>().ToList <Domain.Socioboard.Domain.LinkedInAccount>();
                 Domain.Socioboard.Domain.LinkedInAccount result = new Domain.Socioboard.Domain.LinkedInAccount();
                 if (objlst.Count > 0)
                 {
                     result = objlst[0];
                 }
                 return(result);
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.StackTrace);
                 return(null);
             }
         } //End Transaction
     }     //End Session
 }
コード例 #7
0
        public IHttpActionResult LinkedInProfileUpdate(LinkedInManager LinkedInManager)
        {
            oAuthLinkedIn _oauth = new oAuthLinkedIn();
            string        json   = "";

            Domain.Socioboard.Domain.LinkedInAccount _LinkedinAccount = objLinkedInAccountRepository.getLinkedinAccountDetailsById(LinkedInManager.ProfileId);
            try
            {
                _oauth.ConsumerKey = ConfigurationManager.AppSettings["LinkedinApiKey"];
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                logger.Error(ex.Message);
            }

            try
            {
                _oauth.ConsumerSecret = ConfigurationManager.AppSettings["LinkedinSecretKey"];
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                logger.Error(ex.Message);
            }
            _oauth.Token = _LinkedinAccount.OAuthToken;
            string PostUrl = "https://api.linkedin.com/v1/people/~/shares?format=json";

            if (string.IsNullOrEmpty(LinkedInManager.ImageUrl))
            {
                json = _oauth.LinkedProfilePostWebRequest("POST", PostUrl, LinkedInManager.comment);
            }
            else
            {
                string imagepath = ConfigurationManager.AppSettings["DomainName"].ToString() + Regex.Split(LinkedInManager.ImageUrl, "wwwroot")[1].Replace("\\", "/");
                json = _oauth.LinkedProfilePostWebRequestWithImage("POST", PostUrl, LinkedInManager.comment, imagepath);
            }
            #region ScheduledMessage
            if (!string.IsNullOrEmpty(json))
            {
                objScheduledMessage.Id           = Guid.NewGuid();
                objScheduledMessage.PicUrl       = LinkedInManager.ImageUrl;
                objScheduledMessage.ProfileId    = LinkedInManager.ProfileId;
                objScheduledMessage.ProfileType  = "linkedin";
                objScheduledMessage.ScheduleTime = DateTime.Now;
                objScheduledMessage.ShareMessage = LinkedInManager.comment;
                objScheduledMessage.Status       = true;
                objScheduledMessage.UserId       = Guid.Parse(LinkedInManager.UserId);
                objScheduledMessage.CreateTime   = DateTime.Now;
                objScheduledMessage.ClientTime   = DateTime.Now;
                if (!objScheduledMessageRepository.checkMessageExistsAtTime(objScheduledMessage.UserId, objScheduledMessage.ScheduleTime))
                {
                    objScheduledMessageRepository.addNewMessage(objScheduledMessage);
                }
            }
            #endregion
            return(Ok());
        }
コード例 #8
0
        public string LinkedInScheduleUpdate(LinkedInManager LinkedInManager)
        {
            string json = "";

            if (LinkedInManager.ScheduleTime <= DateTime.Now)
            {
                oAuthLinkedIn _oauth = new oAuthLinkedIn();

                Domain.Socioboard.Domain.LinkedInAccount _LinkedinAccount = objLinkedInAccountRepository.getLinkedinAccountDetailsById(LinkedInManager.ProfileId);
                try
                {
                    _oauth.ConsumerKey = ConfigurationManager.AppSettings["LinkedinApiKey"];
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    logger.Error(ex.Message);
                }

                try
                {
                    _oauth.ConsumerSecret = ConfigurationManager.AppSettings["LinkedinSecretKey"];
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    logger.Error(ex.Message);
                }
                _oauth.Token = _LinkedinAccount.OAuthToken;
                string PostUrl = "https://api.linkedin.com/v1/people/~/shares?format=json";
                if (string.IsNullOrEmpty(LinkedInManager.ImageUrl))
                {
                    json = _oauth.LinkedProfilePostWebRequest("POST", PostUrl, LinkedInManager.comment);
                }
                else
                {
                    string imagepath = ConfigurationManager.AppSettings["DomainName"].ToString() + Regex.Split(LinkedInManager.ImageUrl, "wwwroot")[1].Replace("\\", "/");
                    json = _oauth.LinkedProfilePostWebRequestWithImage("POST", PostUrl, LinkedInManager.comment, imagepath);
                }
                if (!string.IsNullOrEmpty(json))
                {
                    json = "Message post on LinkedIn for Id :" + LinkedInManager.ProfileId + " and Message: " + LinkedInManager.comment;
                    objScheduledMessageRepository.UpdateScheduledMessage(Guid.Parse(LinkedInManager.ScheduleMessageId));
                }
                else
                {
                    json = "Something Went Wrong";
                }
            }

            return(json);
        }
コード例 #9
0
 public string UpdateLinkedinAccountByAdmin(string ObjLinkedin)
 {
     Domain.Socioboard.Domain.LinkedInAccount objLinkedinAccount = (Domain.Socioboard.Domain.LinkedInAccount)(new JavaScriptSerializer().Deserialize(ObjLinkedin, typeof(Domain.Socioboard.Domain.LinkedInAccount)));
     try
     {
         objLinkedInAccountRepository.updateLinkedinUser(objLinkedinAccount);
         return(new JavaScriptSerializer().Serialize("Update Successfully"));
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.StackTrace);
         return(new JavaScriptSerializer().Serialize("Something went Wrong"));
     }
 }
コード例 #10
0
 /// <addLinkedinUser>
 /// Add Linked in User
 /// </summary>
 /// <param name="linkedInAccount">Set Values in a LinkedInAccount Class Property and Pass the Object of LinkedInAccount Class (SocioBoard.Domain.LinkedInAccount).</param>
 public void addLinkedinUser(Domain.Socioboard.Domain.LinkedInAccount linkedInAccount)
 {
     //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(linkedInAccount);
             transaction.Commit();
         } //End Transaction
     }     //End Session
 }
コード例 #11
0
 public string GetLinkedinAccountDetailsById(string UserId, string LinkedinId)
 {
     try
     {
         Guid Userid = Guid.Parse(UserId);
         Domain.Socioboard.Domain.LinkedInAccount LinkedAccount = objlinkedinaccrepo.getUserInformation(Userid, LinkedinId);
         return(new JavaScriptSerializer().Serialize(LinkedAccount));
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.StackTrace);
         return(new JavaScriptSerializer().Serialize("Please Try Again"));
     }
 }
コード例 #12
0
        public string LinkedinProfileDetails(string Userid, string ProfileId)
        {
            Domain.Socioboard.Domain.LinkedInAccount objLinkedinAccount = new Domain.Socioboard.Domain.LinkedInAccount();
            LinkedInAccountRepository _objLinkedInAccountRepository     = new LinkedInAccountRepository();

            if (_objLinkedInAccountRepository.checkLinkedinUserExists(ProfileId, Guid.Parse(Userid)))
            {
                objLinkedinAccount = _objLinkedInAccountRepository.getUserInformation(Guid.Parse(Userid), ProfileId);
            }
            else
            {
                objLinkedinAccount = _objLinkedInAccountRepository.getUserInformation(ProfileId);
            }
            return(new JavaScriptSerializer().Serialize(objLinkedinAccount));
        }
コード例 #13
0
 public string GetLinkedinAccountDetailsById(string UserId, string LinkedinId)
 {
      Domain.Socioboard.Domain.LinkedInAccount LinkedAccount=new LinkedInAccount ();
     try
     {
         Guid Userid = Guid.Parse(UserId);
         if(objlinkedinaccrepo.checkLinkedinUserExists(LinkedinId,Userid))
         {
        LinkedAccount = objlinkedinaccrepo.getUserInformation(Userid, LinkedinId);
         }
         else
         {
             LinkedAccount=objlinkedinaccrepo.getUserInformation(LinkedinId);
         }
         return new JavaScriptSerializer().Serialize(LinkedAccount);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.StackTrace);
         return new JavaScriptSerializer().Serialize("Please Try Again");
     }
 }
コード例 #14
0
        public string AddLinkedinAccount(string oauth_token, string oauth_verifier, string reuqestTokenSecret, string consumerKey, string consumerSecret, string UserId, string GroupId)
        {
            try
            {
                logger.Error("AddLinkedinAccount()");
                string                      ret            = string.Empty;
                LinkedInProfile             objProfile     = new LinkedInProfile();
                LinkedInProfile.UserProfile objUserProfile = new LinkedInProfile.UserProfile();
                objSocialProfile = new Domain.Socioboard.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.Socioboard.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId));
                        objTeamMemberProfile                  = new Domain.Socioboard.Domain.TeamMemberProfile();
                        objTeamMemberProfile.Id               = Guid.NewGuid();
                        objTeamMemberProfile.TeamId           = objTeam.Id;
                        objTeamMemberProfile.Status           = 1;
                        objTeamMemberProfile.ProfileType      = "linkedin";
                        objTeamMemberProfile.StatusUpdateDate = DateTime.Now;
                        objTeamMemberProfile.ProfileId        = objLinkedInAccount.LinkedinUserId;
                    }
                    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.Socioboard.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;
                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex.StackTrace);
                        }
                        if (!objLinkedInFeedRepository.checkLinkedInFeedExists(objLinkedInFeed.FeedId, Guid.Parse(UserId)))
                        {
                            objLinkedInFeedRepository.addLinkedInFeed(objLinkedInFeed);
                        }
                    }
                    #endregion
                }
                catch (Exception ex)
                {
                    logger.Error(ex.StackTrace);
                }
                return("");
            }
            catch (Exception ex)
            {
                logger.Error(ex.StackTrace);
                return("");
            }
        }
コード例 #15
0
        public ActionResult UpdateProfileDetails(string Network, string ProfileName)
        {
            if (Session["User"] != null)
            {
                Domain.Socioboard.Domain.User _User = (Domain.Socioboard.Domain.User)Session["User"];
                if (_User.UserType != "SuperAdmin")
                {
                    return(RedirectToAction("Index", "Index"));
                }
            }
            else
            {
                return(RedirectToAction("Index", "Index"));
            }
            string ReturnMessage = string.Empty;
            bool   Status        = false;

            if (Network == "Facebook")
            {
                Domain.Socioboard.Domain.FacebookAccount objfb = (FacebookAccount)Session["UpdateProfileData"];
                objfb.IsActive   = 1;
                objfb.FbUserName = ProfileName;
                string objFacebook             = new JavaScriptSerializer().Serialize(objfb);
                Api.Facebook.Facebook ApiObjfb = new Api.Facebook.Facebook();
                string FbMessage = (string)(new JavaScriptSerializer().Deserialize(ApiObjfb.UpdateFacebookAccountByAdmin(objFacebook), typeof(string)));
                ReturnMessage = FbMessage;
            }
            if (Network == "Twitter")
            {
                Status = true;
                Domain.Socioboard.Domain.TwitterAccount objfb = (TwitterAccount)Session["UpdateProfileData"];
                objfb.IsActive          = Status;
                objfb.TwitterScreenName = ProfileName;
                string objFacebook           = new JavaScriptSerializer().Serialize(objfb);
                Api.Twitter.Twitter ApiObjfb = new Api.Twitter.Twitter();
                string FbMessage             = (string)(new JavaScriptSerializer().Deserialize(ApiObjfb.UpdateTwitterAccountByAdmin(objFacebook), typeof(string)));
                ReturnMessage = FbMessage;
            }
            if (Network == "Linkedin")
            {
                Status = true;
                Domain.Socioboard.Domain.LinkedInAccount objfb = (LinkedInAccount)Session["UpdateProfileData"];
                objfb.IsActive         = Status;
                objfb.LinkedinUserName = ProfileName;
                string objFacebook           = new JavaScriptSerializer().Serialize(objfb);
                Api.Twitter.Twitter ApiObjfb = new Api.Twitter.Twitter();
                string FbMessage             = (string)(new JavaScriptSerializer().Deserialize(ApiObjfb.UpdateTwitterAccountByAdmin(objFacebook), typeof(string)));
                ReturnMessage = FbMessage;
            }
            if (Network == "Instagram")
            {
                Status = true;
                Domain.Socioboard.Domain.InstagramAccount objfb = (InstagramAccount)Session["UpdateProfileData"];
                objfb.IsActive    = Status;
                objfb.InsUserName = ProfileName;
                string objFacebook = new JavaScriptSerializer().Serialize(objfb);
                Api.Instagram.Instagram ApiObjfb = new Api.Instagram.Instagram();
                string FbMessage = (string)(new JavaScriptSerializer().Deserialize(ApiObjfb.UpdateInstagramAccountByAdmin(objFacebook), typeof(string)));
                ReturnMessage = FbMessage;
            }
            //if (Network == "Tumblr")
            //{
            //    Status = true;
            //    Domain.Socioboard.Domain.TwitterAccount objfb = (TwitterAccount)Session["UpdateProfileData"];
            //    objfb.IsActive = Status;
            //    objfb.TwitterScreenName = ProfileName;
            //    string objFacebook = new JavaScriptSerializer().Serialize(objfb);
            //    Api.Twitter.Twitter ApiObjfb = new Api.Twitter.Twitter();
            //    string FbMessage = (string)(new JavaScriptSerializer().Deserialize(ApiObjfb.UpdateTwitterAccountByAdmin(objFacebook), typeof(string)));
            //    ReturnMessage = FbMessage;
            //}
            if (Network == "Youtube")
            {
                Status = true;
                Domain.Socioboard.Domain.YoutubeAccount objfb = (YoutubeAccount)Session["UpdateProfileData"];
                objfb.Isactive   = 1;
                objfb.Ytusername = ProfileName;
                string objFacebook           = new JavaScriptSerializer().Serialize(objfb);
                Api.Youtube.Youtube ApiObjfb = new Api.Youtube.Youtube();
                string FbMessage             = (string)(new JavaScriptSerializer().Deserialize(ApiObjfb.UpdateYouTubeAccountByAdmin(objFacebook), typeof(string)));
                ReturnMessage = FbMessage;
            }
            if (Network == "GooglePlus")
            {
                Status = true;
                Domain.Socioboard.Domain.GooglePlusAccount objfb = (GooglePlusAccount)Session["UpdateProfileData"];
                objfb.IsActive   = 1;
                objfb.GpUserName = ProfileName;
                string objFacebook           = new JavaScriptSerializer().Serialize(objfb);
                Api.Twitter.Twitter ApiObjfb = new Api.Twitter.Twitter();
                string FbMessage             = (string)(new JavaScriptSerializer().Deserialize(ApiObjfb.UpdateTwitterAccountByAdmin(objFacebook), typeof(string)));
                ReturnMessage = FbMessage;
            }
            return(Content(ReturnMessage));
        }
コード例 #16
0
         public void GetLinkedInUserProfile(dynamic data, oAuthLinkedIn _oauth, Guid user, string LinkedinUserId)
         {

             LinkedInAccount objLinkedInAccount = new LinkedInAccount();
             LinkedInAccountRepository objLiRepo = new LinkedInAccountRepository();
             try
             {
                 objLinkedInAccount.UserId = user;
                 objLinkedInAccount.LinkedinUserId = data.id.ToString();
                 try
                 {
                     objLinkedInAccount.EmailId = data.email.ToString();
                 }
                 catch { }
                 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 { }
                 try
                 {
                     objLinkedInAccount.ProfileUrl = data.profile_url.ToString();
                 }
                 catch (Exception ex)
                 {
                     Console.WriteLine(ex.StackTrace);
                 }
                 objLinkedInAccount.Connections = data.connections;
                 objLinkedInAccount.IsActive = true;
                 objLiRepo.updateLinkedinUser(objLinkedInAccount);
             }
             catch
             {
             }

         }
コード例 #17
0
        public string SheduleLinkedInMessage(string LinkedInId, string UserId, string sscheduledmsgguid)
        {
            string str = string.Empty;

            try
            {
                objScheduledMessage = objScheduledMessageRepository.GetScheduledMessageDetails(Guid.Parse(sscheduledmsgguid));
                objLinkedInAccount  = objLinkedInAccountRepository.getUserInformation(Guid.Parse(UserId), LinkedInId);

                oAuthLinkedIn Linkedin_oauth = new oAuthLinkedIn();
                Linkedin_oauth.ConsumerKey    = System.Configuration.ConfigurationSettings.AppSettings["LiApiKey"].ToString();
                Linkedin_oauth.ConsumerSecret = System.Configuration.ConfigurationSettings.AppSettings["LiSecretKey"].ToString();
                Linkedin_oauth.FirstName      = objLinkedInAccount.LinkedinUserName;
                Linkedin_oauth.Token          = objLinkedInAccount.OAuthToken;
                Linkedin_oauth.TokenSecret    = objLinkedInAccount.OAuthSecret;
                Linkedin_oauth.Verifier       = objLinkedInAccount.OAuthVerifier;
                if (objLinkedInAccount != null)
                {
                    try
                    {
                        GlobusLinkedinLib.App.Core.LinkedInUser linkeduser = new GlobusLinkedinLib.App.Core.LinkedInUser();

                        if (string.IsNullOrEmpty(objScheduledMessage.ShareMessage))
                        {
                            objScheduledMessage.ShareMessage = "There is no data in Share Message !";
                        }

                        var response = string.Empty;;
                        try
                        {
                            response = linkeduser.SetStatusUpdate(Linkedin_oauth, objScheduledMessage.ShareMessage);
                            str      = "Message post on linkedin for Id :" + objLinkedInAccount.LinkedinUserId + " and Message: " + objScheduledMessage.ShareMessage;
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }

                        if (string.IsNullOrEmpty(response))
                        {
                            ScheduledMessage schmsg = new ScheduledMessage();
                            schmsg.UpdateScheduledMessageByMsgId(Guid.Parse(sscheduledmsgguid));
                        }
                        else
                        {
                            str = "Message not posted";
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                }
                else
                {
                    str = "facebook account not found for id" + objScheduledMessage.ProfileId;
                }
            }

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

            return(str);
        }
コード例 #18
0
        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.Socioboard.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.Socioboard.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId));
                        objTeamMemberProfile = new Domain.Socioboard.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.Socioboard.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.Socioboard.Domain.LinkedIn_Update_Messages> lst_Messages = l.GetUserUpdateNew(_oauth, objLinkedInAccount.LinkedinUserId, 10);
                    foreach (var item_Messages in lst_Messages)
                    {
                        try
                        {
                            objLinkedInMessage = new Domain.Socioboard.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 "";
            }
        }
コード例 #19
0
 /// <getLinkedinAccountDetailsById>
 /// Get linkedin account details by id
 /// </summary>
 /// <param name="liuserid"></param>
 /// <returns>Return object of LinkedInAccount Class with  value of each member.(Domain.LinkedInAccount)</returns>
 public Domain.Socioboard.Domain.LinkedInAccount getLinkedinAccountDetailsById(string liuserid)
 {
     //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.
                 NHibernate.IQuery query = session.CreateQuery("from LinkedInAccount where LinkedinUserId = :userid");
                 query.SetParameter("userid", liuserid);
                 Domain.Socioboard.Domain.LinkedInAccount result = new Domain.Socioboard.Domain.LinkedInAccount();
                 foreach (Domain.Socioboard.Domain.LinkedInAccount item in query.Enumerable<Domain.Socioboard.Domain.LinkedInAccount>())
                 {
                     result = item;
                     break;
                 }
                 return result;
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.Message);
                 return null;
             }
         }//End Transaction
     }//End Session
 }
コード例 #20
0
 public string LinkedinProfileDetails(string Userid, string ProfileId)
 {
     Domain.Socioboard.Domain.LinkedInAccount objLinkedinAccount = new Domain.Socioboard.Domain.LinkedInAccount();
     LinkedInAccountRepository _objLinkedInAccountRepository = new LinkedInAccountRepository();
     if (_objLinkedInAccountRepository.checkLinkedinUserExists(ProfileId, Guid.Parse(Userid)))
     {
         objLinkedinAccount = _objLinkedInAccountRepository.getUserInformation(Guid.Parse(Userid), ProfileId);
     }
     else
     {
         objLinkedinAccount = _objLinkedInAccountRepository.getUserInformation(ProfileId);
     }
     return new JavaScriptSerializer().Serialize(objLinkedinAccount);
 }
コード例 #21
0
 public Domain.Socioboard.Domain.LinkedInAccount getUserInformation(string liuserid)
 {
     //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 details of account.
                 List<Domain.Socioboard.Domain.LinkedInAccount> objlst = session.CreateQuery("from LinkedInAccount where LinkedinUserId = :LinkedinUserId ")                    
                 .SetParameter("LinkedinUserId", liuserid)
                 .List<Domain.Socioboard.Domain.LinkedInAccount>().ToList<Domain.Socioboard.Domain.LinkedInAccount>();
                 Domain.Socioboard.Domain.LinkedInAccount result = new Domain.Socioboard.Domain.LinkedInAccount();
                 if (objlst.Count > 0)
                 {
                     result = objlst[0];
                 }
                 return result;
                
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.StackTrace);
                 return null;
             }
         }//End Transaction
     }//End Session
 }
コード例 #22
0
ファイル: User.asmx.cs プロジェクト: jalchr/socioboard
 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"));
     }
 }
コード例 #23
0
        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;
        }