Exemple #1
0
        // DELETE /TerminalLogico/token/idTerminalLogico
        public HttpResponseMessage Delete(string token, Int32 idTerminalLogico)
        {
            tbLogAcessoUsuario log = new tbLogAcessoUsuario();

            try
            {
                log = Bibliotecas.LogAcaoUsuario.New(token, JsonConvert.SerializeObject("idTerminalLogico : " + idTerminalLogico), "Delete");

                HttpResponseMessage retorno = new HttpResponseMessage();
                if (Permissoes.Autenticado(token))
                {
                    GatewayTerminalLogico.Delete(token, idTerminalLogico);
                    log.codResposta = (int)HttpStatusCode.OK;
                    Bibliotecas.LogAcaoUsuario.Save(log);
                    return(Request.CreateResponse(HttpStatusCode.OK));
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.Unauthorized));
                }
            }
            catch
            {
                throw new HttpResponseException(HttpStatusCode.InternalServerError);
            }
        }
Exemple #2
0
        // GET /RelatorioVendas/token/colecao/campo/orderBy/pageSize/pageNumber?CAMPO1=VALOR&CAMPO2=VALOR
        public HttpResponseMessage Get(string token, int colecao = 0, int campo = 0, int orderBy = 0, int pageSize = 0, int pageNumber = 0)
        {
            // Abre nova conexão
            using (painel_taxservices_dbContext _db = new painel_taxservices_dbContext())
            {
                tbLogAcessoUsuario log = new tbLogAcessoUsuario();
                try
                {
                    log = Bibliotecas.LogAcaoUsuario.New(token, null, "Get", _db);

                    Dictionary <string, string> queryString = Request.GetQueryNameValuePairs().ToDictionary(x => x.Key, x => x.Value);
                    HttpResponseMessage         retorno     = new HttpResponseMessage();
                    if (Permissoes.Autenticado(token, _db))
                    {
                        Retorno dados = GatewayRelatorioVendas.Get(token, colecao, campo, orderBy, pageSize, pageNumber, queryString, _db);
                        log.codResposta = (int)HttpStatusCode.OK;
                        Bibliotecas.LogAcaoUsuario.Save(log, _db);
                        return(Request.CreateResponse <Retorno>(HttpStatusCode.OK, dados));
                    }
                    else
                    {
                        log.codResposta = (int)HttpStatusCode.Unauthorized;
                        Bibliotecas.LogAcaoUsuario.Save(log, _db);
                        return(Request.CreateResponse(HttpStatusCode.Unauthorized));
                    }
                }
                catch (Exception e)
                {
                    log.codResposta = (int)HttpStatusCode.InternalServerError;
                    log.msgErro     = e.Message;
                    Bibliotecas.LogAcaoUsuario.Save(log);//, _db);
                    throw new HttpResponseException(HttpStatusCode.InternalServerError);
                }
            }
        }
Exemple #3
0
        // PATCH: /VendasErp/token/ => upload de um arquivo csv
        public HttpResponseMessage Patch(string token)
        {
            // Abre nova conexão
            using (painel_taxservices_dbContext _db = new painel_taxservices_dbContext())
            {
                tbLogAcessoUsuario log = new tbLogAcessoUsuario();
                try
                {
                    log = Bibliotecas.LogAcaoUsuario.New(token, null, "Patch", _db);

                    HttpResponseMessage retorno = new HttpResponseMessage();
                    if (Permissoes.Autenticado(token, _db))
                    {
                        //GatewayVendasErp.Patch(token, log, _db);
                        log.codResposta = (int)HttpStatusCode.OK;
                        Bibliotecas.LogAcaoUsuario.Save(log, _db);
                        return(Request.CreateResponse(HttpStatusCode.OK));
                    }
                    else
                    {
                        log.codResposta = (int)HttpStatusCode.Unauthorized;
                        Bibliotecas.LogAcaoUsuario.Save(log, _db);
                        return(Request.CreateResponse(HttpStatusCode.Unauthorized));
                    }
                }
                catch (Exception e)
                {
                    log.codResposta = (int)HttpStatusCode.InternalServerError;
                    log.msgErro     = e.Message;
                    Bibliotecas.LogAcaoUsuario.Save(log);
                    return(Request.CreateResponse(HttpStatusCode.InternalServerError, e.Message));
                }
            }
        }
Exemple #4
0
        // DELETE /tbEmpresaFilial/token/nrCNPJ
        public HttpResponseMessage Delete(string token, string nrCNPJ)
        {
            tbLogAcessoUsuario log = new tbLogAcessoUsuario();

            try
            {
                log = Bibliotecas.LogAcaoUsuario.New(token, JsonConvert.SerializeObject("nrCNPJ : " + nrCNPJ), "Delete");

                HttpResponseMessage retorno = new HttpResponseMessage();
                if (Permissoes.Autenticado(token))
                {
                    GatewayTbEmpresaFilial.Delete(token, nrCNPJ);
                    log.codResposta = (int)HttpStatusCode.OK;
                    Bibliotecas.LogAcaoUsuario.Save(log);
                    return(Request.CreateResponse(HttpStatusCode.OK));
                }
                else
                {
                    log.codResposta = (int)HttpStatusCode.Unauthorized;
                    Bibliotecas.LogAcaoUsuario.Save(log);
                    return(Request.CreateResponse(HttpStatusCode.Unauthorized));
                }
            }
            catch (Exception e)
            {
                log.codResposta = (int)HttpStatusCode.InternalServerError;
                log.msgErro     = e.Message;
                Bibliotecas.LogAcaoUsuario.Save(log);
                throw new HttpResponseException(HttpStatusCode.InternalServerError);
            }
        }
        // GET /TB_UNIVERSIDADE_VIDEOS/token/colecao/campo/orderBy/pageSize/pageNumber?CAMPO1=VALOR&CAMPO2=VALOR
        public Retorno Get(string token, int colecao = 0, int campo = 0, int orderBy = 0, int pageSize = 0, int pageNumber = 0)
        {
            // Abre nova conexão
            using (ServeLojaContext _db = new ServeLojaContext())
            {
                try
                {
                    Dictionary <string, string> queryString = Request.GetQueryNameValuePairs().ToDictionary(x => x.Key, x => x.Value);

                    if (Permissoes.Autenticado(token, _db))
                    {
                        return(GatewayTbUniversidadeVideos.Get(token, colecao, campo, orderBy, pageSize, pageNumber, queryString));
                    }
                    else
                    {
                        return new Retorno()
                               {
                                   Token = false
                               }
                    };                                          //return new Retorno() { Token = false }; //throw new Exception("Unauthorized");
                }
                catch (Exception e)
                {
                    throw new Exception(e.Message);
                }
            }
        }
Exemple #6
0
        private void dependency_OnChange(object sender, SqlNotificationEventArgs e)
        {
            //Clean up the old notification
            SqlDependency dep = (SqlDependency)sender;

            dep.OnChange -= dependency_OnChange;

            registraEventoNotificacao();

            if (e.Info.Equals(SqlNotificationInfo.Insert) ||
                e.Info.Equals(SqlNotificationInfo.Update) ||
                e.Info.Equals(SqlNotificationInfo.Delete))
            {
                if (!Permissoes.Autenticado(filtro.Token))
                {
                    return;
                }

                // Só envia se de fato tiveram mudanças para o filtro selecionado
                List <dynamic> mudancas = obtemListaComMudancas(e.Info);
                if (mudancas.Count > 0)
                {
                    context.Clients.Client(connectionId).enviaMudancas(mudancas[0]);
                }
            }
        }
Exemple #7
0
        // DELETE /webpages_Controllers/token/id_controller
        public HttpResponseMessage Delete(string token, Int32 id_controller)
        {
            // Abre nova conexão
            using (painel_taxservices_dbContext _db = new painel_taxservices_dbContext())
            {
                tbLogAcessoUsuario log = new tbLogAcessoUsuario();
                try
                {
                    HttpResponseMessage retorno = new HttpResponseMessage();

                    log = Bibliotecas.LogAcaoUsuario.New(token, JsonConvert.SerializeObject("id_controller : " + id_controller), "Delete", _db);

                    if (Permissoes.Autenticado(token, _db))
                    {
                        GatewayWebpagesControllers.Delete(token, id_controller, _db);
                        log.codResposta = (int)HttpStatusCode.OK;
                        Bibliotecas.LogAcaoUsuario.Save(log, _db);
                        return(Request.CreateResponse(HttpStatusCode.OK));
                    }
                    else
                    {
                        log.codResposta = (int)HttpStatusCode.Unauthorized;
                        Bibliotecas.LogAcaoUsuario.Save(log, _db);
                        return(Request.CreateResponse(HttpStatusCode.Unauthorized));
                    }
                }
                catch (Exception e)
                {
                    log.codResposta = (int)HttpStatusCode.InternalServerError;
                    log.msgErro     = e.Message;
                    Bibliotecas.LogAcaoUsuario.Save(log);
                    throw new HttpResponseException(HttpStatusCode.InternalServerError);
                }
            }
        }
Exemple #8
0
        // POST /webpages_Controllers/token/
        public HttpResponseMessage Post(string token, [FromBody] Models.Object.CadastroController param)
        {
            // Abre nova conexão
            using (painel_taxservices_dbContext _db = new painel_taxservices_dbContext())
            {
                tbLogAcessoUsuario log = new tbLogAcessoUsuario();
                try
                {
                    HttpResponseMessage retorno = new HttpResponseMessage();

                    log = Bibliotecas.LogAcaoUsuario.New(token, JsonConvert.SerializeObject(param), "Post", _db);

                    if (Permissoes.Autenticado(token, _db))
                    {
                        Int32 dados = GatewayWebpagesControllers.Add(token, param, _db);
                        log.codResposta = (int)HttpStatusCode.OK;
                        Bibliotecas.LogAcaoUsuario.Save(log, _db);
                        return(Request.CreateResponse <Int32>(HttpStatusCode.OK, dados));
                    }
                    else
                    {
                        log.codResposta = (int)HttpStatusCode.Unauthorized;
                        Bibliotecas.LogAcaoUsuario.Save(log, _db);
                        return(Request.CreateResponse(HttpStatusCode.Unauthorized));
                    }
                }
                catch (Exception e)
                {
                    log.codResposta = (int)HttpStatusCode.InternalServerError;
                    log.msgErro     = e.Message;
                    Bibliotecas.LogAcaoUsuario.Save(log);
                    throw new HttpResponseException(HttpStatusCode.InternalServerError);
                }
            }
        }
Exemple #9
0
        // PUT /tbContaCorrente/token/
        public HttpResponseMessage Put(string token, [FromBody] tbContaCorrente param)
        {
            // Abre nova conexão
            using (painel_taxservices_dbContext _db = new painel_taxservices_dbContext())
            {
                tbLogAcessoUsuario log = new tbLogAcessoUsuario();
                try
                {
                    log = Bibliotecas.LogAcaoUsuario.New(token, JsonConvert.SerializeObject(param), "Put", _db);

                    HttpResponseMessage retorno = new HttpResponseMessage();
                    if (Permissoes.Autenticado(token, _db))
                    {
                        GatewayTbContaCorrente.Update(token, param, _db);
                        log.codResposta = (int)HttpStatusCode.OK;
                        Bibliotecas.LogAcaoUsuario.Save(log, _db);
                        return(Request.CreateResponse(HttpStatusCode.OK));
                    }
                    else
                    {
                        log.codResposta = (int)HttpStatusCode.Unauthorized;
                        Bibliotecas.LogAcaoUsuario.Save(log, _db);
                        return(Request.CreateResponse(HttpStatusCode.Unauthorized));
                    }
                }
                catch (Exception e)
                {
                    log.codResposta = (int)HttpStatusCode.InternalServerError;
                    log.msgErro     = e.Message;
                    Bibliotecas.LogAcaoUsuario.Save(log);//, _db);
                    throw new HttpResponseException(HttpStatusCode.InternalServerError);
                }
            }
        }
Exemple #10
0
        // DELETE /webpages_Users/token/id_users
        public HttpResponseMessage Delete(string token, Int32 id_users)
        {
            // Abre nova conexão
            using (painel_taxservices_dbContext _db = new painel_taxservices_dbContext())
            {
                tbLogAcessoUsuario log = new tbLogAcessoUsuario();
                try
                {
                    log = Bibliotecas.LogAcaoUsuario.New(token, JsonConvert.SerializeObject("id_users : " + id_users), "Delete", _db);

                    HttpResponseMessage retorno = new HttpResponseMessage();
                    if (Permissoes.Autenticado(token, _db) /* && Permissoes.usuarioTemPermissaoMetodoURL(token, UrlAPIs.ADMINISTRACAO_WEBPAGESUSERS, "DELETE")*/)
                    {
                        GatewayWebpagesUsers.Delete(token, id_users, _db);
                        log.codResposta = (int)HttpStatusCode.OK;
                        Bibliotecas.LogAcaoUsuario.Save(log, _db);
                        return(Request.CreateResponse(HttpStatusCode.OK));
                    }
                    else
                    {
                        log.codResposta = (int)HttpStatusCode.Unauthorized;
                        Bibliotecas.LogAcaoUsuario.Save(log, _db);
                        return(Request.CreateResponse(HttpStatusCode.Unauthorized));
                    }
                }
                catch (Exception e)
                {
                    log.codResposta = (int)HttpStatusCode.InternalServerError;
                    log.msgErro     = e.Message;
                    Bibliotecas.LogAcaoUsuario.Save(log);
                    throw new HttpResponseException(HttpStatusCode.InternalServerError);
                }
            }
        }
Exemple #11
0
        // PUT /tbSituacaoRedeTef/token/
        public HttpResponseMessage Put(string token, [FromBody] tbSituacaoRedeTef param)
        {
            tbLogAcessoUsuario log = new tbLogAcessoUsuario();

            try
            {
                log = Bibliotecas.LogAcaoUsuario.New(token, JsonConvert.SerializeObject(param), "Put");

                HttpResponseMessage retorno = new HttpResponseMessage();
                if (Permissoes.Autenticado(token))
                {
                    GatewayTbSituacaoRedeTef.Update(token, param);
                    log.codResposta = (int)HttpStatusCode.OK;
                    Bibliotecas.LogAcaoUsuario.Save(log);
                    return(Request.CreateResponse(HttpStatusCode.OK));
                }
                else
                {
                    log.codResposta = (int)HttpStatusCode.Unauthorized;
                    Bibliotecas.LogAcaoUsuario.Save(log);
                    return(Request.CreateResponse(HttpStatusCode.Unauthorized));
                }
            }
            catch (Exception e)
            {
                log.codResposta = (int)HttpStatusCode.InternalServerError;
                log.msgErro     = e.Message;
                Bibliotecas.LogAcaoUsuario.Save(log);
                throw new HttpResponseException(HttpStatusCode.InternalServerError);
            }
        }
Exemple #12
0
        // DELETE /tbAssinante/token/cdCatalogo
        public HttpResponseMessage Delete(string token, short cdCatalogo, int id_users)
        {
            tbLogAcessoUsuario log = new tbLogAcessoUsuario();

            try
            {
                log = Bibliotecas.LogAcaoUsuario.New(token, JsonConvert.SerializeObject("cdCatalogo : " + cdCatalogo), "DELETE");

                HttpResponseMessage retorno = new HttpResponseMessage();
                if (Permissoes.Autenticado(token))
                {
                    GatewayTbAssinante.Delete(token, cdCatalogo, id_users);
                    log.codResposta = (int)HttpStatusCode.OK;
                    Bibliotecas.LogAcaoUsuario.Save(log);
                    return(Request.CreateResponse(HttpStatusCode.OK));
                }
                else
                {
                    log.codResposta = (int)HttpStatusCode.Unauthorized;
                    Bibliotecas.LogAcaoUsuario.Save(log);
                    return(Request.CreateResponse(HttpStatusCode.Unauthorized));
                }
            }
            catch (Exception e)
            {
                log.codResposta = (int)HttpStatusCode.InternalServerError;
                log.msgErro     = e.Message;
                Bibliotecas.LogAcaoUsuario.Save(log);
                throw new HttpResponseException(HttpStatusCode.InternalServerError);
            }
        }
Exemple #13
0
        // DELETE /tbBancoParametro/token/cdBanco
        public HttpResponseMessage Delete(string token, string cdBanco, string dsMemo, int cdGrupo)
        {
            // Abre nova conexão
            using (painel_taxservices_dbContext _db = new painel_taxservices_dbContext())
            {
                tbLogAcessoUsuario log = new tbLogAcessoUsuario();
                try
                {
                    log = Bibliotecas.LogAcaoUsuario.New(token, JsonConvert.SerializeObject("cdBanco : " + cdBanco + "; dsMemo : " + dsMemo + "; cdGrupo : " + cdGrupo), "Delete", _db);

                    HttpResponseMessage retorno = new HttpResponseMessage();
                    if (Permissoes.Autenticado(token, _db))
                    {
                        GatewayTbBancoParametro.Delete(token, cdBanco, dsMemo, cdGrupo, _db);
                        log.codResposta = (int)HttpStatusCode.OK;
                        Bibliotecas.LogAcaoUsuario.Save(log, _db);
                        return(Request.CreateResponse(HttpStatusCode.OK));
                    }
                    else
                    {
                        log.codResposta = (int)HttpStatusCode.Unauthorized;
                        Bibliotecas.LogAcaoUsuario.Save(log, _db);
                        return(Request.CreateResponse(HttpStatusCode.Unauthorized));
                    }
                }
                catch (Exception e)
                {
                    log.codResposta = (int)HttpStatusCode.InternalServerError;
                    log.msgErro     = e.Message;
                    Bibliotecas.LogAcaoUsuario.Save(log);//, _db);
                    throw new HttpResponseException(HttpStatusCode.InternalServerError);
                }
            }
        }
Exemple #14
0
        // POST /TerminalLogico/token/
        public HttpResponseMessage Post(string token, [FromBody] TerminalLogico param)
        {
            tbLogAcessoUsuario log = new tbLogAcessoUsuario();

            try
            {
                log = Bibliotecas.LogAcaoUsuario.New(token, JsonConvert.SerializeObject(param), "Post");

                HttpResponseMessage retorno = new HttpResponseMessage();
                if (Permissoes.Autenticado(token))
                {
                    Int32 dados = GatewayTerminalLogico.Add(token, param);
                    log.codResposta = (int)HttpStatusCode.OK;
                    Bibliotecas.LogAcaoUsuario.Save(log);
                    return(Request.CreateResponse <Int32>(HttpStatusCode.OK, dados));
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.Unauthorized));
                }
            }
            catch
            {
                throw new HttpResponseException(HttpStatusCode.InternalServerError);
            }
        }
Exemple #15
0
        // GET /TerminalLogico/token/colecao/campo/orderBy/pageSize/pageNumber?CAMPO1=VALOR&CAMPO2=VALOR
        public HttpResponseMessage Get(string token, int colecao = 0, int campo = 0, int orderBy = 0, int pageSize = 0, int pageNumber = 0)
        {
            tbLogAcessoUsuario log = new tbLogAcessoUsuario();

            try
            {
                log = Bibliotecas.LogAcaoUsuario.New(token, null, "Get");

                Dictionary <string, string> queryString = Request.GetQueryNameValuePairs().ToDictionary(x => x.Key, x => x.Value);
                HttpResponseMessage         retorno     = new HttpResponseMessage();
                if (Permissoes.Autenticado(token))
                {
                    Retorno dados = GatewayTerminalLogico.Get(token, colecao, campo, orderBy, pageSize, pageNumber, queryString);
                    log.codResposta = (int)HttpStatusCode.OK;
                    Bibliotecas.LogAcaoUsuario.Save(log);
                    return(Request.CreateResponse <Retorno>(HttpStatusCode.OK, dados));
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.Unauthorized));
                }
            }
            catch
            {
                throw new HttpResponseException(HttpStatusCode.InternalServerError);
            }
        }
Exemple #16
0
        // GET /RecebimentoParcela/token/colecao/campo/orderBy/pageSize/pageNumber?CAMPO1=VALOR&CAMPO2=VALOR
        public HttpResponseMessage Get(string token, int colecao = 0, int campo = 0, int orderBy = 0, int pageSize = 0, int pageNumber = 0)
        {
            // Abre nova conexão
            using (painel_taxservices_dbContext _db = new painel_taxservices_dbContext())
            {
                tbLogAcessoUsuario log = new tbLogAcessoUsuario();
                try
                {
                    log = Bibliotecas.LogAcaoUsuario.New(token, null, "Get", _db);

                    HttpResponseMessage         result      = null;
                    Dictionary <string, string> queryString = Request.GetQueryNameValuePairs().ToDictionary(x => x.Key, x => x.Value);
                    string outValue             = null;
                    HttpResponseMessage retorno = new HttpResponseMessage();
                    if (Permissoes.Autenticado(token, _db))
                    {
                        Retorno dados = GatewayRecebimentoParcela.Get(token, colecao, campo, orderBy, pageSize, pageNumber, queryString, _db);
                        log.codResposta = (int)HttpStatusCode.OK;
                        Bibliotecas.LogAcaoUsuario.Save(log, _db);
                        if (queryString.TryGetValue("" + (int)GatewayRecebimentoParcela.CAMPOS.EXPORTAR, out outValue))
                        {
                            result         = Request.CreateResponse(HttpStatusCode.OK);
                            result.Content = new StreamContent(new MemoryStream(Negocios.Util.GatewayExportar.CSV(dados.Registros.ToArray())));
                            result.Content.Headers.ContentDisposition          = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment");
                            result.Content.Headers.ContentType                 = new MediaTypeHeaderValue("application/octet-stream");
                            result.Content.Headers.ContentDisposition.FileName = "file" + DateTime.Now.ToString();
                            return(result);
                        }
                        return(Request.CreateResponse <Retorno>(HttpStatusCode.OK, dados));
                    }
                    else
                    {
                        log.codResposta = (int)HttpStatusCode.Unauthorized;
                        Bibliotecas.LogAcaoUsuario.Save(log, _db);
                        return(Request.CreateResponse(HttpStatusCode.Unauthorized));
                    }
                }
                catch (Exception e)
                {
                    log.codResposta = (int)HttpStatusCode.InternalServerError;
                    log.msgErro     = e.Message;
                    Bibliotecas.LogAcaoUsuario.Save(log);//, _db);
                    throw new HttpResponseException(HttpStatusCode.InternalServerError);
                }
                //finally
                //{
                //    // Fecha conexão
                //    _db.Database.Connection.Close();
                //    _db.Dispose();
                //}
            }
            //    }
            //}
        }
Exemple #17
0
        // GET /autenticacao/
        public Autenticado Get(string token, int colecao = 0, int campo = 0, int orderBy = 0, int pageSize = 0, int pageNumber = 0)
        {
            // Abre nova conexão
            using (painel_taxservices_dbContext _db = new painel_taxservices_dbContext())
            {
                try
                {
                    if (!Permissoes.Autenticado(token, _db))
                    {
                        throw new HttpResponseException(HttpStatusCode.Unauthorized);
                    }

                    //_db.Configuration.ProxyCreationEnabled = false;

                    var verify = (from v in _db.LoginAutenticacaos
                                  where v.token.Equals(token)
                                  select v
                                  ).Single();

                    if (verify == null)
                    {
                        throw new HttpResponseException(HttpStatusCode.InternalServerError);
                    }

                    #region Log de Acesso ao Sistema
                    api.Models.Object.Log log = new api.Models.Object.Log();
                    log.IdUser       = verify.idUsers;
                    log.IdController = 45;
                    log.IdMethod     = 51;
                    log.DtAcesso     = DateTime.Now;

                    LogAcesso.New(log);
                    #endregion

                    return(AcessoUsuarioLogado(token, verify.idUsers, _db));
                }
                catch (Exception e)
                {
                    if (e.Message.Equals("401"))
                    {
                        throw new HttpResponseException(HttpStatusCode.Unauthorized);
                    }
                    else
                    {
                        throw new HttpResponseException(HttpStatusCode.InternalServerError);
                    }
                }
            }
        }
Exemple #18
0
        private List <dynamic> obtemListaComMudancas(SqlNotificationInfo Info = SqlNotificationInfo.Unknown)
        {
            List <dynamic> mudancas = new List <dynamic>();

            if (token == null || !Permissoes.Autenticado(token))
            {
                return(mudancas);
            }

            semaforo.WaitOne();

            List <FilaBootICard> oldList = list != null ? list : new List <FilaBootICard>();

            initList();

            DateTime dtOut = DateTime.Now;

            if (list != null)
            {
                try
                {
                    if (Info.Equals(SqlNotificationInfo.Delete))
                    {
                        // Delete
                        mudancas.Add(new { NotificationInfo = Info.ToString().ToUpper(),
                                           objetos          = oldList.Where(e => !list.Any(l => l.id == e.id))
                                                              .ToList <FilaBootICard>() });
                    }
                    else
                    {
                        // Insert, Update
                        mudancas.Add(new { NotificationInfo = Info.ToString().ToUpper(),
                                           objetos          = list.Where(e => !oldList.Any(l => l.id == e.id && l.stProcessamento == e.stProcessamento &&
                                                                                           l.dtInsert == e.dtInsert && l.webpages_UsersInsert.id_users == e.webpages_UsersInsert.id_users &&
                                                                                           ((l.cdUser == null && e.cdUser == null) || (l.cdUser != null && e.cdUser != null && l.cdUser.Value == e.cdUser.Value)) &&//((l.webpages_Users == null && e.webpages_Users == null) || (l.webpages_Users != null && e.webpages_Users != null && l.webpages_Users.id_users == e.webpages_Users.id_users)) &&
                                                                                           ((l.dtProcessamento == null && e.dtProcessamento == null) || (l.dtProcessamento != null && e.dtProcessamento != null && l.dtProcessamento.Value.Equals(e.dtProcessamento.Value)))))
                                                              .ToList <FilaBootICard>() });
                    }
                }
                catch (Exception e)
                {
                }
            }

            semaforo.Release(1);

            return(mudancas);
        }
Exemple #19
0
        private List <dynamic> obtemListaComMudancas(SqlNotificationInfo Info = SqlNotificationInfo.Unknown)
        {
            List <dynamic> mudancas = new List <dynamic>();

            if (filtro.Token == null || !Permissoes.Autenticado(filtro.Token))
            {
                return(mudancas);
            }

            semaforo.WaitOne();

            List <MonitorCargasBoot> oldList = list != null ? list : new List <MonitorCargasBoot>();

            initList();

            DateTime dtOut = DateTime.Now;

            if (list != null)
            {
                try
                {
                    if (Info.Equals(SqlNotificationInfo.Delete))
                    {
                        // Delete
                        mudancas = getListaAgrupadaEOrdenada(oldList
                                                             .Where(e => !list.Any(l => l.idLogCargaDetalhe == e.idLogCargaDetalhe))    //l.empresa.nu_cnpj == e.empresa.nu_cnpj && l.tbAdquirente.cdAdquirente == e.tbAdquirente.cdAdquirente))
                                                             .ToList <MonitorCargasBoot>(), Info);
                    }
                    else
                    {
                        // Insert, Update
                        mudancas = getListaAgrupadaEOrdenada(list
                                                             .Where(e => !oldList.Any(l => l.idLogCargaDetalhe == e.idLogCargaDetalhe && l.flStatus.Equals(e.flStatus) &&
                                                                                      ((l.dtExecucaoFim == null && e.dtExecucaoFim == null) ||
                                                                                       (l.dtExecucaoFim != null && e.dtExecucaoFim != null && l.dtExecucaoFim.Equals(e.dtExecucaoFim)))))
                                                             .ToList <MonitorCargasBoot>(), Info);
                    }
                }
                catch (Exception e)
                {
                }
            }

            semaforo.Release(1);

            return(mudancas);
        }
Exemple #20
0
 public HttpResponseMessage Post(string token, object param)
 {
     try
     {
         if (Permissoes.Autenticado(token))
         {
             return(Request.CreateResponse <object>(HttpStatusCode.OK, param));
         }
         else
         {
             return(Request.CreateResponse(HttpStatusCode.Unauthorized));
         }
     }
     catch
     {
         throw new HttpResponseException(HttpStatusCode.InternalServerError);
     }
 }
Exemple #21
0
 // POST /Nutricash/token/
 public HttpResponseMessage Post(string token, [FromBody] Nutricash param)
 {
     try
     {
         HttpResponseMessage retorno = new HttpResponseMessage();
         if (Permissoes.Autenticado(token))
         {
             return(Request.CreateResponse <Int32>(HttpStatusCode.OK, GatewayNutricash.Add(token, param)));
         }
         else
         {
             return(Request.CreateResponse(HttpStatusCode.Unauthorized));
         }
     }
     catch
     {
         throw new HttpResponseException(HttpStatusCode.InternalServerError);
     }
 }
Exemple #22
0
 // PUT /Sodexo/token/
 public HttpResponseMessage Put(string token, [FromBody] Sodexo param)
 {
     try
     {
         HttpResponseMessage retorno = new HttpResponseMessage();
         if (Permissoes.Autenticado(token))
         {
             GatewaySodexo.Update(token, param);
             return(Request.CreateResponse(HttpStatusCode.OK));
         }
         else
         {
             return(Request.CreateResponse(HttpStatusCode.Unauthorized));
         }
     }
     catch
     {
         throw new HttpResponseException(HttpStatusCode.InternalServerError);
     }
 }
 // DELETE /TB_UNIVERSIDADE_VIDEOS/token/UNV_ID_VIDEOS
 public void Delete(string token, Int64 id)
 {
     // Abre nova conexão
     using (ModelApiUnes _db = new ModelApiUnes())
     {
         try
         {
             if (Permissoes.Autenticado(token, _db))
             {
                 GatewayTbUniversidadeVideos.Delete(token, id, _db);
             }
             //else
             //return new Retorno() { Token = false }; //throw new Exception("Unauthorized");
         }
         catch (Exception e)
         {
             throw new Exception(e.Message);
         }
     }
 }
 public void Put(string token, [FromBody] TB_UNIVERSIDADE_TAG param)
 {
     // Abre nova conexão
     using (ModelApiUnes _db = new ModelApiUnes())
     {
         try
         {
             if (Permissoes.Autenticado(token, _db))
             {
                 GatewayTbUniversidadeTag.Update(token, param, _db);
             }
             //else
             //return new Retorno() { Token = false }; //throw new Exception("Unauthorized");
         }
         catch (Exception e)
         {
             throw new Exception(e.Message);
         }
     }
 }
Exemple #25
0
 // DELETE /Nutricash/token/id
 public HttpResponseMessage Delete(string token, Int32 id)
 {
     try
     {
         HttpResponseMessage retorno = new HttpResponseMessage();
         if (Permissoes.Autenticado(token))
         {
             GatewayNutricash.Delete(token, id);
             return(Request.CreateResponse(HttpStatusCode.OK));
         }
         else
         {
             return(Request.CreateResponse(HttpStatusCode.Unauthorized));
         }
     }
     catch
     {
         throw new HttpResponseException(HttpStatusCode.InternalServerError);
     }
 }
Exemple #26
0
 // GET /Nutricash/token/colecao/campo/orderBy/pageSize/pageNumber?CAMPO1=VALOR&CAMPO2=VALOR
 public HttpResponseMessage Get(string token, int colecao = 0, int campo = 0, int orderBy = 0, int pageSize = 0, int pageNumber = 0)
 {
     try
     {
         Dictionary <string, string> queryString = Request.GetQueryNameValuePairs().ToDictionary(x => x.Key, x => x.Value);
         HttpResponseMessage         retorno     = new HttpResponseMessage();
         if (Permissoes.Autenticado(token))
         {
             return(Request.CreateResponse <Retorno>(HttpStatusCode.OK, GatewayNutricash.Get(token, colecao, campo, orderBy, pageSize, pageNumber, queryString)));
         }
         else
         {
             return(Request.CreateResponse(HttpStatusCode.Unauthorized));
         }
     }
     catch
     {
         throw new HttpResponseException(HttpStatusCode.InternalServerError);
     }
 }
        // PUT /TB_UNIVERSIDADE_VIDEOS/token/
        public void Put(string token, Models.Object.VIDEOS_PERFIL param)
        {
            // Abre nova conexão
            using (ModelApiUnes _db = new ModelApiUnes())
            {
                try
                {
                    if (Permissoes.Autenticado(token, _db))
                    {
                        if (param.VIDEOS.UNV_TX_HASH != null)
                        {
                            param.VIDEOS.UNV_DT_DATA = null;
                            //param.UNV_NR_VIEW = null;
                            GatewayTbUniversidadeVideos.Update(token, param, _db);
                        }
                        else
                        {
                            Estatisticas values = new Estatisticas();
                            values.Idvideo   = param.VIDEOS.UNV_ID_VIDEOS;
                            values.Idusuario = Permissoes.GetIdUserFromToken(token);

                            GatewayTbUniversidadeVideos.Update(token, values);

                            TB_UNIVERSIDADE_ESTATISTICAS paramSt = new TB_UNIVERSIDADE_ESTATISTICAS();
                            paramSt.UNV_ID_VIDEOS   = values.Idvideo;
                            paramSt.USU_ID_USUARIO  = values.Idusuario;
                            paramSt.UNE_DT_DATAVIEW = DateTime.Now;

                            GatewayTbUniversidadeEstatisticas.Add(token, paramSt);
                        }
                    }
                    //else
                    //return new Retorno() { Token = false }; //throw new Exception("Unauthorized");
                }
                catch (Exception e)
                {
                    throw new Exception(e.Message);
                }
            }
        }
Exemple #28
0
        // POST /Recebimento/token/
        public HttpResponseMessage Post(string token, [FromBody] Recebimento param)
        {
            // Abre nova conexão
            using (painel_taxservices_dbContext _db = new painel_taxservices_dbContext())
            {
                tbLogAcessoUsuario log = new tbLogAcessoUsuario();
                try
                {
                    log = Bibliotecas.LogAcaoUsuario.New(token, JsonConvert.SerializeObject(param), "Post", _db);

                    HttpResponseMessage retorno = new HttpResponseMessage();
                    if (Permissoes.Autenticado(token, _db) && Permissoes.GetRoleLevel(token, _db) <= 1)
                    {
                        Int32 id = GatewayRecebimento.Add(token, param, _db);
                        log.codResposta = (int)HttpStatusCode.OK;
                        Bibliotecas.LogAcaoUsuario.Save(log, _db);
                        return(Request.CreateResponse(HttpStatusCode.OK, id));
                    }
                    else
                    {
                        log.codResposta = (int)HttpStatusCode.Unauthorized;
                        Bibliotecas.LogAcaoUsuario.Save(log, _db);
                        return(Request.CreateResponse(HttpStatusCode.Unauthorized));
                    }
                }
                catch (Exception e)
                {
                    log.codResposta = (int)HttpStatusCode.InternalServerError;
                    log.msgErro     = e.Message;
                    Bibliotecas.LogAcaoUsuario.Save(log);//, _db);
                    throw new HttpResponseException(HttpStatusCode.InternalServerError);
                }
                //finally
                //{
                //    // Fecha conexão
                //    _db.Database.Connection.Close();
                //    _db.Dispose();
                //}
            }
        }
 // POST /TB_UNIVERSIDADE_VIDEOS/token/
 public Int64 Post(string token, Models.Object.VIDEOS_PERFIL param)
 {
     // Abre nova conexão
     using (ModelApiUnes _db = new ModelApiUnes())
     {
         try
         {
             if (Permissoes.Autenticado(token, _db))
             {
                 return(GatewayTbUniversidadeVideos.Add(token, param, _db));
             }
             else
             {
                 return(0);// new Retorno() { Token = false }; //return new Retorno() { Token = false }; //throw new Exception("Unauthorized");
             }
         }
         catch (Exception e)
         {
             throw new Exception(e.Message);
         }
     }
 }
Exemple #30
0
        /*// POST /tbEmpresa/token/
         * public HttpResponseMessage Post(string token, [FromBody]tbEmpresa param)
         * {
         *  tbLogAcessoUsuario log = new tbLogAcessoUsuario();
         *  try
         *  {
         *      log = Bibliotecas.LogAcaoUsuario.New(token, JsonConvert.SerializeObject(param), "Post");
         *
         *      HttpResponseMessage retorno = new HttpResponseMessage();
         *      if (Permissoes.Autenticado(token))
         *      {
         *          string dados = GatewayTbEmpresa.Add(token, param);
         *          log.codResposta = (int)HttpStatusCode.OK;
         *          Bibliotecas.LogAcaoUsuario.Save(log);
         *          return Request.CreateResponse<string>(HttpStatusCode.OK, dados);
         *      }
         *      else
         *      {
         *          log.codResposta = (int)HttpStatusCode.Unauthorized;
         *          Bibliotecas.LogAcaoUsuario.Save(log);
         *          return Request.CreateResponse(HttpStatusCode.Unauthorized);
         *      }
         *  }
         *  catch (Exception e)
         *  {
         *      log.codResposta = (int)HttpStatusCode.InternalServerError;
         *      log.msgErro = e.Message;
         *      Bibliotecas.LogAcaoUsuario.Save(log);
         *      throw new HttpResponseException(HttpStatusCode.InternalServerError);
         *  }
         * }
         *
         * // PUT /tbEmpresa/token/
         * public HttpResponseMessage Put(string token, [FromBody]tbEmpresa param)
         * {
         *  tbLogAcessoUsuario log = new tbLogAcessoUsuario();
         *  try
         *  {
         *      log = Bibliotecas.LogAcaoUsuario.New(token, JsonConvert.SerializeObject(param), "Put");
         *
         *      HttpResponseMessage retorno = new HttpResponseMessage();
         *      if (Permissoes.Autenticado(token))
         *      {
         *          Retorno dados = GatewayTbEmpresa.Update(token, param);
         *          log.codResposta = (int)HttpStatusCode.OK;
         *          Bibliotecas.LogAcaoUsuario.Save(log);
         *          return Request.CreateResponse<Retorno>(HttpStatusCode.OK,dados);
         *      }
         *      else
         *      {
         *          log.codResposta = (int)HttpStatusCode.Unauthorized;
         *          Bibliotecas.LogAcaoUsuario.Save(log);
         *          return Request.CreateResponse(HttpStatusCode.Unauthorized);
         *      }
         *  }
         *  catch (Exception e)
         *  {
         *      log.codResposta = (int)HttpStatusCode.InternalServerError;
         *      log.msgErro = e.Message;
         *      Bibliotecas.LogAcaoUsuario.Save(log);
         *      throw new HttpResponseException(HttpStatusCode.InternalServerError);
         *  }
         * }*/

        /*// DELETE /tbEmpresa/token/nrCNPJBase
         * public HttpResponseMessage Delete(string token, string nrCNPJBase)
         * {
         *  tbLogAcessoUsuario log = new tbLogAcessoUsuario();
         *  try
         *  {
         *      log = Bibliotecas.LogAcaoUsuario.New(token, JsonConvert.SerializeObject("nrCNPJBase : " + nrCNPJBase), "Delete");
         *
         *      HttpResponseMessage retorno = new HttpResponseMessage();
         *      if (Permissoes.Autenticado(token))
         *      {
         *          GatewayTbEmpresa.Delete(token, nrCNPJBase);
         *          log.codResposta = (int)HttpStatusCode.OK;
         *          Bibliotecas.LogAcaoUsuario.Save(log);
         *          return Request.CreateResponse(HttpStatusCode.OK);
         *      }
         *      else
         *      {
         *          log.codResposta = (int)HttpStatusCode.Unauthorized;
         *          Bibliotecas.LogAcaoUsuario.Save(log);
         *          return Request.CreateResponse(HttpStatusCode.Unauthorized);
         *      }
         *  }
         *  catch (Exception e)
         *  {
         *      log.codResposta = (int)HttpStatusCode.InternalServerError;
         *      log.msgErro = e.Message;
         *      Bibliotecas.LogAcaoUsuario.Save(log);
         *      throw new HttpResponseException(HttpStatusCode.InternalServerError);
         *  }
         * }*/


        // PATCH /tbEmpresa/token/
        public HttpResponseMessage Patch(string token)
        {
            // Abre nova conexão
            using (painel_taxservices_dbContext _db = new painel_taxservices_dbContext())
            {
                tbLogAcessoUsuario log = new tbLogAcessoUsuario();
                try
                {
                    log = Bibliotecas.LogAcaoUsuario.New(token, null, "Patch", _db);

                    HttpResponseMessage retorno = new HttpResponseMessage();
                    if (Permissoes.Autenticado(token, _db))
                    {
                        Dictionary <string, string> queryString = Request.GetQueryNameValuePairs().ToDictionary(x => x.Key, x => x.Value);
                        Mensagem mensagem = GatewayTbEmpresa.Patch(token, queryString, _db);
                        log.codResposta = mensagem.cdMensagem;
                        if (mensagem.cdMensagem != 200)
                        {
                            log.msgErro = mensagem.dsMensagem;
                        }
                        Bibliotecas.LogAcaoUsuario.Save(log, _db);
                        return(Request.CreateResponse <Mensagem>(HttpStatusCode.OK, mensagem));
                    }
                    else
                    {
                        log.codResposta = (int)HttpStatusCode.Unauthorized;
                        Bibliotecas.LogAcaoUsuario.Save(log, _db);
                        return(Request.CreateResponse(HttpStatusCode.Unauthorized));
                    }
                }
                catch (Exception e)
                {
                    log.codResposta = (int)HttpStatusCode.InternalServerError;
                    log.msgErro     = e.Message;
                    Bibliotecas.LogAcaoUsuario.Save(log);
                    throw new HttpResponseException(HttpStatusCode.InternalServerError);
                }
            }
        }