Ver Fonte

ftp抓取数去,后面全部手动释放

lcl há 6 meses atrás
pai
commit
0ec3a041be
1 ficheiros alterados com 59 adições e 59 exclusões
  1. 59 59
      Util/HaoDa/GetHaoDaFTPInfoService.cs

+ 59 - 59
Util/HaoDa/GetHaoDaFTPInfoService.cs

@@ -325,75 +325,75 @@ namespace MySystem
 
                 // 打开数据流
                 Stream responseStream = response.GetResponseStream();
-                using (StreamReader reader = new StreamReader(responseStream))
+                StreamReader reader = new StreamReader(responseStream)
+                // 读取数据
+                string fileContents = reader.ReadToEnd();
+                if (!string.IsNullOrEmpty(fileContents))
                 {
                     WebCMSEntities db = new WebCMSEntities();
-                    // 读取数据
-                    string fileContents = reader.ReadToEnd();
-                    if (!string.IsNullOrEmpty(fileContents))
+                    var DataInfo = fileContents.TrimEnd('\n').Split('\n', 2);
+                    var DataList = DataInfo[1].Split('\n');
+                    foreach (var DataListItem in DataList)
                     {
-                        var DataInfo = fileContents.TrimEnd('\n').Split('\n', 2);
-                        var DataList = DataInfo[1].Split('\n');
-                        foreach (var DataListItem in DataList)
+                        var DataListInfo = DataListItem.Split(',');
+
+                        var MerchantNo = ""; // 商户号
+                        var BaseNo = ""; // 设备号
+                        var OrderNo = ""; // 订单号
+                        var PayWay = ""; // 支付方式(微信 支付宝)
+                        var TradeType = ""; // 交易类型
+                        var TradeAmount = ""; // 交易金额
+                        var TradeFee = ""; // 交易手续费
+                        var TradeDate = ""; // 交易时间
+                        var TradeCycle = ""; // 结算周期
+
+                        MerchantNo = DataListInfo[0];
+                        BaseNo = DataListInfo[1];
+                        OrderNo = DataListInfo[2];
+                        PayWay = DataListInfo[3];
+                        TradeType = DataListInfo[4];
+                        TradeAmount = DataListInfo[5];
+                        TradeFee = DataListInfo[6];
+                        TradeDate = DataListInfo[7];
+                        TradeCycle = DataListInfo[8];
+
+                        TradeDate = TradeDate.Substring(0, 4) + "-" + TradeDate.Substring(4, 2) + "-" + TradeDate.Substring(6, 2) + " " + TradeDate.Substring(8, 2) + ":" + TradeDate.Substring(10, 2) + ":" + TradeDate.Substring(12, 2);
+
+                        var PayMode = 0;
+                        if (PayWay.Contains("支付宝")) PayMode = 1;
+                        if (PayWay.Contains("微信")) PayMode = 2;
+
+                        var merchantAddInfo = db.MerchantAddInfo.FirstOrDefault(m => m.MchtNo == MerchantNo) ?? new MerchantAddInfo();
+                        if (merchantAddInfo.Id > 0)
                         {
-                            var DataListInfo = DataListItem.Split(',');
-
-                            var MerchantNo = ""; // 商户号
-                            var BaseNo = ""; // 设备号
-                            var OrderNo = ""; // 订单号
-                            var PayWay = ""; // 支付方式(微信 支付宝)
-                            var TradeType = ""; // 交易类型
-                            var TradeAmount = ""; // 交易金额
-                            var TradeFee = ""; // 交易手续费
-                            var TradeDate = ""; // 交易时间
-                            var TradeCycle = ""; // 结算周期
-
-                            MerchantNo = DataListInfo[0];
-                            BaseNo = DataListInfo[1];
-                            OrderNo = DataListInfo[2];
-                            PayWay = DataListInfo[3];
-                            TradeType = DataListInfo[4];
-                            TradeAmount = DataListInfo[5];
-                            TradeFee = DataListInfo[6];
-                            TradeDate = DataListInfo[7];
-                            TradeCycle = DataListInfo[8];
-
-                            TradeDate = TradeDate.Substring(0, 4) + "-" + TradeDate.Substring(4, 2) + "-" + TradeDate.Substring(6, 2) + " " + TradeDate.Substring(8, 2) + ":" + TradeDate.Substring(10, 2) + ":" + TradeDate.Substring(12, 2);
-
-                            var PayMode = 0;
-                            if (PayWay.Contains("支付宝")) PayMode = 1;
-                            if (PayWay.Contains("微信")) PayMode = 2;
-
-                            var merchantAddInfo = db.MerchantAddInfo.FirstOrDefault(m => m.MchtNo == MerchantNo) ?? new MerchantAddInfo();
-                            if (merchantAddInfo.Id > 0)
+                            var merchantInfo = db.MerchantInfo.FirstOrDefault(m => m.Id == merchantAddInfo.Id) ?? new MerchantInfo();
+                            var orders = db.ConsumerOrders.FirstOrDefault(m => m.SeoTitle == OrderNo && m.OrderNo == OrderNo) ?? new ConsumerOrders();
+                            if (orders.Id == 0)
                             {
-                                var merchantInfo = db.MerchantInfo.FirstOrDefault(m => m.Id == merchantAddInfo.Id) ?? new MerchantInfo();
-                                var orders = db.ConsumerOrders.FirstOrDefault(m => m.SeoTitle == OrderNo && m.OrderNo == OrderNo) ?? new ConsumerOrders();
-                                if (orders.Id == 0)
+                                var query = db.ConsumerOrders.Add(new ConsumerOrders()
                                 {
-                                    var query = db.ConsumerOrders.Add(new ConsumerOrders()
-                                    {
-                                        Status = 1,
-                                        CreateDate = DateTime.Parse(TradeDate),
-                                        UpdateDate = DateTime.Parse(TradeDate),
-                                        SnNo = BaseNo,
-                                        PayMoney = decimal.Parse(TradeAmount),
-                                        PayMode = PayMode,
-                                        SeoTitle = OrderNo,
-                                        OrderNo = OrderNo,
-                                        MerchantId = merchantAddInfo.Id,
-                                        UserId = merchantInfo.UserId
-                                    }).Entity;
-                                }
+                                    Status = 1,
+                                    CreateDate = DateTime.Parse(TradeDate),
+                                    UpdateDate = DateTime.Parse(TradeDate),
+                                    SnNo = BaseNo,
+                                    PayMoney = decimal.Parse(TradeAmount),
+                                    PayMode = PayMode,
+                                    SeoTitle = OrderNo,
+                                    OrderNo = OrderNo,
+                                    MerchantId = merchantAddInfo.Id,
+                                    UserId = merchantInfo.UserId
+                                }).Entity;
                             }
                         }
-                        db.SaveChanges();
-                        db.Dispose();
                     }
-
-                    // 关闭响应
-                    response.Close();
+                    db.SaveChanges();
+                    db.Dispose();
                 }
+
+                // 关闭响应
+                reader.Dispose();
+                responseStream.Dispose();
+                response.Close();
             }
             catch (WebException ex)
             {