/// <summary> /// Creates a zip-file containing all files necessary for executing a service /// </summary> /// <param name="org">The organization code for the service owner</param> /// <param name="service">The service code for the current service</param> /// <param name="edition">The edition code for the current service</param> /// <returns>Was the package creation successful</returns> public bool CreateServicePackage(string org, string service, string edition) { ServiceMetadata serviceMetadata = _repository.GetServiceMetaData(org, service, edition); string packagesDir = _settings.GetServicePackagesPath(org, service, edition, AuthenticationHelper.GetDeveloperUserName(_httpContextAccessor.HttpContext)); string tempDir = _settings.GetTemporaryPath(org, service, edition, AuthenticationHelper.GetDeveloperUserName(_httpContextAccessor.HttpContext)); string tempDirName = Path.GetRandomFileName(); string tempDirPath = tempDir + tempDirName + "/"; CopyDirectoryContents(_settings.GetViewPath(org, service, edition, AuthenticationHelper.GetDeveloperUserName(_httpContextAccessor.HttpContext)), tempDirPath + ServiceRepositorySettings.VIEW_FOLDER_NAME); CopyDirectoryContents(_settings.GetMetadataPath(org, service, edition, AuthenticationHelper.GetDeveloperUserName(_httpContextAccessor.HttpContext)), tempDirPath + ServiceRepositorySettings.METADATA_FOLDER_NAME); CopyDirectoryContents(_settings.GetCodelistPath(org, service, edition, AuthenticationHelper.GetDeveloperUserName(_httpContextAccessor.HttpContext)), tempDirPath + ServiceRepositorySettings.CODELISTS_FOLDER_NAME); CopyDirectoryContents(_settings.GetResourcePath(org, service, edition, AuthenticationHelper.GetDeveloperUserName(_httpContextAccessor.HttpContext)), tempDirPath + ServiceRepositorySettings.RESOURCE_FOLDER_NAME); Directory.CreateDirectory(tempDirPath + "/Assemblies/"); Directory.CreateDirectory(packagesDir); string compileResult = string.Empty; string assemblyName = CreateServiceAssembly(org, service, edition, tempDirPath + "/Assemblies/").AssemblyName; ServicePackageDetails details = new ServicePackageDetails { AssemblyName = assemblyName, Organization = org, Service = service, Edition = edition, CreatedDateTime = DateTime.Now }; string detailsAsJson = JsonConvert.SerializeObject(details); string filePath = tempDirPath + "/ServicePackageDetails.json"; File.WriteAllText(filePath, detailsAsJson, Encoding.UTF8); ZipFile.CreateFromDirectory(tempDirPath, packagesDir + tempDirName + ".zip"); Directory.Delete(tempDirPath, true); return(true); }
/// <summary> /// Get the view content for a given razor file on disk /// </summary> /// <param name="org">The Organization code for the service owner</param> /// <param name="service">The service code for the current service</param> /// <param name="edition">The edition code for the current service</param> /// <param name="name">The name of the RazorView (fileName)</param> /// <returns>The content (html/razor) of a Razor View</returns> public string GetView(string org, string service, string edition, string name) { string filename = _settings.GetViewPath(org, service, edition, AuthenticationHelper.GetDeveloperUserName(_httpContextAccessor.HttpContext)) + name + ".cshtml"; return(File.ReadAllText(filename, Encoding.UTF8)); }