Beispiel #1
0
 public Block(Node node)
 {
     NextBlocks = new Dictionary<string, Block>();
     Name = node.Name;
     GlobalGUID = node.GlobalGUID;
     InstanceGUID = node.InstanceGUID;
     switch (node.GetType().Name)
     {
         case "ServiceNode":
             BlockType = BlockTypes.Service;
             DestURI = ServiceManager.ServiceList[node.GlobalGUID].ServiceConfig["Server_URI"];
             break;
         case "ConditionNode":
             BlockType = BlockTypes.Condition;
             ConditionType = ServiceManager.ConditionList[node.GlobalGUID].Type;
             break;
         case "ConditionValueNode":
             BlockType = BlockTypes.ConditionOption;
             break;
         case "SIPResponseNode":
             BlockType = BlockTypes.SIPResponse;
             break;
         default:
             Console.WriteLine("Unkown node type" + node.GetType().Name);
             break;
     }
     if (node.Name != "Start")
     {
         FillBlocks(node, this);
     }
 }
 public ServiceFlow(Node rootNode, String name)
 {
     Init(name);
     FirstBlockGUID = rootNode.Children[0].InstanceGUID;
     Dictionary<string, Block> blocks = new Dictionary<string, Block>();
     CreateBlocks(blocks, rootNode);
     Blocks = blocks;
     RootNode = rootNode.d3Node;
 }
 //Flat Tree
 private void CreateBlocks(Dictionary<string, Block> blocks, Node node)
 {
     Block block = new Block(node);
     if (node.Children.Count > 0)
     {
         if (node.Name != "Start")
         {
             blocks.Add(block.InstanceGUID, block);
         }
         foreach (Node child in node.Children)
         {
             CreateBlocks(blocks, child);
         }
     }
 }
Beispiel #4
0
 public string SaveChain(Object guid, String chain, String name)
 {
     var jss = new JavaScriptSerializer();
     D3Node rootD3Node = jss.Deserialize<D3Node>(chain);
     Node rootNode = new Node(rootD3Node);
     List<ServiceFlow> sfs;
     String errorMessage;
     if (GetServiceFlows(out sfs, out errorMessage))
     {
         ServiceFlow serviceflow = new ServiceFlow(rootNode, name);
         return jss.Serialize(SaveServiceFlow(sfs, serviceflow));
     }
     return jss.Serialize(errorMessage);
 }
 private void CreateBlocks(Node node)
 {
     Blocks = new Dictionary<string, Block>();
     CreateBlocks(Blocks, node);
 }
Beispiel #6
0
 //Pruned section of tree starting at node
 private void FillBlocks(Node node, Block block)
 {
     if (node == null) return;
     if (node.Children.Count > 0)
     {
         foreach (Node child in node.Children)
         {
             switch (node.GetType().Name)
             {
                 case "ServiceNode":
                 case "ConditionNode":
                     block.AddChild(child.Name, new Block(child));
                     break;
                 case "ConditionValueNode":
                 case "SIPResponseNode":
                     block.AddChild(child.InstanceGUID, new Block(child));
                     break;
                 default:
                     Console.WriteLine("Unkown node type" + child.GetType().Name);
                     break;
             }
             //FillBlocks(child, block);
         }
     }
 }