Ejemplo n.º 1
0
        public HttpResponseMessage Logout([FromBody] object value)
        {
            JsonRequestDb oJson;

            try {
                oJson = JsonConvert.DeserializeObject <JsonRequestDb>(value.ToString());
            } catch (Exception) {
                throw new Exception("Nem sikerült értelmezni a JSON adatot. A helyes formátum pl: {db:'Ostomy',action:'login',pars:{fh:'asos',jsz:'asosasos'}}");
            }
            addTokenToPars(oJson);
            if (logInfo == null)
            {
                logInfo = BaseApiController.logInfoFactory();
            }
            using (_sql = new Sql(getConnectionString(oJson.db), logInfo)) {
                Dictionary <string, string> pars = oJson.pars;
                if (oJson.log != null && !string.IsNullOrWhiteSpace(oJson.log.msg))
                {
                    logInfo.Log(oJson.log.msg);
                }
                if (oJson.log == null || !oJson.log.enabled)
                {
                    _sql.logger.DisabledOnce();
                }
                _sql.logout(pars);
                return(Request.CreateResponse(HttpStatusCode.OK));
            }
        }
Ejemplo n.º 2
0
        public DataSet Login([FromBody] object value)
        {
            JsonRequestDb oJson;

            try {
                oJson = JsonConvert.DeserializeObject <JsonRequestDb>(value.ToString());
            } catch (Exception) {
                throw new Exception("Nem sikerült értelmezni a JSON adatot. A helyes formátum pl: {db:'Ostomy',action:'login',pars:{fh:'asos',jsz:'asosasos'}}");
            }
            addTokenToPars(oJson);
            if (logInfo == null)
            {
                logInfo = BaseApiController.logInfoFactory();
            }
            using (_sql = new Sql(getConnectionString(oJson.db), logInfo)) {
                Dictionary <string, string> pars = oJson.pars;
                pars.Add("IP", (Request.GetOwinContext() == null ? "na" : Request.GetOwinContext().Request.RemoteIpAddress));
                if (oJson.log != null && !string.IsNullOrWhiteSpace(oJson.log.msg))
                {
                    logInfo.Log(oJson.log.msg);
                }
                if (oJson.log == null || !oJson.log.enabled)
                {
                    _sql.logger.DisabledOnce();
                }
                using (DataSet ds = _sql.login(pars)) {
                    if (ds != null && ds.Tables.Count == 2)
                    {
                        ds.Tables[0].TableName = "token";
                        ds.Tables[1].TableName = "groups";
                    }
                    return(ds);
                }
            }
        }