/// <summary> /// This method returns LinkedIn list for specified userId /// </summary> /// <param name="userId">userId</param> /// <returns>Response string</returns> public string GetLinkedInListWithUserId(string userId) { string responseData = string.Empty; try { NameValueCollection nameValue = new NameValueCollection(); nameValue["userId"] = userId; string message = HelperMethods.GetParametersListForLogMessage(nameValue); HelperMethods.AddLogs("Enter into GetLinkedInListWithUserId. Parameters List => " + message); if (!string.IsNullOrEmpty(userId)) { OFunnelDatabaseHandler oFunnelDatabaseHandler = new OFunnelDatabaseHandler(); DataSet dataSet = oFunnelDatabaseHandler.GetLinkedInAccessTokenFromUserId("'" + userId + "'"); if (HelperMethods.IsValidDataSet(dataSet)) { string authToken = Convert.ToString(dataSet.Tables[0].Rows[0]["accessToken"]); if (!string.IsNullOrEmpty(authToken)) { // Create request to get profile from LinkedIn. string linkedInListUrl = this.CreateRequestToGetLinkedInListFromLinkedIn(authToken); if (!string.IsNullOrEmpty(linkedInListUrl)) { Int32 httpStatusCode = -1; Stream response = this.ExecuteRequestToGetResult(linkedInListUrl, ref httpStatusCode); if (response != null) { StreamReader streamReader = new StreamReader(response); responseData = streamReader.ReadToEnd(); response.Dispose(); } else { HelperMethods.AddLogs("GetLinkedInListWithUserId: LinkedIn connections response stream is null so LinkedIn connections not found for this user, either there is no connection for this user or some error occured."); } } } } else { HelperMethods.AddLogs(string.Format("GetLinkedInListWithUserId: Failed to get Access Token from database for userId = {0}.", userId)); } } else { HelperMethods.AddLogs("GetLinkedInListWithUserId: BadRequest as Required parameter {userId} is missing."); } } catch (Exception ex) { HelperMethods.AddLogs(string.Format("GetLinkedInListWithUserId: Failed to get LinkedIn connections from LinkedIn for userId = {0}. Exception Occured {1}", userId, ex.Message)); Debug.WriteLine("Failed to get LinkedIn Connections. Exception: " + ex.Message); } HelperMethods.AddLogs("Exit from GetLinkedInListWithUserId. \n\n"); return(responseData); }