public string GetLabel(string shipmentId, LabelFormat format) { var req = new RestRequest("/shipping/shipment/{ShipmentId}/label"); req.AddUrlSegment("ShipmentId", shipmentId); switch (format) { case LabelFormat.Citizen: req.AddHeader("Accept", "text/vnd.citizen-clp"); break; case LabelFormat.Eltron: req.AddHeader("Accept", "text/vnd.eltron-epl"); break; case LabelFormat.Html: req.AddHeader("Accept", "text/html"); break; default: throw new ArgumentOutOfRangeException("format", format, null); } var data = Client.Get(req); return(data.Content); }
public ContentResult SaveLabelFormat(string sName, int iSize, string sFormat) { if (!Authenticate()) { return(Content("2")); } var label = (from e in DbUtil.Db.LabelFormats where e.Name == sName where e.Size == iSize select e).FirstOrDefault(); if (label == null) { var lfNew = new LabelFormat(); lfNew.Name = sName; lfNew.Size = iSize; lfNew.Format = sFormat; DbUtil.Db.LabelFormats.InsertOnSubmit(lfNew); DbUtil.Db.SubmitChanges(); } else { label.Format = sFormat; DbUtil.Db.SubmitChanges(); } return(Content("0")); }
public frmLabelFormats(LabelFormat labelFormat) { InitializeComponent(); this.m_labelFormat = labelFormat; _configService = new ConfigService(); }
public BartenderFormat addFMT(IRepository repository) { BartenderFormat newformat = new BartenderFormat(); Dictionary <string, string> results = openFileBox("Bartender Files|*.btw", true); foreach (KeyValuePair <string, string> fn in results) { newformat.FormatName = fn.Key; newformat.FormatPath = fn.Value; newformat.SubStrings = new List <BartenderSubString>(); Engine engine = runBartenderEngine(); LabelFormat openformat = engine.Documents.Open(newformat.FormatPath); if (openformat != null) { foreach (var ss in openformat.SubStrings) { newformat.SubStrings.Add(new BartenderSubString() { SubStringName = ss.Name, SubStringValue = ss.Value, SubStringSerializeBy = ss.SerializeBy, SubStringSerializeEvery = ss.SerializeEvery, SubStringRollover = ss.Rollover, SubStringRolloverLimit = ss.RolloverLimit, SubStringRolloverResetValue = ss.RolloverResetValue, SubStringType = ss.Type, }); } } repository.Add(newformat); repository.Save(); } return(newformat); }
private void AddPage(PdfDocument Doc, PdfPage Page, LabelFormat lf) { Page = Doc.AddPage(); Page.Width = XUnit.FromMillimeter(lf.PageWidth); Page.Height = XUnit.FromMillimeter(lf.PageHeight); }
public frmLabelFormats(int appConfigId) { InitializeComponent(); //m_labelFormat = new LabelFormat(); //_configService = new ConfigService(); this.m_labelFormat = new LabelFormat(); this.m_labelFormat.AppConfigId = appConfigId; _configService = new ConfigService(); }
/// <inheritdoc /> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; if (Type != null) { hashCode = hashCode * 59 + Type.GetHashCode(); } if (Start != null) { hashCode = hashCode * 59 + Start.GetHashCode(); } if (End != null) { hashCode = hashCode * 59 + End.GetHashCode(); } if (Size != null) { hashCode = hashCode * 59 + Size.GetHashCode(); } if (Coloring != null) { hashCode = hashCode * 59 + Coloring.GetHashCode(); } if (ShowLines != null) { hashCode = hashCode * 59 + ShowLines.GetHashCode(); } if (ShowLabels != null) { hashCode = hashCode * 59 + ShowLabels.GetHashCode(); } if (LabelFont != null) { hashCode = hashCode * 59 + LabelFont.GetHashCode(); } if (LabelFormat != null) { hashCode = hashCode * 59 + LabelFormat.GetHashCode(); } if (Operation != null) { hashCode = hashCode * 59 + Operation.GetHashCode(); } if (Value != null) { hashCode = hashCode * 59 + Value.GetHashCode(); } return(hashCode); } }
/// <summary> /// Draws the label. /// </summary> /// <param name="context">Context.</param> /// <param name="format">Format.</param> /// <param name="bordertype">Bordertype.</param> /// <param name="labelposition">Labelposition.</param> /// <param name="pin">Pin.</param> /// <param name="xpos">Xpos.</param> /// <param name="ypos">Ypos.</param> public static void DrawLabel(Cairo.Context context, LabelFormat format, BorderType bordertype, LabelPosition labelposition, IPin pin, int xpos, int ypos) { switch (format) { case LabelFormat.Flat: DrawLabelFlat(context, bordertype, labelposition, pin, xpos, ypos); break; case LabelFormat.Bold: DrawLabel(context, bordertype, pin, xpos, ypos); break; } }
private void MakePdfDocumentForLabels(PdfDocument pdfDoc, LabelFormat labelFormat, Dictionary <int, EnvelopeAddress> labels) { int pageCount = FindPdfDocPagesCnt(labels.Count, labelFormat.LabelsPerPage); int lastLabelIdxOnPage = 0; XFont xfont = GetLabelsXFont(); for (int pageIdx = 0; pageIdx < pageCount; pageIdx++) { PdfPage pdfPage = CreateNewPage(pdfDoc, true, PageSizeConverter.ToSize(PdfSharp.PageSize.Letter)); lastLabelIdxOnPage = FillPdfPageWithLabels(pdfPage, labelFormat, xfont, labels, lastLabelIdxOnPage); } }
public Label(string id, string url, LabelFormat format, string trackingNumber, CarrierType carrier, NFX.Financial.Amount rate) : this() { ID = id; CreateDate = App.TimeSource.UTCNow; URL = url; Format = format; TrackingNumber = trackingNumber; Carrier = carrier; Rate = rate; }
public Label(object id, string url, byte[] data, LabelFormat format, string trackingNumber, Carrier carrier, NFX.Financial.Amount rate) : this() { ID = id; CreateDate = App.TimeSource.UTCNow; URL = url; Data = data; Format = format; TrackingNumber = trackingNumber; Carrier = carrier; Rate = rate; }
public override void WriteXml(XmlWriter writer) { TypeConverter colorConverter = TypeDescriptor.GetConverter(typeof(Color)); base.WriteXml(writer); writer.WriteElementString("KnobImage", KnobImage); writer.WriteStartElement("Positions"); foreach (RotarySwitchPosition position in Positions) { writer.WriteStartElement("Position"); writer.WriteAttributeString("Name", position.Name); writer.WriteAttributeString("Rotation", position.Rotation.ToString(CultureInfo.InvariantCulture)); writer.WriteEndElement(); } writer.WriteEndElement(); writer.WriteElementString("DefaultPosition", DefaultPosition.ToString(CultureInfo.InvariantCulture)); if (DrawLines) { writer.WriteStartElement("Lines"); writer.WriteElementString("Thickness", LineThickness.ToString(CultureInfo.InvariantCulture)); writer.WriteElementString("Length", LineLength.ToString(CultureInfo.InvariantCulture)); writer.WriteElementString("Color", colorConverter.ConvertToInvariantString(LineColor)); writer.WriteEndElement(); } if (DrawLabels) { writer.WriteStartElement("Labels"); writer.WriteElementString("Color", colorConverter.ConvertToInvariantString(LabelColor)); writer.WriteElementString("MaxWidth", MaxLabelWidth.ToString(CultureInfo.InvariantCulture)); writer.WriteElementString("MaxHeight", MaxLabelHeight.ToString(CultureInfo.InvariantCulture)); writer.WriteElementString("Distance", LabelDistance.ToString(CultureInfo.InvariantCulture)); LabelFormat.WriteXml(writer); writer.WriteEndElement(); } writer.WriteStartElement("ClickType"); writer.WriteElementString("Type", ClickType.ToString()); if (ClickType == Controls.ClickType.Swipe) { writer.WriteElementString("Sensitivity", SwipeSensitivity.ToString(CultureInfo.InvariantCulture)); } writer.WriteEndElement(); writer.WriteElementString("MouseWheel", MouseWheelAction.ToString(CultureInfo.InvariantCulture)); }
/// <summary> /// Serves as a hash function for the objects of <see cref="DumpAttribute"/> and its derived types. /// </summary> /// <returns>A hash code for the current <see cref="DumpAttribute"/> instance.</returns> public override int GetHashCode() { var hashCode = Constants.HashInitializer; unchecked { hashCode = Constants.HashMultiplier * hashCode + Order.GetHashCode(); hashCode = Constants.HashMultiplier * hashCode + DumpNullValues.GetHashCode(); hashCode = Constants.HashMultiplier * hashCode + Skip.GetHashCode(); hashCode = Constants.HashMultiplier * hashCode + RecurseDump.GetHashCode(); hashCode = Constants.HashMultiplier * hashCode + (DefaultProperty?.GetHashCode() ?? 0); hashCode = Constants.HashMultiplier * hashCode + Mask.GetHashCode(); hashCode = Constants.HashMultiplier * hashCode + MaskValue.GetHashCode(); hashCode = Constants.HashMultiplier * hashCode + MaxLength.GetHashCode(); hashCode = Constants.HashMultiplier * hashCode + MaxDepth.GetHashCode(); hashCode = Constants.HashMultiplier * hashCode + LabelFormat.GetHashCode(); hashCode = Constants.HashMultiplier * hashCode + ValueFormat.GetHashCode(); } return(hashCode); }
public void SaveLabelFormat(LabelFormat labelFormat) { using (var conn = new SqliteConnection("Data Source=" + System.Environment.CurrentDirectory + "/zpl.db")) { if (labelFormat.Id > 0) { var sql = "UPDATE LabelFormats SET Name = @Name, Height = @Height, Width = @Width, PrintDensity = @PrintDensity, UseBitonal = @UseBitonal, IsDefault = @IsDefault WHERE Id = @Id "; var result = conn.Execute(sql, new { labelFormat.Name, labelFormat.Height, labelFormat.Width, labelFormat.PrintDensity, labelFormat.UseBitonal, labelFormat.IsDefault, labelFormat.Id }); } else { var sql = "insert into LabelFormats (AppConfigId, Name, Height, Width, PrintDensity, UseBitonal, IsDefault) VALUES" + "(@AppConfigId, @Name, @Height, @Width, @PrintDensity, @UseBitonal, @IsDefault)"; var result = conn.Execute(sql, new { labelFormat.AppConfigId, labelFormat.Name, labelFormat.Height, labelFormat.Width, labelFormat.PrintDensity, labelFormat.UseBitonal, labelFormat.IsDefault }); } } }
public LabelFormat GetLabelFormat(int idLabelFormat) { List <LabelFormat> listLabelFormat = null; LabelFormat emptyItem = new LabelFormat(); listLabelFormat = GetLabelFormats(); if (listLabelFormat.Count > 0) { foreach (LabelFormat item in listLabelFormat) { if (item.Id == idLabelFormat) { return(item); } } return(emptyItem); } else { return(emptyItem); } }
private static void preview2BitmapFile(LabelFormat btFormat, TaskQueue queue, PoolItem item) { string methodName = "preview2BitmapFile"; logger.DebugFormat("BEGIN: {0}()", methodName); try { string bmpFileName = "%PageNumber%.bmp"; Resolution res = new Resolution(item.DPI); System.Drawing.Color bkcolor = System.Drawing.ColorTranslator.FromHtml("#FFFFFF"); ExportPrintPreviewToFileTask bitmapTask = new ExportPrintPreviewToFileTask(btFormat, item.BmpFolder, bmpFileName); bitmapTask.Directory = item.BmpFolder; bitmapTask.FileNameTemplate = bmpFileName; bitmapTask.BackgroundColor = bkcolor; bitmapTask.Colors = ColorDepth.Mono; bitmapTask.ImageType = ImageType.BMP; bitmapTask.IncludeBorder = false; bitmapTask.IncludeMargins = false; bitmapTask.OverwriteOptions = OverwriteOptions.Overwrite; bitmapTask.Resolution = res; logger.DebugFormat("ExportPrintPreviewToFileTask bitmap file starting ..."); TaskStatus taskStatus = queue.QueueTaskAndWait(bitmapTask, BtTaskManager.Timeout); if (taskStatus != TaskStatus.Success) { string str = ""; foreach (Seagull.BarTender.Print.Message m in bitmapTask.Messages) { str += string.Format("{0} Message: {1}\r\n", m.Severity, m.Text); } item.HasError = true; item.ErrorText = string.Format("Thread Id: {0} generate label {1} bitmap file {2} ErrorText: {3}", item.ThreadId.ToString(), item.BtwFile, taskStatus.ToString(), str); throw new Exception(item.ErrorText); } else { logger.DebugFormat("Thread Id: {0} generate label {1} bitmap files count :{1} ok! ", item.ThreadId.ToString(), item.BtwFile, bitmapTask.NumberOfPreviews.ToString()); } } catch (Exception e) { logger.Error(e.Message, e); throw; } finally { logger.DebugFormat("END: {0}()", methodName); } }
private static void print2BitmapFile(LabelFormat btFormat, TaskQueue queue, PoolItem item) { string methodName = "print2BitmapFile"; logger.DebugFormat("BEGIN: {0}()", methodName); try { PrintLabelFormatTask bitmapTask = new PrintLabelFormatTask(btFormat); bitmapTask.PrintJobName = item.BtwSrcFileName; logger.DebugFormat("PrintLabelFormatTask bitmap file starting ..."); lock (synPrinter) { setupBitmapPrinter(item); Thread.Sleep(20); TaskStatus taskStatus = queue.QueueTaskAndWait(bitmapTask, BtTaskManager.Timeout); if (taskStatus != TaskStatus.Success) { string str = ""; foreach (Seagull.BarTender.Print.Message m in bitmapTask.Messages) { str += string.Format("{0} Message: {1}\r\n", m.Severity, m.Text); } item.HasError = true; item.ErrorText = string.Format("Thread Id: {0} generate label {1} bitmap file {2} ErrorText: {3}", item.ThreadId.ToString(), item.BtwFile, taskStatus.ToString(), str); throw new Exception(item.ErrorText); } else { waitingBitmapFile(item.BmpFolder); logger.DebugFormat("Thread Id: {0} generate label {1} bitmap files ok! ", item.ThreadId.ToString(), item.BtwFile); } } } catch (Exception e) { logger.Error(e.Message, e); throw; } finally { logger.DebugFormat("END: {0}()", methodName); } }
/// <summary> /// Draws the labels. /// </summary> /// <param name="context">Context.</param> /// <param name="pins">Pins.</param> /// <param name="xpos">Xpos.</param> /// <param name="ypos">Ypos.</param> /// <param name="labelposition">Labelposition.</param> /// <param name="labelformat">Labelformat.</param> /// <param name="bordtype">Bordtype.</param> public static void SetPinLabels(Cairo.Context context, List<IPin> pins, int xpos, int ypos, LabelPosition labelposition, LabelFormat labelformat = LabelFormat.Flat, BorderType bordtype = BorderType.Line) { int height = (labelformat == LabelFormat.Flat) ? FlatHeight : BoldHeight; for (int i = 0; i < pins.Count; i++) { DrawLabel (context, labelformat, bordtype, labelposition, pins [i], xpos, ypos + (i * height + i * Space)); } }
protected abstract void SetSubStrings(LabelFormat labelFormat);
protected override void SetSubStrings(LabelFormat labelFormat) { labelFormat.SubStrings.SetSubString("OrderNo", orderNo); labelFormat.SubStrings.SetSubString("FirstSerialNo", firstSerialNo.ToString().PadLeft(4, '0')); }
public override void ReadXml(XmlReader reader) { TypeConverter colorConverter = TypeDescriptor.GetConverter(typeof(Color)); base.ReadXml(reader); KnobImage = reader.ReadElementString("KnobImage"); if (!reader.IsEmptyElement) { Positions.Clear(); reader.ReadStartElement("Positions"); int i = 1; while (reader.NodeType != XmlNodeType.EndElement) { Positions.Add(new RotarySwitchPosition(this, i++, reader.GetAttribute("Name"), Double.Parse(reader.GetAttribute("Rotation"), CultureInfo.InvariantCulture))); reader.Read(); } reader.ReadEndElement(); } else { reader.Read(); } DefaultPosition = int.Parse(reader.ReadElementString("DefaultPosition"), CultureInfo.InvariantCulture); if (reader.Name.Equals("Lines")) { DrawLines = true; reader.ReadStartElement("Lines"); LineThickness = double.Parse(reader.ReadElementString("Thickness"), CultureInfo.InvariantCulture); LineLength = double.Parse(reader.ReadElementString("Length"), CultureInfo.InvariantCulture); LineColor = (Color)colorConverter.ConvertFromInvariantString(reader.ReadElementString("Color")); reader.ReadEndElement(); } else { DrawLines = false; } if (reader.Name.Equals("Labels")) { DrawLabels = true; reader.ReadStartElement("Labels"); LabelColor = (Color)colorConverter.ConvertFromInvariantString(reader.ReadElementString("Color")); MaxLabelWidth = double.Parse(reader.ReadElementString("MaxWidth"), CultureInfo.InvariantCulture); MaxLabelHeight = double.Parse(reader.ReadElementString("MaxHeight"), CultureInfo.InvariantCulture); LabelDistance = double.Parse(reader.ReadElementString("Distance"), CultureInfo.InvariantCulture); LabelFormat.ReadXml(reader); reader.ReadEndElement(); } else { DrawLabels = false; } if (reader.Name.Equals("ClickType")) { reader.ReadStartElement("ClickType"); ClickType = (ClickType)Enum.Parse(typeof(ClickType), reader.ReadElementString("Type")); if (ClickType == Controls.ClickType.Swipe) { SwipeSensitivity = double.Parse(reader.ReadElementString("Sensitivity"), CultureInfo.InvariantCulture); } reader.ReadEndElement(); } else { ClickType = Controls.ClickType.Swipe; SwipeSensitivity = 0d; } try { bool mw; bool.TryParse(reader.ReadElementString("MouseWheel"), out mw); MouseWheelAction = mw; } catch { MouseWheelAction = true; } BeginTriggerBypass(true); CurrentPosition = DefaultPosition; EndTriggerBypass(true); }
public async Task <List <byte[]> > Labels_GetAsync(string consignmentnumber, LabelFormat format = LabelFormat.LABEL_PDF, bool rotate = false) { return(await Labels_GetAsync(new List <string>(new string[] { consignmentnumber }), format, rotate)); }
// Methods public void SetItems(bool isLoop, int id, ICollection <T> items, LabelFormat funcFormat, Action <int, int, T> onSelect, Action <int, int, T> onDelaySelect = null) { }
/// <summary> /// Draws the labels. /// </summary> /// <param name="context">Context.</param> /// <param name="pins">Pins.</param> /// <param name="xpos">Xpos.</param> /// <param name="ypos">Ypos.</param> /// <param name="labelposition">Labelposition.</param> /// <param name="labelformat">Labelformat.</param> /// <param name="bordtype">Bordtype.</param> public static void SetPinLabels(Cairo.Context context, List <IPin> pins, int xpos, int ypos, LabelPosition labelposition, LabelFormat labelformat = LabelFormat.Flat, BorderType bordtype = BorderType.Line) { int height = (labelformat == LabelFormat.Flat) ? FlatHeight : BoldHeight; for (int i = 0; i < pins.Count; i++) { DrawLabel(context, labelformat, bordtype, labelposition, pins [i], xpos, ypos + (i * height + i * Space)); } }
abstract protected void SetSubStrings(LabelFormat labelFormat);
private static int FillPdfPageWithLabels(PdfPage pdfPage, LabelFormat labelFormat, XFont xfont, Dictionary <int, EnvelopeAddress> labels, int lastLabelIdx) { string cellText; using (XGraphics graphicsDc = XGraphics.FromPdfPage(pdfPage, XGraphicsUnit.Inch)) { float left = labelFormat.LabelCell.Left; float top = labelFormat.LabelCell.Top; float bottom; float right; float cellWidth = labelFormat.LabelCell.Width; float cellHeight = labelFormat.LabelCell.Height; float columnSpacing = labelFormat.ColumnSpacing; int lablelIdx = lastLabelIdx; for (int j = 0; j < labelFormat.CellsCntPerVertical; j++) { if (lablelIdx > labels.Count) { break; } bottom = top + cellHeight; for (int k = 0; k < labelFormat.CellsCntPerHorizontal; k++) { EnvelopeAddress envelope; if (!labels.TryGetValue(lablelIdx++, out envelope)) { continue; } cellText = envelope.RecipientText; right = left + cellWidth; if (labelFormat.LabelCell.ShowMarkupLines) { PaintPdfCellLines(graphicsDc, left, right, top, bottom); } float rightMargin = labelFormat.LabelCell.LeftMargin; PdfCell newCell = new PdfCell() { Left = left, Top = top, Width = right - left - rightMargin, Height = bottom - top, LeftMargin = labelFormat.LabelCell.LeftMargin, TopMargin = labelFormat.LabelCell.TopMargin }; newCell.XFont = xfont; PaintPdfCellText(graphicsDc, cellText, newCell); left = right + columnSpacing; } top = bottom; left = labelFormat.LabelCell.Left; } return(lablelIdx); } }
private static void setAndCheckLabelContent(LabelFormat btFormat, PoolItem item) { #region 產生LabelFormat 打印參數數據 DatabaseConnections bcList = btFormat.DatabaseConnections; #region Check and Set Database connection if (bcList.Count > 0) { #region Check and Set TextFile Name var textFileList = bcList.Where(x => x.Type == InputDataFile.TextFile).ToList(); if (textFileList.Count > 0) { var nameList = textFileList.Select(x => x.Name).ToList(); if (item.TextFileValueList.Count == 0) { item.HasError = true; string errorMsg = string.Format(MissLableName, string.Join(",", nameList.ToArray()), "TextFile", item.BtwSrcFileName); throw new Exception(errorMsg); } else if (textFileList.Count == 1) // 單筆 { var textFileName = item.TextFileValueList.Where(x => x.Name == textFileList[0].Name).FirstOrDefault(); if (textFileName == null) { textFileName = item.TextFileValueList[0]; } TextFile file = (TextFile)textFileList[0]; file.FileName = item.ThreadFolder + textFileName.Name + ".txt"; } else { var textFileName = item.TextFileValueList.Select(x => x.Name).ToList(); var missingNameList = nameList.Except(textFileName).ToList(); if (missingNameList.Count > 0) { item.HasError = true; string errorMsg = string.Format(MissLableName, string.Join(",", missingNameList.ToArray()), "TextFile", item.BtwSrcFileName); throw new Exception(errorMsg); } foreach (TextFile file in textFileList) { file.FileName = item.TextFileValueList .Where(x => x.Name == file.Name) .Select(y => item.ThreadFolder + y.Name + ".txt") .FirstOrDefault(); } } } #endregion #region check and set SQLStatement in DB var OLEDBList = bcList.Where(x => x.Type == InputDataFile.OLEDB).ToList(); if (OLEDBList.Count > 0) { if (item.OLEDBValueList.Count > 0) { foreach (OLEDB db in OLEDBList) { string sentence = item.OLEDBValueList .Where(x => x.Name == db.Name) .Select(y => y.Value).FirstOrDefault(); if (!string.IsNullOrEmpty(sentence)) { db.SQLStatement = sentence; } } } } var ODBCList = bcList.Where(x => x.Type == InputDataFile.OLEDB).ToList(); if (ODBCList.Count > 0) { if (item.ODBCValueList.Count > 0) { foreach (ODBC db in ODBCList) { string sentence = item.ODBCValueList .Where(x => x.Name == db.Name) .Select(y => y.Value).FirstOrDefault(); if (!string.IsNullOrEmpty(sentence)) { db.SQLStatement = sentence; } } } } #endregion } #endregion SubStrings substringList = btFormat.SubStrings; #region Check and Set Named DataSource Name/Value if (substringList.Count > 0) { var lbNameList = substringList.Select(x => x.Name).ToList(); var dataValueList = item.NameValueList; if (dataValueList.Count > 0) { var dataNameList = dataValueList.Select(x => x.Name).ToList(); var missingNameList = lbNameList.Except(dataNameList).ToList(); if (missingNameList.Count > 0) { item.HasError = true; string errorMsg = string.Format(MissLableName, string.Join(",", missingNameList.ToArray()), "NamedDataSource", item.BtwSrcFileName); throw new Exception(errorMsg); } //Set Name & Value in label template foreach (SubString substring in substringList) { substring.Value = dataValueList.Where(x => x.Name == substring.Name).Select(y => y.Value).FirstOrDefault() ?? ""; } } else { item.HasError = true; string errorMsg = string.Format(MissLableName, string.Join(",", lbNameList.ToArray()), "NamedDataSource", item.BtwSrcFileName); throw new Exception(errorMsg); } } #endregion #endregion //btFormat.PrintSetup.PrinterName = ""; btFormat.PrintSetup.EnablePrompting = false; }
public ActionResult UpdateAttend(string data) { // Authenticate first if (!Auth()) { return(Message.createErrorReturn("Authentication failed, please try again", Message.API_ERROR_INVALID_CREDENTIALS)); } Message response = new Message(); Message message = Message.createFromString(data); AttendanceBundle bundle = JsonConvert.DeserializeObject <AttendanceBundle>(message.data); foreach (Attendance attendance in bundle.attendances) { foreach (AttendanceGroup group in attendance.groups) { CmsData.Attend.RecordAttend(CurrentDatabase, attendance.peopleID, group.groupID, group.present, group.datetime); CmsData.Attend attend = CurrentDatabase.Attends.FirstOrDefault(a => a.PeopleId == attendance.peopleID && a.OrganizationId == group.groupID && a.MeetingDate == group.datetime); if (attend == null) { continue; } if (group.present) { attend.SubGroupID = group.subgroupID; attend.SubGroupName = group.subgroupName; } else { attend.SubGroupID = 0; attend.SubGroupName = ""; } if (group.join) { JoinToOrg(attendance.peopleID, group.groupID); } } CurrentDatabase.SubmitChanges(); } if (message.device == Message.API_DEVICE_WEB) { string bundleData = SerializeJSON(bundle); var m = new CheckInModel(); m.SavePrintJob(message.kiosk, null, bundleData); response.setNoError(); response.count = 1; response.data = bundleData; return(response); } List <Label> labels = new List <Label>(); string securityCode = CurrentDatabase.NextSecurityCode().Select(c => c.Code).Single().Trim(); using (var db = new SqlConnection(Util.ConnectionString)) { Dictionary <int, LabelFormat> formats = LabelFormat.forSize(db, bundle.labelSize); foreach (Attendance attendance in bundle.attendances) { attendance.load(); attendance.labelSecurityCode = securityCode; labels.AddRange(attendance.getLabels(formats, bundle.securityLabels, bundle.guestLabels, bundle.locationLabels, bundle.nameTagAge)); } if (labels.Count > 0 && bundle.attendances.Count > 0 && bundle.securityLabels == Attendance.SECURITY_LABELS_PER_FAMILY) { labels.AddRange(bundle.attendances[0].getSecurityLabel(formats)); } } response.setNoError(); response.count = 1; response.data = SerializeJSON(labels); return(response); }
public Stream GeneratePdfLabels(List <string> Addresses, LabelFormat lf, int QtyEachLabel) { Stream generatePdfLabels = new MemoryStream(); // The label sheet is basically a table and each cell is a single label // Format related int CellsPerPage = lf.RowCount * lf.ColumnCount; int CellsThisPage = 0; //XRect ContentRectangle = new XRect(); // A single cell content rectangle. This is the rectangle that can be used for contents and accounts for margins and padding. XSize ContentSize = new XSize(); // Size of content area inside a cell. double ContentLeftPos; // left edge of current content area. double ContentTopPos; // Top edge of current content area // Layout related XColor StrokeColor = XColors.DarkBlue; XColor FillColor = XColors.DarkBlue; XPen Pen = new XPen(StrokeColor, 0.1); XBrush Brush = new XSolidBrush(FillColor); XGraphics Gfx; XGraphicsPath Path = new XGraphicsPath(); //int LoopTemp = 0; // Counts each itteration. Used with QtyEachLabel int CurrentColumn = 1; int CurrentRow = 1; PdfDocument Doc = new PdfDocument(); PdfPage page = new PdfPage(); //AddPage(Doc, page, lf); Doc.AddPage(page); Gfx = XGraphics.FromPdfPage(page); // Ensure that at least 1 of each label is printed. if (QtyEachLabel < 1) { QtyEachLabel = 1; } // Define the content area size ContentSize = new XSize(XUnit.FromMillimeter(lf.LabelWidth - lf.LabelPaddingLeft - lf.LabelPaddingRight).Point, XUnit.FromMillimeter(lf.LabelHeight - lf.LabelPaddingTop - lf.LabelPaddingBottom).Point); if (Addresses != null) { if (Addresses.Count > 0) // We actually have addresses to output. { WriteLine(); foreach (string Address in Addresses) { // Once for each address for (int LoopTemp = 0; LoopTemp < QtyEachLabel; LoopTemp++) // Once for each copy of this address. { WriteLine($"Obradjuje se : {Address} "); //WriteLine($"Nalepnica: {CellsThisPage} od :{CellsPerPage} "); if (CellsThisPage == CellsPerPage) { //AddPage(Doc, page, lf); //Gfx = XGraphics.FromPdfPage(page); page = Doc.AddPage(); Gfx = XGraphics.FromPdfPage(page); CellsThisPage = 0; } // This pages worth of cells are filled up. Create a new page // Calculate which row and column we are working on. CurrentColumn = (CellsThisPage + 1) % lf.ColumnCount; double a = (CellsThisPage + 1) / lf.ColumnCount; CurrentRow = (int)Math.Truncate(a); //WriteLine($"Tekuci red: {CurrentRow} tekuca kolona :{CurrentColumn} "); if (CurrentColumn == 0) { // This occurs when you are working on the last column of the row. // This affects the count for column and row CurrentColumn = lf.ColumnCount; } else { // We are not viewing the last column so this number will be decremented by one. CurrentRow = CurrentRow + 1; } // Calculate the left position of the current cell. ContentLeftPos = ((CurrentColumn - 1) * lf.HorizontalPitch) + lf.LeftMargin + lf.LabelPaddingLeft; // Calculate the top position of the current cell. ContentTopPos = ((CurrentRow - 1) * lf.VerticalPitch) + lf.TopMargin + lf.LabelPaddingTop; //WriteLine($"Leva pozicija: {ContentLeftPos} Pozicija od vrha :{ContentTopPos} Velicina sadrzaja : {ContentSize} "); // Define the content rectangle. XPoint xpoint1 = new XPoint(XUnit.FromMillimeter(ContentLeftPos).Point, XUnit.FromMillimeter(ContentTopPos).Point); XRect ContentRectangle = new XRect(xpoint1, ContentSize); Path = new XGraphicsPath(); // Add the address string to the page. Path.AddString(Address, new XFontFamily("Arial"), XFontStyle.Regular, 9, ContentRectangle, XStringFormats.TopLeft); Gfx.DrawPath(Pen, Brush, Path); // Increment the cell count CellsThisPage = CellsThisPage + 1; } } Doc.Save(generatePdfLabels, false); } } return(generatePdfLabels); }
protected override void SetSubStrings(LabelFormat labelFormat) { labelFormat.SubStrings.SetSubString("nrzlec_ilosc", orderNo + "-" + orderQuantity.ToString().PadLeft(3, '0')); }
private async Task <List <byte[]> > Labels_GetAsync(List <string> consignmentnumbers, LabelFormat format = LabelFormat.LABEL_PDF, bool rotate = false) { string querystring = string.Format("connote={0}&format={1}&rotate={2}", string.Join(",", consignmentnumbers.ToArray()), format, rotate); HttpResponseMessage response = await Common.GetHttpClient(API_TOKEN).GetAsync("api/labels?" + querystring); if (response.IsSuccessStatusCode) { return(response.Content.ReadAsAsync <List <byte[]> >().Result); } else { StringBuilder sb = new StringBuilder(); sb.AppendFormat("{0} ({1}) - {2}", (int)response.StatusCode, response.ReasonPhrase, response.Content.ReadAsStringAsync().Result); throw new HttpRequestException(sb.ToString()); } }
protected override void SetSubStrings(LabelFormat labelFormat) { labelFormat.SubStrings.SetSubString("Program_12NC", nc12); labelFormat.SubStrings.SetSubString("Program_Name", programName); }
/// <summary> /// Draws the label. /// </summary> /// <param name="context">Context.</param> /// <param name="format">Format.</param> /// <param name="bordertype">Bordertype.</param> /// <param name="labelposition">Labelposition.</param> /// <param name="pin">Pin.</param> /// <param name="xpos">Xpos.</param> /// <param name="ypos">Ypos.</param> public static void DrawLabel(Cairo.Context context, LabelFormat format, BorderType bordertype, LabelPosition labelposition, IPin pin, int xpos, int ypos) { switch (format) { case LabelFormat.Flat: DrawLabelFlat (context, bordertype, labelposition, pin, xpos, ypos); break; case LabelFormat.Bold: DrawLabel (context, bordertype, pin, xpos, ypos); break; } }
public void SaveLabelFormat(LabelFormat labelFormat) { _configRepo.SaveLabelFormat(labelFormat); }
private void GetPrinter(object sender, DoWorkEventArgs e) { PrintDocument pd = new PrintDocument(); string s = pd.PrinterSettings.PrinterName; if (!s.Equals(Form_main.printer)) return; try { Form_main.engine = new Seagull.BarTender.Print.Engine(true); _lf = new LabelFormat("d:/bartender/mylabel.btw"); _lf2 = new LabelFormat("d:/bartender/mylabel2.btw"); this.EnabledPrint = true; } catch (PrintEngineException) { this.EnabledPrint = false; } }
public bool Equals([AllowNull] Contours other) { if (other == null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return((Type == other.Type && Type != null && other.Type != null && Type.Equals(other.Type)) && (Start == other.Start && Start != null && other.Start != null && Start.Equals(other.Start)) && (End == other.End && End != null && other.End != null && End.Equals(other.End)) && (Size == other.Size && Size != null && other.Size != null && Size.Equals(other.Size)) && (Coloring == other.Coloring && Coloring != null && other.Coloring != null && Coloring.Equals(other.Coloring)) && (ShowLines == other.ShowLines && ShowLines != null && other.ShowLines != null && ShowLines.Equals(other.ShowLines)) && (ShowLabels == other.ShowLabels && ShowLabels != null && other.ShowLabels != null && ShowLabels.Equals(other.ShowLabels)) && (LabelFont == other.LabelFont && LabelFont != null && other.LabelFont != null && LabelFont.Equals(other.LabelFont)) && (LabelFormat == other.LabelFormat && LabelFormat != null && other.LabelFormat != null && LabelFormat.Equals(other.LabelFormat)) && (Operation == other.Operation && Operation != null && other.Operation != null && Operation.Equals(other.Operation)) && (Value == other.Value && Value != null && other.Value != null && Value.Equals(other.Value))); }