Exemple #1
0
        public void LoadDocument(string strFile)
        {
            Dictionary <string, IActivity> mapActivity = new Dictionary <string, IActivity>();
            XmlDocument doc = new XmlDocument();

            //doc.Load(strFile);
            doc.LoadXml(strFile);
            XPathNavigator    nav      = doc.CreateNavigator();
            XPathNodeIterator Iterator = nav.Select("/CallFlow/Node[@docID='" + this.strDocID + "']");

            while (Iterator.MoveNext())
            {
                string strID        = Iterator.Current.GetAttribute("id", string.Empty);
                string strDocID     = Iterator.Current.GetAttribute("docID", string.Empty);
                int    x            = Convert.ToInt32(Iterator.Current.GetAttribute("lineNodeX", string.Empty));
                int    y            = Convert.ToInt32(Iterator.Current.GetAttribute("lineNodeY", string.Empty));
                bool   allowDrop    = Convert.ToBoolean(Iterator.Current.GetAttribute("allowDrop", string.Empty));
                bool   allowDraw    = Convert.ToBoolean(Iterator.Current.GetAttribute("allowDraw", string.Empty));
                string strLabelText = Iterator.Current.GetAttribute("LabelText", string.Empty);
                string strNodeValue = Iterator.Current.GetAttribute("NodeValue", string.Empty);

                Node n = GraphContainer.Instance.CreateNode(this, this, strID, strLabelText, allowDrop, allowDraw);
                //this.AddControl(n.Label);

                n.DocID     = strDocID;
                n.NodeValue = strNodeValue;
                GraphContainer.Instance.Nodes[strID] = n;
            }

            Iterator = nav.Select("/CallFlow/Activity[@docID='" + this.strDocID + "']");
            while (Iterator.MoveNext())
            {
                string strName       = Iterator.Current.GetAttribute("activityName", string.Empty);
                string strID         = Iterator.Current.GetAttribute("activityID", string.Empty);
                string activityValue = Iterator.Current.GetAttribute("activityValue", string.Empty);
                string strDesc       = Iterator.Current.GetAttribute("activityDesc", string.Empty);
                int    x             = Convert.ToInt32(Iterator.Current.GetAttribute("x", string.Empty));
                int    y             = Convert.ToInt32(Iterator.Current.GetAttribute("y", string.Empty));
                int    width         = Convert.ToInt32(Iterator.Current.GetAttribute("width", string.Empty));
                int    height        = Convert.ToInt32(Iterator.Current.GetAttribute("height", string.Empty));
                string strDocID      = Iterator.Current.GetAttribute("docID", string.Empty);

                IActivity act = ActivityCreator.Instance.CreateActivity(strName);
                act.ActivityID    = strID;
                act.ActivityValue = activityValue;
                act.Width         = width;
                act.Height        = height;
                act.DocID         = strDocID;
                act.Position      = new Point(x, y);

                XPathNodeIterator subNodes = nav.Select("/CallFlow/Activity[@activityID='" + strID + "']/EntryNode");
                while (subNodes.MoveNext())
                {
                    string strTmpNodeID = subNodes.Current.GetAttribute("id", string.Empty);
                    act.AddEntryNode(GraphContainer.Instance.Nodes[strTmpNodeID]);
                    GraphContainer.Instance.Nodes[strTmpNodeID].Activity = act as object;
                }

                subNodes = nav.Select("/CallFlow/Activity[@activityID='" + strID + "']/Node");
                while (subNodes.MoveNext())
                {
                    string strTmpNodeID = subNodes.Current.GetAttribute("id", string.Empty);
                    GraphContainer.Instance.Nodes[strTmpNodeID].Activity = act as object;
                    act.Nodes.Add(GraphContainer.Instance.Nodes[strTmpNodeID]);
                }

                subNodes = nav.Select("/CallFlow/Activity[@activityID='" + strID + "']/PrimaryNode");
                while (subNodes.MoveNext())
                {
                    string strTmpNodeID = subNodes.Current.GetAttribute("id", string.Empty);
                    act.PrimaryNode = GraphContainer.Instance.Nodes[strTmpNodeID];
                    GraphContainer.Instance.Nodes[strTmpNodeID].Activity = act as object;
                }

                subNodes = nav.Select("/CallFlow/Activity[@activityID='" + strID + "']/Attrs");
                while (subNodes.MoveNext())
                {
                    string strAttrKey = subNodes.Current.GetAttribute("key", string.Empty);
                    act.Values()[strAttrKey] = subNodes.Current.GetAttribute("val", string.Empty);
                }


                act.PreLoadDescription(this);

                GraphContainer.Instance.Activities.Add(act);
                //act.AdjustNodePosition();
                act.Description    = strDesc;
                mapActivity[strID] = act;
            }

            Iterator = nav.Select("/CallFlow/Page[@docID='" + this.strDocID + "']");
            while (Iterator.MoveNext())
            {
                string strName     = Iterator.Current.GetAttribute("flowName", string.Empty);
                string strActivity = Iterator.Current.GetAttribute("entry", string.Empty);

                Page p = new Page(this.strDocID, strName, mapActivity[strActivity]);
                GraphContainer.Instance.AddPage(strDocID, p);
            }

            Invalidate();
        }