Beispiel #1
0
        public void PostPaymentuse()
        {
            SqlConnection conn = new SqlConnection("Server=.;Initial Catalog=mytest;User ID=sa;Password=123456;Pooling=true;Max Pool Size=1024;Min Pool Size=0;");

            StringBuilder sqlstr = new StringBuilder();

            sqlstr.Append(@"select * from daorushuju");
            conn.Open();
            SqlCommand    comm = new SqlCommand(sqlstr.ToString(), conn);
            SqlDataReader sdr  = comm.ExecuteReader();

            Pay_InfoEntity        payinfo      = new Pay_InfoEntity();
            List <Pay_InfoEntity> payinfolists = new List <Pay_InfoEntity>();

            while (sdr.Read())
            {
                payinfo = new Pay_InfoEntity
                {
                    Project_Name = sdr[2].ToString().Trim(),
                    Electricity_Supplier_Name = sdr[3].ToString().Trim(),
                    Pay_Money   = Convert.ToDecimal(sdr[6]),
                    Pay_Info_Id = sdr[10].ToString()
                };
                payinfolists.Add(payinfo);
                if (!sdr.HasRows)
                {
                    payinfo = new Pay_InfoEntity
                    {
                        Project_Name = "",
                    };
                    payinfolists.Add(payinfo);
                }
            }
            sdr.Close();
            conn.Close();

            string                      datetime       = DateTime.Now.ToString("yyyyMMdd");
            string                      paycode        = "History" + datetime + "A00";
            string                      i              = "1";
            string                      hetong         = "HT-" + datetime + "-00";
            EcommerceBLL                ecombll        = new EcommerceBLL();
            Base_ProjectInfoBLL         bpbbll         = new Base_ProjectInfoBLL();
            EcommerceProjectRelationBLL ecomprorelabll = new EcommerceProjectRelationBLL();
            bool isexprot = true;

            foreach (var item in payinfolists)
            {
                var projectdata = bpbbll.GetList("").ToList().Where(t => t.ProjecName == item.Project_Name).ToList();
                var ecomdata    = ecombll.GetList("").Where(t => t.EcommerceName == item.Electricity_Supplier_Name).ToList();
                if (ecomdata.Count == 0)
                {
                    isexprot = false;
                    string msg = string.Format("不存在该电商公司:{0}", item.Electricity_Supplier_Name);
                    Info(msg);
                    continue;
                }
                bool isexist = ecomprorelabll.GetProjectAndEcom().Any(t => t.ProjecName == item.Project_Name &&
                                                                      t.EcommerceName == item.Electricity_Supplier_Name);
                if (!isexist)
                {
                    isexprot = false;
                    string msg = string.Format("该电商公司(  {0}  )和项目(  {1}  )不存在", item.Electricity_Supplier_Name, item.Project_Name);
                    Error(msg);
                    continue;
                }
                InputPaymentuse abc = new InputPaymentuse();
                if (i.Length == 1)
                {
                    i = "0" + i;
                }
                abc.pay_info_id                = item.Pay_Info_Id;
                abc.pay_info_code              = paycode + i;
                abc.electricity_supplier_name  = item.Electricity_Supplier_Name;
                abc.electricity_supplier_code  = ecomdata[0].EcommerceCode;
                abc.electricity_supplier_id    = ecomdata[0].EcommerceID;
                abc.electricity_supplier_ad_id = ecomdata[0].EcommerceGroupID;
                abc.electricity_supplier_ad    = ecomdata[0].EcommerceGroupName;
                abc.project_code               = projectdata[0].ProjectCode;
                abc.project_id       = projectdata[0].ProjectID;
                abc.project_name     = item.Project_Name;
                abc.pay_info_type    = "EC";
                abc.contract_code    = hetong + i;
                abc.contract_name    = item.Project_Name + "历史合同数据";
                abc.pay_money        = Convert.ToDecimal(item.Pay_Money);
                abc.pay_createtime   = Convert.ToDateTime("2018/08/01");
                abc.pay_completetime = Convert.ToDateTime("2018/08/31");
                abc.pay_reason       = "导入历史数据";
                abc.approval_status  = "SUBMITED";
                abc.url        = "https://fssc.yango.com.cn/jiebao-plus/#/app/smart_expense/form/EC/306991952048422912/detail";
                abc.login_name = "金涛";
                abc.login_code = "金涛";
                i = (Convert.ToInt32(i) + 1).ToString();
                string param         = abc.ToJson();
                string a             = "";
                string paydatadetail = abc.ToJson();
                // data(paydatadetail);
            }
            if (!isexprot)
            {
                return;
            }
            foreach (var item in payinfolists)
            {
                var projectdata = bpbbll.GetList("").ToList().Where(t => t.ProjecName == item.Project_Name).ToList();
                var ecomdata    = ecombll.GetList("").Where(t => t.EcommerceName == item.Electricity_Supplier_Name).ToList();
                if (ecomdata.Count == 0)
                {
                    string msg = string.Format("不存在该电商公司:{0}", item.Electricity_Supplier_Name);
                    Error(msg);
                }
                InputPaymentuse abc = new InputPaymentuse();
                if (i.Length == 1)
                {
                    i = "0" + i;
                }
                abc.pay_info_id                = item.Pay_Info_Id;
                abc.pay_info_code              = paycode + i;
                abc.electricity_supplier_name  = item.Electricity_Supplier_Name;
                abc.electricity_supplier_code  = ecomdata[0].EcommerceCode;
                abc.electricity_supplier_id    = ecomdata[0].EcommerceID;
                abc.electricity_supplier_ad_id = ecomdata[0].EcommerceGroupID;
                abc.electricity_supplier_ad    = ecomdata[0].EcommerceGroupName;
                abc.project_code               = projectdata[0].ProjectCode;
                abc.project_id       = projectdata[0].ProjectID;
                abc.project_name     = item.Project_Name;
                abc.pay_info_type    = "EC";
                abc.contract_code    = hetong + i;
                abc.contract_name    = item.Project_Name + "历史合同数据";
                abc.pay_money        = Convert.ToDecimal(item.Pay_Money);
                abc.pay_createtime   = Convert.ToDateTime("2018/08/01");
                abc.pay_completetime = Convert.ToDateTime("2018/08/31");
                abc.pay_reason       = "导入历史数据";
                abc.approval_status  = "AUDITED";
                abc.url        = "https://fssc.yango.com.cn/jiebao-plus/#/app/smart_expense/form/EC/306991952048422912/detail";
                abc.login_name = "金涛";
                abc.login_code = "金涛";
                i = (Convert.ToInt32(i) + 1).ToString();
                string param = abc.ToJson();
                string a     = "";

                string res = HttpMethods.PostResponse("http://172.19.10.206:8090/api/money/paymentuse", param, out a);
            }
        }
Beispiel #2
0
 public void PostList()
 {
     string a     = "";
     string param = "[{'id':'1',	'age':1},{	'id':'2','age':100}]";
     string res   = HttpMethods.PostResponse("http://localhost:30004/api/List/", param, out a);
 }