| | |
| | | using BarcodeStandard; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.Information; |
| | | using SkiaSharp; |
| | | using SqlSugar; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Drawing; |
| | | using System.Drawing.Imaging; |
| | | using System.Drawing.Printing; |
| | | using System.Linq; |
| | | using System.Runtime.InteropServices; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Core; |
| | |
| | | Width = Width, |
| | | Height = Height, |
| | | Size = Size, |
| | | Qty = 1, |
| | | PrintFrequency = 2, |
| | | }; |
| | | BaseDal.AddData(palletCodeInfo); |
| | | return WebResponseContent.Instance.OK(); |
| | |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// æå°æ¡ç |
| | | /// </summary> |
| | | /// <param name="keys"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent PrintBarcodeLib(List<int> keys) |
| | | { |
| | | try |
| | | { |
| | | Dt_PalletCodeInfo palletCodeInfo = BaseDal.QueryFirst(x => keys.Contains(x.Id)); |
| | | if (palletCodeInfo == null) throw new Exception("ä¿¡æ¯æè¯¯"); |
| | | #region çææ¡ç |
| | | Barcode barcode = new Barcode();//å建æ¡å½¢ç 对象 |
| | | barcode.IncludeLabel = true;//ç¡®ä¿å
æ¬æ ç¾ |
| | | barcode.Alignment = AlignmentPositions.Center;//æ¡å½¢ç 坹齿¹å¼ |
| | | barcode.LabelFont = new SKFont |
| | | { |
| | | Typeface = SKTypeface.FromFamilyName("Arial", SKFontStyle.Normal),//å使 ·å¼ |
| | | Size = palletCodeInfo.Size,// æ ç¾åä½ |
| | | }; |
| | | barcode.EncodedType = BarcodeStandard.Type.Code128; |
| | | barcode.Width = palletCodeInfo.Width; |
| | | barcode.Height = palletCodeInfo.Height; |
| | | #endregion |
| | | for (int i = 1; i <= palletCodeInfo.Qty; i++) |
| | | { |
| | | #region çææ¡å½¢ç å¾å |
| | | var n = DateTime.Now.ToString("yy"); |
| | | var Barcode = n + palletCodeInfo.Code.ToString("000000"); |
| | | //var Barcode = palletCodeInfo.PalletCode + palletCodeInfo.Code.ToString("00000000"); |
| | | palletCodeInfo.Code++; |
| | | SKImage bitmap = barcode.Encode(Barcode); |
| | | #endregion |
| | | for (int j = 1; j <= palletCodeInfo.PrintFrequency; j++) |
| | | { |
| | | |
| | | } |
| | | } |
| | | return WebResponseContent.Instance.OK("æå°æå"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | public string newBarcodeLib(int key) |
| | | { |
| | | Dt_PalletCodeInfo palletCodeInfo = BaseDal.QueryFirst(x => key == x.Id); |
| | | Barcode barcode = new Barcode();//å建æ¡å½¢ç 对象 |
| | | barcode.IncludeLabel = true;//ç¡®ä¿å
æ¬æ ç¾ |
| | | barcode.Alignment = AlignmentPositions.Center;//æ¡å½¢ç 坹齿¹å¼ |
| | | barcode.LabelFont = new SKFont |
| | | { |
| | | Typeface = SKTypeface.FromFamilyName("Arial", SKFontStyle.Bold),//å使 ·å¼ |
| | | Size = palletCodeInfo.Size,// æ ç¾åä½ |
| | | }; |
| | | barcode.EncodedType = BarcodeStandard.Type.Code128; |
| | | barcode.Width = palletCodeInfo.Width; |
| | | barcode.Height = palletCodeInfo.Height; |
| | | var Barcode = DateTime.Now.ToString("yy") + palletCodeInfo.Code.ToString("000000"); |
| | | palletCodeInfo.Code++; |
| | | BaseDal.UpdateData(palletCodeInfo); |
| | | SKImage bitmap = barcode.Encode(Barcode); |
| | | var a = barcode.EncodedImageBytes; |
| | | |
| | | return Convert.ToBase64String(a, 0, (int)a.Length); |
| | | } |
| | | public string newBarcodeLib(palletCodeInfoDTO palletCodeInfo) |
| | | { |
| | | #region çææ¡å½¢ç |
| | |
| | | //设置æ¡å½¢ç 尺寸 |
| | | barcode.Width = palletCodeInfo.Width; |
| | | barcode.Height = palletCodeInfo.Height; |
| | | |
| | | var Barcode = DateTime.Now.ToString("yy") + palletCodeInfo.Code.ToString("000000"); |
| | | //çææ¡å½¢ç å¾å |
| | | SKImage bitmap = barcode.Encode(palletCodeInfo.PalletCode); |
| | | SKImage bitmap = barcode.Encode(Barcode); |
| | | var a = barcode.EncodedImageBytes; |
| | | var b = Convert.ToBase64String(a, 0, (int)a.Length); |
| | | //ä¿åæ¡å½¢ç å¾åå°æä»¶ï¼å¯éï¼ |