/// <summary> /// Prj_Sheet to Xml /// </summary> /// <param name="sheet"></param> public static void GenerateXinHuaSheets(BllManager bll, Prj_Document documet, string outPath) { string pagesPath = outPath + "\\data\\xinhua\\Pages\\"; if (!Directory.Exists(pagesPath)) { Directory.CreateDirectory(pagesPath); } if (session == null) { session = bll.manager.session; } try { // 每个Document只包含一个Sheet int sheetID = bll.manager.SheetCRUD.GetPrj_Sheets_By_Prj_Document_ID(documet.ID)[0].ID; Prj_Sheet sheet = bll.manager.SheetCRUD.Load_Sheet(sheetID); ArrayList symbols = new ArrayList(); // 算法块 foreach (Cld_FCBlock block in sheet.Cld_FCBlock_List) { #region if(特殊块) if (block.FunctionName == "XAI") { GenerateXAIBlock(block, symbols); } else if (block.FunctionName == "XAO") { GenerateXAOBlock(block, symbols); } else if (block.FunctionName == "XDI") { GenerateXDIBlock(block, symbols); } else if (block.FunctionName == "XDO") { GenerateXDOBlock(block, symbols); } else if (block.FunctionName == "XPI") { GenerateXPIBlock(block, symbols); } else if (block.FunctionName == "XPgAI") { GenerateXPgAIBlock(block, symbols); } else if (block.FunctionName == "XPgAO") { GenerateXPgAOBlock(block, symbols); } else if (block.FunctionName == "XPgDI") { GenerateXPgDIBlock(block, symbols); } else if (block.FunctionName == "XPgDO") { GenerateXPgDOBlock(block, symbols); } else if (block.FunctionName == "XNetAI") { GenerateXNetAIBlock(block, symbols); } else if (block.FunctionName == "XNetAO") { GenerateXNetAOBlock(block, symbols); } else if (block.FunctionName == "XNetDI") { GenerateXNetDIBlock(block, symbols); } else if (block.FunctionName == "XNetDO") { GenerateXNetDOBlock(block, symbols); } #endregion else { bll.generate_Rec_symbol(block, BllManager.rela_pos.UPLEFT); GenerateCommonBlock(block, symbols); } } // 文本块 foreach (Cld_Graphic graphic in sheet.Cld_Graphic_List) { if (graphic.Type == "Text") { GenerateText(graphic, symbols); } } //IList constants = sheet.Cld_Constant_List; // 信号线 IDictionary<string, Cld_Signal> signalTable = bll.GenerateSignalLines(sheet); foreach (Cld_Signal signal in signalTable.Values) { string[] signalDataList = signal.Data.TrimEnd(' ', ';').Split(';'); foreach (string signalData in signalDataList) { LogicSignalLine signalline = new LogicSignalLine(signalData, signal.Name, signal.SignalType); symbols.Add(signalline); } } // 创建XmlTextWriter类的实例对象 XmlTextWriter textWriter = new XmlTextWriter(pagesPath + documet.DocumentName.Replace('-', '_') + ".xfig", Encoding.UTF8); textWriter.Indentation = 4; textWriter.Formatting = Formatting.Indented; textWriter.WriteStartElement("document"); textWriter.WriteAttributeString("Type", "BeginNode"); textWriter.WriteAttributeString("GraphicName", documet.DocumentCaption); textWriter.WriteAttributeString("BackColor", "FF FF FF FF"); textWriter.WriteAttributeString("width", Convert.ToString(sheet.Width * 10)); textWriter.WriteAttributeString("heigth", Convert.ToString(sheet.Height * 10)); LogicRectangle pageBounds0 = new LogicRectangle(); pageBounds0.Location = new PointF(0, 0); pageBounds0.Size = new SizeF(sheet.Width, sheet.Height); pageBounds0.LineWidth = 1; pageBounds0.GetXinhuaGraphicXml(textWriter); LogicRectangle pageBounds1 = new LogicRectangle(); pageBounds1.Location = new PointF(30, 30); pageBounds1.Size = new SizeF(sheet.Width - 60f, sheet.Height - 60f); pageBounds1.LineWidth = 2; pageBounds1.GetXinhuaGraphicXml(textWriter); foreach (object obj in symbols) { ((ILogicGraphicFormat)obj).GetXinhuaGraphicXml(textWriter); } textWriter.WriteEndElement(); textWriter.Close(); } catch (System.Exception e) { Console.WriteLine(e.ToString()); } }