/// <summary> /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据 /// </summary> /// <param name="pPageIndex">页数</param> /// <param name="pPageSize">每页列表</param> /// <param name="pOrderBy">排序</param> /// <param name="pSortExpression">排序字段</param> /// <param name="pRecordCount">列表行数</param> /// <returns>数据分页</returns> public static List <ProjectStepInfo> GetPagedList(int pPageIndex, int pPageSize, SortDirection pOrderBy, string pSortExpression, out int pRecordCount) { if (pPageIndex <= 1) { pPageIndex = 1; } List <ProjectStepInfo> list = new List <ProjectStepInfo>(); Query q = ProjectStep.CreateQuery(); q.PageIndex = pPageIndex; q.PageSize = pPageSize; q.ORDER_BY(pSortExpression, pOrderBy.ToString()); ProjectStepCollection collection = new ProjectStepCollection(); collection.LoadAndCloseReader(q.ExecuteReader()); foreach (ProjectStep projectStep in collection) { ProjectStepInfo projectStepInfo = new ProjectStepInfo(); LoadFromDAL(projectStepInfo, projectStep); list.Add(projectStepInfo); } pRecordCount = q.GetRecordCount(); return(list); }
public void FadeScheduledObjects(ProjectStep projectStep) { foreach (ProjectStepObject projectStepObject in projectStep.projectObjects) { ProjectObjects.instance.GetObjectById(projectStepObject.objectId).AddScheduledActivity(projectStepObject.activity); } }
//数据持久化 internal static void SaveToDb(ProjectStepInfo pProjectStepInfo, ProjectStep pProjectStep, bool pIsNew) { pProjectStep.ProjectStepId = pProjectStepInfo.projectStepId; pProjectStep.ProjectStepName = pProjectStepInfo.projectStepName; pProjectStep.IsNew = pIsNew; string UserName = SubsonicHelper.GetUserName(); try { pProjectStep.Save(UserName); } catch (Exception ex) { LogManager.getInstance().getLogger(typeof(ProjectStepInfo)).Error(ex); if (ex.Message.Contains("插入重复键")) //违反了唯一键 { throw new AppException("此对象已经存在"); //此处等待优化可以从唯一约束中直接取出提示来,如果没有的话,默认为原始的出错提示 } throw new AppException("保存失败"); } pProjectStepInfo.projectStepId = pProjectStep.ProjectStepId; //如果缓存存在,更新缓存 if (CachedEntityCommander.IsTypeRegistered(typeof(ProjectStepInfo))) { ResetCache(); } }
public ActionResult CreateProjectStep(CreateProjectStep createProjectStep) { if (ModelState.IsValid) { ProjectStep projectStep = new ProjectStep { Description = createProjectStep.Description, ProjectId = createProjectStep.ProjectId, Title = createProjectStep.Title }; projectStepRepository.Insert(projectStep); projectStepRepository.SaveChanges(); TempData["IsSuccess"] = true; TempData["Message"] = "Этап проекта успешно создан!"; TempData["ProjectStep"] = createProjectStep; } else { TempData["IsSuccess"] = false; TempData["Message"] = "Этап проекта не был создан, т.к. не заполнены все поля. Пожалуйста повторите попытку заполнив все поля."; TempData["ProjectStep"] = createProjectStep; } return(RedirectToAction("Index")); }
public ActionResult Steps(string id) { if (!Common.CheckUserSession()) { return(this.RedirectToAction("Index", "Login")); } var project = new ProjectService(Common.GetConnectionString()).Load(x => x.GUID == id).FirstOrDefault(); ViewBag.ProjectName = project.Title; ViewBag.ProjectId = project.ProjectId; ViewBag.ProjectGUID = id; var projectStepService = new ProjectStepService(Common.GetConnectionString()); ViewBag.StepIds = projectStepService.Load(x => x.ProjectId == project.ProjectId).Select(x => x.ProjectStepId).ToList(); ProjectStep firstStep = null; if (Session["ActiveStep"] != null) { int projectStepId = Convert.ToInt16(Session["ActiveStep"]); firstStep = projectStepService.Load(x => x.ProjectId == project.ProjectId && x.ProjectStepId == projectStepId).FirstOrDefault(); } if (firstStep == null) { firstStep = projectStepService.Load(x => x.ProjectId == project.ProjectId).FirstOrDefault(); } return(View(firstStep)); }
public void AddProjectStep(ProjectStep step, bool canUndo = false) { projectSteps.Add(step); if (canUndo) { UndoMenu.instance.AddUndoStep(step); } }
public void Delete(ProjectStep model) { if (model == null) { throw new ArgumentNullException("ProjectStep"); } projectStepRepository.Delete(model); }
public int Insert(ProjectStep model) { if (model == null) { throw new ArgumentNullException("ProjectStep"); } return(projectStepRepository.Insert(model)); }
public void StartProcess(ProjectStep projectStep, List <ProjectObject> projectObjects) { this.projectStep = projectStep; foreach (ProjectObject projectObject in projectObjects) { targetUids.Add(projectObject); } StartCoroutine(FindBestSpot()); }
public void UnFadeScheduledObjects() { if (lastScheduledStep != null) { foreach (ProjectStepObject projectStepObject in lastScheduledStep.projectObjects) { ProjectObjects.instance.GetObjectById(projectStepObject.objectId).RemoveScheduledActivity(projectStepObject.activity); } lastScheduledStep = null; } }
public ActionResult EditStep(ProjectStep projectStep) { if (!Common.CheckUserSession()) { return(this.RedirectToAction("Index", "Login")); } new ProjectStepService(Common.GetConnectionString()).Save(projectStep, true); var guid = new ProjectService(Common.GetConnectionString()).Load(x => x.ProjectId == projectStep.ProjectId).Select(x => x.GUID).FirstOrDefault(); Session["ActiveStep"] = projectStep.ProjectStepId; return(RedirectToAction("Steps", new { id = guid })); }
public void SendProjectStep() { ProjectStep projectStep = new ProjectStep( PlannerSubmitMenu.instance.GetNameInput(), Utils_Prefs.GetProjectId(), CreateStepObjects(ObjectSelection.instance.GetSelectedObjects()), DurationMenu.instance.GetDurationInput(), CrewSizeMenu.instance.GetCrewSizeInput(), LeadLagMenu.instance.GetLeadInput(), LeadLagMenu.instance.GetLagInput(), CreateStepObjects(ObjectSelection.instance.GetPrerequisiteObjects(), true) ); Menu.instance.DeselectButtonClick(); }
/// <summary> /// 保存 /// </summary> public override void Save() { if (!m_Loaded) //新增 { ProjectStep projectStep = new ProjectStep(); SaveToDb(this, projectStep, true); } else //修改 { ProjectStep projectStep = new ProjectStep(projectStepId); if (projectStep.IsNew) { throw new AppException("该数据已经不存在了"); } SaveToDb(this, projectStep, false); } }
/// <summary> /// 删除 /// </summary> /// <returns>是否成功</returns> public override void Delete() { if (!m_Loaded) { throw new AppException("尚未初始化"); } bool result = (ProjectStep.Delete(ProjectStepId) == 1); //更新缓存 if (result && CachedEntityCommander.IsTypeRegistered(typeof(ProjectStepInfo))) { ResetCache(); } if (!result) { throw new AppException("删除失败,数据可能被删除"); } }
public ActionResult DeleteStep(int id) { if (id > 0) { ProjectStep ps = projectStepRepository.GetById(id); projectStepRepository.Delete(ps); projectStepRepository.SaveChanges(); TempData["IsSuccess"] = true; TempData["Message"] = "Этап успешно удален!"; } else { TempData["IsSuccess"] = false; TempData["Message"] = "Произошла ошибка, пожалуйста повторите попытку!"; } return(RedirectToAction("Index")); }
public JsonResult GetProjectStep(int id) { ProjectStep projectSteps = projectStepRepository.GetById(id); if (projectSteps != null) { ProjectStepDTO projectStepsDTO = new ProjectStepDTO { Id = projectSteps.ID, Description = projectSteps.Description, Title = projectSteps.Title, ProjectId = projectSteps.ProjectId }; return(Json(ResponseProcessing.Success(projectStepsDTO, "Проект успешно извлечен."))); } else { return(Json(ResponseProcessing.Error(String.Format("У проекта с идентификатором {0} этапов не существует.", id)))); } }
private void LoadFromId(int projectStepId) { if (CachedEntityCommander.IsTypeRegistered(typeof(ProjectStepInfo))) { ProjectStepInfo projectStepInfo = Find(GetList(), projectStepId); if (projectStepInfo == null) { throw new AppException("未能在缓存中找到相应的键值对象"); } Copy(projectStepInfo, this); } else { ProjectStep projectStep = new ProjectStep(projectStepId); if (projectStep.IsNew) { throw new AppException("尚未初始化"); } LoadFromDAL(this, projectStep); } }
//数据持久化 internal static void SaveToDb(ProjectStepInfo pProjectStepInfo, ProjectStep pProjectStep,bool pIsNew) { pProjectStep.ProjectStepId = pProjectStepInfo.projectStepId; pProjectStep.ProjectStepName = pProjectStepInfo.projectStepName; pProjectStep.IsNew=pIsNew; string UserName = SubsonicHelper.GetUserName(); try { pProjectStep.Save(UserName); } catch(Exception ex) { LogManager.getInstance().getLogger(typeof(ProjectStepInfo)).Error(ex); if(ex.Message.Contains("插入重复键"))//违反了唯一键 { throw new AppException("此对象已经存在");//此处等待优化可以从唯一约束中直接取出提示来,如果没有的话,默认为原始的出错提示 } throw new AppException("保存失败"); } pProjectStepInfo.projectStepId = pProjectStep.ProjectStepId; //如果缓存存在,更新缓存 if (CachedEntityCommander.IsTypeRegistered(typeof(ProjectStepInfo))) { ResetCache(); } }
/// <summary> /// 保存 /// </summary> public override void Save() { if(!m_Loaded)//新增 { ProjectStep projectStep=new ProjectStep(); SaveToDb(this, projectStep,true); } else//修改 { ProjectStep projectStep=new ProjectStep(projectStepId); if(projectStep.IsNew) throw new AppException("该数据已经不存在了"); SaveToDb(this, projectStep,false); } }
private void LoadFromId(int projectStepId) { if (CachedEntityCommander.IsTypeRegistered(typeof(ProjectStepInfo))) { ProjectStepInfo projectStepInfo=Find(GetList(), projectStepId); if(projectStepInfo==null) throw new AppException("未能在缓存中找到相应的键值对象"); Copy(projectStepInfo, this); } else { ProjectStep projectStep=new ProjectStep( projectStepId); if(projectStep.IsNew) throw new AppException("尚未初始化"); LoadFromDAL(this, projectStep); } }
public static DataTable getProjectStepList() { Query q = ProjectStep.CreateQuery(); return(q.ExecuteDataSet().Tables[0]); }
public void AddUndoStep(ProjectStep step) { undoSteps.Insert(0, step); }
//从后台获取数据 internal static void LoadFromDAL(ProjectStepInfo pProjectStepInfo, ProjectStep pProjectStep) { pProjectStepInfo.projectStepId = pProjectStep.ProjectStepId; pProjectStepInfo.projectStepName = pProjectStep.ProjectStepName; pProjectStepInfo.Loaded = true; }
//从后台获取数据 internal static void LoadFromDAL(ProjectStepInfo pProjectStepInfo, ProjectStep pProjectStep) { pProjectStepInfo.projectStepId = pProjectStep.ProjectStepId; pProjectStepInfo.projectStepName = pProjectStep.ProjectStepName; pProjectStepInfo.Loaded=true; }