public override Record ConvertToCq(CellArgs args) { Record r = null; string strTarget = args["Target"]; string strSample = args["Sample"]; string strCq = args["Cq"]; //Target 是否满足要求并截取 Target 编号 string tagName = TagEV.IsMeet(strTarget) ? TagEV.Extract(strTarget) : null; bool tnok = !string.IsNullOrEmpty(tagName); bool snok = !string.IsNullOrEmpty(strSample); double dCq = 0; bool cqok = !string.IsNullOrEmpty(strCq) && double.TryParse(strCq, out dCq) && dCq > 0; if (tnok && snok && cqok) { r = new Record() { TargetKey = tagName, Date = args.File.Date, SampleKey = strSample, SampleName = strSample, FID = args.File.FID, File = args.File.FileName, TargetName = strTarget, Value = dCq }; } return(r); }
void OnSwapCellListener(object sender, CellArgs cellArgs) { gameController.ChangeState(new SwapState(gameController, gameController.stateMachine)); bool canSwap = gameController.CanSwap(cellArgs.cell); if (canSwap) { gameController.SwapCell(cellArgs.cell); } else { SetIdleState(); } }
void OnMatchThreeFailedListener(object sender, CellArgs cell) { SetIdleState(); }
void OnSelectCellListener(object sender, CellArgs cellArgs) { gameController.ChangeState(new SelectState(gameController, gameController.stateMachine)); gameController.SetSelectedCell(cellArgs.cell); }
protected virtual void Each_FileHandleEvent(FileInfo info) { //判断文件是否符合要求 bool meet = true; meet = !info.Name.Contains("~$") && (EvFile?.IsMeet(info.Name) ?? false); if (meet) { //生成MD5 string md5 = ToGenerateMD5(info); MF file = new MF() { FID = md5, FileName = info.Name, Date = Convert.ToDateTime(EvFile.Extract(info.Name)) }; //查询数据库,判断是否已经读取过 bool readed = false; if (JoinDb) { using (IDbQuery query = DbIns.GetQuery("Cq")) { if (query != null) { query.Open(); object obj = query.SelectToValue(new QueryArgs() { Where = "FID=@FID", Rows = "Count(1)", Param = new DbParams[] { new DbParams("FID", md5) }, Group = "FID" }); int count = Convert.ToInt32(obj); readed = count > 0; } } } //循环读取 if (!readed) { using (IExcReader reader = ExcIns.GetReader()) { bool isopen = reader?.Open(info.FullName) ?? false; if (CellHelper != null && isopen) { CellHelper.ToObtainColumn = new string[] { "Target", "Sample", "Cq" }; using (IDbAlter alter = DbIns.GetAlter("Cq")) { alter.Open(); IDbTrans trans = DbIns.GetTrans(); trans.Begin(); while (reader.Read()) { Record cq = null; //如果列索引为空则查找索引 if (!CellHelper.IsFindColumn) { CellHelper.FindColumnIndex(reader.Columns); } //不为空则将单元格转化为 Cq ; else { CellArgs args = CellHelper.GetArgs(reader); args.File = file; cq = CqHelper.ConvertToCq(args); } //将 Cq 插入到分类集合中 if (cq != null) { if (JoinDb) { try { alter.Insert(cq, "ID"); } catch { trans.Rollback(); } } CqHelper?.InsertToCollection(cq, Group); } } trans.Commit(); } } } } } }
public abstract Record ConvertToCq(CellArgs args);