public bool compile()
        {
            base.compile();
            bool      ret         = false;
            Node      valueNode   = FindFirstNode();
            Node      nodeEntry   = Compiler.mapLink[valueNode];
            IActivity farActivity = FindActivityByEntry(nodeEntry);

            mapNodeValue["[%DONE%]"] = farActivity;

            string strDesc1 = farActivity.Description.Replace(' ', '_');

            strCurrentExt = FindExtension(this);
            if (strCurrentExt.Trim().Length <= 0)
            {
                Compiler.PrintError("Disconnected link", "");
                return(false);
            }

            string strVal = "";

            if (attribute.ContainsKey("ext"))
            {
                strVal = attribute["ext"];
                if (strVal.Trim().Length <= 0)
                {
                    Compiler.PrintError("Activity '" + strDesc + "' in '" + this.FindFlow(strDocID) + "' - variable " + strVal + " not be defined.", "");
                    return(ret);
                }
                else if (VariableExist(strVal, true))
                {
                    strVal = "${" + strVal + "}";
                }
            }


            //Goto label
            lpInstruction = new ArrayList();

            InstructionSet set = new InstructionSet();

            set.ExtNumber   = strCurrentExt;
            set.Label       = strDesc.Replace(' ', '_');
            set.Instruction = string.Format("Goto({0},{1})", new object[] { strVal, strDesc1 });
            lpInstruction.Add(set);

            priorityOffset = lpInstruction.Count - 1;

            ret = true;

            return(ret);
        }
Exemple #2
0
        public bool compile()
        {
            base.compile();

            bool ret = false;

            strCurrentExt = FindExtension(this);
            if (strCurrentExt.Trim().Length <= 0)
            {
                Compiler.PrintError("Disconnected link", "");
                return(false);
            }

            string strLang = "";

            if (attribute.ContainsKey("language"))
            {
                strLang = attribute["language"];

                if (strLang.Trim().Length <= 0)
                {
                    Compiler.PrintError("Activity '" + strDesc + "' in '" + this.FindFlow(strDocID) + "' - variable " + strLang + " not be defined.", "");
                    return(ret);
                }
                else if (!VariableExist(strLang, true))
                {
                    strLang = "${" + strLang + "}";
                }
            }

            Node      valueNode   = FindNodeByResult("Done");
            Node      nodeEntry   = Compiler.mapLink[valueNode];
            IActivity farActivity = FindActivityByEntry(nodeEntry);

            mapNodeValue["[%DONE%]"] = farActivity;

            lpInstruction = new ArrayList();
            string         strInstruct = string.Format("Set(CHANNEL(language)={0}) ", new object[] { strLang });
            InstructionSet set         = new InstructionSet();

            set.ExtNumber   = strCurrentExt;
            set.Label       = strDesc.Replace(' ', '_');
            set.Instruction = strInstruct;
            lpInstruction.Add(set);

            priorityOffset = lpInstruction.Count - 1;

            ret = true;
            return(ret);
        }
Exemple #3
0
        public bool compile()
        {
            base.compile();
            base.compile();

            bool ret = false;
            Page p   = Compiler.mapPage[this.DocID];

            lpInstruction = new ArrayList();
            string strInstruct = "";

            //Result nodes
            if (resultNode.Count < 0)
            {
                Compiler.PrintError("Activity '" + strDesc + "' result node not be defined.", "");
                return(ret);
            }
            else
            {
                Dictionary <string, Node> .Enumerator lpNode = resultNode.GetEnumerator();

                while (lpNode.MoveNext())
                {
                    KeyValuePair <string, Node> item = lpNode.Current;
                    string    strItem      = item.Value.Value;
                    Node      valueNode2   = item.Value;                   //current result node for this activity
                    Node      nodeEntry2   = Compiler.mapLink[valueNode2]; //Entry node of the following activity
                    IActivity farActivity2 = FindActivityByEntry(nodeEntry2);

                    mapNodeValue["[%" + strItem.Trim() + "%]"] = farActivity2;

                    strInstruct = string.Format("NoOp(Start context {0})", new object[] { p.FlowName.Replace(' ', '_') });
                    InstructionSet set = new InstructionSet();
                    set.ExtNumber   = item.Value.Value;
                    set.Priority    = StartPriority;
                    set.Label       = strDesc.Replace(' ', '_');
                    set.Instruction = strInstruct;
                    lpInstruction.Add(set);
                }

                Context = p.FlowName.Replace(' ', '_');

                priorityOffset = 0;

                ret = true;
            }


            return(ret);
        }
        public bool compile()
        {
            base.compile();
            bool ret = true;

            string strTimeout = "";

            if (attribute.ContainsKey("wait"))
            {
                strTimeout = attribute["wait"];
                if (Convert.ToInt32(strTimeout) <= 0)
                {
                    strTimeout = "";
                }
            }

            Node      valueNode   = FindNodeByResult("Done");
            Node      nodeEntry   = Compiler.mapLink[valueNode];
            IActivity farActivity = FindActivityByEntry(nodeEntry);

            mapNodeValue["[%DONE%]"] = farActivity;


            strCurrentExt = FindExtension(this);
            if (strCurrentExt.Trim().Length <= 0)
            {
                Compiler.PrintError("Disconnected link", "");
                return(false);
            }

            lpInstruction = new ArrayList();
            InstructionSet set = new InstructionSet();

            set.ExtNumber   = strCurrentExt;
            set.Label       = strDesc.Replace(' ', '_');
            set.Instruction = string.Format("Answer({0})", new object[] { strTimeout });
            lpInstruction.Add(set);

            priorityOffset = lpInstruction.Count - 1;

            return(ret);
        }
Exemple #5
0
        public void adjustSequence()
        {
            if (lpInstruction != null)
            {
                int            idx     = 0;
                InstructionSet mainSet = null;
                foreach (InstructionSet set in lpInstruction)
                {
                    if (idx == 0)
                    {
                        mainSet = set;
                    }
                    else if (idx == 2)
                    {
                        int priority = set.Priority;

                        mainSet.Instruction = mainSet.Instruction.Replace("YXYXYX", Convert.ToString(priority));
                    }
                    idx++;
                }
            }
        }
        public bool compile()
        {
            base.compile();

            bool   ret    = false;
            string strVal = "";

            if (attribute.ContainsKey("hangupcode"))
            {
                strVal = attribute["hangupcode"];
                if (VariableExist(strVal, true))
                {
                    strVal = "${" + strVal + "}";
                }
            }

            strCurrentExt = FindExtension(this);
            if (strCurrentExt.Trim().Length <= 0)
            {
                Compiler.PrintError("Disconnected link", "");
                return(false);
            }

            lpInstruction = new ArrayList();
            InstructionSet set = new InstructionSet();

            set.ExtNumber   = strCurrentExt;
            set.Label       = strDesc.Replace(' ', '_');
            set.Instruction = string.Format("Hangup({0}) ", new object[] { strVal });
            lpInstruction.Add(set);
            priorityOffset = lpInstruction.Count - 1;

            ret = true;

            return(ret);
        }
Exemple #7
0
        public bool compile()
        {
            base.compile();
            bool ret = false;

            lpInstruction = new ArrayList();
            ArrayList strResult = null;
            string    strVar    = "";

            if (attribute.ContainsKey("var"))
            {
                strVar = attribute["var"];

                if (strVar.Trim().Length > 0)
                {
                    if (VariableExist(strVar, true))
                    {
                        strVar = "${" + strVar + "}";
                    }
                    else
                    {
                        Compiler.PrintError("Activity '" + strDesc + "' in '" + this.FindFlow(strDocID) + "' - variable not be defined.", "");
                        return(ret);
                    }
                }
                else
                {
                    Compiler.PrintError("Activity '" + strDesc + "' in '" + this.FindFlow(strDocID) + "' - variable not be defined.", "");
                    return(ret);
                }
            }
            else
            {
                Compiler.PrintError("Activity '" + strDesc + "' in '" + this.FindFlow(strDocID) + "' - variable not be defined.", "");
                return(ret);
            }


            strCurrentExt = FindExtension(this);
            if (strCurrentExt.Trim().Length <= 0)
            {
                Compiler.PrintError("Disconnected link", "");
                return(false);
            }

            strResult = ConcatResult();

            InstructionSet set = new InstructionSet();

            set.ExtNumber   = strCurrentExt;
            set.Label       = strDesc.Replace(' ', '_');
            set.Instruction = "NoOp(Switch Case: " + set.Label + ")";
            lpInstruction.Add(set);

            foreach (string strItem in strResult)
            {
                Node      valueNode   = FindNodeByResult(strItem);
                Node      nodeEntry   = Compiler.mapLink[valueNode];
                IActivity farActivity = FindActivityByEntry(nodeEntry);

                mapNodeValue["[%" + strItem.Trim() + "%]"] = farActivity;

                set             = new InstructionSet();
                set.ExtNumber   = strCurrentExt;
                set.Label       = "";
                set.Instruction = string.Format("Gotoif($[\"{0}\"=\"{1}\"]?{2})", new object[] { strVar, strItem.Trim(), farActivity.Description.Replace(' ', '_') });
                lpInstruction.Add(set);
            }

            priorityOffset = lpInstruction.Count - 1;

            ret = true;
            return(ret);
        }
        public bool compile()
        {
            base.compile();
            bool   ret       = false;
            string strVal1   = "";
            string strOp     = "";
            string strVal2   = "";
            string strResult = "";
            string strType   = "";

            if (attribute.ContainsKey("variable1"))
            {
                strVal1 = attribute["variable1"];
                if (IsNumber(strVal1))
                {
                    //none
                }
                else if (strVal1.Trim().Length <= 0)
                {
                    Compiler.PrintError("Activity '" + strDesc + "' in '" + this.FindFlow(strDocID) + "' - variable " + strVal1 + " not be defined.", "");
                    return(ret);
                }
                else if (VariableExist(strVal1, true))
                {
                    strVal1 = "${" + strVal1 + "}";
                }
            }
            if (attribute.ContainsKey("operator"))
            {
                strOp = attribute["operator"];
            }
            if (attribute.ContainsKey("variable2"))
            {
                strVal2 = attribute["variable2"];
                if (IsNumber(strVal2))
                {
                    //none
                }
                else if (strVal2.Trim().Length <= 0)
                {
                    Compiler.PrintError("Activity '" + strDesc + "' in '" + this.FindFlow(strDocID) + "' - variable " + strVal2 + " not be defined.", "");
                    return(ret);
                }
                else if (VariableExist(strVal2, true))
                {
                    strVal2 = "${" + strVal2 + "}";
                }
            }
            if (attribute.ContainsKey("optype"))
            {
                strType = attribute["optype"];
            }
            if (attribute.ContainsKey("result"))
            {
                strResult = attribute["result"];

                if (!VariableExist(strResult, false))
                {
                    Compiler.PrintError("Activity '" + strDesc + "' in '" + this.FindFlow(strDocID) + "' - variable " + strResult + " not be defined", "");
                    return(ret);
                }
            }

            Node      valueNode   = FindNodeByResult("Done");
            Node      nodeEntry   = Compiler.mapLink[valueNode];
            IActivity farActivity = FindActivityByEntry(nodeEntry);

            mapNodeValue["[%DONE%]"] = farActivity;

            strCurrentExt = FindExtension(this);
            if (strCurrentExt.Trim().Length <= 0)
            {
                Compiler.PrintError("Disconnected link", "");
                return(false);
            }


            lpInstruction = new ArrayList();
            InstructionSet set = new InstructionSet();

            set.ExtNumber   = strCurrentExt;
            set.Label       = strDesc.Replace(' ', '_');
            set.Instruction = string.Format("SET({0}=${{MATH({1}{2}{3},{4})}})",
                                            new object[] { strResult, strVal1, strOp, strVal2, strType });
            lpInstruction.Add(set);

            priorityOffset = lpInstruction.Count - 1;

            ret = true;

            return(ret);
        }
Exemple #9
0
        public bool compile()
        {
            base.compile();

            bool      ret         = false;
            Node      valueNode   = FindFirstNode();
            Node      nodeEntry   = Compiler.mapLink[valueNode];
            IActivity farActivity = FindActivityByEntry(nodeEntry);

            mapNodeValue["[%DONE%]"] = farActivity;
            Page thisPage = ThisPage();

            strCurrentExt = FindExtension(this);
            if (strCurrentExt.Trim().Length <= 0)
            {
                Compiler.PrintError("Disconnected link", "");
                return(false);
            }


            if (Compiler.mapPage.ContainsKey(farActivity.DocID))
            {
                Page page = Compiler.mapPage[farActivity.DocID];

                string strVal       = "";
                string strGotoLabel = "";

                if (attribute.ContainsKey("extension"))
                {
                    strVal = attribute["extension"];
                    if (strVal.Trim().Length <= 0)
                    {
                        Compiler.PrintError("Activity '" + strDesc + "' in '" + this.FindFlow(strDocID) + "' - variable " + strVal + " not be defined.", "");
                        return(ret);
                    }
                    else if (VariableExist(strVal, true))
                    {
                        strVal = "${" + strVal + "}";
                    }
                }
                if (attribute.ContainsKey("gotolabel"))
                {
                    strGotoLabel = attribute["gotolabel"];
                    if (strGotoLabel.Trim().Length <= 0)
                    {
                        Compiler.PrintError("Label '" + strDesc + "' in '" + this.FindFlow(strDocID) + "' - variable " + strVal + " not be defined.", "");
                        return(ret);
                    }
                }


                //Goto label
                lpInstruction = new ArrayList();

                InstructionSet set = new InstructionSet();
                set.ExtNumber = strCurrentExt;
                set.Label     = strDesc.Replace(' ', '_');
                if (thisPage.DocID == page.DocID)
                {
                    if (strGotoLabel.ToLower() == "start")
                    {
                        set.Instruction = string.Format("Goto({0},{1})", new object[] { strVal, 1 });
                    }
                    else
                    {
                        set.Instruction = string.Format("Goto({0},{1})", new object[] { strVal, strGotoLabel });
                    }
                }
                else
                {
                    if (strGotoLabel.ToLower() == "start")
                    {
                        set.Instruction = string.Format("Goto({0},{1},{2})", new object[] { page.FlowName.Replace(' ', '_'), strVal, 1 });
                    }
                    else
                    {
                        set.Instruction = string.Format("Goto({0},{1},{2})", new object[] { page.FlowName.Replace(' ', '_'), strVal, strGotoLabel });
                    }
                }
                lpInstruction.Add(set);

                priorityOffset = lpInstruction.Count - 1;

                ret = true;
            }
            else
            {
                Compiler.PrintError("Subflow for " + strDesc + " not be defined.", "");
            }

            return(ret);
        }
        public bool compile()
        {
            base.compile();

            bool ret = false;

            lpInstruction = new ArrayList();
            string strWait   = "";
            string strDialTo = "";
            string strOption = "";

            strCurrentExt = FindExtension(this);
            if (strCurrentExt.Trim().Length <= 0)
            {
                Compiler.PrintError("Disconnected link", "");
                return(false);
            }

            if (attribute.ContainsKey("wait"))
            {
                strWait = attribute["wait"];
            }
            if (attribute.ContainsKey("dialto"))
            {
                strDialTo = attribute["dialto"];

                if (strDialTo.Trim().Length <= 0)
                {
                    Compiler.PrintError("Activity '" + strDesc + "' in '" + this.FindFlow(strDocID) + "' - variable " + strDialTo + " not be defined.", "");
                    return(ret);
                }
                else if (!VariableExist(strDialTo, true))
                {
                    //none
                }
                else
                {
                    strDialTo = "${" + strDialTo + "}";
                }
            }
            if (attribute.ContainsKey("options"))
            {
                strOption = attribute["options"];
            }

            string strDesc2 = "";
            string strDesc3 = "";
            string strDesc4 = "";
            string strDesc5 = "";
            string strDesc6 = "";
            string strDesc7 = "";
            string strDesc8 = "";
            string strDesc9 = "";

            string strDesc22 = "";
            string strDesc33 = "";
            string strDesc44 = "";
            string strDesc55 = "";
            string strDesc66 = "";
            string strDesc77 = "";
            string strDesc88 = "";
            string strDesc99 = "";


            InstructionSet set = new InstructionSet();

            set.ExtNumber   = strCurrentExt;
            set.Label       = strDesc.Replace(' ', '_');
            set.Instruction = string.Format("Dial({0},{1},{2})", new object[] { strDialTo, strWait, strOption });
            lpInstruction.Add(set);

            Node      valueNode   = FindNodeByResult("CHANUNAVAIL");
            Node      nodeEntry   = Compiler.mapLink[valueNode];
            IActivity farActivity = FindActivityByEntry(nodeEntry);

            mapNodeValue["[%CHANUNAVAIL%]"] = farActivity;
            strDesc2        = farActivity.Description.Replace(' ', '_');
            strDesc22       = farActivity.Description.Replace(' ', '_') + System.Guid.NewGuid().ToString().Substring(0, 5);
            set             = new InstructionSet();
            set.ExtNumber   = strCurrentExt;
            set.Label       = strDesc.Replace(' ', '_');
            set.Instruction = string.Format("Gotoif($[\"${{DIALSTATUS}}\"=\"CHANUNAVAIL\"]?{0})", new object[] { strDesc22 });
            lpInstruction.Add(set);

            valueNode   = FindNodeByResult("BUSY");
            nodeEntry   = Compiler.mapLink[valueNode];
            farActivity = FindActivityByEntry(nodeEntry);
            mapNodeValue["[%BUSY%]"] = farActivity;
            strDesc3        = farActivity.Description.Replace(' ', '_');
            strDesc33       = farActivity.Description.Replace(' ', '_') + System.Guid.NewGuid().ToString().Substring(0, 5);
            set             = new InstructionSet();
            set.ExtNumber   = strCurrentExt;
            set.Label       = strDesc.Replace(' ', '_');
            set.Instruction = string.Format("Gotoif($[\"${{DIALSTATUS}}\"=\"BUSY\"]?{0})", new object[] { strDesc33 });
            lpInstruction.Add(set);

            valueNode   = FindNodeByResult("NOANSWER");
            nodeEntry   = Compiler.mapLink[valueNode];
            farActivity = FindActivityByEntry(nodeEntry);
            mapNodeValue["[%NOANSWER%]"] = farActivity;
            strDesc4        = farActivity.Description.Replace(' ', '_');
            strDesc44       = farActivity.Description.Replace(' ', '_') + System.Guid.NewGuid().ToString().Substring(0, 5);
            set             = new InstructionSet();
            set.ExtNumber   = strCurrentExt;
            set.Label       = strDesc.Replace(' ', '_');
            set.Instruction = string.Format("Gotoif($[\"${{DIALSTATUS}}\"=\"NOANSWER\"]?{0})", new object[] { strDesc44 });
            lpInstruction.Add(set);

            valueNode   = FindNodeByResult("ANSWER");
            nodeEntry   = Compiler.mapLink[valueNode];
            farActivity = FindActivityByEntry(nodeEntry);
            mapNodeValue["[%ANSWER%]"] = farActivity;
            strDesc5        = farActivity.Description.Replace(' ', '_');
            strDesc55       = farActivity.Description.Replace(' ', '_') + System.Guid.NewGuid().ToString().Substring(0, 5);
            set             = new InstructionSet();
            set.ExtNumber   = strCurrentExt;
            set.Label       = strDesc.Replace(' ', '_');
            set.Instruction = string.Format("Gotoif($[\"${{DIALSTATUS}}\"=\"ANSWER\"]?{0})", new object[] { strDesc55 });
            lpInstruction.Add(set);

            valueNode   = FindNodeByResult("CANCEL");
            nodeEntry   = Compiler.mapLink[valueNode];
            farActivity = FindActivityByEntry(nodeEntry);
            mapNodeValue["[%CANCEL%]"] = farActivity;
            strDesc6        = farActivity.Description.Replace(' ', '_');
            strDesc66       = farActivity.Description.Replace(' ', '_') + System.Guid.NewGuid().ToString().Substring(0, 5);
            set             = new InstructionSet();
            set.ExtNumber   = strCurrentExt;
            set.Label       = strDesc.Replace(' ', '_');
            set.Instruction = string.Format("Gotoif($[\"${{DIALSTATUS}}\"=\"CANCEL\"]?{0})", new object[] { strDesc66 });
            lpInstruction.Add(set);

            valueNode   = FindNodeByResult("DONTCALL");
            nodeEntry   = Compiler.mapLink[valueNode];
            farActivity = FindActivityByEntry(nodeEntry);
            mapNodeValue["[%DONTCALL%]"] = farActivity;
            strDesc7        = farActivity.Description.Replace(' ', '_');
            strDesc77       = farActivity.Description.Replace(' ', '_') + System.Guid.NewGuid().ToString().Substring(0, 5);
            set             = new InstructionSet();
            set.ExtNumber   = strCurrentExt;
            set.Label       = strDesc.Replace(' ', '_');
            set.Instruction = string.Format("Gotoif($[\"${{DIALSTATUS}}\"=\"DONTCALL\"]?{0})", new object[] { strDesc77 });
            lpInstruction.Add(set);

            valueNode   = FindNodeByResult("TORTURE");
            nodeEntry   = Compiler.mapLink[valueNode];
            farActivity = FindActivityByEntry(nodeEntry);
            mapNodeValue["[%TORTURE%]"] = farActivity;
            strDesc8        = farActivity.Description.Replace(' ', '_');
            strDesc88       = farActivity.Description.Replace(' ', '_') + System.Guid.NewGuid().ToString().Substring(0, 5);
            set             = new InstructionSet();
            set.ExtNumber   = strCurrentExt;
            set.Label       = strDesc.Replace(' ', '_');
            set.Instruction = string.Format("Gotoif($[\"${{DIALSTATUS}}\"=\"TORTURE\"]?{0})", new object[] { strDesc88 });
            lpInstruction.Add(set);

            valueNode   = FindNodeByResult("CONGESTION");
            nodeEntry   = Compiler.mapLink[valueNode];
            farActivity = FindActivityByEntry(nodeEntry);
            mapNodeValue["[%CONGESTION%]"] = farActivity;
            strDesc9        = farActivity.Description.Replace(' ', '_');
            strDesc99       = farActivity.Description.Replace(' ', '_') + System.Guid.NewGuid().ToString().Substring(0, 5);
            set             = new InstructionSet();
            set.ExtNumber   = strCurrentExt;
            set.Label       = strDesc.Replace(' ', '_');
            set.Instruction = string.Format("Gotoif($[\"${{DIALSTATUS}}\"=\"CONGESTION\"]?{0})", new object[] { strDesc99 });
            lpInstruction.Add(set);



            set             = new InstructionSet();
            set.ExtNumber   = strCurrentExt;
            set.Label       = strDesc22;
            set.Instruction = string.Format("Goto({0})", new object[] { strDesc2 });
            lpInstruction.Add(set);

            set             = new InstructionSet();
            set.ExtNumber   = strCurrentExt;
            set.Label       = strDesc33;
            set.Instruction = string.Format("Goto({0})", new object[] { strDesc3 });
            lpInstruction.Add(set);

            set             = new InstructionSet();
            set.ExtNumber   = strCurrentExt;
            set.Label       = strDesc44;
            set.Instruction = string.Format("Goto({0})", new object[] { strDesc4 });
            lpInstruction.Add(set);

            set             = new InstructionSet();
            set.ExtNumber   = strCurrentExt;
            set.Label       = strDesc55;
            set.Instruction = string.Format("Goto({0})", new object[] { strDesc5 });
            lpInstruction.Add(set);

            set             = new InstructionSet();
            set.ExtNumber   = strCurrentExt;
            set.Label       = strDesc66;
            set.Instruction = string.Format("Goto({0})", new object[] { strDesc6 });
            lpInstruction.Add(set);

            set             = new InstructionSet();
            set.ExtNumber   = strCurrentExt;
            set.Label       = strDesc77;
            set.Instruction = string.Format("Goto({0})", new object[] { strDesc7 });
            lpInstruction.Add(set);

            set             = new InstructionSet();
            set.ExtNumber   = strCurrentExt;
            set.Label       = strDesc88;
            set.Instruction = string.Format("Goto({0})", new object[] { strDesc8 });
            lpInstruction.Add(set);

            set             = new InstructionSet();
            set.ExtNumber   = strCurrentExt;
            set.Label       = strDesc99;
            set.Instruction = string.Format("Goto({0})", new object[] { strDesc9 });
            lpInstruction.Add(set);



            priorityOffset = lpInstruction.Count - 1;

            ret = true;

            return(ret);
        }
Exemple #11
0
        public bool compile()
        {
            base.compile();

            bool      ret         = false;
            Node      valueNode   = FindFirstNode();
            Node      nodeEntry   = Compiler.mapLink[valueNode];
            IActivity farActivity = FindActivityByEntry(nodeEntry);

            mapNodeValue["[%DONE%]"] = farActivity;


            strCurrentExt = FindExtension(this);
            if (strCurrentExt.Trim().Length <= 0)
            {
                Compiler.PrintError("Disconnected link", "");
                return(false);
            }

            string strTime  = "*";
            string strDow   = "*";
            string strDom   = "*";
            string strMonth = "*";

            if (attribute.ContainsKey("timerange"))
            {
                strTime = attribute["timerange"];
                if (strTime.Trim().Length <= 0)
                {
                    Compiler.PrintError("Activity '" + strDesc + "' in '" + this.FindFlow(strDocID) + "' - variable " + strTime + " not be defined.", "");
                    return(ret);
                }
                else if (VariableExist(strTime, true))
                {
                    strTime = "${" + strTime + "}";
                }

                strDow = attribute["dow"];
                if (strDow.Trim().Length <= 0)
                {
                    Compiler.PrintError("Activity '" + strDesc + "' in '" + this.FindFlow(strDocID) + "' - variable " + strDow + " not be defined.", "");
                    return(ret);
                }
                else if (VariableExist(strDow, true))
                {
                    strDow = "${" + strDow + "}";
                }

                strDom = attribute["dom"];
                if (strDom.Trim().Length <= 0)
                {
                    Compiler.PrintError("Activity '" + strDesc + "' in '" + this.FindFlow(strDocID) + "' - variable " + strDom + " not be defined.", "");
                    return(ret);
                }
                else if (VariableExist(strDom, true))
                {
                    strDom = "${" + strDom + "}";
                }

                strMonth = attribute["month"];
                if (strMonth.Trim().Length <= 0)
                {
                    Compiler.PrintError("Activity '" + strDesc + "' in '" + this.FindFlow(strDocID) + "' - variable " + strMonth + " not be defined.", "");
                    return(ret);
                }
                else if (VariableExist(strMonth, true))
                {
                    strMonth = "${" + strMonth + "}";
                }
            }

            Node      valueNode1   = FindNodeByResult("Match");
            Node      nodeEntry1   = Compiler.mapLink[valueNode1];
            IActivity farActivity1 = FindActivityByEntry(nodeEntry1);

            mapNodeValue["[%Match%]"] = farActivity1;

            Node      valueNode2   = FindNodeByResult("Not Match");
            Node      nodeEntry2   = Compiler.mapLink[valueNode2];
            IActivity farActivity2 = FindActivityByEntry(nodeEntry2);

            mapNodeValue["[%NotMatch%]"] = farActivity2;

            string strDesc1 = farActivity1.Description.Replace(' ', '_');
            string strDesc2 = farActivity2.Description.Replace(' ', '_');

            //Goto label
            lpInstruction = new ArrayList();

            InstructionSet set = new InstructionSet();

            set.ExtNumber   = strCurrentExt;
            set.Label       = strDesc.Replace(' ', '_');
            set.Instruction = string.Format("GotoIfTime({0},{1},{2},{3}?{4})", new object[] { strTime, strDow, strDom, strMonth, "YXYXYX" });
            lpInstruction.Add(set);


            //Not match
            set             = new InstructionSet();
            set.ExtNumber   = strCurrentExt;
            set.Label       = "";
            set.Instruction = string.Format("Goto({0})", new object[] { strDesc2 });
            lpInstruction.Add(set);

            //Match (Priority = YXYXYX)
            set             = new InstructionSet();
            set.ExtNumber   = strCurrentExt;
            set.Label       = "";
            set.Instruction = string.Format("Goto({0})", new object[] { strDesc1 });
            lpInstruction.Add(set);

            priorityOffset = lpInstruction.Count - 1;

            ret = true;

            return(ret);
        }
        public bool compile()
        {
            base.compile();

            bool ret = false;

            lpInstruction = new ArrayList();
            string strMaxDigit = "";
            string strRetry    = "";
            string strSilent   = "";
            string strEntryMsg = "";
            string strOptions  = "";
            string strVariable = "";

            if (attribute.ContainsKey("maxdigit"))
            {
                strMaxDigit = attribute["maxdigit"];
            }
            if (attribute.ContainsKey("retry"))
            {
                strRetry = attribute["retry"];
            }
            if (attribute.ContainsKey("silent"))
            {
                strSilent = Convert.ToString(Convert.ToInt32(attribute["silent"]) * 1);
            }
            if (attribute.ContainsKey("variable"))
            {
                strVariable = attribute["variable"];

                if (!VariableExist(strVariable, true))
                {
                    Compiler.PrintError("Activity '" + strDesc + "' in '" + this.FindFlow(strDocID) + "' - variable " + strVariable + " not be defined.", "");
                    return(ret);
                }
                else
                {
                    strVariable = "${" + strVariable + "}";
                }
            }
            if (attribute.ContainsKey("options"))
            {
                strOptions = attribute["options"];
            }
            if (attribute.ContainsKey("entrymsg"))
            {
                strEntryMsg = attribute["entrymsg"];

                if (strEntryMsg.Trim().Length <= 0)
                {
                    Compiler.PrintError("Activity '" + strDesc + "' in '" + this.FindFlow(strDocID) + "' - variable " + strEntryMsg + " not be defined.", "");
                    return(ret);
                }
                else if (!VariableExist(strEntryMsg, true))
                {
                    //none
                }
                else
                {
                    strEntryMsg = "${" + strEntryMsg + "}";
                }
            }
            strCurrentExt = FindExtension(this);
            if (strCurrentExt.Trim().Length <= 0)
            {
                Compiler.PrintError("Disconnected link", "");
                return(false);
            }

            InstructionSet set = new InstructionSet();

            set.ExtNumber   = strCurrentExt;
            set.Label       = strDesc.Replace(' ', '_');
            set.Instruction = string.Format("read({0},{1},{2},{3},{4},{5})",
                                            new object[] { strVariable, strEntryMsg, strMaxDigit, strOptions, strRetry, strSilent });
            lpInstruction.Add(set);

            Node      valueNode   = FindNodeByResult("Done");
            Node      nodeEntry   = Compiler.mapLink[valueNode];
            IActivity farActivity = FindActivityByEntry(nodeEntry);

            mapNodeValue["[%DONE%]"] = farActivity;

            priorityOffset = lpInstruction.Count - 1;

            ret = true;

            return(ret);
        }
Exemple #13
0
        public bool compile()
        {
            base.compile();

            bool   ret         = false;
            string strSilent   = "";
            string strDuration = "";
            string strFile     = "";
            string strFormat   = "";
            string strOptions  = "";


            strCurrentExt = FindExtension(this);
            if (strCurrentExt.Trim().Length <= 0)
            {
                Compiler.PrintError("Disconnected link", "");
                return(false);
            }

            Node      valueNode   = FindNodeByResult("Done");
            Node      nodeEntry   = Compiler.mapLink[valueNode];
            IActivity farActivity = FindActivityByEntry(nodeEntry);

            mapNodeValue["[%DONE%]"] = farActivity;

            if (attribute.ContainsKey("silent"))
            {
                strSilent = attribute["silent"];
            }
            if (attribute.ContainsKey("duration"))
            {
                strDuration = attribute["duration"];
            }
            if (attribute.ContainsKey("filename"))
            {
                strFile = attribute["filename"];

                if (strFile.Trim().Length <= 0)
                {
                    Compiler.PrintError("Activity '" + strDesc + "' in '" + this.FindFlow(strDocID) + "' - variable " + strFile + " not be defined.", "");
                    return(ret);
                }
                else if (VariableExist(strFile, true))
                {
                    strFile = "${" + strFile + "}";
                }
            }
            if (attribute.ContainsKey("format"))
            {
                strFormat = attribute["format"];
            }
            if (attribute.ContainsKey("options"))
            {
                strOptions = attribute["options"];
            }

            lpInstruction = new ArrayList();

            InstructionSet set = new InstructionSet();

            set.ExtNumber   = strCurrentExt;
            set.Label       = strDesc.Replace(' ', '_');
            set.Instruction = string.Format("Record({0}.{1},{2},{3},{4}) ",
                                            new object[] { strFile, strFormat, strSilent, strDuration, strOptions });
            lpInstruction.Add(set);


            priorityOffset = lpInstruction.Count - 1;

            ret = true;

            return(ret);
        }
Exemple #14
0
        public bool sequence(int overall)
        {
            bool ret             = false;
            int  overallPriority = overall;


            if (resultNode.Count > 0)
            {
                Dictionary <string, Node> .Enumerator lpThisNodes = resultNode.GetEnumerator();

                while (lpThisNodes.MoveNext())
                {
                    if (this.ActivityName.ToLower() == "start")
                    {
                        overallPriority = 1;
                    }

                    KeyValuePair <string, Node> itemNode = lpThisNodes.Current;
                    Node      thisResultNode             = itemNode.Value;
                    Node      nextEntryNode = Compiler.mapLink[thisResultNode];
                    IActivity nextActivity  = FindActivityByEntry(nextEntryNode);

                    Debug.WriteLine("Enter Activity : " + this.ActivityID + " - " + this.Description + " - StartPriority = " + Convert.ToString(this.StartPriority) + " EndPriority = " + Convert.ToString(this.EndPriority) + " Overall = " + Convert.ToString(overallPriority));

                    if (this.ActivityName.ToLower() == "changeext")
                    {
                    }
                    else if (nextActivity.StartPriority <= 0)
                    {
                        nextActivity.StartPriority = overallPriority + this.InstructionCount;
                        overallPriority           += this.InstructionCount;
                        Debug.WriteLine("Next Activity (<0) : " + nextActivity.ActivityID + " - " + nextActivity.Description + " - StartPriority = " + Convert.ToString(nextActivity.StartPriority) + " EndPriority = " + Convert.ToString(nextActivity.EndPriority));
                        nextActivity.sequence(overallPriority);
                        nextActivity.adjustSequence();
                    }
                    else
                    {
                        Debug.WriteLine("Loopback Activity : " + this.ActivityID + " - " + this.Description + " - StartPriority = " + Convert.ToString(this.StartPriority) + " EndPriority = " + Convert.ToString(this.EndPriority));

                        if (this.StartPriority > nextActivity.StartPriority)
                        {
                            if (CanJumpNear())
                            {
                                InstructionSet set = new InstructionSet();
                                set.ExtNumber   = strCurrentExt;
                                set.Label       = "";
                                set.Instruction = string.Format("Goto({0})", new object[] { nextActivity.StartPriority });
                                lpInstruction.Add(set);
                                int _tmpS = this.StartPriority;
                                this.StartPriority = _tmpS;
                                overallPriority++;
                            }
                        }


                        Debug.WriteLine("Next Activity : " + nextActivity.ActivityID + " - " + nextActivity.Description + " - StartPriority = " + Convert.ToString(nextActivity.StartPriority) + " EndPriority = " + Convert.ToString(nextActivity.EndPriority));
                    }
                    ret = true;
                }
            }
            else
            {
                ret = true;
            }

            return(ret);
        }
        public bool compile()
        {
            base.compile();

            string strVal     = "";
            string strFile    = "";
            string strExt     = "";
            string strOptions = "";
            string strCmd     = "";
            string strOthers  = "";

            bool ret = false;

            if (attribute.ContainsKey("filename"))
            {
                strFile = attribute["filename"];

                if (strFile.Trim().Length > 0)
                {
                    if (VariableExist(strFile, true))
                    {
                        strFile = "${" + strFile + "}";
                    }
                }
                else
                {
                    Compiler.PrintError("Activity '" + strDesc + "' in '" + this.FindFlow(strDocID) + "' - filename not be defined.", "");
                    return(ret);
                }
            }
            else
            {
                Compiler.PrintError("Activity '" + strDesc + "' in '" + this.FindFlow(strDocID) + "' - filename not be defined.", "");
                return(ret);
            }

            if (attribute.ContainsKey("ext"))
            {
                strExt = attribute["ext"];

                if (strExt.Trim().Length > 0)
                {
                    if (VariableExist(strExt, true))
                    {
                        strExt = "${" + strExt + "}";
                    }
                }
                else
                {
                    Compiler.PrintError("Activity '" + strDesc + "' in '" + this.FindFlow(strDocID) + "' - file extension not be defined.", "");
                    return(ret);
                }
            }
            else
            {
                Compiler.PrintError("Activity '" + strDesc + "' in '" + this.FindFlow(strDocID) + "' - file extension not be defined.", "");
                return(ret);
            }

            if (attribute.ContainsKey("bridge"))
            {
                strVal = attribute["bridge"];

                if (strVal.Trim().Length > 0)
                {
                    if (strVal == "1")
                    {
                        strOptions += "b";
                    }
                }
            }

            if (attribute.ContainsKey("append"))
            {
                strVal = attribute["append"];

                if (strVal.Trim().Length > 0)
                {
                    if (strVal == "1")
                    {
                        strOptions += "a";
                    }
                }
            }

            if (attribute.ContainsKey("spokevolume"))
            {
                strVal = attribute["spokevolume"];

                if (this.IsNumber(strVal))
                {
                    strOptions += "V(" + strVal + ")";
                }
            }

            if (attribute.ContainsKey("heardvolume"))
            {
                strVal = attribute["heardvolume"];

                if (this.IsNumber(strVal))
                {
                    strOptions += "v(" + strVal + ")";
                }
            }

            if (attribute.ContainsKey("overallvolume"))
            {
                strVal = attribute["overallvolume"];

                if (this.IsNumber(strVal))
                {
                    strOptions += "W(" + strVal + ")";
                }
            }

            if (attribute.ContainsKey("cmd"))
            {
                strCmd = attribute["cmd"];
            }


            Node      valueNode   = FindNodeByResult("Done");
            Node      nodeEntry   = Compiler.mapLink[valueNode];
            IActivity farActivity = FindActivityByEntry(nodeEntry);

            mapNodeValue["[%DONE%]"] = farActivity;

            strCurrentExt = FindExtension(this);
            if (strCurrentExt.Trim().Length <= 0)
            {
                Compiler.PrintError("Disconnected link", "");
                return(false);
            }


            if (strCmd.Trim().Length > 0 && strOptions.Trim().Length > 0)
            {
                strOthers = "," + strOptions + "," + strCmd;
            }
            else if (strCmd.Trim().Length <= 0 && strOptions.Trim().Length > 0)
            {
                strOthers = "," + strOptions;
            }
            else if (strCmd.Trim().Length > 0 && strOptions.Trim().Length <= 0)
            {
                strOthers = ",," + strCmd;
            }


            lpInstruction = new ArrayList();
            InstructionSet set = new InstructionSet();

            set.ExtNumber   = strCurrentExt;
            set.Label       = strDesc.Replace(' ', '_');
            set.Instruction = string.Format("MixMonitor({0}.{1}{2}) ", new object[] { strFile, strExt, strOthers });
            lpInstruction.Add(set);

            priorityOffset = lpInstruction.Count - 1;

            ret = true;

            return(ret);
        }
        public bool compile()
        {
            base.compile();
            string strVal    = "";
            string strResult = "";
            string strOffset = "";
            string strLength = "";

            bool ret = false;

            if (attribute.ContainsKey("result"))
            {
                strResult = attribute["result"];

                if (strResult.Trim().Length <= 0)
                {
                    Compiler.PrintError("Activity '" + strDesc + "' in '" + this.FindFlow(strDocID) + "' - variable " + strResult + " not be defined.", "");
                    return(ret);
                }
                else if (!VariableExist(strResult, true))
                {
                    Compiler.PrintError("Activity '" + strDesc + "' in '" + this.FindFlow(strDocID) + "' - variable " + strResult + " not be defined.", "");
                    return(ret);
                }
            }

            if (attribute.ContainsKey("var"))
            {
                strVal    = attribute["var"];
                strOffset = attribute["offset"];

                try
                {
                    int i = Convert.ToInt32(attribute["length"]);
                    if (i == 0)
                    {
                        strLength = attribute["length"];
                    }
                }
                catch (Exception ex)
                {
                }

                if (!VariableExist(strVal, false))
                {
                    Compiler.PrintError("Activity '" + strDesc + "' in '" + this.FindFlow(strDocID) + "' - variable " + strVal + " not be defined.", "");
                    return(ret);
                }

                if (strLength.Length > 0)
                {
                    strVal = "${" + strVal + ":" + strOffset + ":" + strLength + "}";
                }
                else
                {
                    strVal = "${" + strVal + ":" + strOffset + "}";
                }
            }


            Node      valueNode   = FindNodeByResult("Done");
            Node      nodeEntry   = Compiler.mapLink[valueNode];
            IActivity farActivity = FindActivityByEntry(nodeEntry);

            mapNodeValue["[%DONE%]"] = farActivity;

            strCurrentExt = FindExtension(this);
            if (strCurrentExt.Trim().Length <= 0)
            {
                Compiler.PrintError("Disconnected link", "");
                return(false);
            }

            lpInstruction = new ArrayList();
            InstructionSet set = new InstructionSet();

            set.ExtNumber   = strCurrentExt;
            set.Label       = strDesc.Replace(' ', '_');
            set.Instruction = string.Format("Set({0}={1}) ", new object[] { strResult, strVal });
            lpInstruction.Add(set);

            priorityOffset = lpInstruction.Count - 1;

            ret = true;

            return(ret);
        }
Exemple #17
0
        public bool compile()
        {
            base.compile();

            string strVal     = "";
            string strMailBox = "";
            string strOptions = "";

            bool ret = false;

            if (attribute.ContainsKey("mailbox"))
            {
                strMailBox = attribute["mailbox"];

                if (strMailBox.Trim().Length > 0)
                {
                    if (VariableExist(strMailBox, true))
                    {
                        strMailBox = "${" + strMailBox + "}";
                    }
                }
                else
                {
                    Compiler.PrintError("Activity '" + strDesc + "' in '" + this.FindFlow(strDocID) + "' - mailbox not be defined.", "");
                    return(ret);
                }
            }
            else
            {
                Compiler.PrintError("Activity '" + strDesc + "' in '" + this.FindFlow(strDocID) + "' - mailbox not be defined.", "");
                return(ret);
            }



            if (attribute.ContainsKey("option"))
            {
                strOptions = attribute["option"];
            }


            Node      valueNode   = FindNodeByResult("Done");
            Node      nodeEntry   = Compiler.mapLink[valueNode];
            IActivity farActivity = FindActivityByEntry(nodeEntry);

            mapNodeValue["[%DONE%]"] = farActivity;

            strCurrentExt = FindExtension(this);
            if (strCurrentExt.Trim().Length <= 0)
            {
                Compiler.PrintError("Disconnected link", "");
                return(false);
            }

            if (strOptions.Trim().Length > 0)
            {
                strMailBox += "," + strOptions;
            }

            lpInstruction = new ArrayList();
            InstructionSet set = new InstructionSet();

            set.ExtNumber   = strCurrentExt;
            set.Label       = strDesc.Replace(' ', '_');
            set.Instruction = string.Format("VoiceMailMain({0}) ", new object[] { strMailBox });
            lpInstruction.Add(set);

            priorityOffset = lpInstruction.Count - 1;

            ret = true;

            return(ret);
        }
        public bool compile()
        {
            base.compile();

            bool   ret     = false;
            string strVal  = "";
            string strType = "";


            strCurrentExt = FindExtension(this);
            if (strCurrentExt.Trim().Length <= 0)
            {
                Compiler.PrintError("Disconnected link", "");
                return(false);
            }

            if (attribute.ContainsKey("variable"))
            {
                strVal = attribute["variable"];

                if (strVal.Trim().Length <= 0)
                {
                    Compiler.PrintError("Activity '" + strDesc + "' in '" + this.FindFlow(strDocID) + "' - variable " + strVal + " not be defined.", "");
                    return(ret);
                }
                else if (VariableExist(strVal, true))
                {
                    strVal = "${" + strVal + "}";
                }
            }
            if (attribute.ContainsKey("type"))
            {
                strType = attribute["type"];
            }

            Node      valueNode   = FindNodeByResult("Done");
            Node      nodeEntry   = Compiler.mapLink[valueNode];
            IActivity farActivity = FindActivityByEntry(nodeEntry);

            mapNodeValue["[%DONE%]"] = farActivity;


            lpInstruction = new ArrayList();
            if (strType.ToUpper() == "Digits".ToUpper())
            {
                InstructionSet set = new InstructionSet();
                set.ExtNumber   = strCurrentExt;
                set.Label       = strDesc.Replace(' ', '_');
                set.Instruction = string.Format("SayDigits({0}) ", new object[] { strVal });
                lpInstruction.Add(set);
            }
            else if (strType.ToUpper() == "Alpha".ToUpper())
            {
                InstructionSet set = new InstructionSet();
                set.ExtNumber   = strCurrentExt;
                set.Label       = strDesc.Replace(' ', '_');
                set.Instruction = string.Format("SayAlpha({0}) ", new object[] { strVal });
                lpInstruction.Add(set);
            }
            else if (strType.ToUpper() == "Number".ToUpper())
            {
                InstructionSet set = new InstructionSet();
                set.ExtNumber   = strCurrentExt;
                set.Label       = strDesc.Replace(' ', '_');
                set.Instruction = string.Format("SayNumber({0}) ", new object[] { strVal });
                lpInstruction.Add(set);
            }
            else if (strType.ToUpper() == "Phonetic".ToUpper())
            {
                InstructionSet set = new InstructionSet();
                set.ExtNumber   = strCurrentExt;
                set.Label       = strDesc.Replace(' ', '_');
                set.Instruction = string.Format("SayPhonetic({0}) ", new object[] { strVal });
                lpInstruction.Add(set);
            }
            else
            {
                InstructionSet set = new InstructionSet();
                set.ExtNumber   = strCurrentExt;
                set.Label       = strDesc.Replace(' ', '_');
                set.Instruction = string.Format("SayDigits({0}) ", new object[] { strVal });
                lpInstruction.Add(set);
            }

            priorityOffset = lpInstruction.Count - 1;

            ret = true;

            return(ret);
        }
        public bool compile()
        {
            base.compile();

            string strVal1 = "";
            string strVal2 = "";
            string strOp   = "";
            bool   ret     = false;

            if (attribute.ContainsKey("variable1"))
            {
                strVal1 = attribute["variable1"];

                if (IsNumber(strVal1))
                {
                    //none
                }
                else if (strVal1.Trim().Length <= 0)
                {
                    Compiler.PrintError("Activity '" + strDesc + "' in '" + this.FindFlow(strDocID) + "' - variable " + strVal1 + " not be defined.", "");
                    return(ret);
                }
                else if (!VariableExist(strVal1, true))
                {
                    //none
                }
                else
                {
                    strVal1 = "${" + strVal1 + "}";
                }
            }
            if (attribute.ContainsKey("variable2"))
            {
                strVal2 = attribute["variable2"];
                if (IsNumber(strVal2))
                {
                    //none
                }
                else if (strVal2.Trim().Length <= 0)
                {
                    Compiler.PrintError("Activity '" + strDesc + "' in '" + this.FindFlow(strDocID) + "' - variable " + strVal2 + " not be defined.", "");
                    return(ret);
                }
                else if (!VariableExist(strVal2, true))
                {
                    //none
                }
                else
                {
                    strVal2 = "${" + strVal2 + "}";
                }
            }
            if (attribute.ContainsKey("operator"))
            {
                strOp = attribute["operator"];
            }

            strCurrentExt = FindExtension(this);
            if (strCurrentExt.Trim().Length <= 0)
            {
                Compiler.PrintError("Disconnected link", "");
                return(false);
            }

            Node      valueNode1   = FindNodeByResult("Yes");
            Node      nodeEntry1   = Compiler.mapLink[valueNode1];
            IActivity farActivity1 = FindActivityByEntry(nodeEntry1);

            mapNodeValue["[%YES%]"] = farActivity1;

            Node      valueNode2   = FindNodeByResult("No");
            Node      nodeEntry2   = Compiler.mapLink[valueNode2];
            IActivity farActivity2 = FindActivityByEntry(nodeEntry2);

            mapNodeValue["[%NO%]"] = farActivity2;


            string strDesc1  = farActivity1.Description.Replace(' ', '_');
            string strDesc11 = farActivity1.Description.Replace(' ', '_') + System.Guid.NewGuid().ToString().Substring(0, 5);

            string strDesc2  = farActivity2.Description.Replace(' ', '_');
            string strDesc22 = farActivity2.Description.Replace(' ', '_') + System.Guid.NewGuid().ToString().Substring(0, 5);

            lpInstruction = new ArrayList();
            InstructionSet set = new InstructionSet();

            set.ExtNumber   = strCurrentExt;
            set.Label       = strDesc.Replace(' ', '_');
            set.Instruction = string.Format("Gotoif($[\"{0}\" {1} \"{2}\"]?{3}:{4})", new object[] { strVal1, strOp, strVal2, strDesc11, strDesc22 });
            lpInstruction.Add(set);

            set             = new InstructionSet();
            set.ExtNumber   = strCurrentExt;
            set.Label       = strDesc11;
            set.Instruction = string.Format("Goto({0})", new object[] { strDesc1 });
            lpInstruction.Add(set);

            set             = new InstructionSet();
            set.ExtNumber   = strCurrentExt;
            set.Label       = strDesc22;
            set.Instruction = string.Format("Goto({0})", new object[] { strDesc2 });
            lpInstruction.Add(set);


            priorityOffset = lpInstruction.Count - 1;

            ret = true;

            return(ret);
        }
Exemple #20
0
        public bool compile()
        {
            bool ret = false;

            base.compile();

            lpInstruction = new ArrayList();
            string strInstruct = "";
            string strMsg      = "";
            string strDTMF     = "";

            strCurrentExt = FindExtension(this);
            if (strCurrentExt.Trim().Length <= 0)
            {
                Compiler.PrintError("Disconnected link", "");
                return(false);
            }

            if (attribute.ContainsKey("msgs"))
            {
                strMsg = attribute["msgs"];

                if (strMsg.Trim().Length <= 0)
                {
                    Compiler.PrintError("Activity '" + strDesc + "' in '" + this.FindFlow(strDocID) + "' - variable " + strMsg + " not be defined.", "");
                    return(ret);
                }
                else if (!VariableExist(strMsg, true))
                {
                    //none
                }
                else
                {
                    strMsg = "${" + strMsg + "}";
                }
            }
            if (attribute.ContainsKey("dtmf"))
            {
                strDTMF = attribute["dtmf"];
            }

            if (strDTMF == "0")
            {
                InstructionSet set = new InstructionSet();
                set.ExtNumber   = strCurrentExt;
                set.Label       = strDesc.Replace(' ', '_');
                set.Instruction = string.Format("Playback({0})", new object[] { strMsg });
                lpInstruction.Add(set);

                Node      valueNode    = FindNodeByResult("DONE");
                Node      nodeEntry    = Compiler.mapLink[valueNode];
                IActivity farActivity1 = FindActivityByEntry(nodeEntry);
                mapNodeValue["[%DONE%]"] = farActivity1;

                set             = new InstructionSet();
                set.ExtNumber   = strCurrentExt;
                set.Label       = strDesc.Replace(' ', '_');
                set.Instruction = string.Format("Goto({0})", new object[] { farActivity1.Description.Replace(' ', '_') });
                lpInstruction.Add(set);

                priorityOffset = lpInstruction.Count - 1;

                ret = true;
            }
            else
            {
                Node      valueNode    = FindNodeByResult("DONE");
                Node      nodeEntry    = Compiler.mapLink[valueNode];
                IActivity farActivity1 = FindActivityByEntry(nodeEntry);
                mapNodeValue["[%DONE%]"] = farActivity1;

                valueNode = FindNodeByResult("DTMF");
                nodeEntry = Compiler.mapLink[valueNode];
                IActivity farActivity2 = FindActivityByEntry(nodeEntry);
                mapNodeValue["[%DTMF%]"] = farActivity2;

                InstructionSet set = new InstructionSet();
                set.ExtNumber   = strCurrentExt;
                set.Label       = strDesc.Replace(' ', '_');
                set.Instruction = string.Format("Read(digitto,{0},1,,0,1)", new object[] { strMsg });
                lpInstruction.Add(set);

                string strDesc1  = farActivity1.Description.Replace(' ', '_');
                string strDesc2  = farActivity2.Description.Replace(' ', '_');
                string strDesc11 = farActivity1.Description.Replace(' ', '_') + System.Guid.NewGuid().ToString().Substring(0, 5);
                string strDesc22 = farActivity2.Description.Replace(' ', '_') + System.Guid.NewGuid().ToString().Substring(0, 5);

                set             = new InstructionSet();
                set.ExtNumber   = strCurrentExt;
                set.Label       = strDesc.Replace(' ', '_');
                set.Instruction = string.Format("Gotoif($[ \"${{LEN(${{digitto}})}}\" > \"0\"]?{0}:{1})", new object[] { strDesc11, strDesc22 });
                lpInstruction.Add(set);

                set             = new InstructionSet();
                set.ExtNumber   = strCurrentExt;
                set.Label       = strDesc11;
                set.Instruction = string.Format("Goto({0})", new object[] { strDesc1 });
                lpInstruction.Add(set);

                set             = new InstructionSet();
                set.ExtNumber   = strCurrentExt;
                set.Label       = strDesc22;
                set.Instruction = string.Format("Goto({0})", new object[] { strDesc2 });
                lpInstruction.Add(set);

                priorityOffset = lpInstruction.Count - 1;

                ret = true;
            }

            return(ret);
        }
        public bool compile()
        {
            base.compile();

            bool      ret         = false;
            Node      valueNode   = this.PrimaryNode;
            Node      nodeEntry   = Compiler.mapLink[valueNode];
            IActivity farActivity = FindActivityByEntry(nodeEntry); //Sub-proc entry activity

            mapNodeValue["[%DONE%]"] = farActivity;


            strCurrentExt = FindExtension(this);
            if (strCurrentExt.Trim().Length <= 0)
            {
                Compiler.PrintError("Disconnected link", "");
                return(false);
            }

            string strVal = "";

            if (attribute.ContainsKey("arguments"))
            {
                strVal = attribute["arguments"];
            }

            if (Compiler.mapPage.ContainsKey(farActivity.DocID))
            {
                Page page = Compiler.mapPage[farActivity.DocID];

                //Goto label
                lpInstruction = new ArrayList();
                string strInstruct = "";

                if (strVal.Trim().Length > 0)
                {
                    strInstruct = string.Format("Gosub({0},{1},1({2}))",
                                                new object[] { page.FlowName.Replace(' ', '_'), strCurrentExt, strVal });
                }
                else
                {
                    strInstruct = string.Format("Gosub({0},{1},1)",
                                                new object[] { page.FlowName.Replace(' ', '_'), strCurrentExt });
                }

                InstructionSet set = new InstructionSet();
                set.ExtNumber   = strCurrentExt;
                set.Label       = strDesc.Replace(' ', '_');
                set.Instruction = strInstruct;
                lpInstruction.Add(set);

                //Result nodes
                if (resultNode.Count < 0)
                {
                    Compiler.PrintError("Activity '" + strDesc + "' result node not be defined.", "");
                    return(ret);
                }
                else
                {
                    Dictionary <string, Node> .Enumerator lpNode = resultNode.GetEnumerator();
                    while (lpNode.MoveNext())
                    {
                        KeyValuePair <string, Node> item = lpNode.Current;
                        if (item.Value.NodeID != this.PrimaryNode.NodeID)
                        {
                            string    strItem      = item.Value.Value;
                            Node      valueNode2   = item.Value;
                            Node      nodeEntry2   = Compiler.mapLink[valueNode2];
                            IActivity farActivity2 = FindActivityByEntry(nodeEntry2);

                            mapNodeValue["[%" + strItem.Trim() + "%]"] = farActivity2;

                            strInstruct = string.Format("Gotoif($[\"${{RETVAL}}\"=\"{0}\"]?{1})", new object[] { strItem.Trim(), farActivity2.Description.Replace(' ', '_') });

                            set             = new InstructionSet();
                            set.ExtNumber   = strCurrentExt;
                            set.Label       = "";
                            set.Instruction = strInstruct;
                            lpInstruction.Add(set);
                        }
                    }

                    priorityOffset = lpInstruction.Count - 1;

                    ret = true;
                }
            }

            return(ret);
        }
        public bool compile()
        {
            base.compile();

            bool ret = false;

            lpInstruction = new ArrayList();
            string    strMaxDigit           = "";
            string    strRetry              = "";
            string    strSilent             = "";
            string    strEntryMsg           = "";
            string    strInvalidMsg         = "";
            string    strNoInputMsg         = "";
            ArrayList strResult             = null;
            string    strGlobalTimeout      = "";
            string    strGlobalInvalidInput = "";

            Node nodeGlobalTimeout = Compiler.mapNode[attribute["globaltimeout"]];
            Node nodeGlobalInvalid = Compiler.mapNode[attribute["globalinvalid"]];

            if (nodeGlobalTimeout != null)
            {
                if (Compiler.mapPage.ContainsKey(nodeGlobalTimeout.DocID))
                {
                    Page page = Compiler.mapPage[nodeGlobalTimeout.DocID];
                    strGlobalTimeout = page.FlowName.Replace(' ', '_');
                }
                else
                {
                    Compiler.PrintWarn("GlobalTimeout subflow for GetDigits " + strDesc + " not be defined.", "");
                }
            }

            if (nodeGlobalInvalid != null)
            {
                if (Compiler.mapPage.ContainsKey(nodeGlobalInvalid.DocID))
                {
                    Page page = Compiler.mapPage[nodeGlobalInvalid.DocID];
                    strGlobalInvalidInput = page.FlowName.Replace(' ', '_');
                }
                else
                {
                    Compiler.PrintWarn("GlobalInvalid subflow for GetDigits " + strDesc + " not be defined.", "");
                }
            }


            if (attribute.ContainsKey("maxdigit"))
            {
                strMaxDigit = attribute["maxdigit"];
            }
            if (attribute.ContainsKey("retry"))
            {
                strRetry = attribute["retry"];
            }
            if (attribute.ContainsKey("silent"))
            {
                strSilent = Convert.ToString(Convert.ToInt32(attribute["silent"]) * 1000);
            }
            if (attribute.ContainsKey("invalidmsg"))
            {
                strInvalidMsg = attribute["invalidmsg"];

                if (IsNumber(strInvalidMsg))
                {
                    //none
                }
                else if (!VariableExist(strInvalidMsg, true))
                {
                    //none
                }
                else
                {
                    strInvalidMsg = "${" + strInvalidMsg + "}";
                }
            }
            if (attribute.ContainsKey("noinputmsg"))
            {
                strNoInputMsg = attribute["noinputmsg"];
                if (IsNumber(strNoInputMsg))
                {
                    //none
                }
                else if (!VariableExist(strNoInputMsg, true))
                {
                    //none
                }
                else
                {
                    strNoInputMsg = "${" + strNoInputMsg + "}";
                }
            }
            if (attribute.ContainsKey("entrymsg"))
            {
                strEntryMsg = attribute["entrymsg"];

                if (strEntryMsg.Trim().Length <= 0)
                {
                    Compiler.PrintError("Activity '" + strDesc + "' in '" + this.FindFlow(strDocID) + "' - variable " + strEntryMsg + " not be defined.", "");
                    return(ret);
                }
                else if (!VariableExist(strEntryMsg, true))
                {
                    //none
                }
                else
                {
                    strEntryMsg = "${" + strEntryMsg + "}";
                }
            }
            strCurrentExt = FindExtension(this);
            if (strCurrentExt.Trim().Length <= 0)
            {
                Compiler.PrintError("Disconnected link", "");
                return(false);
            }

            strResult = ConcatResult();

            InstructionSet set = new InstructionSet();

            set.ExtNumber   = strCurrentExt;
            set.Label       = strDesc.Replace(' ', '_');
            set.Instruction = string.Format("AGI(\"getdigits2.php\",\"{0}\",\"{1}\",\"{2}\",\"{3}\",\"{4}\",\"{5}\",\"{6}\",\"{7}\",\"{8}\",\"{9}\")",
                                            new object[] { strEntryMsg, strSilent, strMaxDigit, "0", strResult, strRetry, strNoInputMsg, strInvalidMsg, strGlobalTimeout, strGlobalInvalidInput });
            lpInstruction.Add(set);



            foreach (string strItem in strResult)
            {
                Node      valueNode   = FindNodeByResult(strItem);
                Node      nodeEntry   = Compiler.mapLink[valueNode];
                IActivity farActivity = FindActivityByEntry(nodeEntry);

                mapNodeValue["[%" + strItem.Trim() + "%]"] = farActivity;

                set             = new InstructionSet();
                set.ExtNumber   = strCurrentExt;
                set.Label       = "";
                set.Instruction = string.Format("Gotoif($[\"${{keys}}\"=\"{0}\"]?{1})", new object[] { strItem.Trim(), farActivity.Description.Replace(' ', '_') });
                lpInstruction.Add(set);
            }

            priorityOffset = lpInstruction.Count - 1;

            ret = true;
            return(ret);
        }