using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Net; using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; using CommonHelper; using GasolineBlend.DAL; using GasolineBlend.Entity; using Newtonsoft.Json; using Newtonsoft.Json.Linq; namespace GasolineBlend.BLL { public class ChinaStockBLL { private ChinaStockDAL _acc = new ChinaStockDAL(); public List GetChinaStockList() { return _acc.GetChinaStockList(); } public List GetChinaStockList(string SearchInfo) { return _acc.GetChinaStockList(SearchInfo); } //public ChinaStockBasic GetChinaStockBasic(string Name) //{ // return _acc.GetChinaStockBasic(Name); //} //public List GetChinaStockDetail(string fullName) //{ // return _acc.GetChinaStockDetail(fullName); //} public string SendRequest(string url, string content, Encoding encoding) { try { HttpWebRequest request = (System.Net.HttpWebRequest)WebRequest.Create(url); request.Method = "POST"; // 内容类型 request.ContentType = "application/json"; //request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.124 Safari/537.36 Edg/102.0.1245.44"; //request.Headers.Add("hexin-v", "A7V-DydvPAbIKFi6ykYGWU5hxDt2MmlEM-ZNmDfacSx7Dteh_4J5FMM2XWnE"); var payload = System.Text.Encoding.UTF8.GetBytes(content); request.ContentLength = payload.Length; Stream writer = request.GetRequestStream(); writer.Write(payload, 0, payload.Length); writer.Close(); System.Net.HttpWebResponse webResponse = (HttpWebResponse)request.GetResponse(); StreamReader sr = new StreamReader(webResponse.GetResponseStream(), encoding); return sr.ReadToEnd(); } catch (Exception e) { return "Error"; } } public object GetChinaStockDetail(int CompanyId, int ReportType, string TSCode, int Year) { string URL = Configs.GetValue("HYSiteUrl"); ChinaStockDetailPara chinaStockDetailPara = new ChinaStockDetailPara(); chinaStockDetailPara.ReportType = ReportType; chinaStockDetailPara.CompanyId = CompanyId; chinaStockDetailPara.TSCode = TSCode; chinaStockDetailPara.Year = Year; string Content = JsonHelper.ToJson(chinaStockDetailPara); string GetSarchUrl = $"{URL}/ChinaStock/GetChinaStockDetail"; string Result = SendRequest(GetSarchUrl, Content, Encoding.UTF8); //JavaMsgData javaMsgData = JsonHelper.ToObject(Result); return (JObject)JsonConvert.DeserializeObject(Result); } public object GetIndustryStockList(string SearchInfo, int ReportType) { string URL = Configs.GetValue("HYSiteUrl"); IndustryStockListPara industyStockListPara = new IndustryStockListPara(); industyStockListPara.SearchInfo = SearchInfo; industyStockListPara.ReportType = ReportType; string Content = JsonHelper.ToJson(industyStockListPara); string GetSearchUrl = $"{URL}/IndustryStock/GetIndustryStockList"; string Result = SendRequest(GetSearchUrl, Content, Encoding.UTF8); //JavaMsgData javaMsgData = JsonHelper.ToObject(Result); return (JObject)JsonConvert.DeserializeObject(Result); } //public object GetChinaStockList(string SearchInfo, int ReportType) //{ // string URL = Configs.GetValue("HYSiteUrl"); // ChinaStockListPara chinaStockListPara=new ChinaStockListPara(); // chinaStockListPara.SearchInfo = SearchInfo; // chinaStockListPara.ReportType = ReportType; // string Content = JsonHelper.ToJson(chinaStockListPara); // string GetSarchUrl = $"{URL}/ChinaStock/GetChinaStockList"; // string Result = SendRequest(GetSarchUrl, Content, Encoding.UTF8); // //JavaMsgData javaMsgData = JsonHelper.ToObject(Result); // return (JObject)JsonConvert.DeserializeObject(Result); //} } }