public bool IsRuningApplication(string path) { ApplicationRuntimeModel runtimeModel = _applicationManage.GetRuntimeModelByPath(path); if (runtimeModel == null) { return(false); } return(runtimeModel.ApplicationStatus == ApplicationStatusEnum.Runing); }
public void Add(ApplicationInfoModel model) { if (_allApplicationInfos.ContainsKey(model.ID)) { throw new DeployException("应用程序已存在"); } model.ApplicationStatus = ApplicationStatusEnum.Stop; var runtimeModel = new ApplicationRuntimeModel(model, _applicationHandlerContext); if (!_allApplicationInfos.TryAdd(model.ID, runtimeModel)) { throw new DeployException("添加失败"); } }
public void Stop(Guid id) { if (!_allApplicationInfos.ContainsKey(id)) { throw new DeployException("应用程序不存在"); } ApplicationRuntimeModel runtimeModel = _allApplicationInfos[id]; if (runtimeModel.ApplicationStatus != ApplicationStatusEnum.Runing) { throw new DeployException("应用程序尚运行"); } runtimeModel.Stop(); }
public void Edit(ApplicationInfoModel model) { if (!_allApplicationInfos.ContainsKey(model.ID)) { throw new DeployException("应用程序不存在"); } ApplicationRuntimeModel runtimeModel = _allApplicationInfos[model.ID]; if (runtimeModel.ApplicationStatus != ApplicationStatusEnum.Stop) { throw new DeployException("应用程序尚未停止"); } model.ApplicationStatus = ApplicationStatusEnum.Stop; model.CopyProperties(runtimeModel.ApplicationInfo); }
public ApplicationInfoModel Delete(Guid id) { if (!_allApplicationInfos.ContainsKey(id)) { throw new DeployException("应用程序不存在"); } ApplicationRuntimeModel runtimeModel = _allApplicationInfos[id]; if (runtimeModel.ApplicationStatus != ApplicationStatusEnum.Stop) { throw new DeployException("应用程序尚未停止"); } if (!_allApplicationInfos.TryRemove(id, out ApplicationRuntimeModel applicationRuntimeModel)) { throw new DeployException("删除失败"); } return(applicationRuntimeModel.ApplicationInfo); }
public void Start(Guid id) { if (!CanRun()) { throw new InvalidOperationException("正在发布中,请稍后"); } if (!_allApplicationInfos.ContainsKey(id)) { throw new DeployException("应用程序不存在"); } ApplicationRuntimeModel runtimeModel = _allApplicationInfos[id]; if (runtimeModel.ApplicationStatus != ApplicationStatusEnum.Stop) { throw new DeployException("应用程序尚未停止"); } runtimeModel.Start(); }
/// <summary> /// 复制应用程序 /// </summary> /// <param name="directoryInfo"></param> private void CopyApplication(DirectoryInfo directoryInfo) { string targetPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Application", directoryInfo.Name); ApplicationRuntimeModel runtimeModel = _applicationManage.GetRuntimeModelByPath(directoryInfo.Name); if (runtimeModel != null && runtimeModel.ApplicationInfo.ApplicationType != ApplicationTypeEnum.StaticDocument) { runtimeModel.Stop(); if (runtimeModel.ApplicationStatus == ApplicationStatusEnum.Stop) { CopyDirectory(directoryInfo, targetPath); } else { throw new DeployException("应用程序关闭失败"); } } CopyDirectory(directoryInfo, targetPath); }
public void ClearInactiveApplication() { string directoryPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Application"); if (!Directory.Exists(directoryPath)) { return; } var directoryInfo = new DirectoryInfo(directoryPath); foreach (DirectoryInfo directory in directoryInfo.GetDirectories()) { ApplicationRuntimeModel runtimeModel = _applicationManage.GetRuntimeModelByPath(directory.Name); if (runtimeModel == null) { directory.Delete(true); } } }
public ICollection <string> GetConsoleMessage(Guid id) { if (!_allApplicationInfos.ContainsKey(id)) { throw new DeployException("应用程序不存在"); } ApplicationRuntimeModel runtimeModel = _allApplicationInfos[id]; if (runtimeModel.ApplicationStatus != ApplicationStatusEnum.Runing) { throw new DeployException("应用程序尚运行"); } ICollection <string> result = runtimeModel.ConsoleMessage; if (result.Count == 0) { throw new DeployException("没有任何消息"); } return(result); }