/// <summary> /// 取得当前项目下控制器的最大ID /// </summary> /// <returns></returns> protected int GetMaxControllerID() { SCA.Model.ProjectModel project = SCA.BusinessLib.ProjectManager.GetInstance.Project; int tempID = 0; foreach (var c in project.Controllers) { tempID = c.ID == null ? 0 : c.ID; if (c.ID > tempID) { tempID = c.ID; } } return(tempID); }
public bool AddControllerToProject(ControllerModel controller) { try { SCA.Model.ProjectModel project = SCA.BusinessLib.ProjectManager.GetInstance.Project; if (project.Controllers.Count == 0)//如果还未设置主控制器,则默认第一个控制器为主控制器 { controller.PrimaryFlag = true; } int maxControllerID = GetMaxControllerID(); controller.ID = maxControllerID + 1; controller.ProjectID = project.ID; controller.Project = project; project.Controllers.Add(controller); controller.IsDirty = true; //SetDataDirty(); } catch { return(false); } return(true); }