public override int GetHashCode() { int hash = 1; if (Major != 0L) { hash ^= Major.GetHashCode(); } if (Minor != 0L) { hash ^= Minor.GetHashCode(); } if (Patch.Length != 0) { hash ^= Patch.GetHashCode(); } if (LabelTemplate.Length != 0) { hash ^= LabelTemplate.GetHashCode(); } if (releaseBranch_ != null) { hash ^= ReleaseBranch.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public override void LoadChildNodes() { // try { //Clear existing child nodes (label templates) base.Nodes.Clear(); //Create label template objects (inherit from TreeNode); add to node array base.mChildNodes = new TreeNode[this.mLabelStore.Labels.LabelDetailTable.Rows.Count]; for (int i = 0; i < this.mLabelStore.Labels.LabelDetailTable.Rows.Count; i++) { LabelTemplate template = null; try { template = this.mLabelStore.NewLabelTemplate((LabelDS.LabelDetailTableRow) this.mLabelStore.Labels.LabelDetailTable.Rows[i]); LabelTemplateNode node = new LabelTemplateNode(template.LabelType + " (" + template.PrinterType + ")", App.ICON_APP, App.ICON_APP, template); base.mChildNodes[i] = node; base.Nodes.Add(node); //Cascade loading child nodes if this node is expanded (to get the + sign) if (base.IsExpanded) { node.LoadChildNodes(); } } catch (Exception) { MessageBox.Show("Error on label template loading; continuing..."); } } } catch (Exception ex) { throw new ApplicationException("Failed to load all child nodes for label store " + base.Text + ".", ex); } }
public String GetReplacedTemplateForLabels(IList <Label> labelList, LabelTemplate template, string printLot) { string result = ""; //Obteniendo el listado de TAGS que se deben reemplazar en el template IList <LabelMapping> labelmappings = Factory.DaoLabelMapping().Select( new LabelMapping { LabelType = template.LabelType }); //Reemplazando el Header if (template.PLHeader != null) { result += ReplaceTemplate(labelmappings, template.PLHeader, labelList[0]) + Environment.NewLine; } //Reemplazando el Body if (template.PLTemplate != null) { foreach (Label label in labelList) { result += ReplaceTemplate(labelmappings, template.PLTemplate, label) + Environment.NewLine; } } return(result); }
internal void ApplyOutboundLabel() { //Complete label processing (determine final label format) for this sorted item try { if (this.IsError()) { this.mLabelTemplate = ErrorLabelTemplate; } //Bypass LabelMaker FormatTemplate() method so Panda tokens remain to be replaced by PandaSvc //this.mLabelFormat = base.FormatTemplate(this.mLabelTemplate.Template); this.mLabelFormat = this.mLabelTemplate.Template; setTokenValues(); foreach (System.Collections.DictionaryEntry token in base.mTokens) { if (token.Key.ToString() != TokenLibrary.STATUSCODE) { this.mLabelFormat = this.mLabelFormat.Replace(token.Key.ToString(), token.Value.ToString()); } } } catch (Exception ex) { if (!this.IsError()) { // sorted item is not in error - problem generating regular label this.mException = new OutboundLabelException(ex); this.ApplyOutboundLabel(); //recursive call } else { // error generating error label this.mException = new ErrorLabelException(ex); this.mLabelFormat = ErrorLabelTemplate.Template; // asssign string without substituting } } }
private static void Export(LocalReport report, LabelTemplate template, string renderFormat) { //renderFormat = "IMAGE", "PDF", string deviceInfo = template.Body; Warning[] warnings; //m_streams = new List<Stream>(); try { report.Render(renderFormat, deviceInfo, CreateStream, out warnings); foreach (Stream stream in m_streams[curTemplate]) { stream.Position = 0; } } catch (Exception ex) { string exMessage = WriteLog.GetTechMessage(ex); //throw new Exception(exMessage); } }
public static void PrintDocument(Document document, Printer printer) { if (document.DocType.Template == null) { return; } try { //Inicializando variables usadas en la impresion //if (m_streams == null) m_streams = new Dictionary <LabelTemplate, IList <Stream> >(); //if (m_currentPageIndex == null) m_currentPageIndex = new Dictionary <LabelTemplate, int>(); curTemplate = document.DocType.Template; usePrinter = printer; //Ejecutar la impresion global en un Hilo Thread th = new Thread(new ParameterizedThreadStart(PrintDocumentThread)); th.Start(document); } catch (Exception ex) { Util.ShowError("Report could not shown: " + ex.Message); } }
private void OnPrintLabels(object sender, EventArgs e) { SelectedPrinter = (Printer)View.PrinterList.SelectedItem; //if (View.Model.LabelsToPrint == null || View.Model.LabelsToPrint.Count == 0) if (View.ToPrintLabels.SelectedItems == null) { Util.ShowError("No labels selected to print."); return; } ProcessWindow pw = new ProcessWindow("Printing Labels ..."); try { //Setea el template si lo escogio. LabelTemplate tplFile = View.PrintTemplate.SelectedItem != null ? ((LabelTemplate)View.PrintTemplate.SelectedItem) : null; //Si el template es Null Trata de setear el Template De receiving if (!string.IsNullOrEmpty(Util.GetConfigOption("RECVTPL")) && tplFile == null) { try { tplFile = service.GetLabelTemplate( new LabelTemplate { RowID = int.Parse(Util.GetConfigOption("RECVTPL")) }).First(); } catch { } } //Send Labels to Print. List <WpfFront.WMSBusinessService.Label> lblToPrint = new List <WpfFront.WMSBusinessService.Label>(); foreach (object lbl in View.ToPrintLabels.SelectedItems) { lblToPrint.Add((WpfFront.WMSBusinessService.Label)lbl); } if (tplFile.IsPL == true) { service.PrintLabelsFromDevice(WmsSetupValues.DEFAULT, tplFile.Header, lblToPrint); //View.Model.LabelsToPrint.ToList() } else { ReportMngr.PrintLabelsInBatch(tplFile, SelectedPrinter, lblToPrint); //View.Model.LabelsToPrint } ResetForm(); pw.Close(); Util.ShowMessage("Process Completed."); return; } catch (Exception ex) { pw.Close(); Util.ShowError("Error printing labels.\n" + ex.Message); } }
static void Main(string[] args) { try { ReadyLabelDriver driver = new ReadyLabelDriver(); driver.InitializeDriver("localhost", 5300); LabelTemplate templates = driver.GetTemplates().FirstOrDefault(); if (templates != null) { // initialize egecko instrument Console.WriteLine("Initializing instrument"); driver.EGeckoInitializeInstrument(); Console.WriteLine("Instrument Initialized"); // test rotations Console.WriteLine("Rotating stage to 90"); driver.EGeckoRotateStage(90, "absolute"); Console.WriteLine("Rotating stage to 180"); driver.EGeckoRotateStage(180, "absolute"); Console.WriteLine("Rotating stage to 0"); driver.EGeckoRotateStage(0, "absolute"); Console.WriteLine("Printing label template at" + templates.FilePath); Dictionary <string, bool> printSides = new Dictionary <string, bool>() { { "North", true }, { "South", false }, { "East", true }, { "West", false } }; Dictionary <string, string> data = new Dictionary <string, string>() { { "VAR", "TEST DATA" }, }; // test print and apply driver.EGeckoPrint(templates.FilePath, printSides, data, 0, 0, 0, false); Console.WriteLine("EGecko test completed"); } else { Console.WriteLine("No label templates found."); } } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.ReadLine(); }
//Interface public LabelTemplateNode(string text, int imageIndex, int selectedImageIndex, LabelTemplate labelTemplate) : base(text, imageIndex, selectedImageIndex) { //Constructor try { this.mLabelTemplate = labelTemplate; } catch (Exception ex) { throw new ApplicationException("Unexpected error while creating new Label Template Node instance.", ex); } }
public MainWindow() { InitializeComponent(); LabelTemplate labelTemplateConverter = new LabelTemplate(); Binding binding = new Binding("Item.Items"); binding.Converter = labelTemplateConverter; txtBlock.SetBinding(TextBlock.TextProperty, binding); }
public IList <LabelTemplate> Select(LabelTemplate data) { IList <LabelTemplate> datos = new List <LabelTemplate>(); datos = GetHsql(data).List <LabelTemplate>(); if (!Factory.IsTransactional) { Factory.Commit(); } return(datos); }
public override IQuery GetHsql(object data) { StringBuilder sql = new StringBuilder("select a from LabelTemplate a where "); LabelTemplate printingTemplate = (LabelTemplate)data; if (printingTemplate != null) { Parms = new List <Object[]>(); if (printingTemplate.RowID != 0) { sql.Append(" a.RowID = :id and "); Parms.Add(new Object[] { "id", printingTemplate.RowID }); } if (printingTemplate.LabelType != null && printingTemplate.LabelType.DocTypeID != 0) { sql.Append(" a.LabelType.DocTypeID = :id1 and "); Parms.Add(new Object[] { "id1", printingTemplate.LabelType.DocTypeID }); } if (printingTemplate.LabelType != null && printingTemplate.LabelType.DocClass != null && printingTemplate.LabelType.DocClass.DocClassID != 0) { sql.Append(" a.LabelType.DocClass.DocClassID = :id8 and "); Parms.Add(new Object[] { "id8", printingTemplate.LabelType.DocClass.DocClassID }); } if (!String.IsNullOrEmpty(printingTemplate.Name)) { sql.Append(" a.Name = :nom and "); Parms.Add(new Object[] { "nom", printingTemplate.Name }); } if (!String.IsNullOrEmpty(printingTemplate.Header)) { sql.Append(" a.Header = :nom1 and "); Parms.Add(new Object[] { "nom1", printingTemplate.Header }); } if (printingTemplate.DefPrinter != null && printingTemplate.DefPrinter.ConnectionID != 0) { sql.Append(" a.DefPrinter.ConnectionID = :ip8 and "); Parms.Add(new Object[] { "ip8", printingTemplate.DefPrinter.ConnectionID }); } } sql = new StringBuilder(sql.ToString()); sql.Append(" 1=1 order by a.RowID asc "); IQuery query = Factory.Session.CreateQuery(sql.ToString()); SetParameters(query); return(query); }
//Imprime en impresora mandando la lineas de comando PCL private static void PrintLabelByPL(LabelTemplate template, IList <Label> listLabels, Printer printer) { LabelMngr lblMngr = new LabelMngr(); string templateReplaced = lblMngr.GetReplacedTemplateForLabels(listLabels, template, ""); if (string.IsNullOrEmpty(templateReplaced)) { //throw new Exception("Error creating Printer Template."); ExceptionMngr.WriteEvent("Error creating Printer Template. " + template.Header, ListValues.EventType.Fatal, null, null, ListValues.ErrorCategory.Printer); } PrintLabels(templateReplaced, printer.PrinterPath); }
//Imprime en impresora mandando la lineas de comando PCL private static void PrintLabelByPL(LabelTemplate template, IList <Label> listLabels, Printer printer) { string templateReplaced = (new WMSServiceClient()) .GetReplacedTemplateForLabels(listLabels, template, ""); if (string.IsNullOrEmpty(templateReplaced)) { Util.ShowError("Error creating Printer Template."); return; } PrinterControl.PrintLabels(templateReplaced, printer.PrinterPath); }
public override void New() { //Create a new label template try { LabelTemplate template = this.mLabelStore.NewLabelTemplate(); dlgLabelTemplate dlg = new dlgLabelTemplate(template); if (dlg.ShowDialog() == DialogResult.OK) { this.mLabelStore.Labels.LabelDetailTable.AddLabelDetailTableRow(template.LabelType, template.PrinterType, template.LabelString); LoadChildNodes(); } } catch (Exception ex) { throw new ApplicationException("Failed to create a new label template for label store " + base.Text + ".", ex); } }
public void UpdateLabel() { //Update the label due to changes in the label template or labelmaker try { //Create a copy of the current label template and set the format to textbox text //This way, the label reflects the unsaved template changes LabelTemplate oLabelTemplate = this.mLabelTemplateNode.LabelTemplate.Copy(); oLabelTemplate.LabelString = this.txtTemplate.Text; this.mLabel = new Tsort.Labels.Label(oLabelTemplate, this.mLabelMaker); this.lblLabel.Text = "Format: (" + this.mLabelMaker.Name + ")"; this.txtLabel.Text = this.mLabel.LabelFormat; this.lblLabelSize.Text = this.txtLabel.Text.Length.ToString() + " chars"; } catch (Exception ex) { MessageBox.Show(this, ex.Message); } }
public override int GetHashCode() { int hash = 1; if (Range.Length != 0) { hash ^= Range.GetHashCode(); } hash ^= unitKey_.GetHashCode(); if (Height != 0D) { hash ^= Height.GetHashCode(); } if (Label.Length != 0) { hash ^= Label.GetHashCode(); } if (CustomLabel.Length != 0) { hash ^= CustomLabel.GetHashCode(); } if (LinkTemplate.Length != 0) { hash ^= LinkTemplate.GetHashCode(); } if (LabelTemplate.Length != 0) { hash ^= LabelTemplate.GetHashCode(); } if (Rangemax != 0D) { hash ^= Rangemax.GetHashCode(); } if (Rangemin != 0D) { hash ^= Rangemin.GetHashCode(); } hash ^= Metadata.GetHashCode(); if (ShowKey != false) { hash ^= ShowKey.GetHashCode(); } return(hash); }
/// <summary> /// Crea un numero de labels definido para el numero de paquetes recibidos de un PO /// Envia el mail de notificacion. /// </summary> /// <param name="document"></param> /// <param name="numLabels"></param> /// <param name="sysUser"></param> public void ReceiptAcknowledge(Document document, double numLabels, SysUser sysUser, string appPath) { //Crear el documento de Mail para enviar el Mensaje. SendProcessNotification(sysUser, document, BasicProcess.ReceiptAcknowledge); //Cambiar las fechas de arrive del PO que llego document.Date5 = DateTime.Now; Factory.DaoDocument().Update(document); //Manadar a Imprimir los N Labels de Acknolegement. if (string.IsNullOrEmpty(appPath)) { appPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), WmsSetupValues.WebServer); } LabelTemplate template = Factory.DaoLabelTemplate().Select(new LabelTemplate { Header = WmsSetupValues.DefTpl_DocumentLabel }).First(); IList <Label> labelsToPrintX = new List <Label>(); for (int z = 1; z <= (int)numLabels; z += 1) { labelsToPrintX.Add( new Label { LabelCode = document.DocNumber, LabelType = new DocumentType { DocTypeID = LabelType.CustomerLabel }, CurrQty = z, StartQty = numLabels, CreatedBy = sysUser.UserName }); } ReportMngr.PrintLabelsFromFacade(new Printer { PrinterName = WmsSetupValues.DEFAULT }, template, labelsToPrintX, appPath); }
private static void Export(LocalReport report, LabelTemplate template, string renderFormat) { //docType => 1 - Document, 2 - labels string deviceInfo = ""; deviceInfo = template.Body; //if (docType == 1) //{ // deviceInfo = "<DeviceInfo>" + // " <OutputFormat>EMF</OutputFormat>" + // " <PageWidth>8.5in</PageWidth>" + // " <PageHeight>11in</PageHeight>" + // " <MarginTop>0.25in</MarginTop>" + // " <MarginLeft>0.25in</MarginLeft>" + // " <MarginRight>0.25in</MarginRight>" + // " <MarginBottom>0.25in</MarginBottom>" + // "</DeviceInfo>"; //} //else if (docType == 2) //{ // deviceInfo = "<DeviceInfo>" + // " <OutputFormat>EMF</OutputFormat>" + // " <PageWidth>4.1in</PageWidth>" + // " <PageHeight>6.2in</PageHeight>" + // " <MarginTop>0in</MarginTop>" + // " <MarginLeft>0in</MarginLeft>" + // " <MarginRight>0in</MarginRight>" + // " <MarginBottom>0in</MarginBottom>" + // "</DeviceInfo>"; //} Warning[] warnings; //m_streams = new List<Stream>(); report.Render(renderFormat, deviceInfo, CreateStream, out warnings); foreach (Stream stream in m_streams[curTemplate]) { stream.Position = 0; } }
internal static void PrintShipmentPackLabels(Document shipment) { if (shipment == null || shipment.DocID == 0) { Util.ShowError("Shipment must be created before reprint all Labels."); return; } //Open View Packages LabelTemplate template = null; try { template = (new WMSServiceClient()).GetLabelTemplate(new LabelTemplate { Header = WmsSetupValues.DefaultPackLabelTemplate }).First(); } catch { Util.ShowError("No packing label defined."); return; } ProcessWindow pw = new ProcessWindow("Printing Labels ... "); int x = 0; try { x = (new WMSServiceClient()).PrintPackageLabels(shipment); } catch (Exception ex) { pw.Close(); Util.ShowError("Error: " + ex.Message); } pw.Close(); }
private MessagePool GenerateMessage(IList <LabelMapping> labelMap, LabelTemplate templateData, Object obj) { //Header - Subject string subject = templateData.Header; string body = templateData.Body; for (int i = 0; i < labelMap.Count; i++) { subject = subject.Replace(labelMap[i].DataKey, GetMapPropertyValue(labelMap[i].DataValue, obj)); body = body.Replace(labelMap[i].DataKey, GetMapPropertyValue(labelMap[i].DataValue, obj).Replace("\n", "<br>")); //Para fit in html } return(new MessagePool { Message = body, Subject = subject, CreationDate = DateTime.Now, CreatedBy = WmsSetupValues.SystemUser }); }
/// <summary> /// Factory method for <see cref="FrameworkElement"/> creation. /// </summary> /// <param name="state">Item state.</param> /// <returns>New element.</returns> FrameworkElement CreateElement(ItemState state) { var fe = default(FrameworkElement); if (LabelTemplate != null) { fe = LabelTemplate.LoadContent() as FrameworkElement; } else if (Theme.TextBlockTemplate != null) { fe = Theme.TextBlockTemplate.LoadContent() as TextBlock; if (LabelStyle != null) { BindTo(this, nameof(LabelStyle), fe, FrameworkElement.StyleProperty); } } if (fe != null) { fe.SizeChanged += Element_SizeChanged; } return(fe); }
//Process the lines to Print - OBSOLETE public String GetReplacedTemplate(IList <DocumentBalance> printList, LabelTemplate template, string printLot, UserByRol userByRol) { Factory.IsTransactional = true; string result = ""; Node node = WType.GetNode(new Node { NodeID = NodeType.PreLabeled }); Bin bin = WType.GetBin(new Bin { BinCode = DefaultBin.MAIN, Location = userByRol.Location }); try { foreach (DocumentBalance printLine in printList) { result += ProcessPrintingLine(printLine, template, printLot, node, bin, userByRol); if (template.PrintEmptyLabel == true) { result += template.Empty; } } Factory.Commit(); } catch (Exception ex) { Factory.Rollback(); ExceptionMngr.WriteEvent("GetReplacedTemplate:", ListValues.EventType.Fatal, ex, null, ListValues.ErrorCategory.ErpConnection); throw new Exception(WriteLog.GetTechMessage(ex)); } return(result); }
private static void PrintLabelByTemplate(LabelTemplate template, List <Label> listOfLabels) { if (listOfLabels == null || listOfLabels.Count == 0) { return; } listLabels = listOfLabels; try { //Si viene una impresora definida utiliza esa, si no utiliza la del template if (template != null) { curTemplate = template; } else { curTemplate = (new WMSProcessClient()).GetLabelTemplate(new LabelTemplate { Header = WmsSetupValues.ProductLabelTemplate }).First(); } usePrinter = usePrinter == null ? new Printer { PrinterName = curTemplate.DefPrinter.Name, PrinterPath = curTemplate.DefPrinter.CnnString } : usePrinter; } catch { throw new Exception("Printer not defined for template " + curTemplate.Name); } if (usePrinter == null) { throw new Exception("Printer not defined for template " + curTemplate.Name); } //Revisa si el label imprime por comandos y lo manda a esa ruta. if (template.IsPL == true) { PrintLabelByPL(template, listOfLabels, usePrinter); return; } try { string labelPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), WmsSetupValues.RdlTemplateDir + "\\" + template.Header); if (!File.Exists(labelPath)) { throw new Exception("Label template " + template.Header + " does not exists.\n"); } //Definicion de Reporte localReport = new LocalReport(); localReport.EnableExternalImages = true; localReport.ExecuteReportInCurrentAppDomain(System.Reflection.Assembly.GetExecutingAssembly().Evidence); localReport.AddTrustedCodeModuleInCurrentAppDomain("Barcode, Version=1.0.5.40001, Culture=neutral, PublicKeyToken=6dc438ab78a525b3"); localReport.AddTrustedCodeModuleInCurrentAppDomain("System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"); localReport.EnableExternalImages = true; localReport.ReportPath = labelPath; DataSet ds = ProcessLabels(listOfLabels); localReport.DataSources.Add(new ReportDataSource("Details", ds.Tables["Details"])); //Proceso de Creacion de archivos curTemplate = template; m_streams.Add(curTemplate, new List <Stream>()); m_currentPageIndex.Add(curTemplate, 0); Export(localReport, curTemplate, "IMAGE"); //1 - Document, 2 - Label m_currentPageIndex[curTemplate] = 0; Thread th = new Thread(new ParameterizedThreadStart(Print)); th.Start(usePrinter.PrinterName); //Print(usePrinter.PrinterName); } catch (Exception ex) { throw new Exception(ex.Message); } }
//Imprime en impresora mandando la lineas de comando PCL private static void PrintLabelByPL(LabelTemplate template, IList<Label> listLabels, Printer printer) { string templateReplaced = (new WMSServiceClient()) .GetReplacedTemplateForLabels(listLabels, template, ""); if (string.IsNullOrEmpty(templateReplaced)) { Util.ShowError("Error creating Printer Template."); return; } PrinterControl.PrintLabels(templateReplaced, printer.PrinterPath); }
public static void PrintLabelsFromFacade(Printer printer, LabelTemplate defTemplate, IList <Label> listOfLabels, string appPath) { usePrinter = null; if (listOfLabels == null || listOfLabels.Count == 0) { return; } //if (string.IsNullOrEmpty(printer)) //throw new Exception("Printer not found"); if (printer != null && printer.PrinterName != WmsSetupValues.DEFAULT) { usePrinter = printer; } AppPath = appPath; m_streams = new Dictionary <LabelTemplate, IList <Stream> >(); m_currentPageIndex = new Dictionary <LabelTemplate, int>(); //1. Si viene un template imprime los labes con ese template if (defTemplate != null) { try { if (listOfLabels[0].LabelType.DocTypeID == LabelType.ProductLabel) { PrintLabelByTemplate(defTemplate, listOfLabels.Where(f => f.Product.PrintLabel != false).ToList()); } else { PrintLabelByTemplate(defTemplate, listOfLabels); } UpdateLabelPrintStatus(); return; } catch { throw; } } //Agrupa a los diferentes tipos de label y a los null y los manda por aparte. //Filtra los que no imprime label (double check) IList <LabelTemplate> templateList = new List <LabelTemplate>(); //Si el lable es de producto busca las templates del producto. if (listOfLabels[0].LabelType.DocTypeID == LabelType.ProductLabel) { templateList = listOfLabels.Where(f => f.Product.DefaultTemplate != null) .Select(f => f.Product.DefaultTemplate).Distinct().ToList(); } string error = ""; //Para cada template mandando la impresion foreach (LabelTemplate template in templateList) { try { if (listOfLabels[0].LabelType.DocTypeID == LabelType.ProductLabel) { PrintLabelByTemplate(template, listOfLabels.Where(f => f.Product.DefaultTemplate.RowID == template.RowID && f.Product.PrintLabel != false) .ToList()); } else { PrintLabelByTemplate(template, listOfLabels); } UpdateLabelPrintStatus(); //tl = new Thread(new ThreadStart(UpdateLabelPrintStatus)); //tl.Start(); } catch (Exception ex) { error += ex.Message; } } //Mandando las labels con template en Null try { defTemplate = (new DaoFactory()).DaoLabelTemplate().Select(new LabelTemplate { Header = WmsSetupValues.DefaultLabelTemplate }).First(); List <Label> labelsWoTemplate = null; if (listOfLabels[0].LabelType.DocTypeID == LabelType.ProductLabel) { labelsWoTemplate = listOfLabels.Where(f => f.Product.DefaultTemplate == null && f.Product.PrintLabel != false).ToList(); } else { labelsWoTemplate = listOfLabels.ToList(); } PrintLabelByTemplate(defTemplate, labelsWoTemplate); //tl = new Thread(new ThreadStart(UpdateLabelPrintStatus)); //tl.Start(); UpdateLabelPrintStatus(); } catch (Exception ex) { error += ex.Message; } //Final Error if (!string.IsNullOrEmpty(error)) { throw new Exception(error); } }
public ViewDocument(LabelTemplate report, int docID, string printer, bool showBtnPrint, IList<WpfFront.WMSBusinessService.Label> list) { if (report == null) { Util.ShowError("Report could not be found."); return; } InitializeComponent(); printerName = printer; documentID = docID; labelList = list; #region Windows Form Host //if (showBtnPrint) // btnPrintBatch.Visibility = Visibility.Visible; //else // btnPrintBatch.Visibility = Visibility.Collapsed; //Create a Windows Forms Host to host a form WindowsFormsHost host = new WindowsFormsHost(); //Report ddimensions host.HorizontalAlignment = HorizontalAlignment.Stretch; host.VerticalAlignment = VerticalAlignment.Stretch; //pivotView.Width = 900; //pivotView.Height = 700; pivotView.Margin = new System.Windows.Forms.Padding { All = 5 }; //Add the component to the host host.Child = pivotView; gridP.Children.Add(host); #endregion try { //Report File exists string reportPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), WmsSetupValues.RdlTemplateDir + "\\" + report.Header); if (!File.Exists(reportPath)) { Util.ShowError("Report file does not exists."); return; } //Rendering Report this.pivotView.ProcessingMode = ProcessingMode.Local; this.pivotView.LocalReport.ReportPath = reportPath; this.pivotView.LocalReport.EnableExternalImages = true; this.pivotView.LocalReport.ExecuteReportInCurrentAppDomain(System.Reflection.Assembly.GetExecutingAssembly().Evidence); this.pivotView.LocalReport.AddTrustedCodeModuleInCurrentAppDomain("Barcode, Version=1.0.5.40001, Culture=neutral, PublicKeyToken=6dc438ab78a525b3"); this.pivotView.LocalReport.AddTrustedCodeModuleInCurrentAppDomain("System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"); DataSet ds; //Document if (documentID > 0) { ds = ReportMngr.ProcessDocument(documentID, service, report.Header); if (ds == null) return; pivotView.LocalReport.DataSources.Add(new ReportDataSource("Header", ds.Tables["ReportHeaderFormat"])); pivotView.LocalReport.DataSources.Add(new ReportDataSource("Details", ds.Tables["ReportDetailFormat"])); } //Labels else if (report.LabelType.DocClass.DocClassID == SDocClass.Label) { ds = ReportMngr.ProcessLabels(labelList); pivotView.LocalReport.DataSources.Add(new ReportDataSource("Details", ds.Tables["Details"])); } /* // CAA [2010/06/22] // Nueva opción para enviar parámetros al reporte if (parameters != null) { ReportParameter rp; ReportParameter[] rpList= new ReportParameter[parameters.Count()]; int cont = 1; foreach (string parameter in parameters) { rp = new ReportParameter("p"+cont.ToString(), parameter); rpList[cont-1] = rp; cont++; } pivotView.LocalReport.SetParameters(rpList); } */ //Showing pivotView.Show(); pivotView.LocalReport.Refresh(); pivotView.RefreshReport(); } catch (Exception ex) { Util.ShowError("Report could not shown: " + ex.Message); } }
public int PrintPackageLabels(Document shipment, string printer, string appPath, string labelcode) { IList <Label> labelsToPrint = null; LabelTemplate defTemplate = null; if (shipment != null && shipment.DocID != 0) { labelsToPrint = Factory.DaoDocumentPackage().Select( new DocumentPackage { PostingDocument = shipment } ).Select(f => f.PackLabel).ToList(); try { defTemplate = Factory.DaoLabelTemplate().Select( new LabelTemplate { Header = WmsSetupValues.DefaultPackLabelTemplate }).First(); } catch { } } else if (!string.IsNullOrEmpty(labelcode)) { labelsToPrint = Factory.DaoDocumentPackage().Select( new DocumentPackage { PackLabel = new Label { LabelCode = labelcode } } ).Select(f => f.PackLabel).ToList(); try { if (labelsToPrint[0].Package.PackageType == "P" || labelsToPrint[0].Package.Level == 0) // || labelsToPrint[0].Package.ParentPackage == null { defTemplate = Factory.DaoLabelTemplate().Select( new LabelTemplate { Header = WmsSetupValues.DefaultPalletTemplate }).First(); } else if (labelsToPrint[0].Package.PackageType == "B") { defTemplate = Factory.DaoLabelTemplate().Select( new LabelTemplate { Header = WmsSetupValues.DefaultPackLabelTemplate }).First(); } } catch { } } if (labelsToPrint == null || labelsToPrint.Count == 0) { return(0); } Printer objPrinter = null; //Printer - Default for the Template objPrinter = new Printer { PrinterName = WmsSetupValues.DEFAULT }; ReportMngr.PrintLabelsFromFacade(objPrinter, defTemplate, labelsToPrint, appPath); return(labelsToPrint.Count); }
public static void ShowDocument(LabelTemplate rptCode, int docID, string printer, bool showBtnPrint) { ViewDocument fv = new ViewDocument(rptCode, docID, printer, showBtnPrint, null); fv.Show(); }
public static void ShowLabelsToPrint(LabelTemplate rptCode, bool showBtnPrint, IList<Label> labelList) { ViewDocument fv = new ViewDocument(rptCode, 0, null, showBtnPrint, labelList); fv.Show(); }
private static void Export(LocalReport report, LabelTemplate template, string renderFormat) { //docType => 1 - Document, 2 - labels string deviceInfo = ""; deviceInfo = template.Body; //if (docType == 1) //{ // deviceInfo = "<DeviceInfo>" + // " <OutputFormat>EMF</OutputFormat>" + // " <PageWidth>8.5in</PageWidth>" + // " <PageHeight>11in</PageHeight>" + // " <MarginTop>0.25in</MarginTop>" + // " <MarginLeft>0.25in</MarginLeft>" + // " <MarginRight>0.25in</MarginRight>" + // " <MarginBottom>0.25in</MarginBottom>" + // "</DeviceInfo>"; //} //else if (docType == 2) //{ // deviceInfo = "<DeviceInfo>" + // " <OutputFormat>EMF</OutputFormat>" + // " <PageWidth>4.1in</PageWidth>" + // " <PageHeight>6.2in</PageHeight>" + // " <MarginTop>0in</MarginTop>" + // " <MarginLeft>0in</MarginLeft>" + // " <MarginRight>0in</MarginRight>" + // " <MarginBottom>0in</MarginBottom>" + // "</DeviceInfo>"; //} Warning[] warnings; //m_streams = new List<Stream>(); report.Render(renderFormat, deviceInfo, CreateStream, out warnings); foreach (Stream stream in m_streams[curTemplate]) stream.Position = 0; }
public async Task <System.Net.Http.HttpResponseMessage> GenerateExcelPreview(int materialLotID) { Contract.Ensures(Contract.Result <Task <HttpResponseMessage> >() != null); // get print property entities var printPropertyEntities = await this.GetNamedEntities(cPrintPropertiesEntityName); if (printPropertyEntities == null) { return(this.Request.CreateResponse(HttpStatusCode.NotFound)); } Type printPropertyType = printPropertyEntities.GetType().GetGenericArguments()[0]; //Type relevantType = null; //DbContext.TryGetRelevantType(cPrintPropertiesEntityName, out relevantType); var expressionPP = Expression <DynamicEntity, int>(printPropertyType.GetProperty("MaterialLotID"), materialLotID); var materialLotPPEntities = Where(printPropertyEntities, expressionPP, printPropertyType); // get print file entities var printFileEntities = await this.GetNamedEntities(cPrintFileEntityName); if (printFileEntities == null) { return(this.Request.CreateResponse(HttpStatusCode.NotFound)); } //if (((IQueryable<DynamicEntity>)printFileEntities).Count() == 0) // return this.Request.CreateResponse(HttpStatusCode.NotFound); Type printFileType = printFileEntities.GetType().GetGenericArguments()[0]; var expressionPF = Expression <DynamicEntity, int>(printFileType.GetProperty("MaterialLotID"), materialLotID); var materialLotPFEntities = Where(printFileEntities, expressionPF, printFileType); if (((IQueryable <DynamicEntity>)materialLotPFEntities).Count() == 0) { return(this.Request.CreateResponse(HttpStatusCode.NotFound)); } // get the media resource stream from the entity DynamicEntity printFileObj = ((IQueryable <DynamicEntity>)materialLotPFEntities).First(); var dataPropInfo = printFileObj.GetType().GetProperty("Data"); if (!(dataPropInfo.GetValue(printFileObj) is byte[] templateBytes)) { return(this.Request.CreateResponse(HttpStatusCode.NotFound)); } string fileSaveLocation = Path.GetTempFileName(); File.WriteAllBytes(fileSaveLocation, templateBytes); #region Excel Work List <PrintPropertiesValue> printPropertyValues = new List <PrintPropertiesValue>(); foreach (var item in materialLotPPEntities) { var typeProperty = item.GetType().GetProperty("TypeProperty"); var codeProperty = item.GetType().GetProperty("PropertyCode"); var valueProperty = item.GetType().GetProperty("Value"); string typePropertyValue = typeProperty.GetValue(item) as string; string codePropertyValue = codeProperty.GetValue(item) as string; string valuePropertyValue = valueProperty.GetValue(item) as string; PrintPropertiesValue printPropertiesValue = new PrintPropertiesValue { TypeProperty = typePropertyValue, PropertyCode = codePropertyValue, Value = valuePropertyValue }; printPropertyValues.Add(printPropertiesValue); } LabelTemplate labelTemplate = new LabelTemplate(fileSaveLocation); labelTemplate.FillParamValues(printPropertyValues); #endregion #region PNG Generation var namePropInfo = printFileObj.GetType().GetProperty("Name"); var nameValue = namePropInfo.GetValue(printFileObj) as string; string outputFileName = Path.Combine(Path.GetTempPath(), nameValue + ".png"); try { //ConvertToPngAspose(fileSaveLocation, outputFileName); xlsConverter.Program.ConvertNoRotate(fileSaveLocation, outputFileName); } catch (Exception exception) { DynamicLogger.Instance.WriteLoggerLogError("GenerateExcelPreview (materialLotID=" + materialLotID + ")", exception); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exception)); } if (File.Exists(fileSaveLocation)) { File.Delete(fileSaveLocation); } #endregion var bytes = File.ReadAllBytes(outputFileName); File.Delete(outputFileName); var stream = new MemoryStream(bytes); if (stream == null) { return(this.Request.CreateResponse(HttpStatusCode.NotFound)); } var mediaNameStr = Path.GetFileName(outputFileName); var mediaTypeStr = "image/png"; var mediaType = new MediaTypeHeaderValue(mediaTypeStr); // get the range and stream media type var range = this.Request.Headers.Range; HttpResponseMessage response; if (range == null) { // if the range header is present but null, then the header value must be invalid if (this.Request.Headers.Contains("Range")) { return(this.Request.CreateErrorResponse(HttpStatusCode.RequestedRangeNotSatisfiable, "GenerateExcelPreview")); } // if no range was requested, return the entire stream response = this.Request.CreateResponse(HttpStatusCode.OK); response.Headers.AcceptRanges.Add("bytes"); response.Content = new StreamContent(stream); response.Content.Headers.ContentType = mediaType; response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment"); mediaNameStr = System.Web.HttpUtility.UrlEncode(mediaNameStr); response.Content.Headers.ContentDisposition.FileName = mediaNameStr; return(response); } var partialStream = EnsureStreamCanSeek(stream); response = this.Request.CreateResponse(HttpStatusCode.PartialContent); response.Headers.AcceptRanges.Add("bytes"); try { // return the requested range(s) response.Content = new ByteRangeStreamContent(partialStream, range, mediaType); } catch (InvalidByteRangeException exception) { DynamicLogger.Instance.WriteLoggerLogError("GenerateExcelPreview (materialLotID=" + materialLotID + ")", exception); response.Dispose(); return(Request.CreateErrorResponse(exception)); } // change status code if the entire stream was requested if (response.Content.Headers.ContentLength.Value == partialStream.Length) { response.StatusCode = HttpStatusCode.OK; } return(response); }
//public String GetReplacedTemplate(IList<DocumentBalance> printList, LabelTemplate template, String printLot, UserByRol userByRol) //{ // try { // SetService(); return SerClient.GetReplacedTemplate(printList.ToList(), template, printLot, userByRol); } // finally // { // SerClient.Close(); // if (SerClient.State == CommunicationState.Faulted) // SerClient.Abort(); // } //} public IList<LabelTemplate> GetLabelTemplate(LabelTemplate data) { try { SetService(); return SerClient.GetLabelTemplate(data); } finally { SerClient.Close(); if (SerClient.State == CommunicationState.Faulted) SerClient.Abort(); } }
public void DeleteLabelTemplate(LabelTemplate data) { try { SetService(); SerClient.DeleteLabelTemplate(data); } finally { SerClient.Close(); if (SerClient.State == CommunicationState.Faulted) SerClient.Abort(); } }
public static void PrintLabelsInBatch(LabelTemplate defTemplate, Printer printer, IList<Label> listOfLabels) { //if (string.IsNullOrEmpty(printer)) //{ // Util.ShowError("Printer not found"); // return; //} Thread tl; if (printer != null && printer.PrinterName != WmsSetupValues.DEFAULT) usePrinter = printer; //printerName = printer; //m_streams = new List<Stream>(); m_streams = new Dictionary<LabelTemplate, IList<Stream>>(); m_currentPageIndex = new Dictionary<LabelTemplate, int>(); //1. Si viene un template imprime los labes con ese template if (defTemplate != null) { try { PrintLabelByTemplate(defTemplate, listOfLabels.Where(f => f.Product.PrintLabel != false).ToList()); //tl = new Thread(new ThreadStart(UpdateLabelPrintStatus)); //tl.Start(); UpdateLabelPrintStatus(); } catch (Exception ex) { Util.ShowError(ex.Message); } return; } //2. Agrupa a los diferentes tipos de label y a los null y los manda por aparte. //Filtra los que no imprime label (double check) IList<LabelTemplate> templateList = new List<LabelTemplate>(); //Si el lable es de producto busca las templates del producto. if (listOfLabels[0].LabelType.DocTypeID == LabelType.ProductLabel) templateList = listOfLabels.Where(f => f.Product.DefaultTemplate != null) .Select(f => f.Product.DefaultTemplate).Distinct().ToList(); string error = ""; //Configurando el template por defecto para impresion LabelTemplate defLabelTemplate = App.defTemplate; //Para cada template mandando la impresion foreach (LabelTemplate template in templateList) { try { PrintLabelByTemplate(template, listOfLabels.Where(f => f.Product.DefaultTemplate == template && f.Product.PrintLabel != false) .ToList()); tl = new Thread(new ThreadStart(UpdateLabelPrintStatus)); tl.Start(); } catch (Exception ex) { error += ex.Message; } } //Mandando las labels con template ne Null try { List<Label> labelsWoTemplate = null; if (listOfLabels[0].LabelType.DocTypeID == LabelType.ProductLabel) labelsWoTemplate = listOfLabels.Where(f => f.Product.DefaultTemplate == null && f.Product.PrintLabel != false).ToList(); else labelsWoTemplate = listOfLabels.ToList(); PrintLabelByTemplate(defLabelTemplate, labelsWoTemplate); tl = new Thread(new ThreadStart(UpdateLabelPrintStatus)); tl.Start(); } catch (Exception ex) { error += ex.Message; } //Final Error if (!string.IsNullOrEmpty(error)) Util.ShowError(error); }
public static void PrintLabelsInBatch(LabelTemplate defTemplate, Printer printer, IList <Label> listOfLabels) { //if (string.IsNullOrEmpty(printer)) //{ // Util.ShowError("Printer not found"); // return; //} Thread tl; if (printer != null && printer.PrinterName != WmsSetupValues.DEFAULT) { usePrinter = printer; } //printerName = printer; //m_streams = new List<Stream>(); m_streams = new Dictionary <LabelTemplate, IList <Stream> >(); m_currentPageIndex = new Dictionary <LabelTemplate, int>(); //1. Si viene un template imprime los labes con ese template if (defTemplate != null) { try { PrintLabelByTemplate(defTemplate, listOfLabels.Where(f => f.Product.PrintLabel != false).ToList()); //tl = new Thread(new ThreadStart(UpdateLabelPrintStatus)); //tl.Start(); UpdateLabelPrintStatus(); } catch (Exception ex) { Util.ShowError(ex.Message); } return; } //2. Agrupa a los diferentes tipos de label y a los null y los manda por aparte. //Filtra los que no imprime label (double check) IList <LabelTemplate> templateList = new List <LabelTemplate>(); //Si el lable es de producto busca las templates del producto. if (listOfLabels[0].LabelType.DocTypeID == LabelType.ProductLabel) { templateList = listOfLabels.Where(f => f.Product.DefaultTemplate != null) .Select(f => f.Product.DefaultTemplate).Distinct().ToList(); } string error = ""; //Configurando el template por defecto para impresion LabelTemplate defLabelTemplate = App.defTemplate; //Para cada template mandando la impresion foreach (LabelTemplate template in templateList) { try { PrintLabelByTemplate(template, listOfLabels.Where(f => f.Product.DefaultTemplate == template && f.Product.PrintLabel != false) .ToList()); tl = new Thread(new ThreadStart(UpdateLabelPrintStatus)); tl.Start(); } catch (Exception ex) { error += ex.Message; } } //Mandando las labels con template ne Null try { List <Label> labelsWoTemplate = null; if (listOfLabels[0].LabelType.DocTypeID == LabelType.ProductLabel) { labelsWoTemplate = listOfLabels.Where(f => f.Product.DefaultTemplate == null && f.Product.PrintLabel != false).ToList(); } else { labelsWoTemplate = listOfLabels.ToList(); } PrintLabelByTemplate(defLabelTemplate, labelsWoTemplate); tl = new Thread(new ThreadStart(UpdateLabelPrintStatus)); tl.Start(); } catch (Exception ex) { error += ex.Message; } //Final Error if (!string.IsNullOrEmpty(error)) { Util.ShowError(error); } }
public String GetReplacedTemplateForLabels(IList<Label> labelList, LabelTemplate template, string printLot) { try { SetService(); return SerClient.GetReplacedTemplateForLabels(labelList.ToList(), template, printLot); } finally { SerClient.Close(); if (SerClient.State == CommunicationState.Faulted) SerClient.Abort(); } }
private static void PrintLabelByTemplate(LabelTemplate template, List<Label> listOfLabels) { if (listOfLabels == null || listOfLabels.Count == 0) return; listLabels = listOfLabels; try { //Si viene una impresora definida utiliza esa, si no utiliza la del template if (template != null) curTemplate = template; else curTemplate = (new WMSProcessClient()).GetLabelTemplate(new LabelTemplate { Header = WmsSetupValues.ProductLabelTemplate }).First(); usePrinter = usePrinter == null ? new Printer { PrinterName = curTemplate.DefPrinter.Name, PrinterPath = curTemplate.DefPrinter.CnnString } : usePrinter; } catch { throw new Exception("Printer not defined for template " + curTemplate.Name); } if (usePrinter == null) throw new Exception("Printer not defined for template " + curTemplate.Name); //Revisa si el label imprime por comandos y lo manda a esa ruta. if (template.IsPL == true) { PrintLabelByPL(template, listOfLabels, usePrinter); return; } try { string labelPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), WmsSetupValues.RdlTemplateDir + "\\" + template.Header); if (!File.Exists(labelPath)) throw new Exception("Label template " + template.Header + " does not exists.\n"); //Definicion de Reporte localReport = new LocalReport(); localReport.EnableExternalImages = true; localReport.ExecuteReportInCurrentAppDomain(System.Reflection.Assembly.GetExecutingAssembly().Evidence); localReport.AddTrustedCodeModuleInCurrentAppDomain("Barcode, Version=1.0.5.40001, Culture=neutral, PublicKeyToken=6dc438ab78a525b3"); localReport.AddTrustedCodeModuleInCurrentAppDomain("System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"); localReport.EnableExternalImages = true; localReport.ReportPath = labelPath; DataSet ds = ProcessLabels(listOfLabels); localReport.DataSources.Add(new ReportDataSource("Details", ds.Tables["Details"])); //Proceso de Creacion de archivos curTemplate = template; m_streams.Add(curTemplate, new List<Stream>()); m_currentPageIndex.Add(curTemplate, 0); Export(localReport, curTemplate, "IMAGE"); //1 - Document, 2 - Label m_currentPageIndex[curTemplate] = 0; Thread th = new Thread(new ParameterizedThreadStart(Print)); th.Start(usePrinter.PrinterName); //Print(usePrinter.PrinterName); } catch (Exception ex) { throw new Exception(ex.Message); } }
/// <summary> /// Get Print file string to print /// </summary> /// <param name="labels">List of labels to print</param> /// <param name="template">Template to use for the printing</param> /// <returns></returns> public String ProcessPrintingLine(DocumentBalance printLine, LabelTemplate template, String printLot, Node node, Bin bin, UserByRol userByRol) { string result = ""; Status status = WType.GetStatus(new Status { StatusID = EntityStatus.Active }); //Active //Obteniendo el listado de TAGS que se deben reemplazar en el template IList <LabelMapping> labelmappings = Factory.DaoLabelMapping().Select( new LabelMapping { LabelType = template.LabelType }); //Template base //int i; IList <Label> labelList = new List <Label>(); //Tipo De impresion //1. Normal Imprime standar, sin logistica //2. Logistic (Notes tiene data) - imprime normal mas la Logistica Unit logisticUnit = null; if (printLine.Notes != null && printLine.Notes.Contains("Logistic")) { string[] dataLogistic = printLine.Notes.Split(':'); //El primer elemento contiene la unidad logistica. logisticUnit = Factory.DaoUnit().SelectById(new Unit { UnitID = int.Parse(dataLogistic[1]) }); //3. Only print Logistic (notes tiene "ONLYPACK") - no imprime la normal (si las crea), solo imprime las logisticas //if (printLine.Notes.Contains("ONLYPACK")) //printOnlyLogistic = true; } //CReating Document Line to Send DocumentLine prnLine = new DocumentLine { Product = printLine.Product, Document = printLine.Document, Unit = printLine.Unit, Quantity = printLine.Quantity }; //Crea las etiquetas de la cantidad de producto a recibir Logisticas y sus Hijas double logisticFactor = (logisticUnit != null) ? (double)(logisticUnit.BaseAmount / printLine.Unit.BaseAmount) : 1; labelList = CreateProductLabels(logisticUnit, prnLine, node, bin, logisticFactor, printLot, "", DateTime.Now) .Where(f => f.FatherLabel == null).ToList(); //Reemplazando el Header if (template.Header != null) { result += ReplaceTemplate(labelmappings, template.Header, labelList[0]) + Environment.NewLine; } //Reemplazando el Body if (template.Body != null) { foreach (Label label in labelList) { result += ReplaceTemplate(labelmappings, template.Body, label) + Environment.NewLine; } } return(result); }
public static void PrintDocument(Document document, Printer printer) { if (document.DocType.Template == null) return; try { //Inicializando variables usadas en la impresion //if (m_streams == null) m_streams = new Dictionary<LabelTemplate, IList<Stream>>(); //if (m_currentPageIndex == null) m_currentPageIndex = new Dictionary<LabelTemplate, int>(); curTemplate = document.DocType.Template; usePrinter = printer; //Ejecutar la impresion global en un Hilo Thread th = new Thread(new ParameterizedThreadStart(PrintDocumentThread)); th.Start(document); } catch (Exception ex) { Util.ShowError("Report could not shown: " + ex.Message); } }