/// <summary> /// Return a given code list. /// </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="name">The name of the code list.</param> /// <returns>The code list.</returns> public CodeList GetCodeListByName(string org, string service, string name) { CodeList codeList = null; string textData = File.ReadAllText(_settings.GetCodelistPath(org, service, AuthenticationHelper.GetDeveloperUserName(_httpContextAccessor.HttpContext)) + name + ".json"); codeList = JsonConvert.DeserializeObject <CodeList>(textData); return(codeList); }
/// <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); }