public void Test_mapping_ubl_to_ccl()
        {
            string repoPath = TestUtils.PathToTestResource(@"XSDImporterTest\mapping\MappingImporterTests\mapping_ubl_to_ccl\Invoice.eap");

            File.Copy(TestUtils.PathToTestResource(@"XSDImporterTest\mapping\MappingImporterTests\mapping_ubl_to_ccl\Repository-with-CDTs-and-CCs.eap"), repoPath, true);
            var repo = new Repository();

            repo.OpenFile(repoPath);

            var mappingFileNames = new List <string> {
                "ubl2cll_1_1.mfd", "ubl2cll_2_1.mfd", "ubl2cll_3_1.mfd", "ubl2cll_4_1.mfd", "ubl2cll_5_1.mfd", "ubl2cll_6_1.mfd", "ubl2cll_7_1.mfd", "ubl2cll_8_1.mfd", "ubl2cll_9_1.mfd", "ubl2cll_10_1.mfd", "ubl2cll_11_1.mfd", "ubl2cll_12_1.mfd", "ubl2cll_13_1.mfd"
            };
            var mappingFiles = new List <string>();

            foreach (var mappingFile in mappingFileNames)
            {
                mappingFiles.Add(TestUtils.PathToTestResource(@"XSDImporterTest\mapping\MappingImporterTests\mapping_ubl_to_ccl\" + mappingFile));
            }

            string[] schemaFiles = new[] { TestUtils.PathToTestResource(@"XSDImporterTest\mapping\MappingImporterTests\mapping_ubl_to_ccl\invoice\maindoc\UBL-Invoice-2.0.xsd") };

            Console.Out.WriteLine("Starting mapping");
            var repository = CctsRepositoryFactory.CreateCctsRepository(repo);
            var ccLib      = repository.GetCcLibraries().FirstOrDefault();

            new MappingImporter(mappingFiles, schemaFiles, ccLib, ccLib.BLibrary, DocLibraryName, BieLibraryName, BdtLibraryName, Qualifier, RootElementName, repository).ImportMapping();
        }
        private AntlrClassGenerationTaskInternal CreateBuildTaskWrapper()
        {
            var wrapper = new AntlrClassGenerationTaskInternal();

            IList <string> sourceCodeFiles = null;

            if (this.SourceCodeFiles != null)
            {
                sourceCodeFiles = new List <string>(SourceCodeFiles.Length);
                foreach (ITaskItem taskItem in SourceCodeFiles)
                {
                    sourceCodeFiles.Add(taskItem.ItemSpec);
                }
            }

            if (this.TokensFiles != null && this.TokensFiles.Length > 0)
            {
                Directory.CreateDirectory(OutputPath);

                HashSet <string> copied = new HashSet <string>(StringComparer.OrdinalIgnoreCase);
                foreach (ITaskItem taskItem in TokensFiles)
                {
                    string fileName = taskItem.ItemSpec;
                    if (!File.Exists(fileName))
                    {
                        Log.LogError("The tokens file '{0}' does not exist.", fileName);
                        continue;
                    }

                    string vocabName = Path.GetFileNameWithoutExtension(fileName);
                    if (!copied.Add(vocabName))
                    {
                        Log.LogWarning("The tokens file '{0}' conflicts with another tokens file in the same project.", fileName);
                        continue;
                    }

                    string target = Path.Combine(OutputPath, Path.GetFileName(fileName));
                    if (!Path.GetExtension(target).Equals(".tokens", StringComparison.OrdinalIgnoreCase))
                    {
                        Log.LogError("The destination for the tokens file '{0}' did not have the correct extension '.tokens'.", target);
                        continue;
                    }

                    File.Copy(fileName, target, true);
                    File.SetAttributes(target, File.GetAttributes(target) & ~FileAttributes.ReadOnly);
                }
            }

            wrapper.AntlrToolPath            = AntlrToolPath;
            wrapper.SourceCodeFiles          = sourceCodeFiles;
            wrapper.TargetLanguage           = TargetLanguage;
            wrapper.OutputPath               = OutputPath;
            wrapper.RootNamespace            = RootNamespace;
            wrapper.GeneratedSourceExtension = GeneratedSourceExtension;
            wrapper.LanguageSourceExtensions = LanguageSourceExtensions;
            wrapper.DebugGrammar             = DebugGrammar;
            wrapper.ProfileGrammar           = ProfileGrammar;
            return(wrapper);
        }
        private AntlrClassGenerationTaskInternal CreateBuildTaskWrapper(AppDomain domain)
        {
            AntlrClassGenerationTaskInternal wrapper = (AntlrClassGenerationTaskInternal)domain.CreateInstanceAndUnwrap(Assembly.GetExecutingAssembly().FullName, typeof(AntlrClassGenerationTaskInternal).FullName);

            IList <string> sourceCodeFiles = null;

            if (this.SourceCodeFiles != null)
            {
                sourceCodeFiles = new List <string>(SourceCodeFiles.Length);
                foreach (ITaskItem taskItem in SourceCodeFiles)
                {
                    sourceCodeFiles.Add(taskItem.ItemSpec);
                }
            }

            if (this.TokensFiles != null && this.TokensFiles.Length > 0)
            {
                HashSet <string> copied = new HashSet <string>(StringComparer.OrdinalIgnoreCase);
                foreach (ITaskItem taskItem in TokensFiles)
                {
                    string fileName = taskItem.ItemSpec;
                    if (!File.Exists(fileName))
                    {
                        Log.LogError("The tokens file '{0}' does not exist.", fileName);
                        continue;
                    }

                    string vocabName = Path.GetFileNameWithoutExtension(fileName);
                    if (!copied.Add(vocabName))
                    {
                        Log.LogWarning("The tokens file '{0}' conflicts with another tokens file in the same project.", fileName);
                        continue;
                    }

                    string target = Path.Combine(OutputPath, Path.GetFileName(fileName));
                    if (!Path.GetExtension(target).Equals(".tokens", StringComparison.OrdinalIgnoreCase))
                    {
                        Log.LogError("The destination for the tokens file '{0}' did not have the correct extension '.tokens'.", target);
                        continue;
                    }

                    File.Copy(fileName, target, true);
                    File.SetAttributes(target, File.GetAttributes(target) & ~FileAttributes.ReadOnly);
                }
            }

            wrapper.AntlrToolPath            = AntlrToolPath;
            wrapper.SourceCodeFiles          = sourceCodeFiles;
            wrapper.LibPaths                 = LibPaths;
            wrapper.Language                 = Language;
            wrapper.OutputPath               = OutputPath;
            wrapper.RootNamespace            = RootNamespace;
            wrapper.GeneratedSourceExtension = GeneratedSourceExtension;
            return(wrapper);
        }
Beispiel #4
0
 /// <summary>
 /// Копирует текущий файл по заданному пути.
 /// </summary>
 /// <param name="newName">Путь, куда скопировать.</param>
 public override void copyto(string newName)
 {
     for (int i = 0; i < fileList.Count; i++)
     {
         try
         {
             FileClass.Copy(fileList[i], newName + i + ".txt", true);
         }
         catch (Exception e) { throw e; }
         messenger(string.Format("Обьект " + fileList[i] + " был скопирован.\n"));
     }
 }
        // This is NOT thread safe but it is only called from within a lock
        private Assembly ReloadAssembly(string pathToAssembly)
        {
            // If there's a current AssemblyLoadContext, unload it before creating a new one.
            if (!(_currentAssemblyLoadContext is null))
            {
                _currentAssemblyLoadContext.Unload();

                // we need to remove the current part too
                ApplicationPart?currentPart = _applicationPartManager.ApplicationParts.FirstOrDefault(x => x.Name == RoslynCompiler.GeneratedAssemblyName);
                if (currentPart != null)
                {
                    _applicationPartManager.ApplicationParts.Remove(currentPart);
                }
            }

            // We must create a new assembly load context
            // as long as theres a reference to the assembly load context we can't delete the assembly it loaded
            _currentAssemblyLoadContext = new UmbracoAssemblyLoadContext();

            // NOTE: We cannot use in-memory assemblies due to the way the razor engine works which must use
            // application parts in order to add references to it's own CSharpCompiler.
            // These parts must have real paths since that is how the references are loaded. In that
            // case we'll need to work on temp files so that the assembly isn't locked.

            // Get a temp file path
            // NOTE: We cannot use Path.GetTempFileName(), see this issue:
            // https://github.com/dotnet/AspNetCore.Docs/issues/3589 which can cause issues, this is recommended instead
            var tempFile = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());

            File.Copy(pathToAssembly, tempFile, true);

            // Load it in
            Assembly assembly = _currentAssemblyLoadContext.LoadFromAssemblyPath(tempFile);

            // Add the assembly to the application parts - this is required because this is how
            // the razor ReferenceManager resolves what to load, see
            // https://github.com/dotnet/aspnetcore/blob/master/src/Mvc/Mvc.Razor.RuntimeCompilation/src/RazorReferenceManager.cs#L53
            var partFactory = ApplicationPartFactory.GetApplicationPartFactory(assembly);

            foreach (ApplicationPart applicationPart in partFactory.GetApplicationParts(assembly))
            {
                _applicationPartManager.ApplicationParts.Add(applicationPart);
            }

            return(assembly);
        }
Beispiel #6
0
        /// <summary>
        /// Добавление изображения в БД
        /// </summary>
        /// <param name="image"></param>
        /// <param name="imageName"></param>
        public void DownloadImage(string image, string imageName)
        {
            string name = imageName;

            //Если нет расширения, то добавить
            FileInfo info = new FileInfo(image);

            if (!name.Contains(info.Extension))
            {
                name = imageName + info.Extension;
            }

            //Копируем изображение в папку images
            string imagePath = Path.Combine(imagesPath, name);

            File.Copy(image, imagePath);

            //Добавляем изображение в БД
            AddNewImage(new FileInfo(imagePath));
        }
Beispiel #7
0
 /// <summary>
 /// Копирует текущий файл по заданному пути.
 /// </summary>
 /// <param name="newName">Путь, куда скопировать.</param>
 public override void copyto(string newName)
 {
     for (int i = 0; i < fileList.Count; i++)
     {
         try
         {
             FileClass.Copy(fileList[i], newName);
             if (Messang != null)
             {
                 Messang(this, new MyEvenArgs(string.Format("Файл '{0}' был перемещен.", fileList[i])));
             }
         }
         catch {
             if (Messang != null)
             {
                 Messang(this, new MyEvenArgs(string.Format("Файл '{0}' был перемещен.", fileList[i])));
             }
         }
     }
 }
Beispiel #8
0
 public void CopyTo(File target)
 {
     if (IsFile)
     {
         SysFile.Copy(FullName, target.FullName);
     }
     else if (IsDirectory)
     {
         if (target.IsDirectory)
         {
             target.CleanDirectory();
         }
         else
         {
             target.CreateDirectory();
         }
         foreach (var file in GetFiles())
         {
             file.CopyTo(new File(target, file.Name));
         }
     }
 }
Beispiel #9
0
        public static void Create(TuxConfig cfg, params IEnumerable <IContent>[] contents)
        {
            var          destination = new File(cfg.AppTemp);
            var          arch        = Architecture.X86_64;
            var          host        = Environment.MachineName;
            const string license     = "Proprietary";
            const string release     = "unstable";
            const string group       = "gnome";
            var          desc        = FormatDesc(cfg.Description).Split('\n');
            var          summary     = desc.First();
            var          description = string.Join(string.Empty, desc.Skip(1));
            var          include     = new Contents();
            var          packer      = new RpmContents(include);
            var          allContents = contents.SelectMany(c => c).ToArray();

            Array.ForEach(allContents, packer.Add);
            var builder = new Builder();

            builder.setPackage(cfg.PkgName, cfg.Version, release);
            builder.setType(RpmType.BINARY);
            builder.setPlatform(arch, Os.LINUX);
            builder.setSummary(summary);
            builder.setDescription(description);
            builder.setBuildHost(host);
            builder.setLicense(license);
            builder.setGroup(group);
            builder.setPackager(cfg.Maintainer.Split('<').First().Trim());
            builder.setVendor(cfg.Maintainer);
            builder.setUrl(cfg.Homepage);
            builder.setProvides(cfg.PkgName);
            builder.setFiles(include);
            var tmpFileName = Path.Combine(cfg.AppTemp, builder.build(destination));
            var fileName    = $"{cfg.PackageFile}.rpm";

            NetFile.Copy(tmpFileName, fileName, true);
        }
        private AntlrClassGenerationTaskInternal CreateBuildTaskWrapper()
        {
            AntlrClassGenerationTaskInternal wrapper = new AntlrClassGenerationTaskInternal();

            IList <string> sourceCodeFiles = null;

            if (this.SourceCodeFiles != null)
            {
                sourceCodeFiles = new List <string>(SourceCodeFiles.Length);
                foreach (ITaskItem taskItem in SourceCodeFiles)
                {
                    sourceCodeFiles.Add(taskItem.ItemSpec);
                }
            }

            if (this.TokensFiles != null && this.TokensFiles.Length > 0)
            {
                Directory.CreateDirectory(OutputPath);

                HashSet <string> copied = new HashSet <string>(StringComparer.OrdinalIgnoreCase);
                foreach (ITaskItem taskItem in TokensFiles)
                {
                    string fileName = taskItem.ItemSpec;
                    if (!File.Exists(fileName))
                    {
                        Log.LogError("The tokens file '{0}' does not exist.", fileName);
                        continue;
                    }

                    string vocabName = Path.GetFileNameWithoutExtension(fileName);
                    if (!copied.Add(vocabName))
                    {
                        Log.LogWarning("The tokens file '{0}' conflicts with another tokens file in the same project.", fileName);
                        continue;
                    }

                    string target = Path.Combine(OutputPath, Path.GetFileName(fileName));
                    if (!Path.GetExtension(target).Equals(".tokens", StringComparison.OrdinalIgnoreCase))
                    {
                        Log.LogError("The destination for the tokens file '{0}' did not have the correct extension '.tokens'.", target);
                        continue;
                    }

                    File.Copy(fileName, target, true);
                    File.SetAttributes(target, File.GetAttributes(target) & ~FileAttributes.ReadOnly);
                }
            }

            wrapper.ToolPath                            = ToolPath;
            wrapper.SourceCodeFiles                     = sourceCodeFiles;
            wrapper.TargetLanguage                      = TargetLanguage;
            wrapper.TargetFrameworkVersion              = TargetFrameworkVersion;
            wrapper.OutputPath                          = OutputPath;
            wrapper.Encoding                            = Encoding;
            wrapper.LanguageSourceExtensions            = LanguageSourceExtensions;
            wrapper.TargetNamespace                     = TargetNamespace;
            wrapper.GenerateListener                    = GenerateListener;
            wrapper.GenerateVisitor                     = GenerateVisitor;
            wrapper.ForceAtn                            = ForceAtn;
            wrapper.AbstractGrammar                     = AbstractGrammar;
            wrapper.JavaVendor                          = JavaVendor;
            wrapper.JavaInstallation                    = JavaInstallation;
            wrapper.JavaExecutable                      = JavaExecutable;
            wrapper.UseCSharpGenerator                  = UseCSharpGenerator;
            wrapper.IncludeDebuggerNonUserCodeAttribute = IncludeDebuggerNonUserCodeAttribute;
            return(wrapper);
        }
 /// <summary>
 /// Создание дубликата файла
 /// </summary>
 /// <param name="path">Путь к копии файла</param>
 /// <returns>Копия текущего файла</returns>
 public virtual Config DublicateFile(string path)
 {
     File.Copy(Path, path, true);
     return(new Config(path));
 }