Exemple #1
0
        //将数据保存为XML文件(接口)
        public XmlDocument ToXML()
        {
            //所有网络数据都保存为xml格式
            XmlDocument doc  = new XmlDocument();
            XmlElement  root = doc.CreateElement(XmlNames.Graph);

            //Nodes
            var nodes = doc.CreateElement(XmlNames.Nodes);

            nodes.SetAttribute(XmlNames.NodeNumber, myNodeList.Count.ToString());
            foreach (KeyValuePair <string, Node> curItem in myNodeList)
            {
                XmlElement newNode = SerializableHelper.Serialize(doc, curItem.Value);
                nodes.AppendChild(newNode);
            }
            root.AppendChild(nodes);
            //Edges
            var edges = doc.CreateElement(XmlNames.Edges);

            edges.SetAttribute(XmlNames.EdgeNumber, myEdgeList.Count.ToString());
            foreach (Edge curItem in myEdgeList)
            {
                edges.AppendChild(SerializableHelper.Serialize(doc, curItem));
            }
            root.AppendChild(edges);

            doc.AppendChild(root);
            return(doc);
        }
        public void GoIntoQueueOld(RequestData data)
        {
            string requestDir = queueDir + "\\request" + "\\" + data.DocName;

            if (!Directory.Exists(requestDir))
            {
                Directory.CreateDirectory(requestDir);
            }
            string requestFile = requestDir + "\\" + data.Sequence;

            SerializableHelper helper = new SerializableHelper();

            helper.Serialize(data, requestFile);
        }