//取出打印中要传给模板的数据,各个子类应分别实现这个方法 protected string[] GetPrintVars(MKeyPart mKeyPart, MKeyPartDetail mKeyPartDetail, List <string> reserveInfo) { if (mKeyPart == null || mKeyPartDetail == null) { return(null); } int count = (reserveInfo == null) ? 0 : reserveInfo.Count; string[] returnValue = new string[20 + count]; for (int i = 0; i < returnValue.Length; i++) { returnValue[i] = string.Empty; } returnValue[1] = mKeyPart.MItemCode; returnValue[2] = mKeyPart.LotNO; returnValue[3] = mKeyPart.PCBA; returnValue[4] = mKeyPart.BIOS; returnValue[5] = mKeyPart.Version; returnValue[6] = mKeyPart.VendorItemCode; returnValue[7] = mKeyPart.VendorCode; returnValue[8] = mKeyPart.DateCode; returnValue[9] = mKeyPart.MoCode; returnValue[10] = mKeyPart.MITEMNAME; returnValue[11] = mKeyPartDetail.SerialNo; for (int i = 0; i < count; i++) { returnValue[20 + i] = reserveInfo[i]; } return(returnValue); }
public UserControl.Messages Print(string printer, string templatePath, MKeyPart mKeyPart, List <MKeyPartDetail> mKeyPartDetailList, List <string> reserveInfo) { UserControl.Messages messages = new UserControl.Messages(); try { try { this.PrePrint(); _CodeSoftFacade.OpenTemplate(printer, templatePath); } catch (System.Exception ex) { messages.Add(new UserControl.Message(UserControl.MessageType.Error, ex.Message)); return(messages); } //批量打印前生成文本文件 string strBatchDataFile = string.Empty; if (_IsBatchPrint) { strBatchDataFile = CreateFile(); } for (int i = 0; i < mKeyPartDetailList.Count; i++) { LabelPrintVars labelPrintVars = new LabelPrintVars(); string[] vars = new string[0]; if (messages.IsSuccess()) { try { //要传给Codesoft的数组,字段顺序不能修改 vars = this.GetPrintVars(mKeyPart, mKeyPartDetailList[i], reserveInfo); //批量打印前的写文件 if (_IsBatchPrint) { string[] printVars = ProcessVars(vars, labelPrintVars); WriteFile(strBatchDataFile, printVars); } //直接打印 else { _CodeSoftFacade.LabelPrintVars = labelPrintVars; _CodeSoftFacade.Print(vars); } } catch (System.Exception ex) { messages.Add(new UserControl.Message(UserControl.MessageType.Error, ex.Message)); return(messages); } } } //批量打印 if (_IsBatchPrint) { try { _CodeSoftFacade.Print(strBatchDataFile, GetDataDescPath(_DataDescFileName)); } catch (System.Exception ex) { messages.Add(new UserControl.Message(UserControl.MessageType.Error, ex.Message)); return(messages); } } messages.Add(new UserControl.Message(UserControl.MessageType.Success, "$Success_Print_Label")); } finally { } return(messages); }
public void ProcessRequest(HttpContext context) { string itemCodeValue = context.Request.QueryString["itemCodeValue"].Trim().ToUpper(); string snPrefix = context.Request.QueryString["snPrefix"].Trim().ToUpper(); string StartSnCodeValue = context.Request.QueryString["StartSnCodeValue"].Trim().ToUpper(); string actionType = context.Request.QueryString["Action"].Trim().ToUpper(); string EndSnValue = context.Request.QueryString["EndSnValue"].Trim().ToUpper(); string SnSeqValue = context.Request.QueryString["SnSeqValue"].Trim().ToUpper(); string CheckedValue = context.Request.QueryString["CheckedValue"].Trim().ToUpper(); try { _facade = new MaterialFacade(this.DataProvider); string returnValue = "false"; string _scale = string.Empty; NumberScale scale = NumberScale.Scale34; _scale = "34"; if (CheckedValue == "10") { scale = NumberScale.Scale10; _scale = "10"; } else if (CheckedValue == "16") { scale = NumberScale.Scale16; _scale = "16"; } else if (CheckedValue == "34") { scale = NumberScale.Scale34; _scale = "34"; } else { scale = NumberScale.Scale34; _scale = "34"; } int length = StartSnCodeValue.Trim().Length; if (StartSnCodeValue.Trim() != "" && EndSnValue.Trim() != "") { long startSN = 0; try { startSN = long.Parse(NumberScaleHelper.ChangeNumber(StartSnCodeValue.Trim(), scale, NumberScale.Scale10)); } catch (Exception ex) { //throw ex; //txtMORCardStartEdit.Focus(); returnValue = "false"; } long endSN = 0; try { endSN = long.Parse(NumberScaleHelper.ChangeNumber(EndSnValue.Trim(), scale, NumberScale.Scale10)); } catch (Exception ex) { returnValue = "false"; } if ((startSN.ToString().Length + snPrefix.Trim().Length) > 40) { returnValue = "false"; } if (startSN > endSN) { returnValue = "false"; } bool needUpdateDetail = true; if (actionType == "UPDATE") { MKeyPart oldMKeyPart = (MKeyPart)_facade.GetMKeyPart(Convert.ToDecimal(SnSeqValue), itemCodeValue); if (oldMKeyPart != null && oldMKeyPart.RCardPrefix.Trim().ToUpper() == snPrefix.Trim().ToUpper() && oldMKeyPart.RunningCardStart.Trim().ToUpper() == StartSnCodeValue.Trim().ToUpper() && oldMKeyPart.RunningCardEnd.Trim().ToUpper() == EndSnValue.Trim().ToUpper() && oldMKeyPart.SNScale.Trim().ToUpper() == _scale) { needUpdateDetail = false; } } //if (actionType == "ADD") //{ //检查需要插入的detail数据量是否太多 if (needUpdateDetail) { if (endSN - startSN > 4999) { returnValue = "true"; } else { returnValue = "false"; } } else { returnValue = "false"; } //} //if (actionType == "UPDATE") //{ // long count = endSN - startSN + 1; //当前界面上算出来的数量 // try // { // long checkCount = _facade.CheckMKeyPartDetail(SnSeqValue, itemCodeValue, StartSnCodeValue, EndSnValue, snPrefix.Trim().ToUpper()); // if (checkCount == 0) // { // if (endSN - startSN > 4999) // { // returnValue = "true"; // } // else // { // returnValue = "false"; // } // } // else // { // if (count - checkCount < 0 || count - checkCount == 0) //会删掉数据库的序列号,所以速度比较快。 // { // returnValue = "false"; // } // else // { // if (count - checkCount > 4999) //为4999 //会insert into 序列号到数据库,所以要判断inset into的数量是否大于4999 // { // returnValue = "true"; // } // else // { // returnValue = "false"; // } // } // } // } // catch (Exception ex) // { // returnValue = "false"; // } //} } else { returnValue = "false"; } context.Response.Write(returnValue); } catch (Exception ex) { context.Response.Write(ex.Message); } }