Exemplo n.º 1
0
        private object UserLogin(DBEntities db, ref ErrorInfo err, string loginName, string loginIP)
        {
            var user = db.fa_user.SingleOrDefault(x => x.LOGIN_NAME == loginName);

            if (user == null)
            {
                err.IsError = true;
                err.Message = "用户名不存在";
                return(null);
            }
            else
            {
                if (!ProInterface.AppSet.RepeatUser)
                {
                    Global.ClearTimeOutUser();
                    var nowUse = Global.OnLines.FirstOrDefault(x => x.UserId == user.ID && x.LoginIP != loginIP);
                    if (nowUse != null)
                    {
                        System.TimeSpan ts = DateTime.Now - nowUse.LastOpTime;
                        err.IsError = true;
                        err.Message = string.Format("该用户已经在[{0}]登录,最后操作时间为[{1}],请稍后[{2}]分钟后再试....", nowUse.LoginIP, nowUse.LastOpTime, ProInterface.AppSet.TimeOut - ts.Minutes);
                        return(null);
                    }
                }
                try
                {
                    return(Global.Add(user.ID, loginIP));
                }
                catch (Exception e)
                {
                    err.IsError = true;
                    err.Message = e.Message;
                    return(null);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Def block parser
        /// </summary>
        void PushBlock(List <Expression> body, List <Exp> IL)
        {
            Expression expr;
            var        ifparts = new Stack <If>();

            for (int i = 0; i < body.Count; i++)
            {
                expr = body[i]; // cur expression

                switch (expr.Command)
                {
                case "class":
                {
                    Class type = ParseClass(expr);
                    Global.Add(type.Name, type);
                }
                break;

                case "def":
                {
                    Function func = ParseFunc(expr);
                    Global.Add(func.Name, func);
                }
                break;

                case "if":
                case "elif":
                    ifparts.Push(
                        new If
                    {
                        Test = AsBool(Parse(expr)),
                        Body = ParseBlock(expr.Body)
                    });
                    if (i + 1 == body.Count || body[i + 1].Command?.StartsWith("el") == false)
                    {
                        IL.Add(IfThenElse(ifparts));
                    }
                    break;

                case "else":
                    IL.Add(IfThenElse(ifparts, ParseBlock(expr.Body)));
                    break;

                case "for":
                {
                    var v = expr[0].Value;
                    expr.RemoveRange(0, 2);
                    if (expr.Count == 2 && expr[0].Value == "range")
                    {
                    }
                }
                break;

                case "while":
                    br.Push(Exp.Label());
                    con.Push(Exp.Label());

                    IL.Add(Exp.Loop(
                               Exp.IfThenElse(
                                   test: AsBool(Parse(expr)),
                                   ifTrue: ParseBlock(expr.Body),
                                   ifFalse: Exp.Goto(br.Peek())
                                   ),
                               br.Peek(),
                               con.Peek()));

                    br.Pop();
                    con.Pop();
                    break;

                case "try":

                    break;

                case "except":

                    break;

                case "finally":

                    break;

                case "import":

                    break;

                case "from":

                    break;

                case "return":
                    IL.Add(Exp.Goto(ret.Peek(), Parse(expr)));
                    break;

                case "break":
                    IL.Add(Exp.Goto(br.Peek()));
                    break;

                case "continue":
                    IL.Add(Exp.Goto(con.Peek()));
                    break;

                case "pass":
                    // nothing to do
                    break;

                case "global":
                {
                    var w = Split(expr, TokenType.Comma);
                    foreach (var v in w)
                    {
                        Local.Add(v[0].Value, GlobalAccess(v[0].Value));
                    }
                }
                break;

                case "nonlocal":

                    break;

                case "del":

                    break;

                case "raise":

                    break;

                case "assert":

                    break;

                case "yield":

                    break;

                case "print":
                    IL.Add(Exp.Call(typeof(Console).GetMethod("WriteLine", new[] { typeof(object) }), Parse(expr)));
                    break;

                case "emit":
                    Emit(expr[0].Value, IL);
                    break;

                case "assign":
                {
                    (var left, var right, var op) = SplitAssign(expr);

                    var vars   = Split(left, TokenType.Comma);
                    var values = Split(right, TokenType.Comma);

                    if (op != Op.None)         // augmented assignment
                    {
                        if (vars.Count == 1)
                        {
                            if (values.Count == 1)
                            {
                                Exp var = ParseUnit(vars[0]);
                                Exp val = Parse(values[0]);
                                IL.Add(Exp.Assign(var, Dynamic(op, var, val)));
                            }
                            else if (values.Count > 1)         // tuple
                            {
                                // pass
                            }
                        }
                        else
                        {
                            throw new Exception("illegal expression for augmented assignment");
                        }
                    }
                    else if (vars.Count == values.Count)
                    {
                        for (int j = 0; j < vars.Count; j++)
                        {
                            IL.Add(Assign(vars[j], Parse(values[j])));
                        }
                    }
                    else if (vars.Count > 1 && values.Count == 1)         // unpack
                    {
                        Exp iter = Cache("c_002");

                        var iterable = Parse(values[0]);
                        IL.Add(Exp.Assign(iter, iterable));

                        for (int j = 0; j < vars.Count; j++)
                        {
                            IL.Add(Assign(vars[j], Exp.Call(iter, typeof(Object).GetMethod("__getitem__"), Exp.Constant(new Int(j)))));
                        }
                    }
                    else if (vars.Count == 1 && values.Count > 1)         // tuple
                    {
                        var tpl = Exp.ListInit(Exp.New(typeof(Tuple)),
                                               values.Select(Parse));
                        IL.Add(Assign(vars[0], tpl));
                    }
                }
                break;

                case null:
                    IL.Add(Parse(expr));
                    break;
                }
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Add a new message into the handler for a global aspect
 /// </summary>
 /// <param name="message"></param>
 /// <param name="parameters">If a parameter contains {LANGUAGE_KEY}, it means that LANGUAGE_KEY must be replaced by the label of LANGUAGE_KEY for a given language</param>
 public void AddGlobal(string message, params object[] parameters)
 {
     Global.Add(new Error(message, parameters));
 }
Exemplo n.º 4
0
        // 用户登录
        private string userLogin()
        {
            myJson my = new myJson();

            try
            {
                #region 检测用户名,密码
                string userName = Funcs.Get("userName"); //用户名
                string pwd      = Funcs.Get("pwd");      //密码

                string         strSql = "select su.*,sp.paramsName userTypeName from system_users su inner join system_params sp on su.userType=sp.id where su.userName=@userName and su.password=@pwd";
                SqlParameter[] param  = new SqlParameter[] {
                    new SqlParameter("@userName", SqlDbType.VarChar)
                    {
                        Value = userName
                    },
                    new SqlParameter("@pwd", SqlDbType.VarChar)
                    {
                        Value = Funcs.MD5(pwd)
                    }
                };

                DataTable tb = Utility.SqlHelper.GetDataTable(strSql, param);
                if (tb == null || tb.Rows.Count < 1)
                {
                    my.flag = 0;
                    my.msg  = "用户名或密码错误!";
                    return(JsonConvert.SerializeObject(my));
                }
                if (int.Parse(tb.Rows[0]["userstatus"].ToString()) == 0)
                {
                    my.flag = 0;
                    my.msg  = "您的帐号已暂停使用,请联系管理员!";
                    return(JsonConvert.SerializeObject(my));
                }
                #endregion

                #region 保存用户信息,权限到Session
                string loginUserId = tb.Rows[0]["id"].ToString();
                //防止一个帐号多处登录
                Global.Add(int.Parse(loginUserId), HttpContext.Current.Session.SessionID);


                //保存用户的信息到Session
                MySession.Add("userId", tb.Rows[0]["id"]);
                MySession.Add("userName", tb.Rows[0]["userName"]);
                MySession.Add("userTypeName", tb.Rows[0]["userTypeName"]);
                MySession.Add("trueName", tb.Rows[0]["trueName"]);

                #endregion

                my.flag = 1;
                my.msg  = "登录成功";
                return(JsonConvert.SerializeObject(my));
            }
            catch (Exception ex)
            {
                my.flag = 0;
                my.msg  = "登录失败:" + ex.Message;
                return(JsonConvert.SerializeObject(my));
            }
        }
Exemplo n.º 5
0
 private bool EnableHotSpot()
 {
     return(Global.Add(this));
 }