//根据用户id得到用户名 private string GetConsumer(string UserId, AccessDapperDber doorDapperDber) { string sql = " select name from userinfo where Badgenumber='" + UserId + "'"; DataTable dt = doorDapperDber.ExecuteDataTable(sql); if (dt != null && dt.Rows.Count > 0) { return(dt.Rows[0][0].ToString()); } return(""); }
private string GetMachine(string MachineId, AccessDapperDber doorDapperDber) { string sql = " select MachineAlias from Machines where id=" + MachineId + ""; DataTable dt = doorDapperDber.ExecuteDataTable(sql); if (dt != null && dt.Rows.Count > 0) { return(dt.Rows[0][0].ToString()); } return(""); }
/// <summary> /// 默认取当前月份轨道衡的数据 /// </summary> /// <param name="argConn">Access数据库连接串</param> /// <returns></returns> private DataTable getData(AccessDapperDber argConn) { DataTable dt = new DataTable(); int tempMonth = DateTime.Now.Month;//取当前日期的月份 int tempDay = -CommonDAO.GetInstance().GetAppletConfigInt32("轨道衡数据读取天数"); string sql = string.Format(@"select * from {0} where 发货单位 <> '' and 收货单位 <> '' and 时间 > '{1}'", tempMonth, getCurrentTime(DateTime.Now.AddDays(tempDay))); dt = argConn.ExecuteDataTable(sql); return(dt); }
private DcDbers() { BeltSampler_Dber = new SqlServerDapperDber(commonDAO.GetCommonAppletConfigString("皮带采样机接口连接字符串")); AutoCupboard_Dber = new SqlServerDapperDber(commonDAO.GetCommonAppletConfigString("智能存样柜接口连接字符串")); PneumaticTransfer_Dber = new SqlServerDapperDber(commonDAO.GetCommonAppletConfigString("气动传输接口连接字符串")); WeightBridger_Dber = new SqlServerDapperDber(commonDAO.GetCommonAppletConfigString("轨道衡数据库连接字符串")); CarJXSampler_Dber1 = new SqlServerDapperDber(commonDAO.GetCommonAppletConfigString("#1汽车机械采样机接口连接字符串")); CarJXSampler_Dber2 = new SqlServerDapperDber(commonDAO.GetCommonAppletConfigString("#2汽车机械采样机接口连接字符串")); WeightBridger_Dber1 = new AccessDapperDber(string.Format(commonDAO.GetAppletConfigString("轨道衡数据库连接字符串1"), DateTime.Now.Year)); }
/// <summary> /// 同步门禁数据 /// </summary> /// <param name="output"></param> public void SyncDoorData(Action <string, eOutputType> output, AccessDapperDber doorDapperDber) { int res = 0; string sql = " select * from acc_monitor_log where time>#2018-08-08#"; sql += " order by time"; DataTable dtNum = doorDapperDber.ExecuteDataTable(sql); if (dtNum.Rows.Count > 0) { for (int i = 0; i < dtNum.Rows.Count; i++) { string id = dtNum.Rows[i]["id"].ToString(); string userId = dtNum.Rows[i]["pin"].ToString(); string deviceId = dtNum.Rows[i]["device_id"].ToString(); string consumerName = GetConsumer(userId, doorDapperDber); string doorName = GetMachine(deviceId, doorDapperDber); if (string.IsNullOrEmpty(consumerName)) { continue; } if (string.IsNullOrEmpty(doorName)) { continue; } CmcsGuardInfo entity = Dbers.GetInstance().SelfDber.Entity <CmcsGuardInfo>("where NId=:NId", new { NId = id }); if (entity == null) { entity = new CmcsGuardInfo() { DataFrom = "智能化", F_ConsumerId = userId, F_ConsumerName = consumerName, F_InOut = "1", F_ReaderId = deviceId, F_ReaderName = doorName, NId = id, F_ReadDate = DateTime.Parse(dtNum.Rows[i]["time"].ToString()) }; res += Dbers.GetInstance().SelfDber.Insert(entity); } } } output(string.Format("同步门禁数据{0}条", res), eOutputType.Normal); }
/// <summary> /// 执行所有任务 /// </summary> void ExecuteAllTask() { DataHandlerDAO dataHandlerDAO = DataHandlerDAO.GetInstance(); taskSimpleScheduler.StartNewTask("同步批次明细", () => { dataHandlerDAO.SyncToBatch(this.rTxtOutputer.Output); }, 60000, OutputError); taskSimpleScheduler.StartNewTask("同步集控信号", () => { dataHandlerDAO.SyncHomePageSignalData(this.rTxtOutputer.Output); }, 60000, OutputError); AccessDapperDber doorDapperDber = new AccessDapperDber("Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info =true;Data Source=\\\\10.36.0.71\\ZKAccess3.5\\ZKAccess.mdb;"); taskSimpleScheduler.StartNewTask("同步门禁数据", () => { //dataHandlerDAO.SyncDoorData(this.rTxtOutputer.Output, doorDapperDber); }, 60000, OutputError); }
public override System.Data.DataTable ExecuteGrab() { AccessDapperDber accessDber = new AccessDapperDber(ConnStr); return(accessDber.ExecuteDataTable("select * from sample where Date > #" + DateTime.Now.AddDays(-DayRange).ToString("yyyy-MM-dd") + "#")); }
/// <summary> /// 同步集样罐信息到集中管控 /// </summary> /// <param name="output"></param> /// <returns></returns> public void SyncBarrel(Action <string, eOutputType> output, AccessDapperDber accessDapperDber) { int res = 0; DataTable infpdcybarrels = accessDapperDber.ExecuteDataTable("select * from 桶号点数"); if (infpdcybarrels != null && infpdcybarrels.Rows.Count > 0) { for (int i = 0; i < infpdcybarrels.Rows.Count; i++) { InfEquInfSampleBarrel oldEquInfSampleBarrel = Dbers.GetInstance().SelfDber.Entity <InfEquInfSampleBarrel>("where MachineCode=:MachineCode and BarrelNumber=:BarrelNumber" , new { MachineCode = this.MachineCode, BarrelNumber = infpdcybarrels.Rows[i]["桶号"].ToString() }); if (oldEquInfSampleBarrel == null) { InfEquInfSampleBarrel entity = new InfEquInfSampleBarrel(); entity.BarrelNumber = infpdcybarrels.Rows[i]["桶号"].ToString(); entity.SampleCount = Convert.ToInt32(infpdcybarrels.Rows[i]["点数"].ToString()); entity.BarrelStatus = entity.SampleCount > 0 ? "未满" : "空桶"; DataTable dtSetUp = accessDapperDber.ExecuteDataTable("select * from 系统参数"); if (dtSetUp != null && dtSetUp.Rows.Count > 0) { int count = Convert.ToInt32(dtSetUp.Rows[0]["盛样点数"].ToString()); if (entity.SampleCount == count) { entity.BarrelStatus = "已满"; } } entity.MachineCode = this.MachineCode; //InFactoryBatchId = entity.InFactoryBatchId, entity.InterfaceType = commonDAO.GetMachineInterfaceTypeByCode(this.MachineCode); string dqth = commonDAO.GetSignalDataValue(MachineCode, "当前桶号"); if (entity.BarrelNumber == dqth) { entity.IsCurrent = 1; } else { entity.IsCurrent = 0; } entity.SampleCode = infpdcybarrels.Rows[i]["单位"].ToString(); entity.UpdateTime = DateTime.Now; //BarrelType = entity.BarrelType, if (Dbers.GetInstance().SelfDber.Insert(entity) > 0) { res++; } ; } else { oldEquInfSampleBarrel.BarrelNumber = infpdcybarrels.Rows[i]["桶号"].ToString(); oldEquInfSampleBarrel.SampleCount = Convert.ToInt32(infpdcybarrels.Rows[i]["点数"].ToString()); oldEquInfSampleBarrel.BarrelStatus = oldEquInfSampleBarrel.SampleCount > 0 ? "未满" : "空桶"; DataTable dtSetUp = accessDapperDber.ExecuteDataTable("select * from 系统参数"); if (dtSetUp != null && dtSetUp.Rows.Count > 0) { int count = Convert.ToInt32(dtSetUp.Rows[0]["盛样点数"].ToString()); if (oldEquInfSampleBarrel.SampleCount == count) { oldEquInfSampleBarrel.BarrelStatus = "已满"; } } //oldEquInfSampleBarrel.InFactoryBatchId = equInfSampleBarrel.InFactoryBatchId; string dqth = commonDAO.GetSignalDataValue(MachineCode, "当前桶号"); if (oldEquInfSampleBarrel.BarrelNumber == dqth) { oldEquInfSampleBarrel.IsCurrent = 1; } else { oldEquInfSampleBarrel.IsCurrent = 0; } oldEquInfSampleBarrel.SampleCode = infpdcybarrels.Rows[i]["单位"].ToString(); oldEquInfSampleBarrel.UpdateTime = DateTime.Now; //oldEquInfSampleBarrel.DataFlag = equInfSampleBarrel.DataFlag; if (Dbers.GetInstance().SelfDber.Update(oldEquInfSampleBarrel) > 0) { res++; } } //{ // entity.DataFlag = 1; // DcDbers.GetInstance().CarJXSampler_Dber.Update(entity); // res++; //} } } output(string.Format("同步集样罐记录 {0} 条", res), eOutputType.Normal); }