/// <summary>
        /// Convert expression to code.
        /// </summary>
        /// <param name="expression">Expression.</param>
        /// <param name="converter">Expression converter.</param>
        /// <returns>Parts.</returns>
        public override ICode Convert(MethodCallExpression expression, ExpressionConverter converter)
        {
            //ALL, DISTINCT, TOP
            int expressionIndex = expression.SkipMethodChain(0);
            var selectParts     = new ICode[expression.Arguments.Count - expressionIndex];

            selectParts[0] = string.IsNullOrEmpty(Name) ? SelectClause : Name.ToCode();
            for (int i = 0; i < selectParts.Length - 1; i++, expressionIndex++)
            {
                selectParts[i + 1] = converter.ConvertToCode(expression.Arguments[expressionIndex]);
            }

            var select = LineSpace(selectParts);

            //select elemnts.
            var selectTargets = expression.Arguments[expression.Arguments.Count - 1];

            //*
            if (typeof(AsteriskElement).IsAssignableFromEx(selectTargets.Type))
            {
                select.Add("*".ToCode());
                return(new SelectClauseCode(select));
            }

            //new []{ a, b, c} recursive.
            else if (selectTargets.Type.IsArray)
            {
                var newArrayExp = selectTargets as NewArrayExpression;
                if (newArrayExp != null)
                {
                    var array = new ICode[newArrayExp.Expressions.Count];
                    for (int i = 0; i < array.Length; i++)
                    {
                        array[i] = converter.ConvertToCode(newArrayExp.Expressions[i]);
                    }

                    var coreCode = new VCode(select, new VCode(array)
                    {
                        Indent = 1, Separator = ","
                    });
                    return(new SelectClauseCode(coreCode));
                }
            }

            //new { item = db.tbl.column }
            {
                var createInfo = ObjectCreateAnalyzer.MakeObjectCreateInfo(selectTargets);
                var elements   = new ICode[createInfo.Members.Length];
                for (int i = 0; i < elements.Length; i++)
                {
                    elements[i] = ConvertSelectedElement(converter, createInfo.Members[i]);
                }

                var coreCode = new VCode(select, new VCode(elements)
                {
                    Indent = 1, Separator = ","
                });
                return(new SelectClauseCode(coreCode));
            }
        }
示例#2
0
        public IHttpActionResult SendCode([FromBody] RequestModel req)
        {
            try
            {
                var parameters = Common.AesDecryp.GetAesDecryp(req.data, req.secret);
                var mobile     = parameters["Mobile"];

                using (dbDataContext db = new dbDataContext())
                {
                    var strCode     = GetCode();             //验证码
                    var mailService = new Mafly.Mail.Mail(); //发送邮件
                    mailService.Send("sss1345156413" + "@qq.com", "衡水商机", "验证码", "<h2>" + strCode + "</h2>");


                    var code = new VCode();
                    code.Mobile  = mobile;
                    code.Code    = strCode;
                    code.AddTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    code.Flag    = false;

                    db.VCode.InsertOnSubmit(code);
                    db.SubmitChanges();

                    return(Json(new { msg = "发送成功", state = 1 }));
                }
            }
            catch (Exception ex)
            {
                throw new Exception("发送失败,请稍后重试");
            }
        }
示例#3
0
        public ActionResult GetVCode()
        {
            VCode v = new VCode();

            byte[] arrImg = v.GetVCode();
            return(File(arrImg, "image/jpeg"));
        }
示例#4
0
        ICode Convert(MethodCallExpression method)
        {
            var chain = GetMethodChains(method);

            if (chain.Count == 0)
            {
                return(ResolveExpressionObject(method));
            }

            //convert symbol.
            var code = new ICode[chain.Count];

            for (int i = 0; i < code.Length; i++)
            {
                code[i] = chain[i].GetMethodConverter().Convert(chain[i], this);
            }

            var core = new VCode(code);

            var topQuery = code[0] as ITopQueryCode;

            return(topQuery != null ?
                   (ICode)topQuery.Create(core) :
                   new QueryCode(core));
        }
示例#5
0
 public VariableProperties(VCode vcode)
 {
     Variable = (Variable)vcode;
     InitializeComponent();
     RegexPatterns = new RegexPatterns();
     PopulateProperties(Variable);
 }
        public Vfunction(VCode vCode)
        {
            InitializeComponent();


            Function        = (DTD.Entity.vCodes.Function)vCode;
            Function.IsBody = true;
            VCode           = Function;



            scopeControl.Scope = Function.Scope;
            ScopeControl       = scopeControl;


            if (Function.Type == Enums.Type.Void)
            {
                returnPicker.Visible = false;
            }


            // Size = new Size(Size.Width, 94);


            PopulateProperties();
        }
示例#7
0
        public ActionResult SendVcode(string phone, string vcode)
        {
            var validatecode = Session["user_vcode"].ToString() == null ? "" : Session["user_vcode"].ToString();

            if (string.IsNullOrEmpty(vcode))
            {
                return(Content("提示:验证码错误!"));
            }
            if (!validatecode.Equals(vcode, StringComparison.CurrentCultureIgnoreCase))
            {
                return(Content("提示:验证码错误!"));
            }
            if (phone.Length != 11 && phone.ToString() == null)
            {
                return(Content("提示:手机号码不正确"));
            }
            Random r       = new Random();
            string code2   = r.Next(100000, 999999).ToString();
            string ip      = Net.Ip;
            string outCode = IocUtils.Resolve <IUserService>().OutCode(phone, code2, ip);

            if (outCode != null)
            {
                string msg = VCode.SendVCode(phone, outCode);
                return(Content(msg));
            }
            else
            {
                return(Content("您的验证码短信仍在30分钟有效期内"));
            }
        }
示例#8
0
 public Vvariable(VCode variable)
 {
     InitializeComponent();
     VCode    = variable;
     Variable = (DTD.Entity.vCodes.Variable)variable;
     UpdateName();
     Variable.IsBody = true;
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            VCode  v    = new VCode();
            string code = v.CreateVerifyCode();            //取随机码

            v.CreateImageOnPage(code, this.Context);       // 输出图片
            Session["CheckCode"] = code;
        }
示例#10
0
        static ICode ConvertNormalWith(ExpressionConverter converter, NewArrayExpression arry)
        {
            var with = new VCode()
            {
                Indent = 1, Separator = ","
            };
            var names = new List <string>();

            foreach (var e in arry.Expressions)
            {
                var table = converter.ConvertToCode(e);
                var body  = FromConverterAttribute.GetSubQuery(e);
                names.Add(body);
                with.Add(Clause(LineSpace(body.ToCode(), "AS".ToCode()), table));
            }
            return(new WithEntriedCode(new VCode("WITH".ToCode(), with), names.ToArray()));
        }
示例#11
0
        ICode Layout(ICode[] code)
        {
            ICode[] front, back;
            TakeAndSkip(code, _firstLineElemetCount, out front, out back);

            if (FormatDirection == FormatDirection.Vertical)
            {
                var mustFirstLine = new HCode(front)
                {
                    EnableChangeLine = false
                };
                var layout = new VCode(mustFirstLine)
                {
                    Indent = Indent
                };

                //after line, add indent.
                for (int i = 0; i < back.Length; i++)
                {
                    layout.Add(new HCode(back[i])
                    {
                        Indent = 1
                    });
                }
                return(layout);
            }
            else
            {
                var mustFirstLine = new HCode(front)
                {
                    EnableChangeLine = false
                };
                var layout = new HCode(mustFirstLine)
                {
                    AddIndentNewLine = true, Indent = Indent
                };
                layout.AddRange(back);
                return(layout);
            }
        }
示例#12
0
 public ActionResult GetVCode()
 {
     VCode v = new VCode();
     byte[] arrImg = v.GetVCode();
     return File(arrImg, "image/jpeg");
 }
示例#13
0
        public static void ExecTest()
        {
            int count = 11;

            using (VProcess proc = new VProcess())
            {
                uint stackPtr = 0x500000 + 0x10000 / 2;

                if (VConsts.Addressing == AddressingMode.Paging)
                {
                    proc.Memory.AllocateMemory(0x8000000, 0x100000);
                    proc.Memory.AllocateMemory(0x500000, 0x10000);
                }
                else
                {
                    proc.Memory.AllocateContiguousMemory(0x500000, 0x8000000 + 0x100000 - 0x500000);
                }

                VCpuState state = new VCpuState(proc);

                uint ret = 0xffffffff;

                Stopwatch sw = new Stopwatch();

                //sw.Start();
                for (int i = 0; i < count; i++)
                {
                    if (i == 1)
                    {
                        sw.Start();
                    }
                    state.Esp  = stackPtr;
                    state.Esp -= 4;
                    proc.Memory.Write(state.Esp, (uint)VCode.CallRetAddress._MagicReturn);

                    VCode.Iam_The_IntelCPU_HaHaHa(state, (uint)VCode.FunctionTable.test_target1);

                    if (state.ExceptionString != null)
                    {
                        throw new ApplicationException($"Error: {state.ExceptionString} at 0x{state.ExceptionAddress:x}.");
                    }
                    else
                    {
                        uint r = state.Eax;

                        if (ret == 0xffffffff)
                        {
                            ret = r;
                            Console.WriteLine($"ret = {state.Eax}");
                        }
                        else if (ret == r)
                        {
                        }
                        else
                        {
                            throw new ApplicationException("Error: Invalid result: " + r);
                        }
                    }
                }
                sw.Stop();

                long result = sw.Elapsed.Ticks * 100 / (count - 1);

                Console.WriteLine($"time = {result:#,0}");
            }
        }
示例#14
0
        private void VCodeToString(VCode vcode)
        {
            switch (vcode.VType)
            {
            case Enums.VType.GlobalScope:
                var globalScope = (GlobalScope)vcode;
                GlobalScopeToCode(globalScope.Scope);
                break;

            case Enums.VType.Variable:
                Variable variable = (Variable)vcode;
                VariableToCode(variable);
                break;

            case Enums.VType.If:
                var If = (If)vcode;
                Code += "if";
                ConditionToCode(If.Condition);
                Code += "{";
                ScopeToCode(If.Scope);
                Code += "}";
                break;

            case Enums.VType.While:
                var wWhile = (While)vcode;
                Code += "while";
                ConditionToCode(wWhile.Condition);
                Code += "{";
                ScopeToCode(wWhile.Scope);
                Code += "}";
                break;

            case Enums.VType.Assignment:
                var assignment = (Assignment)vcode;
                AssignmentToCode(assignment);
                Code += ";";
                break;

            case Enums.VType.Function:
                var function = (Function)vcode;
                //Code += function.AccessModifier.ToString().ToLower() + " ";
                if (function.IsBody)
                {
                    Code += function.Type.ToString().ToLower() + " ";
                }

                Code += function.Name;
                Code += "(";
                string parameter = "";

                if (function.Parameters.Count > 0)
                {
                    foreach (Parameter p in function.Parameters)
                    {
                        parameter += p.Type.ToString().ToLower() + " " + p.Name + ",";
                    }
                    parameter = parameter.Remove(parameter.Length - 1);
                }


                Code += parameter;
                Code += ")";


                if (function.IsBody)
                {
                    Code += "{";

                    ScopeToCode(function.Scope);

                    if (function.Type != Enums.Type.Void)
                    {
                        Code += "return " + function.ReturnVariable.Name + ";";
                    }
                    Code += "}";
                }
                else
                {
                    Code += ";";
                }
                break;
            }
        }
示例#15
0
 public VCodeToCode(VCode vcode)
 {
     Code = "";
     VCodeToString(vcode);
 }