Ejemplo n.º 1
0
    void PopulateAdjacents()
    {
        for (int y = 0; y < dungeon.height; y++)
        {
            for (int x = 0; x < dungeon.width; x++)
            {
                NodeTrace n = traces[x, y];

                if (x - 1 >= 0)
                {
                    n.adjacents.Add(traces[x - 1, y]);
                }
                if (x + 1 < dungeon.width)
                {
                    n.adjacents.Add(traces[x + 1, y]);
                }
                if (y - 1 >= 0)
                {
                    n.adjacents.Add(traces[x, y - 1]);
                }
                if (y + 1 < dungeon.height)
                {
                    n.adjacents.Add(traces[x, y + 1]);
                }
            }
        }
    }
Ejemplo n.º 2
0
        //Carga los movimientos a los que se hacen referencia
        private void LoadTransactions(DocumentBalance actualRecord)
        {
            //Solo Muestra Labesl con cantidades fijas a remover
            View.BrdManual.Visibility = Visibility.Collapsed;


            NodeTrace pattern = new NodeTrace
            {
                Node  = actualRecord.Node,
                Label = new WpfFront.WMSBusinessService.Label
                {
                    Product = actualRecord.Product
                              //Printed = true,
                              //Unit = actualRecord.Unit
                }
            };

            //Cuando se desea cancelar la linea de un Shipment.
            //JM - Marzo 9 / 2010
            if (actualRecord.DocumentLine != null && actualRecord.DocumentLine.LineNumber > 0)
            {
                pattern.PostingDocLineNumber = actualRecord.DocumentLine.LineNumber;
                pattern.PostingDocument      = actualRecord.Document;
            }
            else
            {
                pattern.PostingDocument = new Document {
                    DocID = -1
                };
                pattern.Document = actualRecord.Document;
            }


            // lista de labels printed
            View.Model.LstPrinted = service.GetNodeTrace(pattern).ToList();

            View.ListPrinted.Items.Refresh();

            // qtys manuales y printed
            View.Model.QtyPrintedOld = View.Model.LstPrinted.Sum(f => f.Quantity);//Sum(f=>f.Label.CurrQty);
            View.Model.QtyManualOld  = int.Parse(actualRecord.QtyPending.ToString()) - View.Model.LstPrinted.Count();

            // solo si hay disponibilidad se habilitan las tablas
            //if (View.Model.QtyManualOld == 0)
            //View.BrdManual.Visibility = Visibility.Collapsed;

            if (View.Model.QtyPrintedOld == 0)
            {
                View.BrdPrinted.Visibility = Visibility.Collapsed;
            }


            //Si el documento es de receiving oculta el Bin de restock
            if (View.Model.Record.Document.DocType.DocClass.DocClassID == SDocClass.Receiving)
            {
                View.StkUcBin.Visibility = Visibility.Collapsed;
            }
        }
        private void LoadReceivedLabels(Document document, bool usePrintLot)
        {
            //si usePrintLot viene en false muestra todo los labels organizados por lote

            if (document == null)
            {
                return;
            }

            //Carga en la lista de labels, los labels que pertenecen a este documento y que no estan printed
            NodeTrace patterTrace = new NodeTrace
            {
                Document = document,
                Node     = View.Model.Node,
                Status   = new Status {
                    StatusID = EntityStatus.Active
                }
            };


            //PrintLot trae los ultimos labels procesados.
            patterTrace.Label = new WpfFront.WMSBusinessService.Label
            {
                PrintingLot = usePrintLot ? View.PrintLot.Text : "",
                FatherLabel = new WpfFront.WMSBusinessService.Label {
                    LabelID = -1
                },
                ReceivingDocument = document
                                    //El -1 especifica que la consulta debe hacerse sobre labels con father label = null
            };


            try
            {
                View.Model.LabelsToPrint = null;
                View.Model.LabelsToPrint = service.GetNodeTrace(patterTrace).Select(f => f.Label)
                                           .Where(f => f.Product.PrintLabel == true)
                                           .OrderByDescending(f => f.LabelID).ToList(); //Ordenadas por Lote
            }
            catch { }

            View.ToPrintLabels.Items.Refresh();

            if (View.Model.LabelsToPrint != null && View.Model.LabelsToPrint.Count > 0)
            {
                View.BrdPreview.Visibility  = Visibility.Visible;
                View.BrdGenerate.Visibility = Visibility.Collapsed;
            }
        }
Ejemplo n.º 4
0
        public IList <NodeTrace> Select(NodeTrace data)
        {
            IList <NodeTrace> datos = GetHsql(data).List <NodeTrace>();

            try {
                if (!Factory.IsTransactional)
                {
                    Factory.Commit();
                }
            }
            catch (Exception e)
            {
                NHibernateHelper.WriteEventLog(WriteLog.GetTechMessage(e));
            }

            return(datos);
        }
Ejemplo n.º 5
0
    void PopulateNodes()
    {
        for (int y = 0; y < dungeon.height; y++)
        {
            for (int x = 0; x < dungeon.width; x++)
            {
                int v = 1;

                switch (dungeon.canvas[x, y])
                {
                case ' ':
                    v = 0;
                    break;

                case 'o':
                    v = 2;
                    break;
                }

                nodes[x, y]  = new Node(v, new Vector2(x, y));
                traces[x, y] = new NodeTrace(nodes[x, y]);
            }
        }
    }
Ejemplo n.º 6
0
    List <Node> Walk(Vector2 start, Vector2 end)
    {
        //Debug.Log(string.Format("Walking from {0} to {1}", start, end));

        ClearTraces();

        Queue <NodeTrace> opened = new Queue <NodeTrace>();
        List <NodeTrace>  closed = new List <NodeTrace>();

        NodeTrace startTrace = traces[(int)start.x, (int)start.y];

        startTrace.HCost = GetHCost(start, end);
        startTrace.FCost = startTrace.HCost;
        opened.Enqueue(startTrace);

        NodeTrace current    = null;
        int       safetyLock = 10000;

        while (opened.Count > 0 && safetyLock > 0)
        {
            safetyLock--;

            current = opened.Dequeue();
            closed.Add(current);

            if (current.node.position == end)
            {
                break;
            }

            foreach (NodeTrace adj in current.adjacents)
            {
                if (adj.node.position == end)
                {
                    adj.parent = current;
                    opened.Clear();

                    opened.Enqueue(adj);
                    break;
                }

                if (adj.node.value != 0 || closed.Contains(adj))
                {
                    continue;
                }

                int GCost = current.GCost + 1;
                int HCost = GetHCost(adj.node.position, end);
                int FCost = GCost + HCost;

                if (FCost < adj.FCost || !opened.Contains(adj))
                {
                    adj.GCost = GCost;
                    adj.HCost = HCost;
                    adj.FCost = FCost;

                    adj.parent = current;
                    if (!opened.Contains(adj))
                    {
                        opened.Enqueue(adj);
                    }
                }
            }
        }

        if (safetyLock == 0)
        {
            Debug.LogError("Safety lock activated!");
        }

        NodeTrace firstStep = current.parent;

        if (firstStep == null)
        {
            Debug.LogError("No space for corridor!");
            return(null);
        }

        List <Node> steps = new List <Node>();

        steps.Add(firstStep.node);

        safetyLock = 100;
        while (firstStep.parent != null && safetyLock > 0)
        {
            safetyLock--;

            firstStep = firstStep.parent;
            steps.Add(firstStep.node);
        }

        if (safetyLock == 0)
        {
            Debug.LogError("Safety lock activated!");
        }

        steps.Reverse();
        steps.RemoveAt(0);

        return(steps);
    }
Ejemplo n.º 7
0
 public Boolean Update(NodeTrace data)
 {
     return(base.Update(data));
 }
Ejemplo n.º 8
0
 public NodeTrace SaveNodeTrace(NodeTrace data)
 {
     try {
     SetService();  return SerClient.SaveNodeTrace(data); }
     finally
     {
         SerClient.Close();
         if (SerClient.State == CommunicationState.Faulted)
         SerClient.Abort(); 
     }
 }
        //
        /// <summary>
        ///Receive Returns, primero recibe normal la cantidad total y luego saca de ese label todo lo que o sea onHand.
        /// Deja el mismo receiving document para poder crear el documento a postear en el ERP.
        /// </summary>
        /// <param name="document"></param>
        /// <param name="retProduct"></param>
        /// <param name="sysUser"></param>
        /// <param name="retTotalQty"></param>
        /// <returns></returns>
        public bool ReceiveReturn(Document document, IList <ProductStock> retProduct,
                                  SysUser sysUser, double retTotalQty, Node recNode)
        {
            Factory.IsTransactional = true;

            try
            {
                DocumentLine line = new DocumentLine
                {
                    Document     = document,
                    Product      = retProduct.First().Product, //View.ComboProduct.SelectedItem,
                    Unit         = retProduct.First().Unit,
                    Quantity     = retTotalQty,
                    QtyPending   = retTotalQty,
                    QtyAllocated = 1,
                    CreatedBy    = sysUser.UserName
                };

                //RETURN
                Bin binDest = WType.GetBin(new Bin {
                    BinCode = DefaultBin.RETURN, Location = retProduct.First().Bin.Location
                });
                //retProduct.Where(f => f.Bin.BinCode == DefaultBin.RETURN).Select(f => f.Bin).First();

                ReceiveProduct(line, new Unit(), binDest, recNode);

                //Mueve las cantidades diferentes del Bin Return a el Bin Correcto.
                Label label = Factory.DaoLabel().Select(new Label {
                    ReceivingDocument = document,
                    Product           = retProduct.First().Product,
                    Status            = new Status {
                        StatusID = EntityStatus.Active
                    }, Node = recNode
                }).First();
                DocumentLine tmpLine = null;

                foreach (ProductStock ps in retProduct.Where(f => f.Bin.BinCode != DefaultBin.RETURN))
                {
                    tmpLine = new DocumentLine {
                        Quantity = ps.Stock, Document = document,
                        Product  = ps.Product, CreatedBy = sysUser.UserName, Unit = ps.Unit
                    };

                    //Disminuye el Label Original
                    DecreaseQtyFromLabel(label, tmpLine, "Decreased in return " + document.DocNumber, false, recNode, false);
                    label.StartQty = label.CurrQty;

                    //Crea un Lable Nuevo en el bin de destino.
                    IncreaseQtyIntoBin(tmpLine, recNode, ps.Bin, "Decreased in return " + document.DocNumber + ", Bin: " + ps.Bin.BinCode, true, DateTime.Now, null, label);
                }

                //Reversado el Node trace del label original al la cantidad final.
                try {
                    NodeTrace ndtrace = Factory.DaoNodeTrace().Select(new NodeTrace {
                        Label = label, Document = document
                    }).First();

                    if (label.CurrQty == 0)
                    {//Lo elimina porque la QTY es cero.
                        Factory.DaoNodeTrace().Delete(ndtrace);
                        Factory.DaoLabel().Delete(label);
                    }
                    else
                    {
                        ndtrace.Quantity = label.CurrQty;
                        Factory.DaoNodeTrace().Update(ndtrace);
                        Factory.DaoLabel().Update(label);
                    }
                }
                catch { }



                return(true);
            }
            catch (Exception ex)
            {
                Factory.Rollback();
                ExceptionMngr.WriteEvent("ReceiveReturn:", ListValues.EventType.Fatal, ex, null, ListValues.ErrorCategory.Business);
                throw new Exception(WriteLog.GetTechMessage(ex));
            }
        }
Ejemplo n.º 10
0
        //23 Marzo 09 - Update of tracking data
        private void UpdateTrackData()
        {
            try
            {
                //Carga en la lista de labels, los labels que pertenecen a este documento para incluir su track option
                NodeTrace patterTrace = new NodeTrace
                {
                    Document = View.Model.Document,
                    Node     = View.Model.Node,
                    Status   = new Status {
                        StatusID = EntityStatus.Active
                    },
                    Label = new Label {
                        Product = View.Model.Product, Status = new Status {
                            StatusID = EntityStatus.Active
                        }
                    }
                };

                //Lista de labels recibidos
                View.Model.ManualTrackList = service.GetNodeTrace(patterTrace)
                                             .Select(f => f.Label).ToList();

                View.ManualTrackList.Items.Refresh();
                if (View.Model.ManualTrackList.Count == 1)
                {
                    View.ManualTrackList.SelectedIndex = 0;
                }

                //Seleccionar los limites de ingreso de datos, cuenta los labels que tengan
                //el dato en blanco indicando que estan pendientes.
                TrackOption trackName   = null;
                string      curTrackVal = ""; //guarda el cur value delegate track data
                int         tmpCount    = 0;


                //Calculando el remaining depende si es unico el track o no.
                if (View.Model.MaxTrackQty == 1) //Si es Unico
                {
                    try { View.Model.RemainingQty = (int)View.Model.ManualTrackList.Where(f => f.LabelType.DocTypeID == LabelType.ProductLabel).Sum(f => f.CurrQty); }
                    catch { }

                    View.TxtQtyTrack.Text      = View.Model.MaxTrackQty.ToString();
                    View.Model.TrackUnit       = View.Model.Product.BaseUnit;
                    View.TxtQtyTrack.IsEnabled = false;
                }
                else //Si no.
                {
                    for (int i = 0; i < View.Model.TrackData.Count; i++)
                    {
                        tmpCount  = 0;
                        trackName = View.Model.TrackData[i].TrackOption;

                        //Verison Anterior
                        //Obtiene los trackoption missing.
                        //tmpCount = View.Model.ManualTrackList
                        //    .Where(f => f.GetType().GetProperty(trackName).GetValue(f, null) == null
                        //        || f.GetType().GetProperty(trackName).GetValue(f, null).ToString().Trim() == "")
                        //        .Count();

                        //version 14 abril 2009, trackOption del label en otra tabla
                        foreach (Label trLabel in View.Model.ManualTrackList)
                        {
                            try { curTrackVal = trLabel.TrackOptions.Where(f => f.TrackOption.RowID == trackName.RowID).First().TrackValue; }
                            catch { curTrackVal = ""; }

                            if (string.IsNullOrEmpty(curTrackVal))
                            {
                                tmpCount++;
                            }
                        }

                        //Vuelve la cantidad pendiente como la mayor de las dos, Aplica para no UNIQUE track
                        View.Model.RemainingQty = tmpCount > View.Model.RemainingQty ? tmpCount : View.Model.RemainingQty;
                    }

                    View.TxtQtyTrack.Text      = View.Model.RemainingQty.ToString();
                    View.TxtQtyTrack.IsEnabled = true;
                }


                //Cantidad pendiente por poner el tracking
                //if (View.Model.MaxTrackQty == 1)
                //{ //Si es unique debe pedir 1 a 1 hasta todas las unidades basicas
                //    View.TxtQtyTrack.Text = View.Model.MaxTrackQty.ToString();
                //    View.Model.TrackUnit = View.Model.Product.BaseUnit;
                //    View.TxtQtyTrack.IsEnabled = false;
                //}
                //else
                //{
                //    View.TxtQtyTrack.Text = View.Model.RemainingQty.ToString();
                //    View.TxtQtyTrack.IsEnabled = true;
                //}
            }
            catch (Exception ex)
            {
                Util.ShowError("Problem loading received list.\n" + ex.Message);
                return;
            }
        }
Ejemplo n.º 11
0
        public override IQuery GetHsql(Object data)
        {
            StringBuilder sql       = new StringBuilder("select a from NodeTrace a    where  ");
            NodeTrace     nodetrace = (NodeTrace)data;

            if (nodetrace != null)
            {
                Parms = new List <Object[]>();
                if (nodetrace.RowID != 0)
                {
                    sql.Append(" a.RowID = :id     and   ");
                    Parms.Add(new Object[] { "id", nodetrace.RowID });
                }

                if (nodetrace.Node != null && nodetrace.Node.NodeID != 0)
                {
                    sql.Append(" a.Node.NodeID = :id1     and   ");
                    Parms.Add(new Object[] { "id1", nodetrace.Node.NodeID });
                }

                if (nodetrace.Document != null && nodetrace.Document.DocID != 0)
                {
                    sql.Append(" a.Document.DocID = :id2     and   ");
                    Parms.Add(new Object[] { "id2", nodetrace.Document.DocID });
                }


                if (nodetrace.Bin != null && nodetrace.Bin.BinID != 0)
                {
                    sql.Append(" a.Bin.BinID = :id5     and   ");
                    Parms.Add(new Object[] { "id5", nodetrace.Bin.BinID });
                }

                if (nodetrace.BinSource != null && nodetrace.BinSource.BinID != 0)
                {
                    sql.Append(" a.BinSource.BinID = :bs1     and   ");
                    Parms.Add(new Object[] { "bs1", nodetrace.BinSource.BinID });
                }

                if (nodetrace.IsDebit != null)
                {
                    sql.Append(" a.IsDebit = :ids5     and   ");
                    Parms.Add(new Object[] { "ids5", nodetrace.IsDebit });
                }


                if (nodetrace.PostingDocLineNumber != 0)
                {
                    sql.Append(" a.PostingDocLineNumber = :ipl5     and   ");
                    Parms.Add(new Object[] { "ipl5", nodetrace.PostingDocLineNumber });
                }


                //LABEL

                if (nodetrace.Label != null)
                {
                    if (!String.IsNullOrEmpty(nodetrace.Label.LabelCode))
                    {
                        sql.Append(" (a.Label.LabelCode = :nom OR a.Label.LabelID = :lb1d ) and ");

                        long barcode;
                        if (Int64.TryParse(nodetrace.Label.LabelCode, out barcode))
                        {
                            Parms.Add(new Object[] { "nom", barcode.ToString() });
                        }
                        else
                        {
                            Parms.Add(new Object[] { "nom", nodetrace.Label.LabelCode });
                        }

                        try
                        {
                            if (nodetrace.Label.LabelCode.StartsWith("1") && nodetrace.Label.LabelCode.Length == WmsSetupValues.LabelLength)
                            {
                                Parms.Add(new Object[] { "lb1d", Int64.Parse(nodetrace.Label.LabelCode.Substring(1, WmsSetupValues.LabelLength - 1)) });
                            }
                            else
                            {
                                Parms.Add(new Object[] { "lb1d", 0 });
                            }
                        }
                        catch { Parms.Add(new Object[] { "lb1d", 0 }); }
                    }


                    if (nodetrace.Label.FatherLabel != null && nodetrace.Label.FatherLabel.LabelID != 0)
                    {
                        if (nodetrace.Label.FatherLabel.LabelID > 0)
                        {
                            sql.Append(" a.Label.FatherLabel.LabelID = :if6     and   ");
                            Parms.Add(new Object[] { "if6", nodetrace.Label.FatherLabel.LabelID });
                        }
                        else
                        {
                            sql.Append(" a.Label.FatherLabel.LabelID is null  and   ");
                        }
                    }

                    if (nodetrace.Label.LabelID != 0)
                    {
                        sql.Append(" a.Label.LabelID = :id6     and   ");
                        Parms.Add(new Object[] { "id6", nodetrace.Label.LabelID });
                    }


                    if (!string.IsNullOrEmpty(nodetrace.Label.PrintingLot))
                    {
                        sql.Append(" a.Label.PrintingLot = :pl01    and   ");
                        Parms.Add(new Object[] { "pl01", nodetrace.Label.PrintingLot });
                    }


                    if (nodetrace.Label.IsLogistic != null)
                    {
                        sql.Append(" a.Label.IsLogistic = :id26     and   ");
                        Parms.Add(new Object[] { "id26", nodetrace.Label.IsLogistic });
                    }


                    if (nodetrace.Label.Product != null && nodetrace.Label.Product.ProductID != 0)
                    {
                        sql.Append(" a.Label.Product.ProductID = :id10     and   ");
                        Parms.Add(new Object[] { "id10", nodetrace.Label.Product.ProductID });
                    }

                    if (nodetrace.Label.Node != null && nodetrace.Label.Node.NodeID != 0)
                    {
                        sql.Append(" a.Label.Node.NodeID = :nid10     and   ");
                        Parms.Add(new Object[] { "nid10", nodetrace.Label.Node.NodeID });
                    }

                    if (nodetrace.Label.Status != null && nodetrace.Label.Status.StatusID != 0)
                    {
                        sql.Append(" a.Label.Status.StatusID = :sid10     and   ");
                        Parms.Add(new Object[] { "sid10", nodetrace.Label.Status.StatusID });
                    }

                    if (nodetrace.Label.Unit != null && nodetrace.Label.Unit.UnitID != 0)
                    {
                        sql.Append(" a.Label.Unit.UnitID = :id11     and   ");
                        Parms.Add(new Object[] { "id11", nodetrace.Label.Unit.UnitID });
                    }

                    if (nodetrace.Label.Printed != null)
                    {
                        sql.Append(" a.Label.Printed = :id12     and   ");
                        Parms.Add(new Object[] { "id12", nodetrace.Label.Printed });
                    }


                    if (nodetrace.Label.Node != null && nodetrace.Label.Node.NodeID != 0)
                    {
                        sql.Append(" a.Label.Node.NodeID = :nt11     and   ");
                        Parms.Add(new Object[] { "nt11", nodetrace.Label.Node.NodeID });
                    }

                    if (nodetrace.Label.LabelType != null && nodetrace.Label.LabelType.DocTypeID != 0)
                    {
                        sql.Append(" a.Label.LabelType.DocTypeID = :lx11     and   ");
                        Parms.Add(new Object[] { "lx11", nodetrace.Label.LabelType.DocTypeID });
                    }
                }



                if (nodetrace.Status != null && nodetrace.Status.StatusID != 0)
                {
                    sql.Append(" a.Status.StatusID = :id7     and   ");
                    Parms.Add(new Object[] { "id7", nodetrace.Status.StatusID });
                }

                if (!String.IsNullOrEmpty(nodetrace.Comment))
                {
                    sql.Append(" a.Comment = :nomz     and   ");
                    Parms.Add(new Object[] { "nomz", nodetrace.Comment });
                }

                if (nodetrace.PostingDocument != null)
                {
                    if (nodetrace.PostingDocument.DocID <= 0)
                    {
                        sql.Append(" a.PostingDocument.DocID is null and ");
                    }

                    else if (nodetrace.PostingDocument.DocID == 1)
                    {
                        sql.Append(" a.PostingDocument.DocID IS NOT NULL and ");
                    }

                    else
                    {
                        sql.Append(" a.PostingDocument.DocID = :dom2  and ");
                        Parms.Add(new Object[] { "dom2", nodetrace.PostingDocument.DocID });
                    }
                }


                if (nodetrace.PostingDate != null)
                {
                    sql.Append(" a.PostingDate like :nom1     and   ");
                    Parms.Add(new Object[] { "nom1", nodetrace.PostingDate + "%" });
                }
            }

            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);
        }
Ejemplo n.º 12
0
 public NodeTrace SelectById(NodeTrace data)
 {
     return((NodeTrace)base.SelectById(data));
 }
Ejemplo n.º 13
0
 public Boolean Delete(NodeTrace data)
 {
     return(base.Delete(data));
 }
        //Permite reversar un documento PR que fue posteado en el ERP,
        //solo se reversa si en el ERP no lo ha posteado
        public void ReversePurchaseReceipt(Document data)
        {
            Factory.IsTransactional = true;

            //if (data.Company.ErpConnection == null)
            //    throw new Exception("Please setup Erp Connection.");

            //SetConnectMngr(data.Company);

            Node recNode = new Node {
                NodeID = NodeType.Received
            };
            Node storedNode = new Node {
                NodeID = NodeType.Stored
            };

            try
            {
                //Update document status to Cancelled
                Status cancelled = WType.GetStatus(new Status {
                    StatusID = DocStatus.Cancelled
                });
                Status inactive = WType.GetStatus(new Status {
                    StatusID = EntityStatus.Inactive
                });


                //Cross Dock 7 - Marzo - 09
                ReverseCrossDockProcess(data);

                data.DocStatus = cancelled;
                Factory.DaoDocument().Update(data);

                //Pasa las lineas del documento a Cancelled
                IList <DocumentLine> docLines = Factory.DaoDocumentLine().Select(new DocumentLine {
                    Document = data
                });

                foreach (DocumentLine dl in docLines)
                {
                    dl.LineStatus = cancelled;
                    Factory.DaoDocumentLine().Update(dl);
                }

                //update NodeTrace
                NodeTrace qNodeTrace = new NodeTrace {
                    PostingDocument = data
                };

                //Busca todo los registros de ese documento y los reversa
                IList <NodeTrace> nodeTraceList = Factory.DaoNodeTrace().Select(qNodeTrace);

                Node voidNode = WType.GetNode(new Node {
                    NodeID = NodeType.Voided
                });

                Label curLabel;

                foreach (NodeTrace trace in nodeTraceList)
                {
                    //Crear un trace que tenga la transaccion del posting eliminado en el nodo void
                    //Registra el movimiento del nodo
                    if (trace.Node.NodeID == NodeType.Stored)
                    {
                        trace.Node       = voidNode;
                        trace.Status     = inactive;
                        trace.ModDate    = DateTime.Now;
                        trace.ModifiedBy = data.ModifiedBy;
                        trace.Comment    = "Stored: " + trace.PostingDocument.DocNumber + " Reversed";
                        Factory.DaoNodeTrace().Update(trace);

                        /*
                         * SaveNodeTrace(
                         *  new NodeTrace
                         *  {
                         *      Node = voidNode,
                         *      Document = trace.Document,
                         *      Label = trace.Label,
                         *      Quantity = trace.Quantity,
                         *      IsDebit = trace.IsDebit,
                         *      CreatedBy = trace.CreatedBy,
                         *      PostingDocument = trace.PostingDocument,
                         *      PostingUserName = trace.PostingUserName,
                         *      Status = inactive,
                         *      Comment = "Receipt " + trace.PostingDocument.DocNumber + " Reversed",
                         *      ModDate = DateTime.Now,
                         *      ModifiedBy = data.ModifiedBy,
                         *      PostingDate = trace.PostingDate,
                         *  });
                         */
                    }

                    //Reversa el trace original para poderlo postear nuevamente
                    if (trace.Node.NodeID == NodeType.Received)
                    {
                        trace.DocumentLine    = null;
                        trace.PostingDate     = null;
                        trace.PostingDocument = null;
                        trace.PostingUserName = null;
                        trace.ModifiedBy      = data.ModifiedBy;
                        trace.ModDate         = DateTime.Now;

                        Factory.DaoNodeTrace().Update(trace);


                        //Reverse labels to node trace received
                        curLabel      = trace.Label;
                        curLabel.Node = recNode;

                        try { curLabel.Notes += "Receipt " + trace.PostingDocument.DocNumber + " Reversed"; }
                        catch { }

                        curLabel.ModDate    = DateTime.Now;
                        curLabel.ModifiedBy = data.ModifiedBy;

                        Factory.DaoLabel().Update(curLabel);
                    }
                }

                Factory.Commit();
            }
            catch (Exception ex)
            {
                Factory.Rollback();
                ExceptionMngr.WriteEvent("ReversePurchaseReceipt #" + data.DocNumber, ListValues.EventType.Fatal, ex, null, ListValues.ErrorCategory.Persistence);
                throw;
                //return;
            }
        }
Ejemplo n.º 15
0
        public void PickCrossDockProduct(Document purchase, IList <DocumentBalance> crossDockBalance, SysUser picker)
        {
            Factory.IsTransactional = true;

            Node storedNode = WType.GetNode(new Node {
                NodeID = NodeType.Stored
            });
            Node node = WType.GetNode(new Node {
                NodeID = NodeType.Picked
            });
            Status status = WType.GetStatus(new Status {
                StatusID = EntityStatus.Active
            });
            DocumentType labelType = WType.GetLabelType(new DocumentType {
                DocTypeID = LabelType.ProductLabel
            });

            Bin pickingBin = WType.GetBin(new Bin {
                Location = purchase.Location, BinCode = DefaultBin.PICKING
            });

            Dictionary <Document, Label> packageLabel = new Dictionary <Document, Label>();
            Status locked = WType.GetStatus(new Status {
                StatusID = EntityStatus.Locked
            });


            try
            {
                //Solo toma las lineas de sales y deja quietas las del docuemnto de purchasing
                foreach (DocumentBalance line in crossDockBalance.Where(f => f.Document.DocType.DocClass.DocClassID == SDocClass.Shipping))
                {
                    //Valida si el documento no es nulo
                    Rules.ValidateDocument(line.Document, true);


                    if (line.Document.DocType.DocTypeID != SDocType.PickTicket)
                    {
                        //Valida si el producto esta en ese documento
                        DocumentLine docLine = new DocumentLine
                        {
                            Document   = line.Document,
                            Product    = line.Product,
                            LineStatus = new Status {
                                StatusID = DocStatus.New
                            },
                            Unit     = line.Unit,
                            Quantity = line.QtyProcessed //Quatity processed que es la que hace el cruce con el CrossDock
                        };

                        Rules.ValidateProductInDocument(docLine, true);

                        //Valida si hay saldo pendiente por procesar
                        try { Rules.ValidateBalanceQuantityInDocument(docLine, node, true, true); }
                        catch { continue; }
                    }

                    //Toma el producto del nodetrace
                    //Obtiene los labels que va a mover
                    NodeTrace sourceTrace = new NodeTrace
                    {
                        Document = purchase,
                        //Dec 7/09 no se puede forzar a que sea la misma unidad del balance //Unit = line.Unit,
                        Label = new Label {
                            Product = line.Product, Node = storedNode, Status = status
                        },
                        Status = status,
                        Node   = storedNode
                    };

                    //Obtiene las transacciones del node trace para ese documento especifico de Purchase.
                    IList <Label> labelList = Factory.DaoNodeTrace().Select(sourceTrace).Select(f => f.Label)
                                              //.Take(int.Parse(line.QtyProcessed.ToString()))
                                              .ToList();


                    if (labelList.Sum(f => f.CurrQty * f.Unit.BaseAmount) < line.QtyProcessed * line.Unit.BaseAmount)
                    {
                        Factory.Rollback();
                        throw new Exception("No quantity available in the purchase document " + purchase.DocNumber
                                            + " for product " + line.Product.FullDesc + ".\nQty Available: " + labelList.Sum(f => f.CurrQty * f.Unit.BaseAmount).ToString()
                                            + " Qty Requested: " + (line.QtyProcessed * line.Unit.BaseAmount).ToString() + " in Doc# " + line.Document.DocNumber);
                    }


                    //Package Label para el Despacho
                    if (!packageLabel.ContainsKey(line.Document))
                    {
                        packageLabel.Add(line.Document, GetPackageLabel(new Label {
                            LabelID = -1
                        }, line.Document, picker).PackLabel);
                    }


                    //Debe piquear la cantidad necesaria para suplir el SO con los labels
                    //recibidos.

                    double crQtyBal = line.QtyProcessed * line.Unit.BaseAmount; //LLevada  a la unidad basica

                    foreach (Label curLabel in labelList)
                    {
                        if (crQtyBal <= 0)
                        {
                            break;
                        }

                        //Si el Qty del label menor que lo pendiente mando todo el label
                        if (curLabel.CurrQty * curLabel.Unit.BaseAmount <= crQtyBal)
                        {
                            //Si el destino es logitico lo hace su padre, si no es producto suelto en BIN
                            curLabel.ModifiedBy = purchase.ModifiedBy;
                            curLabel.Node       = node;
                            curLabel.LastBin    = curLabel.Bin;
                            curLabel.Bin        = pickingBin;
                            curLabel.ModDate    = DateTime.Now;

                            curLabel.FatherLabel = null;
                            curLabel.FatherLabel = packageLabel[line.Document];
                            curLabel.Status      = locked;

                            SaveNodeTrace(new NodeTrace
                            {
                                Node      = node,
                                Label     = curLabel,
                                Quantity  = curLabel.CurrQty,
                                Bin       = pickingBin,
                                IsDebit   = false,
                                CreatedBy = purchase.ModifiedBy,
                                Document  = line.Document,
                                // 07 Marzo 2009
                                // En el comenttario se pone el # del PO de cross dock,
                                // este dato sirve en caso de reversion del crossdock process
                                Comment = purchase.DocNumber
                            });


                            curLabel.ShippingDocument = line.Document;
                            Factory.DaoLabel().Update(curLabel);
                            crQtyBal -= curLabel.CurrQty * curLabel.Unit.BaseAmount;
                        }

                        //Si no: disminuyo el Qty del label y hago un Increase
                        else
                        {
                            //Si el destino es logitico lo hace su padre, si no es producto suelto en BIN
                            curLabel.ModifiedBy = purchase.ModifiedBy;
                            curLabel.ModDate    = DateTime.Now;
                            curLabel.CurrQty   -= crQtyBal;
                            Factory.DaoLabel().Update(curLabel);

                            //Increase The Pick Node

                            Node pickNode = WType.GetNode(new Node {
                                NodeID = NodeType.Picked
                            });

                            DocumentLine crdLine = new DocumentLine {
                                Document  = line.Document,
                                Product   = line.Product,
                                Quantity  = crQtyBal,
                                CreatedBy = purchase.ModifiedBy
                            };

                            Label pickedLabel = IncreaseQtyIntoBin(crdLine, pickNode, Rules.GetBinForNode(pickNode, purchase.Location),
                                                                   "Picking Dest", true, DateTime.Now, null, curLabel);

                            pickedLabel.FatherLabel      = packageLabel[line.Document];
                            pickedLabel.Status           = locked;
                            pickedLabel.ShippingDocument = line.Document;

                            Factory.DaoLabel().Update(pickedLabel);

                            //Factory.Commit();
                        }
                    }



                    /*
                     * //Acutualiza la ubicacion Nuevo Bin
                     * foreach (Label curLabel in labelList)
                     * {
                     *  //Si el destino es logitico lo hace su padre, si no es producto suelto en BIN
                     *  curLabel.ModifiedBy = purchase.ModifiedBy;
                     *  curLabel.Node = node;
                     *  curLabel.LastBin = curLabel.Bin;
                     *  curLabel.Bin = pickingBin;
                     *
                     *  SaveNodeTrace(new NodeTrace
                     *  {
                     *      Node = node,
                     *      Label = curLabel,
                     *      Quantity = curLabel.CurrQty,
                     *      Bin = pickingBin,
                     *      IsDebit = false,
                     *      CreatedBy = purchase.ModifiedBy,
                     *      Document = line.Document,
                     *      // 07 Marzo 2009
                     *      // En el comenttario se pone el # del PO de cross dock,
                     *      // este dato sirve en caso de reversion del crossdock process
                     *      Comment = purchase.DocNumber
                     *  });
                     *
                     *  curLabel.FatherLabel = null;
                     *  Factory.DaoLabel().Update(curLabel);
                     * }
                     */
                }

                Factory.Commit();


                //Actualiza el estado de los documentos de shiiping a CrossDock
                foreach (Document doc in crossDockBalance.Where(f => f.Document.DocType.DocClass.DocClassID == SDocClass.Shipping).Select(f => f.Document).Distinct())
                {
                    doc.CrossDocking = true;
                    Factory.DaoDocument().Update(doc);
                }

                Factory.Commit();
            }
            catch (Exception ex)
            {
                Factory.Rollback();
                ExceptionMngr.WriteEvent("PickCrossDockProduct:", ListValues.EventType.Fatal, ex, null, ListValues.ErrorCategory.Business);
                throw new Exception(WriteLog.GetTechMessage(ex));
            }
        }
        //This method revisa si el recibo pertenece a aun procesos de cross dock
        //y Anula el docuemnto de crossdock y sus lineas, y Unpick las cantidades
        //piqueadas para los documentos de ventas
        private void ReverseCrossDockProcess(Document receipt)
        {
            if (receipt.CrossDocking != true)
            {
                return;
            }

            try
            {
                Factory.IsTransactional = true;

                Status cancelled = WType.GetStatus(new Status {
                    StatusID = DocStatus.Cancelled
                });

                TaskDocumentRelation taskRel = new TaskDocumentRelation
                {
                    IncludedDoc = receipt,
                    TaskDoc     = new Document {
                        DocType = new DocumentType {
                            DocTypeID = SDocType.CrossDock
                        }
                    }
                };


                IList <TaskDocumentRelation> listTask = Factory.DaoTaskDocumentRelation().Select(taskRel)
                                                        .Where(f => f.TaskDoc.DocStatus.StatusID != DocStatus.Cancelled).ToList();

                //Cuando no tiene docuemnto asociado
                if (listTask == null || listTask.Count == 0)
                {
                    return;
                }

                //Si tiene docuemnto asociado continua.
                //1. Cancela el documento cross dock y sus lineas.
                Document crossDockDocument = listTask[0].TaskDoc;
                crossDockDocument.DocStatus = cancelled;
                WType.GetStatus(new Status {
                    StatusID = DocStatus.Cancelled
                });
                crossDockDocument.Comment   += "\nDocument cancelled due the reversion of receipt " + receipt.DocNumber;
                crossDockDocument.ModifiedBy = receipt.ModifiedBy;
                crossDockDocument.ModDate    = DateTime.Now;

                foreach (DocumentLine line in crossDockDocument.DocumentLines)
                {
                    line.LineStatus = cancelled;
                    Factory.DaoDocumentLine().Update(line);
                }

                //Actualizando el documento
                Factory.DaoDocument().Update(crossDockDocument);

                //Reversando las cantidades piqeuadas para suplir los documentos de ventas.
                //Obtiene las cantidades que fueron piquedas por cada liena de cada documento de vantas

                //Node traces que fueron afectados con ese recibo.
                NodeTrace sourceTrace = new NodeTrace
                {
                    Node = new Node {
                        NodeID = NodeType.Picked
                    },
                    Status = new Status {
                        StatusID = EntityStatus.Active
                    },
                    Comment = receipt.CustPONumber
                };

                IList <NodeTrace> nodes = Factory.DaoNodeTrace().Select(sourceTrace);

                Node labelNode = Factory.DaoNode().Select(new Node {
                    NodeID = NodeType.Stored
                }).First();

                //revesar todo lo piqueado a main
                Bin bin = WType.GetBin(new Bin {
                    Location = receipt.Location, BinCode = DefaultBin.PUTAWAY
                });

                Status status = Factory.DaoStatus().Select(new Status {
                    StatusID = EntityStatus.Active
                }).First();

                ReverseNodeTrace(nodes, receipt.ModifiedBy, labelNode, bin, status);

                Factory.Commit();
            }
            catch (Exception ex)
            {
                Factory.Rollback();

                ExceptionMngr.WriteEvent("ReverseCrossDockProcess:Doc#" + receipt.DocNumber, ListValues.EventType.Fatal, ex, null, ListValues.ErrorCategory.Business);
                throw;
            }
        }
Ejemplo n.º 17
0
        //23 Marzo 09 - Update of tracking data
        private void UpdateTrackData()
        {
            try
            {
                //Carga en la lista de labels, los labels que pertenecen a este documento para incluir su track option
                NodeTrace patterTrace = new NodeTrace
                {
                    Document = View.Model.Document,
                    Node = View.Model.Node,
                    Status = new Status { StatusID = EntityStatus.Active },
                    Label = new Label {  Product = View.Model.Product, Status = new Status { StatusID = EntityStatus.Active } }
                };

                //Lista de labels recibidos
                View.Model.ManualTrackList = service.GetNodeTrace(patterTrace)
                    .Select(f => f.Label).ToList();

                View.ManualTrackList.Items.Refresh();
                if (View.Model.ManualTrackList.Count == 1)
                    View.ManualTrackList.SelectedIndex = 0;

                //Seleccionar los limites de ingreso de datos, cuenta los labels que tengan
                //el dato en blanco indicando que estan pendientes.    
                TrackOption trackName = null; 
                string curTrackVal = ""; //guarda el cur value delegate track data
                int tmpCount = 0;


                //Calculando el remaining depende si es unico el track o no.
                if (View.Model.MaxTrackQty == 1) //Si es Unico
                {
                    try { View.Model.RemainingQty = (int)View.Model.ManualTrackList.Where(f => f.LabelType.DocTypeID == LabelType.ProductLabel).Sum(f => f.CurrQty); }
                    catch { }
                    
                    View.TxtQtyTrack.Text = View.Model.MaxTrackQty.ToString();
                    View.Model.TrackUnit = View.Model.Product.BaseUnit;
                    View.TxtQtyTrack.IsEnabled = false;

                }
                else //Si no.
                {

                    for (int i = 0; i < View.Model.TrackData.Count; i++)
                    {
                        tmpCount = 0;
                        trackName = View.Model.TrackData[i].TrackOption;

                        //Verison Anterior
                        //Obtiene los trackoption missing.
                        //tmpCount = View.Model.ManualTrackList
                        //    .Where(f => f.GetType().GetProperty(trackName).GetValue(f, null) == null
                        //        || f.GetType().GetProperty(trackName).GetValue(f, null).ToString().Trim() == "")
                        //        .Count();

                        //version 14 abril 2009, trackOption del label en otra tabla
                        foreach (Label trLabel in View.Model.ManualTrackList)
                        {

                            try { curTrackVal = trLabel.TrackOptions.Where(f => f.TrackOption.RowID == trackName.RowID).First().TrackValue; }
                            catch { curTrackVal = ""; }

                            if (string.IsNullOrEmpty(curTrackVal))
                                tmpCount++;
                        }

                        //Vuelve la cantidad pendiente como la mayor de las dos, Aplica para no UNIQUE track
                        View.Model.RemainingQty = tmpCount > View.Model.RemainingQty ? tmpCount : View.Model.RemainingQty;
                    }

                    View.TxtQtyTrack.Text = View.Model.RemainingQty.ToString();
                    View.TxtQtyTrack.IsEnabled = true;
                }


                //Cantidad pendiente por poner el tracking
                //if (View.Model.MaxTrackQty == 1)
                //{ //Si es unique debe pedir 1 a 1 hasta todas las unidades basicas
                //    View.TxtQtyTrack.Text = View.Model.MaxTrackQty.ToString();
                //    View.Model.TrackUnit = View.Model.Product.BaseUnit;
                //    View.TxtQtyTrack.IsEnabled = false;
                //}
                //else
                //{
                //    View.TxtQtyTrack.Text = View.Model.RemainingQty.ToString();
                //    View.TxtQtyTrack.IsEnabled = true;
                //}

            }
            catch (Exception ex)
            {
                Util.ShowError("Problem loading received list.\n" + ex.Message);
                return;
            }

        }
Ejemplo n.º 18
0
 public IList<NodeTrace> GetNodeTrace(NodeTrace data)
 {
     try
     {
         SetService(); 
         return SerClient.GetNodeTrace(data);
     }
     catch { return null;  }
     finally
     {
         if (SerClient.State == CommunicationState.Faulted)
             SerClient.Abort(); 
         else
             SerClient.Close();
     }
 }
Ejemplo n.º 19
0
        private void PrintLabels()
        {
            //if (View.PrinterList.SelectedItem == null)
                //return;


            try
            {
                //string printerName = View.PrinterList.SelectedItem != null ? ((Printer)View.PrinterList.SelectedItem).PrinterName : "";


                NodeTrace patterTrace = new NodeTrace
                {
                    Document = View.Model.Document,
                    Node = new Node { NodeID = NodeType.Stored }, //View.Model.Node,
                    Status = new Status { StatusID = EntityStatus.Active },
                    Label = new Label
                    {
                        Node = new Node { NodeID = NodeType.Stored },
                        Product = View.Model.KitProduct
                    }
                };


                List<Label> labelsToPrint = service.GetNodeTrace(patterTrace)
                    .Select(f => f.Label).Where(f => f.FatherLabel == null && f.Product.PrintLabel == true).ToList();


                if (labelsToPrint == null || labelsToPrint.Count == 0)
                {
                    pw.Close();
                    return;
                }

                /*
                LabelTemplate defTemplate;
                try
                {
                    defTemplate = service.GetLabelTemplate(
                        new LabelTemplate { Header = WmsSetupValues.AssemblyLabelTemplate }).First();
                }
                catch { 
                    Util.ShowError("Label " + WmsSetupValues.AssemblyLabelTemplate + " does not exists, or no label definde for Kit/Assembly.");
                    return;
                }

                ReportMngr.PrintLabelsInBatch(defTemplate, (Printer)View.PrinterList.SelectedItem, labelsToPrint);
                ReportMngr.PrintLabelsInBatch(defTemplate, new Printer { PrinterName = WmsSetupValues.DEFAULT }, labelsToPrint);
                */

                //Usar el Facade para esto.

                
                //Definicion del Template a Imprimier
                string printTemplate;
                try
                {
                    printTemplate = View.Model.KitProduct.DefaultTemplate != null ? View.Model.KitProduct.DefaultTemplate.Header : WmsSetupValues.AssemblyLabelTemplate;
                }
                catch { printTemplate = WmsSetupValues.AssemblyLabelTemplate; }


                service.PrintLabelsFromDevice(WmsSetupValues.DEFAULT, printTemplate, labelsToPrint);

            }

            catch (Exception ex) { pw.Close();  Util.ShowError("Error imprimiendo. " + ex.Message); }

        }
Ejemplo n.º 20
0
 public void DeleteNodeTrace(NodeTrace data)
 {
     try {
     SetService();  SerClient.DeleteNodeTrace(data); }
     finally
     {
         SerClient.Close();
         if (SerClient.State == CommunicationState.Faulted)
         SerClient.Abort(); 
     }
 }
Ejemplo n.º 21
0
 public NodeTrace Save(NodeTrace data)
 {
     return((NodeTrace)base.Save(data));
 }