Ejemplo n.º 1
0
        /// <summary>
        /// 加载中英文字典
        /// </summary>
        private void LoadLanguge()
        {
            try
            {
                CLanguage.LoadLanType();

                string lanDB = Application.StartupPath + "\\LAN.accdb";

                if (!File.Exists(lanDB))
                {
                    return;
                }

                CAccess db = new CAccess(".", lanDB);

                string er = string.Empty;

                DataSet ds = null;

                string sqlCmd = "select * from LanList order by idNo";

                if (!db.QueryCmd(sqlCmd, out ds, out er))
                {
                    return;
                }

                Dictionary <string, string> lan = new Dictionary <string, string>();

                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    string LAN_CH = ds.Tables[0].Rows[i]["LAN_CH"].ToString();

                    string LAN_EN = ds.Tables[0].Rows[i]["LAN_EN"].ToString();

                    if (!lan.ContainsKey(LAN_CH))
                    {
                        lan.Add(LAN_CH, LAN_EN);
                    }
                }

                CLanguage.Load(lan, out er);
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 2
0
 public void VisitAccess(CAccess access)
 {
     VisitExpression(access);
 }
Ejemplo n.º 3
0
        public void VisitFile(CFile file)
        {
            if (!canGenerate(file))
            {
                return;
            }

            visitor.PreVisitFile(file);

            filenamesrc = file.Token;

            new CNewline(null).Accept(visitor);

            if (instrument)
            {
                COption cCodeCoverage =
                    new COption(new CToken(file.Filename, TokenTypes.keyword, "option"),
                                new CToken(file.Filename, TokenTypes.keyword, "include"),
                                new CToken(file.Filename, TokenTypes.str, "cCodeCoverage.asp"));
                cCodeCoverage.Accept(this);
            }

            visitor.VisitFile(file);

            if (file.Attributes.contains("GenerateProcessAjaxFunction"))
            {
                CFunction unicoderequest = CProgram.Global.FindFunction("unicoderequest");
                CFunction intrequest     = CProgram.Global.FindFunction("intrequest");
                CFunction boolrequest    = CProgram.Global.FindFunction("boolrequest");

                CToken    tok         = CreateTokenWithAdditionalInfo("ProcessAjax", "processajax", TokenTypes.identifier);
                CFunction processAjax =
                    new CFunction(tok, tok.RawValue, tok.Value, TokenTypes.visPublic, CFunction.vbSub, null,
                                  new CTypeRef(null, BuiltIns.Void));

                CAccess pivotitem = new CAccess(unicoderequest.Token, unicoderequest.Token);
                pivotitem.ReferenceTarget = unicoderequest;
                CParameters pivotparams = new CParameters();
                pivotparams.Unnamed.Add(
                    new CConstantExpression(CreateTokenWithAdditionalInfo("sFunction", TokenTypes.str)));
                CSelect select =
                    new CSelect(CreateTokenWithAdditionalInfo("select", TokenTypes.controlFlow),
                                new CDefaultAccess(pivotitem.Token, pivotitem, pivotparams));

                IEnumerator      it   = CProgram.Global.Functions.GetEnumerator();
                List <CVariable> vars = new List <CVariable>();
                while (it.MoveNext())
                {
                    CFunction func = (CFunction)it.Current;
                    if (!func.Attributes.contains("ExecuteOnServer"))
                    {
                        continue;
                    }

                    CStatementBlock block      = new CStatementBlock();
                    CParameters     funcParams = new CParameters();
                    for (int ixArg = 0; ixArg < func.Arguments.Count - 3; ixArg++)
                    {
                        CArgument arg = func.Arguments[ixArg];

                        tok =
                            CreateTokenWithAdditionalInfo("vParam" + (ixArg + 1), "vparam" + (ixArg + 1),
                                                          TokenTypes.identifier);
                        if (ixArg >= vars.Count)
                        {
                            vars.Add(new CVariable(tok, false, new CTypeRef(null, BuiltIns.Variant), null, null, null));
                        }

                        CAssignment assign = new CAssignment(tok);

                        CAccess left = new CAccess(tok, tok);
                        left.ReferenceTarget = vars[ixArg];
                        assign.Target        = left;
                        funcParams.Unnamed.Add(left);

                        CFunction rightfunc = intrequest;
                        if (arg.Type.RawName == "Boolean")
                        {
                            rightfunc = boolrequest;
                        }
                        else if (arg.Type.RawName == "String")
                        {
                            rightfunc = unicoderequest;
                        }

                        CParameters parameters = new CParameters();
                        parameters.Unnamed.Add(
                            new CConstantExpression(CreateTokenWithAdditionalInfo(tok.RawValue, TokenTypes.str)));

                        CAccess rightitem = new CAccess(rightfunc.Token, rightfunc.Token);
                        rightitem.ReferenceTarget = rightfunc;

                        assign.Source = new CDefaultAccess(rightfunc.Token, rightitem, parameters);
                        assign.Source.RhsAssignmentSource = true;

                        block.Add(assign);
                    }

                    CAccess        calledItem = new CAccess(func.Token, func.Token);
                    CDefaultAccess called     = new CDefaultAccess(func.Token, calledItem, funcParams);
                    calledItem.ReferenceTarget = calledItem.ReferenceTarget = func;

                    if (func.Attributes.contains("picture") || func.FunctionType == CFunction.vbFunction)
                    {
                        CAccess returnItem = new CAccess(processAjax.Token, processAjax.Token);
                        returnItem.ReferenceTarget = processAjax;

                        CAssignment assign = new CAssignment(processAjax.Token);
                        assign.Target = returnItem;

                        if (func.FunctionType == CFunction.vbFunction)
                        {
                            assign.Source = called;
                        }
                        else
                        {
                            assign.Source = new CPictureOfExpression(tok, called);
                        }

                        block.Add(assign);
                    }
                    else
                    {
                        block.Add(new CExpressionStatement(called));
                    }

                    tok = CreateTokenWithAdditionalInfo("case", TokenTypes.controlFlow);
                    CExpression exp =
                        new CConstantExpression(CreateTokenWithAdditionalInfo(func.RawName, TokenTypes.str));
                    select.Cases.Add(new CCase(tok, exp, block));
                }

                CDim dim = new CDim(CreateTokenWithAdditionalInfo("Dim", TokenTypes.declaration));
                dim.Variables.AddRange(vars);
                processAjax.Statements.Add(dim);
                processAjax.Statements.Add(select);

                CNewline nl = new CNewline(CreateTokenWithAdditionalInfo("\n", TokenTypes.newline));
                nl.Accept(this);
                processAjax.Accept(this);
                nl.Accept(this);
            }
        }
Ejemplo n.º 4
0
        public Object PreAcceptThen(CIf cif, Object objstate)
        {
            int         newtype = 0;
            CExpression exp     = cif.Condition;
            bool        not     = exp is CNot;

            if (not)
            {
                exp = ((CNot)exp).Operand;
                if (exp is CParenExpression)
                {
                    exp = ((CParenExpression)exp).InnerExpression;
                }
            }

            if (exp is CLogic && ((CLogic)exp).Operation.Value == "or")
            {
                CExpression lhs = ((CLogic)exp).Left;
                if (lhs is CAccess && ((CAccess)lhs).IsRootAccess &&
                    ((CAccess)lhs).ReferenceToken.Value == "g_fmssql")
                {
                    newtype |= DbMsSql;
                }
                exp = ((CLogic)exp).Right;
            }

            if (exp is CAccess)
            {
                CAccess acc = (CAccess)exp;
                if (acc.IsRootAccess)
                {
                    if (acc.ReferenceToken.Value == "g_fmssql")
                    {
                        newtype |= DbMsSql;
                    }
                    if (acc.ReferenceToken.Value == "g_fmysql")
                    {
                        newtype |= DbMySql;
                    }
                }
            }

            if (newtype == 0)
            {
                return(null);
            }

            if (not)
            {
                newtype = ~newtype;
            }

            DbTypeInfo state;

            if (objstate == null)
            {
                state         = new DbTypeInfo();
                state.oldtype = dbtype;
            }
            else
            {
                state = (DbTypeInfo)objstate;
            }
            state.currenttype = newtype;
            state.elsetype   &= ~newtype;

            dbtype = newtype;
            return(state);
        }