public BarcodeReading RegisterBarcodeScan(string scannedBarcode) { BarcodeReading br = ParseBarcode(scannedBarcode); if (!DoesThisJobHaveAColorAssigned(br.Job)) { throw new Exception(string.Format("JOB {0} does not have an assigned color", br.Job)); } if (!IsBarcodeDataCorrect(br)) { throw new Exception(string.Format("Job")); } br.ScanDate = DateTime.Now; Barcodes barcode = GetBarcodes().FirstOrDefault(x => x.Barcode == br.Barcode); if (barcode == null) { barcode = new Barcodes() { Barcode = br.Barcode, Job = br.Job, Line = br.Line, ScanDate = br.ScanDate, SentDatabase = false, SentPrint = false, Tag = br.Tag }; AddBarcode(barcode); } return(br); }
public StatusValuePair <ArchiveEntities> Create(string url, string editUrl, int createById, string listID = null, string itemID = null, DateTime?created = null, bool isArchiveElement = false, string documentType = null, string description = null, string status = null, string barode = null ) { const string sql = "EXECUTE [dbo].[P_ArchiveEntity_Create] @Url, @EditUrl, @Created, @CreatedBy, @IsArchiveElement, @DocumentType, @Description, @Status, @ListID, @ItemID"; StatusValuePair <ArchiveEntities> procedureSingle = StoredProcedureSingle <ArchiveEntities>(sql, new { Url = url, EditUrl = editUrl, Created = created ?? DateTime.Now, CreatedBy = createById, IsArchiveElement = isArchiveElement, DocumentType = documentType, Description = description, Status = status, ListID = listID, ItemID = itemID }); if (!procedureSingle.HasValue || procedureSingle.Value == null) { return(procedureSingle); } string barcodestring; if (barode != null) { barcodestring = barode; } else { barcodestring = BarcodeFabric.Create(procedureSingle.Value.Id); } ArchiveEntities archiveEntities = procedureSingle.Value; archiveEntities.Barcode = barcodestring; procedureSingle.Value.FullId = Barcodes.FormatItemID(procedureSingle.Value.ItemID); procedureSingle = Update(archiveEntities); if (!procedureSingle.HasValue) { Delete(archiveEntities); } return(procedureSingle); }
private void Generate_Click(object sender, EventArgs e) { Barcodes barcodeDetails = new Barcodes(); DataTable datatable = barcodeDetails._Barcodes; DataTable dt = new DataTable(); //dt.TableName = "Master"; string selectedJob = ddlJobList.SelectedItem.ToString(); SqlConnection conn = new SqlConnection(); conn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["VedConnections"].ConnectionString; conn.Open(); try { SqlCommand generateCmd = new SqlCommand(); generateCmd.Connection = conn; generateCmd.CommandType = CommandType.StoredProcedure; SqlParameter param = new SqlParameter(); param.ParameterName = "@jobno"; param.Value = selectedJob; generateCmd.Parameters.Add(param); generateCmd.CommandText = "LoadBarcodes"; SqlDataReader sdr = generateCmd.ExecuteReader(); //DataTable dt = new DataTable(); dt.Load(sdr); assignDataToReport(dt); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public override List <IProduct> CheckForDiscount(List <IProduct> cart) { // filter Cart only get type(Product) and group the products by barcode var posibleProductsForDiscount = cart.Where(product => product.GetType() == typeof(Product)) .Where(product => Barcodes.Contains(product.Barcode)); var amountOfGroups = posibleProductsForDiscount.GroupBy(group => group.Barcode).Count(); if (posibleProductsForDiscount.Count() == 2 && amountOfGroups == 2) { string description = "Discount"; decimal cartPrice = 0m; foreach (var product in posibleProductsForDiscount) { cartPrice += product.Amount; description += "-" + product.Barcode; } DiscountProduct = new DiscountProduct((cartPrice - StaticDiscount) * -1, description); return(posibleProductsForDiscount.ToList()); } return(null); }
public void OnResult(ZXing.Result result) { var barcode = result.Text; Barcodes.Add(barcode); Mvx.Resolve <IToast>().Show(string.Format("Bar code = {0} added to list", barcode)); }
public override global::System.Data.DataSet Clone() { Barcodes cln = ((Barcodes)(base.Clone())); cln.InitVars(); cln.SchemaSerializationMode = this.SchemaSerializationMode; return(cln); }
private void OpenBarcodeCreationDialog() { var addBarcodeDialog = dialogService.ShowDialog <AddBarcodeDialog, AddBarcodeDialogViewModel>(Window); if (addBarcodeDialog.DialogResult == true) { Barcodes.Add(addBarcodeDialog.ResultInfo.RawBarcode); } }
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (value is string) { Type type = Barcodes.GetType((string)value); return(type == null ? null : Activator.CreateInstance(type)); } return(base.ConvertFrom(context, culture, value)); }
public WorkspaceViewModel(WorkspaceViewModel workspaceViewModel) : this() { Name = workspaceViewModel.Name; foreach (var barcode in workspaceViewModel.Barcodes) { Barcodes.Add(new BarcodeViewModel(barcode)); } }
public ScanningPageModel() { // subscribe to scanned message MessagingCenter.Subscribe <App, string>(this, "Barcode", (sender, arg) => { // Add the barcode to a list (first position) Barcodes.Insert(0, new ScannedItem { Barcode = arg }); }); }
public int GetBarcodeId(string guid) { Barcodes barcode = db.Barcodes .Include(x => x.CheckIns) .Where(x => x.Barcode.ToString() == guid && x.IsActive == true) .SingleOrDefault(); int barcodeId = barcode.Id; return(barcodeId); }
private DateTime?GetBarcodeDateByStatus(List <string> stageIds) { var barcode = Barcodes.FirstOrDefault(a => stageIds.Contains(a.Stage.Id)); if (barcode != null) { return(barcode.DateCreated); } return(null); }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) { Barcodes ds = new Barcodes(); global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny(); any.Namespace = ds.Namespace; sequence.Items.Add(any); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte()));) { ; } if ((s1.Position == s1.Length)) { return(type); } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return(type); }
public void DeleteBarcode(string barcode) { try { var barcodeToRemove = Barcodes.FirstOrDefault(f => f == barcode); Barcodes.Remove(barcodeToRemove); } catch (Exception ex) { MessageBox.Show(JsonConvert.SerializeObject(ex), "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); Log.Error(ex); } }
public bool isValidBarcode(string guid) { bool valid = false; Barcodes barcode = db.Barcodes .Include(x => x.CheckIns) .Where(x => x.Barcode.ToString() == guid && x.IsActive == true) .SingleOrDefault(); if (barcode != null) { valid = true; } return(valid); }
public List <DateTime> QueryCheckInTimes(string guid) { List <DateTime> checkInTimes = new List <DateTime>(); Barcodes barcode = db.Barcodes .Include(x => x.CheckIns) .Where(x => x.Barcode.ToString() == guid && x.IsActive == true) .SingleOrDefault(); foreach (CheckIns checkIn in barcode.CheckIns) { checkInTimes.Add(checkIn.CheckinTime.Value); } return(checkInTimes); }
public ParticipantDTO FindParticipantByBarcode(string guid) { Barcodes barcode = db.Barcodes .Where(x => x.Barcode.ToString() == guid && x.IsActive == true) .SingleOrDefault(); ParticipantDTO pDTO = new ParticipantDTO(); Participants participant = db.Participants .Include(x => x.Barcodes) .Include(x => x.EventID) .Include(x => x.AccountID) .Where(x => x.Barcodes.Select(y => y.Id).ToList().Contains(barcode.Id) && x.IsActive == true) .SingleOrDefault(); pDTO = MapParticipantToDTO(participant); return(pDTO); }
public void CreateCheckIn(CheckInDTO checkInDTO) { string userId = HttpContext.Current.User.Identity.GetUserId(); ApplicationUser user = db.Users.Find(userId); Barcodes barcode = db.Barcodes.Find(checkInDTO.BarcodeId); CheckIns ci = new CheckIns(); ci.CheckinTime = DateTime.Now; ci.CreatedDate = DateTime.Now; ci.CreatedBy = user; ci.IsActive = true; db.CheckIns.Add(ci); barcode.CheckIns = new List <CheckIns>(); barcode.CheckIns.Add(ci); db.SaveChanges(); }
public int CreateParticipant(ParticipantDTO participantsDTO) { string userId = HttpContext.Current.User.Identity.GetUserId(); ApplicationUser user = db.Users.Find(userId); Events events = db.Events.Find(participantsDTO.eventId); List <Barcodes> barcodes = new List <Barcodes>(); foreach (Guid barcode in participantsDTO.Barcodes) { var barcodeRecord = new Barcodes { Barcode = barcode, CreatedBy = user, CreatedDate = DateTime.Now, IsActive = true }; barcodes.Add(barcodeRecord); } var participant = new Participants { AccountID = user, NumberOfTicket = participantsDTO.NumberOfTicket, Reminder = participantsDTO.Reminder, EventID = events, CreatedBy = user, IsActive = true, CreatedDate = DateTime.Now, Barcodes = barcodes }; db.Participants.Add(participant); db.SaveChanges(); return(participant.Id); }
public void AddSuppliers(string sku, string id, string name, string company, List <string> barcodeList) { var parentCompany = CompanyDataSourceInstance.CompanyCollection.Find(x => x.CompanyName.ToLower().Equals(company.ToLower())); var sameSupplierExist = parentCompany.SuppliersDataSourceInstance.SupplierList.FindAll(x => x.ID.Equals(id)); if (sameSupplierExist.Count.Equals(0)) { Suppliers suppliersInstance = new Suppliers { ID = id, Name = name }; parentCompany.SuppliersDataSourceInstance.SupplierList.Add(suppliersInstance); parentCompany.SuppliersDataSourceInstance.ExportToCsv(inputPath); } else { Console.WriteLine("Already Supplier data exist"); } bool isBarCodeUpdate = false; foreach (var barcodeData in barcodeList) { var sameBarcodeExist = parentCompany.BarcodeDataSourceInstance.BarcodeList.FindAll(x => x.SKU.Equals(sku) && x.SupplierID.Equals(id) && x.Barcode.Equals(barcodeData)); if (sameBarcodeExist.Count.Equals(0)) { isBarCodeUpdate = true; var barcodeInstance = new Barcodes { SKU = sku, SupplierID = id, Barcode = barcodeData }; parentCompany.BarcodeDataSourceInstance.BarcodeList.Add(barcodeInstance); } } if (isBarCodeUpdate) { parentCompany.BarcodeDataSourceInstance.ExportToCsv(inputPath); } MergeCatalogDataSourceInstance.ExportToCsv(parentCompanyName, outputPath, CompanyDataSourceInstance.CompanyCollection); }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object Value) { edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); string name = (Value as BarcodeBase).Name; ListBox lb = new ListBox(); lb.Items.AddRange(Barcodes.GetItems()); lb.SelectedItem = name; lb.BorderStyle = BorderStyle.None; lb.Height = lb.ItemHeight * lb.Items.Count; lb.Click += new EventHandler(lb_Click); edSvc.DropDownControl(lb); string selectedName = (string)lb.SelectedItem; if (selectedName != name) { return(Activator.CreateInstance(Barcodes.GetType(selectedName))); } return(Value); }
public static byte[] BarCodeWrite(int left, int top, int height, ElementDrawRotation rotation, Barcodes barcode, bool readable, string barcodeData) { string encodedReadable = readable ? "1" : "0"; string bartype = BarcodeTypeMap.TSCPLBarcodeTypeMap[(int)barcode.Type]; if (bartype == string.Empty) { throw new ApplicationException("Barcode not yet supported by LabelPrinter library or printer language."); } return(Encoding.GetEncoding(850).GetBytes(string.Format("BARCODE {0},{1},\"{2}\",{3},{4},{5},{6},{7},\"{8}\"\n", left, top, bartype, height, encodedReadable, Rotation.TSCPLRotationMap[(int)rotation], barcode.BarWidthNarrow, barcode.BarWidthWide, barcodeData))); }
public static BubbleSheet scanSheet(Bitmap input, ExamSpecifics test) { RotatedRect[] barcodes = BarScan.detectBarcodes(input); Bitmap toScan = new Bitmap(input.Width, input.Height, PixelFormat.Format32bppArgb); Graphics g = Graphics.FromImage(toScan); g.DrawImage(input, new Point(0, 0)); g.Dispose(); toScan.SetPixel((int)barcodes[0].GetVertices()[1].X, (int)barcodes[0].GetVertices()[1].Y, Color.FromArgb(150, 0, 50)); toScan.SetPixel((int)barcodes[0].GetVertices()[3].X, (int)barcodes[0].GetVertices()[3].Y, Color.FromArgb(150, 0, 100)); toScan.SetPixel((int)barcodes[1].GetVertices()[1].X, (int)barcodes[1].GetVertices()[1].Y, Color.FromArgb(150, 50, 50)); toScan.SetPixel((int)barcodes[1].GetVertices()[3].X, (int)barcodes[1].GetVertices()[3].Y, Color.FromArgb(150, 50, 100)); Bitmap toCompartmentalize = new Bitmap(toScan.Width, toScan.Height); int minY = 0; bool found1 = false; bool isDone = false; Point p1 = new Point(); Point p2 = new Point(); Point p3 = new Point(); Point p4 = new Point(); for (int y = 0; y < toScan.Height; y++) { if (isDone) { break; } for (int x = 0; x < toScan.Width; x++) { Color c = toScan.GetPixel(x, y); if (c.R == 150) { if (c.B == 50 && c.G == 0) { p1 = new Point(x, y); } else if (c.B == 100 && c.G == 0) { p2 = new Point(x, y); } else if (c.B == 50 && c.G == 50) { p3 = new Point(x, y); } else if (c.B == 100 && c.G == 50) { p4 = new Point(x, y); } if (c.B == 100) { if (found1) { if (y > minY) { minY = y; } isDone = true; break; } else { minY = y; found1 = true; } } } } } Graphics p = Graphics.FromImage(toCompartmentalize); p.DrawImage(toScan, new Point(0, 0)); p.Dispose(); Rectangle r1 = new Rectangle(p1.X - 50, p1.Y - 50, (p2.X - p1.X) + 100, (p2.Y - p1.Y) + 100); Rectangle r2 = new Rectangle(p3.X - 50, p3.Y - 50, (p4.X - p3.X) + 100, (p4.Y - p3.Y) + 100); Barcodes quickCodes = new Barcodes(BarScan.cropImage(toCompartmentalize, r1), BarScan.cropImage(toCompartmentalize, r2)); toCompartmentalize = BarScan.cropImage(toCompartmentalize, new Rectangle(0, minY, toCompartmentalize.Width, toCompartmentalize.Height - minY)); ScanAndGrade scantron = Compartmentalize.findBubbles(toCompartmentalize, test); //CALCULATE SCORE double score = 0; score = score + (scantron.scannedScores[1].score * test.multipleChoiceWeight); score = score + (scantron.scannedScores[2].score * test.pairingWeight); score = score + (scantron.scannedScores[3].score * test.trueWeight); score = score + (scantron.scannedScores[4].score * test.compWeight); score = score + (scantron.scannedScores[5].score * test.subjectWeight); Bitmap correctAnswerOverlay = new Bitmap(toCompartmentalize.Width, toCompartmentalize.Height); Bitmap inCorrectAnswerOverlay = new Bitmap(toCompartmentalize.Width, toCompartmentalize.Height); Bitmap blankAnswerOverlay = new Bitmap(toCompartmentalize.Width, toCompartmentalize.Height); Graphics correctAnswerOverlayGraphics = Graphics.FromImage(correctAnswerOverlay); scantron.scannedScores[0].drawCorrectAnswer(correctAnswerOverlayGraphics); scantron.scannedScores[1].drawCorrectAnswer(correctAnswerOverlayGraphics); scantron.scannedScores[2].drawCorrectAnswer(correctAnswerOverlayGraphics); scantron.scannedScores[3].drawCorrectAnswer(correctAnswerOverlayGraphics); scantron.scannedScores[4].drawCorrectAnswer(correctAnswerOverlayGraphics); scantron.scannedScores[5].drawCorrectAnswer(correctAnswerOverlayGraphics); correctAnswerOverlayGraphics.Dispose(); Graphics inCorrectAnswerOverlayGraphics = Graphics.FromImage(inCorrectAnswerOverlay); scantron.scannedScores[0].drawCorrectAnswer(inCorrectAnswerOverlayGraphics); scantron.scannedScores[1].drawCorrectAnswer(inCorrectAnswerOverlayGraphics); scantron.scannedScores[2].drawCorrectAnswer(inCorrectAnswerOverlayGraphics); scantron.scannedScores[3].drawCorrectAnswer(inCorrectAnswerOverlayGraphics); scantron.scannedScores[4].drawCorrectAnswer(inCorrectAnswerOverlayGraphics); scantron.scannedScores[5].drawCorrectAnswer(inCorrectAnswerOverlayGraphics); inCorrectAnswerOverlayGraphics.Dispose(); Graphics blankAnswerOverlayGraphics = Graphics.FromImage(blankAnswerOverlay); scantron.scannedScores[0].drawCorrectAnswer(blankAnswerOverlayGraphics); scantron.scannedScores[1].drawCorrectAnswer(blankAnswerOverlayGraphics); scantron.scannedScores[2].drawCorrectAnswer(blankAnswerOverlayGraphics); scantron.scannedScores[3].drawCorrectAnswer(blankAnswerOverlayGraphics); scantron.scannedScores[4].drawCorrectAnswer(blankAnswerOverlayGraphics); scantron.scannedScores[5].drawCorrectAnswer(blankAnswerOverlayGraphics); blankAnswerOverlayGraphics.Dispose(); BubbleSheet toReturn = new BubbleSheet(quickCodes.seatID, quickCodes.socialID, test, score, (scantron.scannedScores[0] as StudentCondition).didCheat, (scantron.scannedScores[0] as StudentCondition).wasAbsent, scantron.scannedScores[1].getResponses(), scantron.scannedScores[2].getResponses(), scantron.scannedScores[3].getResponses(), scantron.scannedScores[4].getResponses(), scantron.scannedScores[5].getResponses(), correctAnswerOverlay, inCorrectAnswerOverlay, toCompartmentalize, blankAnswerOverlay); return(toReturn); }
public static byte[] BarCodeWrite(int left, int top, int height, ElementDrawRotation rotation, Barcodes barcode, bool readable, string barcodeData, PrinterSettings settings) { string encodedReadable = readable ? "B" : "N"; return(Encoding.GetEncoding(437).GetBytes(string.Format("B{0},{1},{2},{3},{4},{5},{6},{7},\"{8}\"\n", left + settings.AlignLeft, top + settings.AlignTop, (int)rotation, barcode.P4Value, barcode.BarWidthNarrow, barcode.BarWidthWide, height, encodedReadable, barcodeData))); }
private async void SubmitCommandRecieverAsync() { try { Loader.StartLoading(); var location = await _geolocationService.GetLastLocationAsync(); Loader.StopLoading(); var tags = ConstantManager.Tags; var partnerModel = ConstantManager.Partner; if (Barcodes.Count() == 0) { await _dialogService.DisplayAlertAsync("Error", "Error: Please add some scans.", "Ok"); return; } IEnumerable <BarcodeModel> empty = Barcodes.Where(x => x.Barcode.Count() == 0); if (empty.ToList().Count > 0) { string result = await _dialogService.DisplayActionSheetAsync("Error? \n Some pallets have 0 scans. Do you want to edit them or remove the empty pallets.", null, null, "Remove empties", "Edit"); if (result == "Remove empties") { foreach (var item in empty.Reverse()) { Barcodes.Remove(item); } if (Barcodes.Count == 0) { return; } } if (result == "Edit") { await ItemTappedCommandRecieverAsync(empty.FirstOrDefault()); return; } } List <string> closedBatches = new List <string>(); List <NewPallet> newPallets = new List <NewPallet>(); NewPallet newPallet = null; List <TItem> palletItems = new List <TItem>(); TItem palletItem = null; foreach (var pallet in Barcodes) { palletItem = new TItem { Barcode = pallet.Barcode, ScanDate = DateTimeOffset.UtcNow.Date, TagsStr = pallet.TagsStr }; if (pallet.Tags != null) { foreach (var tag in pallet.Tags) { palletItem.Tags.Add(tag); } } palletItems.Add(palletItem); newPallet = new NewPallet { Barcode = BatchId, BuildDate = DateTimeOffset.UtcNow.Date, StockLocation = partnerModel?.PartnerId, StockLocationId = partnerModel?.PartnerId, StockLocationName = partnerModel?.FullName, OwnerId = AppSettings.CompanyId, PalletId = _uuidManager.GetUuId(), ReferenceKey = "", }; if (tags != null) { foreach (var item in tags) { newPallet.Tags.Add(item); } } foreach (var item in palletItems) { newPallet.PalletItems.Add(item); } newPallets.Add(newPallet); } bool accept = await _dialogService.DisplayAlertAsync("Close batch", "Mark this batch as completed?", "Yes", "No"); if (accept) { closedBatches = Barcodes.Select(x => x.Barcode).ToList(); } Loader.StartLoading(); ManifestModel model = model = GenerateManifest(location ?? new Xamarin.Essentials.Location(0, 0), newPallets, closedBatches); if (model != null) { try { var current = Connectivity.NetworkAccess; if (current == NetworkAccess.Internet) { ManifestModelGet manifestResult = await _moveService.PostManifestAsync(model, AppSettings.SessionId, Configuration.NewManifest); try { AddorUpdateManifestOffline(model, false); } catch (Exception ex) { Crashes.TrackError(ex); } await GetPostedManifestDetail(); } else { try { AddorUpdateManifestOffline(model, true); } catch (Exception ex) { Crashes.TrackError(ex); } await GetPostedManifestDetail(); } } catch (Exception ex) { Crashes.TrackError(ex); } finally { Loader.StopLoading(); model = null; tags = null; partnerModel = null; closedBatches = null; newPallets = null; newPallet = null; palletItems = null; Cleanup(); } } else { await _dialogService.DisplayAlertAsync("Alert", "Something goes wrong please check again", "Ok"); } } catch (Exception) { } finally { Loader.StopLoading(); } }
public void DeleteBarcode(string barcode) { var barcodeToRemove = Barcodes.First(f => f == barcode); Barcodes.Remove(barcodeToRemove); }
public static byte[] BarCodeWrite(int left, int top, int height, ElementDrawRotation rotation, Barcodes barcode, bool readable, string barcodeData) { string encodedReadable = readable ? "Y" : "N"; char encodedRotation = Rotation.ZPLRotationMap[(int)rotation]; switch (barcode.Type) { case BarcodeType.CODE39_STD_EXT: return(Encoding.GetEncoding(850).GetBytes(string.Format("^FO{0},{1}^BY{2}^B3{3},N,{4},{5}^FD{6}^FS", left, top, barcode.BarWidthNarrow, encodedRotation, height, encodedReadable, barcodeData))); case BarcodeType.CODE128_AUTO: return(Encoding.GetEncoding(850).GetBytes(string.Format("^FO{0},{1}^BY{2}^BC{3},{4},{5}^FD{6}^FS", left, top, barcode.BarWidthNarrow, encodedRotation, height, encodedReadable, barcodeData))); case BarcodeType.UPC_A: return(Encoding.GetEncoding(850).GetBytes(string.Format("^FO{0},{1}^BY{2}^BU{3},{4},{5}^FD{6}^FS", left, top, barcode.BarWidthNarrow, encodedRotation, height, encodedReadable, barcodeData))); case BarcodeType.UPC_E: return(Encoding.GetEncoding(850).GetBytes(string.Format("^FO{0},{1}^BY{2}^B9{3},{4},{5}^FD{6}^FS", left, top, barcode.BarWidthNarrow, encodedRotation, height, encodedReadable, barcodeData))); case BarcodeType.EAN8: return(Encoding.GetEncoding(850).GetBytes(string.Format("^FO{0},{1}^BY{2}^B8{3},{4},{5}^FD{6}^FS", left, top, barcode.BarWidthNarrow, encodedRotation, height, encodedReadable, barcodeData))); case BarcodeType.EAN13: return(Encoding.GetEncoding(850).GetBytes(string.Format("^FO{0},{1}^BY{2}^BE{3},{4},{5}^FD{6}^FS", left, top, barcode.BarWidthNarrow, encodedRotation, height, encodedReadable, barcodeData))); default: throw new ApplicationException("Barcode not yet supported by LabelPrinter library or printer language."); } }
public void AddBarcode(BarcodeType type, string message, string encoding, string alternateText) { Barcodes.Add(new Barcode(type, message, encoding, alternateText)); }
/// <summary> /// Initializes a new instance of the <see cref="LineaTest.BarcodeScannedEventArgs"/> class. /// </summary> public BarcodeScannedEventArgs(string Data, Barcodes BarcodeType) { this.Data = Data; this.BarcodeType = BarcodeType; }
public void AddBarcode(BarcodeType type, string message, string encoding) { Barcodes.Add(new Barcode(type, message, encoding)); }
public StatusValuePair <List <ArchiveEntities> > Search(SearchParams searchParams) { List <string> barcodes = searchParams.Barcodes.ToList(); bool? isArchiveElement = searchParams.IsArchiveElement; List <int> userGroupIds = searchParams.UserGroupIds; List <SearchParams.SpFieldsStructHidden> fieldsStruct = searchParams.FieldsStruct; // когда всё пусто if ((!searchParams.Barcodes.Any() || searchParams.Barcodes.All(string.IsNullOrWhiteSpace)) && !searchParams.IsArchiveElement.HasValue && searchParams.FieldsStruct.Count == 0) { return(new StatusValuePair <List <ArchiveEntities> >(null, ErrorCode.UnknownError)); } StringBuilder sqlQuery = new StringBuilder(); sqlQuery.AppendFormat( "SELECT A.* FROM ArchiveEntities AS A left join ArchiveDocsContentType as AD on A.{0}=AD.{0} WHERE ", Constants.BarCodeFieldName); // Permissions string permissionsFilter = string.Empty; if (userGroupIds.Count > 1) { foreach (int uId in userGroupIds) { if (permissionsFilter.EndsWith(")")) { permissionsFilter += " OR "; } permissionsFilter += "([UserGroupId] = " + uId + ")"; } } else { permissionsFilter = "[UserGroupId] = " + userGroupIds.FirstOrDefault(); } sqlQuery.AppendFormat(" A.[{0}] IN (SELECT [{0}] FROM [{1}] WHERE ({2})) ", Constants.BarCodeFieldName, Constants.PermissionsDataTableName, permissionsFilter); // End Permissions // IsArchiveElement And IsUpdated if (isArchiveElement.HasValue) { sqlQuery.AppendFormat(" AND (A.[IsArchiveElement] = {0}) ", isArchiveElement.Value ? 1 : 0); } sqlQuery.Append(" AND (A.[IsUpdated] = 1 OR AD.[IsUpdated] = 1) "); // End IsArchiveElement And IsUpdated // BarCodes string barcodeFilter = string.Empty; if (barcodes.Count() > 1) { foreach (string barcode in barcodes) { if (barcodeFilter.EndsWith(")")) { barcodeFilter += " OR "; } barcodeFilter += "(A.[" + Constants.BarCodeFieldName + "] = '" + barcode + "')"; } } else if (barcodes.Any()) { barcodeFilter = "A.[" + Constants.BarCodeFieldName + "] = '" + barcodes.FirstOrDefault() + "'"; } // End BarCodes // Field Filters string fieldsFilter = string.Empty; if (!barcodes.Any()) { if (fieldsStruct.Count() > 1) { foreach (SearchParams.SpFieldsStructHidden fieldFilter in fieldsStruct) { string buildFieldsFilter = BuildFieldsFilter(fieldFilter); if (string.IsNullOrWhiteSpace(buildFieldsFilter)) { continue; } if (fieldsFilter.EndsWith(")")) { fieldsFilter += " AND "; } fieldsFilter += buildFieldsFilter; } } else if (fieldsStruct.Any()) { SearchParams.SpFieldsStructHidden spFieldsStructHidden = fieldsStruct.First(); if (!string.IsNullOrWhiteSpace(spFieldsStructHidden.InternalName) && !string.IsNullOrWhiteSpace(spFieldsStructHidden.Value)) { fieldsFilter = BuildFieldsFilter(spFieldsStructHidden); } } } // End Field Filters if (!string.IsNullOrWhiteSpace(barcodeFilter) && !string.IsNullOrWhiteSpace(fieldsFilter)) { sqlQuery.AppendFormat(" AND ({0} OR {1}) ", barcodeFilter, fieldsFilter); } else if (!string.IsNullOrWhiteSpace(barcodeFilter)) { sqlQuery.AppendFormat(" AND ({0}) ", barcodeFilter); } else if (!string.IsNullOrWhiteSpace(fieldsFilter)) { sqlQuery.AppendFormat(" AND ({0})", fieldsFilter); } string sql = sqlQuery.ToString(); StatusValuePair <List <ArchiveEntities> > entitieses = StoredProcedureList <ArchiveEntities>(sql); //entitieses.Value = entitieses.Value.Select(archiveItem=>archiveItem); List <ArchiveEntities> global = entitieses.Value.Select(archiveEntity => { archiveEntity.Barcode = Barcodes.FormatBarcode(archiveEntity.Barcode); return(archiveEntity); }).ToList(); if (entitieses.HasValue && entitieses.ErrorCode == ErrorCode.NoError) { return(entitieses.Value); } return(new StatusValuePair <List <ArchiveEntities> >(null, ErrorCode.UnknownError)); }