Exemplo n.º 1
0
        private string GetTrdFileID(ShopData shop, DateTime begin, DateTime end, T_ERP_ShopTrade shpTrd) {
            try {
                using (var blk = new SqlBulkCopy(_con)) {
                    blk.DestinationTableName = shop.TradeTableName;
                    blk.WriteToServer<T_ERP_ShopTrade>(shpTrd);
                }
                var fileId = SqlHelper.ExecuteScalar(_con, System.Data.CommandType.Text,
                    string.Format("select id from {0} where guid='{1}'", shop.TradeTableName, shpTrd.Guid));
                var fileName = _filepath + "trade\\" + shop.SellerNick + "\\" + fileId.ToString() + ".json";
                if (!File.Exists(_filepath + "test.txt")) {
                    _applog.DebugException(new Exception("路径不合法或者测试文件不存在!"));
                    return string.Empty;
                }
                return fileName;
            } catch (Exception ex) {
                _applog.DebugException(ex);
#if DEBUG
                throw;
#else
#endif
            }
        }
Exemplo n.º 2
0
        protected int SyncRetry(T_ERP_SyncLog sd)
        {
            try
            {
                var prmMin = new SqlParameter("@minjdp", sd.MinDateTime);
                var prmMax = new SqlParameter("@maxjdp", sd.MaxDateTime);
                var prmNick = new SqlParameter("@Nick", sd.SellerNick);

                var dt = SqlHelper.ExecuteDataTable(_con, System.Data.CommandType.StoredProcedure, ProcShopRetry, prmNick, prmMin, prmMax);
                if (dt == null || dt.Rows.Count < 1) return 0;
                var jds = ObjectHelper.Create<Jdp>(dt);
                if (null == jds || jds.Count < 1) return 0;
                //_applog.DebugException(new Exception(string.Format("RETRY\tSHOP:{1}\tCOUNT:{0}\tBegin:{1}\tEnd:{2}\tFor Retry Sync.", jds.Count, sd.SellerNick,
                //    sd.MinDateTime.ToDefaultStr(),sd.MaxDateTime.ToDefaultStr())));

                DateTime begin = (DateTime)(prmMin.Value);
                DateTime end = (DateTime)(prmMax.Value);

                var shop = GetShops().Where(p => p.SellerNick.Equals(sd.SellerNick)).FirstOrDefault();

                Guid shpguid = Guid.NewGuid();
                List<TradeFullinfoGetResponse> trdf = jds.Select(k => TopUtils.ParseResponse<TradeFullinfoGetResponse>(k.jdp_response))
                        .ToList();
                var trds = trdf.Select(k => k.Trade).ToList();
                var shpTrd = new T_ERP_ShopTrade()
                {
                    Begin = begin,
                    End = end,
                    Guid = shpguid,
                    SellerNick = shop.SellerNick,
                    JdpCount = trds.Count(),
                    TrdPayed = trds.Where(p => !string.IsNullOrEmpty(p.PayTime)).Count(),
                    TrdUnPay = trds.Where(p => string.IsNullOrEmpty(p.PayTime)).Count(),
                    TrdStep = trds.Where(p => !string.IsNullOrEmpty(p.StepTradeStatus)).Count()
                };

                var fileName = GetTrdFileID(shop, begin, end, shpTrd);
                if (string.IsNullOrEmpty(fileName)) return 0;
                WriteFileTradeData(trds, fileName);
                //WriteDataEx(jds, new ShopData { SellerNick = sd.SellerNick }, sd.MinDateTime, sd.MaxDateTime, "重试");
                return jds.Count;
            }
            catch (Exception ex)
            {
                _applog.DebugException(ex);
#if DEBUG
                //throw;
#else
#endif
                return 100;
            }
        }