private int WriteIC(string ICdata) { int ret = 0; //打开读写器 if (PrintProduct.ICCPowerOn("USB1") != 0) { return(-11); } byte[] ucpATR = new byte[256]; int nATRLen = 0; PrintProduct.ResetCard(ref ucpATR[0], ref nATRLen); //string stratr = System.Text.Encoding.Default.GetString(ucpATR, 0, nATRLen); //东信和平 if (ucpATR[9] == 0x86 && ucpATR[10] == 0x60) { string[] data = ICdata.Split('#'); //ret = EP_DLL.PersoCard(PrintProduct.Transmit, PrintProduct.ResetCard, "", 0, ICdata, ICdata.Length); ret = EP_DLL.PersoCard(PrintProduct.Transmit, PrintProduct.ResetCard, EP_DLL.SendMsgToJMJ, "", 0, data[1], data[1].Length); if (ret != 0) { return(ret); } } //金邦达 else if ((ucpATR[9] == 0x86 && ucpATR[10] == 0x65) || (ucpATR[10] == 0x86 && ucpATR[11] == 0x65)) { string[] data = ICdata.Split('#'); ret = PAC_DLL.PersoCard(PrintProduct.Transmit, PrintProduct.ResetCard, PAC_DLL.SendMsgToJMJ, "", 0, data[1], data[1].Length); if (ret != 0) { return(ret); } } else if ((ucpATR[9] == 0x86 && ucpATR[10] == 0x49)) { string[] data = ICdata.Split('#'); ret = TS_DLL.iWriteCard(data[1], TS_DLL.SendMsgToJMJ); if (ret != 0) { return(ret); } } //关闭读写器 PrintProduct.ICCPowerOff(); return(0); }
public int ProductExecute(PrintParameter printPra, string ICdata, out string outCardData) { int ret = 0; outCardData = ""; PrintProduct ppro = new PrintProduct(); //打开打印机 int printHandle = PrintProduct.OpenPrinter(printName); if (printHandle <= 0) { MsgPutOut("制作卡片", "打开打印机失败"); return(-101); } //进卡 int steps = 100; ret = PrintProduct.FeedCard(printHandle, 0, steps); if (ret != 1) { ucFlowChart1.SetStepStatus(1, false); MsgPutOut("制作卡片", "进卡失败"); return(-102); } ucFlowChart1.SetStepStatus(1, true); this.Refresh(); //写IC MsgPutOut("制作卡片", "正在写卡,请耐心等待..."); ret = WriteIC(ICdata); if (ret != 0) { ucFlowChart1.SetStepStatus(2, false); PrintProduct.Eject(printHandle); MsgPutOut("制作卡片", "写卡失败,错误代码:" + ret); return(-103); } //读卡 ret = ReadCardInfo(out outCardData); if (ret != 0) { MsgPutOut("制作卡片", "读卡失败,错误代码:" + ret); return(-104); } ucFlowChart1.SetStepStatus(2, true); this.Refresh(); //排版照片 if (!ppro.DrawPhoto(printPra)) { MsgPutOut("制作卡片", "排版照片失败"); return(-105); } //排版个人信息 if (!ppro.DrawPersonInfo(printPra)) { MsgPutOut("制作卡片", "排版个人信息失败"); return(-106); } //开始打印 MsgPutOut("制作卡片", "正在打印,请耐心等待..."); ret = PrintProduct.StartPrint(printHandle, 2, 0); if (ret != 1) { ucFlowChart1.SetStepStatus(3, false); MsgPutOut("制作卡片", "打印失败"); return(-107); } ucFlowChart1.SetStepStatus(3, true); this.Refresh(); return(0); }