public string PsotCommentOnLinkedinCompanyPageUpdate(string UserId, string PageId, string Updatekey, string Comment)
        {
            try
            {
                Domain.Myfashion.Domain.LinkedinCompanyPage objlicompanypage = new Domain.Myfashion.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 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.Myfashion.Domain.LinkedinCompanyPage objlicompanypage = new Domain.Myfashion.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 List<CompanyPageComment> GetPagePostscomment(oAuthLinkedIn OAuth, string updatekey,string PageId)
        {
            CompanyPageComment companypage_postcmnt = new CompanyPageComment();

            Company companyConnection = new Company();
            string CommentPageData = companyConnection.GetLinkedINCommentOnPagePost(OAuth, updatekey, PageId);
            var commentpost_data = JObject.Parse(CommentPageData);

            #region PagePostComment
            //xmlResult = companyConnection.GetCommentOnPagePost(OAuth, updatekey);

            //XmlNodeList xmlNodeList = xmlResult.GetElementsByTagName("update-comment");
            //foreach (XmlNode xn in xmlNodeList)
            //{

            //    try
            //    {
            //        XmlElement Element = (XmlElement)xn;



            //        try
            //        {
            //            companypage_postcmnt.Comment = Element.GetElementsByTagName("comment")[0].InnerText;
            //        }
            //        catch
            //        { }
            //        try
            //        {

            //            companypage_postcmnt.FirstName = Element.GetElementsByTagName("first-name")[0].InnerText;


            //        }
            //        catch
            //        {
            //            companypage_postcmnt.FirstName = Element.GetElementsByTagName("name")[0].InnerText;
            //        }
            //        try
            //        {
            //            companypage_postcmnt.LastName = Element.GetElementsByTagName("last-name")[0].InnerText;
            //        }
            //        catch
            //        {
            //            companypage_postcmnt.LastName = null;
            //        }

            //        try
            //        {
            //            double timestamp = Convert.ToDouble(Element.GetElementsByTagName("timestamp")[0].InnerText);
            //            companypage_postcmnt.CommentTime = JavaTimeStampToDateTime(timestamp);
            //        }
            //        catch
            //        {

            //        }
            //        try
            //        {
            //            companypage_postcmnt.PictureUrl = Element.GetElementsByTagName("picture-url")[0].InnerText;
            //        }
            //        catch
            //        {
            //            companypage_postcmnt.PictureUrl = null;
            //        }


            //        CompanyPagePostsList.Add(companypage_postcmnt);
            //    }
            //    catch { }
            //} 
            #endregion
            foreach (var item in commentpost_data["updateComments"]["values"])
            {
                  try
                    {
                        companypage_postcmnt.Comment = item["comment"].ToString();
                     }
                    catch
                    { }
                  try
                  {
                      companypage_postcmnt.FirstName = item["company"]["name"].ToString();
                  }
                  catch
                  { }
                  try
                  {
                      double timestamp = Convert.ToDouble(item["timestamp"].ToString());
                      companypage_postcmnt.CommentTime = JavaTimeStampToDateTime(timestamp);
                  }
                  catch
                  {

                  }
                  try
                  {
                      companypage_postcmnt.PictureUrl = commentpost_data["updateContent"]["companyStatusUpdate"]["share"]["content"]["thumbnailUrl"].ToString();
                  }
                  catch
                  {
                      companypage_postcmnt.PictureUrl = null;
                  }
                  CompanyPagePostsList.Add(companypage_postcmnt);
            }
            return CompanyPagePostsList;

        }
        /// <summary>
        /// Get The Linkedin Company Page Profile by Id
        /// </summary>
        /// <param name="OAuth"></param>
        /// <returns></returns>
        /// 
        //id,name,email-domains,description,founded-year,end-year,locations,Specialties,website-url,status,employee-count-range,industries,company-type,logo-url,square-logo-url,blog-rss-url,num-followers,universal-name
        public CompanyProfile GetCompanyPageProfile(oAuthLinkedIn oAuth, string CompanyPageId)
        {
            CompanyProfile CompanyProfile = new CompanyProfile();
            Company companyConnection = new Company();
            xmlResult = companyConnection.Get_CompanyProfileById(oAuth, CompanyPageId);
            XmlElement root = xmlResult.DocumentElement;


            try
            {
                CompanyProfile.Pageid = xmlResult.GetElementsByTagName("id")[0].InnerText;
            }
            catch { }

            try
            {
                CompanyProfile.name = xmlResult.GetElementsByTagName("name")[0].InnerText;
            }
            catch { }
            try
            {

                CompanyProfile.EmailDomains = xmlResult.GetElementsByTagName("email-domains")[0].InnerText;

            }
            catch
            { }

            try
            {
                CompanyProfile.description = xmlResult.GetElementsByTagName("description")[0].InnerText;
            }
            catch { }

            try
            {
                CompanyProfile.founded_year = xmlResult.GetElementsByTagName("founded-year")[0].InnerText;
            }
            catch { }


            try
            {
                CompanyProfile.end_year = xmlResult.GetElementsByTagName("end-year")[0].InnerText;
            }
            catch { }

            try
            {
                string location = string.Empty;
                string street1 = xmlResult.GetElementsByTagName("street1")[0].InnerText;
                string city = xmlResult.GetElementsByTagName("city")[0].InnerText;
                string postalcode = xmlResult.GetElementsByTagName("postal-code")[0].InnerText;
                string phone1 = xmlResult.GetElementsByTagName("phone1")[0].InnerText;
                string fax = xmlResult.GetElementsByTagName("fax")[0].InnerText;

                location += street1 + " " + city + " postal Code: " + postalcode + " Phone: " + phone1 + " Fax: " + fax;
                CompanyProfile.locations = location;
            }
            catch { }
            try
            {
                string Speciality = string.Empty;
                XmlNodeList xmlNodeList = xmlResult.GetElementsByTagName("specialties");
                foreach (XmlNode xn in xmlNodeList)
                {

                    try
                    {
                        XmlElement Element = (XmlElement)xn;
                        Speciality = Element.GetElementsByTagName("specialty")[0].InnerText;
                        Speciality += ",";
                    }
                    catch { }

                }

                Speciality = Speciality.Substring(0, Speciality.Length - 1);
                CompanyProfile.Specialties = Speciality;
            }
            catch { }

            try
            {
                CompanyProfile.website_url = xmlResult.GetElementsByTagName("website-url")[0].InnerText;
            }
            catch { }
            try
            {


                XmlNodeList xmlNodeList = xmlResult.GetElementsByTagName("status");
                foreach (XmlNode xn in xmlNodeList)
                {

                    try
                    {
                        XmlElement Element = (XmlElement)xn;
                        CompanyProfile.status = Element.GetElementsByTagName("name")[0].InnerText;
                    }
                    catch { }
                }
            }
            catch { }

            try
            {

                XmlNodeList xmlNodeList = xmlResult.GetElementsByTagName("employee-count-range");
                foreach (XmlNode xn in xmlNodeList)
                {

                    try
                    {
                        XmlElement Element = (XmlElement)xn;
                        CompanyProfile.employee_count_range = Element.GetElementsByTagName("name")[0].InnerText;
                    }
                    catch { }
                }
            }
            catch { }
            try
            {
                XmlNodeList xmlNodeList = xmlResult.GetElementsByTagName("industry");
                foreach (XmlNode xn in xmlNodeList)
                {

                    try
                    {
                        XmlElement Element = (XmlElement)xn;
                        CompanyProfile.industries = Element.GetElementsByTagName("name")[0].InnerText;
                    }
                    catch { }
                }
            }
            catch { }
            try
            {
                XmlNodeList xmlNodeList = xmlResult.GetElementsByTagName("company-type");
                foreach (XmlNode xn in xmlNodeList)
                {

                    try
                    {
                        XmlElement Element = (XmlElement)xn;
                        CompanyProfile.company_type = Element.GetElementsByTagName("name")[0].InnerText;
                    }
                    catch { }
                }

            }
            catch { }
            try
            {
                CompanyProfile.logo_url = xmlResult.GetElementsByTagName("logo-url")[0].InnerText;
            }
            catch { }
            try
            {
                CompanyProfile.square_logo_url = xmlResult.GetElementsByTagName("square-logo-url")[0].InnerText;
            }
            catch { }
            try
            {
                CompanyProfile.blog_rss_url = xmlResult.GetElementsByTagName("blog-rss-url")[0].InnerText;
            }
            catch { }
            try
            {
                CompanyProfile.num_followers = Convert.ToInt16(xmlResult.GetElementsByTagName("num-followers")[0].InnerText);
            }
            catch { }
            try
            {
                CompanyProfile.universal_name = xmlResult.GetElementsByTagName("universal-name")[0].InnerText;
            }
            catch { }







            return CompanyProfile;

        }
        public List<CompanyPagePosts> GetPagePosts(oAuthLinkedIn OAuth, string CompanyPageId)
        {
            CompanyPagePosts companypage_post = new CompanyPagePosts();

            Company companyConnection = new Company();
            xmlResult = companyConnection.Get_CompanyUpdateById(OAuth, CompanyPageId);

            XmlNodeList xmlNodeList = xmlResult.GetElementsByTagName("update");
            foreach (XmlNode xn in xmlNodeList)
            {

                try
                {
                    XmlElement Element = (XmlElement)xn;



                    try
                    {
                        companypage_post.Type = Element.GetElementsByTagName("update-type")[0].InnerText;
                    }
                    catch
                    { }
                    try
                    {
                        companypage_post.UpdateKey = Element.GetElementsByTagName("update-key")[0].InnerText;
                    }
                    catch
                    { }
                    try
                    {
                        companypage_post.PostId = Element.GetElementsByTagName("service-provider-share-id")[0].InnerText;
                    }
                    catch
                    {

                    }

                    try
                    {
                        double timestamp = Convert.ToDouble(Element.GetElementsByTagName("timestamp")[0].InnerText);
                        companypage_post.PostDate = JavaTimeStampToDateTime(timestamp);
                    }
                    catch
                    {

                    }
                    try
                    {
                        companypage_post.Posts = Element.GetElementsByTagName("comment")[0].InnerText;
                    }
                    catch
                    {

                    }
                    try
                    {
                        companypage_post.PostImageUrl = Element.GetElementsByTagName("shortened-url")[0].InnerText;
                    }
                    catch
                    {
                        companypage_post.PostImageUrl = null;
                    }

                    try
                    {
                        string likes = Element.GetElementsByTagName("num-likes")[0].InnerText;
                        companypage_post.Likes = Convert.ToInt16(likes);
                    }
                    catch
                    {
                    }
                    try
                    {
                        string cnt = string.Empty;
                        XmlElement numofcomments = xmlResult.DocumentElement;
                        if (numofcomments.HasAttribute("total"))
                        {
                            cnt = numofcomments.GetAttribute("total");
                        }
                        companypage_post.Comments = Convert.ToInt16(cnt);
                    }
                    catch
                    {
                    }



                    CompanyPagePostsList.Add(companypage_post);
                }
                catch { }
            }
            return CompanyPagePostsList;

        }
        public List<CompanyPageComment> GetPagePostscomment(oAuthLinkedIn OAuth, string updatekey)
        {
            CompanyPageComment companypage_postcmnt = new CompanyPageComment();

            Company companyConnection = new Company();
            xmlResult = companyConnection.GetCommentOnPagePost(OAuth, updatekey);

            XmlNodeList xmlNodeList = xmlResult.GetElementsByTagName("update-comment");
            foreach (XmlNode xn in xmlNodeList)
            {

                try
                {
                    XmlElement Element = (XmlElement)xn;



                    try
                    {
                        companypage_postcmnt.Comment = Element.GetElementsByTagName("comment")[0].InnerText;
                    }
                    catch
                    { }
                    try
                    {

                        companypage_postcmnt.FirstName = Element.GetElementsByTagName("first-name")[0].InnerText;


                    }
                    catch
                    {
                        companypage_postcmnt.FirstName = Element.GetElementsByTagName("name")[0].InnerText;
                    }
                    try
                    {
                        companypage_postcmnt.LastName = Element.GetElementsByTagName("last-name")[0].InnerText;
                    }
                    catch
                    {
                        companypage_postcmnt.LastName = null;
                    }

                    try
                    {
                        double timestamp = Convert.ToDouble(Element.GetElementsByTagName("timestamp")[0].InnerText);
                        companypage_postcmnt.CommentTime = JavaTimeStampToDateTime(timestamp);
                    }
                    catch
                    {

                    }
                    try
                    {
                        companypage_postcmnt.PictureUrl = Element.GetElementsByTagName("picture-url")[0].InnerText;
                    }
                    catch
                    {
                        companypage_postcmnt.PictureUrl = null;
                    }


                    CompanyPagePostsList.Add(companypage_postcmnt);
                }
                catch { }
            }
            return CompanyPagePostsList;

        }
        public CompanyPagePosts GetPostLike(oAuthLinkedIn OAuth, string UpdateKey, string PageId)
        {
            CompanyPagePosts objLicmpnypost = new CompanyPagePosts();
            Company companyConnection = new Company();
            xmlResult = companyConnection.GetLikeorNotOnPagePost(OAuth, UpdateKey, PageId);
            try
            {
                string like = xmlResult.GetElementsByTagName("is-liked")[0].InnerText;
                if (like == "true")
                {
                    objLicmpnypost.isLiked = 1;
                }
                else { objLicmpnypost.isLiked = 0; }

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
            return objLicmpnypost;
        }
         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 List<CompanyPagePosts> GetPagePosts(oAuthLinkedIn OAuth, string CompanyPageId)
        {
            CompanyPagePosts companypage_post = new CompanyPagePosts();
            Company companyConnection = new Company();

            string companyPageData = companyConnection.GetLinkedIN_CompanyUpdateById(OAuth, CompanyPageId);
            var Company_Data = JObject.Parse(companyPageData);
           #region XmlParsing
            //xmlResult = companyConnection.Get_CompanyUpdateById(OAuth, CompanyPageId);

            //XmlNodeList xmlNodeList = xmlResult.GetElementsByTagName("update");
            //foreach (XmlNode xn in xmlNodeList)
            //{

            //    try
            //    {
            //        XmlElement Element = (XmlElement)xn;



            //        try
            //        {
            //            companypage_post.Type = Element.GetElementsByTagName("update-type")[0].InnerText;
            //        }
            //        catch
            //        { }
            //        try
            //        {
            //            companypage_post.UpdateKey = Element.GetElementsByTagName("update-key")[0].InnerText;
            //        }
            //        catch
            //        { }
            //        try
            //        {
            //            companypage_post.PostId = Element.GetElementsByTagName("service-provider-share-id")[0].InnerText;
            //        }
            //        catch
            //        {

            //        }

            //        try
            //        {
            //            double timestamp = Convert.ToDouble(Element.GetElementsByTagName("timestamp")[0].InnerText);
            //            companypage_post.PostDate = JavaTimeStampToDateTime(timestamp);
            //        }
            //        catch
            //        {

            //        }
            //        try
            //        {
            //            companypage_post.Posts = Element.GetElementsByTagName("comment")[0].InnerText;
            //        }
            //        catch
            //        {

            //        }
            //        try
            //        {
            //            companypage_post.PostImageUrl = Element.GetElementsByTagName("shortened-url")[0].InnerText;
            //        }
            //        catch
            //        {
            //            companypage_post.PostImageUrl = null;
            //        }

            //        try
            //        {
            //            string likes = Element.GetElementsByTagName("num-likes")[0].InnerText;
            //            companypage_post.Likes = Convert.ToInt16(likes);
            //        }
            //        catch
            //        {
            //        }
            //        try
            //        {
            //            string cnt = string.Empty;
            //            XmlElement numofcomments = xmlResult.DocumentElement;
            //            if (numofcomments.HasAttribute("total"))
            //            {
            //                cnt = numofcomments.GetAttribute("total");
            //            }
            //            companypage_post.Comments = Convert.ToInt16(cnt);
            //        }
            //        catch
            //        {
            //        }



            //        CompanyPagePostsList.Add(companypage_post);
            //    }
            //    catch { }
            //} 
            #endregion

            foreach (var item in Company_Data["values"])
            {
                try
                {
                    companypage_post.Type = item["updateType"].ToString();
                       
                }
                catch
                { }
                try
                {
                    companypage_post.UpdateKey = item["updateKey"].ToString();

                }
                catch
                { }
                try
                {
                    companypage_post.PostId = item["updateContent"]["companyStatusUpdate"]["share"]["id"].ToString();

                }
                catch
                { }
                try
                {
                    companypage_post.Posts = item["updateContent"]["companyStatusUpdate"]["share"]["comment"].ToString();

                }
                catch
                { }
                try
                {
                    string datetime=item["updateContent"]["companyStatusUpdate"]["share"]["timestamp"].ToString();
                    companypage_post.PostDate = JavaTimeStampToDateTime(double.Parse(datetime));

                }
                catch
                { }
                try
                {
                    companypage_post.PostImageUrl = item["updateContent"]["companyStatusUpdate"]["share"]["content"]["thumbnailUrl"].ToString();

                }
                catch
                {
                    companypage_post.PostImageUrl = "";
                }
                try
                {
                    string likes = item["numLikes"].ToString();
                    companypage_post.Likes = Convert.ToInt16(likes);
                }
                catch
                {
                }
                try
                {
                    string url = "https://api.linkedin.com/v1/companies/" + CompanyPageId + "/updates/key=" + companypage_post.UpdateKey + "/update-comments?format=json";
                    string response = OAuth.APIWebRequest("GET", url, null);
                    var comment = JObject.Parse(response);
                    string Comments = comment["_total"].ToString();
                    companypage_post.Comments = Convert.ToInt16(Comments);
                }
                catch
                {
                }
                CompanyPagePostsList.Add(companypage_post);
            }
            return CompanyPagePostsList;

        }
        /// <summary>
        /// Get The Linkedin Company Page Profile by Id
        /// </summary>
        /// <param name="OAuth"></param>
        /// <returns></returns>
        /// 
        //id,name,email-domains,description,founded-year,end-year,locations,Specialties,website-url,status,employee-count-range,industries,company-type,logo-url,square-logo-url,blog-rss-url,num-followers,universal-name
        public CompanyProfile GetCompanyPageProfile(oAuthLinkedIn oAuth, string CompanyPageId)
        {
            CompanyProfile CompanyProfile = new CompanyProfile();
            Company companyConnection = new Company();
            //xmlResult = companyConnection.Get_CompanyProfileById(oAuth, CompanyPageId);
            //XmlElement root = xmlResult.DocumentElement;
            string linkedincmpydata = companyConnection.GetLinkedIN_CompanyProfileById(oAuth,CompanyPageId);
            var company_data = JObject.Parse(linkedincmpydata);

            try
            {
                //CompanyProfile.Pageid = xmlResult.GetElementsByTagName("id")[0].InnerText;
                CompanyProfile.Pageid = company_data["id"].ToString();
            }
            catch { }

            try
            {
                //CompanyProfile.name = xmlResult.GetElementsByTagName("name")[0].InnerText;
                CompanyProfile.name = company_data["name"].ToString();
            }
            catch { }
            try
            {

               // CompanyProfile.EmailDomains = xmlResult.GetElementsByTagName("email-domains")[0].InnerText;
                CompanyProfile.EmailDomains = company_data["emailDomains"]["values"][0].ToString();

            }
            catch
            { }

            try
            {
                //CompanyProfile.description = xmlResult.GetElementsByTagName("description")[0].InnerText;
                CompanyProfile.description = company_data["description"].ToString();
            }
            catch { }

            try
            {
                //CompanyProfile.founded_year = xmlResult.GetElementsByTagName("founded-year")[0].InnerText;
                CompanyProfile.founded_year = company_data["foundedYear"].ToString();
            }
            catch { }


            try
            {
                //CompanyProfile.end_year = xmlResult.GetElementsByTagName("end-year")[0].InnerText;
            }
            catch { }

            try
            {
                string location = string.Empty;
                //string street1 = xmlResult.GetElementsByTagName("street1")[0].InnerText;
                //string city = xmlResult.GetElementsByTagName("city")[0].InnerText;
                //string postalcode = xmlResult.GetElementsByTagName("postal-code")[0].InnerText;
                //string phone1 = xmlResult.GetElementsByTagName("phone1")[0].InnerText;
                //string fax = xmlResult.GetElementsByTagName("fax")[0].InnerText;
                string street1 = company_data["locations"]["values"][0]["address"]["street1"].ToString();
                string city = company_data["locations"]["values"][0]["address"]["city"].ToString();
                string postalCode = company_data["locations"]["values"][0]["address"]["postalCode"].ToString();
                string phone1 = company_data["locations"]["values"][0]["contactInfo"]["phone1"].ToString();
                string fax = company_data["locations"]["values"][0]["contactInfo"]["fax"].ToString();
                location += street1 + " " + city + " postal Code: " + postalCode + " Phone: " + phone1 + " Fax: " + fax;
                CompanyProfile.locations = location;
            }
            catch { }
            try
            {
                string Speciality = string.Empty;
                //XmlNodeList xmlNodeList = xmlResult.GetElementsByTagName("specialties");
                //foreach (XmlNode xn in xmlNodeList)
                //{

                //    try
                //    {
                //        XmlElement Element = (XmlElement)xn;
                //        Speciality = Element.GetElementsByTagName("specialty")[0].InnerText;
                //        Speciality += ",";
                //    }
                //    catch { }

                //}
                foreach (var item in company_data["specialties"]["values"])
                {
                    try
                    {
                        Speciality = item.ToString();
                        Speciality += ",";
                    }
                    catch { }
                }

                Speciality = Speciality.Substring(0, Speciality.Length - 1);
                CompanyProfile.Specialties = Speciality;
            }
            catch { }

            try
            {
                //CompanyProfile.website_url = xmlResult.GetElementsByTagName("website-url")[0].InnerText;
                CompanyProfile.website_url = company_data["websiteUrl"].ToString();
            }
            catch { }
            try
            {

                CompanyProfile.status = company_data["status"]["name"].ToString();
               
                //XmlNodeList xmlNodeList = xmlResult.GetElementsByTagName("status");
                //foreach (XmlNode xn in xmlNodeList)
                //{

                //    try
                //    {
                //        XmlElement Element = (XmlElement)xn;
                //        CompanyProfile.status = Element.GetElementsByTagName("name")[0].InnerText;
                //    }
                //    catch { }
                //}
            }
            catch { }

            try
            {

                CompanyProfile.employee_count_range = company_data["employeeCountRange"]["name"].ToString();
               
                //XmlNodeList xmlNodeList = xmlResult.GetElementsByTagName("employee-count-range");
                //foreach (XmlNode xn in xmlNodeList)
                //{

                //    try
                //    {
                //        XmlElement Element = (XmlElement)xn;
                //        CompanyProfile.employee_count_range = Element.GetElementsByTagName("name")[0].InnerText;
                //    }
                //    catch { }
                //}
            }
            catch { }
            try
            {
                foreach (var item in company_data["industries"]["values"])
                {
                    CompanyProfile.industries = item["name"].ToString();
                }
                //XmlNodeList xmlNodeList = xmlResult.GetElementsByTagName("industry");
                //foreach (XmlNode xn in xmlNodeList)
                //{

                //    try
                //    {
                //        XmlElement Element = (XmlElement)xn;
                //        CompanyProfile.industries = Element.GetElementsByTagName("name")[0].InnerText;
                //    }
                //    catch { }
                //}
            }
            catch { }
            try
            {


                CompanyProfile.company_type = company_data["companyType"]["name"].ToString();
              
                //XmlNodeList xmlNodeList = xmlResult.GetElementsByTagName("company-type");
                //foreach (XmlNode xn in xmlNodeList)
                //{

                //    try
                //    {
                //        XmlElement Element = (XmlElement)xn;
                //        CompanyProfile.company_type = Element.GetElementsByTagName("name")[0].InnerText;
                //    }
                //    catch { }
                //}

            }
            catch { }
            try
            {
               // CompanyProfile.logo_url = xmlResult.GetElementsByTagName("logo-url")[0].InnerText;
                CompanyProfile.logo_url = company_data["logoUrl"]. ToString();
            }
            catch { }
            try
            {
               // CompanyProfile.square_logo_url = xmlResult.GetElementsByTagName("square-logo-url")[0].InnerText;
                CompanyProfile.square_logo_url = company_data["square-logo-url"].ToString();
            }
            catch { }
            try
            {
                //CompanyProfile.blog_rss_url = xmlResult.GetElementsByTagName("blog-rss-url")[0].InnerText;
                CompanyProfile.blog_rss_url = company_data["blog-rss-url"].ToString();
            }
            catch { }
            try
            {
                //CompanyProfile.num_followers = Convert.ToInt16(xmlResult.GetElementsByTagName("num-followers")[0].InnerText);
                CompanyProfile.num_followers = Convert.ToInt16(company_data["numFollowers"].ToString());
            }
            catch { }
            try
            {
               // CompanyProfile.universal_name = xmlResult.GetElementsByTagName("universal-name")[0].InnerText;
                CompanyProfile.universal_name = company_data["universalName"].ToString();
            }
            catch { }







            return CompanyProfile;

        }