leo
2023-08-19 ed40b3a565a0a52c3e98e47888c65e2df50eb9ea
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
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 string SendRequest(string url, string content, Encoding encoding)
        {
            try
            {
                HttpWebRequest request = (System.Net.HttpWebRequest)WebRequest.Create(url);
                request.Method = "POST";
                // 内容类型
                request.ContentType = "application/json";
                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 "";
            }
 
        }
 
        public List<ChinaStock> GetChinaStockList()
        {
            return _acc.GetChinaStockList();
        }
 
        public ChinaStockBasic GetChinaStockBasic(string Name)
        {
            return _acc.GetChinaStockBasic(Name);
        }
 
        //public List<ChinaStock> GetChinaStockDetail(string fullName)
        //{
        //    return _acc.GetChinaStockDetail(fullName);
        //}
 
 
        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);
        }
 
        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);
            //return javaMsgData;
        }
 
        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 GetSarchUrl = $"{URL}/IndustryStock/GetIndustryStockList";
            string Result = SendRequest(GetSarchUrl, Content, Encoding.UTF8);
            //JavaMsgData javaMsgData = JsonHelper.ToObject<JavaMsgData>(Result);
            return (JObject)JsonConvert.DeserializeObject(Result);
        }
 
 
 
    }
}