public async Task <int> UpdateCustomerJobInfo(customer_quartzjobinfo customerJobInfoModel) { List <string> updateFieldNames = new List <string>(); ReflectObjectFields(customerJobInfoModel, updateFieldNames); //_dbContext.Entry(customerJobInfoModel).State = System.Data.Entity.EntityState.Detached; _dbContext.customer_quartzjobinfo.Attach(customerJobInfoModel); foreach (var fieldName in updateFieldNames) { _dbContext.Entry(customerJobInfoModel).Property(fieldName).IsModified = true; } await _dbContext.SaveChangesAsync(); return(customerJobInfoModel.Id); }
public async Task <int> UpdateCustomerJobInfo(customer_quartzjobinfo customerJobInfoModel) { List <string> updateFieldNames = new List <string>(); ReflectObjectFields(customerJobInfoModel, updateFieldNames); //_dbContext.Entry(customerJobInfoModel).State = System.Data.Entity.EntityState.Detached; _dbContext.customer_quartzjobinfo.Attach(customerJobInfoModel); foreach (var fieldName in updateFieldNames) { _dbContext.Entry(customerJobInfoModel).Property(fieldName).IsModified = true; } //RecordExecutedJob //if (customerJobInfoModel.TriggerState == 6) //{ // var jobDetail = LoadCustomerInfo(x => x.Id == customerJobInfoModel.Id); // var jobInfo = new customer_quartzjobinfo // { // CreateTime = DateTime.Now, // Cron = jobDetail.Cron, // Description = jobDetail.Description, // JobGroupName = jobDetail.JobGroupName, // JobName = jobDetail.JobName+jobDetail.Id, // TriggerState = 2, // TriggerName = jobDetail.TriggerName, // TriggerGroupName = jobDetail.TriggerGroupName, // DLLName = ConfigurationManager.AppSettings["dllName"], // FullJobName = ConfigurationManager.AppSettings["FullJobName"], // RequestUrl = jobDetail.RequestUrl, // Deleted = false, // Cycle = jobDetail.Cycle, // TriggerType = jobDetail.TriggerType, // RepeatCount = jobDetail.RepeatCount // }; // AddCustomerJobInfo(jobDetail); //} await _dbContext.SaveChangesAsync(); return(customerJobInfoModel.Id); }