using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Models;
using System.Web.SessionState;
using System.Web.UI.WebControls;
using System.Web.Script.Serialization;
using System.Text;
using System.Data.Entity.Validation;
using System.Data;
using System.Configuration;
using System.Data.SqlClient;
using System.Net;
using System.Text.RegularExpressions;
using jmail;
using Security;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.IO;
using System.Runtime.Serialization.Json; /// <summary>
/// P2PScore 的摘要说明
/// </summary>
public class P2PScore : SessionGlobal
{
    
        string returnMenu = "调用失败";         CHKEntities chkEt = new CHKEntities();
        CSTEntities cstEt = new CSTEntities();
        SYSEntities sysEt = new SYSEntities();
        string appKey = System.Configuration.ConfigurationManager.AppSettings["appKey"] != null ? System.Configuration.ConfigurationManager.AppSettings["appKey"].Trim() : "";
        string uuid = System.Configuration.ConfigurationManager.AppSettings["uuId"] != null ? System.Configuration.ConfigurationManager.AppSettings["uuId"].Trim() : "";             //机构注册生成唯一标识码。
        string version = System.Configuration.ConfigurationManager.AppSettings["version"] != null ? System.Configuration.ConfigurationManager.AppSettings["version"].Trim() : "";//默认值 “1.0”
        #region 传入字段
        string phoneCode = "";  //手机设备码
        string phoneCodeType = "";//手机设备码类型
        string platform = "";  //手机系统
        string addressHome = "";  //家庭地址(详细)
        string addressCompany = "";   //公司地址(详细)
        string companyTel = "";
        string mobile = "";
        string month = "";                //贷款期限
        string realName = "";         //用户姓名或者机构编码
        string businessNumber = "";         //贷款编号
        string clientNumber = "";         //客户编号
        string idenCard = "";         //身份标识码( 可传输身份证后四位)。
        string gender = "";               //性别(1,男;2,女)
        string yearBorn = "";          //出生年份(YYYY-MM-DD)
        string house_hold_city = "";  //户籍所在地
        string localLive = "";            //本地居住时间(单位:年)
        string marriage = "";             //婚姻状态(1未婚;2已婚;3离异/丧偶/其他)
        string children = "";             //子女状态(1 无子女 2 有子女)
        string education = "";            //教育程度(1技校/中专/高中及以下;2大专;3本科;4硕士及以上) 
        string ssFund = "";               //社保状态(1-有 2-无) 
        string companyType = "";          //公司类型1、政府非企业类(政府机构/事业单位);2,国企央企;3,三资企业(台企、港企、外企);4,内资上市;5,内资非上市(民营/私营/普通);6,个体工商户;7,其他
        string industry = "";             //公司行业(1,批发/零售;2,制造业;3,金融/保险/证券;4,住宿/餐饮/旅游;5,商业服务/娱乐/艺术/体育;6,计算机/互联网;7,通信/电子;8,建筑/房地产;9,法律/咨询;10,卫生/教育/社会服务;11,国家机关/公共事业/科研/社会团体;12,生物/制药;13,广告/媒体;14,能源;15,贸易;16,交通运输/仓储/邮政/物流;17,农/林/牧/渔;18,其他)
        string creditCard = "";           //信用卡(1、有信用卡;2、无信用卡)
        string firstCardTime = "";     //首次信用卡开卡时间YYYY-MM-DD
        string totalLimit = "";           //信用卡总额度【xxx】元
        string cardOverdueCount = "";       //信用卡逾期次数单位 【xxx】次
        string cardOverdueDays = "";     //信用卡最长逾期天数
        string cardDebt = "";             // 信用卡负债 1、有信用卡负债2、无信用卡负债
        string isHasHouse = "";          //贷款本人名下房产(1-有2-无)
        string isDebtHouse = "";         //房贷-1-有房贷、2-无房贷
        string monthlyPayHouse = "";      //房贷月供【xxx】元
        string isHasCar = "";            //贷款本人名下车产1-有车产2-无车产
        string isDebtCar = "";            //车贷1-有车贷2-无车贷
        string monthlyPayCar = "";        //车贷月供【xxx】元
        string otherLoanMoneyTotal = "";  //其他贷款总额【xxx】元
        string otherLoanReturn = "";      //其他贷款月供【xxx】元
        string MD5 = "";              //根据报文体内容1到59字段累加做MD5加密。         #region 个人
        string work_city = "";        //工作城市  单位地址
        string currentOnboardTime = "";//本单位入职时间: YYYY-MM-DD   进入现公司时间
        string money = "";          //申请额度
        string salary = "";              //单位 元/月 ,实际到手工资 
        string salaryType = "";           //工资发放类型(1,每月打卡/转账工资;2,现金工
        #endregion         #region 企业
        string role = "";                 //公司所处角色1-法人2-股东
        string monthlyPrivateLiquid = "";     //公司月均对私流水【xx】元/月
        string monthlyPublicLiquid = "";   //公司月均对公流水【xx】元/月
        string companySize = "";          //公司规模【xx】人
        string companyAddressOperat_city = "";    //公司经营所在城市
        string companyAddress_city = "";          //公司注册地城市
        string registTime = "";                   //公司注册时间YYYY-MM-DD
        string businessLicense = "";              //公司营业执照1-有、2-无
        string creditCardCount = "";              //信用卡所属银行个数:如:3(个)
        string cardDebtMount = "";                //信用卡负债多少:如:[XX](元)
        string consultLoan = "";                  //有无咨询其他机构1.有2.无
        #endregion
        #region 违约需要字段
        string isOpen = "";   //公开程度
        string isNative = "";
        string liveCase = "";
        string liveJoin = "";  //共同居住者
        string compAddresProvince = "";
        string compJoinDate = "";
        string yearIncome = "";  //年收入
        string borrowType = "";
        string car = "";
        string house = "";
        string isCredit = ""; //是否有信用报告
        string creditLimit = "";//信用卡最高额度
        string creditCardAccount = ""; //信用卡账户数
        string sumLoan = "";    //贷款账户数
        string noCancellationAccount = ""; //未销户数量
        string overdueLoan = "";     //未结清贷款数
        string overdueCreditCardNum = "";   //发生过 90 天以上逾期的信用卡账户数
        string overdueLoanNum = "";   //发生过 90 天以上 逾期的 贷款账户 数
        string sumOneMonthOverdueCard = "";   //信用卡单月最高逾期总额
        string sumOneMonthOverdueLoan = "";   //贷款单月最高逾期总额
        string longOneMonthCard = "";         //信用卡单月最长逾期月数
        string longOneMonthLoan = "";         //贷款单月最长逾期月数
        string sixMonthAverageLimit = "";     //最近 6 个月平均使用额度
        string sixMonthAverageRepayment = ""; //最近 6 个月平均 应还款
        string totalNowMonthRepayCard = "";   //信用卡本 月应还 款汇总
        string totalNowMonthRepayLoan = "";   //贷款本月 应还款 汇总 
        string totalCreditLimit = "";         //授信额度/信用额度汇总
        string totalLoanMoney = "";           //贷款金额 汇总
        string totalUsedLimit = "";           //已使用额 度汇总
        string totalBalance = "";             //本金余额 汇总/贷款余额汇总
        string queryTimesOne = "";            //近一个月 查询次 数
        string cardAmountAvg = "";            //信用卡月均流水
        string maxReturnMoney = "";           //月供金额
        string nowAddressProvince = "";
        string isLegalPerson = "";
        string stockRatio = "";               //所占股份比例
        string palace = "";                   //经营场所
        string regDate = "";                  //公司注册时间
        string staffAmount = "";
        string publicAverage = "";            //企业资金平均流水
        #endregion
        #endregion
        public P2PScore()
    {
        //
        // TODO: 在此处添加构造函数逻辑
        //
    }     /// <summary>
    /// 调用评分接口公用方法返回评分结果
    /// </summary>
    /// <param name="lendifId">贷款id</param>
    /// <param name="cust_id">客户id</param>
    /// <param name="returnMenuBeizhu">返回值备注内容</param>
    /// <param name="Scoretype">接口类型,1:申请评分接口,2,反欺诈评分接口3,违约评分接口</param>
    /// <returns>评分结果</returns>
    public  string GetDockingScore(int lendId, int cust_id, out string returnMenuBeizhu, int Scoretype = )
    {
      
        returnMenuBeizhu = "";
        CHK_docking_score_request scorerequest = chkEt.CHK_docking_score_request.Where(a => a.lend_info_id == lendId).OrderByDescending(p => p.score_request_id).FirstOrDefault();
        if (scorerequest.IsNotNull())
        {
            string url = "";
            int jktupe = ;
            string buffer = "";
            #region 参数赋值
            CST_cust cust = cstEt.CST_cust.Find(cust_id);
            CST_person_info person = cstEt.CST_person_info.Find(cust_id);
            CHK_lend_info lendinfo = chkEt.CHK_lend_info.Find(lendId);
            if (lendinfo != null)
            {
                businessNumber = lendinfo.lend_no ?? "";         //贷款编号
                if (lendinfo.lend_month_math != null)
                    month = Convert.ToInt32(lendinfo.lend_month_math).ToString();
                money = Convert.ToDouble(lendinfo.lend_money ?? ).ToString("0.00");
                string type = lendinfo.Lend_use??"";
                if (type.Trim() != "")
                {
                    //贷款用途
                    if (type.IndexOf("装修") >= )
                        borrowType = "";
                    else if (type.IndexOf("经营") >= )
                        borrowType = "";
                    else if (type.IndexOf("购车") >= )
                        borrowType = "";
                    else
                        borrowType = "";
                }
            }
            if (scorerequest.phoneCode != null)
                phoneCode = scorerequest.phoneCode.ToString();
            if (scorerequest.phoneCodeType != null)
                phoneCodeType = scorerequest.phoneCodeType.ToString();
            if (scorerequest.phoneplatform != null)
                platform = scorerequest.phoneplatform.ToString();
            if (scorerequest.companyTel != null)
                companyTel = scorerequest.companyTel.ToString();
            if (person != null)
            {
                if (person.unit_type != null)
                    companyType = person.unit_type.ToString();
                if (person.person_industry != null)
                    industry = P2PTable.Getperson_industryId(person.person_industry ?? "");
                if (person.is_marit != null)
                    marriage = person.is_marit.ToString();
                if (person.person_sex != null)
                    gender = person.person_sex.ToString();
                if (person.brith_date != null)
                    yearBorn = Convert.ToDateTime(person.brith_date).ToString("yyyy-MM-dd");
                if (person.person_edu != null)
                    education = person.person_edu.ToString();
                if (person.clew_mob_tel != null)
                    mobile = person.clew_mob_tel.ToString();
                if (person.unit_time != null)
                {
                    currentOnboardTime = Convert.ToDateTime(person.unit_time).ToString("yyyy-MM-dd");
                }
                if (person.month_base_salary != null)
                    salary = Convert.ToInt32(person.month_base_salary).ToString();//实际到手工资
                if (person.domi_place != null )
                {
                    string domi_place=Convert.ToInt32(person.domi_place).ToString();
                    var ddlinfo=sysEt.SYS_ddl_info.Where(p=>p.item_value==domi_place && p.ddl_type_id== && p.item_name=="本地").FirstOrDefault();
                    isNative = ddlinfo !=null? "" : ""; //是否本地户口 1是 2否
                }
                if (person.live_state != null && person.live_state.Trim()!="")
                {
                    string live_state = person.live_state.ToString();//居住状况
                    if(live_state.IndexOf("按揭")>=)
                    liveCase = "";
                    else if(live_state.IndexOf("自置")>=)
                    liveCase = "";
                     else if(live_state.IndexOf("租房")>=)
                    liveCase = "";
                     else if(live_state.IndexOf("亲属楼宇")>=)
                    liveCase = "";
                     else if(live_state.IndexOf("集体宿舍")>=)
                    liveCase = "";
                   else
                    liveCase = "";
                }
               
            }
            if (scorerequest.localLive != null)
                localLive = scorerequest.localLive.ToString();
            if (scorerequest.total_credit_card != null)
                totalLimit = scorerequest.total_credit_card.ToString();
            if (scorerequest.late_credit_card != null)
                cardOverdueCount = scorerequest.late_credit_card.ToString();
            if (scorerequest.is_children_state != null)
                children = scorerequest.is_children_state.ToString();
            if (scorerequest.is_social_security != null)
                ssFund = scorerequest.is_social_security.ToString();
            if (scorerequest.wage_payment_type != null)
                salaryType = scorerequest.wage_payment_type.ToString();
            if (scorerequest.is_credit_card != null)
                creditCard = scorerequest.is_credit_card.ToString(); //dt.ToFileTime().ToString();//
            if (scorerequest.first_credit_card != null)
            {
                firstCardTime = Convert.ToDateTime(scorerequest.first_credit_card).ToString("yyyy-MM-dd");
            }
            if (scorerequest.overdue_credit_card != null)
                cardOverdueDays = scorerequest.overdue_credit_card.ToString();
            if (scorerequest.is_credit_card_debt != null)
                cardDebt = scorerequest.is_credit_card_debt.ToString();
            if (scorerequest.is_house_property != null)
                isHasHouse = scorerequest.is_house_property.ToString();
            if (scorerequest.is_mortgage != null)
                isDebtHouse = scorerequest.is_mortgage.ToString();
            if (scorerequest.mortgag_month != null)
                monthlyPayHouse = scorerequest.mortgag_month.ToString();
            if (scorerequest.is_car_production != null)
                isHasCar = scorerequest.is_car_production.ToString();
            if (scorerequest.car_loan != null)
                isDebtCar = scorerequest.car_loan.ToString();
            monthlyPayCar = scorerequest.car_loan_month.ToString();
            if (scorerequest.total_loans != null)
                otherLoanMoneyTotal = scorerequest.total_loans.ToString();
            if (scorerequest.other_loans_month != null)
                otherLoanReturn = scorerequest.other_loans_month.ToString();
            if (scorerequest.is_zxqtdkjg != null)
                consultLoan = scorerequest.is_zxqtdkjg.ToString();
            if (scorerequest.gs_scje != null)
                role = scorerequest.gs_scje.ToString();
            if (scorerequest.gs_yjdgls != null)
                monthlyPublicLiquid = scorerequest.gs_yjdgls.ToString();
            if (scorerequest.gs_yjdsls != null)
                monthlyPrivateLiquid = scorerequest.gs_yjdsls.ToString();
            if (scorerequest.gs_gm != null)
                companySize = scorerequest.gs_gm.ToString();
            companyAddress_city = GetcityName(scorerequest.gs_zcdcscity ?? "", );//公司地址(取值最后节点)
            house_hold_city = GetcityName(scorerequest.mess_addrcity ?? "", );//户籍所在地(取值最后节点)
            addressCompany = GetcityName(scorerequest.unit_addrcity ?? "", );//单位地址(取值全部节点)
            addressHome = GetcityName(scorerequest.mess_addrcity ?? "", );//户籍所在地(取值全部节点)
            compAddresProvince = GetcityName(scorerequest.unit_addrcity ?? "", );//单位地址(取值省节点)
            if (addressCompany.Trim() == "")
            {//企业贷时单位地址不为必填项,如果没填值  可取 公司经营地址
                addressCompany = GetcityName(scorerequest.operate_url ?? "", );//公司经营地址(取值全部节点)
                compAddresProvince = GetcityName(scorerequest.operate_url ?? "", );//单位地址(取值省节点)
            }
            nowAddressProvince = GetcityName(scorerequest.mess_addrcity ?? "", );//户籍所在地(取值省节点)
            work_city = GetcityName(scorerequest.unit_addrcity ?? "", );
            companyAddressOperat_city = GetcityName(Convert.ToString(scorerequest.operate_urlcity ?? ""), );
            if (scorerequest.gs_yyzz != null)
                businessLicense = scorerequest.gs_yyzz.ToString();
            if (scorerequest.bank_credit_card != null)
                creditCardCount = scorerequest.bank_credit_card.ToString();
            if (scorerequest.credit_liabilities != null)
                cardDebtMount = scorerequest.credit_liabilities.ToString();
            #region 违约需要字段
            isLegalPerson = role;//是否法人(望洲均为个人申请业务流程无法人)
            compJoinDate = currentOnboardTime;//入职日期
            
             if (scorerequest.is_car_production != null)
               car = scorerequest.is_car_production==?"":"";   //有无车产
            else
               car="-1";
            if (scorerequest.is_house_property != null)
               house = scorerequest.is_house_property==?"":"";   //有无房产
            else
               house="-1";
            if (scorerequest.creditLimit != null)
                creditLimit = scorerequest.creditLimit.ToString();   //信用卡最高额度
            if (scorerequest.gs_gm != null)
                staffAmount = scorerequest.gs_gm.ToString();   //公司规模人
            if (scorerequest.isOpen != null)
                isOpen = scorerequest.isOpen.ToString();   //公开程度
            if (scorerequest.liveJoin != null)
                liveJoin = scorerequest.liveJoin.ToString(); //共同居住者
            if (scorerequest.yearIncome != null)
                yearIncome = scorerequest.yearIncome.ToString(); //年收入
            if (scorerequest.isCredit != null)
                isCredit = scorerequest.isCredit.ToString();//是否有信用报告
            if (scorerequest.creditCardAccount != null)
                creditCardAccount = scorerequest.creditCardAccount.ToString();//信用卡账户数
            if (scorerequest.sumLoan != null)
                sumLoan = scorerequest.sumLoan.ToString();   //贷款账户数
            if (scorerequest.noCancellationAccount != null)
                noCancellationAccount = scorerequest.noCancellationAccount.ToString();//未销户数量
            if (scorerequest.overdueLoan != null)
                overdueLoan = scorerequest.overdueLoan.ToString();    //未结清贷款数
            if (scorerequest.overdueCreditCardNum != null)
                overdueCreditCardNum = scorerequest.overdueCreditCardNum.ToString();  //发生过 90 天以上逾期的信用卡账户数
            if (scorerequest.overdueLoanNum != null)
                overdueLoanNum = scorerequest.overdueLoanNum.ToString();  //发生过 90 天以上 逾期的 贷款账户 数
            if (scorerequest.sumOneMonthOverdueCard != null)
                sumOneMonthOverdueCard = scorerequest.sumOneMonthOverdueCard.ToString();  //信用卡单月最高逾期总额
            if (scorerequest.sumOneMonthOverdueLoan != null)
                sumOneMonthOverdueLoan = scorerequest.sumOneMonthOverdueLoan.ToString();  //贷款单月最高逾期总额
            if (scorerequest.longOneMonthCard != null)
                longOneMonthCard = scorerequest.longOneMonthCard.ToString();        //信用卡单月最长逾期月数
            if (scorerequest.longOneMonthLoan != null)
                longOneMonthLoan = scorerequest.longOneMonthLoan.ToString();        //贷款单月最长逾期月数
            if (scorerequest.sixMonthAverageLimit != null)
                sixMonthAverageLimit = scorerequest.sixMonthAverageLimit.ToString();    //最近 6 个月平均使用额度
            if (scorerequest.sixMonthAverageRepayment != null)
                sixMonthAverageRepayment = scorerequest.sixMonthAverageRepayment.ToString();//最近 6 个月平均 应还款
            if (scorerequest.totalNowMonthRepayCard != null)
                totalNowMonthRepayCard = scorerequest.totalNowMonthRepayCard.ToString();  //信用卡本 月应还 款汇总
            if (scorerequest.totalNowMonthRepayLoan != null)
                totalNowMonthRepayLoan = scorerequest.totalNowMonthRepayLoan.ToString();  //贷款本月 应还款 汇总 
            if (scorerequest.totalCreditLimit != null)
                totalCreditLimit = scorerequest.totalCreditLimit.ToString();        //授信额度/信用额度汇总
            if (scorerequest.totalLoanMoney != null)
                totalLoanMoney = scorerequest.totalLoanMoney.ToString();          //贷款金额 汇总
            if (scorerequest.totalUsedLimit != null)
                totalUsedLimit = scorerequest.totalUsedLimit.ToString();          //已使用额 度汇总
            if (scorerequest.totalBalance != null)
                totalBalance = scorerequest.totalBalance.ToString();            //本金余额 汇总/贷款余额汇总
            if (scorerequest.queryTimesOne != null)
                queryTimesOne = scorerequest.queryTimesOne.ToString();           //近一个月 查询次 数
            if (scorerequest.cardAmountAvg != null)
                cardAmountAvg = scorerequest.cardAmountAvg.ToString();           //信用卡月均流水
            if (scorerequest.maxReturnMoney != null)
                maxReturnMoney = scorerequest.maxReturnMoney.ToString();          //月供金额
            if (scorerequest.stockRatio != null)
                stockRatio = scorerequest.stockRatio.ToString();              //所占股份比例
            if (scorerequest.palace != null)
                palace = scorerequest.palace.ToString();                  //经营场所
            if (scorerequest.regDate != null)
                regDate = scorerequest.regDate.ToString("yyyy-MM-dd");                 //公司注册时间
            if (scorerequest.publicAverage != null)
                publicAverage = scorerequest.publicAverage.ToString();           //企业资金平均流水
            #endregion
            #endregion
            if (scorerequest.lend_biz_name != null)
            {
                if (scorerequest.lend_biz_name.IndexOf("望业贷") > - || scorerequest.lend_biz_name.IndexOf("生意贷") > -)
                    jktupe = ;
                else if (scorerequest.lend_biz_name.IndexOf("贷易贷") > - || scorerequest.lend_biz_name.IndexOf("贷易贷") > -)
                    jktupe = ;
            }
            if (cust != null)
            {
                realName = cust.cust_name ?? "";
                idenCard = cust.cret_code ?? "";
                //idenCard = DateTime.Now.ToString("yyyyMMddmmss") + fiverandomno();
                clientNumber = cust.cust_no ?? "";         //客户编号
            }
            JObject jo2 = new JObject();
            switch (Scoretype)
            {
                case :
                    #region 申请评分接口
                    if (jktupe != )
                    {
                        #region 个人申请评分
                        url = System.Configuration.ConfigurationManager.AppSettings["PersonalIF"] != null ? System.Configuration.ConfigurationManager.AppSettings["PersonalIF"].Trim() : "";
                        //类赋值处理用于序列化
                        jsonPersonclass personclass = jsonGRSQPFBind(appKey, uuid, version, month, realName, businessNumber,clientNumber, idenCard, gender, yearBorn, house_hold_city, localLive, marriage, children, education, ssFund, companyType, industry, creditCard, firstCardTime, totalLimit, cardOverdueCount, cardOverdueDays, cardDebt, isHasHouse, isDebtHouse, monthlyPayHouse, isHasCar, isDebtCar, monthlyPayCar, otherLoanMoneyTotal, otherLoanReturn, work_city, currentOnboardTime, money, salary, salaryType, consultLoan);
                       //类json序列化为string
                        buffer = JsonConvert.SerializeObject(personclass);
                        #endregion
                    }
                    else if (jktupe == )
                    {
                        #region 企业申请评分
                        if (companyType.Trim() != "")
                        {
                            if (companyType == "")
                                companyType = "";
                            else if (companyType == "")
                                companyType = "";
                            else
                                companyType = "";
                        }
                        CST_relevance_person relevance_person = cstEt.CST_relevance_person.Where(p => p.person_info_id == cust_id).FirstOrDefault();
                        if (relevance_person != null)
                        {
                            if (relevance_person.build_date != null)
                                registTime = Convert.ToDateTime(relevance_person.build_date).ToString("yyyy-MM-dd");
                        }
                        url = System.Configuration.ConfigurationManager.AppSettings["EnterpriseIF"] != null ? System.Configuration.ConfigurationManager.AppSettings["EnterpriseIF"].Trim() : "";
                        //类赋值处理用于序列化
                        Enterprise enterprise = jsonQYSQPFBind(appKey, uuid, version, month, realName, businessNumber, clientNumber, idenCard, gender, yearBorn, house_hold_city, marriage, children, education, ssFund, companyType, industry, creditCard, firstCardTime, totalLimit, cardOverdueCount, cardOverdueDays, cardDebt, isHasHouse, isDebtHouse, monthlyPayHouse, isHasCar, isDebtCar, monthlyPayCar, otherLoanMoneyTotal, otherLoanReturn, money, role, monthlyPrivateLiquid, monthlyPublicLiquid, companySize, companyAddressOperat_city, companyAddress_city, registTime, businessLicense, creditCardCount, cardDebtMount, consultLoan);
                         buffer = JsonConvert.SerializeObject(enterprise);
                        #endregion
                    }
                    // 传参数
                    jo2 = ResponseBind(url, buffer);
                    //保存返回数据并返回结果
                    ScoreReponseSave(lendId, cust_id, ref returnMenuBeizhu, ref returnMenu, chkEt, idenCard, scorerequest, lendinfo, jo2);
                    #endregion
                    break;
                case :
                    #region 反欺诈评分接口
                  
                    string linkmanMobile = "";
                    List<jsonNamemobileclass> NamemobileList = new List<jsonNamemobileclass>();
                    var contact = cstEt.CST_urgent_contact.Where(p => p.contact_person != null && p.contact_mobile.Trim() != null && p.contact_mobile.Trim() != "" && p.contact_person.Trim() != "" && p.person_info_id == cust_id).ToList();
                    foreach (CST_urgent_contact contactmodel in contact)
                    {
                        jsonNamemobileclass Namemobileclass = new jsonNamemobileclass();
                        Namemobileclass.name = contactmodel.contact_person;
                        Namemobileclass.mobile = contactmodel.contact_mobile;
                        NamemobileList.Add(Namemobileclass);
                    }
                     linkmanMobile = JsonConvert.SerializeObject(NamemobileList);
                   
                    url = System.Configuration.ConfigurationManager.AppSettings["FqzScoreIF"] != null ? System.Configuration.ConfigurationManager.AppSettings["FqzScoreIF"].Trim() : "";
                      
                //类赋值处理用于序列化
                    jsonFQZclass FQZclass = jsonFQZPFBind(appKey, uuid, version, businessNumber, clientNumber, idenCard, realName, mobile,
                    companyTel, linkmanMobile, phoneCode, phoneCodeType, platform, addressHome, addressCompany);
                     buffer = JsonConvert.SerializeObject(FQZclass);
                    // 传参数
                    jo2 = ResponseBind(url, buffer);
                    //保存返回数据并返回结果
                    QZReponseSave(lendId, cust_id, ref returnMenu, chkEt, idenCard, scorerequest, lendinfo, jo2);
                    #endregion
                    break;
                case :
                    #region 违约评分接口
                    if(marriage=="")
                        marriage ="";
                    else if (marriage == "")
                        marriage = "";
                    else
                        marriage = "";
                     var ddlinfo=sysEt.SYS_ddl_info.Where(p=>p.item_value==education &&p.ddl_type_id==).FirstOrDefault();
                   if (ddlinfo != null && ddlinfo.item_name != null)
                   {
                       string item_name = ddlinfo.item_name.ToString();//学历
                       if (item_name.IndexOf("技校/中专/高中及以下") >= )
                           education = "";
                       else if (item_name.IndexOf("硕") >= )
                           education = "";
                       else if (item_name.IndexOf("本") >= )
                           education = "";
                       else if (item_name.IndexOf("专") >= )
                           education = "";
                      else
                           education = "";
                  }
                    if (jktupe == )
                    {
                        #region 个人非业主违约接口评分
                        url = System.Configuration.ConfigurationManager.AppSettings["PersonalWyScoreIF"] != null ? System.Configuration.ConfigurationManager.AppSettings["PersonalWyScoreIF"].Trim() : "";                         //类赋值处理用于序列化
                        jsonPersonWyclass personclass = jsonGRWYPFBind(appKey, uuid, businessNumber, clientNumber, gender, yearBorn,
                             education, marriage, children, isOpen, isNative, liveCase, liveJoin, compAddresProvince, compJoinDate, companyType,
                            yearIncome, borrowType, car, house, isCredit, creditLimit, creditCardAccount, sumLoan, noCancellationAccount,
                            overdueLoan, overdueCreditCardNum, overdueLoanNum, sumOneMonthOverdueCard, sumOneMonthOverdueLoan, longOneMonthCard,
                            longOneMonthLoan, sixMonthAverageLimit, sixMonthAverageRepayment, totalNowMonthRepayCard, totalNowMonthRepayLoan,
                            totalCreditLimit, totalLoanMoney, totalUsedLimit, totalBalance, queryTimesOne, cardAmountAvg, maxReturnMoney, nowAddressProvince,
                            version);
                        buffer = JsonConvert.SerializeObject(personclass);
                        #endregion
                    }
                    else if (jktupe == )
                    {
                        #region 个人业主违约接口评分
                        url = System.Configuration.ConfigurationManager.AppSettings["PersonalOwnerWyScoreIF"] != null ? System.Configuration.ConfigurationManager.AppSettings["PersonalOwnerWyScoreIF"].Trim() : "";                         //类赋值处理用于序列化
                        jsonPersonWyclass personclass = jsonGRWYPFBind(appKey, uuid, businessNumber, clientNumber, gender, yearBorn,
                             education, marriage, children, isOpen, isNative, liveCase, liveJoin, compAddresProvince, compJoinDate, companyType,
                            yearIncome, borrowType, car, house, isCredit, creditLimit, creditCardAccount, sumLoan, noCancellationAccount,
                            overdueLoan, overdueCreditCardNum, overdueLoanNum, sumOneMonthOverdueCard, sumOneMonthOverdueLoan, longOneMonthCard,
                            longOneMonthLoan, sixMonthAverageLimit, sixMonthAverageRepayment, totalNowMonthRepayCard, totalNowMonthRepayLoan,
                            totalCreditLimit, totalLoanMoney, totalUsedLimit, totalBalance, queryTimesOne, cardAmountAvg, maxReturnMoney, nowAddressProvince,
                            version);
                        buffer = JsonConvert.SerializeObject(personclass);
                        #endregion
                    }
                    else if (jktupe == )
                    {
                        if (companyType.Trim() != "")
                        {
                            if (companyType == "")
                                companyType = "";
                            else if (companyType == "")
                                companyType = "";
                            else
                                companyType = "";
                        }
                        #region 企业主违约接口评分
                        url = System.Configuration.ConfigurationManager.AppSettings["OCWyScoreIF"] != null ? System.Configuration.ConfigurationManager.AppSettings["OCWyScoreIF"].Trim() : "";
                        //类赋值处理用于序列化
                        jsonOCWyclass personclass = jsonQYWYPFBind(appKey, uuid, businessNumber, clientNumber, gender, yearBorn,
                             education, marriage, children, isOpen, isNative, liveCase, liveJoin, compAddresProvince, companyType, isLegalPerson,
                             stockRatio, regDate, palace, staffAmount, publicAverage, monthlyPrivateLiquid,
                            yearIncome, borrowType, car, house, isCredit, creditLimit, creditCardAccount, sumLoan, noCancellationAccount,
                            overdueLoan, overdueCreditCardNum, overdueLoanNum, sumOneMonthOverdueCard, sumOneMonthOverdueLoan, longOneMonthCard,
                            longOneMonthLoan, sixMonthAverageLimit, sixMonthAverageRepayment, totalNowMonthRepayCard, totalNowMonthRepayLoan,
                            totalCreditLimit, totalLoanMoney, totalUsedLimit, totalBalance, queryTimesOne, maxReturnMoney,
                            version);
                        buffer = JsonConvert.SerializeObject(personclass);
                        #endregion
                    }
                    // 传参数
                    jo2 = ResponseBind(url, buffer);
                    //保存返回数据并返回结果
                    WYReponseSave(lendId, cust_id, ref returnMenuBeizhu, ref returnMenu, chkEt, idenCard, "", scorerequest, lendinfo, jo2,);
                    #endregion
                    break;
            }         }
        return returnMenu;
    }
    /// <summary>
    /// 调用反馈接口公用方法返回评分结果
    /// </summary>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
    /// <param name="lendifId">贷款id</param>
    /// <param name="cust_id">客户id</param>
    /// <param name="returnMenuBeizhu">返回值备注内容</param>
    /// <param name="Scoretype">接口类型,1:申请反馈接口,2,反欺诈反馈接口</param>
    /// <returns>评分结果</returns>
    public  string GetDockingFankui(int lendId, int cust_id, out string returnMenuBeizhu, string borrowResult, string refuseReason, int Scoretype = )
    {         string feedbackNumber = "";
        returnMenuBeizhu = "";
        CHK_docking_score_request scorerequest = chkEt.CHK_docking_score_request.Where(a => a.lend_info_id == lendId).OrderByDescending(p => p.score_request_id).FirstOrDefault();
        if (scorerequest.IsNotNull())
        {
            string url = "";
            string buffer = "";
            CHK_lend_info lendinfo = chkEt.CHK_lend_info.Find(lendId);
            businessNumber = (lendinfo!=null&&lendinfo.lend_no !=null)?lendinfo.lend_no.ToString():"";         //贷款编号
            JObject jo2 = new JObject();
            switch (Scoretype)
            {
                case :
                   #region 申请反馈接口
                    feedbackNumber = chkEt.CHK_docking_score_response.Where(p => p.lend_info_id == lendId).ToList().Count()>?(chkEt.CHK_docking_score_response.Where(p => p.lend_info_id == lendId).OrderByDescending(p => p.score_response_id).FirstOrDefault().feedbackNumber??""):"";
                    if (feedbackNumber != "")
                    {
                        url = System.Configuration.ConfigurationManager.AppSettings["FeedbackSqpfActionIF"] != null ? System.Configuration.ConfigurationManager.AppSettings["FeedbackSqpfActionIF"].Trim() : "";
                        //类赋值处理用于序列化
                        jsonSQFKclass SQFKclass = jsonSQFKBind(appKey, uuid, version, businessNumber, feedbackNumber, borrowResult, refuseReason);
                        buffer = JsonConvert.SerializeObject(SQFKclass);
                    }
                    else 
                    {
                        int custid = (chkEt.CHK_lend_info.Find(lendId) != null && chkEt.CHK_lend_info.Find(lendId).cust_id!=null)?Convert.ToInt32(chkEt.CHK_lend_info.Find(lendId).cust_id):;
                        CST_cust cust = cstEt.CST_cust.Find(custid);
                          CHK_docking_score_response response = chkEt.CHK_docking_score_response.Where(p => p.lend_info_id == lendId).OrderByDescending(p => p.score_response_id).FirstOrDefault() ;
                        if (cust != null && response != null)
                        {
                            realName = cust.cust_name ?? "";
                            idenCard = response.idcard_sjNo ?? "";
                        }
                        //老数据处理
                        url = System.Configuration.ConfigurationManager.AppSettings["FeedbackSqpfActionIFold"] != null ? System.Configuration.ConfigurationManager.AppSettings["FeedbackSqpfActionIFold"].Trim() : "";
                        //类赋值处理用于序列化
                        jsonSQFKclassold SQFKclass = jsonSQFKBindold(appKey, uuid, version, realName, idenCard, borrowResult, refuseReason);
                        buffer = JsonConvert.SerializeObject(SQFKclass);
                        feedbackNumber = "老数据";
                    }
                    // 传参数
                    jo2 = ResponseBind(url, buffer);
                    //保存返回数据并返回结果
                    ScoreReponseSave(lendId, cust_id, ref returnMenuBeizhu, ref returnMenu, chkEt, idenCard, scorerequest, lendinfo, jo2,
                        feedbackNumber, borrowResult, refuseReason);
                    #endregion
                    break;
                case :
                    #region 反欺诈反馈接口
                    feedbackNumber =  chkEt.CHK_docking_QZ_response.Where(p => p.lend_info_id == lendId).ToList().Count()>?(chkEt.CHK_docking_QZ_response.Where(p => p.lend_info_id == lendId).OrderByDescending(p => p.qz_response_id).FirstOrDefault().sq_feedbackNumber ?? ""):""; 
                    string isFraud = borrowResult;
                    string fraudType = refuseReason;
                    url = System.Configuration.ConfigurationManager.AppSettings["FeedbackFqzIF"] != null ? System.Configuration.ConfigurationManager.AppSettings["FeedbackFqzIF"].Trim() : "";
                    //类赋值处理用于序列化
                    jsonFQZFKclass FQZFKclass = jsonFQZFKBind(appKey, uuid, version, businessNumber, feedbackNumber, isFraud, fraudType);
                    buffer = JsonConvert.SerializeObject(FQZFKclass);
                    // 传参数
                    jo2 = ResponseBind(url, buffer);
                    //保存返回数据并返回结果
                    QZReponseSave(lendId, cust_id, ref returnMenu, chkEt, idenCard, scorerequest, lendinfo, jo2, feedbackNumber, isFraud, fraudType);
                    #endregion
                    break;
            }         }
        return returnMenu;
    }     /// <summary>
    /// 调用违约反馈接口公用方法返回评分结果
    /// </summary>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
    /// <param name="lendifId">贷款id</param>
    /// <param name="cust_id">客户id</param>
    /// <param name="returnMenuBeizhu">返回值备注内容</param>
    /// <param name="Scoretype">接口类型,1:申请反馈接口,2,反欺诈反馈接口</param>
    /// <returns>评分结果</returns>
    public string GetDockingWYFankui(int plan_id,int lendId, int cust_id, out string returnMenuBeizhu,string businessNumber,string clientNumber,
            string loanPeriods, string loanMoney, string period,
            string monthReturnAmount,string planRepaymentDate,
            string repaymentFunds,
            string repayInterest,
            string repaymentDate,
            string realityReceiveCapital,
            string realityReceiveInterest,
            string interestPenalty,
            string breach,
            string actualTotalAmount,
            string isOverdue,
            string overdueDays,
            string overduePeriod)
    {         string feedbackNumber = "";
        returnMenuBeizhu = "";
        CHK_docking_score_request scorerequest = chkEt.CHK_docking_score_request.Where(a => a.lend_info_id == lendId).OrderByDescending(p => p.score_request_id).FirstOrDefault();
        if (scorerequest.IsNotNull())
        {
            string url = "";
            string buffer = "";
            CHK_lend_info lendinfo = chkEt.CHK_lend_info.Find(lendId);
            JObject jo2 = new JObject();
            feedbackNumber = chkEt.CHK_docking_WY_response.Where(p => p.lend_info_id == lendId).ToList().Count() >  ? (chkEt.CHK_docking_WY_response.Where(p => p.lend_info_id == lendId).OrderByDescending(p => p.wy_response_id).FirstOrDefault().feedbackNumber ?? "") : "";
            #region 违约反馈接口
            url = System.Configuration.ConfigurationManager.AppSettings["FeedbackWyIF"] != null ? System.Configuration.ConfigurationManager.AppSettings["FeedbackWyIF"].Trim() : "";             //类赋值处理用于序列化
            jsonWYFKclass personclass = jsonGRWYFKBind(appKey, uuid, businessNumber, clientNumber, feedbackNumber, loanPeriods,
                 loanMoney, period, monthReturnAmount, planRepaymentDate, repaymentFunds, repayInterest,
                 repaymentDate, realityReceiveCapital, realityReceiveInterest, interestPenalty, breach,
                 actualTotalAmount, isOverdue, overdueDays, overduePeriod, version);
            buffer = JsonConvert.SerializeObject(personclass);
            // 传参数
            jo2 = ResponseBind(url, buffer);
            //保存返回数据并返回结果
            WYReponseSave(lendId, cust_id, ref returnMenuBeizhu, ref returnMenu, chkEt, idenCard, feedbackNumber, scorerequest, lendinfo, jo2, plan_id);
            #endregion         }
        return returnMenu;
    }
    /// <summary>
    /// 传输方法
    /// </summary>
    /// <param name="url">接口地址</param>
    /// <param name="ms">序列化后的数据</param>
    /// <returns></returns>
    private static JObject ResponseBind(string url,string buffer = "")
    {
        SecurityUtils su = new SecurityUtils();//给值
        IDictionary<string, string> parameters = new Dictionary<string, string>();
        parameters.Add("request", buffer);
        string strReturn = su.ReturnActionFromXml(url, parameters);
        JObject jo = (JObject)JsonConvert.DeserializeObject(strReturn);
        string responsestr = jo["response"] != null ? jo["response"].ToString().Trim() : "";//执行结果
        JObject jo2 = (JObject)JsonConvert.DeserializeObject(responsestr);
        return jo2;
    }
    /// <summary>
    /// 评分历史数据保存并返回结果
    /// </summary>
    /// <param name="lendId">贷款id</param>
    /// <param name="cust_id">客户id</param>
    /// <param name="returnMenuBeizhu">备注返回内容</param>
    /// <param name="returnMenu">接口调用结果</param>
    /// <param name="chkEt"></param>
    /// <param name="idenCard">随机数唯一流水</param>
    /// <param name="scorerequest">评分表</param>
    /// <param name="lendinfo">贷款表</param>
    /// <param name="jo2">内层json值</param>
    private static void ScoreReponseSave(int lendId, int cust_id, ref string returnMenuBeizhu, ref string returnMenu, CHKEntities chkEt, string idenCard,
        CHK_docking_score_request scorerequest, CHK_lend_info lendinfo, JObject jo2, string feedbackNumber = "", string borrowResult = "",
        string refuseReason = "")
    {
        returnMenuBeizhu = jo2["beizhu"] != null ? jo2["beizhu"].ToString().Trim() : "";
       
            //保存历史记录 
           
            if (feedbackNumber.Trim() == "")
            {
                if (jo2["status"] != null && jo2["status"].ToString().Trim() == "true")
                {
                    #region SQ 申请返回数据保存
                     CHK_docking_score_response scorereponse = new CHK_docking_score_response();
                     scorereponse.score_response_id = P2PUtil.GetMaxTableId("CHK_docking_score_response");
                     scorereponse.score = jo2["score"].ToString().Trim();
                     scorereponse.crate = jo2["crate"].ToString().Trim();
                     scorereponse.hdchance = jo2["hdchance"].ToString().Trim();
                     scorereponse.beizhu = jo2["beizhu"].ToString().Trim();
                     scorereponse.feedbackNumber = jo2["feedbackNumber"].ToString().Trim();
                     scorereponse.status = jo2["status"].ToString().Trim();
                     scorereponse.message = jo2["message"].ToString().Trim();
                     scorereponse.add_date = P2PUtil.GetBizDate(P2PUtil.getOrgId());
                     scorereponse.add_emp_id = (int)P2PUtil.GetSessionEmpInfo().emp_id;
                     scorereponse.lend_biz_name = scorerequest.lend_biz_name ?? "";
                     scorereponse.lend_biz_type = scorerequest.lend_biz_type ?? ;
                     scorereponse.lend_info_id = lendId;
                     scorereponse.cust_id = cust_id;
                     scorereponse.score_request_id = scorerequest.score_request_id;
                     scorereponse.idcard_sjNo = idenCard;
                     try
                     {
                         chkEt.CHK_docking_score_response.Add(scorereponse);
                         lendinfo.score_response_id = scorereponse.score_response_id;
                         scorerequest.idcard_sjNo = scorereponse.idcard_sjNo;
                         chkEt.SaveChanges();
                         returnMenu = "调用成功";
                     }
                     catch (HttpRequestValidationException ex)
                     {
                    
                         throw ex;
                     }
                    #endregion
                }
            }
            else
            {
                #region FK 反馈返回数据保存
                CHK_docking_score_response scorereponse = chkEt.CHK_docking_score_response.Where(p => p.lend_info_id == lendId && p.feedbackNumber == feedbackNumber).FirstOrDefault();
                if (feedbackNumber == "老数据" && scorereponse==null)
                    scorereponse = chkEt.CHK_docking_score_response.Where(p => p.lend_info_id == lendId).OrderByDescending(p=>p.score_response_id).FirstOrDefault();
                if (scorereponse != null)
                {
                    scorereponse.fk_status = jo2["status"].ToString().Trim();
                    scorereponse.fk_message = jo2["message"].ToString().Trim();
                    scorereponse.borrowResult = borrowResult.Trim() != "" ? borrowResult : "";
                    scorereponse.refuseReason = refuseReason;
                    scorereponse.fk_add_date = P2PUtil.GetBizDate(P2PUtil.getOrgId());
                    scorereponse.fk_add_emp_id = (int)P2PUtil.GetSessionEmpInfo().emp_id;
                    try
                    {
                        chkEt.SaveChanges();
                        if (jo2["status"] != null && jo2["status"].ToString().Trim() == "true")
                            returnMenu = "调用成功";
                        else
                            returnMenu = "调用失败";
                    }
                    catch (HttpRequestValidationException ex)
                    {
                        throw ex;
                    }
                }
                else {
                    returnMenu = "调用失败,未添加申请评分,不可反馈";
                }
                #endregion
                
            }
        
    }     /// <summary>
    /// 违约历史数据保存并返回结果
    /// </summary>
    /// <param name="lendId">贷款id</param>
    /// <param name="cust_id">客户id</param>
    /// <param name="returnMenuBeizhu">备注返回内容</param>
    /// <param name="returnMenu">接口调用结果</param>
    /// <param name="chkEt"></param>
    /// <param name="idenCard">随机数唯一流水</param>
    /// <param name="scorerequest">评分表</param>
    /// <param name="lendinfo">贷款表</param>
    /// <param name="jo2">内层json值</param>
    private static void WYReponseSave(int lendId, int cust_id, ref string returnMenuBeizhu, ref string returnMenu, CHKEntities chkEt, string idenCard,
        string feedbackNumber, CHK_docking_score_request scorerequest, CHK_lend_info lendinfo, JObject jo2, int plan_id = )
    {
         //保存历史记录 
        if (feedbackNumber.Trim() == "")
        {
           returnMenuBeizhu = jo2["beizhu"] != null ? jo2["beizhu"].ToString().Trim() : "";
            if (jo2["status"] != null && jo2["status"].ToString().Trim() == "true")
            {
                //保存历史记录 
                CHK_docking_WY_response scorereponse = new CHK_docking_WY_response();
                scorereponse.wy_response_id = P2PUtil.GetMaxTableId("CHK_docking_WY_response");
                scorereponse.score = jo2["score"].ToString().Trim();
                scorereponse.crate = jo2["crate"].ToString().Trim();
                scorereponse.wychance = jo2["wychance"].ToString().Trim();
                scorereponse.beizhu = jo2["beizhu"].ToString().Trim();
                scorereponse.sq_status = jo2["status"].ToString().Trim();
                scorereponse.sq_message = jo2["message"].ToString().Trim();
                scorereponse.feedbackNumber = jo2["feedbackNumber"].ToString().Trim();
                scorereponse.sq_add_date = P2PUtil.GetBizDate(P2PUtil.getOrgId());
                scorereponse.sq_add_emp_id = (int)P2PUtil.GetSessionEmpInfo().emp_id;
                scorereponse.lend_biz_name = scorerequest.lend_biz_name ?? "";
                scorereponse.lend_biz_type = scorerequest.lend_biz_type ?? ;
                scorereponse.lend_info_id = lendId;
                scorereponse.cust_id = cust_id;
                scorereponse.score_request_id = scorerequest.score_request_id;
                scorereponse.wy_companyUid = idenCard;
                try
                {
                    chkEt.CHK_docking_WY_response.Add(scorereponse);
                    lendinfo.wy_response_id = scorereponse.wy_response_id;
                    scorerequest.wy_companyUid = scorereponse.wy_companyUid;
                    chkEt.SaveChanges();
                    returnMenu = "调用成功";
                }
                catch (HttpRequestValidationException ex)
                {                     throw ex;
                }             }
        }
        else
        {
            #region FK 反馈返回数据保存
            CHK_docking_WY_response scorereponse = chkEt.CHK_docking_WY_response.Where(p => p.lend_info_id == lendId && p.feedbackNumber == feedbackNumber).FirstOrDefault();
            if (scorereponse != null)
            {
                scorereponse.fk_status = jo2["status"].ToString().Trim();
                scorereponse.fk_message = jo2["message"].ToString().Trim();
                scorereponse.fk_add_date = P2PUtil.GetBizDate(P2PUtil.getOrgId());
                scorereponse.fk_add_emp_id = (int)P2PUtil.GetSessionEmpInfo().emp_id;
                CHK_collect_plan_info plan = chkEt.CHK_collect_plan_info.Find(plan_id);
                if (plan != null && jo2["status"] != null && jo2["status"].ToString().Trim() == "true")
                {
                    plan.fk_status = ;
                }
                else
                {
                    plan.fk_status = ;
                }
                try
                {
                    chkEt.SaveChanges();
                    if (jo2["status"] != null && jo2["status"].ToString().Trim() == "true")
                        returnMenu = "调用成功";
                    else
                        returnMenu = "调用失败";
                }
                catch (HttpRequestValidationException ex)
                {
                    throw ex;
                }
            }
            else
            {
                returnMenu = "调用失败,未添加欺诈评分,不可反馈";
            }
            #endregion
        }
    }     /// <summary>
    /// 欺诈历史数据保存并返回结果
    /// </summary>
    /// <param name="lendId">贷款id</param>
    /// <param name="cust_id">客户id</param>
    /// <param name="returnMenuBeizhu">备注返回内容</param>
    /// <param name="returnMenu">接口调用结果</param>
    /// <param name="chkEt"></param>
    /// <param name="idenCard">随机数唯一流水</param>
    /// <param name="scorerequest">评分表</param>
    /// <param name="lendinfo">贷款表</param>
    /// <param name="jo2">内层json值</param>
    private static void QZReponseSave(int lendId, int cust_id, ref string returnMenu, CHKEntities chkEt, string idenCard, CHK_docking_score_request scorerequest,
        CHK_lend_info lendinfo, JObject jo2, string feedbackNumber = "", string isFraud = "", string fraudType = "")
    {
       
            //保存历史记录 
            if (feedbackNumber.Trim() == "")
            {
                if (jo2["status"] != null && (jo2["status"].ToString().Trim() == "success" || jo2["status"].ToString().Trim() == "true"))
                {
                    #region SQ 评分返回数据保存
                     CHK_docking_QZ_response scorereponse = new CHK_docking_QZ_response();
                     scorereponse.qz_response_id = P2PUtil.GetMaxTableId("CHK_docking_QZ_response");
                     scorereponse.totalScore = jo2["totalScore"].ToString().Trim();
                     scorereponse.riskRanking = jo2["riskRanking"].ToString().Trim();
                     scorereponse.finalProposa = jo2["finalProposal"].ToString().Trim();
                     scorereponse.firstProposal = jo2["firstProposal"].ToString().Trim();
                     scorereponse.secondProposal = jo2["secondProposal"].ToString().Trim();
                     scorereponse.thirdProposal = jo2["thirdProposal"].ToString().Trim();
                     scorereponse.sq_status = jo2["status"].ToString().Trim();
                     scorereponse.sq_message = jo2["message"].ToString().Trim();
                     scorereponse.sq_feedbackNumber = jo2["feedbackNumber"].ToString().Trim();
                     scorereponse.sq_add_date = P2PUtil.GetBizDate(P2PUtil.getOrgId());
                     scorereponse.sq_add_emp_id = (int)P2PUtil.GetSessionEmpInfo().emp_id;
                     scorereponse.lend_biz_name = scorerequest.lend_biz_name ?? "";
                     scorereponse.lend_biz_type = scorerequest.lend_biz_type ?? ;
                     scorereponse.lend_info_id = lendId;
                     scorereponse.cust_id = cust_id;
                     scorereponse.score_request_id = scorerequest.score_request_id;
                     scorereponse.qz_companyUid = idenCard;
                     
                     try
                     {
                         chkEt.CHK_docking_QZ_response.Add(scorereponse);
                         lendinfo.qz_response_id = scorereponse.qz_response_id;
                         scorerequest.qz_companyUid = scorereponse.qz_companyUid;
                         chkEt.SaveChanges();
                         returnMenu = "调用成功";
                     }
                     catch (HttpRequestValidationException ex)
                     {
                     
                         throw ex;
                     }
                    #endregion
                }
            }
            else
            {
                #region FK 反馈返回数据保存
                CHK_docking_QZ_response scorereponse = chkEt.CHK_docking_QZ_response.Where(p => p.lend_info_id == lendId && p.sq_feedbackNumber == feedbackNumber).FirstOrDefault();
                if (scorereponse != null)
                {
                    scorereponse.fk_status = jo2["status"].ToString().Trim();
                    scorereponse.fk_message = jo2["message"].ToString().Trim();
                    scorereponse.isFraud = Convert.ToInt32(isFraud.Trim() != "" ? isFraud : "");
                    scorereponse.fraudType = Convert.ToInt32(fraudType.Trim() != "" ? fraudType : "");
                    scorereponse.fk_add_date = P2PUtil.GetBizDate(P2PUtil.getOrgId());
                    scorereponse.fk_add_emp_id = (int)P2PUtil.GetSessionEmpInfo().emp_id;
                   
                    try
                    {
                        chkEt.SaveChanges();
                        if (jo2["status"] != null && jo2["status"].ToString().Trim() == "true")
                            returnMenu = "调用成功";
                        else
                            returnMenu = "调用失败";
                    }
                    catch (HttpRequestValidationException ex)
                    {
                        throw ex;
                    }
                }
                else
                {
                    returnMenu = "调用失败,未添加欺诈评分,不可反馈";
                }
                #endregion
            }
    }        #region 个人申请评分类赋值
    private static jsonPersonclass jsonGRSQPFBind(string appKey, string uuid, string version, string month, string realName, string businessNumber, string clientNumber, string idenCard, string gender, string yearBorn, string house_hold_city, string localLive, string marriage, string children, string education, string ssFund, string companyType, string industry, string creditCard, string firstCardTime, string totalLimit, string cardOverdueCount, string cardOverdueDays, string cardDebt, string isHasHouse, string isDebtHouse, string monthlyPayHouse, string isHasCar, string isDebtCar, string monthlyPayCar, string otherLoanMoneyTotal, string otherLoanReturn, string work_city, string currentOnboardTime, string money, string salary, string salaryType, string consultLoan)
    {
        //请求明文
        StringBuilder sb = new StringBuilder();
        sb.Append(uuid)
        .Append(money)
        .Append(businessNumber)
        .Append(clientNumber)
        .Append(month)
        .Append(realName)
        .Append(idenCard)
        .Append(gender)
        .Append(yearBorn)
        .Append(house_hold_city)
        .Append(localLive)
        .Append(marriage)
        .Append(children)
        .Append(education)
        .Append(ssFund)
        .Append(work_city)
        .Append(currentOnboardTime)
        .Append(companyType)
        .Append(industry)
        .Append(salary)
        .Append(salaryType)
        .Append(creditCard)
        .Append(firstCardTime)
        .Append(totalLimit)
        .Append(cardOverdueCount)
        .Append(cardOverdueDays)
        .Append(cardDebt)
        .Append(isHasHouse)
        .Append(isDebtHouse)
        .Append(monthlyPayHouse)
        .Append(isHasCar)
        .Append(isDebtCar)
        .Append(monthlyPayCar)
        .Append(consultLoan)
        .Append(otherLoanMoneyTotal)
        .Append(otherLoanReturn)
        .Append(version)
        .Append(appKey);         string inputStr = GetMd5String(sb.ToString());//账号密码MD5加密
        jsonPersonclass personclass = new jsonPersonclass();
        personclass.uuid = uuid;
        personclass.money = money;
        if (month.Trim() != "")
            personclass.month = Convert.ToInt32(month);
        personclass.realName = realName;
        personclass.idenCard = idenCard;
        personclass.businessNumber = businessNumber;
        personclass.clientNumber = clientNumber;
        if (gender.Trim() != "")
            personclass.gender = Convert.ToInt32(gender);
        personclass.yearBorn = yearBorn;
        personclass.house_hold_city = house_hold_city;
        if (localLive.Trim() != "")
            personclass.localLive = Convert.ToInt32(localLive);
        if (marriage.Trim() != "")
            personclass.marriage = Convert.ToInt32(marriage);
        if (children.Trim() != "")
            personclass.children = Convert.ToInt32(children);
        if (education.Trim() != "")
            personclass.education = Convert.ToInt32(education);
        if (ssFund.Trim() != "")
            personclass.ssFund = Convert.ToInt32(ssFund);
        personclass.work_city = work_city;
        personclass.currentOnboardTime = currentOnboardTime;
        if (companyType.Trim() != "")
            personclass.companyType = Convert.ToInt32(companyType);
        if (industry.Trim() != "")
            personclass.industry = Convert.ToInt32(industry);
        if (salary.Trim() != "")
            personclass.salary = Convert.ToInt32(salary);
        if (salaryType.Trim() != "")
            personclass.salaryType = Convert.ToInt32(salaryType);
        if (creditCard.Trim() != "")
            personclass.creditCard = Convert.ToInt32(creditCard);
        personclass.firstCardTime = firstCardTime;
        if (totalLimit.Trim() != "")
            personclass.totalLimit = Convert.ToInt32(totalLimit);
        if (cardOverdueCount.Trim() != "")
            personclass.cardOverdueCount = Convert.ToInt32(cardOverdueCount);
        if (cardOverdueDays.Trim() != "")
            personclass.cardOverdueDays = Convert.ToInt32(cardOverdueDays);
        if (cardDebt.Trim() != "")
            personclass.cardDebt = Convert.ToInt32(cardDebt);
        if (isHasHouse.Trim() != "")
            personclass.isHasHouse = Convert.ToInt32(isHasHouse);
        if (isDebtHouse.Trim() != "")
            personclass.isDebtHouse = Convert.ToInt32(isDebtHouse);
        if (monthlyPayHouse.Trim() != "")
            personclass.monthlyPayHouse = Convert.ToInt32(monthlyPayHouse);
        if (isHasCar.Trim() != "")
            personclass.isHasCar = Convert.ToInt32(isHasCar);
        if (isDebtCar.Trim() != "")
            personclass.isDebtCar = Convert.ToInt32(isDebtCar);
        if (monthlyPayCar.Trim() != "")
            personclass.monthlyPayCar = Convert.ToInt32(monthlyPayCar);
        if (consultLoan.Trim() != "")
            personclass.consultLoan = Convert.ToInt32(consultLoan);
        if (otherLoanMoneyTotal.Trim() != "")
            personclass.otherLoanMoneyTotal = Convert.ToInt32(otherLoanMoneyTotal);
        if (otherLoanReturn.Trim() != "")
            personclass.otherLoanReturn = Convert.ToInt32(otherLoanReturn);
        personclass.version = version;
        personclass.MD5 = inputStr;
        return personclass;
    }
    #endregion     #region 企业申请评分类赋值
    private static Enterprise jsonQYSQPFBind(string appKey, string uuid, string version, string month, string realName,string businessNumber,string clientNumber, string idenCard, string gender, string yearBorn, string house_hold_city, string marriage, string children, string education, string ssFund, string companyType, string industry, string creditCard, string firstCardTime, string totalLimit, string cardOverdueCount, string cardOverdueDays, string cardDebt, string isHasHouse, string isDebtHouse, string monthlyPayHouse, string isHasCar, string isDebtCar, string monthlyPayCar, string otherLoanMoneyTotal, string otherLoanReturn, string money, string role, string monthlyPrivateLiquid, string monthlyPublicLiquid, string companySize, string companyAddressOperat_city, string companyAddress_city, string registTime, string businessLicense, string creditCardCount, string cardDebtMount, string consultLoan)
    {
        //请求明文
        StringBuilder sb = new StringBuilder();
        sb.Append(uuid)
        .Append(money)
        .Append(businessNumber)
        .Append(clientNumber)
        .Append(month)
        .Append(realName)
        .Append(idenCard)
        .Append(gender)
        .Append(yearBorn)
        .Append(house_hold_city)
        .Append(marriage)
        .Append(children)
        .Append(education)
        .Append(ssFund)
        .Append(role)
        .Append(companyType)
        .Append(industry)
        .Append(businessLicense)
        .Append(registTime)
        .Append(companyAddress_city)
        .Append(companyAddressOperat_city)
        .Append(companySize)
        .Append(monthlyPublicLiquid)
        .Append(monthlyPrivateLiquid)
        .Append(creditCard)
        .Append(firstCardTime)
        .Append(creditCardCount)
        .Append(totalLimit)
        .Append(cardOverdueCount)
        .Append(cardOverdueDays)
        .Append(cardDebt)
        .Append(cardDebtMount)
        .Append(isHasHouse)
        .Append(isDebtHouse)
        .Append(monthlyPayHouse)
        .Append(isHasCar)
        .Append(isDebtCar)
        .Append(monthlyPayCar)
        .Append(consultLoan)
        .Append(otherLoanMoneyTotal)
        .Append(otherLoanReturn)
         .Append(version)
        .Append(appKey);         string inputStr = GetMd5String(sb.ToString());//账号密码MD5加密
        Enterprise enterprise = new Enterprise();
        enterprise.uuid = uuid;
        enterprise.money = money;
        if (month.Trim() != "")
            enterprise.month = Convert.ToInt32(month);
        enterprise.realName = realName;
        enterprise.idenCard = idenCard;
        enterprise.businessNumber = businessNumber;
        enterprise.clientNumber = clientNumber;
        if (gender.Trim() != "")
            enterprise.gender = Convert.ToInt32(gender);
        enterprise.yearBorn = yearBorn;
        enterprise.house_hold_city = house_hold_city;
        if (marriage.Trim() != "")
            enterprise.marriage = Convert.ToInt32(marriage);
        if (children.Trim() != "")
            enterprise.children = Convert.ToInt32(children);
        if (education.Trim() != "")
            enterprise.education = Convert.ToInt32(education);
        if (ssFund.Trim() != "")
            enterprise.ssFund = Convert.ToInt32(ssFund);
        if (role.Trim() != "")
            enterprise.role = Convert.ToInt32(role);
        if (companyType.Trim() != "")
            enterprise.companyType = Convert.ToInt32(companyType);
        if (industry.Trim() != "")
            enterprise.industry = Convert.ToInt32(industry);
        if (businessLicense.Trim() != "")
            enterprise.businessLicense = Convert.ToInt32(businessLicense);
        if (registTime.Trim() != "")
            enterprise.registTime = registTime;
        if (companyAddress_city.Trim() != "")
            enterprise.companyAddress_city = companyAddress_city;
        enterprise.companyAddressOperat_city = companyAddressOperat_city;
        if (companySize.Trim() != "")
            enterprise.companySize = Convert.ToInt32(companySize);
        if (monthlyPublicLiquid.Trim() != "")
            enterprise.monthlyPublicLiquid = Convert.ToInt32(monthlyPublicLiquid);
        if (monthlyPrivateLiquid.Trim() != "")
            enterprise.monthlyPrivateLiquid = Convert.ToInt32(monthlyPrivateLiquid);
        if (creditCard.Trim() != "")
            enterprise.creditCard = Convert.ToInt32(creditCard);
        enterprise.firstCardTime = firstCardTime;
        if (creditCardCount.Trim() != "")
            enterprise.creditCardCount = Convert.ToInt32(creditCardCount);
        if (totalLimit.Trim() != "")
            enterprise.totalLimit = Convert.ToInt32(totalLimit);
        if (cardOverdueCount.Trim() != "")
            enterprise.cardOverdueCount = Convert.ToInt32(cardOverdueCount);
        if (cardOverdueDays.Trim() != "")
            enterprise.cardOverdueDays = Convert.ToInt32(cardOverdueDays);
        if (cardDebt.Trim() != "")
            enterprise.cardDebt = Convert.ToInt32(cardDebt);
        if (cardDebtMount.Trim() != "")
            enterprise.cardDebtMount = Convert.ToInt32(cardDebtMount);
        if (isHasHouse.Trim() != "")
            enterprise.isHasHouse = Convert.ToInt32(isHasHouse);
        if (isDebtHouse.Trim() != "")
            enterprise.isDebtHouse = Convert.ToInt32(isDebtHouse);
        if (monthlyPayHouse.Trim() != "")
            enterprise.monthlyPayHouse = Convert.ToInt32(monthlyPayHouse);
        if (isHasCar.Trim() != "")
            enterprise.isHasCar = Convert.ToInt32(isHasCar);
        if (isDebtCar.Trim() != "")
            enterprise.isDebtCar = Convert.ToInt32(isDebtCar);
        if (monthlyPayCar.Trim() != "")
            enterprise.monthlyPayCar = Convert.ToInt32(monthlyPayCar);
        if (consultLoan.Trim() != "")
            enterprise.consultLoan = Convert.ToInt32(consultLoan);
        if (otherLoanMoneyTotal.Trim() != "")
            enterprise.otherLoanMoneyTotal = Convert.ToInt32(otherLoanMoneyTotal);
        if (otherLoanReturn.Trim() != "")
            enterprise.otherLoanReturn = Convert.ToInt32(otherLoanReturn);
        enterprise.version = version;
        enterprise.MD5 = inputStr;
        return enterprise;
    }
    #endregion     #region 申请反馈
    private static jsonSQFKclass jsonSQFKBind(string appKey, string uuid, string version, string businessNumber, string feedbackNumber, string borrowResult, string refuseReason)
    {
        //请求明文
        StringBuilder sb = new StringBuilder();
        sb.Append(uuid)
        .Append(businessNumber)
        .Append(feedbackNumber)
        .Append(borrowResult)
        .Append(refuseReason)
        .Append(version)
        .Append(appKey);
        string inputStr = GetMd5String(sb.ToString());//账号密码MD5加密
        jsonSQFKclass personclass = new jsonSQFKclass();
        personclass.uuid = uuid;
        personclass.businessNumber = businessNumber;
        personclass.feedbackNumber = feedbackNumber;
        personclass.refuseReason = refuseReason;
        if (borrowResult.Trim() != "")
            personclass.borrowResult = Convert.ToInt32(borrowResult);
        personclass.version = version;
        personclass.MD5 = inputStr;
        return personclass;
    }
    private static jsonSQFKclassold jsonSQFKBindold(string appKey, string uuid, string version, string realName, string idenCard, string borrowResult, string refuseReason)
    {
        //请求明文
        StringBuilder sb = new StringBuilder();
        sb.Append(uuid)
        .Append(realName)
        .Append(idenCard)
        .Append(borrowResult)
        .Append(refuseReason)
        .Append(version)
        .Append(appKey);
        string inputStr = GetMd5String(sb.ToString());//账号密码MD5加密
        jsonSQFKclassold personclass = new jsonSQFKclassold();
        personclass.uuid = uuid;
        personclass.realName = realName;
        personclass.idenCard = idenCard;
        personclass.refuseReason = refuseReason;
        if (borrowResult.Trim() != "")
            personclass.borrowResult = Convert.ToInt32(borrowResult);
        personclass.version = version;
        personclass.MD5 = inputStr;
        return personclass;
    }
   
    #endregion     #region 反欺诈评分类赋值
    private static jsonFQZclass jsonFQZPFBind(string appKey, string uuid, string version,string businessNumber,string clientNumber, string idenCard, string name, string mobile,
        string companyTel, string linkmanMobile, string phoneCode, string phoneCodeType, string platform, string addressHome, string addressCompany)
    {
        //请求明文
        StringBuilder sb = new StringBuilder();
        sb.Append(uuid)
        .Append(version)
        .Append(businessNumber)
        .Append(clientNumber)
        .Append(idenCard)
        .Append(name)
        .Append(mobile)
        .Append(companyTel)
        .Append(linkmanMobile)
        .Append(phoneCode)
        .Append(phoneCodeType)
        .Append(platform)
        .Append(addressHome)
        .Append(addressCompany)
        .Append(appKey);
        string inputStr = GetMd5String(sb.ToString());//账号密码MD5加密
        jsonFQZclass enterprise = new jsonFQZclass();
        enterprise.uuid = uuid;
        enterprise.version = version;
        enterprise.businessNumber = businessNumber;
        enterprise.clientNumber = clientNumber;
        enterprise.idCard = idenCard;
        enterprise.name = name;
        enterprise.mobile = mobile;
        enterprise.companyTel = companyTel;
        enterprise.linkmanMobile = linkmanMobile;
        enterprise.phoneCode = phoneCode;
        if (phoneCodeType.Trim() != "")
            enterprise.phoneCodeType = Convert.ToInt32(phoneCodeType);
        if (platform.Trim() != "")
            enterprise.platform = Convert.ToInt32(platform);
        enterprise.addressHome = addressHome;
        enterprise.addressCompany = addressCompany;
        enterprise.MD5 = inputStr;
        return enterprise;
    }
    #endregion     #region 反欺诈反馈类赋值
    private static jsonFQZFKclass jsonFQZFKBind(string appKey, string uuid, string version, string businessNumber, string feedbackNumber, string isFraud, string fraudType)
    {
        //请求明文
        StringBuilder sb = new StringBuilder();
        sb.Append(uuid)
        .Append(version)
        .Append(businessNumber)
        .Append(feedbackNumber)
        .Append(isFraud)
        .Append(fraudType)
        .Append(appKey);
        string inputStr = GetMd5String(sb.ToString());//账号密码MD5加密
        jsonFQZFKclass enterprise = new jsonFQZFKclass();
        enterprise.uuid = uuid;
        enterprise.version = version;
        enterprise.businessNumber = businessNumber;
        enterprise.feedbackNumber = feedbackNumber;
        if (isFraud.Trim() != "")
            enterprise.isFraud = Convert.ToInt32(isFraud);
        if (fraudType.Trim() != "")
            enterprise.fraudType = Convert.ToInt32(fraudType);
        enterprise.MD5 = inputStr;
        return enterprise;
    }
    #endregion     #region 个人违约评分类赋值
    private static jsonPersonWyclass jsonGRWYPFBind(string appKey, string uuid, string businessNumber,string clientNumber, string gender, string birthday, string education,
        string marriage, string children, string isOpen, string isNative, string liveCase, string liveJoin, string compAddresProvince,
        string compJoinDate, string companyType, string yearIncome, string borrowType, string car, string house, string isCredit, string creditLimit,
        string creditCardAccount, string sumLoan, string noCancellationAccount, string overdueLoan, string overdueCreditCardNum, string overdueLoanNum,
        string sumOneMonthOverdueCard, string sumOneMonthOverdueLoan, string longOneMonthCard, string longOneMonthLoan, string sixMonthAverageLimit,
        string sixMonthAverageRepayment, string totalNowMonthRepayCard, string totalNowMonthRepayLoan, string totalCreditLimit, string totalLoanMoney,
        string totalUsedLimit, string totalBalance, string queryTimesOne, string cardAmountAvg, string maxReturnMoney, string nowAddressProvince, string version)
    {
        //请求明文
        StringBuilder sb = new StringBuilder();
        sb.Append(uuid)
        .Append(businessNumber)
         .Append(clientNumber)
        .Append(gender)
        .Append(birthday)
        .Append(education)
        .Append(marriage)
        .Append(children)
        .Append(isOpen)
        .Append(isNative)
        .Append(liveCase)
        .Append(liveJoin)
        .Append(compAddresProvince)
        .Append(compJoinDate)
        .Append(companyType)
        .Append(yearIncome)
        .Append(borrowType)
        .Append(car)
        .Append(house)
        .Append(isCredit)
        .Append(creditLimit)
        .Append(creditCardAccount)
        .Append(sumLoan)
        .Append(noCancellationAccount)
        .Append(overdueLoan)
        .Append(overdueCreditCardNum)
        .Append(overdueLoanNum)
        .Append(sumOneMonthOverdueCard)
        .Append(sumOneMonthOverdueLoan)
        .Append(longOneMonthCard)
        .Append(longOneMonthLoan)
        .Append(sixMonthAverageLimit)
        .Append(sixMonthAverageRepayment)
        .Append(totalNowMonthRepayCard)
        .Append(totalNowMonthRepayLoan)
        .Append(totalCreditLimit)
        .Append(totalLoanMoney)
        .Append(totalUsedLimit)
        .Append(totalBalance)
        .Append(queryTimesOne)
        .Append(cardAmountAvg)
        .Append(maxReturnMoney)
        .Append(nowAddressProvince)
        .Append(version)
        .Append(appKey);
        string inputStr = GetMd5String(sb.ToString());//账号密码MD5加密
        jsonPersonWyclass personclass = new jsonPersonWyclass();
        personclass.uuid = uuid;
        personclass.businessNumber = businessNumber;
        personclass.clientNumber = clientNumber;
        if (gender.Trim() != "")
            personclass.gender = Convert.ToInt32(gender);
        personclass.birthday = birthday;
        if (education.Trim() != "")
            personclass.education = Convert.ToInt32(education);
        if (marriage.Trim() != "")
            personclass.marriage = Convert.ToInt32(marriage);
        if (children.Trim() != "")
            personclass.children = Convert.ToInt32(children);
        if (isOpen.Trim() != "")
            personclass.isOpen = Convert.ToInt32(isOpen);
        if (isNative.Trim() != "")
            personclass.isNative = Convert.ToInt32(isNative);
        if (liveCase.Trim() != "")
            personclass.liveCase = Convert.ToInt32(liveCase);
        if (liveJoin.Trim() != "")
            personclass.liveJoin = Convert.ToInt32(liveJoin);
        personclass.compAddresProvince = compAddresProvince;
        if (compJoinDate.Trim() != "")
            personclass.compJoinDate = compJoinDate;
        if (companyType.Trim() != "")
            personclass.companyType = Convert.ToInt32(companyType);
        personclass.yearIncome = yearIncome;
        if (borrowType.Trim() != "")
            personclass.borrowType = Convert.ToInt32(borrowType);
        if (car.Trim() != "")
            personclass.car = Convert.ToInt32(car);
        if (house.Trim() != "")
            personclass.house = Convert.ToInt32(house);
        if (isCredit.Trim() != "")
            personclass.isCredit = Convert.ToInt32(isCredit);
        personclass.creditLimit = creditLimit;
        if (creditCardAccount.Trim() != "")
            personclass.creditCardAccount = Convert.ToInt32(creditCardAccount);
        if (sumLoan.Trim() != "")
            personclass.sumLoan = Convert.ToInt32(sumLoan);
        if (noCancellationAccount.Trim() != "")
            personclass.noCancellationAccount = Convert.ToInt32(noCancellationAccount);
        if (overdueLoan.Trim() != "")
            personclass.overdueLoan = Convert.ToInt32(overdueLoan);
        if (overdueCreditCardNum.Trim() != "")
            personclass.overdueCreditCardNum = Convert.ToInt32(overdueCreditCardNum);
        if (overdueLoanNum.Trim() != "")
            personclass.overdueLoanNum = Convert.ToInt32(overdueLoanNum);
        personclass.sumOneMonthOverdueCard = sumOneMonthOverdueCard;
        personclass.sumOneMonthOverdueLoan = sumOneMonthOverdueLoan;
        if (longOneMonthCard.Trim() != "")
            personclass.longOneMonthCard = Convert.ToInt32(longOneMonthCard);
        if (longOneMonthLoan.Trim() != "")
            personclass.longOneMonthLoan = Convert.ToInt32(longOneMonthLoan);
        personclass.sixMonthAverageLimit = sixMonthAverageLimit;
        personclass.sixMonthAverageRepayment = sixMonthAverageRepayment;
        personclass.totalNowMonthRepayCard = totalNowMonthRepayCard;
        personclass.totalNowMonthRepayLoan = totalNowMonthRepayLoan;
        personclass.totalCreditLimit = totalCreditLimit;
        personclass.totalLoanMoney = totalLoanMoney;
        personclass.totalUsedLimit = totalUsedLimit;
        personclass.totalBalance = totalBalance;
        if (queryTimesOne.Trim() != "")
            personclass.queryTimesOne = Convert.ToInt32(queryTimesOne);
        personclass.cardAmountAvg = cardAmountAvg;
        personclass.maxReturnMoney = maxReturnMoney;
        personclass.nowAddressProvince = nowAddressProvince;
        personclass.version = version;
        personclass.MD5 = inputStr;
        return personclass;
    }
    #endregion     #region 企业主违约评分类赋值
    private static jsonOCWyclass jsonQYWYPFBind(string appKey, string uuid, string businessNumber, string clientNumber, string gender, string birthday, string education,
      string marriage, string children, string isOpen, string isNative, string liveCase, string liveJoin, string compAddresProvince,
      string companyType, string isLegalPerson, string stockRatio, string regDate, string palace, string staffAmount, string publicAverage,
        string monthlyPrivateLiquid, string yearIncome, string borrowType, string car, string house, string isCredit, string creditLimit,
      string creditCardAccount, string sumLoan, string noCancellationAccount, string overdueLoan, string overdueCreditCardNum, string overdueLoanNum,
      string sumOneMonthOverdueCard, string sumOneMonthOverdueLoan, string longOneMonthCard, string longOneMonthLoan, string sixMonthAverageLimit,
      string sixMonthAverageRepayment, string totalNowMonthRepayCard, string totalNowMonthRepayLoan, string totalCreditLimit, string totalLoanMoney,
      string totalUsedLimit, string totalBalance, string queryTimesOne, string maxReturnMoney, string version)
    {
        //请求明文
        StringBuilder sb = new StringBuilder();
        sb.Append(uuid)
        .Append(businessNumber)
         .Append(clientNumber)
        .Append(gender)
        .Append(birthday)
        .Append(education)
        .Append(marriage)
        .Append(children)
        .Append(isOpen)
        .Append(isNative)
        .Append(liveCase)
        .Append(liveJoin)
        .Append(compAddresProvince)
        .Append(companyType)
        .Append(isLegalPerson)
        .Append(stockRatio)
        .Append(regDate)
        .Append(palace)
        .Append(staffAmount)
        .Append(publicAverage)
        .Append(monthlyPrivateLiquid)
        .Append(yearIncome)
        .Append(borrowType)
        .Append(car)
        .Append(house)
        .Append(isCredit)
        .Append(creditLimit)
        .Append(creditCardAccount)
        .Append(sumLoan)
        .Append(noCancellationAccount)
        .Append(overdueLoan)
        .Append(overdueCreditCardNum)
        .Append(overdueLoanNum)
        .Append(sumOneMonthOverdueCard)
        .Append(sumOneMonthOverdueLoan)
        .Append(longOneMonthCard)
        .Append(longOneMonthLoan)
        .Append(sixMonthAverageLimit)
        .Append(sixMonthAverageRepayment)
        .Append(totalNowMonthRepayCard)
        .Append(totalNowMonthRepayLoan)
        .Append(totalCreditLimit)
        .Append(totalLoanMoney)
        .Append(totalUsedLimit)
        .Append(totalBalance)
        .Append(queryTimesOne)
        .Append(maxReturnMoney)
        .Append(version)
        .Append(appKey);
        string inputStr = GetMd5String(sb.ToString());//账号密码MD5加密
        jsonOCWyclass personclass = new jsonOCWyclass();
        personclass.uuid = uuid;
        personclass.businessNumber = businessNumber;
        personclass.clientNumber = clientNumber;
        if (gender.Trim() != "")
            personclass.gender = Convert.ToInt32(gender);
        personclass.birthday = birthday;
        if (education.Trim() != "")
            personclass.education = Convert.ToInt32(education);
        if (marriage.Trim() != "")
            personclass.marriage = Convert.ToInt32(marriage);
        if (children.Trim() != "")
            personclass.children = Convert.ToInt32(children);
        if (isOpen.Trim() != "")
            personclass.isOpen = Convert.ToInt32(isOpen);
        if (isNative.Trim() != "")
            personclass.isNative = Convert.ToInt32(isNative);
        if (liveCase.Trim() != "")
            personclass.liveCase = Convert.ToInt32(liveCase);
        if (liveJoin.Trim() != "")
            personclass.liveJoin = Convert.ToInt32(liveJoin);
        personclass.compAddresProvince = compAddresProvince;
        if (companyType.Trim() != "")
            personclass.companyType = Convert.ToInt32(companyType);
        if (isLegalPerson.Trim() != "")
            personclass.isLegalPerson = Convert.ToInt32(isLegalPerson);
        personclass.stockRatio = stockRatio;
        personclass.regDate = regDate;
        if (palace.Trim() != "")
            personclass.palace = Convert.ToInt32(palace);
        if (staffAmount.Trim() != "")
            personclass.staffAmount = Convert.ToInt32(staffAmount);
        personclass.publicAverage = publicAverage;
        personclass.monthlyPrivateLiquid = monthlyPrivateLiquid;
        personclass.yearIncome = yearIncome;
        if (borrowType.Trim() != "")
            personclass.borrowType = Convert.ToInt32(borrowType);
        if (car.Trim() != "")
            personclass.car = Convert.ToInt32(car);
        if (house.Trim() != "")
            personclass.house = Convert.ToInt32(house);
        if (isCredit.Trim() != "")
            personclass.isCredit = Convert.ToInt32(isCredit);
        personclass.creditLimit = creditLimit;
        if (creditCardAccount.Trim() != "")
            personclass.creditCardAccount = Convert.ToInt32(creditCardAccount);
        if (sumLoan.Trim() != "")
            personclass.sumLoan = Convert.ToInt32(sumLoan);
        if (noCancellationAccount.Trim() != "")
            personclass.noCancellationAccount = Convert.ToInt32(noCancellationAccount);
        if (overdueLoan.Trim() != "")
            personclass.overdueLoan = Convert.ToInt32(overdueLoan);
        if (overdueCreditCardNum.Trim() != "")
            personclass.overdueCreditCardNum = Convert.ToInt32(overdueCreditCardNum);
        if (overdueLoanNum.Trim() != "")
            personclass.overdueLoanNum = Convert.ToInt32(overdueLoanNum);
        personclass.sumOneMonthOverdueCard = sumOneMonthOverdueCard;
        personclass.sumOneMonthOverdueLoan = sumOneMonthOverdueLoan;
        if (longOneMonthCard.Trim() != "")
            personclass.longOneMonthCard = Convert.ToInt32(longOneMonthCard);
        if (longOneMonthLoan.Trim() != "")
            personclass.longOneMonthLoan = Convert.ToInt32(longOneMonthLoan);
        personclass.sixMonthAverageLimit = sixMonthAverageLimit;
        personclass.sixMonthAverageRepayment = sixMonthAverageRepayment;
        personclass.totalNowMonthRepayCard = totalNowMonthRepayCard;
        personclass.totalNowMonthRepayLoan = totalNowMonthRepayLoan;
        personclass.totalCreditLimit = totalCreditLimit;
        personclass.totalLoanMoney = totalLoanMoney;
        personclass.totalUsedLimit = totalUsedLimit;
        personclass.totalBalance = totalBalance;
        if (queryTimesOne.Trim() != "")
            personclass.queryTimesOne = Convert.ToInt32(queryTimesOne);
        personclass.maxReturnMoney = maxReturnMoney;
        personclass.version = version;
        personclass.MD5 = inputStr;
        return personclass;
    }
    #endregion
    #region 违约反馈类赋值
    private static jsonWYFKclass jsonGRWYFKBind(string appKey, string uuid, string businessNumber, string clientNumber, string feedbackNumber, string loanPeriods,
        string loanMoney,string period, string monthReturnAmount, string planRepaymentDate, string repaymentFunds, string repayInterest, 
        string repaymentDate, string realityReceiveCapital, string realityReceiveInterest, string interestPenalty, string breach,
        string actualTotalAmount, string isOverdue, string overdueDays,
        string overduePeriod,string version)
    {
        //请求明文
        StringBuilder sb = new StringBuilder();
        sb.Append(uuid)
        .Append(businessNumber)
         .Append(clientNumber)
        .Append(feedbackNumber)
        .Append(loanPeriods)
        .Append(loanMoney)
        .Append(period)
        .Append(monthReturnAmount)
        .Append(planRepaymentDate)
        .Append(repaymentFunds)
        .Append(repayInterest)
        .Append(repaymentDate)
        .Append(realityReceiveCapital)
        .Append(realityReceiveInterest)
        .Append(interestPenalty)
        .Append(breach)
        .Append(actualTotalAmount)
        .Append(isOverdue)
        .Append(overdueDays)
        .Append(overduePeriod)
        .Append(version)
        .Append(appKey);
        string inputStr = GetMd5String(sb.ToString());//账号密码MD5加密
        jsonWYFKclass personclass = new jsonWYFKclass();
        personclass.uuid = uuid;
        personclass.businessNumber = businessNumber;
        personclass.clientNumber = clientNumber;
        personclass.feedbackNumber = feedbackNumber;
        if (loanPeriods.Trim() != "")
            personclass.loanPeriods = Convert.ToInt32(loanPeriods);
        personclass.loanMoney = loanMoney;
        if (period.Trim() != "")
            personclass.period = Convert.ToInt32(period);
        personclass.monthReturnAmount = monthReturnAmount;
        personclass.planRepaymentDate = planRepaymentDate;
        personclass.repaymentFunds = repaymentFunds;
        personclass.repayInterest = repayInterest;
        personclass.repaymentDate = repaymentDate;
        personclass.realityReceiveCapital = realityReceiveCapital;
        personclass.realityReceiveInterest = realityReceiveInterest;
        personclass.interestPenalty = interestPenalty;
        personclass.breach = breach;
        personclass.actualTotalAmount = actualTotalAmount;
        if (isOverdue.Trim() != "")
            personclass.isOverdue = Convert.ToInt32(isOverdue);
        if (overdueDays.Trim() != "")
            personclass.overdueDays = Convert.ToInt32(overdueDays);
        if (overduePeriod.Trim() != "")
            personclass.overduePeriod = Convert.ToInt32(overduePeriod);
        personclass.version = version;
        personclass.MD5 = inputStr;
        return personclass;
    }
    #endregion     #region 定义存储数据类
    //个人申请评分接口序列化临时类
    public class jsonPersonclass : Object
    {
        public string uuid { get; set; }
        public string money { get; set; }
        public Nullable<int> month { get; set; }
        public string realName { get; set; }
        public string businessNumber { get; set; }
        public string clientNumber { get; set; }
        public string idenCard { get; set; }
        public Nullable<int> gender { get; set; }
        public string yearBorn { get; set; }
        public string house_hold_city { get; set; }
        public Nullable<int> localLive { get; set; }
        public Nullable<int> marriage { get; set; }
        public Nullable<int> children { get; set; }
        public Nullable<int> education { get; set; }
        public Nullable<int> ssFund { get; set; }
        public string work_city { get; set; }
        public string currentOnboardTime { get; set; }
        public Nullable<int> companyType { get; set; }
        public Nullable<int> industry { get; set; }
        public Nullable<int> salary { get; set; }
        public Nullable<int> salaryType { get; set; }
        public Nullable<int> creditCard { get; set; }
        public string firstCardTime { get; set; }
        public Nullable<int> totalLimit { get; set; }
        public Nullable<int> cardOverdueCount { get; set; }
        public Nullable<int> cardOverdueDays { get; set; }
        public Nullable<int> cardDebt { get; set; }
        public Nullable<int> isHasHouse { get; set; }
        public Nullable<int> isDebtHouse { get; set; }
        public Nullable<int> monthlyPayHouse { get; set; }
        public Nullable<int> isHasCar { get; set; }
        public Nullable<int> isDebtCar { get; set; }
        public Nullable<int> monthlyPayCar { get; set; }
        public Nullable<int> consultLoan { get; set; }
        public Nullable<int> otherLoanMoneyTotal { get; set; }
        public Nullable<int> otherLoanReturn { get; set; }
        public string version { get; set; }
        public string MD5 { get; set; }
    }
    //企业申请评分接口序列化临时类
    public class Enterprise : Object
    {
        public string uuid { get; set; }
        public string money { get; set; }
        public Nullable<int> month { get; set; }
        public string realName { get; set; }
        public string businessNumber { get; set; }
        public string clientNumber { get; set; }
        public string idenCard { get; set; }
        public Nullable<int> gender { get; set; }
        public string yearBorn { get; set; }
        public string house_hold_city { get; set; }
        public Nullable<int> marriage { get; set; }
        public Nullable<int> children { get; set; }
        public Nullable<int> education { get; set; }
        public Nullable<int> ssFund { get; set; }
        public Nullable<int> role { get; set; }
        public Nullable<int> companyType { get; set; }
        public Nullable<int> industry { get; set; }
        public Nullable<int> businessLicense { get; set; }
        public string registTime { get; set; }
        public string companyAddress_city { get; set; }
        public string companyAddressOperat_city { get; set; }
        public Nullable<int> companySize { get; set; }
        public Nullable<int> monthlyPublicLiquid { get; set; }
        public Nullable<int> monthlyPrivateLiquid { get; set; }
        public Nullable<int> creditCard { get; set; }
        public string firstCardTime { get; set; }
        public Nullable<int> creditCardCount { get; set; }
        public Nullable<int> totalLimit { get; set; }
        public Nullable<int> cardOverdueCount { get; set; }
        public Nullable<int> cardOverdueDays { get; set; }
        public Nullable<int> cardDebt { get; set; }
        public Nullable<int> cardDebtMount { get; set; }
        public Nullable<int> isHasHouse { get; set; }
        public Nullable<int> isDebtHouse { get; set; }
        public Nullable<int> monthlyPayHouse { get; set; }
        public Nullable<int> isHasCar { get; set; }
        public Nullable<int> isDebtCar { get; set; }
        public Nullable<int> monthlyPayCar { get; set; }
        public Nullable<int> consultLoan { get; set; }
        public Nullable<int> otherLoanMoneyTotal { get; set; }
        public Nullable<int> otherLoanReturn { get; set; }
        public string version { get; set; }
        public string MD5 { get; set; }
    }
    //申请反馈接口临时类
    public class jsonSQFKclass : Object
    {
        public string uuid { get; set; }
        public string businessNumber { get; set; }
        public string feedbackNumber { get; set; }
        public Nullable<int> borrowResult { get; set; }
        public string refuseReason { get; set; }
        public string version { get; set; }
        public string MD5 { get; set; }
    }     //老数据申请反馈接口临时类
    public class jsonSQFKclassold : Object
    {
        public string uuid { get; set; }
        public string realName { get; set; }
        public string idenCard { get; set; }
        public Nullable<int> borrowResult { get; set; }
        public string refuseReason { get; set; }
        public string version { get; set; }
        public string MD5 { get; set; }
    }
    //反欺诈评分接口临时类
    public class jsonFQZclass : Object
    {
        public string uuid { get; set; }
        public string version { get; set; }
        public string businessNumber { get; set; }
        public string clientNumber { get; set; }
        public string idCard { get; set; }
        public string name { get; set; }
        public string mobile { get; set; }
        public string companyTel { get; set; }
        public string linkmanMobile { get; set; }
        public string phoneCode { get; set; }
        public Nullable<int> phoneCodeType { get; set; }
        public Nullable<int> platform { get; set; }
        public string addressHome { get; set; }
        public string addressCompany { get; set; }
        public string MD5 { get; set; }
    }
    //反欺诈评分接口联系人集合临时类
    public class jsonNamemobileclass : Object
    {
        public string mobile { get; set; }
        public string name { get; set; }
    }
    //反欺诈反馈接口临时类
    public class jsonFQZFKclass : Object
    {
        public string uuid { get; set; }
        public string version { get; set; }
        public string businessNumber { get; set; }
        public string feedbackNumber { get; set; }
        public string companyUid { get; set; }
        public Nullable<int> isFraud { get; set; }
        public Nullable<int> fraudType { get; set; }
        public string MD5 { get; set; }
    }     //个人违约评分接口序列化临时类
    public class jsonPersonWyclass : Object
    {
        public string uuid { get; set; }
        public string businessNumber { get; set; }
        public string clientNumber { get; set; }
        public Nullable<int> gender { get; set; }
        public string birthday { get; set; }
        public Nullable<int> education { get; set; }
        public Nullable<int> marriage { get; set; }
        public Nullable<int> children { get; set; }
        public Nullable<int> isOpen { get; set; }
        public Nullable<int> isNative { get; set; }
        public Nullable<int> liveCase { get; set; }
        public Nullable<int> liveJoin { get; set; }
        public string compAddresProvince { get; set; }
        public string compJoinDate { get; set; }
        public Nullable<int> companyType { get; set; }
        public string yearIncome { get; set; }
        public Nullable<int> borrowType { get; set; }
        public Nullable<int> car { get; set; }
        public Nullable<int> house { get; set; }
        public Nullable<int> isCredit { get; set; }
        public string creditLimit { get; set; }
        public Nullable<int> creditCardAccount { get; set; }
        public Nullable<int> sumLoan { get; set; }
        public Nullable<int> noCancellationAccount { get; set; }
        public Nullable<int> overdueLoan { get; set; }
        public Nullable<int> overdueCreditCardNum { get; set; }
        public Nullable<int> overdueLoanNum { get; set; }
        public string sumOneMonthOverdueCard { get; set; }
        public string sumOneMonthOverdueLoan { get; set; }
        public Nullable<int> longOneMonthCard { get; set; }
        public Nullable<int> longOneMonthLoan { get; set; }
        public string sixMonthAverageLimit { get; set; }
        public string sixMonthAverageRepayment { get; set; }
        public string totalNowMonthRepayCard { get; set; }
        public string totalNowMonthRepayLoan { get; set; }
        public string totalCreditLimit { get; set; }
        public string totalLoanMoney { get; set; }
        public string totalUsedLimit { get; set; }
        public string totalBalance { get; set; }
        public Nullable<int> queryTimesOne { get; set; }
        public string cardAmountAvg { get; set; }
        public string maxReturnMoney { get; set; }
        public string nowAddressProvince { get; set; }
        public string version { get; set; }
        public string MD5 { get; set; }
    }
    //企业违约评分接口序列化临时类
    public class jsonOCWyclass : Object
    {
        public string uuid { get; set; }
        public string businessNumber { get; set; }
        public string clientNumber { get; set; }
        public Nullable<int> gender { get; set; }
        public string birthday { get; set; }
        public Nullable<int> education { get; set; }
        public Nullable<int> marriage { get; set; }
        public Nullable<int> children { get; set; }
        public Nullable<int> isOpen { get; set; }
        public Nullable<int> isNative { get; set; }
        public Nullable<int> liveCase { get; set; }
        public Nullable<int> liveJoin { get; set; }
        public string compAddresProvince { get; set; }
        public Nullable<int> companyType { get; set; }
        public Nullable<int> isLegalPerson { get; set; }
        public string stockRatio { get; set; }
        public string regDate { get; set; }
        public Nullable<int> palace { get; set; }
        public Nullable<int> staffAmount { get; set; }
        public string publicAverage { get; set; }
        public string monthlyPrivateLiquid { get; set; }
        public string yearIncome { get; set; }
        public Nullable<int> borrowType { get; set; }
        public Nullable<int> car { get; set; }
        public Nullable<int> house { get; set; }
        public Nullable<int> isCredit { get; set; }
        public string creditLimit { get; set; }
        public Nullable<int> creditCardAccount { get; set; }
        public Nullable<int> sumLoan { get; set; }
        public Nullable<int> noCancellationAccount { get; set; }
        public Nullable<int> overdueLoan { get; set; }
        public Nullable<int> overdueCreditCardNum { get; set; }
        public Nullable<int> overdueLoanNum { get; set; }
        public string sumOneMonthOverdueCard { get; set; }
        public string sumOneMonthOverdueLoan { get; set; }
        public Nullable<int> longOneMonthCard { get; set; }
        public Nullable<int> longOneMonthLoan { get; set; }
        public string sixMonthAverageLimit { get; set; }
        public string sixMonthAverageRepayment { get; set; }
        public string totalNowMonthRepayCard { get; set; }
        public string totalNowMonthRepayLoan { get; set; }
        public string totalCreditLimit { get; set; }
        public string totalLoanMoney { get; set; }
        public string totalUsedLimit { get; set; }
        public string totalBalance { get; set; }
        public string maxReturnMoney { get; set; }
        public Nullable<int> queryTimesOne { get; set; }
        public string version { get; set; }
        public string MD5 { get; set; }
    }     //违约反馈接口序列化临时类
    public class jsonWYFKclass : Object
    {
        public string uuid { get; set; }
        public string businessNumber { get; set; }
        public string clientNumber { get; set; }
        public string feedbackNumber { get; set; }
        public Nullable<int> loanPeriods { get; set; }
        public string loanMoney { get; set; }
        public Nullable<int> period { get; set; }
        public string monthReturnAmount { get; set; }
        public string planRepaymentDate { get; set; }
        public string repaymentFunds { get; set; }
        public string repayInterest { get; set; }
        public string repaymentDate { get; set; }
        public string realityReceiveCapital { get; set; }
        public string realityReceiveInterest { get; set; }
        public string interestPenalty { get; set; }
        public string breach { get; set; }
        public string actualTotalAmount { get; set; }
        public Nullable<int> isOverdue { get; set; }
        public Nullable<int> overdueDays { get; set; }
        public Nullable<int> overduePeriod { get; set; }
        public string version { get; set; }
        public string MD5 { get; set; }
    }
    #endregion
      #region 生成五位随机数
    private static string fiverandomno()
    {
        Random r = new Random();
        string fiverandomno = r.Next(, ).ToString();
        return fiverandomno;
    }
    #endregion     /// <summary>
    /// MD5标准化加密  32位 16进制小写英文加密
    /// </summary>
    /// <param name="paramsString">加密字符串</param>
    /// <returns>加密结果</returns>
    static string GetMd5String(string paramsString)
    {
        System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create();
        byte[] bytes = md5.ComputeHash(Encoding.UTF8.GetBytes(paramsString));
        StringBuilder sb = new StringBuilder();
        foreach (byte b in bytes)
            sb.AppendFormat("{0:x2}", b);
        return sb.ToString();
    }
    /// <summary>
    /// 获取地区名称
    /// </summary>
    /// <param name="itemid">地区id</param>
    /// <param name="cityType">地区类型1:最后节点地区,2:省,3:详细地址</param>
    /// <returns>地区名称</returns>
    public static string GetcityName(string itemid, int cityType)
    {
        SYSEntities sysEt = new SYSEntities();
        string cityName = ""; ;
        var idList = itemid.Split('|').ToList();
        string idvalue = idList.Count >  ? idList[] : "";
        if (idvalue.Length > )
        {
            if (cityType ==  && idvalue != "" && idvalue.Length > )
            {
                var Name = sysEt.SYS_ddl_info.Where(p => p.ddl_type_id ==  && p.item_value == idvalue).Select(p => p.item_name).FirstOrDefault();
                string idvalue1 = idvalue.Substring(, ) + "";//省
                string idvalue2 = idvalue.Substring(, ) + "";//市
                var Name1 = sysEt.SYS_ddl_info.Where(p => p.ddl_type_id ==  && p.item_value == idvalue1).Select(p => p.item_name).FirstOrDefault();
                if (idvalue1 != idvalue2)
                {
                    var Name2 = sysEt.SYS_ddl_info.Where(p => p.ddl_type_id ==  && p.item_value == idvalue2).Select(p => p.item_name).FirstOrDefault();
                    cityName = (Name1 ?? "") + (Name2 ?? "");                 }
                if (idvalue2 != idvalue)
                {
                    var Name3 = sysEt.SYS_ddl_info.Where(p => p.ddl_type_id ==  && p.item_value == idvalue).Select(p => p.item_name).FirstOrDefault();
                    cityName = cityName + (Name ?? "");
                }             }
            else
            {
                if (cityType ==  && idvalue != "")
                {
                    idvalue = idvalue.Substring(, ) + "";
                }
                var Name = sysEt.SYS_ddl_info.Where(p => p.ddl_type_id ==  && p.item_value == idvalue).Select(p => p.item_name).FirstOrDefault();
                cityName = Name ?? "";
                idvalue = idList.Count >  ? idList[] : "";
                if (idvalue.Trim() != "")
                {
                    cityName = idvalue;
                }
                if (cityName == "市辖区" || cityName == "市" || cityName == "县" || cityName == "省直辖行政单位")
                {
                    cityName = "";
                }
            }
        }
        return cityName;
    }
    /// <summary>
    /// 查询申请评分分数区间
    /// </summary>
    /// <param name="responseid">评分表id</param>
    /// <param name="scoreType">类型(1,评分;2,区间)</param>
    /// <returns>数据库对应值</returns>
    public static string GetScoreQJ(int responseid, int scoreType)
    {
        string PForQJ = "";
        CHKEntities chkEt = new CHKEntities();
        CHK_docking_score_response scoreresponse = chkEt.CHK_docking_score_response.Find(responseid);
        if (scoreresponse.IsNotNull())
        {
            if (scoreType == )
            {
                PForQJ = scoreresponse.score ?? "/";
            }
            else
            {
                PForQJ = scoreresponse.crate ?? "/";
            }
        }
        else
        {
            PForQJ = "/";
        }
        return PForQJ;
    }
     /// <summary>
    /// 查询违约评分分数区间
    /// </summary>
    /// <param name="responseid">违约评分表id</param>
    /// <param name="scoreType">类型(1,评分;2,区间)</param>
    /// <returns>数据库对应值</returns>
    public static string GetWYScoreQJ(int responseid, int scoreType)
    {
        string PForQJ = "";
        CHKEntities chkEt = new CHKEntities();
        CHK_docking_WY_response scoreresponse = chkEt.CHK_docking_WY_response.Find(responseid);
        if (scoreresponse.IsNotNull())
        {
            if (scoreType == )
            {
                PForQJ = scoreresponse.score ?? "/";
            }
            else
            {
                PForQJ = scoreresponse.crate ?? "/";
            }
        }
        else
        {
            PForQJ = "/";
        }
        return PForQJ;
    }
    /// <summary>
    /// 查询欺诈评分分数区间
    /// </summary>
    /// <param name="responseid">欺诈评分表id</param>
    /// <param name="scoreType">类型(1,评分;2,区间3、建议分数)</param>
    /// <returns>数据库对应值</returns>
    public static string GetQZScoreQJ(int responseid, int scoreType)
    {
        string PForQJ = "";
        CHKEntities chkEt = new CHKEntities();
        CHK_docking_QZ_response scoreresponse = chkEt.CHK_docking_QZ_response.Find(responseid);
        if (scoreresponse.IsNotNull())
        {
            if (scoreType == )
            {
                PForQJ = scoreresponse.totalScore ?? "/";
            }
            else if(scoreType == )
            {
                PForQJ = "第一高分:" + (scoreresponse.firstProposal ?? "无") + "第二高分:" + (scoreresponse.secondProposal ?? "无") + "第三高分:" + (scoreresponse.thirdProposal ?? "无");
            }
        }
        else
        {
            PForQJ = "/";
        }
        return PForQJ;
    } }   --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------  using System;using System.Text;
using System.Security.Cryptography;
using System.Web;
using System.IO;
using System.Security.Cryptography.X509Certificates;
using System.Net;
using System.Web.UI;
using System.Collections.Generic;
using HttpWebUtility;
using System.Configuration;
using System.Data.Entity.Validation; namespace Security
{
    public class SecurityUtils
    {         // 商户代码
        public static string mchnt_cd = ConfigurationSettings.AppSettings["mchnt_cd"].Trim();         //随机生成流水号
        public static string GetMchnt_txn_ssn()
        {
            Random rad = new Random();//实例化随机数产生器rad;
            string value = rad.Next(, ).ToString();//用rad生成大于等于1000,小于等于9999的随机数
            return DateTime.Now.ToString("yyyyMMddHHmmssfff") + value;
        }         // 私钥存放的位置
        public static string GetPrKey()
        {
            var foldName = "Bin";//存放的文件的名字
            string prKey = GetFileName(foldName) + "\\prkey.key";
            return prKey;         }
        //公钥 存放的位置
        public static string GetPrKey1()
        {
            var foldName = "Bin";//存放的文件的名字
            string prKey = GetFileName(foldName) + "\\pbkey.key";
            return prKey;
        }
        /// <summary>
        /// 验证签名
        /// </summary>
        /// <param name="OriginalString">原文:UTF8编码</param>
        /// <param name="SignatureString">签名:base64编码的字节</param>
        /// <param name="publicKeyPath">公钥路径</param>
        /// <returns> 验签结果</returns>
        public static bool Verify(string OriginalString, string SignatureString, string publicKeyPath)
        {
            //将base64签名数据转码为字节 
            byte[] signedBase64 = Convert.FromBase64String(SignatureString);
            byte[] orgin = Encoding.UTF8.GetBytes(OriginalString);
            string pem;
            using (System.IO.FileStream fs = System.IO.File.OpenRead(publicKeyPath))
            {
                byte[] data = new byte[fs.Length];
                fs.Read(data, , data.Length);
                pem = Encoding.UTF8.GetString(data);
            }             RSACryptoServiceProvider oRSA = new RSACryptoServiceProvider();
            oRSA.FromXmlString(pem);             bool bVerify = oRSA.VerifyData(orgin, "SHA1", signedBase64);
            return bVerify;
        }         /// <summary>
        /// 验证签名
        /// </summary>
        /// <param name="data">原文:UTF8编码</param>
        /// <param name="privateKeyPath">证书路径:D:/certs/mycert.key</param>
        /// <returns> 验签</returns>
        public string Sign(string data1, string privateKeyPath)
        {
            string pem;
            using (System.IO.FileStream fs = System.IO.File.OpenRead(privateKeyPath))
            {
                byte[] data = new byte[fs.Length];
                byte[] res = null;
                fs.Read(data, , data.Length);
                pem = Encoding.UTF8.GetString(data);
            }
            RSACryptoServiceProvider oRSA = new RSACryptoServiceProvider();
            oRSA.FromXmlString(pem);
            byte[] dataBytes = Encoding.UTF8.GetBytes(data1);
            byte[] signatureBytes = oRSA.SignData(dataBytes, "SHA1");
            return Convert.ToBase64String(signatureBytes);
        }         /// <summary>
        /// 验证签名
        /// </summary>
        /// <param name="data">原文:UTF8编码</param>
        /// <param name="privateKeyPath">证书路径:D:/certs/mycert.key</param>
        /// <returns> 验签</returns>
        public string SignIFRE(string data1, string privateKeyPath)
        {             string pem;
            using (System.IO.FileStream fs = System.IO.File.OpenRead(privateKeyPath))
            {
                byte[] data = new byte[fs.Length];
                byte[] res = null;
                fs.Read(data, , data.Length);
                pem = Encoding.UTF8.GetString(data);
            }
            md5 m = new md5();
            pem = m.getmd5(pem, );//账号密码MD5加密
            return pem;
        }         private byte[] GetPem(string type, byte[] data)
        {
            string pem = Encoding.UTF8.GetString(data);
            string header = String.Format("-----BEGIN {0}-----", type);
            string footer = String.Format("-----END {0}-----", type);
            int start = pem.IndexOf(header) + header.Length;
            int end = pem.IndexOf(footer, start);             string base64 = pem.Substring(start, (end - start));             return Convert.FromBase64String(base64);
        }         private RSACryptoServiceProvider LoadCertificateFile(string filename)
        {
            using (System.IO.FileStream fs = System.IO.File.OpenRead(filename))
            {
                byte[] data = new byte[fs.Length];
                byte[] res = null;
                fs.Read(data, , data.Length);
                if (data[] != 0x30)
                {
                    res = GetPem("RSA PRIVATE KEY", data);
                }
                try
                {
                    RSACryptoServiceProvider rsa = DecodeRSAPrivateKey(res);
                    return rsa;
                }
                catch (Exception ex)
                {
                }
                return null;
            }
        }         private RSACryptoServiceProvider DecodeRSAPrivateKey(byte[] privkey)
        {
            byte[] MODULUS, E, D, P, Q, DP, DQ, IQ;             // --------- Set up stream to decode the asn.1 encoded RSA private key ------  
            MemoryStream mem = new MemoryStream(privkey);
            BinaryReader binr = new BinaryReader(mem);  //wrap Memory Stream with BinaryReader for easy reading  
            byte bt = ;
            ushort twobytes = ;
            int elems = ;
            try
            {
                twobytes = binr.ReadUInt16();
                if (twobytes == 0x8130) //data read as little endian order (actual data order for Sequence is 30 81)  
                    binr.ReadByte();    //advance 1 byte  
                else if (twobytes == 0x8230)
                    binr.ReadInt16();    //advance 2 bytes  
                else
                    return null;                 twobytes = binr.ReadUInt16();
                if (twobytes != 0x0102) //version number  
                    return null;
                bt = binr.ReadByte();
                if (bt != 0x00)
                    return null;                 //------ all private key components are Integer sequences ----  
                elems = GetIntegerSize(binr);
                MODULUS = binr.ReadBytes(elems);                 elems = GetIntegerSize(binr);
                E = binr.ReadBytes(elems);                 elems = GetIntegerSize(binr);
                D = binr.ReadBytes(elems);                 elems = GetIntegerSize(binr);
                P = binr.ReadBytes(elems);                 elems = GetIntegerSize(binr);
                Q = binr.ReadBytes(elems);                 elems = GetIntegerSize(binr);
                DP = binr.ReadBytes(elems);                 elems = GetIntegerSize(binr);
                DQ = binr.ReadBytes(elems);                 elems = GetIntegerSize(binr);
                IQ = binr.ReadBytes(elems);                 // ------- create RSACryptoServiceProvider instance and initialize with public key -----  
                CspParameters CspParameters = new CspParameters();
                CspParameters.Flags = CspProviderFlags.UseMachineKeyStore;
                RSACryptoServiceProvider RSA = new RSACryptoServiceProvider(, CspParameters);
                RSAParameters RSAparams = new RSAParameters();
                RSAparams.Modulus = MODULUS;
                RSAparams.Exponent = E;
                RSAparams.D = D;
                RSAparams.P = P;
                RSAparams.Q = Q;
                RSAparams.DP = DP;
                RSAparams.DQ = DQ;
                RSAparams.InverseQ = IQ;
                RSA.ImportParameters(RSAparams);
                return RSA;
            }
            catch (Exception ex)
            {                 return null;
            }
            finally
            {
                binr.Close();
            }
        }         private int GetIntegerSize(BinaryReader binr)
        {
            byte bt = ;
            byte lowbyte = 0x00;
            byte highbyte = 0x00;
            int count = ;
            bt = binr.ReadByte();
            if (bt != 0x02)     //expect integer  
                return ;
            bt = binr.ReadByte();             if (bt == 0x81)
                count = binr.ReadByte();    // data size in next byte  
            else
                if (bt == 0x82)
                {
                    highbyte = binr.ReadByte(); // data size in next 2 bytes  
                    lowbyte = binr.ReadByte();
                    byte[] modint = { lowbyte, highbyte, 0x00, 0x00 };
                    count = BitConverter.ToInt32(modint, );
                }
                else
                {
                    count = bt;     // we already have the data size  
                }             while (binr.ReadByte() == 0x00)
            {   //remove high order zeros in data  
                count -= ;
            }
            binr.BaseStream.Seek(-, SeekOrigin.Current);       //last ReadByte wasn't a removed zero, so back up a byte  
            return count;
        }
        //md5,加密
        public string Encode(string codeName, string sourceString)
        {             return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(sourceString, "MD5").ToLower();         }         public byte[] ReadFile(string fileName)
        {
            FileStream f = new FileStream(fileName, FileMode.Open, FileAccess.Read);
            int size = (int)f.Length;
            byte[] data = new byte[size];
            size = f.Read(data, , size);
            f.Close();
            return data;
        }         public string ReturnActionXml(string url)
        {
            string xml;
            // HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
            //  request.Method = "GET";
            //  HttpWebResponse response = request.GetResponse() as HttpWebResponse;
            HttpWebResponse response = HttpWebResponseUtility.CreateGetHttpResponse(url, null, null, null);
            using (StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
            {
                xml = sr.ReadToEnd();
            }             return xml;         }         public string ReturnActionFromXml(string url, IDictionary<string, string> parameters)
        {
            string xml;
            HttpWebResponse response = HttpWebResponseUtility.CreatePostHttpResponse(url, parameters, null, null, Encoding.UTF8, null);
            using (StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
            {
                xml = sr.ReadToEnd();
            }
            return xml;
        }         public string GetXmlParam(string xml, string startParam, string endParam)
        {
            string xmlParam;
            int a = xml.IndexOf(startParam);
            int b = xml.LastIndexOf(endParam);
            int paramLength = startParam.Length;
            xmlParam = xml.Substring(a + paramLength, (b - a) - paramLength);
            return xmlParam;
        }         //存放的文件夹
        public static string GetFileName(string foldName)
        {
            string savepath = "";
            // string tempPath = "~/Bin";
            //  tempPath = System.Configuration.ConfigurationManager.AppSettings["FolderPath"];
            // tempPath = tempPath.Replace("//LoanSettle", "");
            savepath = HttpContext.Current.Server.MapPath("~");
            string datePath = foldName;
            string sPath = savepath + @"\" + datePath;
            if (!Directory.Exists(sPath))
                Directory.CreateDirectory(sPath);
            return sPath;
        }     }
} ---------------------------------------------------------------------------------------------------------------using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Web; namespace HttpWebUtility
{
    /// <summary>
    /// HttpWebResponseUtility 的摘要说明
    /// 抓取网页的数据 分别是post 和Get
    /// </summary>
    public class HttpWebResponseUtility
    {
        private static readonly string DefaultUserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)";
        public static HttpWebResponse CreateGetHttpResponse(string url, int? timeout, string userAgent, CookieCollection cookies)
        {
            if (string.IsNullOrEmpty(url))
            {
                throw new ArgumentNullException("url");
            }
            HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
            request.Method = "GET";
            request.UserAgent = DefaultUserAgent;
            if (!string.IsNullOrEmpty(userAgent))
            {
                request.UserAgent = userAgent;             } if (timeout.HasValue)
            {
                request.Timeout = timeout.Value;
            } if (cookies != null)
            {
                request.CookieContainer = new CookieContainer();
                request.CookieContainer.Add(cookies);
            }
            return request.GetResponse() as HttpWebResponse;
        }
        public static HttpWebResponse CreatePostHttpResponse(string url, IDictionary<string, string> parameters, int? timeout, string userAgent, Encoding requestEncoding, CookieCollection cookies)
        {
            if (string.IsNullOrEmpty(url))
            { throw new ArgumentNullException("url"); }
            if (requestEncoding == null)
            {
                throw new ArgumentNullException("requestEncoding");
            }
            HttpWebRequest request = null;             //如果是发送HTTPS请求     
            if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
            {
                ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
                request = WebRequest.Create(url) as HttpWebRequest;
                request.ProtocolVersion = HttpVersion.Version10;
            }
            else
            {
                request = WebRequest.Create(url) as HttpWebRequest;
            }
            request.Method = "POST";
            request.ContentType = "application/x-www-form-urlencoded";
            if (!string.IsNullOrEmpty(userAgent))
            {
                request.UserAgent = userAgent;
            }
            else
            {
                request.UserAgent = DefaultUserAgent;
            } if (timeout.HasValue)
            {
                request.Timeout = timeout.Value;
            } if (cookies != null)
            {
                request.CookieContainer = new CookieContainer();
                request.CookieContainer.Add(cookies);
            }
            //如果需要POST数据  
            if (!(parameters == null || parameters.Count == ))
            {
                StringBuilder buffer = new StringBuilder(); int i = ;
                foreach (string key in parameters.Keys)
                {
                    if (i > )
                    {
                        buffer.AppendFormat("&{0}={1}", key, parameters[key]);
                    }
                    else
                    {
                        buffer.AppendFormat("{0}={1}", key, parameters[key]);
                    } i++;
                }
                byte[] data = requestEncoding.GetBytes(buffer.ToString());
                using (Stream stream = request.GetRequestStream())
                { stream.Write(data, , data.Length); }
            } return request.GetResponse() as HttpWebResponse;
        }
        private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
        {
            return true; //总是接受    
        }
    }}  

C# 请求外部服务的办法的更多相关文章

  1. ORA-12514:TNS:监听程序当前无法识别连接描述符中请求的服务解决办法

    ORA-12514:TNS:监听程序当前无法识别连接描述符中请求的服务解决办法: 1.首先打开cmd命令 查看本地TNSPING配置 是否ok?然后找到 Oracle 安装文件 中 listener. ...

  2. ajax跨域请求问题及解决办法总结

    1.浏览器的同源策略及规避方法 目前,所有浏览器都实行同源政策.即协议.域名.端口都相同的URI称为"同源".不同源的url之间: a.无法读取cookie.localstorag ...

  3. node socket :10106无法加载或初始化请求的服务提供程序

    node socket :10106无法加载或初始化请求的服务提供程序 无端端的,不知道怎么回事,node突然就坏掉 了,应该是某些配置无意中改动了,问题如下: 目前能想到的解决办法就是:重置配置,用 ...

  4. Oracle ORA12514 监听程序当前无法识别连接描述符中请求的服务

    在连接数据库的时候,有时会遇到一个“ORA12514:监听程序当前无法识别连接描述符中请求的服务”的错误,这个错误其实就是数据库动态注册(关于动态注册会在稍后讲解)不生效,导致监听器无法识别客户端连接 ...

  5. ORA-12514: 监听程序当前无法识别连接描述符中请求的服务

    /** 异常:ORA-12514: 监听程序当前无法识别连接描述符中请求的服务 * 背景:在很长一段时间都在连接远程开发库,曾偶尔有一次想要连接本地的库进行sql测试,发现连接失败,起初一直有无监听. ...

  6. Istio ServiceEntry 引入外部服务

    概念及示例 使用服务入口Service Entry来添加一个入口到 Istio 内部维护的服务注册中心.添加了服务入口后,Envoy 代理可以向服务发送流量,就好像它是网格内部的服务一样.配置服务入口 ...

  7. istio: 无法提供内部访问外部服务

    现象 能够内部无法访问外部服务. 在部署测试服务 kubectl apply -f samples/sleep/sleep.yaml 设置环境变量 export SOURCE_POD=$(kubect ...

  8. Oracle几个基础配置问题:ORA-12154: TNS: 无法解析指定的连接标识符、ORA-12514: TNS: 监听程序当前无法识别连接描述符中请求的服务、ORA-12516 TNS监听程序找不到符合协议堆栈要求的可用处理程序

    问题1:ORA-12154: TNS: 无法解析指定的连接标识符 在一台服务器上部署了Oracle客户端,使用IP/SID的方式访问,老是报ORA-12154错误,而使用tnsnames访问却没有问题 ...

  9. Node.js 使用 soap 模块请求 WebService 服务接口

    项目开发中需要请求webservice服务,前端主要使用node.js 作为运行环境,因此可以使用soap进行请求. 使用SOAP请求webservice服务的流程如下: 1.进入项目目录,安装 so ...

随机推荐

  1. DBA_Oracle Erp重启Database/Application/Concurrent/Apache(案例)

    2014-12-27 Created By BaoXinjian

  2. BIP_开发案例04_通过BI Publisher实现打印报表的二维码(案例)(待整理)

    2014-01-01 Created BaoXinjian

  3. Shell_Oracle Erp基于主机文件Host开发详解(案例)

    2014-06-20 Created By BaoXinjian

  4. 转--Android中调用webservice的工具类

    最近学习WebService,感觉利用这个借口开发网站的Android客户端方便及了,用到一个工具类,这里铭记一下. public static final String WebServiceName ...

  5. 改变select组件的option选中状态的快捷方法

    以前我都是在<option>标签处通过判断value是否与其中一个相同然后输出selected="selected"来处理的,今天发现可以直接能过Js改变<sel ...

  6. Java中的匿名类

    我们知道接口一般用于定义一种规范或操作协议,然后子类实现接口的所有功能.如下面的简单代码: 定义IMessage接口 package org.lyk.entities; public interfac ...

  7. jquery怎么实现跨域的访问呢?与别人提供的接口连接

    下面这个例子你可以参考下 <script> $.ajax({ async:false, url: 'http://www.mysite.com/demo.do',  // 跨域URL ty ...

  8. eclipse设置svn代理

    共2个步骤: 1. 找到C:\Documents and Settings\用户名\Application Data\Subversion的servers文件, 将#http-proxy-host和# ...

  9. Java 线程间通讯(共享变量方式)

    Java线程间通讯,最常用的方式便是共享变量方式,多个线程共享一个静态变量就可以实现在线程间通讯,但是这需要注意的就是线程同步问题. 一.没考虑线程同步: package com.wyf; publi ...

  10. jquery mobile转场时加载js失效(转)

    jquery mobile拦截了所有的http请求,并使用ajax请求取代传统的http.请求发出后,框架会将请求的内容插入到页面中data- role="page"的部分,取代原 ...