Ejemplo n.º 1
0
        public IList <Label> CreateEmptyPackLabel(Location location, int numLabels, Product product, string printSession,
                                                  SysUser user)
        {
            Factory.IsTransactional = true;

            Node recNode = WType.GetNode(new Node {
                NodeID = NodeType.Stored
            });
            Status status = WType.GetStatus(new Status {
                StatusID = EntityStatus.Active
            });
            DocumentType labelType = WType.GetLabelType(new DocumentType {
                DocTypeID = LabelType.ProductLabel
            });
            Unit logisticUnit = WType.GetUnit(new Unit {
                Company = location.Company, Name = WmsSetupValues.CustomUnit
            });
            Bin destLocation = WType.GetBin(new Bin {
                Location = location, BinCode = DefaultBin.PUTAWAY
            });


            IList <Label> listLabel = new List <Label>();

            //Generate new logistig labels located in MAIN
            //Labels shouldbe activated the next transaction
            try {
                //Funcion para obtener siguiente Label
                //DocumentTypeSequence initSequence = GetNextDocSequence(location.Company, labelType);
                Label fatherLabel = null;

                for (int i = 0; i < (int)numLabels; i++)
                {
                    fatherLabel              = new Label();
                    fatherLabel.Node         = recNode;
                    fatherLabel.Bin          = destLocation;
                    fatherLabel.Product      = product;
                    fatherLabel.CreatedBy    = user.UserName;
                    fatherLabel.Status       = status;
                    fatherLabel.LabelType    = labelType;
                    fatherLabel.CreationDate = DateTime.Now;
                    fatherLabel.Printed      = false;

                    fatherLabel.Unit        = logisticUnit;
                    fatherLabel.IsLogistic  = false;
                    fatherLabel.FatherLabel = null;
                    fatherLabel.LabelCode   = ""; //(initSequence.NumSequence + i).ToString() + GetRandomHex(user.UserName, initSequence.NumSequence + i);
                    fatherLabel.CurrQty     = 0;
                    //Aqui guardan las logisitcas las hijas que contienen unas vez se imprimen
                    fatherLabel.StartQty    = 0;
                    fatherLabel.Notes       = "Empty Label";
                    fatherLabel.PrintingLot = printSession;
                    fatherLabel             = Factory.DaoLabel().Save(fatherLabel);

                    //Registra el movimiento del nodo
                    fatherLabel.LabelCode = fatherLabel.LabelID.ToString();

                    SaveNodeTrace(
                        new NodeTrace
                    {
                        Node      = recNode,
                        Document  = null,
                        Label     = fatherLabel,
                        Quantity  = fatherLabel.CurrQty,
                        IsDebit   = false,
                        CreatedBy = user.UserName
                    }
                        );

                    listLabel.Add(fatherLabel);
                }

                //Ajustando la sequencia
                //initSequence.NumSequence += numLabels;

                //Factory.DaoDocumentTypeSequence().Update(initSequence);

                Factory.Commit();

                return(listLabel);
            }
            catch (Exception ex)
            {
                Factory.Rollback();
                ExceptionMngr.WriteEvent("CreateEmptyLabel:", ListValues.EventType.Fatal, ex, null, ListValues.ErrorCategory.Business);
                throw new Exception(WriteLog.GetTechMessage(ex));
            }
        }