private void btnSearch_Click(object sender, EventArgs e) { YCTBlacklistSearchCondition con = null; if (chkCatched.Checked) { con = new YCTBlacklistSearchCondition(); con.OnlyCatched = true; } List <YCTBlacklist> bls = new YCTBlacklistBll(AppSettings.CurrentSetting.MasterParkConnect).GetItems(con).QueryObjects; if (!string.IsNullOrEmpty(txtCardID.Text)) { bls = bls.Where(it => it.LCN.Contains(txtCardID.Text)).ToList(); } dataGridView1.Rows.Clear(); foreach (var bl in bls) { int row = dataGridView1.Rows.Add(); dataGridView1.Rows[row].Cells["colLCN"].Value = bl.LCN; dataGridView1.Rows[row].Cells["colFCN"].Value = bl.FCN; dataGridView1.Rows[row].Cells["colReason"].Value = GetReason(bl.Reason); dataGridView1.Rows[row].Cells["colCatchAt"].Value = bl.CatchAt; dataGridView1.Rows[row].Cells["colUploadFile"].Value = bl.UploadFile; } lblMsg.Text = string.Format("共有 {0} 项", bls != null ? bls.Count : 0); }
private void ExtraFile(string file) { if (Path.GetExtension(file).ToUpper() == ".ZIP") { string[] mds = ReadMD(file); if (mds != null && mds.Length > 0) { InsertMsg("解析黑名单..."); YCTBlacklistBll bll = new YCTBlacklistBll(AppSettings.CurrentSetting.MasterParkConnect); List <YCTBlacklist> bl = bll.GetItems(null).QueryObjects; Dictionary <string, YCTBlacklist> blacks = new Dictionary <string, YCTBlacklist>(); bl.ForEach(it => blacks.Add(it.LCN, it)); List <YCTBlacklist> addings = new List <YCTBlacklist>(); foreach (var md in mds) { string[] temp = md.Split('\t'); if (temp.Length >= 3) { string lcn = temp[1].Length == 16 ? temp[1] : temp[0]; //CPU名单逻辑卡号在第二个位置, M1卡名单逻辑卡号在第一个位置 string fcn = temp[1].Length == 16 ? temp[0] : temp[1]; //物理卡号位置与逻辑卡号刚好相反 if (!blacks.ContainsKey(lcn)) { YCTBlacklist yb = new YCTBlacklist(); yb.LCN = lcn; yb.FCN = fcn; yb.Reason = temp[2]; yb.AddDateTime = DateTime.Now; addings.Add(yb); } } } if (addings.Count > 0) { int count = 0; List <YCTBlacklist> temp = new List <YCTBlacklist>(); foreach (YCTBlacklist it in addings) { if (temp.Count < 1000) { temp.Add(it); count++; } if (temp.Count == 1000) { bll.BatchInsert(temp); temp.Clear(); InsertMsg(string.Format("导入黑名单完成 {0:P}", (decimal)count / addings.Count)); } } if (temp.Count > 0) { bll.BatchInsert(temp); temp.Clear(); } } InsertMsg("完成黑名单解析"); } } }
private YCTBlacklist GetBlackList(string logicCardID, string physicalCardID) { var item = new YCTBlacklistBll(AppSettings.CurrentSetting.MasterParkConnect).GetByID(logicCardID).QueryObject; return(item); }
private void SyncUploadFiles(FtpClient ftp, YCTSetting yct) { //DateTime dt = DateTime.Now; DateTime dt = DateTime.Today.AddMilliseconds(-1); string m1Zip = string.Format("XF{0}{1}{2}.ZIP", yct.ServiceCode.ToString().PadLeft(4, '0'), yct.ReaderCode.ToString().PadLeft(4, '0'), dt.ToString("yyyyMMdd")); string cpuZip = string.Format("CX{0}{1}{2}.ZIP", yct.ServiceCode.ToString().PadLeft(4, '0'), yct.ReaderCode.ToString().PadLeft(4, '0'), dt.ToString("yyyyMMddHH")); InsertMsg("定位到: " + _WriteFolder); ftp.SetWorkingDirectory(_WriteFolder); var items = ftp.GetListing(_WriteFolder, FtpListOption.NoPath); if (items == null && items.Length == 0 || items.Count(it => it.Name == m1Zip) == 0) { YCTPaymentRecordSearchCondition con = new YCTPaymentRecordSearchCondition() //获取所有钱包类型为M1钱包且未上传的记录 { WalletType = 1, State = (int)YCTPaymentRecordState.PaidOk, UnUploaded = true, PaymentDateTimeRange = new DateTimeRange(new DateTime(2010, 1, 1), dt) }; List <YCTPaymentRecord> records = new YCTPaymentRecordBll(AppSettings.CurrentSetting.MasterParkConnect).GetItems(con).QueryObjects; if (records != null && records.Count > 0) { YCTBlacklistSearchCondition ycon = new YCTBlacklistSearchCondition(); ycon.WalletType = 1; //M ycon.OnlyCatched = true; ycon.OnlyUnUploaded = true; List <YCTBlacklist> blacks = new YCTBlacklistBll(AppSettings.CurrentSetting.MasterParkConnect).GetItems(ycon).QueryObjects; string zip = YCTUploadFileFactory.CreateM1UploadFile(dt, m1Zip, records, blacks); if (!string.IsNullOrEmpty(zip)) { InsertMsg("上传文件" + m1Zip); using (FileStream fs = new FileStream(zip, FileMode.Open, FileAccess.Read)) { ftp.Upload(m1Zip, fs); new YCTPaymentRecordBll(AppSettings.CurrentSetting.MasterParkConnect).BatchChangeUploadFile(records, m1Zip); if (blacks != null && blacks.Count > 0) { new YCTBlacklistBll(AppSettings.CurrentSetting.MasterParkConnect).BatchChangeUploadFile(blacks, m1Zip); } } } } } if (items == null && items.Length == 0 || items.Count(it => it.Name == cpuZip) == 0) { YCTPaymentRecordSearchCondition con = new YCTPaymentRecordSearchCondition() //获取所有钱包类型为CPU钱包且未上传的记录 { WalletType = 2, State = (int)YCTPaymentRecordState.PaidOk, UnUploaded = true, PaymentDateTimeRange = new DateTimeRange(new DateTime(2010, 1, 1), dt) }; List <YCTPaymentRecord> records = new YCTPaymentRecordBll(AppSettings.CurrentSetting.MasterParkConnect).GetItems(con).QueryObjects; if (records != null && records.Count > 0) { YCTBlacklistSearchCondition ycon = new YCTBlacklistSearchCondition(); ycon.WalletType = 2; //cpu ycon.OnlyCatched = true; ycon.OnlyUnUploaded = true; List <YCTBlacklist> blacks = new YCTBlacklistBll(AppSettings.CurrentSetting.MasterParkConnect).GetItems(ycon).QueryObjects; string zip = YCTUploadFileFactory.CreateCPUUploadFile(dt, cpuZip, records, blacks); if (!string.IsNullOrEmpty(zip)) { InsertMsg("上传文件" + cpuZip); using (FileStream fs = new FileStream(zip, FileMode.Open, FileAccess.Read)) { ftp.Upload(cpuZip, fs); new YCTPaymentRecordBll(AppSettings.CurrentSetting.MasterParkConnect).BatchChangeUploadFile(records, cpuZip); if (blacks != null && blacks.Count > 0) { new YCTBlacklistBll(AppSettings.CurrentSetting.MasterParkConnect).BatchChangeUploadFile(blacks, cpuZip); } } } } } }