Beispiel #1
0
        public static long getPointSaleId()
        {
            LotteryPointSaleRepository posRepository = new LotteryPointSaleRepository();
            long posId = Convert.ToInt64(getLocalParameterValue(POS_NAME_PARAM));

            return(posRepository.getById(posId).LPS_Id);
        }
        public bool requestPosInitialization()
        {
            bool instanceSetting = true;
            long userPosId       = SystemSession.sessionUser.LPS_LotteryPointSale;
            LotteryPointSaleRepository pointSaleRepo = new LotteryPointSaleRepository();

            SystemSession.sessionPointSale = pointSaleRepo.getById(userPosId);
            DialogResult msgResult =
                MessageService.displayConfirmMessage(
                    GeneralConstants.getPosConfirmMessage(SystemSession.sessionUser, SystemSession.sessionPointSale),
                    GeneralConstants.POS_CONFIRM_TITLE
                    );

            // Procesar el resultado de la confirmación
            switch (msgResult)
            {
            case DialogResult.Yes:
                // Configurar la instancia de sucursal
                this.initializePosParameter(userPosId);
                break;

            case DialogResult.No:
                instanceSetting = false;
                MessageService.displayErrorMessage(
                    GeneralConstants.POS_INITIALIZATION_ERROR,
                    GeneralConstants.POS_INITIALIZATION_TITLE
                    );
                break;

            default:
                break;
            }
            return(instanceSetting);
        }
Beispiel #3
0
        public bool syncSalePoint_ServerToLocal()
        {
            bool successProcess = true;
            // Realizar la petición http
            ServerConnectionService connection     = new ServerConnectionService();
            ServiceResponseResult   responseResult = connection.getSalePointsFromServer();

            successProcess = this.isValidResponse(responseResult);
            if (successProcess)
            {
                string           jsonStringResult = responseResult.result.ToString();
                JsonObjectParser parser           = new JsonObjectParser((int)EntityType.PointSale);
                // Reemplazar objetos complejos en el json por su id
                JArray jsonArray = JArray.Parse(jsonStringResult);
                foreach (var item in jsonArray)
                {
                    parser.changeJsonProp(item, "company");
                    parser.changeJsonProp(item, "synchronyStatus");
                }
                // Parsear el json de respuesta
                string parsedJsonString = parser.parse(jsonArray.ToString());
                // Realizar la persistencia de los cambios
                LotteryPointSaleRepository posRepo = new LotteryPointSaleRepository();
                posRepo.saveList(JsonConvert.DeserializeObject <List <LPS_LotteryPointSale> >(parsedJsonString));
            }
            return(successProcess);
        }
Beispiel #4
0
        public LPS_LotteryPointSale getPointSale()
        {
            LotteryPointSaleRepository posRepository = new LotteryPointSaleRepository();
            // TODO: Validar si es número
            long posId = Convert.ToInt64(UtilityService.getLocalParameterValue(ParameterConstants.POS_NAME_PARAM));

            return(posRepository.getById(posId));
        }
Beispiel #5
0
        public static LPS_LotteryPointSale getSystemSalePoint()
        {
            LPS_LotteryPointSale pointSaleInstance = null;
            string localParam = getSalePointParamValue();

            if (localParam.Trim() != "")
            {
                LotteryPointSaleRepository posRepository = new LotteryPointSaleRepository();
                // TODO: Validar si es número
                long posId = Convert.ToInt64(localParam);
                pointSaleInstance = posRepository.getById(posId);
            }

            return(pointSaleInstance);
        }
        private bool requestPosId()
        {
            bool   instanceSetting = true;
            string salePointId     = this.getLocalPointSale();

            if (ValidationService.isValidId(salePointId))
            {
                LotteryPointSaleRepository pointSaleRepo = new LotteryPointSaleRepository();
                SystemSession.sessionPointSale = pointSaleRepo.getById(long.Parse(salePointId));
            }
            else
            {
                // Solicitar inicialización de Sucursal solamente si el usuario no es SA
                if (SystemSession.sessionUser != null && SystemSession.sessionUser.USR_UserRole != SystemConstants.ROLE_SA_ID)
                {
                    instanceSetting = this.requestPosInitialization();
                }
            }
            return(instanceSetting);
        }
        private bool validateSalePointInstance()
        {
            bool   instanceSetting = true;
            string salePointId     = this.getLocalPointSale();

            if (ValidationService.isValidId(salePointId))
            {
                LotteryPointSaleRepository pointSaleRepo = new LotteryPointSaleRepository();
                SystemSession.sessionPointSale = pointSaleRepo.getById(long.Parse(salePointId));
            }
            else
            {
                // Sucursal no inicializada, lanzar error
                instanceSetting = false;
                MessageService.displayErrorMessage(
                    GeneralConstants.UNINITIALIZED_SYSTEM_ERROR,
                    GeneralConstants.UNINITIALIZED_SYSTEM_TITLE
                    );
            }
            return(instanceSetting);
        }
Beispiel #8
0
        public object generateSimpleListObject(LTL_LotteryList pListObject,
                                               long pListStatus = SystemConstants.LIST_STATUS_CREATED,
                                               long pSyncStatus = SystemConstants.SYNC_STATUS_COMPLETED
                                               )
        {
            LotteryDrawRepository      lotteryDrawRepository = new LotteryDrawRepository();
            LTD_LotteryDraw            draw      = lotteryDrawRepository.getById(pListObject.LTD_LotteryDraw);
            LotteryPointSaleRepository saleRepo  = new LotteryPointSaleRepository();
            LPS_LotteryPointSale       pointSale = saleRepo.getById(pListObject.LPS_LotteryPointSale);
            // Crear el objeto JSON
            var jsonObject = new
            {
                listNumber        = pListObject.LTL_Id,
                lotteryPointSale  = pointSale.LPS_Id,
                lotteryDraw       = pListObject.LTD_LotteryDraw,
                lotteryListStatus = pListStatus,
                synchronyStatus   = pSyncStatus,
                customerName      = pListObject.LTL_CustomerName,
                createDate        = pListObject.LTL_CreateDate.ToString("yyyy-MM-dd HH:mm:ss"),
            };

            return(jsonObject);
        }
Beispiel #9
0
        public object generateListObject(LTL_LotteryList pListObject)
        {
            LotteryDrawRepository      lotteryDrawRepository = new LotteryDrawRepository();
            LTD_LotteryDraw            draw      = lotteryDrawRepository.getById(pListObject.LTD_LotteryDraw);
            LotteryPointSaleRepository saleRepo  = new LotteryPointSaleRepository();
            LPS_LotteryPointSale       pointSale = saleRepo.getById(pListObject.LPS_LotteryPointSale);
            // Crear el objeto JSON
            var jsonObject = new
            {
                listNumber       = pListObject.LTL_Id,
                lotteryPointSale = new
                {
                    id              = pointSale.LPS_Id,
                    code            = pointSale.LPS_Code,
                    synchronyStatus = new
                    {
                        code        = "SC",
                        displayName = "Sincronizado",
                        description = "Sincronización completa",
                        id          = 3
                    },
                    displayName = pointSale.LPS_DisplayName,
                    description = pointSale.LPS_Description,
                    company     = new
                    {
                        code        = "TR",
                        displayName = "TIEMPOS RIVERA",
                        description = "Tiempos Rivera",
                        id          = 1,
                        createDate  = pointSale.LPS_CreateDate.ToString("yyyy-MM-dd HH:mm:ss")
                    },
                    createDate = pointSale.LPS_CreateDate.ToString("yyyy-MM-dd HH:mm:ss")
                },
                lotteryDraw = new
                {
                    id = pListObject.LTD_LotteryDraw,
                    lotteryDrawType   = draw.LDT_LotteryDrawType,
                    lotteryDrawStatus = draw.LDS_LotteryDrawStatus,
                    createDate        = draw.LTD_CreateDate
                },
                lotteryListStatus = new
                {
                    id          = 2,
                    code        = "R",
                    displayName = "Borrada",
                    description = "Borrada"
                },
                synchronyStatus = new
                {
                    id          = 3,
                    code        = "SC",
                    displayName = "Sincronización completa",
                    description = "Sincronización completa"
                },
                customerName = pListObject.LTL_CustomerName,
                createDate   = pListObject.LTL_CreateDate.ToString("yyyy-MM-dd HH:mm:ss"),
            }
            ;

            return(jsonObject);
        }