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); }
private async void syncWinnerNumbers(LTD_LotteryDraw pDraw, string[] pWinningNumberArray) { SynchronizeService syncService = new SynchronizeService(); syncService.appMediator = this.appMediator; await syncService.syncWinnerNumbersToServerAsync(pDraw, pWinningNumberArray); }
public object generateNewListToSync(LTL_LotteryList pListObject, List <LND_ListNumberDetail> pListNumberDetail = null) { List <ListNumberDetail> numberDetail = null; if (pListNumberDetail != null) { // Trasnformar LND_ListNumberDetail en una lista de elementos para el json numberDetail = pListNumberDetail.Select( x => new ListNumberDetail(x.LND_Id, x.LTL_LotteryList, x.LNR_LotteryNumber, x.LND_SaleImport) ).ToList(); } LotteryDrawRepository lotteryDrawRepository = new LotteryDrawRepository(); LTD_LotteryDraw draw = lotteryDrawRepository.getById(pListObject.LTD_LotteryDraw); // Crear el objeto JSON var jsonObject = new { listNumber = pListObject.LTL_Id, lotteryPointSale = pListObject.LPS_LotteryPointSale, lotteryDraw = new { id = pListObject.LTD_LotteryDraw, lotteryDrawType = draw.LDT_LotteryDrawType, lotteryDrawStatus = draw.LDS_LotteryDrawStatus, createDate = draw.LTD_CreateDate }, customerName = pListObject.LTL_CustomerName, createDate = pListObject.LTL_CreateDate.ToString("yyyy-MM-dd HH:mm:ss"), lotteryListStatus = SystemConstants.LIST_STATUS_CREATED, listNumberDetail = numberDetail } ; return(jsonObject); }
private void saveButton_Click(object sender, EventArgs e) { long groupId = Convert.ToInt64(this.drawTypeBox.SelectedValue); if (groupId == 0) { MessageBox.Show("Debe elegir un grupo válido"); } else { if (this.txbFirst.Text.Trim() == "") { MessageBox.Show("Debe ingresar al menos el primer número ganador"); this.txbFirst.Focus(); } else { LTD_LotteryDraw selectedDraw = new LTD_LotteryDraw(); selectedDraw.LDT_LotteryDrawType = Convert.ToInt64(this.drawTypeBox.SelectedValue); selectedDraw.LTD_CreateDate = this.datePickerList.Value.Date; LotteryDrawRepository lotteryDrawRepository = new LotteryDrawRepository(); selectedDraw = lotteryDrawRepository.getDrawRegister(selectedDraw); // Validar si existe el sorteo seleccionado if (selectedDraw == null) { MessageBox.Show("El sorteo seleccionado no existe y no puede ser ingresado"); } else { // Crear y completar nuevo registro de números ganadores DNW_DrawNumberWinning drawNumberWinning = new DNW_DrawNumberWinning(); drawNumberWinning.LTD_LotteryDraw = selectedDraw.LTD_Id; drawNumberWinning.DNW_FirtsNumber = this.txbFirst.Text; drawNumberWinning.DNW_SecondNumber = this.txbSecond.Text; drawNumberWinning.DNW_ThirdNumber = this.txbThird.Text; drawNumberWinning.DNW_CreateDate = DateTime.Now; drawNumberWinning.SYS_SynchronyStatus = SystemConstants.SYNC_STATUS_PENDING_TO_SERVER; DrawNumberWinningRepository drawNumberWinningRepository = new DrawNumberWinningRepository(); drawNumberWinningRepository.save(ref drawNumberWinning); // Imprimir tiquete de premios / ganadores string[] winningNumberArray = new string[3]; winningNumberArray[0] = this.txbFirst.Text.Trim() == "" ? GeneralConstants.EMPTY_STRING : UtilityService.fillString(this.txbFirst.Text, 2, "0"); winningNumberArray[1] = this.txbSecond.Text.Trim() == "" ? GeneralConstants.EMPTY_STRING : UtilityService.fillString(this.txbSecond.Text, 2, "0"); winningNumberArray[2] = this.txbThird.Text.Trim() == "" ? GeneralConstants.EMPTY_STRING : UtilityService.fillString(this.txbThird.Text, 2, "0"); bool sendToPrint = this.ckbPrint.Checked ? true : false; bool showInPanel = this.ckbPrintScreen.Checked ? true : false; this.ticketPrintService.printPrizeTicket(selectedDraw, winningNumberArray, sendToPrint, showInPanel); // Sincronizar con el servidor central if (UtilityService.realTimeSyncEnabled()) { this.syncWinnerNumbers(selectedDraw, winningNumberArray); } this.Dispose(); } } } }
// Cierre de Sorteos en Servidor public async Task <ServiceResponseResult> syncWinnerNumbersToServerAsync(LTD_LotteryDraw pDraw, string[] pWinningNumberArray) { var jsonObject = this.generateWinnerSyncJson(pDraw, pWinningNumberArray); //Console.WriteLine("Request Ganadores: " + jsonObject); string urlEndPoint = ServiceConectionConstants.WINNER_NUMBERS_RESOURCE_URL; RestClientService restClient = new RestClientService(); return(await restClient.processHttpRequestAsync(urlEndPoint, jsonObject, SystemConstants.HTTP_POST_METHOD)); }
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); }
public void changeDrawStatus(long pDrawType, DateTime?pDrawDate, long pNewStatus) { LTD_LotteryDraw existingDraw = this.drawRepo.getByTypeAndDate(pDrawType, pDrawDate); if (existingDraw != null) { existingDraw.LDS_LotteryDrawStatus = pNewStatus; this.drawRepo.save(ref existingDraw); } }
public List <LTL_LotteryList> getPosTransactionsByDrawAndStatus(LTD_LotteryDraw pDraw, long pCurrentStatus) { return(this.getAll().Where( item => item.LPS_LotteryPointSale == UtilityService.getPointSaleId() && item.LTD_LotteryDraw == pDraw.LTD_Id && item.SYS_SynchronyStatus == pCurrentStatus // Excluir de las transacciones pendientes los estados de lista TEMPORALES && item.LLS_LotteryListStatus != SystemConstants.LIST_STATUS_PROCESSING ).ToList()); }
public bool isDrawClosed(long pDrawType, DateTime?pDrawDate) { bool closedDraw = false; LTD_LotteryDraw existingDraw = this.drawRepo.getByTypeAndDate(pDrawType, pDrawDate); if (existingDraw != null) { closedDraw = existingDraw.LDS_LotteryDrawStatus == SystemConstants.DRAW_STATUS_CLOSED ? true : false; } return(closedDraw); }
public DBL_DrawBalance getByDateAndType(long pDrawType, DateTime?pDrawDate) { DBL_DrawBalance existingDrawBalance = null; DrawService drawService = new DrawService(); LTD_LotteryDraw drawToSave = drawService.getDraw(pDrawType, pDrawDate); if (drawToSave != null) { existingDrawBalance = this.drawBalanceRepo.getByDraw(drawToSave.LTD_Id); } return(existingDrawBalance); }
// Método para imprimir la lista de los números premiados y ganadores public void printPrizeTicket(LTD_LotteryDraw pDraw, string[] pWinningNumberArray, bool pSendToPrint, bool pShowInPanel) { // Configurar impresión para Ticket de Venta TicketPrinter ticketPrinter = new TicketPrinter(); PrizeTicket prizeTicket = new PrizeTicket(); prizeTicket.companyName = UtilityService.getCompanyName(); prizeTicket.title = "NÚMEROS PREMIADOS"; // Obtener datos del punto de venta LPS_LotteryPointSale pointSale = UtilityService.getPointSale(); prizeTicket.pointSaleName = pointSale.LPS_DisplayName; prizeTicket.drawDate = pDraw.LTD_CreateDate; // Obtener datos de tipo de sorteo LotteryDrawTypeRepository drawTypeRepo = new LotteryDrawTypeRepository(); LDT_LotteryDrawType drawType = drawTypeRepo.getById(pDraw.LDT_LotteryDrawType); prizeTicket.drawTypeCode = drawType.LDT_Code; // Llenar datos del número de lista prizeTicket.createDate = DateTime.Now; // Obtener datos de los premios PrizeFactorService prizeFactorService = new PrizeFactorService(); LPF_LotteryPrizeFactor prizeFactor = prizeFactorService.getByGroup(drawType.LDT_Id); if (prizeFactor != null) { prizeTicket.prizeFactorArray[0] = prizeFactor.LPF_FirtsPrizeFactor; prizeTicket.prizeFactorArray[1] = prizeFactor.LPF_SecondPrizeFactor; prizeTicket.prizeFactorArray[2] = prizeFactor.LPF_ThirdPrizeFactor; } // Obtener listado de información de ganadores LotteryListRepository listRepository = new LotteryListRepository(); prizeTicket.listWinningInfo = listRepository.getWinningNumbersList(pDraw, pWinningNumberArray); prizeTicket.winnerNumbers = pWinningNumberArray; ticketPrinter.prizeTicket = prizeTicket; // Obtener nombre de impresora y enviar impresión string printerName = UtilityService.getTicketPrinterName(); ticketPrinter.printPrizeTicket(printerName, pSendToPrint); // Almacenar importe de premio para el sorteo DrawBalanceService drawBalanceService = new DrawBalanceService(); drawBalanceService.saveBalance(pDraw.LDT_LotteryDrawType, pDraw.LTD_CreateDate, 0, ticketPrinter.prizeImport); if (pShowInPanel) { //Console.Write(ticketPrinter.ticketStringText); MessageBox.Show(ticketPrinter.ticketStringText); } }
public List <WinningNumberInfo> getWinningNumbersList(LTD_LotteryDraw pDraw, string [] pWinningNumberArray) { List <WinningNumberInfo> listDataCollection = new List <WinningNumberInfo>(); if (pDraw.LTD_Id != 0) { string acumulateFilters = ""; string winningNumbersFilter = " AND LN.LNR_Number IN ("; foreach (string number in pWinningNumberArray) { acumulateFilters += number == "" ? "" : " '" + number + "',"; } winningNumbersFilter = acumulateFilters.Trim() == "" ? "" : winningNumbersFilter + acumulateFilters.Substring(0, acumulateFilters.Length - 1) + " ) " ; using (var context = new SILOEntities()) { long posId = UtilityService.getPointSale().LPS_Id; var query = "SELECT " + "CASE LN.LNR_Number " + "WHEN '" + pWinningNumberArray[0] + "' THEN 1 " + "WHEN '" + pWinningNumberArray[1] + "' THEN 2 " + "WHEN '" + pWinningNumberArray[2] + "' THEN 3 " + "ELSE 4 " + "END AS prizeOrder, " + " LN.LNR_Number AS numberCode, N.LND_SaleImport AS saleImport, N.LND_SaleImport * 1 AS prizeImport, " + " L.LPS_LotteryPointSale AS salePoint, L.LTL_Id AS localId, L.LTL_CustomerName AS customerName" + " FROM LTL_LotteryList AS L INNER JOIN LND_ListNumberDetail AS N ON N.LTL_LotteryList = L.LTL_Id " + " INNER JOIN LTD_LotteryDraw AS D ON D.LTD_Id = L.LTD_LotteryDraw INNER JOIN LNR_LotteryNumber AS LN ON LN.LNR_Id = N.LNR_LotteryNumber " + "WHERE L.LPS_LotteryPointSale = " + posId + " " + " AND D.LTD_Id = " + pDraw.LTD_Id + " " + " AND L.LLS_LotteryListStatus <> " + SystemConstants.LIST_STATUS_CANCELED + " " + winningNumbersFilter + " ORDER BY prizeOrder, localId, customerName" + " ;"; listDataCollection = context.Database. SqlQuery <WinningNumberInfo>(query) .ToList() ; foreach (var item in listDataCollection) { //Console.WriteLine(item.prizeImport.ToString()); //Console.WriteLine(item.number + " " + item.import + " "); } } } return(listDataCollection); }
// Método para imprimir un ticket de venta de una lista public void printList(LTL_LotteryList pNumberList, int pTicketType = 0) { // Configurar impresión para Ticket de Venta SaleTicket saleTicket = new SaleTicket(pTicketType); saleTicket.companyName = UtilityService.getCompanyName(); // Obtener datos del punto de venta LPS_LotteryPointSale pointSale = UtilityService.getPointSale(); saleTicket.pointSaleName = pointSale.LPS_DisplayName; // Obtener usuario vendedor saleTicket.userName = SystemSession.username; // Obtener datos del sorteo LotteryDrawRepository drawRepo = new LotteryDrawRepository(); LTD_LotteryDraw drawObject = drawRepo.getById(pNumberList.LTD_LotteryDraw); saleTicket.drawDate = drawObject.LTD_CreateDate; // Obtener datos de tipo de sorteo this.drawTypeRepo = new LotteryDrawTypeRepository(); LDT_LotteryDrawType drawType = drawTypeRepo.getById(drawObject.LDT_LotteryDrawType); saleTicket.drawTypeCode = drawType.LDT_Code; // Obtener datos de los premios PrizeFactorService prizeFactorService = new PrizeFactorService(); LPF_LotteryPrizeFactor prizeFactor = prizeFactorService.getByGroup(drawType.LDT_Id); if (prizeFactor != null) { saleTicket.prizeFactorArray[0] = prizeFactor.LPF_FirtsPrizeFactor; saleTicket.prizeFactorArray[1] = prizeFactor.LPF_SecondPrizeFactor; saleTicket.prizeFactorArray[2] = prizeFactor.LPF_ThirdPrizeFactor; } // Llenar datos del número de lista saleTicket.createDate = DateTime.Now; saleTicket.ticketId = pNumberList.LTL_Id; saleTicket.globalId = pointSale.LPS_Id + "" + saleTicket.ticketId; saleTicket.customerName = pNumberList.LTL_CustomerName; // Obtener detalle de la lista procesada this.listRepo = new LotteryListRepository(); saleTicket.listNumberDetail = listRepo.getTupleListDetail(pNumberList.LTL_Id); // Crear instancia de impresora y asignar el ticket TicketPrinter ticketPrinter = new TicketPrinter(); ticketPrinter.saleTicket = saleTicket; // Obtener nombre de impresora y enviar impresión string printerName = UtilityService.getTicketPrinterName(); ticketPrinter.printLotterySaleTicket(printerName); }
private void closeDraw(long pDrawTypeToClose, DateTime pDateToClose) { DrawService drawService = new DrawService(); LTD_LotteryDraw existingDraw = drawService.getDraw(pDrawTypeToClose, pDateToClose); // Validar si el sorteo está cerrado if (existingDraw == null || existingDraw.LDS_LotteryDrawStatus == SystemConstants.DRAW_STATUS_CLOSED) { MessageService.displayInfoMessage( "El sorteo se encuentra cerrado\nNo es necesario realizar la operación.", "SORTEO CERRADO PREVIAMENTE" ); this.clearDrawTypeBox(); } else { List <LTD_LotteryDraw> otherUnclosedDrawList = drawService.getUnclosedDraw(pDrawTypeToClose, pDateToClose); if (otherUnclosedDrawList.Count > 0) { DrawTypeService drawType = new DrawTypeService(); LDT_LotteryDrawType type = drawType.getById(pDrawTypeToClose); string unclosedDateListString = "\n\n"; foreach (LTD_LotteryDraw drawItem in otherUnclosedDrawList) { if (drawItem.LTD_CreateDate != pDateToClose) { unclosedDateListString += type.LDT_DisplayName + "\t" + FormatService.formatDrawDateToSimpleString(drawItem.LTD_CreateDate) + "\n"; } } //Console.WriteLine(unclosedDateListString); MessageService.displayWarningMessage( "Existen sorteos de fechas anteriores pendientes de cierre.\nPor favor, proceda primero a realizar los cierres pendientes:" + unclosedDateListString, "SORTEOS ANTERIORES SIN CERRAR" ); //this.clearDrawTypeBox(); } else { this.confirmDrawClosing(pDrawTypeToClose, pDateToClose); } } }
public void saveBalance(long pDrawType, DateTime?pDrawDate, long pSaleImport = 0, long pPayImport = 0) { DBL_DrawBalance balanceToSave = null; DrawService drawService = new DrawService(); LTD_LotteryDraw drawToSave = drawService.getDraw(pDrawType, pDrawDate); if (drawToSave != null) { balanceToSave = this.drawBalanceRepo.getByDraw(drawToSave.LTD_Id); // Si no existe el balance crearlo if (balanceToSave == null) { balanceToSave = new DBL_DrawBalance(); balanceToSave.LTD_LotteryDraw = drawToSave.LTD_Id; } balanceToSave.DBL_SaleImport = pSaleImport; balanceToSave.DBL_PayImport = pPayImport; this.drawBalanceRepo.save(balanceToSave, balanceToSave.DBL_Id, (e1, e2) => e1.copy(e2)); } }
public object generateWinnerSyncJson(LTD_LotteryDraw pDraw, string[] pWinningNumberArray) { // Crear el objeto JSON var jsonObject = new { lotteryDraw = new { id = pDraw.LTD_Id, lotteryDrawType = pDraw.LDT_LotteryDrawType, lotteryDrawStatus = 1, createDate = pDraw.LTD_CreateDate }, first = pWinningNumberArray[0], second = pWinningNumberArray[1], third = pWinningNumberArray[2], createDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") } ; return(jsonObject); }
public object generateDrawClosingJson(DateTime pDrawDate, long pGroupId, long pStatus) { DrawService drawService = new DrawService(); LTD_LotteryDraw draw = drawService.getDraw(pGroupId, pDrawDate); // Crear el objeto JSON var jsonObject = new { lotteryPointSale = ParameterService.getSalePointId(), lotteryDraw = new { id = draw.LTD_Id, lotteryDrawType = draw.LDT_LotteryDrawType, lotteryDrawStatus = pStatus, createDate = draw.LTD_CreateDate }, createDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") } ; return(jsonObject); }
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); }
//---------------------------------- Métodos de lógica de aplicación -------------------------------// public void fillTextBoxes() { LTD_LotteryDraw draw = new LTD_LotteryDraw(); draw.LDT_LotteryDrawType = Convert.ToInt64(this.drawTypeBox.SelectedValue); draw.LTD_CreateDate = this.datePickerList.Value.Date; LotteryDrawRepository drawRepository = new LotteryDrawRepository(); draw = drawRepository.getDrawRegister(draw); // Validar si existe el sorteo para realizar la búsqueda de los ganadores if (draw != null) { DrawNumberWinningRepository winningRepository = new DrawNumberWinningRepository(); DNW_DrawNumberWinning winningDraw = winningRepository.getById(draw.LTD_Id); // Verificar ganadores para llenar los textboxes if (winningDraw != null) { MessageBox.Show("Los ganadores para el sorteo ya fueron agregados previamente. Puede sobre escribirlos digitando los nuevos números y presionando el botón 'Guardar'."); this.txbFirst.Text = winningDraw.DNW_FirtsNumber; this.txbSecond.Text = winningDraw.DNW_SecondNumber; this.txbThird.Text = winningDraw.DNW_ThirdNumber; } } }
public List <LTL_LotteryList> getPosPendingTransactionsByDraw(LTD_LotteryDraw pDraw) { return(this.listRepository.getPosPendingTransactionsByDraw(pDraw)); }
public void changeListStatusFromQRUpdated(LTD_LotteryDraw pDraw, long pNewStatus) { List <LTL_LotteryList> qrListCollection = this.listRepository.getPosTransactionsByDrawAndStatus(pDraw, SystemConstants.SYNC_STATUS_QRUPDATED); this.listRepository.changeListSyncStatus(qrListCollection, pNewStatus); }
public void changeListStatus(LTD_LotteryDraw pDraw, long pNewStatus) { List <LTL_LotteryList> pendingListCollection = this.listRepository.getPosPendingTransactionsByDraw(pDraw); this.listRepository.changeListSyncStatus(pendingListCollection, pNewStatus); }
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); }