Beispiel #1
0
        //----------------- Servicios de Sincronización de Pago y Reversión -----------------//
        #region Servicios de Sincronización de Pago y Reversión

        public void sendListNumberToServer(LTL_LotteryList pList, List <LND_ListNumberDetail> pNumberDetail)
        {
            // Llamar al servicio de sincronización con el servidor
            ServerConnectionService service        = new ServerConnectionService();
            ServiceResponseResult   responseResult = service.syncListToServer(pList, pNumberDetail, result => processResponseToSendList(result));
            //this.processResponseToSendList(responseResult);
        }
Beispiel #2
0
        public bool syncDraw_ServerToLocal()
        {
            bool successProcess = true;
            long posId          = ParameterService.getSalePointId();

            // Realizar sincronización solamente si la sucursal está asignada
            if (posId != 0)
            {
                // Realizar la petición http
                ServerConnectionService connection     = new ServerConnectionService();
                ServiceResponseResult   responseResult = connection.getReopenDrawList(posId);
                successProcess = this.isValidResponse(responseResult);
                if (successProcess)
                {
                    string jsonStringResult = responseResult.result.ToString();
                    // Obtener array de los id de sorteos reabiertos para la sucursal
                    JArray jsonArray = JArray.Parse(jsonStringResult);
                    // Realizar la persistencia de los sorteos reabiertos
                    LotteryDrawRepository drawRepo = new LotteryDrawRepository();
                    foreach (var drawId in jsonArray)
                    {
                        LTD_LotteryDraw draw = drawRepo.getById((long)drawId);
                        if (draw != null)
                        {
                            draw.LDS_LotteryDrawStatus = SystemConstants.DRAW_STATUS_REOPENED;
                            drawRepo.save(ref draw);
                            // Cambiar todos los registros de QR a pendiente
                            ListService listService = new ListService();
                            listService.changeListStatusFromQRUpdated(draw, SystemConstants.SYNC_STATUS_PENDING_TO_SERVER);
                        }
                    }
                }
            }
            return(successProcess);
        }
Beispiel #3
0
        public bool syncPrizeFactor_ServerToLocal()
        {
            bool successProcess = true;
            // Realizar la petición http
            ServerConnectionService connection     = new ServerConnectionService();
            ServiceResponseResult   responseResult = connection.getPrizeFactorFromServer();

            successProcess = this.isValidResponse(responseResult);
            if (successProcess)
            {
                string           jsonStringResult = responseResult.result.ToString();
                JsonObjectParser parser           = new JsonObjectParser((int)EntityType.PrizeFactor);
                // Reemplazar objetos complejos en el json por su id
                JArray jsonArray = JArray.Parse(jsonStringResult);
                foreach (var item in jsonArray)
                {
                    parser.changeJsonProp(item, "lotteryPointSale");
                    parser.changeJsonProp(item, "lotteryDrawType");
                    parser.changeJsonProp(item, "synchronyStatus");
                }
                // Parsear el json de respuesta
                string parsedJsonString = parser.parse(jsonArray.ToString());
                // Realizar la persistencia de los cambios
                LotteryPrizeFactorRepository prizeFactorRepo = new LotteryPrizeFactorRepository();
                prizeFactorRepo.saveList(JsonConvert.DeserializeObject <List <LPF_LotteryPrizeFactor> >(parsedJsonString));
            }
            return(successProcess);
        }
Beispiel #4
0
        public async Task <ServiceResponseResult> reverseListNumberFromServerAsync(LTL_LotteryList pList)
        {
            // Llamar al servicio de sincronización con el servidor
            ServerConnectionService serverConection = new ServerConnectionService();
            ServiceResponseResult   response        = await serverConection.reverseListToServerAsync(pList);

            return(response);
        }
Beispiel #5
0
        public async Task <ServiceResponseResult> syncWinnerNumbersToServerAsync(LTD_LotteryDraw pDraw, string[] pWinningNumberArray)
        {
            // Llamar al servicio de sincronización con el servidor
            ServerConnectionService service        = new ServerConnectionService();
            ServiceResponseResult   responseResult = await service.syncWinnerNumbersToServerAsync(pDraw, pWinningNumberArray);

            this.processResponseToClosingDraw(responseResult);
            return(responseResult);
        }
Beispiel #6
0
        public async Task <ServiceResponseResult> closeDrawInServerAsync(DateTime pDrawDate, long pGroupId)
        {
            // Llamar al servicio de sincronización con el servidor
            ServerConnectionService service        = new ServerConnectionService();
            ServiceResponseResult   responseResult = await service.closeDrawInServerAsync(pDrawDate, pGroupId);

            this.processResponseToClosingDraw(responseResult);
            return(responseResult);
        }
Beispiel #7
0
        public async Task <ServiceResponseResult> sendListNumberToServerAsync(LTL_LotteryList pList, List <LND_ListNumberDetail> pNumberDetail)
        {
            // Llamar al servicio de sincronización con el servidor
            ServerConnectionService service        = new ServerConnectionService();
            ServiceResponseResult   responseResult = await service.syncListToServerAsync(pList, pNumberDetail);

            this.processResponseToSendList(responseResult);
            return(responseResult);
        }
Beispiel #8
0
        public void reverseListNumberFromServer(LTL_LotteryList pList)
        {
            // Llamar al servicio de sincronización con el servidor
            ServerConnectionService serverConection = new ServerConnectionService();
            ServiceResponseResult   response        = serverConection.reverseListToServer(pList);

            if (ServiceValidator.isValidServiceResponse(response))
            {
                // Cambiar el estado de la lista local a Sincronizado
                this.setListCompleteSync(pList);
            }
            else
            {
                // Error de sincronización
                string responseType = response == null ? "N/A" : response.type;
                LogService.logErrorServiceResponse("No se pudo sincronizar la venta", responseType, "Pendiente");
            }
        }
Beispiel #9
0
        public bool syncCompany_ServerToLocal()
        {
            bool successProcess = true;
            // Realizar la petición http
            ServerConnectionService connection     = new ServerConnectionService();
            ServiceResponseResult   responseResult = connection.getCompaniesFromServer();

            successProcess = this.isValidResponse(responseResult);
            if (successProcess)
            {
                string result = responseResult.result.ToString();
                // Parsear el json de respuesta
                JsonObjectParser parser           = new JsonObjectParser((int)EntityType.Company);
                string           parsedJsonString = parser.parse(result);
                // Realizar la persistencia de los cambios
                CompanyRepository companyRepo = new CompanyRepository();
                companyRepo.saveList(JsonConvert.DeserializeObject <List <CPN_Company> >(parsedJsonString));
            }
            return(successProcess);
        }
Beispiel #10
0
        // Enviar sincronización de números al servidor
        public bool syncDrawType_LocalToServer()
        {
            bool successProcess = true;
            LotteryDrawTypeRepository  drawTypeRepository = new LotteryDrawTypeRepository();
            List <LDT_LotteryDrawType> unsynDrawTypeList  = drawTypeRepository.findUnsynTypes();

            // Sincronizar a servidor si existen elementos pendientes en cliente
            if (unsynDrawTypeList.Count > 0)
            {
                // Crear JsonArray
                var jsonObjectArray = new dynamic[unsynDrawTypeList.Count()];
                for (int i = 0; i < unsynDrawTypeList.Count(); i++)
                {
                    // Crear objeto json
                    var jsonObject = new
                    {
                        id          = unsynDrawTypeList[i].LDT_Id,
                        code        = unsynDrawTypeList[i].LDT_Code,
                        displayName = unsynDrawTypeList[i].LDT_DisplayName,
                        description = unsynDrawTypeList[i].LDT_Description
                    };
                    // Agregar el objeto al array
                    jsonObjectArray[i] = jsonObject;
                }
                var jsonNumberArray = new { items = jsonObjectArray };
                //Console.WriteLine(JsonConvert.SerializeObject(jsonNumberArray));
                ServerConnectionService connection     = new ServerConnectionService();
                ServiceResponseResult   responseResult = connection.sendDrawTypeToService(jsonNumberArray);
                string codeSectionDetail = MethodBase.GetCurrentMethod().DeclaringType.Name + ": " + MethodBase.GetCurrentMethod().Name;
                successProcess = this.isValidResponse(responseResult, codeSectionDetail);
                // Validar resultado de la sincronización
                if (successProcess)
                {
                    // Si el resultado del proceso es exitoso, cambiar estado a sincronizado
                    drawTypeRepository.changeStates(unsynDrawTypeList, SystemConstants.SYNC_STATUS_COMPLETED);
                }
            }
            return(successProcess);
        }
Beispiel #11
0
        // Enviar sincronización de números al servidor
        public bool syncNumbers_LocalToServer()
        {
            bool successProcess = true;
            LotteryNumberRepository  numberRepository = new LotteryNumberRepository();
            List <LNR_LotteryNumber> unsynNumberList  = numberRepository.findUnsynUsers();

            // Sincronizar a servidor si existen elementos pendientes en cliente
            if (unsynNumberList.Count > 0)
            {
                // Crear JsonArray
                var jsonObjectArray = new dynamic[unsynNumberList.Count()];
                for (int i = 0; i < unsynNumberList.Count(); i++)
                {
                    // Crear objeto json
                    var jsonObject = new
                    {
                        id     = unsynNumberList[i].LNR_Id,
                        number = unsynNumberList[i].LNR_Number,
                        //isProhibited = unsynNumberList[i].LNR_IsProhibited
                        isProhibited = unsynNumberList[i].LNR_IsProhibited == 1 ? true : false
                    };
                    // Agregar el objeto al array
                    jsonObjectArray[i] = jsonObject;
                }
                var jsonNumberArray = new { items = jsonObjectArray };
                ServerConnectionService connection     = new ServerConnectionService();
                ServiceResponseResult   responseResult = connection.sendNumberDataToService(jsonNumberArray);
                string codeSectionDetail = MethodBase.GetCurrentMethod().DeclaringType.Name + ": " + MethodBase.GetCurrentMethod().Name;
                successProcess = this.isValidResponse(responseResult, codeSectionDetail);
                // Validar resultado de la sincronización
                if (successProcess)
                {
                    // Si el resultado del proceso es exitoso, cambiar estado a sincronizado
                    numberRepository.changeStates(unsynNumberList, SystemConstants.SYNC_STATUS_COMPLETED);
                }
            }
            return(successProcess);
        }