public int Add(Job_Config record) { string sql = @"insert into Job_Config output inserted.ID values(@jname,@jdisplay,@gname,@cycleUnit,@interval,@assemblyName,@jclass, @start,@enabled,@dtCreatTime,@dtLastTime,@filePath,@status,@repeatMode,@fixedUnit,@FixedExpression)"; object autoId = SqlHelper.ExecuteScalar(sql, new SqlParameter("@jname", record.JobName), new SqlParameter("@gname", record.GroupName), new SqlParameter("@jdisplay", record.JobDisplayName), new SqlParameter("@jclass", record.ClassName), new SqlParameter("@assemblyName", record.AssemblyName), new SqlParameter("@filePath", record.FilePath), new SqlParameter("@repeatMode", Convert.ToInt32(record.RepeatMode)), new SqlParameter("@fixedUnit", record.FixedUnit), new SqlParameter("@FixedExpression", record.FixedExpression), new SqlParameter("@dtCreatTime", record.DataChange_CreateTime), new SqlParameter("@dtLastTime", ""), new SqlParameter("@cycleUnit", record.CycleUnit), new SqlParameter("@interval", record.Interval), new SqlParameter("@start", record.StartTime), new SqlParameter("@status", record.Status), new SqlParameter("@enabled", record.IsEnable) ); return(Convert.ToInt32(autoId)); }
public int Update(Job_Config record) { string sql = @"update Job_Config set JobName=@jname,GroupName=@gname,JobDisplayName=@jdisplay,ClassName=@jclass, AssemblyName=@assemblyName,FilePath=@filePath,RepeatMode=@repeatMode,FixedUnit=@fixedUnit,FixedExpression=@FixedExpression, DataChange_CreateTime=@dtCreatTime,CycleUnit=@cycleUnit,Interval=@interval,StartTime=@start,Status=@status,IsEnable=@enabled where ID=@id"; return(SqlHelper.ExecuteNonQuery(sql, new SqlParameter("@id", record.ID), new SqlParameter("@jname", record.JobName), new SqlParameter("@gname", record.GroupName), new SqlParameter("@jdisplay", record.JobDisplayName), new SqlParameter("@jclass", record.ClassName), new SqlParameter("@assemblyName", record.AssemblyName), new SqlParameter("@filePath", record.FilePath), new SqlParameter("@repeatMode", Convert.ToInt32(record.RepeatMode)), new SqlParameter("@fixedUnit", record.FixedUnit), new SqlParameter("@FixedExpression", record.FixedExpression), new SqlParameter("@dtCreatTime", record.DataChange_CreateTime), new SqlParameter("@cycleUnit", record.CycleUnit), new SqlParameter("@interval", record.Interval), new SqlParameter("@start", record.StartTime), new SqlParameter("@status", record.Status), new SqlParameter("@enabled", record.IsEnable) )); }
public int Add(Job_Config record) { object newRec = _sqlClient.Insert(record); if (newRec != null) { return(Convert.ToInt32(((Job_Config)newRec).ID)); } return(-1); }
public ActionResult Edit(Job_Config record, string buttons = "") { int cnt = -1; record.GroupName = "testGroup"; if (ModelState.IsValid) { if (buttons == "上传") { string fullPath = UploadFiles(); if (!string.IsNullOrEmpty(fullPath)) { record.FilePath = fullPath; } } if (record.ID == -1) { record.DataChange_CreateTime = DateTime.Now; record.ID = dal.Add(record); } else { record.Status = 1;//更新为更新状态 cnt = dal.Update(record); } //if (record.ID!=-1 && cnt > 0) //{ // return RedirectToAction("TaskList"); //} return(RedirectToAction("Edit", new { id = record.ID })); } else { return(RedirectToAction("Edit")); } return(View()); }
/// <summary> /// 将job配置转换成job参数 /// </summary> private JobInfo GetJobInfo(Job_Config config) { var jobInfo = new JobInfo { GroupName = config.GroupName, ClassName = config.ClassName, CanConcurrent = false, CycleUnit = (CycleUnitEnum)config.CycleUnit, Interval = config.Interval, JobName = config.JobName, RepeatMode = (RepeatModeEnum)config.RepeatMode, StartTime = config.StartTime, FileName = config.FilePath, FixedUnit = (FixedUnitEnum)config.FixedUnit, FixedExpression = config.FixedExpression }; return(jobInfo); }
protected Job_Config GetJob_Config(DataRow row) { Job_Config r = new Job_Config(); r.ID = SqlHelper.GetInt32(row["ID"].ToString()); r.JobName = Convert.ToString(row["JobName"]); r.GroupName = Convert.ToString(row["GroupName"]); r.DataChange_CreateTime = Convert.ToDateTime(row["DataChange_CreateTime"]); r.JobDisplayName = Convert.ToString(row["JobDisplayName"]); r.ClassName = Convert.ToString(row["ClassName"]); r.FilePath = Convert.ToString(row["FilePath"]); r.RepeatMode = Convert.ToInt32(row["RepeatMode"]); r.FixedUnit = Convert.ToInt32(row["FixedUnit"]); r.FixedExpression = Convert.ToString(row["FixedExpression"]); r.CycleUnit = Convert.ToInt32(row["CycleUnit"]); r.Interval = Convert.ToInt32(row["Interval"]); r.StartTime = DateTime.Parse(Convert.ToString(row["StartTime"])); r.IsEnable = Convert.ToBoolean(row["IsEnable"]); return(r); }
public ActionResult Edit(string id = "") { Job_Config record = new Job_Config(); if (string.IsNullOrEmpty(id)) { record.ID = -1; record.RepeatMode = 0; record.StartTime = DateTime.Now; } else { record = dal.Get(Convert.ToInt32(id)); } if (record != null) { return(View(record)); } else { return(View("_NoFound")); } }
/// <summary> /// 获取有更新的job配置 /// </summary> private List <Job_Config> GetJobConfig() { var cons = AppConfigHelper.GetQuartzConnString(); var con = new SqlConnection(cons); var sql = string.Format("select * from Job_Config where status!={0}", (int)JobStatusEnum.NoChange); var cmd = new SqlCommand(sql, con); var list = new List <Job_Config>(); using (con) { con.Open(); var reader = cmd.ExecuteReader(); while (reader.Read()) { var item = new Job_Config(); item.ID = Convert.ToInt64(reader["ID"]); item.JobName = reader["JobName"].ToString(); item.FilePath = reader["FilePath"].ToString(); item.CycleUnit = Convert.ToInt32(reader["CycleUnit"]); item.Interval = Convert.ToInt32(reader["Interval"]); item.ClassName = reader["ClassName"].ToString(); item.StartTime = Convert.ToDateTime(reader["StartTime"]); item.IsEnable = Convert.ToBoolean(reader["IsEnable"]); item.FilePath = reader["FilePath"].ToString(); item.Status = Convert.ToInt32(reader["Status"]); item.GroupName = reader["GroupName"].ToString(); item.RepeatMode = Convert.ToInt32(reader["RepeatMode"]); item.FixedUnit = Convert.ToInt32(reader["FixedUnit"]); item.FixedExpression = reader["FixedExpression"].ToString(); list.Add(item); } } return(list); }
public int Update(Job_Config record) { return(_sqlClient.Update <Job_Config>(record, p => p.ID == record.ID) ? 1 : -1); }