Example #1
0
    public static PortalApiModel.RetornoTransicionarSistema TransicionarSistema(PortalApiModel.TransicionarSistema parametros)
    {
        //
        WebReturn <bool> retr = new WebReturn <bool>();

        try
        {
            PortalApiModel.RetornoTransicionarSistema retorno = new PortalApiModel.RetornoTransicionarSistema();
            //
            ControleDeAcessoTO.ObterSistemasPermitidos sistemaSelecionado;
            if (ControleDeAcesso.MODODESENVOLVIMENTO == 0)
            {
                sistemaSelecionado = ControleDeAcesso.ObterConjuntoDePermissoesUsuario(HttpContext.Current.Session).SistemasPermitidos.Where(x => x.CODSISINF == parametros.CODSISINF).FirstOrDefault();
            }
            else
            {
                sistemaSelecionado = new ControleDeAcessoTO.ObterSistemasPermitidos()
                {
                    DESURLLNK = ControleDeAcesso.URLSISTEMAMODODESENVOLVIMENTO
                }
            };
            if (sistemaSelecionado != null)
            {
                var PRIVATEKEY = GerarChavePrivada();
                var codFnc     = ControleDeAcesso.ObterConjuntoDePermissoesUsuario(HttpContext.Current.Session).InformacoesUsuario.CODFNC;
                //
                retorno.PUBLICTOKEN = Encriptar(PRIVATEKEY, new JavaScriptSerializer().Serialize(new ControleDeAcesso.ParametrosCriptografia()
                {
                    ParametrosTransicao = parametros, CODFNC = codFnc
                }));
                //
                retorno.PUBLICKEY = CalcularMD5(PRIVATEKEY);
                retorno.DESURLLNK = sistemaSelecionado.DESURLLNK + CAMINHOAPISISTEMAS + "?PUBLICKEY=" + HttpUtility.UrlEncode(retorno.PUBLICKEY) + "&PUBLICTOKEN=" + HttpUtility.UrlEncode(retorno.PUBLICTOKEN);
                //
                lock (ControleDeAcesso.PENDINGTOKENS)
                    ControleDeAcesso.PENDINGTOKENS.Add(new ControleDeAcesso.PENDINGTOKEN
                                                           ()
                    {
                        DTEXP      = DateTime.Now.AddSeconds(10),
                        PRIVATEKEY = PRIVATEKEY,
                        PUBLICKEY  = retorno.PUBLICKEY
                    });
            }
            return(retorno);
        }
        catch (Exception ex)
        {
            retr.Code    = 1;
            retr.Message = ex.Message;
            Utilitarios.CriaLogErro(ex);
            Utilitarios.InserirLog(ex,
                                   System.Reflection.MethodInfo.GetCurrentMethod().Name,
                                   string.Join(";", System.Reflection.MethodInfo.GetCurrentMethod().GetParameters().Select(val => val.Name)),
                                   ex.GetType().Name,
                                   "ERRO TRANSACIONAR SISTEMA.!!");
            return(null /* TODO Change to default(_) if this is not a reference type */);
        }
    }
 public PortalApiModel.RetornoTransicionarSistema TransicionarSistema(PortalApiModel.TransicionarSistema parametro)
 {
     return(Encryption.TransicionarSistema(parametro));
 }