ResourceCatalogResult CompileAndSave(Guid workspaceID, IResource resource, StringBuilder contents, string savedPath = "", string reason = "") { // Find the service before edits ;) var beforeService = _resourceCatalog.GetDynamicObjects <DynamicService>(workspaceID, resource.ResourceID).FirstOrDefault(); ServiceAction beforeAction = null; if (beforeService != null) { beforeAction = beforeService.Actions.FirstOrDefault(); if (reason?.Equals(GlobalConstants.SaveReasonForDeploy) ?? false) { beforeService.DisplayName = resource.ResourceName; beforeService.Name = resource.ResourceName; } } var result = _resourceCatalog.SaveImpl(workspaceID, resource, contents, savedPath, reason); if (result != null && result.Status == ExecStatus.Success) { if (workspaceID == GlobalConstants.ServerWorkspaceID) { CompileTheResourceAfterSave(workspaceID, resource, contents, beforeAction); UpdateResourceDependencies(resource, contents); SavedResourceCompileMessage(workspaceID, resource, result.Message); } if (ResourceSaved != null && workspaceID == GlobalConstants.ServerWorkspaceID) { ResourceSaved(resource); } } return(result); }
private ResourceCatalogResult CompileAndSave(Guid workspaceID, IResource resource, StringBuilder contents, string savedPath = "") { // Find the service before edits ;) DynamicService beforeService = _resourceCatalog.GetDynamicObjects <DynamicService>(workspaceID, resource.ResourceID).FirstOrDefault(); ServiceAction beforeAction = null; if (beforeService != null) { beforeAction = beforeService.Actions.FirstOrDefault(); } var result = ((ResourceCatalog)_resourceCatalog).SaveImpl(workspaceID, resource, contents, true, savedPath); if (result.Status == ExecStatus.Success) { if (workspaceID == GlobalConstants.ServerWorkspaceID) { CompileTheResourceAfterSave(workspaceID, resource, contents, beforeAction); UpdateResourceDependencies(resource, contents); SavedResourceCompileMessage(workspaceID, resource, result.Message); } if (ResourceSaved != null) { if (workspaceID == GlobalConstants.ServerWorkspaceID) { ResourceSaved(resource); } } } return(result); }
/// <summary> /// Finds the service by name /// </summary> /// <param name="serviceName">Name of the service.</param> /// <param name="workspaceID">The workspace ID.</param> /// <exception cref="System.IO.InvalidDataException">Empty or null service passed in</exception> /// <exception cref="System.Runtime.Serialization.InvalidDataContractException">Null workspace</exception> public DynamicService FindService(string serviceName, Guid workspaceID) { if (string.IsNullOrEmpty(serviceName)) { throw new InvalidDataException(ErrorResource.ServiceIsNull); } var res = _resourceCatalog.GetResource(workspaceID, serviceName); DynamicService ret = null; if (res != null) { ret = ServiceActionRepo.Instance.ReadCache(res.ResourceID); } if (ret == null) { ret = _resourceCatalog.GetDynamicObjects <DynamicService>(workspaceID, serviceName).FirstOrDefault(); if (ret == null) { _perfCounter.Increment(); } } return(ret); }