Click here to Skip to main content
15,891,951 members
Home / Discussions / Java
   

Java

 
Questionerror when run project jsf2.0 Pin
ahmadiss30-Jul-12 7:14
ahmadiss30-Jul-12 7:14 
AnswerRe: error when run project jsf2.0 Pin
Nagy Vilmos30-Jul-12 23:50
professionalNagy Vilmos30-Jul-12 23:50 
QuestionDesigning to interfaces? Pin
Neo1010129-Jul-12 9:52
Neo1010129-Jul-12 9:52 
AnswerRe: Designing to interfaces? Pin
BobJanova29-Jul-12 23:01
BobJanova29-Jul-12 23:01 
GeneralRe: Designing to interfaces? Pin
Neo1010129-Jul-12 23:48
Neo1010129-Jul-12 23:48 
GeneralRe: Designing to interfaces? Pin
BobJanova30-Jul-12 0:13
BobJanova30-Jul-12 0:13 
AnswerRe: Designing to interfaces? Pin
jschell30-Jul-12 5:54
jschell30-Jul-12 5:54 
Questionhow to convert java code to c# code Pin
LAPEC25-Jul-12 12:55
LAPEC25-Jul-12 12:55 
hello everyone

could someone please help me to convert this java code to c#, i have been trying for a week and i am getting very frustrating...
Java
public static void printTicket(final Ticket ticket) throws Exception {
   Job job = new Job()
   {
      @Override
      public Object run() {
         PosPrinter posPrinter = null;
         try 
         {
            if(PrintConfig.getReceiptPrinterType() == PrinterType.OS_PRINTER) {
               JReportPrintService.printTicket(ticket);
               return null;
            }			
            Restaurant restaurant = RestaurantDAO.getInstance().get(Integer.valueOf(1));
            posPrinter = new PosPrinter(PrintConfig.getJavaPosReceiptPrinterName(),
            PrintConfig.getCashDrawerName());
            posPrinter.beginLine(PosPrinter.SIZE_0);
            posPrinter.printText("\u001b|cA\u001b|2C" + restaurant.getName());
            posPrinter.endLine();

            if (restaurant.getAddressLine1() != null) {
               printCentered(posPrinter, restaurant.getAddressLine1());
            }
            if (restaurant.getAddressLine2() != null) {
               printCentered(posPrinter, restaurant.getAddressLine2());
	    }
	    if (restaurant.getAddressLine3() != null) {
               printCentered(posPrinter, restaurant.getAddressLine3());
            }
            if (restaurant.getTelephone() != null) {
               printCentered(posPrinter, restaurant.getTelephone());
            }
            posPrinter.beginLine(PosPrinter.SIZE_0);
            posPrinter.endLine();
            posPrinter.beginLine(PosPrinter.SIZE_0);
	    posPrinter.printText(com.floreantpos.POSConstants.CHK_NO);
            posPrinter.printText(String.valueOf(ticket.getId()));
            posPrinter.endLine();
	    posPrinter.beginLine(PosPrinter.SIZE_0);
	    posPrinter.printText(com.floreantpos.POSConstants.TBL_);
	    posPrinter.printText(String.valueOf(ticket.getTableNumber()));
	    posPrinter.endLine();
	    posPrinter.beginLine(PosPrinter.SIZE_0);
	    posPrinter.printText(com.floreantpos.POSConstants.GUEST + " #");
	    posPrinter.printText(String.valueOf(ticket.getNumberOfGuests()));
	    posPrinter.endLine();
	    posPrinter.beginLine(PosPrinter.SIZE_0);
	    posPrinter.printText(com.floreantpos.POSConstants.SRV_);
	    posPrinter.printText(String.valueOf(ticket.getOwner().getUserId() + "/" +
               ticket.getOwner()));
            posPrinter.endLine();
	    posPrinter.beginLine(PosPrinter.SIZE_0);
	    posPrinter.printText(com.floreantpos.POSConstants.DATE + ": ");
	    posPrinter.printText(Application.formatDate(new Date()));
	    posPrinter.endLine();
	    posPrinter.beginLine(PosPrinter.SIZE_0);
	    posPrinter.endLine();
	    posPrinter.beginLine(PosPrinter.SIZE_0);
	    printFirstColumn(posPrinter, com.floreantpos.POSConstants.QTY, 
               firstColumnLength);
	    printSecondColumn(posPrinter, com.floreantpos.POSConstants.ITEM, 
               firstColumnLength, secondColumnLength, false);
	    printThirdColumn(posPrinter, com.floreantpos.POSConstants.UPRICE, 
               thirdColumnLength);
	    printFourthColumn(posPrinter, com.floreantpos.POSConstants.SUBTOTAL, 
               fourthColumnLength);
	    posPrinter.endLine();
            posPrinter.beginLine(PosPrinter.SIZE_0);
	    posPrinter.printText(StringUtils.leftPad("", totalLength, "_"));
	    posPrinter.endLine();

	    List<TicketItem> ticketItems = ticket.getTicketItems();
	    if (ticketItems != null) {
	       for (TicketItem ticketItem : ticketItems) {
                  posPrinter.beginLine(PosPrinter.SIZE_0);
                  printFirstColumn(posPrinter, String.valueOf(ticketItem.getItemCount()),
                     firstColumnLength);
                  printSecondColumn(posPrinter, ticketItem.getName(), firstColumnLength, 
                     secondColumnLength, false);
                  printThirdColumn(posPrinter, 
                     Application.formatNumber(ticketItem.getUnitPrice()),
                     thirdColumnLength);
                  printFourthColumn(posPrinter, 
                     Application.formatNumber(ticketItem
                     .getSubtotalAmountWithoutModifiers()), fourthColumnLength);
                  posPrinter.endLine();
                  List<TicketItemModifierGroup> modifierGroups = 
                     ticketItem.getTicketItemModifierGroups();
                  if (modifierGroups != null) {
                     for (TicketItemModifierGroup modifierGroup : modifierGroups) {
                        List<TicketItemModifier> modifiers = 
                           modifierGroup.getTicketItemModifiers();
                        if (modifiers != null) {
                           for (TicketItemModifier modifier : modifiers) {
                              if (modifier.getTotalAmount() == 0) {
                                 continue;
                              }
			      boolean extra = false;
			      String display = " - " + modifier.getName();
                              if (modifier.getModifierType() == 
                                 TicketItemModifier.EXTRA_MODIFIER) {
                                 display = " - Extra " + display;
			         extra = true;
			      }
                              posPrinter.beginLine(PosPrinter.SIZE_0);
                              printFirstColumn(posPrinter, 
                              String.valueOf(modifier.getItemCount()), firstColumnLength);
                              printSecondColumn(posPrinter, display, firstColumnLength, 
                              secondColumnLength, false);
			      if(extra) {
                                 printThirdColumn(posPrinter, Application.formatNumber
                                   (modifier.getExtraUnitPrice()), thirdColumnLength);
                              }
			      else {
                                 printThirdColumn(posPrinter, Application.formatNumber
                                 (modifier.getUnitPrice()), thirdColumnLength);
                              }
                              printFourthColumn(posPrinter, Application.formatNumber
                                 (modifier.getTotalAmount()), fourthColumnLength);
			      posPrinter.endLine();
                           }
                        }
                     }
                  }
               }
            }
            posPrinter.beginLine(PosPrinter.SIZE_0);
            posPrinter.printText(StringUtils.leftPad("", totalLength, "_"));
            posPrinter.endLine();
            posPrinter.beginLine(PosPrinter.SIZE_0);
            posPrinter.printText(StringUtils.leftPad("SUB-TOTAL  " + ":", 32));
            posPrinter.printText(StringUtils.leftPad(Application.formatNumber(ticket  
               .getSubtotalAmount()), 10));
            posPrinter.endLine();
	    posPrinter.beginLine(PosPrinter.SIZE_0);
            posPrinter.printText(StringUtils.leftPad("TAX        " + ":", 32));
            posPrinter.printText(StringUtils.leftPad(Application.formatNumber(ticket
               .getTaxAmount()), 10));
            posPrinter.endLine();
	    posPrinter.beginLine(PosPrinter.SIZE_0);
	    posPrinter.printText(StringUtils.leftPad("GRAND TOTAL " + ":", 32));
            posPrinter.printText(StringUtils.leftPad(Application.formatNumber(ticket
               .getTotalAmount()), 10));
            posPrinter.endLine();
	    posPrinter.beginLine(PosPrinter.SIZE_0);
	    posPrinter.endLine();
	    posPrinter.beginLine(PosPrinter.SIZE_0);
	    posPrinter.printText(StringUtils.leftPad("TIP " + ":", 32));
            if (ticket.getGratuity() != null) {
               posPrinter.printText(StringUtils.leftPad(Application.formatNumber(ticket
                  .getGratuity().getAmount()), 10));
	    }
	    posPrinter.endLine();
	    posPrinter.beginLine(PosPrinter.SIZE_0);
	    posPrinter.printText(StringUtils.leftPad("TOTAL " + ":", 32));
	    posPrinter.endLine();
            printCentered(posPrinter, "THANK YOU!!");
            printCentered(posPrinter, "PLEASE COME AGAIN!!!");
	    posPrinter.printCutPartial();
	    //posPrinter.openDrawer();
         } 
         catch(Exception x) {
            logger.error("Error while printing ticket", x);
         }
         finally {
            if (posPrinter != null) {
               posPrinter.finalize();
            }
         }
         return null;
      }
   };
   Worker.post(job);
}


The problem I'm getting is, when i try to convert from java to c#, for some reason it highlights the code (see the three lines on the source code underlined) and it says (the base type is not defined)

Hence I'm very new to this so any help it would mean a world to me...

thanks in advance

kind regards

lapeci
AnswerRe: how to convert java code to c# code Pin
Paul Conrad25-Jul-12 17:02
professionalPaul Conrad25-Jul-12 17:02 
GeneralRe: how to convert java code to c# code Pin
jschell27-Jul-12 12:04
jschell27-Jul-12 12:04 
GeneralRe: how to convert java code to c# code Pin
Paul Conrad27-Jul-12 14:00
professionalPaul Conrad27-Jul-12 14:00 
AnswerRe: how to convert java code to c# code Pin
BobJanova29-Jul-12 22:44
BobJanova29-Jul-12 22:44 
GeneralRe: how to convert java code to c# code Pin
kianfong27-Sep-12 21:26
kianfong27-Sep-12 21:26 
QuestionNEED GOOD JSF VIDEO TUTORIAL Pin
Gaurav Sharma from Bangalore, India24-Jul-12 20:41
Gaurav Sharma from Bangalore, India24-Jul-12 20:41 
AnswerRe: NEED GOOD JSF VIDEO TUTORIAL Pin
TorstenH.24-Jul-12 22:00
TorstenH.24-Jul-12 22:00 
AnswerRe: NEED GOOD JSF VIDEO TUTORIAL Pin
Richard MacCutchan24-Jul-12 22:38
mveRichard MacCutchan24-Jul-12 22:38 
GeneralRe: NEED GOOD JSF VIDEO TUTORIAL Pin
Neo1010129-Jul-12 10:08
Neo1010129-Jul-12 10:08 
QuestionHow can I call doGet method? Pin
Nuha IT24-Jul-12 12:34
Nuha IT24-Jul-12 12:34 
AnswerRe: How can I call doGet method? Pin
Richard MacCutchan24-Jul-12 22:36
mveRichard MacCutchan24-Jul-12 22:36 
AnswerRe: How can I call doGet method? Pin
Andrei Straut25-Jul-12 9:34
Andrei Straut25-Jul-12 9:34 
QuestionHow to parse this XML by using SAX parser, I have no idea about parsing...Plzzz Help Me Pin
Gaurav Sharma from Bangalore, India24-Jul-12 7:30
Gaurav Sharma from Bangalore, India24-Jul-12 7:30 
SuggestionRe: How to parse this XML by using SAX parser, I have no idea about parsing...Plzzz Help Me Pin
Richard MacCutchan24-Jul-12 9:22
mveRichard MacCutchan24-Jul-12 9:22 
GeneralRe: How to parse this XML by using SAX parser, I have no idea about parsing...Plzzz Help Me Pin
Gaurav Sharma from Bangalore, India24-Jul-12 9:38
Gaurav Sharma from Bangalore, India24-Jul-12 9:38 
AnswerRe: How to parse this XML by using SAX parser, I have no idea about parsing...Plzzz Help Me Pin
Richard MacCutchan24-Jul-12 9:26
mveRichard MacCutchan24-Jul-12 9:26 
GeneralRe: How to parse this XML by using SAX parser, I have no idea about parsing...Plzzz Help Me Pin
Gaurav Sharma from Bangalore, India24-Jul-12 9:41
Gaurav Sharma from Bangalore, India24-Jul-12 9:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.