Exemple #1
0
        public void UpdateLineSnaphot()
        {
            try
            {
                this.lineSnapshotTable.AcceptChanges();
                this.lineSnapshotTable.Clear();

                foreach (Product product in this.productBuffer)
                {
                    this.lineSnapshotTable.AddLineSnapshotRow(
                        -1,
                        product.Owner.Id,
                        product.Id,
                        0,
                        this.detroitDataSet.LineId,
                        product.Name,
                        0,
                        DateTime.Now,
                        product.Router.State
                        );
                }

                foreach (Product product in this.productsOnLine)
                {
                    List <string> productStationNames = product.Router.FindStateStations();
                    foreach (string stationName in productStationNames)
                    {
                        IStation station = this.lineDispatcher.GetStationByName(stationName);
                        if (station != null && !product.Router.IsFinalState)
                        {
                            int pState = Convert.ToInt32(station.ProductPosition(product));

                            this.lineSnapshotTable.AddLineSnapshotRow(
                                station.Id,
                                product.Owner.Id,
                                product.Id,
                                pState,
                                this.detroitDataSet.LineId,
                                product.Name,
                                0,
                                DateTime.Now,
                                product.Router.State
                                );
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                this.myLog.LogAlert(AlertType.Error, this.detroitDataSet.LineId.ToString(), ex.TargetSite.ToString(),
                                    ex.Source.ToString(), ex.Message.ToString(), "system");
            }
        }
Exemple #2
0
        private void updateProductInLineSnapshot(Product product)
        {
            if (product != null)
            {
                //Console.WriteLine("Handler: On product moved. Product = " + product.Name);

                try
                {
                    //update products in buffer
                    string    select           = "BatchId = " + product.Owner.Id.ToString() + " AND " + "ProductNummer = " + product.Id.ToString();
                    DataRow[] lsRows           = this.lineSnapshotTable.Select(select);
                    int       fTaktSecondsLeft = 0;

                    if (lsRows.Count() > 0)
                    {
                        DataRow lsRow = lsRows[0];
                        fTaktSecondsLeft = (lsRow.RowState != DataRowState.Deleted) ? Convert.ToInt32(lsRow["TaktSecondsLeft"]) : 0;

                        foreach (DataRow oldRow in lsRows)
                        {
                            if (oldRow.RowState != DataRowState.Deleted)
                            {
                                oldRow.Delete();
                            }
                        }

                        //x this.lineSnapshotTableAdapter.Update(this.lineSnapshotTable);
                        //x this.lineSnapshotTable.AcceptChanges();

                        if (!product.Router.IsFinalState)
                        {
                            List <string> productStationNames = product.Router.FindStateStations();
                            foreach (string stationName in productStationNames)
                            {
                                IStation station = this.lineDispatcher.GetStationByName(stationName);
                                int      pState  = Convert.ToInt32(station.ProductPosition(product));

                                if (station != null && product != null)
                                {
                                    this.lineSnapshotTable.AddLineSnapshotRow(
                                        station.Id,
                                        product.Owner.Id,
                                        product.Id,
                                        pState,
                                        this.detroitDataSet.LineId,
                                        product.Name,
                                        fTaktSecondsLeft,
                                        DateTime.Now,
                                        product.Router.State
                                        );
                                }
                            }

                            //x this.lineSnapshotTableAdapter.Update(this.lineSnapshotTable);
                            //x this.lineSnapshotTable.AcceptChanges();
                        }
                    }
                }
                catch (DBConcurrencyException ex)
                {
                    //Console.WriteLine(ex);
                    this.myLog.LogAlert(AlertType.Error, this.detroitDataSet.LineId.ToString(), ex.TargetSite.ToString(), ex.Source, ex.ToString(), "system");
                }
                catch (Exception ex)
                {
                    //Console.WriteLine(ex);
                    this.myLog.LogAlert(AlertType.Error, this.detroitDataSet.LineId.ToString(), ex.TargetSite.ToString(), ex.Source, ex.Message, "system");
                }
            }
        }