/// <summary> /// Gets the next card enqueued to be printed /// </summary> /// <param name="printerId">The ID of the printer who is requesting the card</param> /// <returns></returns> public MabelCard GetNextJob(int printerId) { MabelRequest request = new MabelRequest(this, "cardHandler.getNextPrintJob", new MabelGetNextJobParams(printerId)); MabelResponse response = MakeRequest(request); if (response.code == 200) { if (response.results == null) { // The API is OK, there's just no cards to print :) return(null); } } else { //Something has gone wrong, best ignore and hope for the best, but exit out this time around // throw an exception probably? throw new Exception("Problem with request to API: " + response.message); } // otherwise... MabelCard card = new MabelCard(); card.card_id = (int)response.results.SelectToken("cardId"); card.member_id = response.results.SelectToken("memberId").ToString(); card.card_front_image_encoded = (string)response.results.SelectToken("imageFront"); card.card_back_image_encoded = (string)response.results.SelectToken("imageBack"); return(card); }
private void UpdateCardDetails(MabelCard card) { if (tbStatusBar.InvokeRequired == false) { if (card != null) { Image frontImage = card.GetCardFrontImage(); Image backImage = card.GetCardBackImage(); if (Properties.Settings.Default.Orientation.Equals("Portrait")) { frontImage.RotateFlip(RotateFlipType.Rotate90FlipNone); backImage.RotateFlip(RotateFlipType.Rotate270FlipNone); } pbCardFront.Image = frontImage; pbCardBack.Image = backImage; tbMemberId.Text = card.member_id; tbMagId.Text = card.mag_token; tbCardId.Text = card.card_id.ToString(); } } else { UpdateCardDetailsDelegate updateCard = new UpdateCardDetailsDelegate(UpdateCardDetails); this.BeginInvoke(updateCard, new object[] { card }); } }
/// <summary> /// Sets a card's status to printed via the API. /// </summary> /// <param name="printerId"></param> /// <param name="card"></param> /// <returns></returns> public MabelResponse SetCardPrinted(int printerId, MabelCard card) { MabelResponse response = MakeRequest(new MabelRequest(this, "cardHandler.setPrinted", new MabelSetCardPrinterParams(card.card_id) )); return(response); }
/// <summary> /// Sets a card's RFID via the API (deprecated) /// </summary> /// <param name="printerId"></param> /// <param name="card"></param> /// <param name="rfid"></param> /// <returns></returns> public MabelResponse SetCardRfid(int printerId, MabelCard card, String rfid) { MabelResponse response = MakeRequest( new MabelRequest( this, "cardPrinter.setStatus", new MabelSetCardRfidParams(printerId, card.card_id, rfid) ) ); return(response); }
/// <summary> /// Sets the status of a card via the API /// </summary> /// <param name="printerId"></param> /// <param name="card"></param> /// <param name="status"></param> /// <returns></returns> public MabelResponse SetCardStatus(int printerId, MabelCard card, string status) { MabelResponse response = MakeRequest( new MabelRequest( this, "cardHandler.setStatus", new MabelSetCardStatusParams(card.card_id, status) ) ); return(response); }
public void PrintMabelCard(MabelCard card) { if ((card.GetCardBackImage() == null) || (card.GetCardFrontImage() == null)) { //throw new Exception("IMAGE_NULL"); // } PrintDocument printDoc = new PrintDocument(); this.pages_printed = 0; printDoc.PrinterSettings.PrinterName = Properties.Settings.Default.LocalPrinter; printDoc.PrinterSettings.Duplex = Duplex.Default; printDoc.DefaultPageSettings.PaperSize = new PaperSize("CR80", 213, 337); printDoc.DefaultPageSettings.Landscape = true; printDoc.DocumentName = "Card-" + card.card_id; PrinterResolution pkResolution; PrinterResolution targetRes = null; for (int i = 0; i < printDoc.PrinterSettings.PrinterResolutions.Count; i++) { pkResolution = printDoc.PrinterSettings.PrinterResolutions[i]; //System.Console.Out.WriteLine("Resolution : " + pkResolution.Kind + " X : " + pkResolution.X + " Y: " + pkResolution.Y); if (pkResolution.Kind.Equals("Custom")) { targetRes = pkResolution; } } if (targetRes != null) { printDoc.DefaultPageSettings.PrinterResolution = targetRes; } else { targetRes = printDoc.DefaultPageSettings.PrinterResolution; } printDoc.PrintPage += new PrintPageEventHandler(printDoc_PrintPage); if (printDoc.PrinterSettings.IsValid) { try { printDoc.Print(); } catch (Exception ex) { lastError = "Printing Error: " + ex.Message; // something went wrong. } } }
public bool RequestNextCard() { MabelCard card; try { card = mabel_api.GetNextJob(printer_id); if (card == null) { return(false); } this.nextCard = card; return(true); } catch (Exception ex) { OnDebug(new DebugEventArgs(mabel_api.lastRequest.buildURL(), ex.Message)); return(false); } }
public NFCEventArgs(String rfidToken, MabelCard card) { this.rfidToken = rfidToken; this.card = card; }
public PrinterEventArgs(MabelCard _card, String _status, PrinterInfo _info) { this.Card = _card; this.Status = _status; this.Info = _info; }
/// <summary> /// Gets the next card enqueued to be printed /// </summary> /// <param name="printerId">The ID of the printer who is requesting the card</param> /// <returns></returns> public MabelCard GetNextJob(int printerId) { MabelRequest request = new MabelRequest(this, "cardHandler.getNextPrintJob", new MabelGetNextJobParams(printerId)); MabelResponse response = MakeRequest(request); if (response.code == 200) { if (response.results == null) { // The API is OK, there's just no cards to print :) return null; } } else { //Something has gone wrong, best ignore and hope for the best, but exit out this time around // throw an exception probably? throw new Exception("Problem with request to API: " + response.message); } // otherwise... MabelCard card = new MabelCard(); card.card_id = (int) response.results.SelectToken("cardId"); card.member_id = response.results.SelectToken("memberId").ToString(); card.card_front_image_encoded = (string)response.results.SelectToken("imageFront"); card.card_back_image_encoded = (string)response.results.SelectToken("imageBack"); return card; }
/// <summary> /// Sets the status of a card via the API /// </summary> /// <param name="printerId"></param> /// <param name="card"></param> /// <param name="status"></param> /// <returns></returns> public MabelResponse SetCardStatus(int printerId, MabelCard card, string status) { MabelResponse response = MakeRequest( new MabelRequest( this, "cardHandler.setStatus", new MabelSetCardStatusParams(card.card_id, status) ) ); return response; }
/// <summary> /// Sets a card's RFID via the API (deprecated) /// </summary> /// <param name="printerId"></param> /// <param name="card"></param> /// <param name="rfid"></param> /// <returns></returns> public MabelResponse SetCardRfid(int printerId, MabelCard card, String rfid) { MabelResponse response = MakeRequest( new MabelRequest( this, "cardPrinter.setStatus", new MabelSetCardRfidParams( printerId, card.card_id, rfid) ) ); return response; }
/// <summary> /// Sets a card's status to printed via the API. /// </summary> /// <param name="printerId"></param> /// <param name="card"></param> /// <returns></returns> public MabelResponse SetCardPrinted(int printerId, MabelCard card) { MabelResponse response = MakeRequest(new MabelRequest(this,"cardHandler.setPrinted", new MabelSetCardPrinterParams( card.card_id) )); return response; }