• Http post 接收 html .netcore


    /// <summary>
            /// 获取主证信息
            /// </summary>
            /// <param name="getDatas"></param>
            public void MainSyndrome(List<ProductionAndOperationLicenseEntity> getDatas)
            {
    
                //获取品种审定信息
                using (var db = DbFactory.DefaultDbContext())
                {
    
                    string baseUrl = config.MainSyndromeUrl + "SeedSearch/SeedSolution/Business/.ashx?Type=SLImpLicence&LicenceID={0}";
    
                    MainSyndromeRequest mainSyndromeReq = new MainSyndromeRequest();
                    POMainSyndromeEntity pOMainSyndrome = new POMainSyndromeEntity();
                    foreach (ProductionAndOperationLicenseEntity item in getDatas)
                    {
                        //用的postMan的方法
                        var client = new RestClient(string.Format(baseUrl, item.LicenceID));
                        client.Timeout = -1;
                        var request = new RestRequest(Method.POST);
                        IRestResponse response = client.Execute(request);
                        
                        //请求是否成功
                        if (response.StatusCode == HttpStatusCode.OK)
                        {
                            mainSyndromeReq = JsonConvert.DeserializeObject<MainSyndromeRequest>(response.Content);
                            if (mainSyndromeReq.Success)
                            {
                                MainSyndromeCharacterProcessing(mainSyndromeReq.ResultData);
                            }
                            //pOMainSyndromes.AddRange(response.Value.rows.ToString().ToEntity<List<SeedExportEntity>>());
                        }
    
                    }
                    
                }
    
            }
    
            public POMainSyndromeEntity MainSyndromeCharacterProcessing(string resultDataStr)
            {
                //字符替换
                resultDataStr = resultDataStr.Replace("
    ","");
                resultDataStr = resultDataStr.Replace("
    ","");
                resultDataStr = resultDataStr.Replace(" ","");
                resultDataStr = ReplaceHtmlTag(resultDataStr,"&");
                
                
                string[] resultStr = resultDataStr.Split('&');
                
                Dictionary<int, string> dic = new Dictionary<int, string>();
                int i = 0;
                foreach (var item in resultStr)
                {
                    dic.Add(i, item);
                    i++;
                }
    
                POMainSyndromeEntity pOMainSyndrome = new POMainSyndromeEntity();
                pOMainSyndrome.Residence = dic[18];
                pOMainSyndrome.LegalRepresentative = dic[2];
                pOMainSyndrome.ProductionAndManagementParadigm = dic[21];
                pOMainSyndrome.EffectiveArea = dic[21];
                pOMainSyndrome.UnifiedSocialCreditCode = dic[24];
                pOMainSyndrome.IssuingSuthority = dic[3];
                return pOMainSyndrome;
                
            }
    
            public static string ReplaceHtmlTag(string html,string intervalStr, int length = 0)
            {
                string strText = System.Text.RegularExpressions.Regex.Replace(html, "</[^>]+>", "!");
                strText = System.Text.RegularExpressions.Regex.Replace(strText, "<[^>]+>", "#");
                strText = System.Text.RegularExpressions.Regex.Replace(strText, "&[^;]+;", "");
                strText = System.Text.RegularExpressions.Regex.Replace(strText, "!#", intervalStr);
                strText = System.Text.RegularExpressions.Regex.Replace(strText, "#", "");
                strText = System.Text.RegularExpressions.Regex.Replace(strText, "!", "");
                
                if (length > 0 && strText.Length > length)
                    return strText.Substring(0, length);
    
                return strText;
            }
    
  • 相关阅读:
    我的ZigBee学习之路
    php form表单post提交获取不到数据,而使用get提交能获取到数据 的解决办法
    Mac phpstorm破解版安装(简单,有效)
    Mac下phpstorm 浏览器出现 502 bad gateway 解决办法
    LayUI之table数据表格获取行、行高亮等相关操作
    钉钉自定义机器人配合SVN钩子事件进行消息的推送实践
    电脑无故失去焦点,罪魁祸首是谁?终极解决办法
    Java实现的电脑已连接WiFi热点的导入导出小工具 wifi备份
    C# DataGridView自定义分页控件
    C# DataGridView控件禁止拷贝数据
  • 原文地址:https://www.cnblogs.com/dreamsails/p/12982400.html
Copyright © 2020-2023  润新知