public static Command CreateModel(DataRow dr) { Command cmd = new Command(); if (dr.Table.Columns.Contains("Id")) { cmd.Id = LibConvert.ObjToInt64(dr["Id"]); } if (dr.Table.Columns.Contains("TaskId")) { cmd.TaskId = LibConvert.ObjToInt64(dr["TaskId"]); } if (dr.Table.Columns.Contains("NodeId")) { cmd.NodeId = LibConvert.ObjToInt64(dr["NodeId"]); } if (dr.Table.Columns.Contains("CommandType")) { cmd.CommandType = (CommandType)LibConvert.ObjToInt(dr["CommandType"]); } if (dr.Table.Columns.Contains("CreateTime")) { cmd.CreateTime = LibConvert.ObjToDateTime(dr["CreateTime"]); } if (dr.Table.Columns.Contains("State")) { cmd.State = LibConvert.ObjToInt(dr["State"]); } return(cmd); }
/// <summary> /// 取得已消费的数量 /// </summary> /// <param name="conn"></param> /// <param name="lastMqId"></param> /// <returns></returns> public long GetMsgCount(DbConn conn, long lastMqId) { return(SqlHelper.Visit((ps) => { MQIDInfo info = PartitionRuleHelper.GetMQIDInfo(lastMqId); string sql = "SELECT SUM(mqcount) FROM [tb_partition_messagequeue_report] WITH(NOLOCK) WHERE [day]<@day AND partitionid=@partitionid"; ps.Add("@day", info.Day); ps.Add("@partitionid", PartitionRuleHelper.GetPartitionID(new PartitionIDInfo() { DataNodePartition = info.DataNodePartition, TablePartition = info.TablePartition })); string tableName = PartitionRuleHelper.GetTableName(info.TablePartition, info.Day); object obj = conn.ExecuteScalar(sql, ps.ToParameters()); long msgCount = 0; if (obj != DBNull.Value && obj != null) { msgCount = LibConvert.ObjToInt64(obj); } long lastCount = 0; using (DbConn nodeConn = DbConfig.CreateConn(DataConfig.DataNodeParConn(PartitionRuleHelper.PartitionNameRule(info.DataNodePartition)))) { nodeConn.Open(); var dal = new tb_messagequeue_dal(); dal.TableName = tableName; lastCount = dal.GetLastDayMsgCount(nodeConn, lastMqId); } return msgCount + lastCount; })); }
public static Config CreateModel(DataRow dr) { Config config = new Config(); if (dr.Table.Columns.Contains("Id")) { config.Id = LibConvert.ObjToInt64(dr["Id"]); } if (dr.Table.Columns.Contains("CategoryId")) { config.CategoryId = LibConvert.ObjToInt64(dr["CategoryId"]); } if (dr.Table.Columns.Contains("ConfigKey")) { config.ConfigKey = LibConvert.ObjToStr(dr["ConfigKey"]); } if (dr.Table.Columns.Contains("ConfigValue")) { config.ConfigValue = LibConvert.ObjToStr(dr["ConfigValue"]); } if (dr.Table.Columns.Contains("Remark")) { config.Remark = LibConvert.ObjToStr(dr["Remark"]); } if (dr.Table.Columns.Contains("CreateTime")) { config.CreateTime = LibConvert.ObjToDateTime(dr["CreateTime"]); } if (dr.Table.Columns.Contains("UpdateTime")) { config.UpdateTime = LibConvert.ObjToDateTime(dr["UpdateTime"]); } return(config); }
public static Project CreateModel(DataRow dr) { Project project = new Project(); if (dr.Table.Columns.Contains("Id")) { project.Id = LibConvert.ObjToInt64(dr["Id"]); } if (dr.Table.Columns.Contains("ProjectName")) { project.ProjectName = LibConvert.ObjToStr(dr["ProjectName"]); } if (dr.Table.Columns.Contains("CategoryIds")) { project.CategoryIds = LibConvert.ObjToStr(dr["CategoryIds"]); } if (dr.Table.Columns.Contains("Remark")) { project.Remark = LibConvert.ObjToStr(dr["Remark"]); } if (dr.Table.Columns.Contains("CreateTime")) { project.CreateTime = LibConvert.ObjToDateTime(dr["CreateTime"]); } return(project); }
public long GetLastMqIdByPartitionId(DbConn conn, int partitionId) { return(SqlHelper.Visit((ps) => { string sql = string.Format("SELECT lastmqid FROM tb_consumer_partition WITH(NOLOCK) WHERE partitionId={0}", partitionId.Tostring()); object obj = conn.ExecuteScalar(sql, null); if (obj != DBNull.Value && obj != null) { return LibConvert.ObjToInt64(obj); } return 0; })); }
/// <summary> /// 取得未消费的数量 /// </summary> /// <param name="lastMqId"></param> /// <returns></returns> public long GetNonMsgCount(DbConn conn, long lastMqId) { return(SqlHelper.Visit((ps) => { MQIDInfo info = PartitionRuleHelper.GetMQIDInfo(lastMqId); var currentday = conn.GetServerDate().Date; string sql = "SELECT SUM(mqcount) FROM [tb_partition_messagequeue_report] WITH(NOLOCK) WHERE [day]>@day AND partitionid=@partitionid AND [day]<>@currentday"; ps.Add("@day", info.Day); ps.Add("@currentday", currentday); ps.Add("@partitionid", PartitionRuleHelper.GetPartitionID(new PartitionIDInfo() { DataNodePartition = info.DataNodePartition, TablePartition = info.TablePartition })); object obj = conn.ExecuteScalar(sql, ps.ToParameters()); long msgCount = 0; if (obj != DBNull.Value && obj != null) { msgCount = LibConvert.ObjToInt64(obj); } long firstCount = 0; long lastCount = 0; using (DbConn nodeConn = DbConfig.CreateConn(DataConfig.DataNodeParConn(PartitionRuleHelper.PartitionNameRule(info.DataNodePartition)))) { nodeConn.Open(); string firsttableName = PartitionRuleHelper.GetTableName(info.TablePartition, info.Day); var msgDal = new tb_messagequeue_dal(); msgDal.TableName = firsttableName; firstCount = msgDal.GetLastDayNonMsgCount(nodeConn, lastMqId); if (info.Day != currentday)//不是今天 { string lasttableName = PartitionRuleHelper.GetTableName(info.TablePartition, currentday); var dal = new tb_messagequeue_dal(); dal.TableName = lasttableName; long maxmqid = dal.GetMaxID(nodeConn); if (lastMqId == 0) { lastCount = 0; } else { lastCount = dal.GetLastDayMsgCount(nodeConn, maxmqid); } } } //最后一天剩余 return msgCount + firstCount + lastCount; })); }
public static SystemConfig CreateModel(DataRow dr) { SystemConfig o = new SystemConfig(); if (dr.Table.Columns.Contains("Id")) { o.Id = LibConvert.ObjToInt64(dr["Id"]); } if (dr.Table.Columns.Contains("ConfigKey")) { o.ConfigKey = LibConvert.ObjToStr("ConfigKey"); } if (dr.Table.Columns.Contains("ConfigValue")) { o.ConfigValue = LibConvert.ObjToStr(dr["ConfigValue"]); } if (dr.Table.Columns.Contains("Remark")) { o.Remark = LibConvert.ObjToStr(dr["Remark"]); } return(o); }
public static Category CreateModel(DataRow dr) { Category category = new Category(); if (dr.Table.Columns.Contains("Id")) { category.Id = LibConvert.ObjToInt64(dr["Id"]); } if (dr.Table.Columns.Contains("CategoryName")) { category.CategoryName = LibConvert.ObjToStr(dr["CategoryName"]); } if (dr.Table.Columns.Contains("Remark")) { category.Remark = LibConvert.ObjToStr(dr["Remark"]); } if (dr.Table.Columns.Contains("CreateTime")) { category.CreateTime = LibConvert.ObjToDateTime(dr["CreateTime"]); } return(category); }
public static TaskModel CreateModel(DataRow dr) { TaskModel model = new TaskModel(); if (dr.Table.Columns.Contains("Id")) { model.Id = LibConvert.ObjToInt64(dr["Id"]); } if (dr.Table.Columns.Contains("TaskName")) { model.TaskName = LibConvert.ObjToStr(dr["TaskName"]); } if (dr.Table.Columns.Contains("TaskDescription")) { model.TaskDescription = LibConvert.ObjToStr(dr["TaskDescription"]); } if (dr.Table.Columns.Contains("CategoryId")) { model.CategoryId = LibConvert.ObjToInt64(dr["CategoryId"]); } if (dr.Table.Columns.Contains("NodeId")) { model.NodeId = LibConvert.ObjToInt64(dr["NodeId"]); } if (dr.Table.Columns.Contains("TaskCreateTime")) { model.TaskCreateTime = LibConvert.ObjToDateTime(dr["TaskCreateTime"]); } if (dr.Table.Columns.Contains("TaskUpdateTime")) { model.TaskUpdateTime = LibConvert.ObjToDateTimeOrNull(dr["TaskUpdateTime"]); } if (dr.Table.Columns.Contains("TaskStartTime")) { model.TaskStartTime = LibConvert.ObjToDateTimeOrNull(dr["TaskStartTime"]); } if (dr.Table.Columns.Contains("TaskStopTime")) { model.TaskStopTime = LibConvert.ObjToDateTimeOrNull(dr["TaskStopTime"]); } if (dr.Table.Columns.Contains("TaskCron")) { model.TaskCron = LibConvert.ObjToStr(dr["TaskCron"]); } if (dr.Table.Columns.Contains("TaskState")) { model.TaskState = LibConvert.ObjToInt(dr["TaskState"]); } if (dr.Table.Columns.Contains("TaskClassPath")) { model.TaskClassPath = LibConvert.ObjToStr(dr["TaskClassPath"]); } if (dr.Table.Columns.Contains("TaskFileName")) { model.TaskFileName = LibConvert.ObjToStr(dr["TaskFileName"]); } if (dr.Table.Columns.Contains("TaskClassNamespace")) { model.TaskClassNamespace = LibConvert.ObjToStr(dr["TaskClassNamespace"]); } return(model); }