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

            zenonLogicProject.ExportAsFile(xmlFilePathToImport, LogicXmlEncoding);
            return(xmlFilePathToImport);
        }
예제 #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);
            }
        }
예제 #3
0
 public void Dispose()
 {
     // delete temporary files which were created during lifetime
     TemporaryFileCreator.CleanupTemporaryFiles();
     // detach event handler
     if (LazyLogicProjects != null)
     {
         LazyLogicProjects.CollectionChanged -= UpdateStratonDirectoryOfPathOnItemAdded;
     }
 }
예제 #4
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);
        }