Exemplo n.º 1
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;
            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();

            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);
        }