admin
2023-12-13 471f85bc683af5e612b216b60301e217a704d8e5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
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<ChinaStock> GetChinaStockList()
        {
            return _acc.GetChinaStockList();
        }
 
        public List<ChinaStock> GetChinaStockList(string SearchInfo)
        {
            return _acc.GetChinaStockList(SearchInfo);
        }
 
        //public ChinaStockBasic GetChinaStockBasic(string Name)
        //{
        //    return _acc.GetChinaStockBasic(Name);
        //}
 
        //public List<ChinaStock> 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<JavaMsgData>(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<JavaMsgData>(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<JavaMsgData>(Result);
        //    return (JObject)JsonConvert.DeserializeObject(Result);
        //}
 
    }
}