public int NewLog(LogRegister log)
        {
            int rows = 0;

            using (var ctx = new UckLibMgrDbEntities())
            {
                ctx.LogRegisters.Add(log);
                rows = ctx.SaveChanges();
            }
            return(rows);
        }
Example #2
0
        public ResponseBussiness <PagoBancarioResponse> ProcesarMovimientoTarjetaBancariaVisaMaster(ProcesarMovimientoTarjetaBancariaRequest request)
        {
            LogRegister s = new LogRegister();

            s.LogEntry("  Inicio ProcesarMovimientoTarjetaBancariaVisaMaster", 2);

            s.LogEntry(request.ToString(), 4);
            TokenDto token = new TokenService().Get();
            //s.LogEntry($"Venta: {request.Venta.ToString()}, Retiro:{request.Retiro.ToString()}, Puntos:{request.Puntos.ToString() }", 4);

            ResponseBussiness <PagoBancarioResponse> response = new PaymentProcessingBusiness(token).ProcesarTarjetaBancariaVisaMaster(request);

            s.LogEntry("  Termina ProcesarMovimientoTarjetaBancariaVisaMaster", 2);
            return(response);
        }
Example #3
0
        /// <summary>
        /// Metodo que valida el token
        /// </summary>
        /// <param name="operationContext">metodo que se ejecutara</param>
        /// <returns></returns>
        protected override bool CheckAccessCore(OperationContext operationContext)
        {
            LogRegister s = new LogRegister();

            s.LogEntry(" CheckAccessCore: Inicio (Validando Token) ", 2);

            Thread.CurrentThread.CurrentCulture   = CultureInfo.CreateSpecificCulture("es-MX");
            Thread.CurrentThread.CurrentUICulture = new CultureInfo("es-MX");

            var    authHeader = WebOperationContext.Current.IncomingRequest.Headers["Authorization"];
            String webServiceRequestedPath = WebOperationContext.Current.IncomingRequest.UriTemplateMatch.RequestUri.OriginalString;

            if (!webServiceRequestedPath.Contains("Sincronizacion/Sincronizacionservice.svc/ejecutarProcesoSincronizacion"))
            {
                if ((authHeader != null) && (authHeader != string.Empty))
                {
                    try
                    {
                        var    access_token    = Encrypted.Decode(authHeader);
                        var    token           = JsonConvert.DeserializeObject <Dictionary <string, object> >(access_token);
                        var    usuario         = token["usuario"].ToString();
                        var    fechaExpiracion = DateTime.Now.AddYears(100); //OCG DateTime.Parse(token["exp"].ToString());
                        string recursos        = token["resources"].ToString();
                        if (DateTime.Now > fechaExpiracion)
                        {
                            throw new WebFaultException <string>("El Token de Acceso Expiró", HttpStatusCode.Unauthorized);
                        }
                        List <string> listaRecursos = new List <string>();
                        foreach (var resource in recursos.Split('|'))
                        {
                            listaRecursos.Add(resource);
                        }
                        try
                        {
                            Thread.CurrentPrincipal = new GenericPrincipal(new GenericIdentity(usuario), listaRecursos.ToArray());
                        }
                        catch (SecurityException ex)
                        {
                            throw new WebFaultException <string>(ex.ToString(), HttpStatusCode.Unauthorized);
                        }
                        s.LogEntry(" CheckAccessCore: FIN (Token valido) ", 2);
                        return(true);
                    }
                    catch (Exception ex)
                    {
                        _ = ex.Message;
                        //Throw an exception with the associated HTTP status code equivalent to HTTP status 401
                        throw new WebFaultException <string>("El Token de acceso no es válido", HttpStatusCode.Unauthorized);
                    }
                }
                else
                {
                    //Throw an exception with the associated HTTP status code equivalent to HTTP status 401
                    throw new WebFaultException <string>("No existe cabecera de autorización", HttpStatusCode.Unauthorized);
                }
            }
            else
            {
                s.LogEntry(" CheckAccessCore: FIN (Token valido) ", 2);
                return(true);
            }
        }
        private void RUNALL()
        {
            _isScroll = true;
            Stopwatch _st = new Stopwatch();

            _st.Start();
            bool _flag = true;

            GlobalData.logManager              = null; //ko luu log neu logManager = null
            GlobalData.logRegister             = null;
            GlobalData.testingData.TOTALRESULT = InitParameters.Statuses.Wait;

            //Đọc file cấu hình config
            if (!Read_All_Config_File())
            {
                GlobalData.testingData.ERRORCODE = "{ ErrorCode: 0x001 }";
                _flag = false;
                goto Finished;
            }

            //Kết nối telnet tới ONT và máy đo
            if (!baseFunction.Connect_Function())
            {
                GlobalData.testingData.ERRORCODE = "{ ErrorCode: 0x002 }";
                _flag = false;
                goto Finished;
            }

            GlobalData.logManager     = new logdata(); //luu log test
            GlobalData.logManager.mac = GlobalData.testingData.MACADDRESS;


            if (GlobalData.initSetting.STATION == "Trước đóng vỏ")
            {
                Calibration calib = new Calibration(GlobalData.MODEM, GlobalData.INSTRUMENT);
                if (!calib.Excute())
                {
                    _flag = false;
                    goto Finished;
                }
            }
            else
            {
                TestAnten testat = new TestAnten(GlobalData.MODEM, GlobalData.INSTRUMENT);
                if (!testat.Excute())
                {
                    _flag = false;
                    goto Finished;
                }
            }

Finished:
            GlobalData.testingData.LOGSYSTEM += string.Format("{0} ĐÃ HOÀN THÀNH.\r\n", _flag == true ? "[OK]" : "[NG]");
            _st.Stop();
            GlobalData.testingData.LOGSYSTEM  += string.Format("Tổng thời gian test: {0} sec.\r\n", _st.ElapsedMilliseconds / 1000);
            GlobalData.testingData.TOTALRESULT = _flag == true ? "PASS" : "FAIL";

            GlobalData.logManager.errorCode   = GlobalData.testingData.ERRORCODE;
            GlobalData.logManager.totalResult = GlobalData.testingData.TOTALRESULT;

            if (GlobalData.logManager != null)
            {
                LogFile.Savetestlog(GlobalData.logManager);
                LogFile.Savedetaillog(GlobalData.testingData.LOGSYSTEM);
                LogFile.Savereviewlog(GlobalData.logManager.mac, GlobalData.testingData.TOTALRESULT);
            }
            if (GlobalData.logRegister != null)
            {
                GlobalData.logRegister.macaddress  = GlobalData.logManager.mac;
                GlobalData.logRegister.totalresult = GlobalData.testingData.TOTALRESULT;
                LogRegister.Save(GlobalData.logRegister);
            }
            _isScroll = false;
        }