예제 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("ProductionStageID,Name,Color,Description,IsActive,AddedDate,UpdatedDate,AddedUserID,UpdatedUserID")] ProductionStage productionStage)
        {
            if (id != productionStage.ProductionStageID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    productionStage.UpdatedDate   = DateTime.Now;
                    productionStage.UpdatedUserID = Int32.Parse(HttpContext.Session.GetString("UserID"));
                    _context.Update(productionStage);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProductionStageExists(productionStage.ProductionStageID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AddedUserID"]   = new SelectList(_context.Users, "UserID", "Login", productionStage.AddedUserID);
            ViewData["UpdatedUserID"] = new SelectList(_context.Users, "UserID", "Login", productionStage.UpdatedUserID);
            return(View(productionStage));
        }
예제 #2
0
 /// <summary>
 /// Deletes the specified product.
 /// </summary>
 /// <param name="stage">The stage.</param>
 public void Delete(ProductionStage stage)
 {
     this.Repository.Delete(stage);
     this.Repository.SaveChanges();
 }
예제 #3
0
 /// <summary>
 /// Updates the specified product.
 /// </summary>
 /// <param name="stage">The stage.</param>
 public void Update(ProductionStage stage)
 {
     this.Repository.SaveChanges();
 }
예제 #4
0
 /// <summary>
 /// Adds the specified product.
 /// </summary>
 /// <param name="stage">The stage.</param>
 public void Add(ProductionStage stage)
 {
     this.Repository.Add(stage);
     this.Repository.SaveChanges();
 }
예제 #5
0
        /// <summary>
        /// Handles the ReceiveCompleted event of the msmq control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">
        ///   The <see cref="ReceiveCompletedEventArgs" />
        ///   instance containing the event data.
        /// </param>
        private void msmq_ReceiveCompleted(
            object sender,
            ReceiveCompletedEventArgs e)
        {
            var str   = e.Message.Body.ToString();
            var split = str.Split(",".ToCharArray());

            // parse out message pieces
            Guid id         = Guid.Parse(split[1]);
            var  timestamp  = DateTime.Parse(split[5]);
            var  line       = split[2].Substring(4);
            var  lineNumber = int.Parse(line);

            // find an existing production entry if it exists
            var entry = this.ProductionEntryService.List().FirstOrDefault(
                p => p.Id == id);

            // create a new entry if it doesnt exist yet...
            if (entry == null)
            {
                var schedule = this.ScheduleService.GetByTimestamp(timestamp);
                entry = new ProductionEntry()
                {
                    Id      = id,
                    Product = schedule == null ? null : schedule.Product,
                    Stages  = new Collection <ProductionStage>()
                };

                this.ProductionEntryService.Add(entry);
            }

            // create a new stage
            var stage = new ProductionStage()
            {
                WorkArea        = split[0],
                TimeStamp       = timestamp,
                LineNumber      = lineNumber,
                ProductionEntry = entry
            };

            // find the station the product is at
            var stationId = split[3];
            var station   = this.StationService.List().FirstOrDefault(
                s => s.Identifier == stationId);

            stage.Station = station;

            // find the flaw
            if (split[4].Length > 0)
            {
                var flawId = split[4];
                stage.ProductFlaw = this.FlawService.List().FirstOrDefault(
                    f => f.Identifier == flawId);
            }

            // save the data!
            entry.Stages.Add(stage);
            this.ProductionEntryService.Update(entry);
            this.StageService.Add(stage);

            // start listening for messages again, if we aren't paused...
            if (this.IsRunning)
            {
                this.Queue.BeginReceive();
            }
        }