Esempio n. 1
0
        private bool MatchValue(string matchKey, WSJValue matchValue, string matchOperation)
        {
            try
            {
                if (!string.IsNullOrEmpty(matchKey) && matchValue != null && matchValue.IsValid)
                {
                    matchOperation = matchOperation == null ? WSFieldFilter.GLOBAL_OPERATIONS.Equal.NAME : matchOperation;

                    switch (matchKey)
                    {
                    case "srckey":
                        return(matchValue.Match(srckey, matchOperation));

                    case "dbkey":
                        return(matchValue.Match(dbkey, matchOperation));

                    case "reckey":
                        return(matchValue.Match(reckey, matchOperation));

                    default: break;
                    }
                }
            }
            catch (Exception) { return(false); }
            return(false);
        }
Esempio n. 2
0
        public bool ExitPrivateSession <S>(WSDataContext db, ClientFunctions CFunc, WSTableSource SessionSrc, ref WSStatus statusLines) where S : WSDynamicEntity
        {
            bool DEAUTHORIZED = false;

            try
            {
                AuthToken.issued     = DateTime.MinValue;
                AuthToken.expires    = DateTime.MinValue;
                AuthToken.expires_in = 0;
                AuthToken.User       = null;

                if (Session == null)
                {
                    DEAUTHORIZED = true;
                }
                else
                {
                    if (db != null)
                    {
                        //TODO@ANDVO:2016-11-09 : instead of looking for Primary Key value, - look for 'SessionID' field to make sure ALL related records will be removed

                        string idName  = SessionSrc.PrimParams.Any() && SessionSrc.PrimParams.Count() == 1 ? SessionSrc.PrimParams.Single().WSColumnRef.NAME : null;
                        object idValue = null;

                        if (Session.TryReadPropertyValue(idName, out idValue))
                        {
                            ParameterExpression paramExp = Expression.Parameter(SessionSrc.ReturnType, "x");

                            Expression <Func <S, bool> > expr = new WSJValue(idValue.ToString()).GetFieldFilter(CFunc, (WSTableParam)SessionSrc.GetXParam(idName), paramExp, 0).ToLambda <S>(paramExp);

                            S delItem = db.GetTable <S>().FirstOrDefault(expr);

                            db.GetTable <S>().DeleteOnSubmit(delItem);
                            db.SubmitChanges();
                            DEAUTHORIZED = true;
                        }
                    }
                }
                if (DEAUTHORIZED)
                {
                    AuthToken.status = WSConstants.AUTH_STATES.DEAUTHORIZED;
                }
            }
            catch (Exception e)
            {
                CFunc.RegError(GetType(), e, ref statusLines);
                AuthToken.status = WSConstants.AUTH_STATES.FAILED_DEAUTHORIZE;
            }
            finally { WSServerMeta.ClearCache(SessionID); }
            return(DEAUTHORIZED);
        }
Esempio n. 3
0
        internal WSFilter GetFilter()
        {
            WSCombineFilter filter = new WSCombineFilter(WSCombineFilter.SQLMode.OrElse);

            foreach (WSJson jOption in option.Value)
            {
                if (jOption is WSJValue)
                {
                    WSJValue jval = (WSJValue)jOption;
                    if (jval.Value.IsTrue() || jval.Value.IsFalse())
                    {
                        filter.Add(new WSBoolOFilter(jval));
                    }
                }
            }
            return(filter != null && filter.IsValid ? filter.Count == 1? filter[0] :filter : null);
        }
Esempio n. 4
0
        private bool MatchValue(string matchKey, WSJValue matchValue, string matchOperation)
        {
            try
            {
                if (!string.IsNullOrEmpty(matchKey) && matchValue != null && matchValue.IsValid)
                {
                    matchOperation = matchOperation == null ? WSFieldFilter.GLOBAL_OPERATIONS.Equal.NAME : matchOperation;

                    switch (matchKey)
                    {
                    case "id":
                        return(matchValue.Match(id, matchOperation));

                    case "login":
                        return(matchValue.Match(login, matchOperation));

                    case "email":
                        return(matchValue.Match(email, matchOperation));

                    case "firstname":
                        return(matchValue.Match(firstname, matchOperation));

                    case "lastname":
                        return(matchValue.Match(lastname, matchOperation));

                    case "role":
                        return(matchValue.Match(role, matchOperation));

                    case "isactive":
                        return(matchValue.Match(isactive, matchOperation));

                    default: break;
                    }
                }
            }
            catch (Exception) { return(false); }
            return(false);
        }