Ejemplo n.º 1
0
 public void EditTask(string conn, TaskModel model)
 {
     string sql = @"UPDATE Task
                    SET TaskName = @name
                       ,TaskDescription = @descript
                       ,CategoryId = @categoryid
                       ,NodeId = @nodeid
                       ,TaskUpdateTime = @updatetime
                       ,TaskCron=@cron
                       ,TaskClassPath = @classpath
                       ,TaskFileName=@filename
                       ,TaskClassNamespace = @namespace WHERE Id = @id";
     SqlParameter[] paramters = new SqlParameter[]
     {
         new SqlParameter("@name",model.TaskName),
         new SqlParameter("@descript",model.TaskDescription),
         new SqlParameter("@categoryid",model.CategoryId),
         new SqlParameter("@nodeid",model.NodeId),
         new SqlParameter("@updatetime",model.TaskUpdateTime),
         new SqlParameter("@cron",model.TaskCron),
         new SqlParameter("@classpath",model.TaskClassPath),
         new SqlParameter("@filename",model.TaskFileName),
         new SqlParameter("@namespace",model.TaskClassNamespace),
         new SqlParameter("@id",model.Id)
     };
     SqlServerHelper.ExecuteNonQuery(conn, sql, paramters);
 }
Ejemplo n.º 2
0
 public void AddTask(string conn, TaskModel model)
 {
     string sql = @"INSERT INTO Task (TaskName,TaskDescription,CategoryId,NodeId,TaskCreateTime,TaskUpdateTime,TaskStartTime,TaskStopTime,TaskCron,TaskState,TaskClassPath,TaskFileName,TaskClassNamespace)
                  VALUES(@name
                        ,@description
                        ,@categoryid
                        ,@nodeid
                        ,@createtime
                        ,@updatetime
                        ,@starttime
                        ,@stoptime
                        ,@cron
                        ,@state
                        ,@classpath
                        ,@filename
                        ,@classnamespace)";
     SqlParameter[] paramters = new SqlParameter[]
     {
         new SqlParameter("@name",model.TaskName),
         new SqlParameter("@description",model.TaskDescription),
         new SqlParameter("@categoryid",model.CategoryId),
         new SqlParameter("@nodeid",model.NodeId),
         new SqlParameter("@createtime",model.TaskCreateTime),
         new SqlParameter("@updatetime",model.TaskUpdateTime),
         new SqlParameter("@starttime",model.TaskStartTime),
         new SqlParameter("@stoptime",model.TaskStopTime),
         new SqlParameter("@cron",model.TaskCron),
         new SqlParameter("@state",model.TaskState),
         new SqlParameter("@classpath",model.TaskClassPath),
         new SqlParameter("@filename",model.TaskFileName),
         new SqlParameter("@classnamespace",model.TaskClassNamespace)
     };
     SqlServerHelper.ExecuteNonQuery(conn, sql, paramters);
 }
Ejemplo n.º 3
0
 public TaskModel GetById(string conn, string taskid)
 {
     TaskModel task = new TaskModel();
     string sql = "SELECT Id,TaskName,TaskDescription,CategoryId,NodeId,TaskCreateTime,TaskUpdateTime,TaskStartTime,TaskStopTime,TaskCron,TaskState,TaskClassPath,TaskFileName,TaskClassNamespace FROM Task WHERE Id=@taskid";
     SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@taskid", taskid) };
     DataTable dt = SqlServerHelper.Get(conn, sql, parameters);
     if (dt.Rows.Count > 0)
     {
         task = TaskModel.CreateModel(dt.Rows[0]);
     }
     return task;
 }
Ejemplo n.º 4
0
 public List<TaskModel> List(string conn)
 {
     List<TaskModel> list = new List<TaskModel>();
     string sql = "SELECT Id,TaskName,TaskDescription,CategoryId,NodeId,TaskCreateTime,TaskUpdateTime,TaskStartTime,TaskStopTime,TaskCron,TaskState,TaskClassPath,TaskFileName,TaskClassNamespace FROM Task";
     DataTable dt = SqlServerHelper.Get(conn, sql);
     if (dt.Rows.Count > 0)
     {
         for (int i = 0; i < dt.Rows.Count; i++)
         {
             TaskModel model = new TaskModel();
             model = TaskModel.CreateModel(dt.Rows[i]);
             list.Add(model);
         }
     }
     return list;
 }
Ejemplo n.º 5
0
 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;
 }