Ejemplo n.º 1
0
        public async Task <ServiceResponse <GetTerminalExternalClientDto> > GetTerminalExternalClientById(string terminalID)
        {
            ServiceResponse <GetTerminalExternalClientDto> serviceResponse = new ServiceResponse <GetTerminalExternalClientDto>();

            try{
                Terminal terminalExternal = await _context.Terminals
                                            .Include(s => s.SystemPOS)
                                            .Where(t => t.TerminalID.Equals(terminalID))
                                            .FirstAsync();

                //var terminalExternalDto = _mapper.Map<List<TerminalsExternalDto>>(terminalsExternal);

                GetTerminalExternalClientDto terextDto = new GetTerminalExternalClientDto();


                AcquirerDto acq = new AcquirerDto();
                terextDto.TerminalID      = terminalExternal.TerminalID;
                terextDto.SerialNumber    = terminalExternal.SerialNumber;
                terextDto.nombreComercial = terminalExternal.Custom1;
                terextDto.direccionFiscal = terminalExternal.Custom2;
                terextDto.rut             = terminalExternal.Custom3;



                acq.acqVisanet          = terminalExternal.Custom4;
                acq.acqFirstdata        = terminalExternal.Custom5;
                acq.acqOca              = terminalExternal.Custom6;
                acq.acqCreditosDirectos = terminalExternal.Custom7;
                acq.acqCabal            = terminalExternal.Custom8;
                acq.acqCreditel         = terminalExternal.Custom9;
                acq.acqPasscard         = terminalExternal.Custom10;
                acq.acqEdenred          = terminalExternal.Custom11;
                acq.acqAnda             = terminalExternal.Custom12;
                acq.acqAMEX             = terminalExternal.Custom13;
                acq.acqClubDelEste      = terminalExternal.Custom14;
                acq.acqMides            = terminalExternal.Custom15;
                acq.acqCabal_usd        = terminalExternal.Custom19;

                terextDto.acquirer     = acq;
                terextDto.ConnectGroup = terminalExternal.SystemPOS.ConnectGroup;
                terextDto.terminalInit = terminalExternal.SystemPOS.TerminalChecksum;
                terextDto.merchantType = terminalExternal.SystemPOS.ControlGroup;


                TerminalStatus ter = await _context.TerminalsStatus.FirstOrDefaultAsync(t => t.TerminalID.Equals(terminalID));

                if (ter != null)
                {
                    terextDto.terminalEnabled = ter.status;
                }
                else
                {
                    terextDto.terminalEnabled = TerminalStatusDisabled;
                }


                if (existTerminalJPOS(terminalID).Result)
                {
                    //ver cual tomamos del value si el campo que está en ptf o ca
                    //string term = addca+terminalID;
                    //Sysconfig sysconfig = await _MySqlcontext.sysconfig.FirstOrDefaultAsync(t => t.id.Equals(term));
                    //parametros de JPOS falta definir cuales son
                    var jpos = await _MySqlcontext.sysconfig.FirstOrDefaultAsync(j => j.id.Equals(addca + terminalID));

                    if (jpos != null)
                    {
                        if (jpos.value != null)
                        {
                            jpos jp = new jpos();
                            jp.setSysconfigValue_CA(jpos.value);

                            string ca    = jp.getCA();
                            string mcc   = jp.getMcc();
                            string pf_id = jp.getPf_id();
                            string visa_spnsrd_mercht = jp.getVisa_spnsrd_mercht();
                            string amex_id_comercio   = jp.getAmex_id_comercio();

                            terextDto.ca_name            = ca.Length == 0 ? null : ca;
                            terextDto.mcc                = mcc.Length == 0 ? null : mcc;
                            terextDto.pf_id              = pf_id.Length == 0 ? null : pf_id;
                            terextDto.visa_spnsrd_mercht = visa_spnsrd_mercht.Length == 0 ? null : visa_spnsrd_mercht;
                            terextDto.amex_id_comercio   = amex_id_comercio.Length == 0 ? null : amex_id_comercio;
                        }
                    }


                    ///terextDto.id = sysconfig.id;
                    ///terextDto.value = sysconfig.value;

                    //RESPETAR ORDEN COMO EN FullTerminalSystemService
                    //fullTerminalSystem.ca+"."+fullTerminalSystem.mcc+"."+fullTerminalSystem.pf_id+
                    //"."+fullTerminalSystem.visa_spnsrd_mercht+"."+fullTerminalSystem.amex_id_comercio

                    //se agrega ',' (coma) segun req.
                    //RST-64

                    /*char [] splitchar = {','};
                     * string [] strArr = null;
                     * string value = sysconfig.value;
                     * //tomo los 40 caracteres primero y los agrego en caname2
                     * if(value.TrimEnd() != "0")
                     * {
                     *  string caname2 = value.Substring(0,40);
                     *  //tring[] jpos_values= sysconfig.value.Split('.');
                     *  //me quedo con el string luego del caname
                     *  string aux = value.Substring(41);
                     *  //separo por '.' el string restante
                     *  strArr = aux.Split(splitchar);
                     *
                     *  if(strArr.Length > 1)
                     *  {
                     *      //Quita los espacios en blanco del final del String
                     *      terextDto.ca_name=caname2.TrimEnd();
                     *      terextDto.mcc= strArr[0];
                     *      terextDto.pf_id=strArr[1];
                     *      terextDto.visa_spnsrd_mercht=strArr[2];
                     *      terextDto.amex_id_comercio=strArr[3];
                     *  }
                     *  else
                     *  {
                     *      terextDto.ca_name=caname2.TrimEnd();
                     *      terextDto.mcc=null;
                     *      terextDto.pf_id=null;
                     *      terextDto.visa_spnsrd_mercht=null;
                     *      terextDto.amex_id_comercio=null;
                     *
                     *  }
                     * }else
                     * {
                     *  terextDto.ca_name=value.TrimEnd();
                     *  terextDto.mcc=null;
                     *  terextDto.pf_id=null;
                     *  terextDto.visa_spnsrd_mercht=null;
                     *  terextDto.amex_id_comercio=null;
                     * }*/
                }

                terextDto.terminalInit = _csvfile.TerminalInitialized(terminalID) ? 1 : 0;

                serviceResponse.Data = terextDto;
            }

            catch (Exception ex)
            {
                serviceResponse.Success = false;
                serviceResponse.Message = ex.Message;
            }
            return(serviceResponse);
        }
Ejemplo n.º 2
0
        public async Task <ServiceResponse <GetFullTerminalSystemDto> > GetFullTerminalSystemByID(string terminal_id)
        {
            ServiceResponse <GetFullTerminalSystemDto> serviceResponse = new ServiceResponse <GetFullTerminalSystemDto>();

            try
            {
                var terminal = await _context.Terminals.FirstOrDefaultAsync(t => t.TerminalID.Equals(terminal_id));

                var system = await _context.SystemPOSs.FirstOrDefaultAsync(t => t.TerminalID.Equals(terminal_id));

                GetFullTerminalSystemDto fullTerminalSystem = new GetFullTerminalSystemDto();
                fullTerminalSystem.TerminalID   = terminal.TerminalID;
                fullTerminalSystem.SerialNumber = terminal.SerialNumber;
                //rst-69
                fullTerminalSystem.ParmConnectTime = terminal.ParmConnectTime;
                fullTerminalSystem.HeaderLine1     = terminal.Custom1;
                fullTerminalSystem.HeaderLine2     = terminal.Custom2;

                //remove RUT:
                fullTerminalSystem.HeaderLine3 = terminal.Custom3.Remove(0, 4);
                fullTerminalSystem.Custom4     = terminal.Custom4;
                fullTerminalSystem.Custom5     = terminal.Custom5;
                fullTerminalSystem.Custom6     = terminal.Custom6;
                fullTerminalSystem.Custom7     = terminal.Custom7;
                fullTerminalSystem.Custom8     = terminal.Custom8;
                fullTerminalSystem.Custom9     = terminal.Custom9;
                fullTerminalSystem.Custom10    = terminal.Custom10;
                fullTerminalSystem.Custom11    = terminal.Custom11;
                fullTerminalSystem.Custom12    = terminal.Custom12;
                fullTerminalSystem.Custom13    = terminal.Custom13;
                fullTerminalSystem.Custom14    = terminal.Custom14;
                fullTerminalSystem.Custom15    = terminal.Custom15;
                fullTerminalSystem.Custom16    = terminal.Custom16;
                fullTerminalSystem.Custom19    = terminal.Custom19;
                fullTerminalSystem.merchanType = system.ControlGroup;

                //actualizar datos terminal
                if (system.TerminalChecksum == 0)
                {
                    fullTerminalSystem.TerminalChecksum = true;
                }
                else
                {
                    fullTerminalSystem.TerminalChecksum = false;
                }

                //actualizar parametros de conexion
                if (system.ParmConnChecksum == 0)
                {
                    fullTerminalSystem.ParmConnChecksum = true;
                }
                else
                {
                    fullTerminalSystem.ParmConnChecksum = false;
                }

                //actualizar tipo de comercio - controlchecksum
                if (system.ControlCheckSum == 0)
                {
                    fullTerminalSystem.ControlCheckSum = true;
                }
                else
                {
                    fullTerminalSystem.ControlCheckSum = false;
                }

                //cargar parametros de conexion
                if (system.ParameterReload == 1)
                {
                    fullTerminalSystem.ParameterReload = true;
                }
                else
                {
                    fullTerminalSystem.ParameterReload = false;
                }

                //cargar programa - program reload
                if (system.ProgramReload == 1)
                {
                    fullTerminalSystem.ProgramReload = true;
                }
                else
                {
                    fullTerminalSystem.ProgramReload = false;
                }

                fullTerminalSystem.ParameterGroup   = system.ParameterGroup;
                fullTerminalSystem.ParameterVersion = system.ParameterVersion;
                fullTerminalSystem.ProgramID        = system.ProgramID;
                fullTerminalSystem.ProgramVersion   = system.ProgramVersion;
                fullTerminalSystem.Paquete          = system.Paquete;
                fullTerminalSystem.ConnectGroup     = system.ConnectGroup;


                //parametros de JPOS falta definir cuales son
                var jpos = await _MySqlcontext.sysconfig.FirstOrDefaultAsync(j => j.id.Equals(addca + fullTerminalSystem.TerminalID));

                if (jpos != null)
                {
                    if (jpos.value != null)
                    {
                        jpos jp = new jpos();
                        jp.setSysconfigValue_CA(jpos.value);

                        string ca    = jp.getCA();
                        string mcc   = jp.getMcc();
                        string pf_id = jp.getPf_id();
                        string visa_spnsrd_mercht = jp.getVisa_spnsrd_mercht();
                        string amex_id_comercio   = jp.getAmex_id_comercio();

                        fullTerminalSystem.ca    = ca.Length == 0 ? null : ca;
                        fullTerminalSystem.mcc   = mcc.Length == 0 ? null : mcc;
                        fullTerminalSystem.pf_id = pf_id.Length == 0 ? null : pf_id;
                        fullTerminalSystem.visa_spnsrd_mercht = visa_spnsrd_mercht.Length == 0 ? null : visa_spnsrd_mercht;
                        fullTerminalSystem.amex_id_comercio   = amex_id_comercio.Length == 0 ? null : amex_id_comercio;
                    }

                    var status = await _context.TerminalsStatus.FirstOrDefaultAsync(s => s.TerminalID.Equals(terminal_id));

                    if (status != null)
                    {
                        if (status.status == 1)
                        {
                            fullTerminalSystem.enabled_JPOS = true;
                        }
                        else
                        {
                            fullTerminalSystem.enabled_JPOS = false;
                        }
                    }
                    else
                    {
                        fullTerminalSystem.enabled_JPOS = false;
                    }
                }
                serviceResponse.Data = fullTerminalSystem;
            }
            catch (Exception ex)
            {
                serviceResponse.Success = false;
                serviceResponse.Message = ex.Message;
            }

            return(serviceResponse);
        }