public Domain.Socioboard.Domain.LinkedinCompanyPage getCompanyPageInformation(Guid userid, string lipageid)
 {
     //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 LinkedinCompanyPage where LinkedinPageId = :LinkedinPageId And UserId=:UserId");
                 query.SetParameter("UserId", userid);
                 query.SetParameter("LinkedinPageId", lipageid);
                 Domain.Socioboard.Domain.LinkedinCompanyPage result = query.UniqueResult <Domain.Socioboard.Domain.LinkedinCompanyPage>();
                 return(result);
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.StackTrace);
                 return(null);
             }
         } //End Transaction
     }     //End Session
 }
        public string PutLikeOnLinkedinCompanyPageUpdate(string UserId, string PageId, string Updatekey, string IsLike)
        {
            try
            {
                string msg = string.Empty;

                int isLike = Convert.ToInt16(IsLike);

                if (isLike == 1)
                {
                    msg = "false";
                }
                else
                {
                    msg = "true";
                }

                Domain.Socioboard.Domain.LinkedinCompanyPage objlicompanypage = new Domain.Socioboard.Domain.LinkedinCompanyPage();
                objlicompanypage = objLinkedCmpnyPgeRepo.getCompanyPageInformation(PageId);
                oAuthLinkedIn Linkedin_oauth = new oAuthLinkedIn();
                Linkedin_oauth.Verifier    = objlicompanypage.OAuthVerifier;
                Linkedin_oauth.TokenSecret = objlicompanypage.OAuthSecret;
                Linkedin_oauth.Token       = objlicompanypage.OAuthToken;
                Linkedin_oauth.Id          = objlicompanypage.LinkedinPageId;
                Linkedin_oauth.FirstName   = objlicompanypage.LinkedinPageName;
                Company company = new Company();
                string  res     = company.SetLikeUpdateOnPagePost(Linkedin_oauth, Updatekey, msg);
                return(new JavaScriptSerializer().Serialize(res));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                return("Something Went Wrong");
            }
        }
 public Domain.Socioboard.Domain.LinkedinCompanyPage getCompanyPageInformation(string liPageid)
 {
     //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.LinkedinCompanyPage> objlst = session.CreateQuery("from LinkedinCompanyPage where LinkedinPageId = :linkedinpageid ")
                                                                              .SetParameter("linkedinpageid", liPageid)
                                                                              .List <Domain.Socioboard.Domain.LinkedinCompanyPage>().ToList <Domain.Socioboard.Domain.LinkedinCompanyPage>();
                 Domain.Socioboard.Domain.LinkedinCompanyPage result = new Domain.Socioboard.Domain.LinkedinCompanyPage();
                 if (objlst.Count > 0)
                 {
                     result = objlst[0];
                 }
                 return(result);
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.StackTrace);
                 return(null);
             }
         } //End Transaction
     }     //End Session
 }
 public void addLinkenCompanyPage(Domain.Socioboard.Domain.LinkedinCompanyPage linkedincompanypage)
 {
     //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(linkedincompanypage);
             transaction.Commit();
         } //End Transaction
     }     //End Session
 }
        public IHttpActionResult PsotCommentOnLinkedinCompanyPageUpdate(LinkedInManager LinkedInManager)
        {
            try
            {
                Domain.Socioboard.Domain.LinkedinCompanyPage objlicompanypage = new Domain.Socioboard.Domain.LinkedinCompanyPage();
                objlicompanypage = objLinkedCmpnyPgeRepo.getCompanyPageInformation(LinkedInManager.ProfileId);
                oAuthLinkedIn Linkedin_oauth = new oAuthLinkedIn();
                try
                {
                    Linkedin_oauth.ConsumerKey = ConfigurationManager.AppSettings["LinkedinApiKey"];
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }

                try
                {
                    Linkedin_oauth.ConsumerSecret = ConfigurationManager.AppSettings["LinkedinSecretKey"];
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                Linkedin_oauth.Verifier    = objlicompanypage.OAuthVerifier;
                Linkedin_oauth.TokenSecret = objlicompanypage.OAuthSecret;
                Linkedin_oauth.Token       = objlicompanypage.OAuthToken;
                Linkedin_oauth.Id          = objlicompanypage.LinkedinPageId;
                Linkedin_oauth.FirstName   = objlicompanypage.LinkedinPageName;
                Company company = new Company();
                string  res     = company.SetCommentOnPagePost(Linkedin_oauth, LinkedInManager.ProfileId, LinkedInManager.Updatekey, LinkedInManager.comment);
                if (res != "Failed")
                {
                    Domain.Socioboard.Domain.LinkedinCompanyPagePosts lipost = new LinkedinCompanyPagePosts();
                    lipost          = objLinkedinPagePostRepository.getCompanyPagPostInformation(LinkedInManager.Updatekey);
                    lipost.Comments = lipost.Comments + 1;
                    objLinkedinPagePostRepository.updateLinkedinPostCommentofPage(lipost);
                }
                string data = new JavaScriptSerializer().Serialize(res);
                return(Ok(data));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                return(Ok("Something Went Wrong"));
            }
        }
        public IHttpActionResult CreateUpdateOnLinkedinCompanyPage(LinkedInManager LinkedInManager)
        {
            try
            {
                Domain.Socioboard.Domain.LinkedinCompanyPage objlicompanypage = new Domain.Socioboard.Domain.LinkedinCompanyPage();
                objlicompanypage = objLinkedCmpnyPgeRepo.getCompanyPageInformation(LinkedInManager.ProfileId);
                oAuthLinkedIn Linkedin_oauth = new oAuthLinkedIn();
                try
                {
                    Linkedin_oauth.ConsumerKey = ConfigurationManager.AppSettings["LinkedinApiKey"];
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }

                try
                {
                    Linkedin_oauth.ConsumerSecret = ConfigurationManager.AppSettings["LinkedinSecretKey"];
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                Linkedin_oauth.Verifier    = objlicompanypage.OAuthVerifier;
                Linkedin_oauth.TokenSecret = objlicompanypage.OAuthSecret;
                Linkedin_oauth.Token       = objlicompanypage.OAuthToken;
                Linkedin_oauth.Id          = objlicompanypage.LinkedinPageId;
                Linkedin_oauth.FirstName   = objlicompanypage.LinkedinPageName;
                Company company = new Company();
                if (string.IsNullOrEmpty(LinkedInManager.ImageUrl))
                {
                    string res = company.SetPostOnPage(Linkedin_oauth, LinkedInManager.ProfileId, LinkedInManager.comment);
                }
                else
                {
                    string imagepath = ConfigurationManager.AppSettings["DomainName"].ToString() + Regex.Split(LinkedInManager.ImageUrl, "wwwroot")[1].Replace("\\", "/");
                    string resdata   = company.SetPostOnPageWithImage(Linkedin_oauth, LinkedInManager.ProfileId, imagepath, LinkedInManager.comment);
                }
                return(Ok());
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                return(Ok());
            }
        }
        public string UpdateLinkedInCompanyPage(LinkedInManager LinkedInManager)
        {
            oAuthLinkedIn _oauth = new oAuthLinkedIn();

            Domain.Socioboard.Domain.LinkedinCompanyPage _LinkedinCompanyPage = objLinkedCmpnyPgeRepo.getCompanyPageInformation(LinkedInManager.ProfileId);
            _oauth.ConsumerKey    = ConfigurationManager.AppSettings["LinkedinApiKey"];
            _oauth.ConsumerSecret = ConfigurationManager.AppSettings["LinkedinSecretKey"];
            _oauth.Verifier       = _LinkedinCompanyPage.OAuthVerifier;
            _oauth.TokenSecret    = _LinkedinCompanyPage.OAuthSecret;
            _oauth.Token          = _LinkedinCompanyPage.OAuthToken;
            _oauth.Id             = _LinkedinCompanyPage.LinkedinPageId;
            _oauth.FirstName      = _LinkedinCompanyPage.LinkedinPageName;
            GlobusLinkedinLib.App.Core.LinkedinCompanyPage objLinedInCmpnyPage = new GlobusLinkedinLib.App.Core.LinkedinCompanyPage();
            GlobusLinkedinLib.App.Core.LinkedinCompanyPage.CompanyProfile objCompanyProfile = new GlobusLinkedinLib.App.Core.LinkedinCompanyPage.CompanyProfile();
            objCompanyProfile = objLinedInCmpnyPage.GetCompanyPageProfile(_oauth, LinkedInManager.ProfileId);
            GetPageProfile(objCompanyProfile, _oauth, _LinkedinCompanyPage.UserId.ToString(), _LinkedinCompanyPage.LinkedinPageId, LinkedInManager.GroupId);
            GetLinkedinCompanyPageFeeds(_oauth, _LinkedinCompanyPage.UserId.ToString(), _LinkedinCompanyPage.LinkedinPageId);
            return("LinkedCompanyPageUpdated");
        }
 public void updateLinkedinPage(Domain.Socioboard.Domain.LinkedinCompanyPage linkedinPage)
 {
     using (NHibernate.ISession session = SessionFactory.GetNewSession())
     {
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             try
             {
                 session.CreateQuery("Update LinkedinCompanyPage set LinkedinPageName =:LinkedinPageName,EmailDomains =:EmailDomains,OAuthToken =:OAuthToken,OAuthSecret=:OAuthSecret,OAuthVerifier=:OAuthVerifier,Description=:Description,FoundedYear=:FoundedYear,EndYear =:EndYear,Locations=:Locations,Specialties=:Specialties,WebsiteUrl=:WebsiteUrl,Status=:Status,EmployeeCountRange=:EmployeeCountRange,Industries=:Industries,CompanyType=:CompanyType,LogoUrl=:LogoUrl,SquareLogoUrl=:SquareLogoUrl,BlogRssUrl=:BlogRssUrl,UniversalName=:UniversalName,NumFollowers=:NumFollowers where LinkedinPageId = :linkedinpageid and UserId = :UserId")
                 .SetParameter("LinkedinPageName", linkedinPage.LinkedinPageName)
                 .SetParameter("EmailDomains", linkedinPage.EmailDomains)
                 .SetParameter("OAuthToken", linkedinPage.OAuthToken)
                 .SetParameter("OAuthSecret", linkedinPage.OAuthSecret)
                 .SetParameter("OAuthVerifier", linkedinPage.OAuthVerifier)
                 .SetParameter("Description", linkedinPage.Description)
                 .SetParameter("FoundedYear", linkedinPage.FoundedYear)
                 .SetParameter("EndYear", linkedinPage.EndYear)
                 .SetParameter("Locations", linkedinPage.Locations)
                 .SetParameter("Specialties", linkedinPage.Specialties)
                 .SetParameter("WebsiteUrl", linkedinPage.WebsiteUrl)
                 .SetParameter("Status", linkedinPage.Status)
                 .SetParameter("EmployeeCountRange", linkedinPage.EmployeeCountRange)
                 .SetParameter("Industries", linkedinPage.Industries)
                 .SetParameter("CompanyType", linkedinPage.CompanyType)
                 .SetParameter("LogoUrl", linkedinPage.LogoUrl)
                 .SetParameter("SquareLogoUrl", linkedinPage.SquareLogoUrl)
                 .SetParameter("BlogRssUrl", linkedinPage.BlogRssUrl)
                 .SetParameter("UniversalName", linkedinPage.UniversalName)
                 .SetParameter("NumFollowers", linkedinPage.NumFollowers)
                 .SetParameter("linkedinpageid", linkedinPage.LinkedinPageId)
                 .SetParameter("UserId", linkedinPage.UserId)
                 .ExecuteUpdate();
                 transaction.Commit();
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.StackTrace);
                 // return 0;
             }
         }
     }
 }
 public string GetLinkedinCompanyPageDetailsByUserIdAndPageId(string UserId, string LinkedinPageId)
 {
     Domain.Socioboard.Domain.LinkedinCompanyPage LinkedinCompanyPage = new Domain.Socioboard.Domain.LinkedinCompanyPage();
     try
     {
         Guid Userid = Guid.Parse(UserId);
         if (objLinkedCmpnyPgeRepo.checkLinkedinPageExists(LinkedinPageId, Userid))
         {
             LinkedinCompanyPage = objLinkedCmpnyPgeRepo.getCompanyPageInformation(Userid, LinkedinPageId);
         }
         else
         {
             LinkedinCompanyPage = objLinkedCmpnyPgeRepo.getCompanyPageInformation(LinkedinPageId);
         }
         return(new JavaScriptSerializer().Serialize(LinkedinCompanyPage));
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.StackTrace);
         return(new JavaScriptSerializer().Serialize("Please Try Again"));
     }
 }
 public string PsotCommentOnLinkedinCompanyPageUpdate(string UserId, string PageId, string Updatekey, string Comment)
 {
     try
     {
         Domain.Socioboard.Domain.LinkedinCompanyPage objlicompanypage = new Domain.Socioboard.Domain.LinkedinCompanyPage();
         objlicompanypage = objLinkedCmpnyPgeRepo.getCompanyPageInformation(PageId);
         oAuthLinkedIn Linkedin_oauth = new oAuthLinkedIn();
         Linkedin_oauth.Verifier    = objlicompanypage.OAuthVerifier;
         Linkedin_oauth.TokenSecret = objlicompanypage.OAuthSecret;
         Linkedin_oauth.Token       = objlicompanypage.OAuthToken;
         Linkedin_oauth.Id          = objlicompanypage.LinkedinPageId;
         Linkedin_oauth.FirstName   = objlicompanypage.LinkedinPageName;
         Company company = new Company();
         string  res     = company.SetCommentOnPagePost(Linkedin_oauth, PageId, Updatekey, Comment);
         return(new JavaScriptSerializer().Serialize(res));
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.StackTrace);
         return("Something Went Wrong");
     }
 }
 public string GetLinkedinCompanyPageDetailsByUserIdAndPageId(string UserId, string LinkedinPageId)
 {
     Domain.Socioboard.Domain.LinkedinCompanyPage LinkedinCompanyPage=new Domain.Socioboard.Domain.LinkedinCompanyPage ();
     try
     {
         Guid Userid = Guid.Parse(UserId);
         if (objLinkedCmpnyPgeRepo.checkLinkedinPageExists(LinkedinPageId, Userid))
         {
             LinkedinCompanyPage = objLinkedCmpnyPgeRepo.getCompanyPageInformation(Userid, LinkedinPageId);
         }
         else
         {
             LinkedinCompanyPage = objLinkedCmpnyPgeRepo.getCompanyPageInformation(LinkedinPageId);
         }
         return new JavaScriptSerializer().Serialize(LinkedinCompanyPage);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.StackTrace);
         return new JavaScriptSerializer().Serialize("Please Try Again");
     }
 }
        public string PutLikeOnLinkedinCompanyPageUpdate(string UserId, string PageId, string Updatekey, string IsLike)
        {
            try
            {
                string msg = string.Empty;
                oAuthLinkedIn Linkedin_oauth = new oAuthLinkedIn();
                int isLike = Convert.ToInt16(IsLike);

                if (isLike == 1)
                {
                    msg = "false";
                }
                else
                { msg = "true"; }
                try
                {
                    Linkedin_oauth.ConsumerKey = ConfigurationManager.AppSettings["LinkedinApiKey"];
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }

                try
                {
                    Linkedin_oauth.ConsumerSecret = ConfigurationManager.AppSettings["LinkedinSecretKey"];
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }

                Domain.Socioboard.Domain.LinkedinCompanyPage objlicompanypage = new Domain.Socioboard.Domain.LinkedinCompanyPage();
                objlicompanypage = objLinkedCmpnyPgeRepo.getCompanyPageInformation(PageId);
                
                Linkedin_oauth.Verifier = objlicompanypage.OAuthVerifier;
                Linkedin_oauth.TokenSecret = objlicompanypage.OAuthSecret;
                Linkedin_oauth.Token = objlicompanypage.OAuthToken;
                Linkedin_oauth.Id = objlicompanypage.LinkedinPageId;
                Linkedin_oauth.FirstName = objlicompanypage.LinkedinPageName;
                Company company = new Company();
                string res = company.SetLikeUpdateOnPagePost(Linkedin_oauth, Updatekey, msg);
                return new JavaScriptSerializer().Serialize(res);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                return "Something Went Wrong";
            }

        }
        public void GetPageProfile(dynamic data, oAuthLinkedIn _OAuth, string UserId, string CompanyPageId, string GroupId)
        {
            Domain.Socioboard.Domain.SocialProfile socioprofile = new Domain.Socioboard.Domain.SocialProfile();
            SocialProfilesRepository socioprofilerepo = new SocialProfilesRepository();
            Domain.Socioboard.Domain.LinkedinCompanyPage objLinkedincmpnypage = new Domain.Socioboard.Domain.LinkedinCompanyPage();
            LinkedinCompanyPageRepository objLinkedCmpnyPgeRepo = new LinkedinCompanyPageRepository();
            Domain.Socioboard.Domain.GroupProfile grpProfile = new Domain.Socioboard.Domain.GroupProfile();

            try
            {
                objLinkedincmpnypage.UserId = Guid.Parse(UserId);
                try
                {
                    objLinkedincmpnypage.LinkedinPageId = data.Pageid.ToString();
                }
                catch
                {
                }
                objLinkedincmpnypage.Id = Guid.NewGuid();
                try
                {
                    objLinkedincmpnypage.EmailDomains = data.EmailDomains.ToString();
                }
                catch { }
                objLinkedincmpnypage.LinkedinPageName = data.name.ToString();
                objLinkedincmpnypage.OAuthToken = _OAuth.Token;
                objLinkedincmpnypage.OAuthSecret = _OAuth.TokenSecret;
                objLinkedincmpnypage.OAuthVerifier = _OAuth.Verifier;
                try
                {
                    objLinkedincmpnypage.Description = data.description.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.FoundedYear = data.founded_year.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.EndYear = data.end_year.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.Locations = data.locations.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.Specialties = data.Specialties.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.WebsiteUrl = data.website_url.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.Status = data.status.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.EmployeeCountRange = data.employee_count_range.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.Industries = data.industries.ToString();
                }
                catch { }
                try
                {
                    string NuberOfFollower = data.num_followers.ToString();
                    objLinkedincmpnypage.NumFollowers = Convert.ToInt16(NuberOfFollower);
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.CompanyType = data.company_type.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.LogoUrl = data.logo_url.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.SquareLogoUrl = data.square_logo_url.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.BlogRssUrl = data.blog_rss_url.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.UniversalName = data.universal_name.ToString();
                }
                catch { }
                #region SocialProfiles
                socioprofile.UserId = Guid.Parse(UserId);
                socioprofile.ProfileType = "linkedincompanypage";
                socioprofile.ProfileId = data.Pageid.ToString(); ;
                socioprofile.ProfileStatus = 1;
                socioprofile.ProfileDate = DateTime.Now;
                socioprofile.Id = Guid.NewGuid();
                #endregion

                #region TeamMemberProfile
                //Domain.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 = "linkedincompanypage";
                //objTeamMemberProfile.StatusUpdateDate = DateTime.Now;
                //objTeamMemberProfile.ProfileId = socioprofile.ProfileId;


                grpProfile.Id = Guid.NewGuid();
                grpProfile.EntryDate = DateTime.UtcNow;
                grpProfile.GroupId = Guid.Parse(GroupId);
                grpProfile.GroupOwnerId = Guid.Parse(UserId);
                grpProfile.ProfileId = socioprofile.ProfileId;
                grpProfile.ProfileType = "linkedincompanypage";
               // grpProfile.ProfilePic 
                #endregion
            }
            catch
            {
            }
            try
            {
                if (!objSocialProfilesRepository.checkUserProfileExist(socioprofile))
                {
                    objSocialProfilesRepository.addNewProfileForUser(socioprofile);
                }
                //if (!objTeamMemberProfileRepository.checkTeamMemberProfile(objTeamMemberProfile.TeamId, objLinkedincmpnypage.LinkedinPageId))
                //{
                //    objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile);
                //}
                if (!grpProfileRepo.checkProfileExistsingroup(Guid.Parse(GroupId), socioprofile.ProfileId))
                {
                    //    objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile);
                    grpProfileRepo.AddGroupProfile(grpProfile);

                }

                if (!objLinkedCmpnyPgeRepo.checkLinkedinPageExists(CompanyPageId, Guid.Parse(UserId)))
                {
                    objLinkedCmpnyPgeRepo.addLinkenCompanyPage(objLinkedincmpnypage);
                }
                else
                {
                    objLinkedincmpnypage.LinkedinPageId = CompanyPageId;
                    objLinkedCmpnyPgeRepo.updateLinkedinPage(objLinkedincmpnypage);
                }
            }
            catch
            {

            }

        }
        public Domain.Socioboard.Domain.LinkedinCompanyPage getCompanyPageInformation(string liPageid)
        {
            //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.LinkedinCompanyPage> objlst = session.CreateQuery("from LinkedinCompanyPage where LinkedinPageId = :linkedinpageid ")
                        .SetParameter("linkedinpageid", liPageid)
                        .List<Domain.Socioboard.Domain.LinkedinCompanyPage>().ToList<Domain.Socioboard.Domain.LinkedinCompanyPage>();
                        Domain.Socioboard.Domain.LinkedinCompanyPage result = new Domain.Socioboard.Domain.LinkedinCompanyPage();
                        if (objlst.Count > 0)
                        {
                            result = objlst[0];
                        }
                        return result;

                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                        return null;
                    }
                }//End Transaction
            }//End Session
        }
         public IHttpActionResult CreateUpdateOnLinkedinCompanyPage(LinkedInManager LinkedInManager)
         {
             try
             {
                 Domain.Socioboard.Domain.LinkedinCompanyPage objlicompanypage = new Domain.Socioboard.Domain.LinkedinCompanyPage();
                 objlicompanypage = objLinkedCmpnyPgeRepo.getCompanyPageInformation(LinkedInManager.ProfileId);
                 oAuthLinkedIn Linkedin_oauth = new oAuthLinkedIn();
                 try
                 {
                     Linkedin_oauth.ConsumerKey = ConfigurationManager.AppSettings["LinkedinApiKey"];
                 }
                 catch (Exception ex)
                 {
                     Console.WriteLine(ex.Message);
                 }

                 try
                 {
                     Linkedin_oauth.ConsumerSecret = ConfigurationManager.AppSettings["LinkedinSecretKey"];
                 }
                 catch (Exception ex)
                 {
                     Console.WriteLine(ex.Message);
                 }
                 Linkedin_oauth.Verifier = objlicompanypage.OAuthVerifier;
                 Linkedin_oauth.TokenSecret = objlicompanypage.OAuthSecret;
                 Linkedin_oauth.Token = objlicompanypage.OAuthToken;
                 Linkedin_oauth.Id = objlicompanypage.LinkedinPageId;
                 Linkedin_oauth.FirstName = objlicompanypage.LinkedinPageName;
                 Company company = new Company();
                 if (string.IsNullOrEmpty(LinkedInManager.ImageUrl))
                 {
                     string res = company.SetPostOnPage(Linkedin_oauth, LinkedInManager.ProfileId, LinkedInManager.comment);
                 }
                 else {
                     string imagepath = ConfigurationManager.AppSettings["DomainName"].ToString() + Regex.Split(LinkedInManager.ImageUrl, "wwwroot")[1].Replace("\\", "/");
                     string resdata = company.SetPostOnPageWithImage(Linkedin_oauth, LinkedInManager.ProfileId, imagepath, LinkedInManager.comment);
                 }
                 return Ok();
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.StackTrace);
                 return Ok();
             }

         }
        public IHttpActionResult PsotCommentOnLinkedinCompanyPageUpdate(LinkedInManager LinkedInManager)
        {
            try
            {
                Domain.Socioboard.Domain.LinkedinCompanyPage objlicompanypage = new Domain.Socioboard.Domain.LinkedinCompanyPage();
                objlicompanypage = objLinkedCmpnyPgeRepo.getCompanyPageInformation(LinkedInManager.ProfileId);
                oAuthLinkedIn Linkedin_oauth = new oAuthLinkedIn();
                try
                {
                    Linkedin_oauth.ConsumerKey = ConfigurationManager.AppSettings["LinkedinApiKey"];
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }

                try
                {
                    Linkedin_oauth.ConsumerSecret = ConfigurationManager.AppSettings["LinkedinSecretKey"];
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                Linkedin_oauth.Verifier = objlicompanypage.OAuthVerifier;
                Linkedin_oauth.TokenSecret = objlicompanypage.OAuthSecret;
                Linkedin_oauth.Token = objlicompanypage.OAuthToken;
                Linkedin_oauth.Id = objlicompanypage.LinkedinPageId;
                Linkedin_oauth.FirstName = objlicompanypage.LinkedinPageName;
                Company company = new Company();
                string res = company.SetCommentOnPagePost(Linkedin_oauth, LinkedInManager.ProfileId, LinkedInManager.Updatekey, LinkedInManager.comment);
                if (res != "Failed")
                {
                    Domain.Socioboard.Domain.LinkedinCompanyPagePosts lipost = new LinkedinCompanyPagePosts();
                    lipost = objLinkedinPagePostRepository.getCompanyPagPostInformation(LinkedInManager.Updatekey);
                    lipost.Comments = lipost.Comments + 1;
                    objLinkedinPagePostRepository.updateLinkedinPostCommentofPage(lipost);
                }
                string data= new JavaScriptSerializer().Serialize(res);
                return Ok(data);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                return Ok("Something Went Wrong");
            }

        }
        public string CreateUpdateOnLinkedinCompanyPage(string UserId, string PageId, string PostMessage)
        {
            try
            {
                Domain.Socioboard.Domain.LinkedinCompanyPage objlicompanypage = new Domain.Socioboard.Domain.LinkedinCompanyPage();
                objlicompanypage = objLinkedCmpnyPgeRepo.getCompanyPageInformation(PageId);
                oAuthLinkedIn Linkedin_oauth = new oAuthLinkedIn();
                Linkedin_oauth.Verifier = objlicompanypage.OAuthVerifier;
                Linkedin_oauth.TokenSecret = objlicompanypage.OAuthSecret;
                Linkedin_oauth.Token = objlicompanypage.OAuthToken;
                Linkedin_oauth.Id = objlicompanypage.LinkedinPageId;
                Linkedin_oauth.FirstName = objlicompanypage.LinkedinPageName;
                Company company = new Company();
                string res = company.SetPostOnPage(Linkedin_oauth, PageId, PostMessage);
                return new JavaScriptSerializer().Serialize(res);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                return "Something Went Wrong";
            }

        }
        public string PsotCommentOnLinkedinCompanyPageUpdate(string UserId, string PageId, string Updatekey, string Comment)
        {
            try
            {
                Domain.Socioboard.Domain.LinkedinCompanyPage objlicompanypage = new Domain.Socioboard.Domain.LinkedinCompanyPage();
                objlicompanypage = objLinkedCmpnyPgeRepo.getCompanyPageInformation(PageId);
                oAuthLinkedIn Linkedin_oauth = new oAuthLinkedIn();
                try
                {
                    Linkedin_oauth.ConsumerKey = ConfigurationManager.AppSettings["LinkedinApiKey"];
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }

                try
                {
                    Linkedin_oauth.ConsumerSecret = ConfigurationManager.AppSettings["LinkedinSecretKey"];
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                Linkedin_oauth.Verifier = objlicompanypage.OAuthVerifier;
                Linkedin_oauth.TokenSecret = objlicompanypage.OAuthSecret;
                Linkedin_oauth.Token = objlicompanypage.OAuthToken;
                Linkedin_oauth.Id = objlicompanypage.LinkedinPageId;
                Linkedin_oauth.FirstName = objlicompanypage.LinkedinPageName;
                Company company = new Company();
                string res = company.SetCommentOnPagePost(Linkedin_oauth, PageId, Updatekey, Comment);
                return new JavaScriptSerializer().Serialize(res);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                return "Something Went Wrong";
            }

        }
        public void GetPageProfile(dynamic data, oAuthLinkedIn _OAuth, string UserId, string CompanyPageId, string GroupId)
        {
            Domain.Socioboard.Domain.SocialProfile socioprofile = new Domain.Socioboard.Domain.SocialProfile();
            Domain.Socioboard.Domain.GroupProfile  grpProfile   = new Domain.Socioboard.Domain.GroupProfile();
            SocialProfilesRepository socioprofilerepo           = new SocialProfilesRepository();

            Domain.Socioboard.Domain.LinkedinCompanyPage objLinkedincmpnypage = new Domain.Socioboard.Domain.LinkedinCompanyPage();
            LinkedinCompanyPageRepository objLinkedCmpnyPgeRepo = new LinkedinCompanyPageRepository();

            try
            {
                objLinkedincmpnypage.UserId = Guid.Parse(UserId);
                try
                {
                    objLinkedincmpnypage.LinkedinPageId = data.Pageid.ToString();
                }
                catch
                {
                }
                objLinkedincmpnypage.Id = Guid.NewGuid();
                try
                {
                    objLinkedincmpnypage.EmailDomains = data.EmailDomains.ToString();
                }
                catch { }
                objLinkedincmpnypage.LinkedinPageName = data.name.ToString();
                objLinkedincmpnypage.OAuthToken       = _OAuth.Token;
                objLinkedincmpnypage.OAuthSecret      = _OAuth.TokenSecret;
                objLinkedincmpnypage.OAuthVerifier    = _OAuth.Verifier;
                try
                {
                    objLinkedincmpnypage.Description = data.description.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.FoundedYear = data.founded_year.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.EndYear = data.end_year.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.Locations = data.locations.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.Specialties = data.Specialties.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.WebsiteUrl = data.website_url.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.Status = data.status.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.EmployeeCountRange = data.employee_count_range.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.Industries = data.industries.ToString();
                }
                catch { }
                try
                {
                    string NuberOfFollower = data.num_followers.ToString();
                    objLinkedincmpnypage.NumFollowers = Convert.ToInt16(NuberOfFollower);
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.CompanyType = data.company_type.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.LogoUrl = data.logo_url.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.SquareLogoUrl = data.square_logo_url.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.BlogRssUrl = data.blog_rss_url.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.UniversalName = data.universal_name.ToString();
                }
                catch { }
                #region SocialProfiles
                socioprofile.UserId        = Guid.Parse(UserId);
                socioprofile.ProfileType   = "linkedincompanypage";
                socioprofile.ProfileId     = data.Pageid.ToString();;
                socioprofile.ProfileStatus = 1;
                socioprofile.ProfileDate   = DateTime.Now;
                socioprofile.Id            = Guid.NewGuid();
                #endregion

                #region TeamMemberProfile
                //Domain.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 = "linkedincompanypage";
                //objTeamMemberProfile.StatusUpdateDate = DateTime.Now;
                //objTeamMemberProfile.ProfileId = socioprofile.ProfileId;

                grpProfile.Id           = Guid.NewGuid();
                grpProfile.GroupId      = Guid.Parse(GroupId);
                grpProfile.GroupOwnerId = objLinkedincmpnypage.UserId;
                grpProfile.ProfileId    = objLinkedincmpnypage.LinkedinPageId;
                grpProfile.ProfileType  = "linkedincompanypage";
                grpProfile.ProfileName  = objLinkedincmpnypage.LinkedinPageName;
                grpProfile.EntryDate    = DateTime.UtcNow;

                #endregion
            }
            catch
            {
            }
            try
            {
                if (!objSocialProfilesRepository.checkUserProfileExist(socioprofile))
                {
                    objSocialProfilesRepository.addNewProfileForUser(socioprofile);
                    grpProfileRepo.AddGroupProfile(grpProfile);
                }
                if (!string.IsNullOrEmpty(GroupId))
                {
                    if (!objTeamMemberProfileRepository.checkTeamMemberProfile(objTeamMemberProfile.TeamId, objLinkedincmpnypage.LinkedinPageId))
                    {
                        objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile);
                    }
                }
                if (!objLinkedCmpnyPgeRepo.checkLinkedinPageExists(CompanyPageId, Guid.Parse(UserId)))
                {
                    objLinkedCmpnyPgeRepo.addLinkenCompanyPage(objLinkedincmpnypage);
                }
                else
                {
                    objLinkedincmpnypage.LinkedinPageId = CompanyPageId;
                    objLinkedCmpnyPgeRepo.updateLinkedinPage(objLinkedincmpnypage);
                }
            }
            catch
            {
            }
        }
示例#20
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;
        }