/// <summary> /// 提交,修改 /// </summary> /// <param name="tandasEntity"></param> /// <param name="keyValue"></param> public void SubmitForm(ProfileSanitationGarbageBoxEntity GarBoxEntity, string keyValue) { if (!string.IsNullOrEmpty(keyValue)) { GarBoxEntity.Modify(keyValue); service.Update(GarBoxEntity); try { //添加日志 LogMess.addLog(DbLogType.Update.ToString(), "修改成功", "修改环卫垃圾箱房信息【" + GarBoxEntity.Address + "】成功!"); } catch { } } else { GarBoxEntity.Create(); service.Insert(GarBoxEntity); try { //添加日志 LogMess.addLog(DbLogType.Update.ToString(), "修改成功", "新建环卫垃圾箱房信息【" + GarBoxEntity.Address + "】成功!"); } catch { } } }
/// <summary> /// 单条 /// 批量导入 /// </summary> /// <param name="entity"></param> /// <param name="skipWhere"></param> /// <param name="coverWhere"></param> public void BatchSubmitFrom(ProfileSanitationGarbageBoxEntity entity, Func <ProfileSanitationGarbageBoxEntity, ProfileSanitationGarbageBoxEntity, bool> skipWhere, Func <ProfileSanitationGarbageBoxEntity, ProfileSanitationGarbageBoxEntity, bool> coverWhere) { if (skipWhere != null) { Func <ProfileSanitationGarbageBoxEntity, bool> dbSkipWhere = db => skipWhere(db, entity); var dbSkipQuery = this.service.dbcontext.Set <ProfileSanitationGarbageBoxEntity>().Where(dbSkipWhere); if (dbSkipQuery.Count() > 0) { return; } } if (coverWhere != null) { Func <ProfileSanitationGarbageBoxEntity, bool> dbCoverWhere = db => coverWhere(db, entity); var dbCoverQuery = this.service.dbcontext.Set <ProfileSanitationGarbageBoxEntity>().Where(dbCoverWhere); if (dbCoverQuery.Count() > 0) { var dbEntity = dbCoverQuery.FirstOrDefault(); dbEntity.CityId = entity.CityId; dbEntity.CountyId = entity.CountyId; dbEntity.ProjectId = entity.ProjectId; dbEntity.F_EnCode = entity.F_EnCode; dbEntity.StreetId = entity.StreetId; dbEntity.Address = entity.Address; dbEntity.Modify(dbEntity.F_Id); this.service.Update(dbEntity); return; } } entity.Create(); this.service.Insert(entity); }
public ActionResult SubmitForm(ProfileSanitationGarbageBoxEntity WayEntity, string keyValue) { App.SubmitForm(WayEntity, keyValue); return(Success("操作成功。")); }
public ActionResult SummitImport(string CityId, string CountyId, string ProjectId, int isRename = 1) { var file = Request.Files[0]; string path = @"D:\项目\聚力环境测评系统\NFine.Web\bin\TemporaryFilesDiskPath\"; string fileName = file.FileName; string filePath = Path.Combine(path, fileName); ImportResultModel result = new ImportResultModel(); int failureQuantity, successfulQuantity; try { if (NFine.Code.FileHelper.IsExistFile(path)) { NFine.Code.FileHelper.DeleteFile(path); } file.SaveAs(filePath); using (ExcelHelper exHelp = new ExcelHelper(filePath)) { var datatable = exHelp.ExcelToDataTable(filePath, true); ProfileSanitationGarbageBoxEntity[] models = new ProfileSanitationGarbageBoxEntity[datatable.Rows.Count]; ProfileSanitationGarbageBoxEntity model; for (int i = 0; i < datatable.Rows.Count; i++) { model = new ProfileSanitationGarbageBoxEntity(); var code = datatable.Rows[i]["序"].ToString(); var streetName = datatable.Rows[i]["街道"].ToString(); var garbageBoxTypeName = datatable.Rows[i]["类型"].ToString(); var address = datatable.Rows[i]["地址"].ToString(); string streetKey = ""; var streetList = StreetApp.GetDictionary(d => d.StreetName == streetName); if (streetList.Count > 0) { streetKey = streetList[0].Key; } else { continue; } model.F_EnCode = int.Parse(code); model.CityId = CityId; model.CountyId = CountyId; model.ProjectId = ProjectId; model.StreetId = streetKey; model.Address = address; models[i] = model; } App.ImportData(models, out successfulQuantity, out failureQuantity); result.IsSucceed = true; result.FailureQuantity = failureQuantity; result.SuccessfulQuantity = successfulQuantity; result.TotalQuantity = models.Length; } } catch (Exception ex) { result.IsSucceed = false; result.ErrorMessage = ex.ToString(); } finally { if (NFine.Code.FileHelper.IsExistFile(path)) { NFine.Code.FileHelper.DeleteFile(path); } } return(Success(string.Format("总条数:{0},成功条数:{1},失败条数:{2}", result.TotalQuantity, result.FailureQuantity, result.ErrorMessage))); }