Пример #1
0
        static public void ImportHMITagTableXML(XmlDocument doc, TagFolder folder)
        {
            FileInfo path = TempFile.File("import_tagtable_", "xml");

            try
            {
                XmlWriter writer = XmlWriter.Create(path.ToString());
                doc.Save(writer);
                writer.Close();

                folder.TagTables.Import(path, ImportOptions.Override);
            }
            finally
            {
                try
                {
                    path.Delete();
                }
                catch (IOException e)
                {
                    Console.WriteLine("Failed to delete temporary file: " + e.Message);
                }
            }
        }
Пример #2
0
 protected override void DoWork()
 {
     lock (portal)
     {
         try
         {
             Stack <string>     group_names = new Stack <string>();
             IEngineeringObject obj         = fromBlock.Parent;
             while (obj is PlcBlockUserGroup)
             {
                 group_names.Push(((PlcBlockGroup)obj).Name);
                 obj = obj.Parent;
             }
             PlcBlockGroup group = toPlc.BlockGroup;
             foreach (string group_name in group_names)
             {
                 PlcBlockUserGroup child = group.Groups.Find(group_name);
                 if (child != null)
                 {
                     group = child;
                 }
                 else
                 {
                     group = group.Groups.Create(group_name);
                 }
             }
             FileInfo file = TempFile.File("export_block_", "xml");
             fromBlock.Export(file, ExportOptions.None);
             group.Blocks.Import(file, overwrite ? ImportOptions.Override : ImportOptions.None);
         } catch (Exception ex)
         {
             LogMessage(MessageLog.Severity.Error, "Failed to copy from " + fromBlock.Name + " to " + toPlc.Name + ":\n" + ex.Message);
             return;
         }
     }
 }
Пример #3
0
        static public void ImportPlcTypeXML(XmlDocument doc, PlcTypeGroup group)
        {
            FileInfo path = TempFile.File("import_type_", "xml");

            try
            {
                XmlWriter writer = XmlWriter.Create(path.ToString());
                doc.Save(writer);
                writer.Close();

                group.Types.Import(path, ImportOptions.Override);
            }
            finally
            {
                try
                {
                    path.Delete();
                }
                catch (IOException e)
                {
                    Console.WriteLine("Failed to delete temporary file: " + e.Message);
                }
            }
        }