/// <summary> /// 得到一个对象实体 /// </summary> public static SynchroCommon.TableSynchroTask DataRowToTableSynchroTask(DataRow row) { SynchroCommon.TableSynchroTask model = new SynchroCommon.TableSynchroTask(); if (row != null) { if (row["TableSynchroTaskID"] != null && row["TableSynchroTaskID"].ToString() != "") { model.TableSynchroTaskID = new Guid(row["TableSynchroTaskID"].ToString()); } if (row["TableName"] != null) { model.TableName = row["TableName"].ToString(); } if (row["TableRowID"] != null && row["TableRowID"].ToString() != "") { model.TableRowID = row["TableRowID"].ToString(); } if (row["OperationType"] != null && row["OperationType"].ToString() != "") { model.OperationType = int.Parse(row["OperationType"].ToString()); } if (row["TaskState"] != null && row["TaskState"].ToString() != "") { model.TaskState = int.Parse(row["TaskState"].ToString()); } if (row["AddDate"] != null && row["AddDate"].ToString() != "") { model.AddDate = DateTime.Parse(row["AddDate"].ToString()); } } return(model); }
public static List <SynchroCommon.TableSynchroTask> GetTableSynchroTaskList() { try { List <SynchroCommon.TableSynchroTask> _TableSynchroTaskList = new List <SynchroCommon.TableSynchroTask>(); DataTable taskDataTable = new DataTable(); using (SqlConnection conn = new SqlConnection(getTmpAppConnectionString())) { string sql = " select top 10* from TableSynchroTask where TaskState=0 and TableRowID is Not NULL order by AddDate"; using (SqlDataAdapter sd = new SqlDataAdapter(sql, conn)) { sd.Fill(taskDataTable); } if (taskDataTable.Rows.Count > 0) { for (int i = 0; i < taskDataTable.Rows.Count; i++) { DataRow row = taskDataTable.Rows[i]; SynchroCommon.TableSynchroTask item = new SynchroCommon.TableSynchroTask(); item = DataRowToTableSynchroTask(taskDataTable.Rows[i]); //UserLoginEx 特殊处理 if (item.TableName == "UserLoginEx" && _TableSynchroTaskList.Where(s => s.TableName == "UserLoginEx" && s.TableRowID == item.TableRowID).ToList().Count > 0) { continue; } _TableSynchroTaskList.Add(item); } } else { _TableSynchroTaskList = null; } } return(_TableSynchroTaskList); } catch (Exception ex) { LogService.WriteErr("程序错误,方法:GetTableSynchroTaskList 错误信息:" + ex.Message); return(null); } }