/// <summary> /// /// </summary> /// <param name="context"></param> /// <returns></returns> public Task Execute(IJobExecutionContext context) { // 是否生成缩略图 bool IsCompressed = ConfigurationManager.AppSettings["IsCompressed"] == "Yes"; string rootPath = HostingEnvironment.MapPath("~/"); return(Task.Factory.StartNew(async() => { if (IsCompressed) { // 获取没有生成缩略图的记录 var list = await srcOp.GetDataByFuncAsync(_ => _.CurrentStatus != (int)RowStatusEnum.Ready); Parallel.ForEach(list, _ => { ImageHelper.MakeThumbnail(rootPath + _.SavePathDir + _.CoverImageName, rootPath + _.SavePathDir + "thumbnail/" + _.CoverImageName.Substring(0, _.CoverImageName.LastIndexOf(".") + 1) + "jpg", 800, 0, ThumbnailMode.W, "jpg"); _.SourceFiles.Split(';').ToList().ForEach(s => { ImageHelper.MakeThumbnail(rootPath + _.SavePathDir + s, rootPath + _.SavePathDir + "thumbnail/" + s.Substring(0, s.LastIndexOf(".") + 1) + "jpg", 800, 0, ThumbnailMode.W, "jpg"); }); _.CurrentStatus = 2; srcOp.Update(_); }); } })); }
/// <summary> /// 保存 /// </summary> /// <param name="model"></param> private void SaveSurvey(SurveyViewModel model) { if (model.SurveyId == 0) { qsOp.Create(new SurveyEntity { SurveyNo = model.SurveyNo, SurveyDesc = model.SurveyDesc, SurveyDate = DateTime.Parse(model.SurveyDate), SurveyImages = model.SurveyImages }); } else { var qs = qsOp.GetSingleData(_ => _.SurveyId == model.SurveyId); qs.SurveyDate = Convert.ToDateTime(model.SurveyDate); qs.SurveyDesc = model.SurveyDesc; string oldFiles = qs.SurveyImages; qs.SurveyImages = model.SurveyImages; qsOp.Update(qs); DelFile(oldFiles, model.SurveyImages); } }