Exemplo n.º 1
0
 public IEnumerable<SequencingStationSetting> GetSequenctionStationSettings()
 {
     PartSequencingDataContext dbSeq = new PartSequencingDataContext();
     var settings = (from s in dbSeq.SequencingStationSettings.Where(s => s.Obsolete == false)
                     select s).OrderBy(g=>g.StationOrder).ToList();
     return settings;
 }
Exemplo n.º 2
0
 public IEnumerable<BaseSequencingStationOffset> GetBaseSequencingStationOffsets()
 {
     PartSequencingDataContext dbSeq = new PartSequencingDataContext();
     var stations = (from s in dbSeq.BaseSequencingStationOffsets
                     select s).ToList();
     return stations;
 }
Exemplo n.º 3
0
        public IEnumerable<SequencingStation> GetSequencingStationsByType(string type)
        {
            PartSequencingDataContext dbSeq = new PartSequencingDataContext();
            PlasticSeqDatabase dbPlasticSeq = new PlasticSeqDatabase();

            if (type.ToUpper().Equals("FRONT"))
            {
                return (from s in SequencingSettingsCacheManager.SequencingStationSettings.Where(s => s.LineId == 1 && s.Obsolete == false)
                        where s.Obsolete == false
                        select new SequencingStation
                        {
                            Description = s.Description,
                            ScheduleAvailable = false,
                            ItemsWaiting = 0,
                            ItemsWaitingPercentage = 0,
                            Id = s.Id,
                            SequencingLocation = dbSeq.SequencingLocations.Where(x => x.Id == s.SequencingLocationId).Single(),
                            Line = dbSeq.Lines.Where(x => x.Id == s.LineId).Single(),
                            Station = dbPlasticSeq.GetStation((int)s.StationId),
                            StationOrder = (int)s.StationOrder,
                            BoxPerSchedule = (int)s.BoxPerSchedule,
                            BoxQty = (int)s.BoxQty,
                            MessageFormat = s.MessageFormat,
                            Obsolete = (bool)s.Obsolete,
                            PartsPerBox = (int)s.PartsPerBox,
                            SeatOptions = (int)s.SeatOptions,
                            SeatOptions2Check = (int)s.SeatOptions2Check,
                            BaseStation = SequencingSettingsCacheManager.SequencingStationSettings.Where(i => i.Id == SequencingSettingsCacheManager.BaseSequencingStationOffsets.Where(x => x.LineId == s.LineId).Single().SequencingStationSettingsId).Single(),
                            Offset = (int)s.Offset,
                        }).ToList();
            }
            else if (type.ToUpper().Equals("REAR"))
            {
                return (from s in SequencingSettingsCacheManager.SequencingStationSettings.Where(s => (s.LineId == 2 || s.LineId == 3) && s.Obsolete == false)
                        where s.Obsolete == false
                        select new SequencingStation
                        {
                            Description = s.Description,
                            ScheduleAvailable = false,
                            ItemsWaiting = 0,
                            ItemsWaitingPercentage = 0,
                            Id = s.Id,
                            SequencingLocation = dbSeq.SequencingLocations.Where(x => x.Id == s.SequencingLocationId).Single(),
                            Line = dbSeq.Lines.Where(x => x.Id == s.LineId).Single(),
                            Station = dbPlasticSeq.GetStation((int)s.StationId),
                            StationOrder = (int)s.StationOrder,
                            BoxPerSchedule = (int)s.BoxPerSchedule,
                            BoxQty = (int)s.BoxQty,
                            MessageFormat = s.MessageFormat,
                            Obsolete = (bool)s.Obsolete,
                            PartsPerBox = (int)s.PartsPerBox,
                            SeatOptions = (int)s.SeatOptions,
                            SeatOptions2Check = (int)s.SeatOptions2Check,
                            BaseStation = SequencingSettingsCacheManager.SequencingStationSettings.Where(i => i.Id == SequencingSettingsCacheManager.BaseSequencingStationOffsets.Where(x => x.LineId == s.LineId).Single().SequencingStationSettingsId).Single(),
                            Offset = (int)s.Offset,
                        }).ToList();
            }

            return null;
        }
Exemplo n.º 4
0
        public SequencingStation GetSequencingStationSettingsById(int id)
        {
            PartSequencingDataContext dbSeq = new PartSequencingDataContext();
            MesDataContext dbMes = new MesDataContext();

            var result = (from s in SequencingSettingsCacheManager.SequencingStationSettings where s.Id == id select s).Single();

            var baseStation = SequencingSettingsCacheManager.BaseSequencingStationOffsets.Where(x => x.LineId == result.LineId).Single();

            
           var setting = new SequencingStation
            {
                Description = result.Description,
                Id = result.Id,
                SequencingLocation = dbSeq.SequencingLocations.Where(x => x.Id == result.SequencingLocationId).Single(),
                Line = dbSeq.Lines.Where(x => x.Id == result.LineId).Single(),
                Station = GetStation((int)result.StationId),
                StationOrder = (int)result.StationOrder,
                BoxPerSchedule = (int)result.BoxPerSchedule,
                BoxQty = (int)result.BoxQty,
                MessageFormat = result.MessageFormat,
                Obsolete = (bool)result.Obsolete,
                PartsPerBox = (int)result.PartsPerBox,
                SeatOptions = (int)result.SeatOptions,
                SeatOptions2Check = (int)result.SeatOptions2Check,
                Status = false,
                Offset = (int)result.Offset,
                BaseStation = SequencingSettingsCacheManager.SequencingStationSettings.Where(x => x.Id == baseStation.SequencingStationSettingsId).Single()
            };

            return setting;
        }
Exemplo n.º 5
0
        public IEnumerable<SequencingLocation> GetSequencingLocations()
        {
            PartSequencingDataContext dbSeq = new PartSequencingDataContext();
            var locations = (from a in dbSeq.SequencingLocations.Where(s => s.Obsolete == false)
                          select a).ToList();

            return locations;
        }
Exemplo n.º 6
0
        public IEnumerable<Line> GetLines()
        {
            PartSequencingDataContext dbSeq = new PartSequencingDataContext();
            var lines = (from a in dbSeq.Lines
                         select a).ToList();

            return lines;
        }
Exemplo n.º 7
0
        public IEnumerable<TempBuffer> GetSequencingBuffer(SequencingStation station)
        {
            PartSequencingDataContext dbSeq = new PartSequencingDataContext();
            HP_MESDataContext dbMes = new HP_MESDataContext();
            SequencingDatabase db = new SequencingDatabase();

            List<TempBuffer> lineBuffer = null;

            string groupLine = station.SequencingLocation.LineGroup.Trim();
            int lineId = station.Line.Id;
            int locationId = station.SequencingLocation.Id;
            if (station.SequencingLocation.ParentId == null)
            {
                lineBuffer = (from s in dbSeq.SEQ_SP_GetSequencingBufferBySeqId(station.Id)
                              select new TempBuffer
                              {
                                  Group = groupLine,
                                  //ItemNumber = "1800VR",
                                  ItemNumber = s.ItemNumber.Trim(),
                                  ItemType = s.ItemType.Trim(),
                                  JobId = (int)s.JobId,
                                  OrderId = (int)s.OrderId,
                                  OrderStatus = (int)s.OrderStatus,
                                  Region = s.Region.Trim(),
                                  LineId = (int)s.LineId,
                                  OrderNumber = s.OrderNumber,
                                  BuildDTM = s.BuildDTM == null ? "" : s.BuildDTM.Value.ToString("mm/dd/yyyy hh:mm:ss tt")
                              }).ToList();
            }
            else
            {

                lineBuffer = (from s in dbSeq.IWS_GetSequencingStationQueueByLocationId(locationId)
                              select new TempBuffer
                              {
                                  ScheduleNum = (int)s.ScheduleNum,
                                  BoxNum = (int)s.BoxNum,
                                  OrderNumber = s.OrderNumber == null ? "" : s.OrderNumber.Trim(),
                                  Group = groupLine,
                                  //ItemNumber = "1420CF",
                                  ItemNumber = s.ItemNumber.Trim(),
                                  ItemType = s.ItemType.Trim(),
                                  JobId = (int)s.JobId,
                                  OrderId = (int)s.OrderId,
                                  OrderStatus = (int)s.OrderStatus,
                                  Region = s.Region.Trim(),
                                  LineId = lineId
                              }).ToList();

            }

            return lineBuffer;
        }
Exemplo n.º 8
0
        public bool IsScheduleReadyBySequencingStationId(int id)
        {
            PartSequencingDataContext dbSeq = new PartSequencingDataContext();
            SequencingFactory maker = new SequencingFactory();
            HP_MESDataContext dbMes = new HP_MESDataContext();

            var seqStations = dbSeq.SequencingStationSettings.Where(i => i.SequencingLocationId == id).ToList();
            if (seqStations.Count() > 0)
            {
                var seqStation = seqStations.FirstOrDefault();
                if (seqStation != null)
                {
                    var station = maker.UpdateNextBoxBySequencingId(seqStation.Id);
                    if (!station.Status)
                    {
                        if (station.ItemsWaiting != 0)
                            return false;
                    }
                    
                    var scheduleStatus = dbSeq.SequencingStationLookups.Where(s => s.SequenceStationSettingsId == station.Id).FirstOrDefault();
                    var tokens = MessageTokensCacheManager.MessageTokens.Where(s => s.LineId == station.Line.Id || s.LineId == 4).ToList();

                    var lineBuffer = maker.GetSequencingBuffer(station);

                    SequencingTrackingItem lastItem = null;
                    var tracking = maker.GetSequencingHistory(station);

                    if (tracking.Any())
                        lastItem = tracking.OrderByDescending(i => i.OrderId).First();

                    var lastJobId = Int32.MinValue;

                    if (lastItem != null)
                        lastJobId = lastItem.OrderId;

                    if (lineBuffer != null)
                    {
                        var itemsinbox = station.PartsPerBox;
                        var boxperschedule = station.BoxPerSchedule;
                        var itemsinschedule = itemsinbox * boxperschedule;

                        var jobs = lineBuffer.Where(i => i.OrderId >= station.NextBox.OrderId).Take(itemsinschedule).ToList();
                        if (itemsinschedule == jobs.Count())
                            return true;
                    }
                }
            }

            return false;
        }
Exemplo n.º 9
0
 public dynamic GetScheduleNumByLocationId(int id)
 {
     PartSequencingDataContext dbSeq = new PartSequencingDataContext();
     SequencingDatabase db = new SequencingDatabase();
     var seqSettings = SequencingSettingsCacheManager.SequencingStationSettings;
     if (seqSettings.Any())
     {
         var station = seqSettings.Where(s => s.SequencingLocationId == id && s.Obsolete == false).FirstOrDefault();
         if (station != null)
         {
             var lookup = dbSeq.SequencingStationLookups.Where(s => s.SequenceStationSettingsId == station.Id).FirstOrDefault();
             if (lookup != null)
                 return new { ScheduleNum = lookup.NextScheduleNum };
         }
     }
     return new { ScheduleNum = 0 };
 }
Exemplo n.º 10
0
        public void UpdateSequencingStationSettingsById(SequencingStation newSetting)
        {
            PartSequencingDataContext db = new PartSequencingDataContext();
            var setting = (from s in db.SequencingStationSettings where s.Id == newSetting.Id select s).Single();
            setting.BoxPerSchedule = newSetting.BoxPerSchedule;
            setting.BoxQty = newSetting.BoxQty;
            setting.Description = newSetting.Description;
            setting.MessageFormat = newSetting.MessageFormat;
            setting.Obsolete = newSetting.Obsolete;
            setting.PartsPerBox = newSetting.PartsPerBox;
            setting.SeatOptions = newSetting.SeatOptions;
            setting.SeatOptions2Check = newSetting.SeatOptions2Check;
            setting.StationOrder = newSetting.StationOrder;
            setting.Offset = newSetting.Offset;
            db.SubmitChanges();

            SequencingSettingsCacheManager.RefreshSequencingStationSettings();
        }
Exemplo n.º 11
0
        public IEnumerable<Statistic> ProductionSummary (int locationId) 
        {
            MesDataContext db = new MesDataContext();
            PartSequencingDataContext dbSeq = new PartSequencingDataContext();

            var station = dbSeq.SequencingLocations.Where(s => s.Id == locationId).SingleOrDefault();
            if (station == null)
                return null;

            var results = (from s in db.GetProductionSummaryByGroup(station.LineGroup.Trim()).Where(i=>i.PointValue != null && i.PointValue != "")
                           select new Statistic
                           {
                               Name = s.PointName.Trim(),
                               Value = s.PointValue == null ? "" : s.PointValue.Trim(),
                           }).ToList();

            return results;
        }
Exemplo n.º 12
0
        public async Task<List<PlasticSeqSchedule>> GetPlasticSeqSchedulesByLocationIdAsync(int locationId)
        {
            #region Get Plastic Seq Schedules By Location Id Async
            List<PlasticSeqSchedule> schedules = new List<PlasticSeqSchedule>();

            PartSequencingDataContext dbSeq = new PartSequencingDataContext();
            var seqStations = (from s in SequencingSettingsCacheManager.SequencingStationSettings
                               where s.SequencingLocationId == locationId
                               select s).ToList();

            await Task.Run(() => Parallel.ForEach(seqStations, s =>
            {
                var schedule = GetPlasticSeqScheduleBySequencingStationId(s.Id);
                schedules.Add(schedule);
            }));

            return schedules.OrderBy(s => s.SequencingStation.StationOrder).ToList();
            #endregion
        }
Exemplo n.º 13
0
        public IEnumerable<SequencingTrackingItem> GetAdminSequencingHistory(SequencingStation station)
        {
            PartSequencingDataContext dbSeq = new PartSequencingDataContext();

            var tracking = (from s in dbSeq.SEQ_SP_GetSequencingHistoryEOLBySeqId(station.Id)
                            select new SequencingTrackingItem
                            {
                                BoxNum = s.BoxNum,
                                DTM = s.DTM,
                                ItemNumber = s.ItemNumber,
                                ItemType = s.ItemType,
                                ScheduleNum = s.ScheduleNum,
                                OrderId = s.OrderId,
                                SequencingStationSettingsId = s.SequencingStationSettingsId,
                                SequencingTrackingHistoryDetailsId = s.SequencingTrackingHistoryDetailId,
                                SequencingTrackingHistoryId = s.SequencingTrackingHistoryId,
                                Type = (int)s.Type
                            }).ToList();
            return tracking;
        }
        //public IEnumerable<TempBuffer> GetSequencingBuffer(SequencingStation station)
        //{
        //    PartSequencingDataContext dbSeq = new PartSequencingDataContext();
        //    MesDataContext dbMes = new MesDataContext();
        //    SequencingDatabase db = new SequencingDatabase();

        //    var lineBuffer = (from s in dbSeq.TempBuffers.Where(l => (l.Group.Trim() == station.SequencingLocation.LineGroup.Trim())).ToList().OrderBy(s => s.OrderId).ToList()
        //                      select s).ToList();

        //    return lineBuffer;
        //}

        #region Get Sequencing History
        public IEnumerable<SequencingTrackingItem> GetSequencingHistory(SequencingStation station)
        {
            PartSequencingDataContext dbSeq = new PartSequencingDataContext();

            var tracking = (dbSeq.SequencingTrackingHistoryDetails.Where(
                    i => i.SequencingStationSettingsId == station.Id).Join(
                    dbSeq.SequencingTrackingHistories, th => th.Id,
                    ti => ti.SequencingTrackingHistoryDetailId, (th, ti) => new SequencingTrackingItem
                    {
                        OrderNumber = ti.OrderNumber,
                        BoxNum = th.BoxNum,
                        DTM = th.DTM,
                        ItemNumber = ti.ItemNumber,
                        ItemType = ti.ItemType,
                        ScheduleNum = th.ScheduleNum,
                        OrderId = ti.OrderId,
                        SequencingStationSettingsId = th.SequencingStationSettingsId,
                        SequencingTrackingHistoryDetailsId = (int)ti.SequencingTrackingHistoryDetailId,
                        SequencingTrackingHistoryId = ti.Id,
                        Type = (int)th.Type
                    })).ToList();

            return tracking;
        }
Exemplo n.º 15
0
        public TrimSchedule GetTrimSchedule(int id)
        {
            PartSequencingDataContext dbSeq = new PartSequencingDataContext();
            SequencingFactory factory = new SequencingFactory();
            HP_MESDataContext dbMes = new HP_MESDataContext();
            ItemDetailsFactory itemDetailsModel = new ItemDetailsFactory();
            TrimSchedule trimSchedule = null;
            List<Seat> offsetSeats = null;
            List<Seat> currentjobs = null;
            var seqMessageProcessor = new SeqMessageProcessor();

            var seqStations = dbSeq.SequencingStationSettings.Where(i => i.SequencingLocationId == id).ToList();
            if (seqStations.Count() > 0)
            {
                var seqStation = seqStations.FirstOrDefault();
                if (seqStation != null)
                {
                    var station = factory.UpdateNextBoxBySequencingId(seqStation.Id);
                    var scheduleStatus = dbSeq.SequencingStationLookups.Where(s => s.SequenceStationSettingsId == station.Id).FirstOrDefault();
                    var tokens = MessageTokensCacheManager.MessageTokens.Where(s => s.LineId == station.Line.Id || s.LineId == 4).ToList();

                    var lineBuffer = factory.GetSequencingBuffer(station);

                    if (lineBuffer != null)
                    {
                        var itemsinbox = station.PartsPerBox;
                        var boxperschedule = station.BoxPerSchedule;
                        var itemsinschedule = itemsinbox * boxperschedule;
                        var boxqty = station.BoxQty;

                        trimSchedule = new TrimSchedule();

                        var tracking = factory.GetSequencingHistory(station);
                        if (tracking.Any()) 
                        {
                            var lastTrackItem = tracking.LastOrDefault();
                            if (lastTrackItem != null)
                            {
                                if (lastTrackItem.Type == 2)
                                {
                                    var lastRealJob = tracking.Where(o => o.OrderId < lastTrackItem.OrderId).OrderByDescending(f => f.OrderId).Where(x => x.ScheduleNum > 0).FirstOrDefault();

                                    if (lastRealJob != null)
                                    {
                                        var unassignedBuffer = tracking.Where(o => o.OrderId <= lastTrackItem.OrderId && o.OrderId >lastRealJob.OrderId).OrderBy(f => f.OrderId).ToList();
                                        if (unassignedBuffer.Count() > 0)
                                        {
                                            var offsetjobs = (from j in unassignedBuffer
                                                              select new Seat
                                                              {
                                                                  OrderStatus = (int)j.OrderStatus,
                                                                  Complete = false,
                                                                  TrimStyle = GetOptionValue(j.ItemNumber.Trim(), 100),
                                                                  Colour = GetOptionValue(j.ItemNumber.Trim(), 101),
                                                                  OrderNumber = j.OrderNumber == null ? "" : j.OrderNumber.Trim(),
                                                                  ItemNumber = j.ItemNumber.Trim(),
                                                                  ItemType = j.ItemType.Trim(),
                                                                  DescLine1 = j.ItemNumber.Trim(),
                                                                  DescLine2 = seqMessageProcessor.GetSequencingMessage(station, j.ItemNumber.Trim(), tokens),
                                                                  JobId = (int)j.JobId,
                                                                  OrderId = j.OrderId,
                                                                  Item = itemDetailsModel.GetItemInfoByLineId(j.ItemNumber.Trim(), station.Line.Id)
                                                              }).ToList();

                                            offsetSeats = offsetjobs;
                                        }
                                    }

                                }
                            }


                        }


                        if (station.SequencingLocation.ParentId == null)
                        {
                            currentjobs = (from j in lineBuffer.Where(i => i.OrderId >= station.NextBox.OrderId).Take(itemsinschedule).ToList()
                                           select new Seat
                                           {
                                               OrderStatus = (int)j.OrderStatus,
                                               Complete = false,
                                               TrimStyle = GetOptionValue(j.ItemNumber.Trim(), 100),
                                               Colour = GetOptionValue(j.ItemNumber.Trim(), 101),
                                               OrderNumber = j.OrderNumber == null ? "" : j.OrderNumber.Trim(),
                                               ItemNumber = j.ItemNumber.Trim(),
                                               ItemType = j.ItemType.Trim(),
                                               DescLine1 = j.ItemNumber.Trim(),
                                               DescLine2 = seqMessageProcessor.GetSequencingMessage(station, j.ItemNumber.Trim(), tokens),
                                               JobId = (int)j.JobId,
                                               OrderId = j.OrderId,
                                               Item = itemDetailsModel.GetItemInfoByLineId(j.ItemNumber.Trim(), station.Line.Id),
                                           }).OrderBy(s => s.OrderId).ToList();
                        }
                        else //from queue
                        {
                            currentjobs = (from j in lineBuffer.Where(i => i.OrderId >= station.NextBox.OrderId).Take(itemsinschedule).ToList()
                                            select new Seat
                                            {
                                                ScheduleNum = j.ScheduleNum,
                                                BoxNum = j.BoxNum,
                                                OrderStatus = (int)j.OrderStatus,
                                                Complete = false,
                                                TrimStyle = GetOptionValue(j.ItemNumber.Trim(), 100),
                                                Colour = GetOptionValue(j.ItemNumber.Trim(), 101),
                                                OrderNumber = j.OrderNumber == null ? "" : j.OrderNumber.Trim(),
                                                ItemNumber = j.ItemNumber.Trim(),
                                                ItemType = j.ItemType.Trim(),
                                                DescLine1 = j.ItemNumber.Trim(),
                                                DescLine2 = seqMessageProcessor.GetSequencingMessage(station, j.ItemNumber.Trim(), tokens),
                                                JobId = (int)j.JobId,
                                                OrderId = j.OrderId,
                                                Item = itemDetailsModel.GetItemInfoByLineId(j.ItemNumber.Trim(), station.Line.Id),
                                            }).OrderBy(s => s.OrderId).ToList();
                        }


                        if (currentjobs.Count() != itemsinschedule)
                            return null;

                        for(int i=0; i<currentjobs.Count(); i++)
                            currentjobs[i].Index = i;

                        trimSchedule.CurrentSchedule = new TrimScheduleInfo
                        {
                            Complete = false,
                            SeatSchedule = currentjobs,
                            SummaryList = GetSummaryHeaderItems(currentjobs, station.Line.Id),
                            ScheduleStatus = GetTrimScheduleStatus(station, scheduleStatus, currentjobs),
                            OffsetSeats = offsetSeats
                        };

                        return trimSchedule;

                    }
                }
            }
            return null;
        }
Exemplo n.º 16
0
        public TrimScheduleInfo GetNextTrimSchedule(int locationId)
        {
            PartSequencingDataContext dbSeq = new PartSequencingDataContext();
            SequencingFactory factory = new SequencingFactory();
            HP_MESDataContext dbMes = new HP_MESDataContext();
            ItemDetailsFactory itemDetailsModel = new ItemDetailsFactory();
            TrimScheduleInfo nextTrimScheduleInfo = null;

            var seqMessageProcessor = new SeqMessageProcessor();

            var seqStations = dbSeq.SequencingStationSettings.Where(i => i.SequencingLocationId == locationId).ToList();
            if (seqStations.Count() > 0)
            {
                var seqStation = seqStations.FirstOrDefault();
                if (seqStation != null)
                {
                    var station = factory.UpdateNextBoxBySequencingId(seqStation.Id);
                    var scheduleStatus = dbSeq.SequencingStationLookups.Where(s => s.SequenceStationSettingsId == station.Id).FirstOrDefault();
                    var tokens = MessageTokensCacheManager.MessageTokens.Where(s => s.LineId == station.Line.Id || s.LineId == 4).ToList();

                    var lineBuffer = factory.GetSequencingBuffer(station);

                    if (lineBuffer != null)
                    {
                        var itemsinbox = station.PartsPerBox;
                        var boxperschedule = station.BoxPerSchedule;
                        var itemsinschedule = itemsinbox * boxperschedule;
                        var boxqty = station.BoxQty;

                        var currentjobs = (from j in lineBuffer.Where(i => i.OrderId >= station.NextBox.OrderId).Take(itemsinschedule).ToList()
                                           select new Seat
                                           {
                                               OrderStatus = (int)j.OrderStatus,
                                               Complete = false,
                                               TrimStyle = GetOptionValue(j.ItemNumber.Trim(), 100),
                                               Colour = GetOptionValue(j.ItemNumber.Trim(), 101),
                                               OrderNumber = j.OrderNumber == null ? "" : j.OrderNumber.Trim(),
                                               ItemNumber = j.ItemNumber.Trim(),
                                               ItemType = j.ItemType.Trim(),
                                               DescLine1 = j.ItemNumber.Trim(),
                                               DescLine2 = seqMessageProcessor.GetSequencingMessage(station, j.ItemNumber.Trim(), tokens),
                                               JobId = (int)j.JobId,
                                               OrderId = j.OrderId,
                                               Item = itemDetailsModel.GetItemInfoByLineId(j.ItemNumber.Trim(), station.Line.Id),
                                           }).OrderBy(s => s.OrderId).ToList();

                        if (currentjobs.Count() != itemsinschedule)
                            return null;

                        var lastcurrentjob = currentjobs.Last();

                        var nextjobs = (from j in lineBuffer.Where(i => i.OrderId > lastcurrentjob.OrderId).Take(itemsinschedule).ToList()
                                        select new Seat
                                        {
                                            OrderStatus = (int)j.OrderStatus,
                                            Complete = false,
                                            TrimStyle = GetOptionValue(j.ItemNumber.Trim(), 100),
                                            Colour = GetOptionValue(j.ItemNumber.Trim(), 101),
                                            OrderNumber = j.OrderNumber == null ? "" : j.OrderNumber.Trim(),
                                            ItemNumber = j.ItemNumber.Trim(),
                                            ItemType = j.ItemType.Trim(),
                                            DescLine1 = j.ItemNumber.Trim(),
                                            DescLine2 = seqMessageProcessor.GetSequencingMessage(station, j.ItemNumber.Trim(), tokens),
                                            JobId = (int)j.JobId,
                                            OrderId = j.OrderId,
                                            Item = itemDetailsModel.GetItemInfoByLineId(j.ItemNumber.Trim(), station.Line.Id)
                                        }).OrderBy(s => s.OrderId).ToList();

                        if (nextjobs.Count() == itemsinschedule)
                        {
                            nextTrimScheduleInfo = new TrimScheduleInfo
                            {
                                Complete = false,
                                SeatSchedule = nextjobs,
                                SummaryList = GetSummaryHeaderItems(nextjobs, station.Line.Id),
                                ScheduleStatus = new TrimScheduleStatus
                                {
                                    CurrentBoxNumber = (scheduleStatus.NextBoxNum + 1) > boxqty ? 1 : scheduleStatus.NextBoxNum + 1,
                                    CurrentScheduleNumber = scheduleStatus.NextScheduleNum + 1
                                }
                            };
                        }
                        else
                        {
                            return null;
                        }

                        for (int i = 0; i < nextjobs.Count(); i++)
                            nextjobs[i].Index = i;

                        return nextTrimScheduleInfo;

                    }
                }
            }
            return null;
        }
Exemplo n.º 17
0
        public IEnumerable<SequencingStation> GetSequencingStationsBySequencingLocationId(int id)
        {
            PartSequencingDataContext dbSeq = new PartSequencingDataContext();
            MesDataContext dbMes = new MesDataContext();
            SequencingScheduleFactory factory = new SequencingScheduleFactory();
            List<SequencingStation> listStations = new List<SequencingStation>();

            var results = (from s in SequencingSettingsCacheManager.SequencingStationSettings
                               where s.SequencingLocationId == id
                               select s).ToList();

            foreach (var seqStation in results)
            {
                var station = factory.UpdateNextBoxBySequencingId(seqStation.Id);
                listStations.Add(station);
            }

            return listStations;
        }
Exemplo n.º 18
0
 public Station GetStation(int id)
 {
     PartSequencingDataContext db = new PartSequencingDataContext();
     var station = db.Stations.Where(x => x.Id == id).FirstOrDefault();
     return station;
 }
Exemplo n.º 19
0
        public IEnumerable<SequencingLocation> GetSequencingLocationsByType(string type)
        {
            PartSequencingDataContext dbSeq = new PartSequencingDataContext();
            var locations = (from a in dbSeq.SequencingLocations.Where(s=>s.Obsolete == false)
                             where a.Type == type.Trim()
                             select a).ToList();

            return locations;
        }
Exemplo n.º 20
0
 public IEnumerable<MessageToken> GetMessageTokens()
 {
     PartSequencingDataContext db = new PartSequencingDataContext();
     var tokens = (from t in db.MessageTokens
                   select t).ToList();
     return tokens;
 }
Exemplo n.º 21
0
        public IEnumerable<SequencingLocation> GetPlasticSequencingLocations()
        {
            PartSequencingDataContext dbSeq = new PartSequencingDataContext();
            var aisles = (from a in dbSeq.SequencingLocations
                          where a.Type == "Plastic" 
                          select a).ToList();

            return aisles;
        }
Exemplo n.º 22
0
 public void UpdateMessageToken(MessageToken token)
 {
     PartSequencingDataContext db = new PartSequencingDataContext();
     db.MessageTokens.Attach(token);
     db.Refresh(System.Data.Linq.RefreshMode.KeepCurrentValues, token);
     db.SubmitChanges();
     MessageTokensCacheManager.RefreshMessageTokens();
 }
Exemplo n.º 23
0
        public TrimSchedule GetTrimSchedule(int id)
        {
            PartSequencingDataContext dbSeq = new PartSequencingDataContext();
            SequencingScheduleFactory factory = new SequencingScheduleFactory();
            MesDataContext dbMes = new MesDataContext();
            ItemDetailsModel itemDetailsModel = new ItemDetailsModel();
            TrimSchedule trimSchedule = null;
            List<Seat> offsetSeats = null;
            List<Seat> currentjobs = null;

            var seqStations = dbSeq.SequencingStationSettings.Where(i => i.SequencingLocationId == id).ToList();
            if (seqStations.Count() > 0)
            {
                var seqStation = seqStations.FirstOrDefault();
                if (seqStation != null)
                {
                    var station = factory.UpdateNextBoxBySequencingId(seqStation.Id);
                    var scheduleStatus = dbSeq.SequencingStationLookups.Where(s => s.SequenceStationSettingsId == station.Id).FirstOrDefault();
                    var tokens = MessageTokensCacheManager.MessageTokens.Where(s => s.LineId == station.Line.Id || s.LineId == 4).ToList();

                    var lineBuffer = factory.GetSequencingBuffer(station);

                    if (lineBuffer != null)
                    {
                        var itemsinbox = station.PartsPerBox;
                        var boxperschedule = station.BoxPerSchedule;
                        var itemsinschedule = itemsinbox * boxperschedule;
                        var boxqty = station.BoxQty;

                        trimSchedule = new TrimSchedule
                        {

                        };


                        //trimSchedule.PreviousSchedule = new TrimScheduleInfo();

                        //SequencingTrackingItem lastItem = null;
                        //var tracking = factory.GetSequencingHistory(station);

                        //if (tracking.Any())
                        //{
                        //    lastItem = tracking.OrderByDescending(i => i.OrderId).First();
                        //    if (lastItem != null)
                        //    {
                        //        int previousScheduleNum = lastItem.ScheduleNum;
                        //        var previousjobs = (from t in tracking.Where(i=>i.ScheduleNum == previousScheduleNum)
                        //                           select new Seat {
                        //                               OrderNumber = t.OrderNumber,
                        //                               OrderStatus = t.OrderStatus,
                        //                               Complete = false,
                        //                               TrimStyle = GetOptionValue(t.ItemNumber.Trim(), 100),
                        //                               Colour = GetOptionValue(t.ItemNumber.Trim(), 101),
                        //                               ItemNumber = t.ItemNumber.Trim(),
                        //                               ItemType = t.ItemType.Trim(),
                        //                               DescLine1 = t.ItemNumber.Trim(),
                        //                               DescLine2 = factory.GetSequencingMessage(station, t.ItemNumber.Trim(), tokens),
                        //                               JobId = (int)t.JobId,
                        //                               OrderId = t.OrderId,
                        //                               Item = itemDetailsModel.GetItemInfoByLineId(t.ItemNumber.Trim(), station.Line.Id)
                        //                           }).ToList();
                        //        trimSchedule.PreviousSchedule.SeatSchedule = previousjobs;
                        //        trimSchedule.PreviousSchedule.SummaryList = GetSummaryHeaderItems(previousjobs, station.Line.Id);
                        //        trimSchedule.PreviousSchedule.ScheduleStatus = new TrimScheduleStatus
                        //        {
                        //            CurrentBoxNumber = lastItem.BoxNum,
                        //            CurrentScheduleNumber = lastItem.ScheduleNum
                        //        };
                        //    }

                        //}
                        //else
                        //{
                        //    trimSchedule.PreviousSchedule = null;
                        //}
                        var tracking = factory.GetSequencingHistory(station);
                        if (tracking.Any()) 
                        {
                            var lastTrackItem = tracking.LastOrDefault();
                            if (lastTrackItem != null)
                            {
                                if (lastTrackItem.Type == 2)
                                {
                                    var lastRealJob = tracking.Where(o => o.OrderId < lastTrackItem.OrderId).OrderByDescending(f => f.OrderId).Where(x => x.ScheduleNum > 0).FirstOrDefault();

                                    if (lastRealJob != null)
                                    {
                                        var unassignedBuffer = tracking.Where(o => o.OrderId <= lastTrackItem.OrderId && o.OrderId >lastRealJob.OrderId).OrderBy(f => f.OrderId).ToList();
                                        if (unassignedBuffer.Count() > 0)
                                        {
                                            var offsetjobs = (from j in unassignedBuffer
                                                              select new Seat
                                                              {
                                                                  OrderStatus = (int)j.OrderStatus,
                                                                  Complete = false,
                                                                  TrimStyle = GetOptionValue(j.ItemNumber.Trim(), 100),
                                                                  Colour = GetOptionValue(j.ItemNumber.Trim(), 101),
                                                                  OrderNumber = j.OrderNumber == null ? "" : j.OrderNumber.Trim(),
                                                                  ItemNumber = j.ItemNumber.Trim(),
                                                                  ItemType = j.ItemType.Trim(),
                                                                  DescLine1 = j.ItemNumber.Trim(),
                                                                  DescLine2 = factory.GetSequencingMessage(station, j.ItemNumber.Trim(), tokens),
                                                                  JobId = (int)j.JobId,
                                                                  OrderId = j.OrderId,
                                                                  Item = itemDetailsModel.GetItemInfoByLineId(j.ItemNumber.Trim(), station.Line.Id)
                                                              }).ToList();

                                            offsetSeats = offsetjobs;
                                        }
                                    }

                                }
                            }


                        }


                        if (station.SequencingLocation.ParentId == null)
                        {
                            currentjobs = (from j in lineBuffer.Where(i => i.OrderId >= station.NextBox.OrderId).Take(itemsinschedule).ToList()
                                           select new Seat
                                           {
                                               OrderStatus = (int)j.OrderStatus,
                                               Complete = false,
                                               TrimStyle = GetOptionValue(j.ItemNumber.Trim(), 100),
                                               Colour = GetOptionValue(j.ItemNumber.Trim(), 101),
                                               OrderNumber = j.OrderNumber == null ? "" : j.OrderNumber.Trim(),
                                               ItemNumber = j.ItemNumber.Trim(),
                                               ItemType = j.ItemType.Trim(),
                                               DescLine1 = j.ItemNumber.Trim(),
                                               DescLine2 = factory.GetSequencingMessage(station, j.ItemNumber.Trim(), tokens),
                                               JobId = (int)j.JobId,
                                               OrderId = j.OrderId,
                                               Item = itemDetailsModel.GetItemInfoByLineId(j.ItemNumber.Trim(), station.Line.Id),
                                           }).OrderBy(s => s.OrderId).ToList();
                        }
                        else //from queue
                        {
                            currentjobs = (from j in lineBuffer.Where(i => i.OrderId >= station.NextBox.OrderId).Take(itemsinschedule).ToList()
                                            select new Seat
                                            {
                                                ScheduleNum = j.ScheduleNum,
                                                BoxNum = j.BoxNum,
                                                OrderStatus = (int)j.OrderStatus,
                                                Complete = false,
                                                TrimStyle = GetOptionValue(j.ItemNumber.Trim(), 100),
                                                Colour = GetOptionValue(j.ItemNumber.Trim(), 101),
                                                OrderNumber = j.OrderNumber == null ? "" : j.OrderNumber.Trim(),
                                                ItemNumber = j.ItemNumber.Trim(),
                                                ItemType = j.ItemType.Trim(),
                                                DescLine1 = j.ItemNumber.Trim(),
                                                DescLine2 = factory.GetSequencingMessage(station, j.ItemNumber.Trim(), tokens),
                                                JobId = (int)j.JobId,
                                                OrderId = j.OrderId,
                                                Item = itemDetailsModel.GetItemInfoByLineId(j.ItemNumber.Trim(), station.Line.Id),
                                            }).OrderBy(s => s.OrderId).ToList();
                        }

                        //var currentjobs = (from j in lineBuffer.Where(i => i.OrderId >= station.NextBox.OrderId).Take(itemsinschedule).ToList()
                        //                   select new Seat {
                                              
                        //                       OrderStatus = (int)j.OrderStatus,
                        //                       Complete = false,
                        //                       TrimStyle = GetOptionValue(j.ItemNumber.Trim(), 100),
                        //                       Colour = GetOptionValue(j.ItemNumber.Trim(), 101),
                        //                       OrderNumber = j.OrderNumber == null ? "" : j.OrderNumber.Trim(),
                        //                       ItemNumber = j.ItemNumber.Trim(),
                        //                       ItemType = j.ItemType.Trim(),
                        //                       DescLine1 = j.ItemNumber.Trim(),
                        //                       DescLine2 = factory.GetSequencingMessage(station, j.ItemNumber.Trim(), tokens),
                        //                       JobId = (int)j.JobId,
                        //                       OrderId = j.OrderId,
                        //                       Item = itemDetailsModel.GetItemInfoByLineId(j.ItemNumber.Trim(), station.Line.Id),
                        //                   }).OrderBy(s=>s.OrderId).ToList();

                        if (currentjobs.Count() != itemsinschedule)
                            return null;

                        //var lastcurrentjob = currentjobs.Last();

                        //var nextjobs = (from j in lineBuffer.Where(i => i.OrderId > lastcurrentjob.OrderId).Take(itemsinschedule).ToList()
                        //                select new Seat
                        //                {
                        //                    OrderStatus = (int)j.OrderStatus,
                        //                    Complete = false,
                        //                    TrimStyle = GetOptionValue(j.ItemNumber.Trim(), 100),
                        //                    Colour = GetOptionValue(j.ItemNumber.Trim(), 101),
                        //                    OrderNumber = j.OrderNumber == null ? "" : j.OrderNumber.Trim(),
                        //                    ItemNumber = j.ItemNumber.Trim(),
                        //                    ItemType = j.ItemType.Trim(),
                        //                    DescLine1 = j.ItemNumber.Trim(),
                        //                    DescLine2 = factory.GetSequencingMessage(station, j.ItemNumber.Trim(), tokens),
                        //                    JobId = (int)j.JobId,
                        //                    OrderId = j.OrderId,
                        //                    Item = itemDetailsModel.GetItemInfoByLineId(j.ItemNumber.Trim(), station.Line.Id)
                        //                }).OrderBy(s => s.OrderId).ToList();

                        //if (nextjobs.Count() == itemsinschedule)
                        //{
                        //    trimSchedule.NextSchedule = new TrimScheduleInfo
                        //    {
                        //        Complete = false,
                        //        SeatSchedule = nextjobs,
                        //        SummaryList = GetSummaryHeaderItems(nextjobs, station.Line.Id),
                        //        ScheduleStatus = new TrimScheduleStatus
                        //        {
                        //            CurrentBoxNumber = (scheduleStatus.NextBoxNum + 1) > boxqty ? 1 : scheduleStatus.NextBoxNum + 1,
                        //            CurrentScheduleNumber = scheduleStatus.NextScheduleNum + 1
                        //        }
                        //    };
                        //}
                        //else
                        //{
                        //    trimSchedule.NextSchedule = null;
                        //}

                        //for (int i = 0; i < nextjobs.Count(); i++)
                        //    nextjobs[i].Index = i;

                        for(int i=0; i<currentjobs.Count(); i++)
                            currentjobs[i].Index = i;

                        trimSchedule.CurrentSchedule = new TrimScheduleInfo
                        {
                            Complete = false,
                            SeatSchedule = currentjobs,
                            SummaryList = GetSummaryHeaderItems(currentjobs, station.Line.Id),
                            ScheduleStatus = GetTrimScheduleStatus(station, scheduleStatus, currentjobs),
                            OffsetSeats = offsetSeats
                        };

                        return trimSchedule;

                    }
                }
            }
            return null;
        }
Exemplo n.º 24
0
 public void CreateMessageToken(MessageToken token)
 {
     PartSequencingDataContext db = new PartSequencingDataContext();
     db.MessageTokens.InsertOnSubmit(token);
     db.SubmitChanges();
     MessageTokensCacheManager.RefreshMessageTokens();
 }
Exemplo n.º 25
0
 public void DeleteMessageTokenById(int id)
 {
     PartSequencingDataContext db = new PartSequencingDataContext();
     var token = db.MessageTokens.Where(s => s.Id == id).FirstOrDefault();
     if (token != null)
     {
         db.MessageTokens.DeleteOnSubmit(token);
         db.SubmitChanges();
     }
     MessageTokensCacheManager.RefreshMessageTokens();
 }
Exemplo n.º 26
0
 public IEnumerable<MessageToken> GetMessageTokensByLineId(int id)
 {
     PartSequencingDataContext db = new PartSequencingDataContext();
     var tokens = (from t in MessageTokensCacheManager.MessageTokens
                   where t.LineId == id
                   select t).ToList();
     return tokens;
 }
Exemplo n.º 27
0
        public TrimScheduleInfo GetTrimScheduleHistoryDetail(int locationId, int scheduleNum)
        {
            PartSequencingDataContext dbSeq = new PartSequencingDataContext();
            ItemDetailsFactory itemDetailsModel = new ItemDetailsFactory();
            SequencingFactory factory = new SequencingFactory();
            var seqMessageProcessor = new SeqMessageProcessor();

            var seqStation = dbSeq.SequencingStationSettings.Where(i => i.SequencingLocationId == locationId).FirstOrDefault();
            var tokens = MessageTokensCacheManager.MessageTokens.Where(s => s.LineId == seqStation.LineId || s.LineId == 4).ToList();
            var station = factory.UpdateNextBoxBySequencingId(seqStation.Id);

            TrimScheduleInfo trimHistorySchedule = null;

            if (station != null)
            {
                SequencingTrackingItem lastItem = null;
                var tracking = factory.GetSequencingHistory(station);

                if (tracking.Any())
                {
                    lastItem = tracking.OrderByDescending(i => i.OrderId).First();
                    if (lastItem != null)
                    {
                        var historyjobs = (from t in dbSeq.IWS_GetSequencingDetailHistoryBySeqSettingsIdAndScheduleNum(station.Id, scheduleNum)
                                          select new Seat
                                          {
                                            ScheduleNum = t.ScheduleNum,
                                            BoxNum = t.BoxNum,
                                            Complete = false,
                                            TrimStyle = GetOptionValue(t.ItemNumber.Trim(), 100),
                                            Colour = GetOptionValue(t.ItemNumber.Trim(), 101),
                                            ItemNumber = t.ItemNumber.Trim(),
                                            ItemType = t.ItemType.Trim(),
                                            DescLine1 = t.ItemNumber.Trim(),
                                            DescLine2 = seqMessageProcessor.GetSequencingMessage(station, t.ItemNumber.Trim(), tokens),
                                            OrderId = t.OrderId,
                                            Item = itemDetailsModel.GetItemInfoByLineId(t.ItemNumber.Trim(), station.Line.Id)
                                          }).ToList();

                        var firstItem = historyjobs.FirstOrDefault();

                        trimHistorySchedule = new TrimScheduleInfo
                        {
                            Complete = true,
                            ScheduleStatus = new TrimScheduleStatus
                            {
                                CurrentBoxNumber = firstItem == null ? 0 : firstItem.BoxNum,
                                CurrentScheduleNumber = firstItem == null ? 0 : firstItem.ScheduleNum
                            },
                            SeatSchedule = historyjobs,
                            SummaryList = GetSummaryHeaderItems(historyjobs, station.Line.Id),
                        };
                        return trimHistorySchedule;
                    }

                }

            }
            return trimHistorySchedule;
        }
Exemplo n.º 28
0
 public SequencingStationLookup GetSequencingStationLookup(int id)
 {
     PartSequencingDataContext db = new PartSequencingDataContext();
     return null;
 }
Exemplo n.º 29
0
        public void CompleteTrimSchedule(TrimScheduleInfo schedule, int id, int employeeId)
        {
            PartSequencingDataContext dbSeq = new PartSequencingDataContext();
            EmployeeDatabase dbEmp = new EmployeeDatabase();
            SequencingFactory factory = new SequencingFactory();

            var employee = dbEmp.GetEmployeeInfo(employeeId);
            var seqStations = dbSeq.SequencingStationSettings.Where(i => i.SequencingLocationId == id).ToList();

            if (seqStations.Count() > 0)
            {
                var seqStation = seqStations.FirstOrDefault();
                if (seqStation != null)
                {
                    var station = factory.UpdateNextBoxBySequencingId(seqStation.Id);
                    var statusLookup = dbSeq.SequencingStationLookups.Where(i => i.SequenceStationSettingsId == seqStation.Id).FirstOrDefault();

                    int boxNum = schedule.ScheduleStatus.CurrentBoxNumber;
                    int scheduleNum = schedule.ScheduleStatus.CurrentScheduleNumber;

                    //check if job completed already
                    bool isComplete = false;
                    var isCompleteResult = dbSeq.IsSequencingScheduleComplete(seqStation.Id, boxNum, scheduleNum);
                    if (isCompleteResult.HasValue == true) // it's null
                        isComplete = (bool)isCompleteResult;

                    if (isComplete)
                    {
                        throw new HttpResponseException(
                            HttpErrorResponse.GetHttpErrorResponse(
                            HttpStatusCode.NotFound, "Trim Schedule Already Completed", string.Format("Trim Schedule {0} Already Completed", scheduleNum)));
                    }

                    if (schedule.ScheduleStatus.CurrentBoxNumber == statusLookup.NextBoxNum
                        && schedule.ScheduleStatus.CurrentScheduleNumber == statusLookup.NextScheduleNum)
                    {
                        var lastjob = schedule.SeatSchedule.Last();
                        var firstjob = schedule.SeatSchedule.First();

                        //get schedule parameters by station
                        var itemsinbox = station.PartsPerBox;
                        var boxperschedule = station.BoxPerSchedule;
                        var itemsinschedule = itemsinbox * boxperschedule;

                        //get sequencing buffer
                        var lineBuffer = factory.GetSequencingBuffer(station);
                        //filter sequencing buffer by last job and first job
                        var validBuffer = lineBuffer.Where(i => i.OrderId <= lastjob.OrderId && i.OrderId >= firstjob.OrderId).OrderBy(s => s.OrderId).ToList();

                        if (validBuffer.Count() == itemsinschedule) //check if there is enough seats to fulfill schedule
                        {
                            if (schedule.OffsetSeats != null)
                            {
                                if (schedule.OffsetSeats.Count() > 0)
                                {

                                }
                            }


                            //save history
                            SequencingTrackingHistoryDetail histDetail = new SequencingTrackingHistoryDetail
                            {
                                BoxNum = schedule.ScheduleStatus.CurrentBoxNumber,
                                DTM = DateTime.Now,
                                ScheduleNum = schedule.ScheduleStatus.CurrentScheduleNumber,
                                SequencingStationSettingsId = station.Id,
                                Type = 1
                            };
                            dbSeq.SequencingTrackingHistoryDetails.InsertOnSubmit(histDetail);

                            foreach (var seat in schedule.SeatSchedule)
                            {
                                SequencingTrackingHistory hist = new SequencingTrackingHistory
                                {
                                    Position = seat.Index + 1,
                                    OrderId = seat.OrderId,
                                    ItemNumber = seat.ItemNumber,
                                    OrderNumber = seat.OrderNumber,
                                    ItemType = seat.ItemType,
                                    JobId = seat.JobId,
                                    SequencingTrackingHistoryDetail = histDetail,
                                };

                                dbSeq.SequencingTrackingHistories.InsertOnSubmit(hist);
                            }

                            //queue station items
                            if ((bool)station.SequencingLocation.QueueItems)
                            {
                                var queueStations = dbSeq.SequencingLocations.Where(l => l.ParentId == station.SequencingLocation.Id).ToList();

                                if (queueStations.Count() > 0)
                                {
                                    foreach (var st in queueStations)
                                    {
                                        var queueItems = (from s in schedule.SeatSchedule
                                                          select new SequencingStationQueue
                                                          {
                                                              OrderNumber = s.OrderNumber == null ? "" : s.OrderNumber.Trim(),
                                                              BoxNum = schedule.ScheduleStatus.CurrentBoxNumber,
                                                              InsertedDTM = DateTime.Now,
                                                              UpdatedDTM = DateTime.Now,
                                                              ItemNumber = s.ItemNumber.Trim(),
                                                              ItemType = s.ItemType.Trim(),
                                                              JobId = s.JobId,
                                                              OrderId = s.OrderId,
                                                              Region = "",
                                                              ScheduleNum = schedule.ScheduleStatus.CurrentScheduleNumber,
                                                              SequencingLocationId = st.Id,
                                                              OrderStatus = (byte)s.OrderStatus,
                                                          }).ToList();

                                        dbSeq.SequencingStationQueues.InsertAllOnSubmit(queueItems);
                                        dbSeq.SubmitChanges();
                                    }
                                }
                            }

                            //no parent station delete from the queue table
                            if (station.SequencingLocation.ParentId != null)
                            {
                                var deleteSeats = dbSeq.SequencingStationQueues.Where(i => i.OrderId <= lastjob.OrderId && i.OrderId >= firstjob.OrderId && i.SequencingLocationId == station.SequencingLocation.Id).OrderBy(s => s.OrderId).ToList();
                                dbSeq.SequencingStationQueues.DeleteAllOnSubmit(deleteSeats);
                                dbSeq.SubmitChanges();
                            }

                            var scheduleHist = new SequencingStationScheduleHistory
                            {
                                EmployeeId = employeeId,
                                EmployeeName = employee == null ? "Unknown Employee" : employee.Name.Trim(),
                                ScheduleNum = schedule.ScheduleStatus.CurrentScheduleNumber,
                                SequencingLocationId = id,
                                DateCompleted = DateTime.Now,
                            };
                            dbSeq.SequencingStationScheduleHistories.InsertOnSubmit(scheduleHist);

                            var nextjob = lineBuffer.Where(i => i.OrderId > lastjob.OrderId).OrderBy(s => s.OrderId).FirstOrDefault();
                            statusLookup.NextBoxNum = schedule.ScheduleStatus.CurrentBoxNumber + 1;
                            statusLookup.NextOrderId = nextjob == null ? statusLookup.NextOrderId + 1 : nextjob.OrderId;
                            statusLookup.NextScheduleNum = schedule.ScheduleStatus.CurrentScheduleNumber + 1;
                            
                            dbSeq.SubmitChanges();

                            //if (id == 7) //first row complete schedule
                            //{
                            //    CompleteTrimSchedule(schedule, 8, employeeId);
                            //}
                        }
                    }
                }
            }
        }
Exemplo n.º 30
0
 public IEnumerable<ColourExtension> GetColourExtensions()
 {
     PartSequencingDataContext db = new PartSequencingDataContext();
     var exts = (from e in db.ColourExtensions
                 select e).ToList();
     return exts;
 }