private void convertToPN(string kwsnFileName) { do { WSNTabItem wsnTabItem = new WSNTabItem("KWSN Model", "KWSN", null); wsnTabItem.Open(kwsnFileName); string pnName = DateTime.Now.Millisecond.ToString() + ".pn"; // 13486468456456.pn PNGenerationHelper helper = new PNGenerationHelper(pnName, wsnTabItem); helper.GenerateXML(false, false); bool cne = createModule(); if (cne == false) break; } while (false); }
public PNGenerationHelper buildHelperAfterCluster(String newFileName) { PNGenerationHelper helper = null; do { if (CurrentActiveTab is WSNTabItem) { helper = new PNGenerationHelper(newFileName, CurrentActiveTab); break; } if ((CurrentActiveTab is PNTabItem) == false) break; XmlDocument pnDoc = new XmlDocument(); try { pnDoc.Load(CurrentActiveTab.FileName); } catch { MessageBox.Show("Error when reading PN file!"); } IList<WSNCanvas> listCanvas = new List<WSNCanvas>(); KWSNGenerationHelper tempHelper = new KWSNGenerationHelper(newFileName, CurrentActiveTab); XmlDocument doc = tempHelper.GenerateXML(); XmlElement wsnNode = doc.ChildNodes[0] as XmlElement; XmlElement networkNode = wsnNode.GetElementsByTagName(XmlTag.TAG_NETWORK)[0] as XmlElement; foreach (XmlElement process in networkNode.ChildNodes) { WSNCanvas kCanvas = new WSNCanvas(process.GetAttribute(XmlTag.ATTR_NAME)); kCanvas.LoadFromXml(process); listCanvas.Add(kCanvas); } helper = new PNGenerationHelper(newFileName, CurrentActiveTab); } while (false); return helper; }