Exemple #1
0
        private string SerializeZenonLogicProjectToXmlFile(LogicProject zenonLogicProject)
        {
            string xmlFilePathToImport = TemporaryFileCreator.GetRandomTemporaryFilePathWithExtension("xml");

            zenonLogicProject.ExportAsFile(xmlFilePathToImport, LogicXmlEncoding);
            return(xmlFilePathToImport);
        }
Exemple #2
0
        /// <summary>
        /// Writes the appli.xml content directly into the file.
        /// </summary>
        /// <remarks>
        /// This is done because import via k5b.exe omitts the folder structures in the application tree.
        /// </remarks>
        /// <param name="zenonLogicProject"></param>
        private void WriteAppliXmlFile(LogicProject zenonLogicProject)
        {
            string appliXmlFilePathToImport = TemporaryFileCreator.GetRandomTemporaryFilePathWithExtension("xml");

            zenonLogicProject.ApplicationTree.ExportAsFile(appliXmlFilePathToImport, LogicXmlEncoding);

            var appliFilePath = Path.Combine(this.ZenonLogicProjectDirectory, "appli.xml");

            try
            {
                if (File.Exists(appliFilePath))
                {
                    File.Delete(appliFilePath);
                }

                File.Copy(appliXmlFilePathToImport, appliFilePath);
            }
            catch (IOException e)
            {
                throw new InvalidOperationException(string.Format(Strings.AppliFileWriteIOException, appliFilePath), e);
            }
            catch (Exception e)
            {
                throw new InvalidOperationException(String.Format(Strings.AppliFileWriteException, appliFilePath), e);
            }
        }
Exemple #3
0
        /// <summary>
        /// Writes the appli.EQV content directly into the file.
        /// </summary>
        /// <remarks>
        /// This is done because the import via k5b.exe omitts global definitions.
        /// </remarks>
        /// <param name="zenonLogicProject"></param>
        private void WriteGlobalDefinesFile(LogicProject zenonLogicProject)
        {
            string      globalDefinesFilePath = TemporaryFileCreator.GetRandomTemporaryFilePathWithExtension("EQV");
            LogicDefine globalDefine          = zenonLogicProject.LogicDefinitions.Defines
                                                .FirstOrDefault(define => define.Name.Equals(Strings.GlobalDefineName));

            if (globalDefine == null || string.IsNullOrWhiteSpace(globalDefine.DefineContent))
            {
                return;
            }

            File.WriteAllText(globalDefinesFilePath, globalDefine.DefineContent);

            var appliEqvFilePath = Path.Combine(this.ZenonLogicProjectDirectory, "appli.EQV");

            if (File.Exists(appliEqvFilePath))
            {
                File.Delete(appliEqvFilePath);
            }

            File.Copy(globalDefinesFilePath, appliEqvFilePath);
        }