Exemple #1
0
        public static bool[] getProhibitedArray()
        {
            bool[] prohibitedArray = new bool[100];
            Dictionary <long, bool> prohibitedCollection = new Dictionary <long, bool>();
            LotteryNumberRepository numberRepository     = new LotteryNumberRepository();

            // Crear diccionario para realizar la conversión
            foreach (var item in numberRepository.getAll())
            {
                bool prohibited = item.LNR_IsProhibited == 1 ? true : false;
                prohibitedCollection.Add(item.LNR_Id, prohibited);
            }
            // Llenar el array de los prohibidos
            for (int i = 0; i < prohibitedArray.Length; i++)
            {
                bool isProhibited = false;
                int  numberId     = (i == 0 ? 100 : i);
                if (prohibitedCollection.TryGetValue(numberId, out isProhibited))
                {
                    prohibitedArray[i] = isProhibited;
                }
                else
                {
                    prohibitedArray[i] = false;
                }
            }
            return(prohibitedArray);
        }
Exemple #2
0
        public bool syncNumbers_ServerToLocal()
        {
            bool successProcess = true;
            // Realizar la petición http
            ServerConnectionService connection     = new ServerConnectionService();
            ServiceResponseResult   responseResult = connection.getNumbersFromServer();

            successProcess = this.isValidResponse(responseResult);
            if (successProcess)
            {
                string result = responseResult.result.ToString();
                // Parsear el json de respuesta
                JsonObjectParser parser           = new JsonObjectParser((int)EntityType.LotteryNumber);
                string           parsedJsonString = parser.parse(result);
                // Realizar la persistencia de los cambios
                LotteryNumberRepository numberRepo = new LotteryNumberRepository();
                numberRepo.saveList(JsonConvert.DeserializeObject <List <LNR_LotteryNumber> >(parsedJsonString));
            }
            return(successProcess);
        }
Exemple #3
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);
        }
Exemple #4
0
        public static void saveProhibitedNumbers(int [] pArray)
        {
            LotteryNumberRepository pointSaleRepository = new LotteryNumberRepository();

            pointSaleRepository.saveProhibitedNumbers(pArray);
        }