Exemplo n.º 1
0
        //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;
        }
Exemplo n.º 2
0
        public IList<LabelTemplate> Select(LabelTemplate data)
        {

                IList<LabelTemplate> datos = new List<LabelTemplate>();
                datos = GetHsql(data).List<LabelTemplate>();
                if (!Factory.IsTransactional)
                    Factory.Commit();
                return datos;

        }
Exemplo n.º 3
0
        public override Boolean Equals(object obj)
        {
            if ((obj == null) || (obj.GetType() != this.GetType()))
            {
                return(false);
            }
            LabelTemplate castObj = (LabelTemplate)obj;

            return((castObj != null) &&
                   (this.RowID == castObj.RowID));
        }
Exemplo n.º 4
0
        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;
        }
Exemplo n.º 5
0
        //public String GetReplacedTemplate(IList<DocumentBalance> printList, LabelTemplate template, String printLot, UserByRol userByRol)
        //{
        //    return LabelMngr.GetReplacedTemplate(printList, template, printLot, userByRol);
        //}

        public IList<LabelTemplate> GetLabelTemplate(LabelTemplate data)
        {
            return Factory.DaoLabelTemplate().Select(data);
        }
Exemplo n.º 6
0
 public LabelTemplate SelectById(LabelTemplate data)
 {
     return (LabelTemplate)base.SelectById(data);
 }
Exemplo n.º 7
0
 public Boolean Delete(LabelTemplate data)
 {
     return base.Delete(data);
 }
Exemplo n.º 8
0
 public Boolean Update(LabelTemplate data)
 {
     return base.Update(data);
 }
Exemplo n.º 9
0
 public LabelTemplate Save(LabelTemplate data)
 {
     return (LabelTemplate)base.Save(data);
 }
Exemplo n.º 10
0
 public void DeleteLabelTemplate(LabelTemplate data) { Factory.DaoLabelTemplate().Delete(data); }
Exemplo n.º 11
0
 public void UpdateLabelTemplate(LabelTemplate data) { Factory.DaoLabelTemplate().Update(data); }
Exemplo n.º 12
0
 public LabelTemplate SaveLabelTemplate(LabelTemplate data) { return Factory.DaoLabelTemplate().Save(data); }
Exemplo n.º 13
0
 ////23 Marzo - 09, Jairo Murillo Print labels already received
 public String GetReplacedTemplateForLabels(IList<Label> labelList, LabelTemplate template, string printLot)
 {
     return LabelMngr.GetReplacedTemplateForLabels(labelList, template, printLot);
 }
Exemplo n.º 14
0
        private static void PrintLabelByTemplate(LabelTemplate rdlTemplateName, IList<Label> listOfLabels)
        {
            try
            {
                if (listOfLabels == null || listOfLabels.Count == 0)
                    return;

                sListLabels = listOfLabels;


                try
                {
                    //Si viene una impresora definida utiliza esa, si no utiliza la del template
                    if (rdlTemplateName != null)
                        curTemplate = rdlTemplateName;
                    else
                        curTemplate = (new DaoFactory()).DaoLabelTemplate().Select(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 (rdlTemplateName.IsPL == true)
                {
                    PrintLabelByPL(rdlTemplateName, listOfLabels, usePrinter);
                    return;
                }


                string labelPath = Path.Combine(AppPath, WmsSetupValues.RdlTemplateDir + "\\" + rdlTemplateName.Header);

                if (!File.Exists(labelPath))
                    throw new Exception("Label template " + labelPath + " does not exists.\n");


                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 
                m_streams.Add(curTemplate, new List<Stream>());

                m_currentPageIndex.Add(curTemplate, 0);

                Export(localReport, curTemplate, "IMAGE");  //1 - Document, 2 -  Label


                m_currentPageIndex[curTemplate] = 0;

                //Ejecutar la impresion global en un Hilo            
                Thread th = new Thread(new ParameterizedThreadStart(Print));
                th.Start(curTemplate.DefPrinter.CnnString);
                //Print(curTemplate.DefPrinter.CnnString);


            }
            catch (Exception ex)
            {
                ExceptionMngr.WriteEvent("PrintLabelByTemplate:" + rdlTemplateName.Name, ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.Business);
                throw new Exception(ex.Message);
            }
        }
Exemplo n.º 15
0
        public void PrintDocument(Document document, LabelTemplate report, string appPath, CustomProcess process)
        {
            curTemplate = report;

            try
            {

                if (curTemplate.DefPrinter == null)
                    throw new Exception("No printer defined for report " + report.Name +".");

                //Save the File printed for Document to show Later. //Solo si no existe.
                try
                {
                    Factory.DaoProcessEntityResource().Save(
                        new ProcessEntityResource
                        {
                            Entity = new ClassEntity { ClassEntityID = EntityID.Document },
                            EntityRowID = document.DocID,
                            CreatedBy = WmsSetupValues.SystemUser,
                            CreationDate = DateTime.Now,
                            Process = process,
                            Status = new Status { StatusID = EntityStatus.Active },
                            Template = report
                        });
                }
                catch { }


                //Usa la default Printer del template
                usePrinter = new Printer { PrinterName = curTemplate.DefPrinter.Name, PrinterPath = curTemplate.DefPrinter.CnnString };              

                //Ejecutar la impresion global en un Hilo            
                //Thread th = new Thread(new ParameterizedThreadStart(PrintDocumentThread));
                //th.Start(document);
                PrintDocumentThread(document);




            }
            catch (Exception ex)
            {
                //throw new Exception("Report could not be printed: " + report.Name + ", " + ex.Message);
                ExceptionMngr.WriteEvent("Report could not be printed: " + report.Name + ", " + ex.Message,
                            ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection);
            }

        }
Exemplo n.º 16
0
        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);
            }


        }
Exemplo n.º 17
0
        /// <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;
        }
Exemplo n.º 18
0
        //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);
        }
Exemplo n.º 19
0
        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);


        }