コード例 #1
0
        public Rule_CompareExp(Rule_Context pContext, NonterminalToken pToken)
            : base(pContext)
        {
            // <Concat Exp> LIKE String
            // <Concat Exp> '=' <Compare Exp>
            // <Concat Exp> '<>' <Compare Exp>
            // <Concat Exp> '>' <Compare Exp>
            // <Concat Exp> '>=' <Compare Exp>
            // <Concat Exp> '<' <Compare Exp>
            // <Concat Exp> '<=' <Compare Exp>
            // <Concat Exp>

            this.ConcatExp = EnterRule.BuildStatments(pContext, pToken.Tokens[0]);
            if (pToken.Tokens.Length > 1)
            {
                op = pToken.Tokens[1].ToString();

                if (pToken.Tokens[1].ToString().Equals("LIKE", StringComparison.OrdinalIgnoreCase))
                {
                    this.STRING = pToken.Tokens[2].ToString().Trim(new char[] { '"' });
                }
                else
                {
                    this.CompareExp = EnterRule.BuildStatments(pContext, pToken.Tokens[2]);
                }
            }
        }
コード例 #2
0
 public Rule_CheckCodeBlock(Rule_Context pContext, NonterminalToken pToken)
     : base(pContext)
 {
     /* <CheckCodeBlock> ::=   <DefineVariables_Statement>
                         | <View_Checkcode_Statement>
                         | <Record_Checkcode_Statement>
             | <Page_Checkcode_Statement>
             | <Field_Checkcode_Statement>
             | <Subroutine_Statement>  */
     switch (pToken.Rule.Rhs[0].ToString())
     {
         case "<DefineVariables_Statement>":
             this.CheckCodeBlock = EnterRule.BuildStatments(pContext, pToken.Tokens[0]);
             break;
         case "<View_Checkcode_Statement>":
             this.CheckCodeBlock = EnterRule.BuildStatments(pContext, pToken.Tokens[0]);
             break;
         case "<Record_Checkcode_Statement>":
             this.CheckCodeBlock = EnterRule.BuildStatments(pContext, pToken.Tokens[0]);
             break;
         case "<Page_Checkcode_Statement>":
             this.CheckCodeBlock = EnterRule.BuildStatments(pContext, pToken.Tokens[0]);
             break;
         case "<Field_Checkcode_Statement>":
             this.CheckCodeBlock = EnterRule.BuildStatments(pContext, pToken.Tokens[0]);
             break;
         case "<Subroutine_Statement>":
             this.CheckCodeBlock = EnterRule.BuildStatments(pContext, pToken.Tokens[0]);
             break;
     }
 }
コード例 #3
0
        public Rule_If_Then_Else_End(Rule_Context pContext, NonterminalToken pToken)
            : base(pContext)
        {
            /*

            <If_Statement>                  ::=   IF <Expression> THEN  <Statements>  END-IF
                                                | IF <Expression> THEN  <Statements>  END
            <If_Else_Statement>              ::=  IF <Expression> THEN  <Statements> <Else_If_Statement>  END-IF
                                                | IF <Expression> THEN  <Statements>  <Else_If_Statement>  END
                                                    IF <Expression> THEN <Statements> ELSE  <Statements>  END-IF
                                                | IF <Expression> THEN <Statements> ELSE  <Statements>  END
             */

            IfClause = EnterRule.BuildStatments(pContext, pToken.Tokens[1]);
            ThenClause = EnterRule.BuildStatments(pContext, pToken.Tokens[3]);
            if (this.GetCommandElement(pToken.Tokens, 4).Equals("Else", StringComparison.OrdinalIgnoreCase))
            {
                ElseClause = EnterRule.BuildStatments(pContext, pToken.Tokens[5]);
            }
                /*
            else
            {
                ElseClause = EnterRule.BuildStatments(pContext, pToken.Tokens[4]);
            }*/
        }
コード例 #4
0
ファイル: Rule_Program.cs プロジェクト: NALSS/epiinfo-82474
 public Rule_Program(Rule_Context pContext, NonterminalToken pToken)
     : base(pContext)
 {
     //<Program> ::= <CheckCodeBlocks> | !Eof
     if (pToken.Tokens.Length > 0)
     {
         CheckCodeBlocks = EnterRule.BuildStatments(pContext, pToken.Tokens[0]);
     }
 }
コード例 #5
0
 public Rule_Begin_Before_Statement(Rule_Context pContext, NonterminalToken pToken)
     : base(pContext)
 {
     //<Begin_Before_statement> ::= Begin-Before <Statements> End | Begin-Before End |!Null
     if (pToken.Tokens.Length > 2)
     {
         //NonterminalToken T = (NonterminalToken)pToken.Tokens[1];
         //this.Statements = new Rule_Statements(pContext, T);
         this.Statements = EnterRule.BuildStatments(pContext, pToken.Tokens[1]);
     }
 }
コード例 #6
0
ファイル: Rule_PowExp.cs プロジェクト: NALSS/epiinfo-82474
        public Rule_PowExp(Rule_Context pContext, NonterminalToken pToken)
            : base(pContext)
        {
            /* 	::= <Negate Exp> '^' <Negate Exp>  | <Negate Exp> */

            this.NegateExp1 = EnterRule.BuildStatments(pContext, pToken.Tokens[0]);
            if (pToken.Tokens.Length > 1)
            {
                this.NegateExp2 = EnterRule.BuildStatments(pContext, pToken.Tokens[2]);
            }
        }
コード例 #7
0
ファイル: Rule_ExprList.cs プロジェクト: NALSS/epiinfo-82474
        public Rule_ExprList(Rule_Context pContext, NonterminalToken pToken)
            : base(pContext)
        {
            /*::= <Expression> ',' <Expr List> | <Expression> */

            this.Expression = EnterRule.BuildStatments(pContext, pToken.Tokens[0]);

            if (pToken.Tokens.Length > 1)
            {
                this.ExprList = EnterRule.BuildStatments(pContext, pToken.Tokens[2]);
            }
        }
コード例 #8
0
        public Rule_DefineVariables_Statement(Rule_Context pContext, NonterminalToken pToken)
            : base(pContext)
        {
            this.TextField = this.ExtractTokensWithFormat(pToken.Tokens);

            //<DefineVariables_Statement> ::= DefineVariables <Define_Statement_Group> End-DefineVariables
            if (pToken.Tokens.Length > 2)
            {
                //define_Statements_Group = new Rule_Define_Statement_Group(pContext, (NonterminalToken)pToken.Tokens[1]);
                define_Statements_Group = EnterRule.BuildStatments(pContext, pToken.Tokens[1]);
            }
        }
コード例 #9
0
ファイル: Rule_AndExp.cs プロジェクト: NALSS/epiinfo-82474
        public Rule_AndExp(Rule_Context pContext, NonterminalToken pToken)
            : base(pContext)
        {
            // <Not Exp> AND <And Exp>
            // <Not Exp>

            this.NotExp = EnterRule.BuildStatments(pContext, pToken.Tokens[0]);
            if (pToken.Tokens.Length > 1)
            {
                this.AndExp = EnterRule.BuildStatments(pContext, pToken.Tokens[2]);
            }
        }
コード例 #10
0
        public Rule_Define_Statement_Group(Rule_Context pContext, NonterminalToken pToken)
            : base(pContext)
        {
            //<Define_Statement_Group> ::= <Define_Statement_Type> <Define_Statement_Group> | <Define_Statement_Type>

            Define_Statement_Type = EnterRule.BuildStatments(pContext, pToken.Tokens[0]);

            if (pToken.Tokens.Length > 1)
            {
                Define_Statement_Group = EnterRule.BuildStatments(pContext, pToken.Tokens[1]);
            }
        }
コード例 #11
0
 public Rule_CheckCodeBlocks(Rule_Context pContext, NonterminalToken pToken)
 {
     //<CheckCodeBlocks> ::= <CheckCodeBlock> <CheckCodeBlocks> | <CheckCodeBlock>
     if (pToken.Tokens.Length > 1)
     {
         CheckCodeBlock = EnterRule.BuildStatments(pContext, pToken.Tokens[0]);
         CheckCodeBlocks = EnterRule.BuildStatments(pContext, pToken.Tokens[1]);
     }
     else
     {
         CheckCodeBlock = EnterRule.BuildStatments(pContext, pToken.Tokens[0]);
     }
 }
コード例 #12
0
ファイル: Rule_NotExp.cs プロジェクト: NALSS/epiinfo-82474
 public Rule_NotExp(Rule_Context pContext, NonterminalToken pToken)
     : base(pContext)
 {
     //<Not Exp> ::= NOT <Compare Exp> | <Compare Exp>
     if (pToken.Tokens.Length == 1)
     {
         CompareExp = EnterRule.BuildStatments(pContext, pToken.Tokens[0]);
     }
     else
     {
         CompareExp = EnterRule.BuildStatments(pContext, pToken.Tokens[1]);
         this.isNotStatement = true;
     }
 }
コード例 #13
0
ファイル: Rule_ConcatExp.cs プロジェクト: NALSS/epiinfo-82474
        public Rule_ConcatExp(Rule_Context pContext, NonterminalToken pToken)
            : base(pContext)
        {
            /*::= <Add Exp> '&' <Concat Exp>
               						| <Add Exp>*/

            this.AddExp = EnterRule.BuildStatments(pContext, pToken.Tokens[0]);
            if (pToken.Tokens.Length > 1)
            {
                this.op = pToken.Tokens[1].ToString();

                this.ConcatExp = EnterRule.BuildStatments(pContext, pToken.Tokens[2]);
            }
        }
コード例 #14
0
ファイル: Rule_AddExp.cs プロジェクト: NALSS/epiinfo-82474
        public Rule_AddExp(Rule_Context pContext, NonterminalToken pToken)
            : base(pContext)
        {
            /*::= <Mult Exp> '+' <Add Exp>
                                        | <Mult Exp> '-' <Add Exp>
                                        | <Mult Exp>*/

            this.MultExp = EnterRule.BuildStatments(pContext, pToken.Tokens[0]);

            if (pToken.Tokens.Length > 1)
            {
                operation = pToken.Tokens[1].ToString();
                this.AddExp = EnterRule.BuildStatments(pContext, pToken.Tokens[2]);
            }
        }
コード例 #15
0
        public Rule_Expression(Rule_Context pContext, NonterminalToken pTokens)
            : base(pContext)
        {
            /*::= <And Exp> OR <Expression>
              						| <And Exp> XOR <Expression>
               							| <And Exp> */

            this.CommandText = this.ExtractTokens(pTokens.Tokens);

            And_Exp = EnterRule.BuildStatments(pContext, pTokens.Tokens[0]);
            if(pTokens.Tokens.Length > 1)
            {
                    op = pTokens.Tokens[1].ToString().ToUpper();
                    Expression = EnterRule.BuildStatments(pContext, pTokens.Tokens[2]);
            }
        }
コード例 #16
0
ファイル: Rule_NegateExp.cs プロジェクト: NALSS/epiinfo-82474
        public Rule_NegateExp(Rule_Context pContext, NonterminalToken pTokens)
            : base(pContext)
        {
            //<Negate Exp> ::= '-' <Value>
            // or
            //<Negate Exp> ::= <Value>

            if(pTokens.Tokens.Length > 1)
            {
                this.op = this.GetCommandElement(pTokens.Tokens,0);
                this.Value = EnterRule.BuildStatments(pContext, pTokens.Tokens[1]);
            }
            else
            {
                this.Value = EnterRule.BuildStatments(pContext, pTokens.Tokens[0]);
            }
        }
コード例 #17
0
ファイル: Rule_MultExp.cs プロジェクト: NALSS/epiinfo-82474
        public Rule_MultExp(Rule_Context pContext, NonterminalToken pToken)
            : base(pContext)
        {
            /*::= <Pow Exp> '*' <Mult Exp>
                                | <Pow Exp> '/' <Mult Exp>
                                | <Pow Exp> MOD <Mult Exp>
                                | <Pow Exp> '%' <Mult Exp>
                                        | <Pow Exp>*/

            this.PowExp = EnterRule.BuildStatments(pContext, pToken.Tokens[0]);
            if(pToken.Tokens.Length > 1)
            {
                this.op = pToken.Tokens[1].ToString();

                this.MultExp = EnterRule.BuildStatments(pContext, pToken.Tokens[2]);
            }
        }
コード例 #18
0
        public Rule_Define_Statement_Type(Rule_Context pContext, NonterminalToken pToken)
            : base(pContext)
        {
            /*<Define_Statement_Type> ::= <Define_Variable_Statement>
                            | <Define_Dll_Statement>
                            | <Define_Group_Statement> */

            this.define_command = EnterRule.BuildStatments(pContext, pToken.Tokens[0]);
            /*
            if (((NonterminalToken)pToken.Tokens[0]).Symbol.ToString() == "<Define_Dll_Statement>")
            {
                this.define_command = new Rule_DLL_Statement(pContext, (NonterminalToken) pToken.Tokens[0]);
            }
            else
            {
                this.define_command = new Rule_Define(pContext, (NonterminalToken) pToken.Tokens[0]);
            }*/
        }
コード例 #19
0
 public Rule_NumToDate(Rule_Context pContext, NonterminalToken pToken)
     : base(pContext)
 {
     this.ParameterList = EnterRule.GetFunctionParameters(pContext, pToken);
     AddCommandVariableCheckValue(ParameterList, "numtodate");
     //if (ParameterList.Count > 0)
     //{
     //    foreach (var item in ParameterList)
     //    {
     //        if (item is Rule_Value)
     //        {
     //            var id = ((Epi.Core.EnterInterpreter.Rules.Rule_Value)(item)).Id;
     //            if (!this.Context.CommandVariableCheck.ContainsKey(id.ToLowerInvariant()))
     //            {
     //                this.Context.CommandVariableCheck.Add(id.ToLowerInvariant(), "numtodate");
     //            }
     //        }
     //    }
     //}
 }
コード例 #20
0
ファイル: Rule_DateDiff.cs プロジェクト: zlmone/epi-info-web
        /// <summary>
        /// Reduction to calculate the difference between two dates.
        /// </summary>
        /// <param name="pToken">The token to use to build the reduction.</param>
        /// <param name="interval">The date interval to use for calculating the difference (seconds, hours, days, months, years)</param>
        public Rule_DateDiff(Rule_Context pContext, NonterminalToken pToken, FunctionUtils.DateInterval interval)
            : base(pContext)
        {
            currentInterval    = interval;
            this.ParameterList = EnterRule.GetFunctionParameters(pContext, pToken);

            /*
             * NonterminalToken T = (NonterminalToken)pToken.Tokens[0];
             * string type = pToken.Rule.Lhs.ToString();
             * switch (type)
             * {
             *  case "<FunctionParameterList>":
             *      this.ParamList = new Rule_FunctionParameterList(pContext, pToken);
             *      break;
             *  case "<FunctionCall>":
             *      this.functionCall = new Rule_FunctionCall(pContext, T);
             *      break;
             *  default:
             *      break;
             * }*/
        }
コード例 #21
0
 public Rule_FindText(Rule_Context pContext, NonterminalToken pToken)
     : base(pContext)
 {
     //SUBSTRING(fullString,startingIndex,length)
     this.ParameterList = EnterRule.GetFunctionParameters(pContext, pToken);
     AddCommandVariableCheckValue(ParameterList, "findtext");
     //if (ParameterList.Count > 0)
     //{
     //    foreach (var item in ParameterList)
     //    {
     //        if (item is Rule_Value)
     //        {
     //            var id = ((Epi.Core.EnterInterpreter.Rules.Rule_Value)(item)).Id;
     //            if (!this.Context.CommandVariableCheck.ContainsKey(id.ToLowerInvariant()))
     //            {
     //                this.Context.CommandVariableCheck.Add(id.ToLowerInvariant(), "findtext");
     //            }
     //        }
     //    }
     //}
 }
コード例 #22
0
        public Rule_Substring(Rule_Context pContext, NonterminalToken pToken)
            : base(pContext)
        {
            //SUBSTRING(fullString,startingIndex,length)
            this.ParameterList = EnterRule.GetFunctionParameters(pContext, pToken);
            AddCommandVariableCheckValue(ParameterList, "substring");
            //if (ParameterList.Count() > 0)
            //{

            //    foreach (var item in ParameterList)
            //    {
            //        if (item is Rule_Value)
            //        {
            //            if (!this.Context.CommandVariableCheck.ContainsKey(((Rule_Value)(item)).Id.ToLowerInvariant()))
            //            {
            //                this.Context.CommandVariableCheck.Add(((Rule_Value)(item)).Id, "substring");
            //            }
            //        }
            //    }
            //}
        }
コード例 #23
0
 public Rule_View_Checkcode_Statement(Rule_Context pContext, NonterminalToken pToken)
     : base(pContext)
 {
     this.TextField = this.ExtractTokensWithFormat(pToken.Tokens);
     // <View_Checkcode_Statement> ::= View <Begin_Before_statement> <Begin_After_statement> End
     for (int i = 1; i < pToken.Tokens.Length; i++)
     {
         if (pToken.Tokens[i] is NonterminalToken)
         {
             NonterminalToken T = (NonterminalToken)pToken.Tokens[i];
             switch (T.Symbol.ToString())
             {
                 case "<Begin_Before_statement>":
                     this.BeginBefore = EnterRule.BuildStatments(pContext, pToken.Tokens[i]);
                     break;
                 case "<Begin_After_statement>":
                     this.BeginAfter = EnterRule.BuildStatments(pContext, pToken.Tokens[i]);
                     break;
             }
         }
     }
 }
コード例 #24
0
ファイル: Rule_Define.cs プロジェクト: fgma75/epiinfo
        public Rule_Define(Rule_Context pContext, NonterminalToken pToken) : base(pContext)
        {
            //DEFINE Identifier <Variable_Scope> <VariableTypeIndicator> <Define_Prompt>
            //DEFINE Identifier '=' <Expression>

            Identifier = GetCommandElement(pToken.Tokens, 1);
            if (GetCommandElement(pToken.Tokens, 2) == "=")
            {
                this.Expression = EnterRule.BuildStatments(pContext, pToken.Tokens[3]);
                // set some defaults
                Variable_Scope        = "STANDARD";
                VariableTypeIndicator = "";
                Define_Prompt         = "";
            }
            else
            {
                Variable_Scope = GetCommandElement(pToken.Tokens, 2);//STANDARD | GLOBAL | PERMANENT |!NULL

                VariableTypeIndicator = GetCommandElement(pToken.Tokens, 3);
                Define_Prompt         = GetCommandElement(pToken.Tokens, 4);
            }
        }
コード例 #25
0
ファイル: Rule_Define.cs プロジェクト: NALSS/epiinfo-82474
        public Rule_Define(Rule_Context pContext, NonterminalToken pToken)
            : base(pContext)
        {
            //DEFINE Identifier <Variable_Scope> <VariableTypeIndicator> <Define_Prompt>
            //DEFINE Identifier '=' <Expression>

            Identifier = GetCommandElement(pToken.Tokens, 1);
            if (GetCommandElement(pToken.Tokens, 2) == "=")
            {
                this.Expression = EnterRule.BuildStatments(pContext, pToken.Tokens[3]);
                // set some defaults
                Variable_Scope = "STANDARD";
                VariableTypeIndicator  =  "";
                Define_Prompt = "";
            }
            else
            {
                Variable_Scope = GetCommandElement(pToken.Tokens, 2);//STANDARD | GLOBAL | PERMANENT |!NULL

                VariableTypeIndicator = GetCommandElement(pToken.Tokens, 3);
                Define_Prompt = GetCommandElement(pToken.Tokens, 4);
            }
        }
コード例 #26
0
        public Rule_Statements(Rule_Context pContext, NonterminalToken pToken) : base(pContext)
        {
            //<Statements> ::= <Statements> <Statement> | <Statement>

            if (pToken.Tokens.Length > 1)
            {
                //NonterminalToken T;
                //T = (NonterminalToken)pToken.Tokens[0];
                //this.statements = new Rule_Statements(pContext, T);
                this.statements = EnterRule.BuildStatments(pContext, pToken.Tokens[0]);

                //T = ((NonterminalToken)pToken.Tokens[1]);
                //this.statement = new Rule_Statement(pContext, T);
                this.statement = EnterRule.BuildStatments(pContext, pToken.Tokens[1]);
            }
            else
            {
                //NonterminalToken T;
                //T = (NonterminalToken)pToken.Tokens[0];
                //this.statement = new Rule_Statement(pContext, T);
                this.statement = EnterRule.BuildStatments(pContext, pToken.Tokens[0]);
            }
        }
コード例 #27
0
        public Rule_View_Checkcode_Statement(Rule_Context pContext, NonterminalToken pToken)
            : base(pContext)
        {
            this.TextField = this.ExtractTokensWithFormat(pToken.Tokens);
            // <View_Checkcode_Statement> ::= View <Begin_Before_statement> <Begin_After_statement> End
            for (int i = 1; i < pToken.Tokens.Length; i++)
            {
                if (pToken.Tokens[i] is NonterminalToken)
                {
                    NonterminalToken T = (NonterminalToken)pToken.Tokens[i];
                    switch (T.Symbol.ToString())
                    {
                    case "<Begin_Before_statement>":
                        this.BeginBefore = EnterRule.BuildStatments(pContext, pToken.Tokens[i]);
                        break;

                    case "<Begin_After_statement>":
                        this.BeginAfter = EnterRule.BuildStatments(pContext, pToken.Tokens[i]);
                        break;
                    }
                }
            }
        }
コード例 #28
0
        public Rule_CheckCodeBlock(Rule_Context pContext, NonterminalToken pToken)
            : base(pContext)
        {
            /* <CheckCodeBlock> ::=   <DefineVariables_Statement>
             | <View_Checkcode_Statement>
             | <Record_Checkcode_Statement>
             | <Page_Checkcode_Statement>
             | <Field_Checkcode_Statement>
             | <Subroutine_Statement>  */
            switch (pToken.Rule.Rhs[0].ToString())
            {
            case "<DefineVariables_Statement>":
                this.CheckCodeBlock = EnterRule.BuildStatments(pContext, pToken.Tokens[0]);
                break;

            case "<View_Checkcode_Statement>":
                this.CheckCodeBlock = EnterRule.BuildStatments(pContext, pToken.Tokens[0]);
                break;

            case "<Record_Checkcode_Statement>":
                this.CheckCodeBlock = EnterRule.BuildStatments(pContext, pToken.Tokens[0]);
                break;

            case "<Page_Checkcode_Statement>":
                this.CheckCodeBlock = EnterRule.BuildStatments(pContext, pToken.Tokens[0]);
                break;

            case "<Field_Checkcode_Statement>":
                this.CheckCodeBlock = EnterRule.BuildStatments(pContext, pToken.Tokens[0]);
                break;

            case "<Subroutine_Statement>":
                this.CheckCodeBlock = EnterRule.BuildStatments(pContext, pToken.Tokens[0]);
                break;
            }
        }
コード例 #29
0
        public Rule_Statements(Rule_Context pContext, NonterminalToken pToken)
            : base(pContext)
        {
            //<Statements> ::= <Statements> <Statement> | <Statement>

               if (pToken.Tokens.Length > 1)
               {
               //NonterminalToken T;
               //T = (NonterminalToken)pToken.Tokens[0];
               //this.statements = new Rule_Statements(pContext, T);
               this.statements = EnterRule.BuildStatments(pContext, pToken.Tokens[0]);

               //T = ((NonterminalToken)pToken.Tokens[1]);
               //this.statement = new Rule_Statement(pContext, T);
               this.statement = EnterRule.BuildStatments(pContext, pToken.Tokens[1]);
               }
               else
               {
               //NonterminalToken T;
               //T = (NonterminalToken)pToken.Tokens[0];
               //this.statement = new Rule_Statement(pContext, T);
               this.statement = EnterRule.BuildStatments(pContext, pToken.Tokens[0]);
               }
        }
コード例 #30
0
        public Rule_Page_Checkcode_Statement(Rule_Context pContext, NonterminalToken pToken)
            : base(pContext)
        {
            this.TextField = this.ExtractTokensWithFormat(pToken.Tokens);

            //<Page_Checkcode_Statement> ::= Page Identifier <Begin_Before_statement> <Begin_After_statement> End
            this.Identifier = this.GetCommandElement(pToken.Tokens, 1).Trim(new char[] { '[', ']' });
            for (int i = 2; i < pToken.Tokens.Length; i++)
            {
                if (pToken.Tokens[i] is NonterminalToken)
                {
                    NonterminalToken T = (NonterminalToken)pToken.Tokens[i];
                    switch (T.Symbol.ToString())
                    {
                        case "<Begin_Before_statement>":
                            this.BeginBefore = EnterRule.BuildStatments(pContext, T);
                            break;
                        case "<Begin_After_statement>":
                            this.BeginAfter = EnterRule.BuildStatments(pContext, T);
                            break;
                    }
                }
            }
        }
コード例 #31
0
        public Rule_Else_If_Statement(Rule_Context pContext, NonterminalToken pToken)
            : base(pContext)
        {
            /*
             *
             * <Else_If_Statement>          ::=  Else-If <Expression> Then <Statements>
             | Else-If <Expression> Then <Statements> Else <Statements>
             | Else-If <Expression> Then <Statements> <Else_If_Statement>
             */

            Expression  = EnterRule.BuildStatments(pContext, pToken.Tokens[1]);
            Statements1 = EnterRule.BuildStatments(pContext, pToken.Tokens[3]);
            if (pToken.Tokens.Length > 4)
            {
                if (this.GetCommandElement(pToken.Tokens, 4).Equals("Else", StringComparison.OrdinalIgnoreCase))
                {
                    Statements2 = EnterRule.BuildStatments(pContext, pToken.Tokens[5]);
                }
                else
                {
                    Statements2 = EnterRule.BuildStatments(pContext, pToken.Tokens[4]);
                }
            }
        }
コード例 #32
0
ファイル: Rule_Dialog.cs プロジェクト: NALSS/epiinfo-82474
        public Rule_Dialog(Rule_Context pContext, NonterminalToken token)
            : base(pContext)
        {
            switch (token.Rule.Lhs.ToString())
            {
                case "<Simple_Dialog_Statement>":
                    this.Dialog = new Rule_Simple_Dialog_Statement(pContext, token);
                    break;
                case "<Numeric_Dialog_Implicit_Statement>":
                    this.Dialog = new Rule_Numeric_Dialog_Implicit_Statement(pContext, token);
                    break;
                case "<TextBox_Dialog_Statement>":
                    this.Dialog = new Rule_TextBox_Dialog_Statement(pContext, token);
                    break;
                case "<Numeric_Dialog_Explicit_Statement>":
                    this.Dialog = new Rule_Numeric_Dialog_Explicit_Statement(pContext, token);
                    break;
                case "<Db_Values_Dialog_Statement>":
                    this.Dialog = new Rule_Db_Values_Dialog_Statement(pContext, token);
                    break;
                case "<YN_Dialog_Statement>":
                    this.Dialog = new Rule_YN_Dialog_Statement(pContext, token);
                    break;
                case "<Db_Views_Dialog_Statement>":
                    this.Dialog = new Rule_Db_Views_Dialog_Statement(pContext, token);
                    break;
                case "<Databases_Dialog_Statement>":
                    this.Dialog = new Rule_Databases_Dialog_Statement(pContext, token);
                    break;
                case "<Db_Variables_Dialog_Statement>":
                    this.Dialog = new Rule_Db_Variables_Dialog_Statement(pContext, token);
                    break;
                case "<Multiple_Choice_Dialog_Statement>":
                    this.Dialog = new Rule_Multiple_Choice_Dialog_Statement(pContext, token);
                    break;
                case "<Dialog_Read_Statement>":
                    this.Dialog = new Rule_Dialog_Read_Statement(pContext, token);
                    break;
                case "<Dialog_Write_Statement>":
                    this.Dialog = new Rule_Dialog_Write_Statement(pContext, token);
                    break;
                case "<Dialog_Read_Filter_Statement>":
                    this.Dialog = new Rule_Dialog_Read_Filter_Statement(pContext, token);
                    break;
                case "<Dialog_Write_Filter_Statement>":
                    this.Dialog = new Rule_Dialog_Write_Filter_Statement(pContext, token);
                    break;
                case "<Dialog_Date_Statement>":
                    this.Dialog = new Rule_Dialog_Date_Statement(pContext, token);
                    break;
                case "<Dialog_Time_Statement>":
                    this.Dialog = new Rule_Dialog_Time_Statement(pContext, token);
                    break;
                case "<Dialog_DateTime_Statement>":
                    this.Dialog = new Rule_Dialog_DateTime_Statement(pContext, token);
                    break;
                case "<Dialog_Date_Mask_Statement>":
                    this.Dialog = new Rule_Dialog_Date_Mask_Statement(pContext, token);
                    break;
                default:
                    this.Dialog = new Rule_TextBox_Dialog_Statement(pContext, token);
                    break;

            }
        }
コード例 #33
0
        public override string RenderHtml()
        {
            int.TryParse(ConfigurationManager.AppSettings["CACHE_DURATION"].ToString(), out CacheDuration);
            CacheIsOn = ConfigurationManager.AppSettings["CACHE_IS_ON"];//false;
            IsCacheSlidingExpiration = ConfigurationManager.AppSettings["CACHE_SLIDING_EXPIRATION"].ToString();
            var html = new StringBuilder();

            var    inputName  = _form.FieldPrefix + _key;
            string ErrorStyle = string.Empty;

            // prompt
            var prompt = new TagBuilder("label");

            System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"(\r\n|\r|\n)+");

            string newText = regex.Replace(Prompt.Replace(" ", "&nbsp;"), "<br />");

            string NewPromp = System.Web.Mvc.MvcHtmlString.Create(newText).ToString();


            prompt.InnerHtml = NewPromp;
            prompt.Attributes.Add("for", inputName);
            prompt.Attributes.Add("class", "EpiLabel");
            prompt.Attributes.Add("Id", "label" + inputName);


            StringBuilder StyleValues = new StringBuilder();

            StyleValues.Append(GetContolStyle(_fontstyle.ToString(), _Prompttop.ToString(), _Promptleft.ToString(), null, Height.ToString(), _IsHidden));
            prompt.Attributes.Add("style", StyleValues.ToString());
            html.Append(prompt.ToString());

            // error label
            if (!IsValid)
            {
                //Add new Error to the error Obj

                ErrorStyle = ";border-color: red";
            }

            // open select element
            //if (this.CodesList != null)
            //{
            //    if (this.CodesList.Count() > 0)
            //    {
            //        string Html = "";
            //        var ScriptRelateCondition = new TagBuilder("script");
            //        foreach (var code in CodesList)
            //        {
            //            Html = "";

            //            var NewCode = Regex.Replace(code.Key.ToString(), @"[^0-9a-zA-Z]+", "");
            //            NewCode = Regex.Replace(NewCode, @"\s+", "");
            //            Html = "var " + NewCode + "=[";
            //            var json1 = JsonConvert.SerializeObject(code.Value);
            //            foreach (var item in code.Value)
            //            {
            //                var values = item.Split('=');
            //                Html = Html + "\"" + values[0] + "," + values[1].ToString().Replace("\"", "") + "\",";


            //            }
            //            Html = Html + "]; ";
            //            ScriptRelateCondition.InnerHtml = ScriptRelateCondition.InnerHtml + Html.ToString();

            //        }
            //        html.Append(ScriptRelateCondition.ToString(TagRenderMode.Normal));
            //        //var JasonObj =
            //        // var jsonSerialiser = new JavaScriptSerializer();
            //        // var json = JsonConvert.SerializeObject(CodesList);

            //    }
            //}
            TagBuilder select = null;

            select = new TagBuilder("select");

            select.Attributes.Add("id", inputName);
            select.Attributes.Add("name", inputName);
            ////////////Check code start//////////////////
            EnterRule FunctionObjectAfter = (EnterRule)_form.FormCheckCodeObj.GetCommand("level=field&event=after&identifier=" + _key);

            if (FunctionObjectAfter != null && !FunctionObjectAfter.IsNull())
            {
                select.Attributes.Add("onblur", "return " + _key + "_after();"); //After
                // select.Attributes.Add("onchange", "return " + _key + "_after();"); //After
            }
            EnterRule FunctionObjectBefore = (EnterRule)_form.FormCheckCodeObj.GetCommand("level=field&event=before&identifier=" + _key);

            if (FunctionObjectBefore != null && !FunctionObjectBefore.IsNull())
            {
                select.Attributes.Add("onfocus", "return " + _key + "_before();"); //Before
            }
            EnterRule FunctionObjectClick = (EnterRule)_form.FormCheckCodeObj.GetCommand("level=field&event=click&identifier=" + _key);

            if (FunctionObjectClick != null && !FunctionObjectClick.IsNull())
            {
                select.Attributes.Add("onclick", "return " + _key + "_click();"); //click
            }
            if (!string.IsNullOrEmpty(this.RelateCondition))
            {
                select.Attributes.Add("onchange", "return SetCodes_Val(this,'" + _form.SurveyInfo.SurveyId + "','" + _key + "');"); //click
            }
            ////////////Check code end//////////////////
            int    LargestChoiseLength = 0;
            string measureString       = "";

            foreach (var choise in _choices)
            {
                if (choise.Key.ToString().Length > LargestChoiseLength)
                {
                    LargestChoiseLength = choise.Key.ToString().Length;

                    measureString = choise.Key.ToString();
                }
            }

            // LargestChoiseLength = LargestChoiseLength * _ControlFontSize;

            Font stringFont = new Font(ControlFontStyle, _ControlFontSize);

            SizeF size = new SizeF();

            using (Graphics g = Graphics.FromHwnd(IntPtr.Zero))
            {
                size = g.MeasureString(measureString.ToString(), stringFont);
            }



            // stringSize = (int) Graphics.MeasureString(measureString.ToString(), stringFont).Width;


            if (_IsRequired == true)
            {
                //awesomplete

                if ((size.Width) > _ControlWidth)
                {
                    // select.Attributes.Add("class", GetControlClass() + "text-input fix-me");
                    select.Attributes.Add("class", GetControlClass() + "fix-me");
                }
                else
                {
                    // select.Attributes.Add("class", GetControlClass() + "text-input");
                    select.Attributes.Add("class", GetControlClass());
                }
                select.Attributes.Add("data-prompt-position", "topRight:10");
            }
            else
            {
                //awesomplete

                //select.Attributes.Add("class", GetControlClass() + "text-input fix-me");
                if ((size.Width) > _ControlWidth)
                {
                    select.Attributes.Add("class", GetControlClass() + "fix-me ");
                }
                else
                {
                    select.Attributes.Add("class", GetControlClass());
                }
                select.Attributes.Add("data-prompt-position", "topRight:10");
            }
            string IsHiddenStyle      = "";
            string IsHighlightedStyle = "";

            if (_IsHidden)
            {
                IsHiddenStyle = "display:none";
            }
            if (_IsHighlighted)
            {
                IsHighlightedStyle = "background-color:yellow";
            }

            //if (_IsDisabled)
            //{
            //    select.Attributes.Add("disabled", "disabled");
            //}

            string InputFieldStyle = GetInputFieldStyle(_InputFieldfontstyle.ToString(), _InputFieldfontSize, _InputFieldfontfamily.ToString());

            select.Attributes.Add("style", "position:absolute;left:" + _left.ToString() + "px;top:" + _top.ToString() + "px" + ";width:" + _ControlWidth.ToString() + "px ; font-size:" + _ControlFontSize + "pt;" + ErrorStyle + ";" + IsHiddenStyle + ";" + IsHighlightedStyle + ";" + InputFieldStyle);
            select.MergeAttributes(_inputHtmlAttributes);
            html.Append(select.ToString(TagRenderMode.StartTag));

            if (ReadOnly || _IsDisabled)
            {
                var scriptReadOnlyText = new TagBuilder("script");
                //scriptReadOnlyText.InnerHtml = "$(function(){$('#" + inputName + "').attr('disabled','disabled')});";
                scriptReadOnlyText.InnerHtml = "$(function(){  var List = new Array();List.push('" + _key + "');CCE_Disable(List, false);});";
                html.Append(scriptReadOnlyText.ToString(TagRenderMode.Normal));
            }


            // initial empty option
            if (this._choices.Count() < 100)
            {
                if (ShowEmptyOption)
                {
                    var opt = new TagBuilder("option");
                    opt.Attributes.Add("value", null);
                    opt.SetInnerText(EmptyOption);
                    html.Append(opt.ToString());
                }
            }
            // options

            // Build codes RelateCondition script object



            switch (this.SelectType.ToString())
            {
            case "11":
                foreach (var choice in _choices)
                {
                    var opt             = new TagBuilder("option");
                    var optSelectedVale = "";
                    if (!string.IsNullOrEmpty(SelectedValue.ToString()))
                    {
                        optSelectedVale = SelectedValue.ToString();        //=="1"? "Yes" : "No";
                    }
                    opt.Attributes.Add("value", (choice.Key == "Yes" ? "1" : "0"));
                    if (choice.Key == optSelectedVale.ToString())
                    {
                        opt.Attributes.Add("selected", "selected");
                    }
                    if (choice.Key == "Yes" || choice.Key == "No")
                    {
                        opt.SetInnerText(choice.Key);
                        html.Append(opt.ToString());
                    }
                }
                break;

            case "17":
                foreach (var choice in _choices)
                {
                    var opt = new TagBuilder("option");
                    opt.Attributes.Add("value", choice.Key);
                    if (choice.Key == SelectedValue.ToString())
                    {
                        opt.Attributes.Add("selected", "selected");
                    }
                    opt.SetInnerText(choice.Key);
                    html.Append(opt.ToString());
                }

                break;

            case "18":


                foreach (var choice in _choices)
                {
                    var opt = new TagBuilder("option");
                    opt.Attributes.Add("value", choice.Key);
                    if (choice.Key == SelectedValue.ToString())
                    {
                        opt.Attributes.Add("selected", "selected");
                    }
                    {
                        opt.SetInnerText(choice.Key);
                    }
                    html.Append(opt.ToString());
                }



                break;

            case "19":
                foreach (var choice in _choices)
                {
                    var opt = new TagBuilder("option");

                    if (choice.Key.Contains("-"))
                    {
                        string[] keyValue    = choice.Key.Split(new char[] { '-' }, 2);
                        string   comment     = keyValue[0].Trim();
                        string   description = keyValue[1].Trim();

                        opt.Attributes.Add("value", comment);

                        if (choice.Value || comment == SelectedValue.ToString())
                        {
                            opt.Attributes.Add("selected", "selected");
                        }

                        opt.SetInnerText(description);
                    }

                    html.Append(opt.ToString());
                }
                break;
            }



            // close select element
            html.Append(select.ToString(TagRenderMode.EndTag));

            // add hidden tag, so that a value always gets sent for select tags
            var hidden1 = new TagBuilder("input");

            hidden1.Attributes.Add("type", "hidden");
            hidden1.Attributes.Add("id", inputName + "_hidden");
            hidden1.Attributes.Add("name", inputName);
            hidden1.Attributes.Add("value", string.Empty);
            html.Append(hidden1.ToString(TagRenderMode.SelfClosing));

            var wrapper = new TagBuilder(_fieldWrapper);

            wrapper.Attributes["class"] = _fieldWrapperClass;
            if (_IsHidden)
            {
                wrapper.Attributes["style"] = "display:none";
            }
            wrapper.Attributes["id"] = inputName + "_fieldWrapper";
            wrapper.InnerHtml        = html.ToString();
            return(wrapper.ToString());
        }
コード例 #34
0
 public Rule_Days(Rule_Context pContext, NonterminalToken pToken)
     : base(pContext, pToken, FunctionUtils.DateInterval.Minute)
 {
     this.ParameterList = EnterRule.GetFunctionParameters(pContext, pToken);
     AddCommandVariableCheckValue(ParameterList, "days");
 }
コード例 #35
0
ファイル: Select.cs プロジェクト: fgma75/epiinfo
        public override string RenderHtml()
        {
            var html = new StringBuilder();

            var inputName = _fieldPrefix + _key;
            string ErrorStyle = string.Empty;

            var prompt = new TagBuilder("label");
            System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"(\r\n|\r|\n)+");
            string newText = regex.Replace(Prompt.Replace(" ", "&nbsp;"), "<br />");
            string NewPromp = System.Web.Mvc.MvcHtmlString.Create(newText).ToString();

            prompt.InnerHtml=NewPromp;
            prompt.Attributes.Add("for", inputName);
            prompt.Attributes.Add("class", "EpiLabel");
            prompt.Attributes.Add("Id", "label" + inputName);

            StringBuilder StyleValues = new StringBuilder();
            StyleValues.Append(GetControlStyle(_fontstyle.ToString(), _Prompttop.ToString(), _Promptleft.ToString(), null, Height.ToString(),_IsHidden));
            prompt.Attributes.Add("style", StyleValues.ToString());
            html.Append(prompt.ToString());

            if (!IsValid)
            {
                ErrorStyle = ";border-color: red";
            }

            //var select = new TagBuilder("select");
            TagBuilder select = null;
            if (this._choices.Count() < 200)
            {
                select = new TagBuilder("select");
            }
            else
            {
                var Value = _choices.FirstOrDefault(x => x.Value == true).Key;
                select = new TagBuilder("input");
                select.Attributes.Add("list", inputName + "_DataList");
                select.Attributes.Add("data-autofirst", "true");
                select.Attributes.Add("value", Value);
            }
            select.Attributes.Add("id", inputName);
            select.Attributes.Add("name", inputName);

            /*if (FunctionObjectAfter != null && !FunctionObjectAfter.IsNull())
            {
                select.Attributes.Add("onblur", "return " + _key + "_after();"); //After
            }
            if (FunctionObjectClick != null && !FunctionObjectClick.IsNull())
            {
                if( this.RelateCondition)
                {
                    select.Attributes.Add("onchange", "return SetCodes_Val(this,'" + "null" + "','" + _key + "');" + _key + "_click();"); //click
                }
                else
                {
                    select.Attributes.Add("onchange", "return " + _key + "_click();"); //click
                }
            }
            else {
                if (this.RelateCondition)
                {
                    select.Attributes.Add("onchange", "return SetCodes_Val(this,'" + "null"+ "','" + _key + "');"  ); //click
                }
            }
            if (FunctionObjectBefore != null && !FunctionObjectBefore.IsNull())
            {
                select.Attributes.Add("onfocus", "return " + _key + "_before();"); //Before
            }*/
            ////////////Check code start//////////////////
            EnterRule FunctionObjectAfter = (EnterRule)_form.FormCheckCodeObj.GetCommand("level=field&event=after&identifier=" + _key);
            if (FunctionObjectAfter != null && !FunctionObjectAfter.IsNull())
            {

                select.Attributes.Add("onblur", "return " + _key + "_after();"); //After
                // select.Attributes.Add("onchange", "return " + _key + "_after();"); //After
            }
            EnterRule FunctionObjectBefore = (EnterRule)_form.FormCheckCodeObj.GetCommand("level=field&event=before&identifier=" + _key);
            if (FunctionObjectBefore != null && !FunctionObjectBefore.IsNull())
            {

                select.Attributes.Add("onfocus", "return " + _key + "_before();"); //Before
            }
            EnterRule FunctionObjectClick = (EnterRule)_form.FormCheckCodeObj.GetCommand("level=field&event=click&identifier=" + _key);

            if (FunctionObjectClick != null && !FunctionObjectClick.IsNull())
            {
                select.Attributes.Add("onclick", "return " + _key + "_click();"); //click
            }
            if (this.RelateCondition)
            {
                select.Attributes.Add("onchange", "return SetCodes_Val(this,'" + _form.SurveyInfo.SurveyId + "','" + SourceTable + "'," + "''" + ",'" + TextColumnName + "','" + FieldRelateCondition + "');"); //click

            }
            ////////////Check code end//////////////////
            int LargestChoiseLength =0 ;
            string measureString = "";

            foreach (var choice in _choices)
            {
                if (choice.Key.ToString().Length > LargestChoiseLength)
                {
                    LargestChoiseLength = choice.Key.ToString().Length;
                    measureString = choice.Key.ToString();
                }
            }

            Font stringFont = new Font(ControlFontStyle, _ControlFontSize);

            SizeF size = new SizeF() ;

            using (Graphics g = Graphics.FromHwnd(IntPtr.Zero))
            {
                size = g.MeasureString(measureString.ToString(), stringFont);
            }

            if (Required == true)
            {
                if (this._choices.Count() < 200)
                {
                    if ((size.Width) > _ControlWidth)
                    {
                        select.Attributes.Add("class", GetControlClass() + "fix-me");
                    }
                    else
                    {
                        select.Attributes.Add("class", GetControlClass());
                    }

                    select.Attributes.Add("data-prompt-position", "topRight:10");
                }
                else
                {
                    if ((size.Width) > _ControlWidth)
                    {
                        select.Attributes.Add("class", GetControlClass() + "fix-me awesomplete Search ");
                    }
                    else
                    {
                        select.Attributes.Add("class", GetControlClass() + " awesomplete Search");
                    }

                    select.Attributes.Add("data-prompt-position", "topRight:10");

                }
            }
            else
            {
                if (this._choices.Count() < 200)
                {
                    //select.Attributes.Add("class", GetControlClass() + "text-input fix-me");
                    if ((size.Width) > _ControlWidth)
                    {
                        select.Attributes.Add("class", GetControlClass() + "fix-me ");
                    }
                    else
                    {

                        select.Attributes.Add("class", GetControlClass());
                    }
                    select.Attributes.Add("data-prompt-position", "topRight:10");
                }
                else
                {
                    if ((size.Width) > _ControlWidth)
                    {
                        select.Attributes.Add("class", GetControlClass() + "fix-me awesomplete Search");
                    }
                    else
                    {

                        select.Attributes.Add("class", GetControlClass() + " awesomplete Search");
                    }
                    select.Attributes.Add("data-prompt-position", "topRight:10");

                }

            }

            string IsHiddenStyle = "";
            string IsHighlightedStyle = "";

            if(_IsHidden)
            {
                IsHiddenStyle = "display:none";
            }

            if (_IsHighlighted)
            {
                IsHighlightedStyle = "background-color:yellow";
            }

            //if (_IsDisabled)
            //{
            //    select.Attributes.Add("disabled", "disabled");
            //}

            string InputFieldStyle = GetInputFieldStyle(_InputFieldfontstyle.ToString(), _InputFieldfontSize, _InputFieldfontfamily.ToString());
            select.Attributes.Add("style", "position:absolute;left:" + _left.ToString() + "px;top:" + _top.ToString() + "px" + ";width:" + _ControlWidth.ToString() + "px ; font-size:" + _ControlFontSize + "pt;" + ErrorStyle + ";" + IsHiddenStyle + ";" + IsHighlightedStyle + ";" + InputFieldStyle);
            select.MergeAttributes(_inputHtmlAttributes);
            html.Append(select.ToString(TagRenderMode.StartTag));

            if (ReadOnly || _IsDisabled)
                {
                var scriptReadOnlyText = new TagBuilder("script");
                //scriptReadOnlyText.InnerHtml = "$(function(){$('#" + inputName + "').attr('disabled','disabled')});";
                scriptReadOnlyText.InnerHtml = "$(function(){  var List = new Array();List.push('" + _key + "');CCE_Disable(List, false);});";
                html.Append(scriptReadOnlyText.ToString(TagRenderMode.Normal));
                }
            if (this._choices.Count() > 200)
            {

                var scriptReadOnlyText = new TagBuilder("script");
                StringBuilder Script = new StringBuilder();
                Script.Append("$(window).load(function () {  ");
                //Script.Append(" $( '#" + inputName + "' ).next().css( 'width', '" + _ControlWidth.ToString() + "px' );  ");
                Script.Append(" $( '#" + inputName + "' ).next().css( 'left', '" + _left.ToString() + "px' );  ");
                Script.Append(" $( '#" + inputName + "' ).next().css( 'top', '" + (_top + 20).ToString() + "px' );  ");

                Script.Append("});");
                scriptReadOnlyText.InnerHtml = Script.ToString();
                html.Append(scriptReadOnlyText.ToString(TagRenderMode.Normal));
            }

            // initial empty option
            if (this._choices.Count() < 200)
            {

                if (ShowEmptyOption)
                {
                    var opt = new TagBuilder("option");
                    opt.Attributes.Add("value", null);
                    opt.SetInnerText(EmptyOption);
                    html.Append(opt.ToString());
                }
            }

            //options
            //Build codes relatecondition Script Object

            if (this._choices.Count() < 200 && this.SelectedValue.ToString() != "18")
            {
                switch (FieldTypeId.ToString())
                {
                    case "11":
                        foreach (var choice in _choices)
                        {
                            var opt = new TagBuilder("option");
                            var optSelectedVale = "";
                            if (!string.IsNullOrEmpty(SelectedValue.ToString()))
                            {
                                optSelectedVale = SelectedValue.ToString();//=="1"? "Yes" : "No";
                            }
                            opt.Attributes.Add("value", (choice.Key == "Yes" ? "1" : "0"));
                            if (choice.Key == optSelectedVale.ToString())
                            {
                                opt.Attributes.Add("selected", "selected");

                            }
                            if (choice.Key == "Yes" || choice.Key == "No")
                            {
                                opt.SetInnerText(choice.Key);
                                html.Append(opt.ToString());
                            }
                        }
                        break;
                    case "17":
                        foreach (var choice in _choices)
                        {
                            var opt = new TagBuilder("option");
                            opt.Attributes.Add("value", choice.Key);
                            if (choice.Key == SelectedValue.ToString()) opt.Attributes.Add("selected", "selected");
                            opt.SetInnerText(choice.Key);
                            html.Append(opt.ToString());
                        }

                        break;
                    case "18":
                        foreach (var choice in _choices)
                        {
                            var opt = new TagBuilder("option");
                            opt.Attributes.Add("value", choice.Key);
                            if (choice.Key == SelectedValue.ToString()) opt.Attributes.Add("selected", "selected");
                            opt.SetInnerText(choice.Key);
                            html.Append(opt.ToString());
                        }

                        break;
                    case "19":
                        foreach (var choice in _choices)
                        {
                            var opt = new TagBuilder("option");

                            if (choice.Key.Contains("-"))
                            {
                                string[] keyValue = choice.Key.Split(new char[] { '-' }, 2);
                                string comment = keyValue[0].Trim();
                                string description = keyValue[1].Trim();

                                opt.Attributes.Add("value", comment);

                                if (choice.Value || comment == SelectedValue.ToString())
                                {
                                    opt.Attributes.Add("selected", "selected");
                                }

                                opt.SetInnerText(description);
                            }

                            html.Append(opt.ToString());
                        }
                        break;
                }
            }
            else
            {

                var datalist = new TagBuilder("datalist ");
                datalist.Attributes.Add("id", inputName + "_DataList");
                html.Append(datalist.ToString(TagRenderMode.StartTag));
                foreach (var choice in _choices)
                {
                    var opt = new TagBuilder("option");
                    opt.Attributes.Add("value", choice.Key);
                    if (choice.Key == SelectedValue.ToString())
                    {
                        opt.SetInnerText(choice.Key);
                        opt.Attributes.Add("selected", "selected");
                    }
                    html.Append(opt.ToString());
                }

            }

            html.Append(select.ToString(TagRenderMode.EndTag));

            var hidden = new TagBuilder("input");
            hidden.Attributes.Add("type", "hidden");
            hidden.Attributes.Add("id", inputName + "_hidden");
            hidden.Attributes.Add("name", inputName);
            hidden.Attributes.Add("value", string.Empty);
            html.Append(hidden.ToString(TagRenderMode.SelfClosing));

            var wrapper = new TagBuilder(_fieldWrapper);
            wrapper.Attributes["class"] = _fieldWrapperClass;
            if (_IsHidden)
            {
                wrapper.Attributes["style"] = "display:none";

            }
            wrapper.Attributes["id"] = inputName + "_fieldWrapper";
            wrapper.InnerHtml = html.ToString();
            return wrapper.ToString();
        }
コード例 #36
0
ファイル: HomeController.cs プロジェクト: fgma75/epiinfo
        public ActionResult Index(Epi.Web.MVC.Models.SurveyInfoModel surveyModel)
        {
            try
            {
                bool IsMobileDevice = this.Request.Browser.IsMobileDevice;

                if (IsMobileDevice == false)
                {
                    IsMobileDevice = Epi.Web.MVC.Utility.SurveyHelper.IsMobileDevice(this.Request.UserAgent.ToString());
                }

                FormsAuthentication.SetAuthCookie("BeginSurvey", false);



                Session["RootResponseId"] = surveyModel.ResponseId;
                string ResponseID = surveyModel.ResponseId; //string.Empty;
                //object tempDataValue;

                //if (TempData.TryGetValue(Epi.Web.MVC.Constants.Constant.RESPONSE_ID, out tempDataValue))
                //{
                //    ResponseID = (string)tempDataValue;
                //}
                //else
                //{

                //}

                Epi.Web.Common.DTO.SurveyAnswerDTO SurveyAnswer = _isurveyFacade.CreateSurveyAnswer(surveyModel.SurveyId, ResponseID.ToString());

                Epi.Web.Common.Message.UserAuthenticationResponse AuthenticationResponse = _isurveyFacade.GetAuthenticationResponse(ResponseID.ToString());

                string strPassCode = Epi.Web.MVC.Utility.SurveyHelper.GetPassCode();
                if (string.IsNullOrEmpty(AuthenticationResponse.PassCode))
                {
                    //_isurveyFacade.UpdatePassCode(ResponseID.ToString(),  TempData["PassCode"].ToString());
                    _isurveyFacade.UpdatePassCode(ResponseID.ToString(), surveyModel.PassCode);
                }


                Epi.Web.Common.Message.SurveyAnswerResponse SurveyAnswerResponse = _isurveyFacade.GetSurveyAnswerResponse(ResponseID);
                SurveyAnswer = SurveyAnswerResponse.SurveyResponseList[0];
                SurveyInfoModel surveyInfoModel = GetSurveyInfo(SurveyAnswer.SurveyId);

                // set the survey answer to be production or test
                SurveyAnswer.IsDraftMode = surveyInfoModel.IsDraftMode;
                XDocument xdoc = XDocument.Parse(surveyInfoModel.XML);

                // MvcDynamicForms.Form form = _isurveyFacade.GetSurveyFormData(SurveyAnswer.SurveyId, 1, SurveyAnswer, IsMobileDevice, "homeController");
                MvcDynamicForms.Form form = _isurveyFacade.GetSurveyFormData(SurveyAnswer.SurveyId, 1, SurveyAnswer, IsMobileDevice, null);

                var _FieldsTypeIDs = from _FieldTypeID in
                                     xdoc.Descendants("Field")
                                     select _FieldTypeID;

                TempData["Width"] = form.Width + 100;

                XDocument xdocResponse = XDocument.Parse(SurveyAnswer.XML);

                XElement ViewElement = xdoc.XPathSelectElement("Template/Project/View");
                string   checkcode   = ViewElement.Attribute("CheckCode").Value.ToString();

                form.FormCheckCodeObj = form.GetCheckCodeObj(xdoc, xdocResponse, checkcode);

                ///////////////////////////// Execute - Record Before - start//////////////////////
                Dictionary <string, string> ContextDetailList = new Dictionary <string, string>();
                EnterRule FunctionObject_B = (EnterRule)form.FormCheckCodeObj.GetCommand("level=record&event=before&identifier=");
                if (FunctionObject_B != null && !FunctionObject_B.IsNull())
                {
                    try
                    {
                        SurveyAnswer.XML = CreateResponseDocument(xdoc, SurveyAnswer.XML);

                        form.RequiredFieldsList = this.RequiredList;
                        FunctionObject_B.Context.HiddenFieldList      = form.HiddenFieldsList;
                        FunctionObject_B.Context.HighlightedFieldList = form.HighlightedFieldsList;
                        FunctionObject_B.Context.DisabledFieldList    = form.DisabledFieldsList;
                        FunctionObject_B.Context.RequiredFieldList    = form.RequiredFieldsList;

                        FunctionObject_B.Execute();

                        // field list
                        form.HiddenFieldsList      = FunctionObject_B.Context.HiddenFieldList;
                        form.HighlightedFieldsList = FunctionObject_B.Context.HighlightedFieldList;
                        form.DisabledFieldsList    = FunctionObject_B.Context.DisabledFieldList;
                        form.RequiredFieldsList    = FunctionObject_B.Context.RequiredFieldList;


                        ContextDetailList = Epi.Web.MVC.Utility.SurveyHelper.GetContextDetailList(FunctionObject_B);
                        form = Epi.Web.MVC.Utility.SurveyHelper.UpdateControlsValuesFromContext(form, ContextDetailList);
                        SurveyAnswer.RecordBeforeFlag = true;
                        _isurveyFacade.UpdateSurveyResponse(surveyInfoModel, ResponseID.ToString(), form, SurveyAnswer, false, false, 0);
                    }
                    catch (Exception ex)
                    {
                        // do nothing so that processing
                        // can continue
                    }
                }
                else
                {
                    SurveyAnswer.XML        = CreateResponseDocument(xdoc, SurveyAnswer.XML);
                    form.RequiredFieldsList = RequiredList;
                    _isurveyFacade.UpdateSurveyResponse(surveyInfoModel, SurveyAnswer.ResponseId, form, SurveyAnswer, false, false, 0);
                }

                SurveyAnswer = _isurveyFacade.GetSurveyAnswerResponse(SurveyAnswer.ResponseId).SurveyResponseList[0];

                ///////////////////////////// Execute - Record Before - End//////////////////////
                //string page;
                // return RedirectToAction(Epi.Web.Models.Constants.Constant.INDEX, Epi.Web.Models.Constants.Constant.SURVEY_CONTROLLER, new {id="page" });
                return(RedirectToAction(Epi.Web.MVC.Constants.Constant.INDEX, Epi.Web.MVC.Constants.Constant.SURVEY_CONTROLLER, new { responseid = ResponseID, PageNumber = 1 }));
            }
            catch (Exception ex)
            {
                Epi.Web.Utility.ExceptionMessage.SendLogMessage(ex, this.HttpContext);
                return(View(Epi.Web.MVC.Constants.Constant.EXCEPTION_PAGE));
            }
        }
コード例 #37
0
 public Rule_SingleFunctionParameterList(Rule_Context pContext, NonterminalToken pToken, Stack<EnterRule> pList) : base(pContext)
 {
     //<SingleFunctionParameterList> ::= <Expression>
     this.Expression = new Rule_Expression(pContext, (NonterminalToken)pToken.Tokens[0]);
     pList.Push(this.Expression);
 }
コード例 #38
0
 public Rule_Months(Rule_Context pContext, NonterminalToken pToken)
     : base(pContext, pToken, FunctionUtils.DateInterval.Year)
 {
     this.ParameterList = EnterRule.GetFunctionParameters(pContext, pToken);
 }
コード例 #39
0
        public override string RenderHtml()
        {
            var  html           = new StringBuilder();
            var  inputName      = _form.FieldPrefix + _key;
            var  choicesList    = _choices.ToList();
            var  selectedValue  = string.Empty;
            bool IsAfterControl = false;

            var choicesList1 = GetChoices(_ChoicesList);

            choicesList = choicesList1.ToList();

            if (!IsValid)
            {
                var error = new TagBuilder("label");
                error.Attributes.Add("class", _errorClass);
                error.SetInnerText(Error);
                html.Append(error.ToString());
            }
            string IsHiddenStyle      = "";
            string IsHighlightedStyle = "";

            //if (_IsHidden)
            //{
            //    //IsHiddenStyle = "visibility:hidden";
            //    IsHiddenStyle = "display:none";
            //}
            if (_IsHighlighted)
            {
                IsHighlightedStyle = "background:yellow";
            }

            //var Div = new TagBuilder("div");
            //Div.Attributes.Add("data-role", "fieldcontain");
            //html.Append(Div.ToString(TagRenderMode.StartTag));

            var fieldset = new TagBuilder("fieldset");

            fieldset.Attributes.Add("data-role", "controlgroup");

            html.Append(fieldset.ToString(TagRenderMode.StartTag));

            var legend = new TagBuilder("legend");

            legend.SetInnerText(Prompt);

            StringBuilder StyleValues = new StringBuilder();

            // StyleValues.Append(GetControlStyle(_fontstyle.ToString(), _promptTop.ToString(), _promptLeft.ToString(), null, Height.ToString(), IsHidden));
            // legend.Attributes.Add("style", StyleValues.ToString());
            html.Append(legend.ToString());



            for (int i = 0; i < choicesList.Count; i++)
            {
                double innerTop  = 0.0;
                double innerLeft = 0.0;
                string radId     = inputName + i;
                // if (Pattern != null && !string.IsNullOrEmpty(Pattern[0]))
                if ((Pattern.Count) == choicesList.Count)
                {
                    List <string> TopLeft = Pattern[i].ToString().Split(':').ToList();

                    if (TopLeft.Count > 0)
                    {
                        innerTop  = double.Parse(TopLeft[0]) * Height;
                        innerLeft = double.Parse(TopLeft[1]) * Width;
                    }
                }


                var rad = new TagBuilder("input");
                rad.Attributes.Add("type", "radio");
                rad.Attributes.Add("name", inputName);
                rad.Attributes.Add("class", inputName);
                rad.Attributes.Add("id", radId);
                //  string InputFieldStyle = GetInputFieldStyle(_InputFieldfontstyle.ToString(), _InputFieldfontSize, _InputFieldfontfamily.ToString());
                // rad.Attributes.Add("style", InputFieldStyle);

                //StringBuilder RadioButton = new StringBuilder();
                //RadioButton.Append("<input type='Radio'");
                //RadioButton.Append(" name='" + inputName + "'");
                //RadioButton.Append(" id='" + radId + "'/>");



                ////http://stackoverflow.com/questions/13492881/why-is-blur-event-not-fired-in-ios-safari-mobile-iphone-ipad
                //Changed from onblur to onchange as its not supported in IOS devices. Please refer to the link above

                ////////////Check code start//////////////////
                EnterRule FunctionObjectAfter = (EnterRule)_form.FormCheckCodeObj.GetCommand("level=field&event=after&identifier=" + _key);
                if (FunctionObjectAfter != null)
                {
                    rad.Attributes.Add("onchange", "$('#" + inputName + "').val('" + i.ToString() + "');$('#" + inputName + "').parent().next().find('input[type=hidden]')[0].value='" + i.ToString() + "'; return " + _key + "_after();"); //After
                    IsAfterControl = true;
                    // rad.Attributes.Add("onblur", "return " + _key + "_after();"); //After
                    // rad.Attributes.Add("onchange", "return " + _key + "_after(this.id);"); //After
                }
                EnterRule FunctionObjectClick = (EnterRule)_form.FormCheckCodeObj.GetCommand("level=field&event=click&identifier=" + _key);
                if (FunctionObjectClick != null)
                {
                    rad.Attributes.Add("onclick", "return " + _key + "_click(this.id);"); //click
                    IsAfterControl = true;
                }
                if (!IsAfterControl)
                {
                    rad.Attributes.Add("onchange", "$('#" + inputName + "').val('" + i.ToString() + "');"); //click
                }

                ////////////Check code end//////////////////
                rad.SetInnerText(choicesList[i].Key);
                rad.Attributes.Add("value", i.ToString());
                rad.Attributes.Add("style", IsHiddenStyle);
                if (_IsDisabled)
                {
                    rad.Attributes.Add("disabled", "disabled");
                }

                if (Value == i.ToString())
                {
                    selectedValue = Value;
                    rad.Attributes.Add("checked", "checked");
                }
                rad.MergeAttributes(_inputHtmlAttributes);
                html.Append(rad.ToString(TagRenderMode.SelfClosing));


                var rightlbl = new TagBuilder("label");
                rightlbl.Attributes.Add("for", radId);
                rightlbl.Attributes.Add("class", "label" + inputName);
                //StringBuilder StyleValues2 = new StringBuilder();
                //StyleValues2.Append(GetRadioListStyle(_fontstyle.ToString(), null, null, null, null, IsHidden));
                ////rightlbl.Attributes.Add("style", StyleValues2.ToString() + ";" + IsHighlightedStyle + ";" + IsHiddenStyle);
                //rightlbl.Attributes.Add("style",  "" + IsHighlightedStyle + ";" + IsHiddenStyle);
                rightlbl.SetInnerText(choicesList[i].Key);
                html.Append(rightlbl.ToString());
            }

            html.Append(fieldset.ToString(TagRenderMode.EndTag));
            //html.Append(Div.ToString(TagRenderMode.EndTag));

            // add hidden tag, so that a value always gets sent for select tags
            var hidden = new TagBuilder("input");

            hidden.Attributes.Add("type", "hidden");
            hidden.Attributes.Add("id", inputName);
            hidden.Attributes.Add("name", inputName);

            hidden.Attributes.Add("value", selectedValue);
            html.Append(hidden.ToString(TagRenderMode.SelfClosing));

            var wrapper = new TagBuilder(_fieldWrapper);

            wrapper.Attributes["class"] = _fieldWrapperClass;
            if (_IsHidden)
            {
                wrapper.Attributes["style"] = "display:none";
            }
            wrapper.Attributes["id"] = inputName + "_fieldWrapper";
            wrapper.InnerHtml        = html.ToString();
            return(wrapper.ToString());
        }
コード例 #40
0
        //object ReturnResult = null;

        public Rule_Assign(Rule_Context pContext, NonterminalToken pTokens) : base(pContext)
        {
            //ASSIGN <Qualified ID> '=' <Expression>
            //<Let_Statement> ::= LET Identifier '=' <Expression>
            //<Simple_Assign_Statement> ::= Identifier '=' <Expression>
            //<Assign_DLL_Statement> ::= ASSIGN <Qualified ID> '=' identifier'!'<FunctionCall>
            string[]         temp;
            NonterminalToken T;
            int  number;
            bool isNumeric;

            switch (pTokens.Rule.Lhs.ToString())
            {
            case "<Assign_Statement>":
                T = (NonterminalToken)pTokens.Tokens[1];
                if (T.Symbol.ToString() == "<Fully_Qualified_Id>")
                {
                    temp             = this.ExtractTokens(T.Tokens).Split(' ');
                    this.Namespace   = T.Tokens[0].ToString();
                    this.QualifiedId = this.GetCommandElement(T.Tokens, 2);
                }
                else
                {
                    this.QualifiedId = this.GetCommandElement(T.Tokens, 0);
                }
                this.value = EnterRule.BuildStatments(pContext, pTokens.Tokens[3]);


                if (pContext.IsVariableValidationEnable)
                {
                    for (int i = 0; pTokens.Tokens.Length > i; i++)
                    {
                        var IdentifierList = this.GetCommandElement(pTokens.Tokens, i).ToString().Split(' ');
                        IdentifierList = RemoveOp(IdentifierList);
                        if (IdentifierList.Length > 0)
                        {
                            foreach (var Identifier in IdentifierList)
                            {
                                isNumeric = int.TryParse(Identifier, out number);
                                if (!string.IsNullOrEmpty(Identifier) && !this.Context.CommandVariableCheck.ContainsKey(Identifier.ToLowerInvariant()) && !isNumeric)
                                {
                                    this.Context.CommandVariableCheck.Add(Identifier, "assign");
                                }
                            }
                        }
                    }
                }


                break;

            case "<Let_Statement>":
                T = (NonterminalToken)pTokens.Tokens[1];
                if (T.Symbol.ToString() == "<Fully_Qualified_Id>")
                {
                    temp             = this.ExtractTokens(T.Tokens).Split(' ');
                    this.Namespace   = T.Tokens[0].ToString();
                    this.QualifiedId = this.GetCommandElement(T.Tokens, 2);
                }
                else
                {
                    this.QualifiedId = this.GetCommandElement(T.Tokens, 0);
                }


                this.value = EnterRule.BuildStatments(pContext, pTokens.Tokens[3]);
                if (pContext.IsVariableValidationEnable)
                {
                    for (int i = 0; pTokens.Tokens.Length > i; i++)
                    {
                        var IdentifierList = this.GetCommandElement(pTokens.Tokens, i).ToString().Split(' ');
                        IdentifierList = RemoveOp(IdentifierList);
                        if (IdentifierList.Length > 0)
                        {
                            foreach (var Identifier in IdentifierList)
                            {
                                isNumeric = int.TryParse(Identifier, out number);
                                if (!string.IsNullOrEmpty(Identifier) && !this.Context.CommandVariableCheck.ContainsKey(Identifier.ToLowerInvariant()) && !isNumeric)
                                {
                                    this.Context.CommandVariableCheck.Add(Identifier, "assign");
                                }
                            }
                        }
                    }
                }
                break;

            case "<Simple_Assign_Statement>":
                //Identifier '=' <Expression>
                //T = (NonterminalToken)pTokens.Tokens[1];
                T = (NonterminalToken)pTokens.Tokens[0];
                if (T.Symbol.ToString() == "<Fully_Qualified_Id>")
                {
                    temp             = this.ExtractTokens(T.Tokens).Split(' ');
                    this.Namespace   = T.Tokens[0].ToString();
                    this.QualifiedId = this.GetCommandElement(T.Tokens, 2);
                }
                else if (T.Symbol.ToString() == "<GridFieldId>")
                {
                    /*<GridFieldId> ::= Identifier'[' <Number>',' Identifier ']'
                     | Identifier '[' <Number> ',' <Number> ']'
                     | Identifier '[' <Number> ',' <Literal_String> ']'*/
                    this.QualifiedId = this.GetCommandElement(T.Tokens, 0);
                    int Int_temp;
                    if (int.TryParse(this.GetCommandElement(T.Tokens, 2), out Int_temp))
                    {
                        this.Index0 = Int_temp;
                    }


                    if (int.TryParse(this.GetCommandElement(T.Tokens, 4), out Int_temp))
                    {
                        this.Index1 = Int_temp;
                    }
                    else
                    {
                        //this.Index1 = this.GetCommandElement(T.Tokens, 4);
                        //this.Index1 = this.ExtractTokens(((NonterminalToken)T.Tokens[4]).Tokens);
                        this.Index1 = new Rule_Value(this.Context, T.Tokens[4]);
                    }
                    this.value = EnterRule.BuildStatments(pContext, pTokens.Tokens[2]);
                    break;
                }
                else
                {
                    this.QualifiedId = this.GetCommandElement(T.Tokens, 0);
                }


                this.value = EnterRule.BuildStatments(pContext, pTokens.Tokens[2]);
                if (pContext.IsVariableValidationEnable)
                {
                    if (!string.IsNullOrEmpty(this.QualifiedId) && !this.Context.CommandVariableCheck.ContainsKey(this.QualifiedId.ToLowerInvariant()))
                    {
                        this.Context.CommandVariableCheck.Add(this.QualifiedId.ToLowerInvariant(), this.QualifiedId.ToLowerInvariant());
                    }
                }
                break;
            }
        }
コード例 #41
0
ファイル: Rule_Statement.cs プロジェクト: zlmone/epi-info-web
        public Rule_Statement(Rule_Context pContext, NonterminalToken pToken) : base(pContext)
        {
            if (pToken.Tokens[0] is TerminalToken)
            {
                return;
            }
            NonterminalToken T = (NonterminalToken)pToken.Tokens[0];

            this.Context.ProgramText.Append(pToken.Tokens[0].ToString());

            this.reduction = EnterRule.BuildStatments(pContext, T);

            //switch (pToken.Rule.Rhs[0].ToString())
            //{
            //    // H1N1
            //    case "<Always_Statement>":
            //        this.reduction = new Rule_Always(pContext, T);
            //        break;

            //    case "<Simple_Assign_Statement>":
            //    case "<Let_Statement>":
            //    case "<Assign_Statement>":
            //        this.reduction = new Rule_Assign(pContext, T);
            //        break;
            //    case "<Assign_DLL_Statement>":
            //        this.reduction = new Rule_Assign_DLL_Statement(pContext, T);
            //        break;
            //    case "<If_Statement>":
            //    case "<If_Else_Statement>":
            //        this.reduction = new Rule_If_Then_Else_End(pContext, T);
            //        break;

            //    case "<Define_Variable_Statement>":
            //        this.reduction = new Rule_Define(pContext, T);
            //        break;

            //    case "<FunctionCall>":
            //        this.reduction = new Rule_FunctionCall(pContext, T);
            //        break;

            //    case "<Hide_Some_Statement>":
            //    case "<Hide_Except_Statement>":
            //        this.reduction = new Rule_Hide(pContext, T);
            //        break;

            //    case "<Unhide_Some_Statement>":
            //    case "<Unhide_Except_Statement>":
            //        this.reduction = new Rule_UnHide(pContext, T);
            //        break;

            //    case "<Go_To_Variable_Statement>":
            //    case "<Go_To_Page_Statement>":
            //        this.reduction = new Rule_GoTo(pContext, T);
            //        break;

            //    case "<Simple_Dialog_Statement>":
            //    case "<Numeric_Dialog_Implicit_Statement>":
            //    case "<Numeric_Dialog_Explicit_Statement>":
            //    case "<TextBox_Dialog_Statement>":
            //    case "<Db_Values_Dialog_Statement>":
            //    case "<YN_Dialog_Statement>":
            //    case "<Db_Views_Dialog_Statement>":
            //    case "<Databases_Dialog_Statement>":
            //    case "<Db_Variables_Dialog_Statement>":
            //    case "<Multiple_Choice_Dialog_Statement>":
            //    case "<Dialog_Read_Statement>":
            //    case "<Dialog_Write_Statement>":
            //    case "<Dialog_Read_Filter_Statement>":
            //    case "<Dialog_Write_Filter_Statement>":
            //    case "<Dialog_Date_Statement>":
            //    case "<Dialog_Date_Mask_Statement>":
            //        this.reduction = new Rule_Dialog(pContext, T);
            //        break;
            //    //case "<Comment_Line>":
            //    //    this.reduction = new Rule_CommentLine(pContext, T);
            //    //    break;
            //    case "<Simple_Execute_Statement>":
            //    case "<Execute_File_Statement>":
            //    case "<Execute_Url_Statement>":
            //    case "<Execute_Wait_For_Exit_File_Statement>":
            //    case "<Execute_Wait_For_Exit_String_Statement>":
            //    case "<Execute_Wait_For_Exit_Url_Statement>":
            //    case "<Execute_No_Wait_For_Exit_File_Statement>":
            //    case "<Execute_No_Wait_For_Exit_String_Statement>":
            //    case "<Execute_No_Wait_For_Exit_Url_Statement>":
            //        this.reduction = new Rule_Execute(pContext, T);
            //        break;
            //    case "<Beep_Statement>":
            //        this.reduction = new Rule_Beep(pContext, T);
            //        break;
            //    case "<Auto_Search_Statement>":
            //        this.reduction = new Rule_AutoSearch(pContext, T);
            //        break;
            //    case "<Quit_Statement>":
            //        this.reduction = new Rule_Quit(pContext);
            //        break;
            //    case "<Clear_Statement>":
            //        this.reduction = new Rule_Clear(pContext, T);
            //        break;
            //    case "<New_Record_Statement>":
            //        this.reduction = new Rule_NewRecord(pContext, T);
            //        break;
            //    case "<Simple_Undefine_Statement>":
            //        this.reduction = new Rule_Undefine(pContext, T);
            //        break;
            //    case "<Geocode_Statement>":
            //        this.reduction = new Rule_Geocode(pContext, T);
            //        break;
            //    case "<DefineVariables_Statement>":
            //        this.reduction = new Rule_DefineVariables_Statement(pContext, T);
            //        break;
            //    case "<Field_Checkcode_Statement>":
            //        this.reduction = new Rule_Field_Checkcode_Statement(pContext, T);
            //        break;
            //    case "<View_Checkcode_Statement>":
            //        this.reduction = new Rule_View_Checkcode_Statement(pContext, T);
            //        break;
            //    case "<Record_Checkcode_Statement>":
            //        this.reduction = new Rule_Record_Checkcode_Statement(pContext, T);
            //        break;
            //    case "<Page_Checkcode_Statement>":
            //        this.reduction = new Rule_Page_Checkcode_Statement(pContext, T);
            //        break;
            //    case "<Subroutine_Statement>":
            //        this.reduction = new Rule_Subroutine_Statement(pContext, T);
            //        break;
            //    case "<Call_Statement>":
            //        this.reduction = new Rule_Call(pContext, T);
            //        break;
            //    case "<Simple_Run_Statement>":
            //    default:
            //        break;
            //}
        }
コード例 #42
0
        public override string RenderHtml()
        {
            var    html       = new StringBuilder();
            var    inputName  = _form.FieldPrefix + _key;
            string ErrorStyle = string.Empty;
            // prompt label
            var prompt = new TagBuilder("label");

            prompt.SetInnerText(Prompt);
            prompt.Attributes.Add("for", inputName);
            prompt.Attributes.Add("Id", "label" + inputName);
            prompt.Attributes.Add("class", "EpiLabel");

            StringBuilder StyleValues = new StringBuilder();

            StyleValues.Append(GetContolStyle(_fontstyle.ToString(), _Prompttop.ToString(), _Promptleft.ToString(), null, Height.ToString(), _IsHidden));
            prompt.Attributes.Add("style", StyleValues.ToString());
            html.Append(prompt.ToString());

            // error label
            if (!IsValid)
            {
                ErrorStyle = ";border-color: red";
            }

            // input element
            var txt = new TagBuilder("input");

            txt.Attributes.Add("name", inputName);
            txt.Attributes.Add("id", inputName);
            txt.Attributes.Add("type", "text");
            txt.Attributes.Add("value", Value);
            ////////////Check code start//////////////////
            EnterRule FunctionObjectAfter = (EnterRule)_form.FormCheckCodeObj.GetCommand("level=field&event=after&identifier=" + _key);
            //if (FunctionObjectAfter != null && !FunctionObjectAfter.IsNull())
            //{
            //txt.Attributes.Add("onblur", "return " + _key + "_after();"); //After
            //}
            EnterRule FunctionObjectBefore = (EnterRule)_form.FormCheckCodeObj.GetCommand("level=field&event=before&identifier=" + _key);

            if (FunctionObjectBefore != null && !FunctionObjectBefore.IsNull())
            {
                txt.Attributes.Add("onfocus", "return " + _key + "_before();"); //Before
            }

            ////////////Check code end//////////////////

            if (_MaxLength.ToString() != "0" && !string.IsNullOrEmpty(_MaxLength.ToString()))
            {
                txt.Attributes.Add("MaxLength", _MaxLength.ToString());
            }
            string IsHiddenStyle      = "";
            string IsHighlightedStyle = "";

            if (_IsHidden)
            {
                IsHiddenStyle = "display:none";
            }
            if (_IsHighlighted)
            {
                IsHighlightedStyle = "background-color:yellow";
            }

            //if (_IsDisabled)
            //{
            //    txt.Attributes.Add("disabled", "disabled");
            //}
            txt.Attributes.Add("class", GetControlClass(Value));

            string InputFieldStyle = GetInputFieldStyle(_InputFieldfontstyle.ToString(), _InputFieldfontSize, _InputFieldfontfamily.ToString());

            txt.Attributes.Add("style", "position:absolute;left:" + _left.ToString() + "px;top:" + _top.ToString() + "px" + ";width:" + _ControlWidth.ToString() + "px" + ErrorStyle + ";" + IsHiddenStyle + ";" + IsHighlightedStyle + ";" + InputFieldStyle);

            txt.MergeAttributes(_inputHtmlAttributes);
            html.Append(txt.ToString(TagRenderMode.SelfClosing));

            // If readonly then add the following jquery script to make the field disabled
            if (ReadOnly || _IsDisabled)
            {
                var scriptReadOnlyText = new TagBuilder("script");
                //scriptReadOnlyText.InnerHtml = "$(function(){$('#" + inputName + "').attr('disabled','disabled')});";
                scriptReadOnlyText.InnerHtml = "$(function(){  var List = new Array();List.push('" + _key + "');CCE_Disable(List, false);});";
                html.Append(scriptReadOnlyText.ToString(TagRenderMode.Normal));
            }
            // adding scripts for date picker
            var scriptDatePicker = new TagBuilder("script");
            //scriptDatePicker.InnerHtml = "$(function() { $('#" + inputName + "').datepicker({changeMonth: true,changeYear: true});});";

            /*Checkcode control after event...for datepicker, the onblur event fires on selecting a date from calender. Since the datepicker control itself is tied to after event which was firing before the datepicker
             * textbox is populated the comparison was not working. For this reason, the control after steps are interjected inside datepicker onClose event, so the after event is fired when the datepicker is populated
             */
            var MinYear = -110;
            var MaxYear = 10;

            if (!string.IsNullOrEmpty(Lower) && !string.IsNullOrEmpty(Upper))
            {
                int Year_Lower = GetYear(Lower, Pattern);
                int Year_Upper = GetYear(Upper, Pattern);

                MinYear = -(DateTime.Now.Year - Year_Lower);
                MaxYear = Year_Upper - DateTime.Now.Year;
            }
            if (FunctionObjectAfter != null && !FunctionObjectAfter.IsNull())
            {
                //scriptDatePicker.InnerHtml = "$('#" + inputName + "').datepicker({onClose:function(){" + _key + "_after();},changeMonth:true,changeYear:true});";
                //Note: datepicker seems to have a command inst.input.focus(); (I think) called after the onClose callback which resets the focus to the original input element. I'm wondering if there is way round this with bind().
                //http://stackoverflow.com/questions/7087987/change-the-focus-on-jqueryui-datepicker-on-close
                scriptDatePicker.InnerHtml = "$('#" + inputName + "').datepicker({onClose:function(){setTimeout(" + _key + "_after,100);},changeMonth:true,changeYear:true,yearRange:'" + MinYear + ":+" + MaxYear + "'});";
            }
            else
            {
                scriptDatePicker.InnerHtml = "$('#" + inputName + "').datepicker({changeMonth: true,changeYear: true,yearRange:'" + MinYear + ":+" + MaxYear + "'});";
            }


            html.Append(scriptDatePicker.ToString(TagRenderMode.Normal));

            //prevent date picker control to submit on enter click
            var scriptBuilder = new TagBuilder("script");

            scriptBuilder.InnerHtml = "$('#" + inputName + "').BlockEnter('" + inputName + "');";
            scriptBuilder.ToString(TagRenderMode.Normal);
            html.Append(scriptBuilder.ToString(TagRenderMode.Normal));

            var wrapper = new TagBuilder(_fieldWrapper);

            wrapper.Attributes["class"] = _fieldWrapperClass;
            if (_IsHidden)
            {
                wrapper.Attributes["style"] = "display:none";
            }
            wrapper.Attributes["id"] = inputName + "_fieldWrapper";
            wrapper.InnerHtml        = html.ToString();
            return(wrapper.ToString());
        }
コード例 #43
0
        public override string RenderHtml()
        {
            var    html       = new StringBuilder();
            var    inputName  = _form.FieldPrefix + _key;
            string ErrorStyle = string.Empty;
            //prompt label
            var prompt = new TagBuilder("label");

            prompt.SetInnerText(Prompt);
            prompt.Attributes.Add("for", inputName);
            prompt.Attributes.Add("class", "EpiLabel");
            prompt.Attributes.Add("Id", "label" + inputName);
            StringBuilder StyleValues = new StringBuilder();

            StyleValues.Append(GetContolStyle(_fontstyle.ToString(), _promptTop.ToString(), _promptLeft.ToString(), null, Height.ToString(), IsHidden));
            prompt.Attributes.Add("style", StyleValues.ToString());
            html.Append(prompt.ToString());
            // error label
            if (!IsValid)
            {
                //Add new Error to the error Obj

                ErrorStyle = ";border-color: red";
            }

            // input element
            var txt = new TagBuilder("textarea");

            txt.Attributes.Add("name", inputName);
            txt.Attributes.Add("id", inputName);
            // txt.SetInnerText(Value);
            ////////////Check code start//////////////////
            EnterRule FunctionObjectAfter = (EnterRule)_form.FormCheckCodeObj.GetCommand("level=field&event=after&identifier=" + _key);

            if (FunctionObjectAfter != null && !FunctionObjectAfter.IsNull())
            {
                txt.Attributes.Add("onblur", "return " + _key + "_after();"); //After
            }
            EnterRule FunctionObjectBefore = (EnterRule)_form.FormCheckCodeObj.GetCommand("level=field&event=before&identifier=" + _key);

            if (FunctionObjectBefore != null && !FunctionObjectBefore.IsNull())
            {
                txt.Attributes.Add("onfocus", "return " + _key + "_before();"); //Before
            }

            ////////////Check code end//////////////////
            txt.SetInnerText(Value);
            //txt.Attributes.Add("class", GetControlClass() + "text-input");
            txt.Attributes.Add("class", GetControlClass());
            if (_isRequired == true)
            {
                // txt.Attributes.Add("class", "validate[required] text-input");
                txt.Attributes.Add("data-prompt-position", "topRight:15");
            }
            string IsHiddenStyle      = "";
            string IsHighlightedStyle = "";

            if (_IsHidden)
            {
                IsHiddenStyle = "display:none";
            }
            if (_IsHighlighted)
            {
                IsHighlightedStyle = "background-color:yellow";
            }

            //if (_IsDisabled)
            //{
            //    txt.Attributes.Add("disabled", "disabled");
            //}
            string InputFieldStyle = GetInputFieldStyle(_InputFieldfontstyle.ToString(), _InputFieldfontSize, _InputFieldfontfamily.ToString());

            txt.Attributes.Add("style", "position:absolute;left:" + _left.ToString() + "px;top:" + _top.ToString() + "px" + ";width:" + _controlWidth.ToString() + "px" + ";height:" + _controlHeight.ToString() + "px" + ErrorStyle + ";" + IsHiddenStyle + ";" + IsHighlightedStyle + ";" + InputFieldStyle);
            txt.MergeAttributes(_inputHtmlAttributes);
            html.Append(txt.ToString());


            // If readonly then add the following jquery script to make the field disabled
            if (ReadOnly || _IsDisabled)
            {
                var scriptReadOnlyText = new TagBuilder("script");
                //scriptReadOnlyText.InnerHtml = "$(function(){$('#" + inputName + "').attr('disabled','disabled')});";
                scriptReadOnlyText.InnerHtml = "$(function(){  var List = new Array();List.push('" + _key + "');CCE_Disable(List, false);});";
                html.Append(scriptReadOnlyText.ToString(TagRenderMode.Normal));
            }

            var wrapper = new TagBuilder(_fieldWrapper);

            wrapper.Attributes["class"] = _fieldWrapperClass;
            if (_IsHidden)
            {
                wrapper.Attributes["style"] = "display:none";
            }
            wrapper.Attributes["id"] = inputName + "_fieldWrapper";
            wrapper.InnerHtml        = html.ToString();
            return(wrapper.ToString());
        }
コード例 #44
0
        /// <summary>
        /// Constructor for Rule_FunctionCall
        /// </summary>
        /// <param name="pToken">The token to build the reduction with.</param>
        public Rule_FunctionCall(Rule_Context pContext, NonterminalToken pToken) : base(pContext)
        {
            /*
            <FunctionCall> ::= <FuncName1> '(' <FunctionParameterList> ')'
			    | <FuncName1> '(' <FunctionCall> ')' 
			    | <FuncName2>
             */
       
            NonterminalToken T;
            if (pToken.Tokens.Length == 1)
            {
                if (pToken.Rule.ToString().Equals("<FunctionCall>"))
                {
                    T = (NonterminalToken)pToken.Tokens[0];
                }
                else
                {
                    T = pToken;
                }
            }
            else
            {
                T = (NonterminalToken)pToken.Tokens[2];
            }


            string temp = null;
            string[] temp2 = null;

            if (pToken.Tokens[0] is NonterminalToken)
            {
                temp = this.ExtractTokens(((NonterminalToken)pToken.Tokens[0]).Tokens).Replace(" . ", ".");
                temp2 = temp.Split('.');

            }
            else
            {
                temp = ((TerminalToken)pToken.Tokens[0]).Text.Replace(" . ", ".");
            }

            if(temp2 != null && temp2.Length > 1)
            {
                this.ClassName = temp2[0].Trim();
                this.MethodName = temp2[1].Trim();

                this.ParameterList = EnterRule.GetFunctionParameters(pContext, (NonterminalToken)pToken.Tokens[2]);
            }
            else
            {
                functionName = this.GetCommandElement(pToken.Tokens, 0).ToString();

                switch (functionName.ToUpperInvariant())
                {
                    case "ABS":
                        functionCall = new Rule_Abs(pContext, T);
                        break;
                    case "COS":
                        functionCall = new Rule_Cos(pContext, T);
                        break;
                    case "CURRENTUSER":
                        functionCall = new Rule_CurrentUser(pContext, T);
                        break;
                    case "DAY":
                        functionCall = new Rule_Day(pContext, T);
                        break;
                    case "DAYS":
                        functionCall = new Rule_Days(pContext, T);
                        break;
                    case "FORMAT":
                        functionCall = new Rule_Format(pContext, T);
                        break;
                    case "HOUR":
                        functionCall = new Rule_Hour(pContext, T);
                        break;
                    case "HOURS":
                        functionCall = new Rule_Hours(pContext, T);
                        break;
                    case "ISUNIQUE":
                        functionCall = new Rule_IsUnique(pContext, T);
                        break;
                    case "LINEBREAK":
                        functionCall = new Rule_LineBreak(pContext, T);
                        break;
                    case "MINUTE":
                        functionCall = new Rule_Minute(pContext, T);
                        break;
                    case "MINUTES":
                        functionCall = new Rule_Minutes(pContext, T);
                        break;
                    case "MONTH":
                        functionCall = new Rule_Month(pContext, T);
                        break;
                    case "MONTHS":
                        functionCall = new Rule_Months(pContext, T);
                        break;
                    case "NUMTODATE":
                        functionCall = new Rule_NumToDate(pContext, T);
                        break;
                    case "NUMTOTIME":
                        functionCall = new Rule_NumToTime(pContext, T);
                        break;
                    case "RECORDCOUNT":
                        functionCall = new Rule_RecordCount(pContext, T);
                        break;
                    case "SECOND":
                        functionCall = new Rule_Second(pContext, T);
                        break;
                    case "SECONDS":
                        functionCall = new Rule_Seconds(pContext, T);
                        break;
                    case "SQRT":
                        functionCall = new Rule_SQRT_Func(pContext, T);
                        break;
                    case "SYSBARCODE":
                        functionCall = new Rule_SystemBarcode(pContext, T);
                        break;
                    case "SYSLATITUDE":
                        functionCall = new Rule_SystemLatitude(pContext, T);
                        break;
                    case "SYSLONGITUDE":
                        functionCall = new Rule_SystemLongitude(pContext, T);
                        break;
                    case "SYSALTITUDE":
                        functionCall = new Rule_SystemAltitude(pContext, T);
                        break;
                    case "SYSTEMDATE":
                        functionCall = new Rule_SystemDate(pContext, T);
                        break;
                    case "SYSTEMTIME":
                        functionCall = new Rule_SystemTime(pContext, T);
                        break;
                    case "TXTTODATE":
                        functionCall = new Rule_TxtToDate(pContext, T);
                        break;
                    case "TXTTONUM":
                        functionCall = new Rule_TxtToNum(pContext, T);
                        break;
                    case "YEAR":
                        functionCall = new Rule_Year(pContext, T);
                        break;
                    case "YEARS":
                        functionCall = new Rule_Years(pContext, T);
                        break;
                    case "SUBSTRING":
                        functionCall = new Rule_Substring(pContext, T);
                        break;
                    case "RND":
                        functionCall = new Rule_Rnd(pContext, T);
                        break;
                    case "EXP":
                        functionCall = new Rule_Exp_Func(pContext, T);
                        break;
                    case "LN":
                        functionCall = new Rule_LN_Func(pContext, T);
                        break;
                    case "ROUND":
                        functionCall = new Rule_Round(pContext, T);
                        break;
                    case "LOG":
                        functionCall = new Rule_LOG_Func(pContext, T);
                        break;
                    case "SIN":
                        functionCall = new Rule_Sin(pContext, T);
                        break;
                    case "TAN":
                        functionCall = new Rule_Tan(pContext, T);
                        break;
                    case "TRUNC":
                        functionCall = new Rule_TRUNC(pContext, T);
                        break;
                    case "STEP":
                        functionCall = new Rule_Step(pContext, T);
                        break;
                    case "UPPERCASE":
                        functionCall = new Rule_UpperCase(pContext, T);
                        break;
                    case "FINDTEXT":
                        functionCall = new Rule_FindText(pContext, T);
                        break;
                    case "ENVIRON":
                        functionCall = new Rule_FindText(pContext, T);
                        break;
                    case "EXISTS":
                        functionCall = new Rule_Exists(pContext, T);
                        break;
                    case "FILEDATE":
                        functionCall = new Rule_FileDate(pContext, T);
                        break;
                    case "ZSCORE":
                        functionCall = new Rule_ZSCORE(pContext, T);
                        break;
                    case "PFROMZ":
                        functionCall = new Rule_PFROMZ(pContext, T);
                        break;
                    case "EPIWEEK":
                        functionCall = new Rule_EPIWEEK(pContext, T);
                        break;
                    case "STRLEN":
                        functionCall = new Rule_STRLEN(pContext, T);
                        break;
                    case "GETCOORDINATES":
                        functionCall = new Rule_GetCoordinates(pContext, T);
                        break;
                    case "SENDSMS":
                        functionCall = new Rule_SendSMS(pContext, T);
                        break;
                    default:
                        throw new Exception("Function name " + functionName.ToUpperInvariant() + " is not a recognized function.");
                }
            }

        }
コード例 #45
0
        public override string RenderHtml()
        {
            string name       = "mvcdynamicfield_" + _key;
            var    html       = new StringBuilder();
            string ErrorStyle = string.Empty;

            var commandButtonTag = new TagBuilder("button");

            //commandButtonTag.Attributes.Add("text", Prompt);
            commandButtonTag.InnerHtml = Prompt;
            commandButtonTag.Attributes.Add("id", name);
            commandButtonTag.Attributes.Add("name", "Relate");
            //commandButtonTag.Attributes.Add("name", name);
            commandButtonTag.Attributes.Add("type", "button");

            commandButtonTag.Attributes.Add("onclick", "NavigateToChild(" + RelatedViewId + ");");
            string IsHiddenStyle      = "";
            string IsHighlightedStyle = "";

            if (_IsHidden)
            {
                IsHiddenStyle = "display:none";
            }

            if (_IsHighlighted)
            {
                IsHighlightedStyle = "background-color:yellow";
            }

            if (_IsDisabled)
            {
                commandButtonTag.Attributes.Add("disabled", "disabled");
            }

            // commandButtonTag.Attributes.Add("style", "position:absolute;left:" + _left.ToString() + "px;top:" + _top.ToString() + "px" + ";width:" + _Width.ToString() + "px" + ";height:" + _Height.ToString() + "px" + ErrorStyle + ";" + IsHiddenStyle + ";" + IsHighlightedStyle);
            commandButtonTag.Attributes.Add("style", "position:absolute;left:" + _left.ToString() + "px;top:" + _top.ToString() + "px" + ";width:" + ControlWidth.ToString() + "px" + ";height:" + ControlHeight.ToString() + "px" + ErrorStyle + ";" + IsHiddenStyle + ";" + IsHighlightedStyle);
            EnterRule FunctionObjectAfter = (EnterRule)_form.FormCheckCodeObj.GetCommand("level=field&event=after&identifier=" + _key);

            if (FunctionObjectAfter != null && !FunctionObjectAfter.IsNull())
            {
                commandButtonTag.Attributes.Add("onblur", "return " + _key + "_after();"); //After
            }
            EnterRule FunctionObjectBefore = (EnterRule)_form.FormCheckCodeObj.GetCommand("level=field&event=before&identifier=" + _key);

            if (FunctionObjectBefore != null && !FunctionObjectBefore.IsNull())
            {
                commandButtonTag.Attributes.Add("onfocus", "return " + _key + "_before();"); //Before
            }
            EnterRule FunctionObjectClick = (EnterRule)_form.FormCheckCodeObj.GetCommand("level=field&event=click&identifier=" + _key);

            if (FunctionObjectClick != null && !FunctionObjectClick.IsNull())
            {
                commandButtonTag.Attributes.Add("onclick", "return " + _key + "_click();");
            }

            //   html.Append(commandButtonTag.ToString(TagRenderMode.SelfClosing));
            html.Append(commandButtonTag.ToString());
            var scriptBuilder = new TagBuilder("script");

            scriptBuilder.InnerHtml = "$('#" + name + "').BlockEnter('" + name + "');";
            scriptBuilder.ToString(TagRenderMode.Normal);
            html.Append(scriptBuilder.ToString(TagRenderMode.Normal));

            var wrapper = new TagBuilder(_fieldWrapper);

            wrapper.Attributes["class"] = _fieldWrapperClass;
            if (_IsHidden)
            {
                wrapper.Attributes["style"] = "display:none";
            }
            wrapper.Attributes["id"] = name + "_fieldWrapper";
            wrapper.InnerHtml        = html.ToString();
            return(wrapper.ToString());
        }
コード例 #46
0
ファイル: Rule_Always.cs プロジェクト: NALSS/epiinfo-82474
 public Rule_Always(Rule_Context pContext, NonterminalToken pToken)
     : base(pContext)
 {
     // ALWAYS <Statements> END
     this.statements = EnterRule.BuildStatments(pContext, pToken.Tokens[1]);
 }
コード例 #47
0
        public override string RenderHtml()
        {
            var    inputName  = _form.FieldPrefix + _key;
            var    html       = new StringBuilder();
            string ErrorStyle = string.Empty;

            // error label
            if (!IsValid)
            {
                //Add new Error to the error Obj
                ErrorStyle = ";border-color: red";
            }

            // checkbox input
            var chk = new TagBuilder("input");

            chk.Attributes.Add("id", inputName);
            chk.Attributes.Add("name", inputName);
            chk.Attributes.Add("type", "checkbox");
            if (Checked)
            {
                chk.Attributes.Add("checked", "checked");
            }
            chk.Attributes.Add("value", bool.TrueString);
            string IsHiddenStyle      = "";
            string IsHighlightedStyle = "";

            if (_IsHidden)
            {
                IsHiddenStyle = "display:none";
            }
            if (_IsHighlighted)
            {
                IsHighlightedStyle = "background-color:yellow";
            }

            //if (_IsDisabled)
            //{
            //    chk.Attributes.Add("disabled", "disabled");
            //}

            chk.Attributes.Add("style", "position:absolute;left:" + _left.ToString() + "px;top:" + _top.ToString() + "px" + ";width:" + _ControlWidth.ToString() + "px" + ErrorStyle + ";" + IsHiddenStyle + ";");

            chk.MergeAttributes(_inputHtmlAttributes);
            ////////////Check code start//////////////////
            EnterRule FunctionObjectAfter = (EnterRule)_form.FormCheckCodeObj.GetCommand("level=field&event=after&identifier=" + _key);

            if (FunctionObjectAfter != null && !FunctionObjectAfter.IsNull())
            {
                chk.Attributes.Add("onblur", "return " + _key + "_after();"); //After
            }
            EnterRule FunctionObjectBefore = (EnterRule)_form.FormCheckCodeObj.GetCommand("level=field&event=before&identifier=" + _key);

            if (FunctionObjectBefore != null && !FunctionObjectBefore.IsNull())
            {
                chk.Attributes.Add("onfocus", "return " + _key + "_before();"); //Before
            }


            EnterRule FunctionObjectClick = (EnterRule)_form.FormCheckCodeObj.GetCommand("level=field&event=click&identifier=" + _key);

            if (FunctionObjectClick != null && !FunctionObjectClick.IsNull())
            {
                chk.Attributes.Add("onclick", "return " + _key + "_click();");
            }



            ////////////Check code end//////////////////
            html.Append(chk.ToString(TagRenderMode.SelfClosing));

            // prompt label
            var prompt = new TagBuilder("label");

            prompt.SetInnerText(Prompt);
            prompt.Attributes.Add("for", inputName);
            prompt.Attributes.Add("class", "EpiLabel");
            prompt.Attributes.Add("Id", "label" + inputName);
            StringBuilder StyleValues = new StringBuilder();

            StyleValues.Append(GetContolStyle(_fontstyle.ToString(), _Prompttop.ToString(), _Promptleft.ToString(), null, null, IsHidden));
            prompt.Attributes.Add("style", StyleValues.ToString() + " ; " + IsHighlightedStyle);
            html.Append(prompt.ToString());
            if (ReadOnly || _IsDisabled)
            {
                var scriptReadOnlyText = new TagBuilder("script");
                //scriptReadOnlyText.InnerHtml = "$(function(){$('#" + inputName + "').attr('disabled','disabled')});";
                scriptReadOnlyText.InnerHtml = "$(function(){  var List = new Array();List.push('" + _key + "');CCE_Disable(List, false);});";
                html.Append(scriptReadOnlyText.ToString(TagRenderMode.Normal));
            }

            // hidden input (so that value is posted when checkbox is unchecked)
            var hdn = new TagBuilder("input");

            hdn.Attributes.Add("type", "hidden");
            hdn.Attributes.Add("id", inputName + "_hidden");
            hdn.Attributes.Add("name", inputName);
            hdn.Attributes.Add("value", bool.FalseString);
            ////////////Check code start//////////////////
            //EnterRule FunctionObjectAfter = (EnterRule)_form.FormCheckCodeObj.GetCommand("level=field&event=after&identifier=" + _key);
            //if (FunctionObjectAfter != null && !FunctionObjectAfter.IsNull())
            //{
            //    hdn.Attributes.Add("onblur", "return " + _key + "_after();"); //After
            //}
            //EnterRule FunctionObjectBefore = (EnterRule)_form.FormCheckCodeObj.GetCommand("level=field&event=before&identifier=" + _key);
            //if (FunctionObjectBefore != null && !FunctionObjectBefore.IsNull())
            //{
            //    hdn.Attributes.Add("onfocus", "return " + _key + "_before();"); //Before
            //}

            ////////////Check code end//////////////////
            html.Append(hdn.ToString(TagRenderMode.SelfClosing));


            //prevent check box control to submit on enter click
            var scriptBuilder = new TagBuilder("script");

            scriptBuilder.InnerHtml = "$('#" + inputName + "').BlockEnter('" + inputName + "');";
            scriptBuilder.ToString(TagRenderMode.Normal);
            html.Append(scriptBuilder.ToString(TagRenderMode.Normal));

            var wrapper = new TagBuilder(_fieldWrapper);

            wrapper.Attributes["class"] = _fieldWrapperClass;
            if (_IsHidden)
            {
                wrapper.Attributes["style"] = "display:none";
            }
            wrapper.Attributes["id"] = inputName + "_fieldWrapper";
            wrapper.InnerHtml        = html.ToString();
            return(wrapper.ToString());
        }
コード例 #48
0
ファイル: Rule_Statement.cs プロジェクト: NALSS/epiinfo-82474
        public Rule_Statement(Rule_Context pContext, NonterminalToken pToken)
            : base(pContext)
        {
            if (pToken.Tokens[0] is TerminalToken)
            {
                return;
            }
            NonterminalToken T = (NonterminalToken) pToken.Tokens[0];

            this.Context.ProgramText.Append(pToken.Tokens[0].ToString());

            this.reduction = EnterRule.BuildStatments(pContext, T);

            //switch (pToken.Rule.Rhs[0].ToString())
            //{
            //    // H1N1
            //    case "<Always_Statement>":
            //        this.reduction = new Rule_Always(pContext, T);
            //        break;

            //    case "<Simple_Assign_Statement>":
            //    case "<Let_Statement>":
            //    case "<Assign_Statement>":
            //        this.reduction = new Rule_Assign(pContext, T);
            //        break;
            //    case "<Assign_DLL_Statement>":
            //        this.reduction = new Rule_Assign_DLL_Statement(pContext, T);
            //        break;
            //    case "<If_Statement>":
            //    case "<If_Else_Statement>":
            //        this.reduction = new Rule_If_Then_Else_End(pContext, T);
            //        break;

            //    case "<Define_Variable_Statement>":
            //        this.reduction = new Rule_Define(pContext, T);
            //        break;

            //    case "<FunctionCall>":
            //        this.reduction = new Rule_FunctionCall(pContext, T);
            //        break;

            //    case "<Hide_Some_Statement>":
            //    case "<Hide_Except_Statement>":
            //        this.reduction = new Rule_Hide(pContext, T);
            //        break;

            //    case "<Unhide_Some_Statement>":
            //    case "<Unhide_Except_Statement>":
            //        this.reduction = new Rule_UnHide(pContext, T);
            //        break;

            //    case "<Go_To_Variable_Statement>":
            //    case "<Go_To_Page_Statement>":
            //        this.reduction = new Rule_GoTo(pContext, T);
            //        break;

            //    case "<Simple_Dialog_Statement>":
            //    case "<Numeric_Dialog_Implicit_Statement>":
            //    case "<Numeric_Dialog_Explicit_Statement>":
            //    case "<TextBox_Dialog_Statement>":
            //    case "<Db_Values_Dialog_Statement>":
            //    case "<YN_Dialog_Statement>":
            //    case "<Db_Views_Dialog_Statement>":
            //    case "<Databases_Dialog_Statement>":
            //    case "<Db_Variables_Dialog_Statement>":
            //    case "<Multiple_Choice_Dialog_Statement>":
            //    case "<Dialog_Read_Statement>":
            //    case "<Dialog_Write_Statement>":
            //    case "<Dialog_Read_Filter_Statement>":
            //    case "<Dialog_Write_Filter_Statement>":
            //    case "<Dialog_Date_Statement>":
            //    case "<Dialog_Date_Mask_Statement>":
            //        this.reduction = new Rule_Dialog(pContext, T);
            //        break;
            //    //case "<Comment_Line>":
            //    //    this.reduction = new Rule_CommentLine(pContext, T);
            //    //    break;
            //    case "<Simple_Execute_Statement>":
            //    case "<Execute_File_Statement>":
            //    case "<Execute_Url_Statement>":
            //    case "<Execute_Wait_For_Exit_File_Statement>":
            //    case "<Execute_Wait_For_Exit_String_Statement>":
            //    case "<Execute_Wait_For_Exit_Url_Statement>":
            //    case "<Execute_No_Wait_For_Exit_File_Statement>":
            //    case "<Execute_No_Wait_For_Exit_String_Statement>":
            //    case "<Execute_No_Wait_For_Exit_Url_Statement>":
            //        this.reduction = new Rule_Execute(pContext, T);
            //        break;
            //    case "<Beep_Statement>":
            //        this.reduction = new Rule_Beep(pContext, T);
            //        break;
            //    case "<Auto_Search_Statement>":
            //        this.reduction = new Rule_AutoSearch(pContext, T);
            //        break;
            //    case "<Quit_Statement>":
            //        this.reduction = new Rule_Quit(pContext);
            //        break;
            //    case "<Clear_Statement>":
            //        this.reduction = new Rule_Clear(pContext, T);
            //        break;
            //    case "<New_Record_Statement>":
            //        this.reduction = new Rule_NewRecord(pContext, T);
            //        break;
            //    case "<Simple_Undefine_Statement>":
            //        this.reduction = new Rule_Undefine(pContext, T);
            //        break;
            //    case "<Geocode_Statement>":
            //        this.reduction = new Rule_Geocode(pContext, T);
            //        break;
            //    case "<DefineVariables_Statement>":
            //        this.reduction = new Rule_DefineVariables_Statement(pContext, T);
            //        break;
            //    case "<Field_Checkcode_Statement>":
            //        this.reduction = new Rule_Field_Checkcode_Statement(pContext, T);
            //        break;
            //    case "<View_Checkcode_Statement>":
            //        this.reduction = new Rule_View_Checkcode_Statement(pContext, T);
            //        break;
            //    case "<Record_Checkcode_Statement>":
            //        this.reduction = new Rule_Record_Checkcode_Statement(pContext, T);
            //        break;
            //    case "<Page_Checkcode_Statement>":
            //        this.reduction = new Rule_Page_Checkcode_Statement(pContext, T);
            //        break;
            //    case "<Subroutine_Statement>":
            //        this.reduction = new Rule_Subroutine_Statement(pContext, T);
            //        break;
            //    case "<Call_Statement>":
            //        this.reduction = new Rule_Call(pContext, T);
            //        break;
            //    case "<Simple_Run_Statement>":
            //    default:
            //        break;
            //}
        }
コード例 #49
0
 public Rule_Abs(Rule_Context pContext, NonterminalToken pToken)
     : base(pContext)
 {
     this.ParameterList = EnterRule.GetFunctionParameters(pContext, pToken);
     AddCommandVariableCheckValue(ParameterList, "abs");
 }
コード例 #50
0
 public Rule_Rnd(Rule_Context pContext, NonterminalToken pToken)
     : base(pContext)
 {
     this.ParameterList = EnterRule.GetFunctionParameters(pContext, pToken);
 }
コード例 #51
0
ファイル: Rule_Always.cs プロジェクト: zlmone/epi-info-web
 public Rule_Always(Rule_Context pContext, NonterminalToken pToken) : base(pContext)
 {
     // ALWAYS <Statements> END
     this.statements = EnterRule.BuildStatments(pContext, pToken.Tokens[1]);
 }
コード例 #52
0
        public override string RenderHtml()
        {
            var    html       = new StringBuilder();
            var    inputName  = _form.FieldPrefix + _key;
            string ErrorStyle = string.Empty;
            // prompt label
            var prompt = new TagBuilder("label");

            prompt.SetInnerText(Prompt);
            prompt.Attributes.Add("for", inputName);
            prompt.Attributes.Add("Id", "label" + inputName);
            //  prompt.Attributes.Add("class", _promptClass);
            prompt.Attributes.Add("class", "EpiLabel");

            StringBuilder StyleValues = new StringBuilder();

            //StyleValues.Append(GetContolStyle(_fontstyle.ToString(), _Prompttop.ToString(), _Promptleft.ToString(), _PromptWidth.ToString(), Height.ToString()));
            StyleValues.Append(GetContolStyle(_fontstyle.ToString(), _promptTop.ToString(), _promptLeft.ToString(), null, Height.ToString(), IsHidden));
            prompt.Attributes.Add("style", StyleValues.ToString());
            html.Append(prompt.ToString());

            // error label
            if (!IsValid)
            {
                //Add new Error to the error Obj
                ErrorStyle = ";border-color: red";
            }

            // input element
            var txt = new TagBuilder("input");

            txt.Attributes.Add("name", inputName);
            txt.Attributes.Add("id", inputName);
            txt.Attributes.Add("type", "text");
            if (_MaxLength > 0 && _MaxLength <= 255)
            {
                txt.Attributes.Add("MaxLength", _MaxLength.ToString());
            }
            else
            {
                txt.Attributes.Add("MaxLength", "255");
            }
            string InputFieldStyle    = GetInputFieldStyle(_InputFieldfontstyle.ToString(), _InputFieldfontSize, _InputFieldfontfamily.ToString());
            string IsHiddenStyle      = "";
            string IsHighlightedStyle = "";

            if (_IsHidden)
            {
                IsHiddenStyle = "display:none";
            }
            if (_IsHighlighted)
            {
                IsHighlightedStyle = "background-color:yellow";
            }

            //if (_IsDisabled)
            //{
            //    txt.Attributes.Add("disabled", "disabled");
            //}

            // txt.Attributes.Add("value", Value);
            ////////////Check code start//////////////////
            EnterRule FunctionObjectAfter = (EnterRule)_form.FormCheckCodeObj.GetCommand("level=field&event=after&identifier=" + _key);

            if (FunctionObjectAfter != null && !FunctionObjectAfter.IsNull())
            {
                txt.Attributes.Add("onblur", "return " + _key + "_after();"); //After
            }
            EnterRule FunctionObjectBefore = (EnterRule)_form.FormCheckCodeObj.GetCommand("level=field&event=before&identifier=" + _key);

            if (FunctionObjectBefore != null && !FunctionObjectBefore.IsNull())
            {
                txt.Attributes.Add("onfocus", "return " + _key + "_before();"); //Before
            }

            ////////////Check code end//////////////////
            txt.Attributes.Add("value", Value);
            txt.Attributes.Add("class", GetControlClass());
            txt.Attributes.Add("data-prompt-position", "topRight:15");
            txt.Attributes.Add("style", "position:absolute;left:" + _left.ToString() + "px;top:" + _top.ToString() + "px" + ";width:" + _controlWidth.ToString() + "px" + ErrorStyle + ";" + IsHiddenStyle + ";" + IsHighlightedStyle + ";" + InputFieldStyle);
            txt.MergeAttributes(_inputHtmlAttributes);
            html.Append(txt.ToString(TagRenderMode.SelfClosing));

            //adding numeric text box validation jquery script tag
            var scriptNumeric = new TagBuilder("script");

            scriptNumeric.InnerHtml = "$(function() { $('#" + inputName + "').numeric();});";
            html.Append(scriptNumeric.ToString(TagRenderMode.Normal));

            //if masked input not empty appy the pattern jquery plugin
            if (!string.IsNullOrEmpty(_Pattern))
            {
                string maskedPatternEq   = GetMaskedPattern(_Pattern);
                var    scriptMaskedInput = new TagBuilder("script");
                scriptMaskedInput.InnerHtml = "$(function() { $('#" + inputName + "').mask('" + maskedPatternEq + "');});";
                html.Append(scriptMaskedInput.ToString(TagRenderMode.Normal));
            }
            // If readonly then add the following jquery script to make the field disabled
            if (ReadOnly || _IsDisabled)
            {
                var scriptReadOnlyText = new TagBuilder("script");
                //scriptReadOnlyText.InnerHtml = "$(function(){$('#" + inputName + "').attr('disabled','disabled')});";
                scriptReadOnlyText.InnerHtml = "$(function(){  var List = new Array();List.push('" + _key + "');CCE_Disable(List, false);});";
                html.Append(scriptReadOnlyText.ToString(TagRenderMode.Normal));
            }

            //prevent numeric text box control to submit on enter click
            var scriptBuilder = new TagBuilder("script");

            scriptBuilder.InnerHtml = "$('#" + inputName + "').BlockEnter('" + inputName + "');";
            scriptBuilder.ToString(TagRenderMode.Normal);
            html.Append(scriptBuilder.ToString(TagRenderMode.Normal));

            var wrapper = new TagBuilder(_fieldWrapper);

            wrapper.Attributes["class"] = _fieldWrapperClass;
            if (_IsHidden)
            {
                wrapper.Attributes["style"] = "display:none";
            }
            wrapper.Attributes["id"] = inputName + "_fieldWrapper";
            wrapper.InnerHtml        = html.ToString();
            return(wrapper.ToString());
        }
コード例 #53
0
ファイル: AutoComplete.cs プロジェクト: fgma75/epiinfo
        public override string RenderHtml()
        {
            int DropDownLimitSize = 1;

            int.TryParse(ConfigurationManager.AppSettings["CACHE_DURATION"].ToString(), out CacheDuration);
            CacheIsOn = ConfigurationManager.AppSettings["CACHE_IS_ON"];//false;
            IsCacheSlidingExpiration = ConfigurationManager.AppSettings["CACHE_SLIDING_EXPIRATION"].ToString();
            var html = new StringBuilder();

            var    inputName  = _form.FieldPrefix + _key;
            string ErrorStyle = string.Empty;

            // prompt
            var prompt = new TagBuilder("label");

            System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"(\r\n|\r|\n)+");

            string newText = regex.Replace(Prompt.Replace(" ", "&nbsp;"), "<br />");

            string NewPromp = System.Web.Mvc.MvcHtmlString.Create(newText).ToString();


            prompt.InnerHtml = NewPromp;
            prompt.Attributes.Add("for", inputName);
            prompt.Attributes.Add("class", "EpiLabel");
            prompt.Attributes.Add("Id", "label" + inputName);


            StringBuilder StyleValues = new StringBuilder();

            StyleValues.Append(GetControlStyle(_fontstyle.ToString(), _Prompttop.ToString(), _Promptleft.ToString(), null, Height.ToString(), _IsHidden));
            prompt.Attributes.Add("style", StyleValues.ToString());
            html.Append(prompt.ToString());

            // error label
            if (!IsValid)
            {
                //Add new Error to the error Obj

                ErrorStyle = ";border-color: red";
            }


            TagBuilder input = null;

            input = new TagBuilder("input");
            input.Attributes.Add("list", inputName + "_DataList");
            input.Attributes.Add("data-autofirst", "true");
            input.Attributes.Add("value", Value);
            input.Attributes.Add("id", inputName);
            input.Attributes.Add("name", inputName);
            ////////////Check code start//////////////////
            EnterRule FunctionObjectAfter = (EnterRule)_form.FormCheckCodeObj.GetCommand("level=field&event=after&identifier=" + _key);

            if (FunctionObjectAfter != null && !FunctionObjectAfter.IsNull())
            {
                input.Attributes.Add("onblur", "return " + _key + "_after();"); //After
                // select.Attributes.Add("onchange", "return " + _key + "_after();"); //After
            }
            EnterRule FunctionObjectBefore = (EnterRule)_form.FormCheckCodeObj.GetCommand("level=field&event=before&identifier=" + _key);

            if (FunctionObjectBefore != null && !FunctionObjectBefore.IsNull())
            {
                input.Attributes.Add("onfocus", "return " + _key + "_before();"); //Before
            }
            EnterRule FunctionObjectClick = (EnterRule)_form.FormCheckCodeObj.GetCommand("level=field&event=click&identifier=" + _key);


            if (!string.IsNullOrEmpty(this.RelateCondition))
            {
                input.Attributes.Add("onchange", "SetCodes_Val(this,'" + _form.SurveyInfo.SurveyId + "','" + SourceTable + "'," + "''" + ",'" + TextColumnName + "','" + RelateCondition + "');"); //click
            }
            ////////////Check code end//////////////////
            int    LargestChoiseLength = 0;
            string measureString       = "";

            foreach (var choise in _choices)
            {
                if (choise.Key.ToString().Length > LargestChoiseLength)
                {
                    LargestChoiseLength = choise.Key.ToString().Length;

                    measureString = choise.Key.ToString();
                }
            }

            // LargestChoiseLength = LargestChoiseLength * _ControlFontSize;

            Font stringFont = new Font(ControlFontStyle, ControlFontSize);

            SizeF size = new SizeF();

            using (Graphics g = Graphics.FromHwnd(IntPtr.Zero))
            {
                size = g.MeasureString(measureString.ToString(), stringFont);
            }



            // stringSize = (int) Graphics.MeasureString(measureString.ToString(), stringFont).Width;


            if (_IsRequired == true)
            {
                //awesomplete
                if (this._choices.Count() < DropDownLimitSize)
                {
                    if ((size.Width) > _ControlWidth)
                    {
                        // select.Attributes.Add("class", GetControlClass() + "text-input fix-me");
                        input.Attributes.Add("class", GetControlClass() + "fix-me");
                    }
                    else
                    {
                        // select.Attributes.Add("class", GetControlClass() + "text-input");
                        input.Attributes.Add("class", GetControlClass());
                    }
                    input.Attributes.Add("data-prompt-position", "topRight:10");
                }
                else
                {
                    if ((size.Width) > _ControlWidth)
                    {
                        // select.Attributes.Add("class", GetControlClass() + "text-input fix-me");
                        input.Attributes.Add("class", GetControlClass() + "fix-me awesomplete Search");
                    }
                    else
                    {
                        // select.Attributes.Add("class", GetControlClass() + "text-input");
                        input.Attributes.Add("class", GetControlClass() + " awesomplete Search");
                    }
                    input.Attributes.Add("data-prompt-position", "topRight:10");
                }
            }
            else
            {
                //awesomplete
                if (this._choices.Count() < DropDownLimitSize)
                {
                    //select.Attributes.Add("class", GetControlClass() + "text-input fix-me");
                    if ((size.Width) > _ControlWidth)
                    {
                        input.Attributes.Add("class", GetControlClass() + "fix-me ");
                    }
                    else
                    {
                        input.Attributes.Add("class", GetControlClass());
                    }
                    input.Attributes.Add("data-prompt-position", "topRight:10");
                }
                else
                {
                    if ((size.Width) > _ControlWidth)
                    {
                        input.Attributes.Add("class", GetControlClass() + "fix-me awesomplete Search");
                    }
                    else
                    {
                        input.Attributes.Add("class", GetControlClass() + " awesomplete Search");
                    }
                    input.Attributes.Add("data-prompt-position", "topRight:10");
                }
            }
            string IsHiddenStyle      = "";
            string IsHighlightedStyle = "";

            if (_IsHidden)
            {
                IsHiddenStyle = "display:none";
            }
            if (_IsHighlighted)
            {
                IsHighlightedStyle = "background-color:yellow";
            }

            //if (_IsDisabled)
            //{
            //    select.Attributes.Add("disabled", "disabled");
            //}

            string InputFieldStyle = GetInputFieldStyle(_InputFieldfontstyle.ToString(), _InputFieldfontSize, _InputFieldfontfamily.ToString());

            input.Attributes.Add("style", "position:absolute;left:" + _left.ToString() + "px;top:" + _top.ToString() + "px" + ";width:" + _ControlWidth.ToString() + "px ; font-size:" + ControlFontSize + "pt;" + ErrorStyle + ";" + IsHiddenStyle + ";" + IsHighlightedStyle + ";" + InputFieldStyle);
            input.MergeAttributes(_inputHtmlAttributes);
            html.Append(input.ToString(TagRenderMode.StartTag));

            if (ReadOnly || _IsDisabled)
            {
                var scriptReadOnlyText = new TagBuilder("script");
                //scriptReadOnlyText.InnerHtml = "$(function(){$('#" + inputName + "').attr('disabled','disabled')});";
                scriptReadOnlyText.InnerHtml = "$(function(){  var List = new Array();List.push('" + _key + "');CCE_Disable(List, false);});";
                html.Append(scriptReadOnlyText.ToString(TagRenderMode.Normal));
            }

            if (this._choices.Count() > DropDownLimitSize)
            {
                var           scriptReadOnlyText = new TagBuilder("script");
                StringBuilder Script             = new StringBuilder();
                Script.Append("$(window).load(function () {  ");

                Script.Append(" $( '#" + inputName + "' ).next().css( 'position', 'absolute' );  ");
                Script.Append(" $( '#" + inputName + "' ).next().css( 'left', '" + _left.ToString() + "px' );  ");
                Script.Append(" $( '#" + inputName + "' ).next().css( 'top', '" + (_top + 29).ToString() + "px' );  ");


                Script.Append("});");
                scriptReadOnlyText.InnerHtml = Script.ToString();
                html.Append(scriptReadOnlyText.ToString(TagRenderMode.Normal));


                //var scriptReadOnlyText1 = new TagBuilder("script");
                //StringBuilder Script1 = new StringBuilder();
                //Script1.Append("  $(document).ready(function () {");


                //Script1.Append("$( '#" + inputName + "').blur(function() { ");
                //Script1.Append("SetCodes_Val(this,'" + _form.SurveyInfo.SurveyId + "','" + _key + "');  ");

                //Script1.Append("});");
                //Script1.Append("});");
                //scriptReadOnlyText1.InnerHtml = Script1.ToString();
                //html.Append(scriptReadOnlyText1.ToString(TagRenderMode.Normal));
            }

            var           scriptReadOnlyText2 = new TagBuilder("script");
            StringBuilder Script2             = new StringBuilder();

            if (!string.IsNullOrEmpty(this.RelateCondition))
            {
                // select.Attributes.Add("onchange", "return SetCodes_Val(this,'" + _form.SurveyInfo.SurveyId + "','" + SourceTable + "'," + "''" + ",'" + TextColumnName + "','" + FieldRelateCondition + "');"); //click
                string RelateConditionScript = "SetCodes_Val(this, '" + _form.SurveyInfo.SurveyId + "', '" + SourceTable + "', " + "''" + ", '" + TextColumnName + "', '" + this.RelateCondition + "');";
                Script2.Append("$('#" + inputName + "' ).on('awesomplete-selectcomplete',function () {  ");

                Script2.Append(RelateConditionScript);
                Script2.Append("});");
                scriptReadOnlyText2.InnerHtml = Script2.ToString();
                html.Append(scriptReadOnlyText2.ToString(TagRenderMode.Normal));
            }

            ///////////////////////////

            var datalist = new TagBuilder("datalist ");

            datalist.Attributes.Add("id", inputName + "_DataList");
            html.Append(datalist.ToString(TagRenderMode.StartTag));

            switch (FieldTypeId.ToString())

            {
            case "17":
                foreach (var choice in _choices)
                {
                    var opt = new TagBuilder("option");
                    opt.Attributes.Add("style", "");
                    opt.Attributes.Add("value", choice.Key);
                    if (choice.Key == SelectedValue.ToString())
                    {
                        opt.Attributes.Add("selected", "selected");
                    }
                    opt.SetInnerText(choice.Key);
                    html.Append(opt.ToString());
                }
                break;

            case "18":
                //    foreach (var choice in _choices)
                //{
                //    var opt = new TagBuilder("option");
                //    opt.Attributes.Add("style", "");
                //    opt.Attributes.Add("value", choice.Key);
                //    if (choice.Key == SelectedValue.ToString()) opt.Attributes.Add("selected", "selected");
                //    opt.SetInnerText(choice.Key);
                //    html.Append(opt.ToString());
                //}
                foreach (var choice in _choices)
                {
                    var opt = new TagBuilder("option");
                    opt.Attributes.Add("value", choice.Key);
                    opt.SetInnerText(choice.Key);

                    html.Append(opt.ToString());
                }
                break;

            case "19":
                foreach (var choice in _choices)
                {
                    var opt = new TagBuilder("option");
                    opt.Attributes.Add("style", "");
                    if (choice.Key.Contains("-"))
                    {
                        string[] keyValue    = choice.Key.Split(new char[] { '-' }, 2);
                        string   comment     = keyValue[0].Trim();
                        string   description = keyValue[1].Trim();

                        opt.Attributes.Add("value", comment);

                        if (choice.Value || comment == SelectedValue.ToString())
                        {
                            opt.Attributes.Add("selected", "selected");
                        }

                        opt.SetInnerText(description);
                    }

                    html.Append(opt.ToString());
                }
                break;
            }
            // close select element
            html.Append(input.ToString(TagRenderMode.EndTag));

            // add hidden tag, so that a value always gets sent for select tags
            var hidden1 = new TagBuilder("input");

            hidden1.Attributes.Add("type", "hidden");
            hidden1.Attributes.Add("id", inputName + "_hidden");
            hidden1.Attributes.Add("name", inputName);
            hidden1.Attributes.Add("value", string.Empty);
            html.Append(hidden1.ToString(TagRenderMode.SelfClosing));

            var wrapper = new TagBuilder(_fieldWrapper);

            wrapper.Attributes["class"] = _fieldWrapperClass;
            if (_IsHidden)
            {
                wrapper.Attributes["style"] = "display:none";
            }
            wrapper.Attributes["id"] = inputName + "_fieldWrapper";
            wrapper.InnerHtml        = html.ToString();
            return(wrapper.ToString());
        }
コード例 #54
0
        public override string RenderHtml()
        {
            var html         = new StringBuilder();
            var inputName    = _form.FieldPrefix + _key;
            var choicesList  = _choices.ToList();
            var choicesList1 = GetChoices(_ChoicesList);

            choicesList = choicesList1.ToList();
            var  selectedValue  = string.Empty;
            bool IsAfterControl = false;

            if (!IsValid)
            {
                var error = new TagBuilder("label");
                error.Attributes.Add("class", _errorClass);
                error.SetInnerText(Error);
                html.Append(error.ToString());
            }
            string IsHiddenStyle      = "";
            string IsHighlightedStyle = "";

            if (_IsHidden)
            {
                //IsHiddenStyle = "visibility:hidden";
                // IsHiddenStyle = "display:none";
            }
            if (_IsHighlighted)
            {
                IsHighlightedStyle = "background:yellow";
            }



            for (int i = 0; i < choicesList.Count; i++)
            {
                double innerTop  = 0.0;
                double innerLeft = 0.0;
                string radId     = inputName + i;
                // if (Pattern != null && !string.IsNullOrEmpty(Pattern[0]))
                if ((Pattern.Count) == choicesList.Count)
                {
                    List <string> TopLeft = Pattern[i].ToString().Split(':').ToList();

                    if (TopLeft.Count > 0)
                    {
                        innerTop  = double.Parse(TopLeft[0]) * Height;
                        innerLeft = double.Parse(TopLeft[1]) * Width;
                    }
                }



                var Div = new TagBuilder("Div");
                Div.Attributes.Add("class", _orientation == Orientation.Vertical ? _verticalClass : _horizontalClass);
                Div.Attributes["class"] += " " + _listClass;
                Div.Attributes.Add("style", "position:absolute; left:" + (_left + innerLeft) + "px;top:" + (_top + innerTop) + "px" + ";width:" + _controlWidth.ToString() + "px" + ";height:" + _controlHeight.ToString() + "px");
                html.Append(Div.ToString(TagRenderMode.StartTag));

                if (!_showTextOnRight)
                {
                    var Leftlbl = new TagBuilder("label");

                    Leftlbl.Attributes.Add("for", inputName);
                    //Leftlbl.Attributes.Add("class", _inputLabelClass);
                    Leftlbl.Attributes.Add("class", "label" + inputName);
                    Leftlbl.Attributes.Add("Id", "label" + inputName + "_" + i);
                    StringBuilder StyleValues1 = new StringBuilder();
                    StyleValues1.Append(GetRadioListStyle(_fontstyle.ToString(), null, null, null, null, IsHidden));
                    string InputFieldStyle_L = GetInputFieldStyle(_InputFieldfontstyle.ToString(), _InputFieldfontSize, _InputFieldfontfamily.ToString());
                    Leftlbl.Attributes.Add("style", StyleValues1.ToString() + ";" + IsHighlightedStyle + ";" + IsHiddenStyle + ";" + InputFieldStyle_L);
                    Leftlbl.SetInnerText(choicesList[i].Key);
                    html.Append(Leftlbl.ToString());
                }

                // radio button input
                var rad = new TagBuilder("input");
                rad.Attributes.Add("type", "radio");
                rad.Attributes.Add("name", inputName);
                rad.Attributes.Add("class", inputName);
                // rad.Attributes.Add("onClick", "return document.getElementById('" + inputName + "').value = this.value;"); //After
                ////////////Check code start//////////////////
                EnterRule FunctionObjectAfter = (EnterRule)_form.FormCheckCodeObj.GetCommand("level=field&event=after&identifier=" + _key);
                if (FunctionObjectAfter != null && !FunctionObjectAfter.IsNull())
                {
                    rad.Attributes.Add("onchange", "$('#" + inputName + "').val('" + i.ToString() + "');$('#" + inputName + "').parent().next().find('input[type=hidden]')[0].value='" + i.ToString() + "'; return " + _key + "_after();"); //After
                    //rad.Attributes.Add("onblur", "$('#" + inputName + "').val('" + i.ToString() + "');return " + _key + "_after();"); //After
                    //rad.Attributes.Add("onclick", "return " + _key + "_after();"); //After
                    IsAfterControl = true;
                }
                EnterRule FunctionObjectClick = (EnterRule)_form.FormCheckCodeObj.GetCommand("level=field&event=click&identifier=" + _key);
                if (FunctionObjectClick != null && !FunctionObjectClick.IsNull())
                {
                    rad.Attributes.Add("onclick", "return " + _key + "_click();"); //click
                    IsAfterControl = true;
                }
                if (!IsAfterControl)
                {
                    rad.Attributes.Add("onchange", "$('#" + inputName + "').val('" + i.ToString() + "');"); //click
                }

                ////////////Check code end//////////////////
                rad.SetInnerText(choicesList[i].Key);
                rad.Attributes.Add("value", i.ToString());
                rad.Attributes.Add("style", IsHiddenStyle);
                if (_IsDisabled)
                {
                    rad.Attributes.Add("disabled", "disabled");
                }

                if (Value == i.ToString())
                {
                    selectedValue = Value;
                    rad.Attributes.Add("checked", "checked");
                }


                rad.MergeAttributes(_inputHtmlAttributes);
                html.Append(rad.ToString(TagRenderMode.SelfClosing));

                // checkbox label
                if (_showTextOnRight)
                {
                    var rightlbl = new TagBuilder("label");
                    rightlbl.Attributes.Add("for", inputName);
                    // rightlbl.Attributes.Add("class", _inputLabelClass);
                    rightlbl.Attributes.Add("class", "label" + inputName);
                    rightlbl.Attributes.Add("Id", "label" + inputName + "_" + i);
                    StringBuilder StyleValues2 = new StringBuilder();
                    StyleValues2.Append(GetRadioListStyle(_fontstyle.ToString(), null, null, null, null, IsHidden));
                    string InputFieldStyle_R = GetInputFieldStyle(_InputFieldfontstyle.ToString(), _InputFieldfontSize, _InputFieldfontfamily.ToString());
                    rightlbl.Attributes.Add("style", StyleValues2.ToString() + ";" + IsHighlightedStyle + ";" + IsHiddenStyle + ";" + InputFieldStyle_R);
                    rightlbl.SetInnerText(choicesList[i].Key);
                    html.Append(rightlbl.ToString());
                }

                html.Append(Div.ToString(TagRenderMode.EndTag));
            }


            // add hidden tag, so that a value always gets sent for select tags
            var hidden = new TagBuilder("input");

            hidden.Attributes.Add("type", "hidden");
            hidden.Attributes.Add("id", inputName);
            hidden.Attributes.Add("name", inputName);
            hidden.Attributes.Add("value", selectedValue);
            html.Append(hidden.ToString(TagRenderMode.SelfClosing));


            var wrapper = new TagBuilder(_fieldWrapper);

            wrapper.Attributes["class"] = _fieldWrapperClass;
            if (_IsHidden)
            {
                wrapper.Attributes["style"] = "display:none";
            }
            wrapper.Attributes["id"] = inputName + "_fieldWrapper";
            wrapper.InnerHtml        = html.ToString();
            return(wrapper.ToString());
        }
コード例 #55
0
        public ActionResult Index(string surveyid, string AddNewFormId, string EditForm)
        {
            int  UserId       = SurveyHelper.GetDecryptUserId(Session["UserId"].ToString());
            int  CuurentOrgId = int.Parse(Session["SelectedOrgId"].ToString());
            Guid ResponseID   = Guid.NewGuid();

            Session["FormValuesHasChanged"] = "";

            TempData[Epi.Web.MVC.Constants.Constant.RESPONSE_ID] = Session["RootResponseId"] = ResponseID.ToString();


            if (string.IsNullOrEmpty(EditForm) && Session["EditForm"] != null)
            {
                EditForm = Session["EditForm"].ToString();
            }

            if (!string.IsNullOrEmpty(EditForm) && string.IsNullOrEmpty(AddNewFormId))
            {
                Session["RootResponseId"] = EditForm.ToLower();

                Session["IsEditMode"] = true;
                Epi.Web.Enter.Common.DTO.SurveyAnswerDTO surveyAnswerDTO = GetSurveyAnswer(EditForm, Session["RootFormId"].ToString());


                Session["RequestedViewId"] = surveyAnswerDTO.ViewId;
                if (Session["RecoverLastRecordVersion"] != null)
                {
                    surveyAnswerDTO.RecoverLastRecordVersion = bool.Parse(Session["RecoverLastRecordVersion"].ToString());
                }
                string ChildRecordId = GetChildRecordId(surveyAnswerDTO);
                Session["RecoverLastRecordVersion"] = false;
                return(RedirectToAction(Epi.Web.MVC.Constants.Constant.INDEX, Epi.Web.MVC.Constants.Constant.SURVEY_CONTROLLER, new { responseid = ChildRecordId, PageNumber = 1, Edit = "Edit" }));
            }
            else
            {
                Session["IsEditMode"] = false;
            }
            bool IsMobileDevice = this.Request.Browser.IsMobileDevice;


            if (IsMobileDevice == false)
            {
                IsMobileDevice = Epi.Web.MVC.Utility.SurveyHelper.IsMobileDevice(this.Request.UserAgent.ToString());
            }

            FormsAuthentication.SetAuthCookie("BeginSurvey", false);
            Session["RootFormId"] = AddNewFormId;
            //create the responseid
            Epi.Web.Enter.Common.DTO.SurveyAnswerDTO SurveyAnswer = _isurveyFacade.CreateSurveyAnswer(AddNewFormId, ResponseID.ToString(), UserId, false, "", false, CuurentOrgId);
            MvcDynamicForms.Form form = _isurveyFacade.GetSurveyFormData(SurveyAnswer.SurveyId, 1, SurveyAnswer, IsMobileDevice, null, null, false, false);
            TempData["Width"] = form.Width + 100;
            SurveyInfoModel surveyInfoModel = Mapper.ToFormInfoModel(form.SurveyInfo);

            // set the survey answer to be production or test
            SurveyAnswer.IsDraftMode = form.SurveyInfo.IsDraftMode;
            XDocument xdoc = XDocument.Parse(form.SurveyInfo.XML);

            ///////////////////////////// Execute - Record Before - start//////////////////////
            Dictionary <string, string> ContextDetailList = new Dictionary <string, string>();
            EnterRule         FunctionObject_B            = (EnterRule)form.FormCheckCodeObj.GetCommand("level=record&event=before&identifier=");
            SurveyResponseXML SurveyResponseXML           = new SurveyResponseXML(PageFields, RequiredList);

            if (FunctionObject_B != null && !FunctionObject_B.IsNull())
            {
                try
                {
                    SurveyAnswer.XML        = SurveyResponseXML.CreateResponseDocument(xdoc, SurveyAnswer.XML);
                    Session["RequiredList"] = SurveyResponseXML._RequiredList;
                    //SurveyAnswer.XML = Epi.Web.MVC.Utility.SurveyHelper.CreateResponseDocument(xdoc, SurveyAnswer.XML, RequiredList);
                    this.RequiredList       = SurveyResponseXML._RequiredList;
                    form.RequiredFieldsList = this.RequiredList;
                    FunctionObject_B.Context.HiddenFieldList      = form.HiddenFieldsList;
                    FunctionObject_B.Context.HighlightedFieldList = form.HighlightedFieldsList;
                    FunctionObject_B.Context.DisabledFieldList    = form.DisabledFieldsList;
                    FunctionObject_B.Context.RequiredFieldList    = form.RequiredFieldsList;

                    FunctionObject_B.Execute();

                    // field list
                    form.HiddenFieldsList      = FunctionObject_B.Context.HiddenFieldList;
                    form.HighlightedFieldsList = FunctionObject_B.Context.HighlightedFieldList;
                    form.DisabledFieldsList    = FunctionObject_B.Context.DisabledFieldList;
                    form.RequiredFieldsList    = FunctionObject_B.Context.RequiredFieldList;


                    ContextDetailList = Epi.Web.MVC.Utility.SurveyHelper.GetContextDetailList(FunctionObject_B);
                    form = Epi.Web.MVC.Utility.SurveyHelper.UpdateControlsValuesFromContext(form, ContextDetailList);

                    _isurveyFacade.UpdateSurveyResponse(surveyInfoModel, ResponseID.ToString(), form, SurveyAnswer, false, false, 0, SurveyHelper.GetDecryptUserId(Session["UserId"].ToString()));
                }
                catch (Exception ex)
                {
                    // do nothing so that processing
                    // can continue
                }
            }
            else
            {
                SurveyAnswer.XML        = SurveyResponseXML.CreateResponseDocument(xdoc, SurveyAnswer.XML);//, RequiredList);
                this.RequiredList       = SurveyResponseXML._RequiredList;
                Session["RequiredList"] = SurveyResponseXML._RequiredList;
                form.RequiredFieldsList = RequiredList;
                _isurveyFacade.UpdateSurveyResponse(surveyInfoModel, SurveyAnswer.ResponseId, form, SurveyAnswer, false, false, 0, SurveyHelper.GetDecryptUserId(Session["UserId"].ToString()));
            }


            return(RedirectToAction(Epi.Web.MVC.Constants.Constant.INDEX, Epi.Web.MVC.Constants.Constant.SURVEY_CONTROLLER, new { responseid = ResponseID, PageNumber = 1, surveyid = surveyInfoModel.SurveyId }));
        }