Example #1
0
        public async Task <IHttpActionResult> CreateJobSlit(JobSplit entity)
        {
            userId = User.Identity.GetUserId();

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var newEntity = entity;

            context.JobSplits.Add(newEntity);
            await context.SaveChangesAsync();

            return(Ok <JobSplit>(newEntity));
        }
Example #2
0
        public async Task <IHttpActionResult> UpdateQAWasteRequest(int id, JobSplitCEAnalysis entity)
        {
            string             userId         = User.Identity.GetUserId();
            JobSplitCEAnalysis existingEntity = await context.JobSplitCEAnalysis.FindAsync(entity.Id);

            JobSplit jobSplit = await context.JobSplits.FindAsync(entity.JobSplitId);

            if (entity == null)
            {
                return(NotFound());
            }
            if (id != entity.Id)
            {
                return(BadRequest(ModelState));
            }
            if (entity == null)
            {
                var       message = string.Format("Entry is empty");
                HttpError err     = new HttpError(message);
                return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, err)));
            }

            if (existingEntity != null && context.Entry(existingEntity).State != EntityState.Detached)
            {
                context.Entry(existingEntity).State = EntityState.Detached;
            }

            var local = context.Set <JobSplitCEAnalysis>().Local.FirstOrDefault(f => f.Id == entity.Id);

            if (local != null)
            {
                context.Entry(local).State = EntityState.Detached;
            }


            context.JobSplitCEAnalysis.Attach(existingEntity);
            context.Entry(existingEntity).State = EntityState.Modified;
            await context.SaveChangesAsync();

            return(Ok <JobSplitCEAnalysis>(existingEntity));
        }
Example #3
0
        public async Task <IHttpActionResult> UpdateJobSlitPrintQCAnalysis(int id, JobSplitQCAnalysis entity)
        {
            string   userId   = User.Identity.GetUserId();
            JobSplit jobSplit = await context.JobSplits.FindAsync(entity.JobSplitId);

            if (entity == null)
            {
                return(NotFound());
            }

            var jobStatusWIP = _repo.FindJobStatusByName("WIP");
            var jobTracker   = await context.JobTrackers.FindAsync(jobSplit.JobTrackerId);

            // Update JobTracker
            jobTracker.PrintQCId            = jobStatusWIP.Id;
            jobTracker.ModifiedOn           = DateTime.Now;
            context.Entry(jobTracker).State = EntityState.Modified;
            await context.SaveChangesAsync();

            return(Ok <JobSplitQCAnalysis>(entity));
        }
Example #4
0
        public async Task <IHttpActionResult> CreateFirstCard(IList <FirstCardModel> entity)
        {
            userId = User.Identity.GetUserId();

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var jobTracker = await context.JobTrackers.FindAsync(entity[0].JobTrackerId);

            var job = await context.Jobs.FindAsync(jobTracker.JobId);

            var serviceType = job.ServiceTypeId;

            // Create the JobSlip
            foreach (var m in entity)
            {
                var newJobSlit = new JobSplit()
                {
                    JobTrackerId = m.JobTrackerId,
                    DepartmentId = m.DepartmentId,
                    SidMachineId = m.SidMachineId,
                    RangeFrom    = m.RangeFrom,
                    RangeTo      = m.RangeTo,
                    CreatedById  = userId,
                    CreatedOn    = DateTime.Now
                };

                var t1 = await CreateJobSlit(newJobSlit);

                var lastJobSplit = _repository.JobSplits.OrderByDescending(x => x.Id).Take(1).ToList();

                // Create the QA Process
                var newQA = new Sid05QA()
                {
                    JobTrackerId = m.JobTrackerId,
                    JobSplitId   = lastJobSplit[0].Id,
                    CreatedOn    = DateTime.Now,
                    CreatedById  = userId
                };
                var t11 = await CreateSidQA(newQA);

                // Create the CEAnalysis
                var goodQty = (m.RangeTo - m.RangeFrom) + 1;

                var newJobSlitCEAnalysis = new JobSplitPrintCEAnalysis()
                {
                    JobSplitId   = lastJobSplit[0].Id,
                    JobTrackerId = m.JobTrackerId,
                    QuantityGood = goodQty,
                    QuantityBad  = 0,
                    QuantityHeld = 0,
                    CreatedOn    = DateTime.Now,
                    CreatedById  = userId,
                    ModifiedById = userId,
                    ModifiedOn   = DateTime.Now
                };

                var t2 = await CreateJobPrintSplitCEAnalysis(newJobSlitCEAnalysis);
            }

            var jobStatusWIP   = _repo.FindJobStatusByName("WIP");
            var jobStatusQueue = _repo.FindJobStatusByName("Queue");

            var jobTypePersoOnly               = _repo.FindJobTypeByName("Perso Only");
            var jobTypePrintingOnly            = _repo.FindJobTypeByName("Printing Only");
            var jobTypePrintingAndPerso        = _repo.FindJobTypeByName("Printing And Perso");
            var jobTypePrintingPersoAndMailing = _repo.FindJobTypeByName("Printing, Perso And Mailing");
            var jobTypePersoAndMailing         = _repo.FindJobTypeByName("Perso And Mailing");

            #region JobTrackerUpdateFlow

            if (serviceType == jobTypePrintingOnly.Id)
            {
                jobTracker.PrintQAId = jobStatusQueue.Id;
            }
            else if (serviceType == jobTypePrintingAndPerso.Id)
            {
                jobTracker.PrintQAId = jobStatusQueue.Id;
            }
            else if (serviceType == jobTypePrintingPersoAndMailing.Id)
            {
                jobTracker.PrintQAId = jobStatusQueue.Id;
            }

            #endregion

            jobTracker.ModifiedOn           = DateTime.Now;
            jobTracker.PrintingId           = jobStatusWIP.Id;
            context.Entry(jobTracker).State = EntityState.Modified;
            await context.SaveChangesAsync();

            return(Ok());
        }
        public async Task <IHttpActionResult> CreateFirstCard(IList <FirstCardModel> entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException(nameof(entity));
            }
            userId = User.Identity.GetUserId();

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var jobTypePersoOnly               = _repo.FindJobTypeByName("Perso Only");
            var jobTypePrintingOnly            = _repo.FindJobTypeByName("Printing Only");
            var jobTypeMailingOnly             = _repo.FindJobTypeByName("Mailing Only");
            var jobTypePrintingAndPerso        = _repo.FindJobTypeByName("Printing And Perso");
            var jobTypePrintingPersoAndMailing = _repo.FindJobTypeByName("Printing, Perso And Mailing");
            var jobTypePersoAndMailing         = _repo.FindJobTypeByName("Perso And Mailing");

            var departmentCE = _repo.FindDepartmentByName("Card Engineer");
            var departmentQc = _repo.FindDepartmentByName("Quality Control");
            var departmentMa = _repo.FindDepartmentByName("Mailing");
            var departmentDp = _repo.FindDepartmentByName("Dispatch");

            var jobStatusCompleted = _repo.FindJobStatusByName("Completed");
            var jobStatusQueue     = _repo.FindJobStatusByName("Queue");

            var jobTracker = await context.JobTrackers.FindAsync(entity[0].JobTrackerId);

            var job = await context.Jobs.FindAsync(jobTracker.JobId);

            var serviceType = job.ServiceTypeId;

            var newFirstCard = new Sid03FirstCard()
            {
                JobTrackerId    = entity[0].JobTrackerId,
                InitializedById = userId,
                InitializedOn   = DateTime.Now
            };

            context.Sid03FirstCards.Add(newFirstCard);
            await context.SaveChangesAsync();

            // Create the JobSplit
            #region JobSplitAnalysis

            foreach (var m in entity)
            {
                var newJobSlit = new JobSplit()
                {
                    JobTrackerId = m.JobTrackerId,
                    DepartmentId = m.DepartmentId,
                    SidMachineId = m.SidMachineId,
                    RangeFrom    = m.RangeFrom,
                    RangeTo      = m.RangeTo,
                    CreatedById  = userId,
                    CreatedOn    = DateTime.Now
                };

                var t1 = await CreateJobSlit(newJobSlit);

                var lastTestMe   = newJobSlit.Id;
                var lastJobSplit = _repository.JobSplits.OrderByDescending(x => x.Id).Take(1).ToList();

                // Create the QA Process
                var newQA = new Sid05QA()
                {
                    JobTrackerId = m.JobTrackerId,
                    JobSplitId   = lastJobSplit[0].Id,
                    CreatedOn    = DateTime.Now,
                    CreatedById  = userId
                };
                var t2 = await CreateSidQA(newQA);

                // Create the CEAnalysis
                var goodQty = (m.RangeTo - m.RangeFrom) + 1;
                var newJobSlitCEAnalysis = new JobSplitCEAnalysis()
                {
                    JobSplitId   = lastJobSplit[0].Id,
                    JobTrackerId = m.JobTrackerId,
                    QuantityGood = goodQty,
                    QuantityBad  = 0,
                    QuantityHeld = 0,
                    CreatedOn    = DateTime.Now,
                    CreatedById  = userId,
                    ModifiedById = userId,
                    ModifiedOn   = DateTime.Now
                };

                var t3 = await CreateJobSlitCEAnalysis(newJobSlitCEAnalysis);
            }

            #endregion

            //// Update JobTracker
            #region JobTrackerUpdateFlow

            jobTracker.FirstJobRunId = jobStatusCompleted.Id;

            if (serviceType == jobTypePersoOnly.Id)
            {
                jobTracker.QAId = jobStatusQueue.Id;
            }
            else if (serviceType == jobTypePrintingAndPerso.Id)
            {
                jobTracker.QAId = jobStatusQueue.Id;
            }
            else if (serviceType == jobTypePersoAndMailing.Id)
            {
                jobTracker.QAId = jobStatusQueue.Id;
            }
            else if (serviceType == jobTypePrintingPersoAndMailing.Id)
            {
                jobTracker.QAId = jobStatusQueue.Id;
            }

            jobTracker.ModifiedOn           = DateTime.Now;
            context.Entry(jobTracker).State = EntityState.Modified;
            await context.SaveChangesAsync();

            #endregion

            return(Ok <Sid03FirstCard>(newFirstCard));
        }
Example #6
0
        public async Task <IHttpActionResult> QACheckProcess(Sid05QA entity)
        {
            string   userId   = User.Identity.GetUserId();
            JobSplit jobSplit = await context.JobSplits.FindAsync(entity.JobSplitId);

            JobTracker jobTracker = await context.JobTrackers.FindAsync(entity.JobTrackerId);

            Job job = await context.Jobs.FindAsync(jobTracker.JobId);

            var jobStatusPending     = _repo.FindJobStatusByName("Pending");
            var jobStatusCompleted   = _repo.FindJobStatusByName("Completed");
            var jobStatusQueue       = _repo.FindJobStatusByName("Queue");
            var jobStatusNotRequired = _repo.FindJobStatusByName("Not Required");

            var jobTypePersoOnly               = _repo.FindJobTypeByName("Perso Only");
            var jobTypePrintingOnly            = _repo.FindJobTypeByName("Printing Only");
            var jobTypePrintingAndPerso        = _repo.FindJobTypeByName("Printing And Perso");
            var jobTypePrintingPersoAndMailing = _repo.FindJobTypeByName("Printing, Perso And Mailing");
            var jobTypePersoAndMailing         = _repo.FindJobTypeByName("Perso And Mailing");
            var serviceType = job.ServiceTypeId;

            var printDepartment = _repo.FindDepartmentByName("Printing");
            var persoDepartment = _repo.FindDepartmentByName("Card Engineer");


            // Update Selected Split QA Process
            var t1 = await UpdateQAJobChecks(entity.Id, entity);

            // JobSplit Process
            jobSplit.IsQACompleted = true;
            var t2 = await UpdateJobSplit(jobSplit.Id, jobSplit);

            // If The split category id Printing
            if (jobSplit.DepartmentId == printDepartment.Id)
            {
                // Process Print Stage Scenerio
                var printDepart = _repo.FindPersoJobSplitByQAProcess(jobSplit.JobTrackerId, printDepartment.Id);

                if (printDepart == null) // If there is no item to process
                {
                    jobTracker.PrintQAId  = jobStatusCompleted.Id;
                    jobTracker.PrintQCId  = jobStatusQueue.Id;
                    jobTracker.ModifiedOn = DateTime.Now;

                    context.Entry(jobTracker).State = EntityState.Modified;
                    await context.SaveChangesAsync();
                }
            }
            else
            {
                // Process Perso Scenerio
                var PersoChecker = _repo.FindPersoJobSplitByQAProcess(jobSplit.JobTrackerId, persoDepartment.Id);

                if (PersoChecker == null)
                {
                    // Update the Tracker
                    #region UpdateTracker

                    // Update JobTracker
                    jobTracker.QAId = jobStatusCompleted.Id;

                    // JobServiceType
                    #region JobTrackerUpdateFlow

                    if (serviceType == jobTypePrintingOnly.Id)
                    {
                        jobTracker.QCId = jobStatusQueue.Id;
                    }
                    else if (serviceType == jobTypePersoOnly.Id)
                    {
                        jobTracker.CardEngrResumeId = jobStatusQueue.Id;
                    }
                    else if (serviceType == jobTypePrintingAndPerso.Id)
                    {
                        jobTracker.CardEngrResumeId = jobStatusQueue.Id;
                    }
                    else if (serviceType == jobTypePersoAndMailing.Id)
                    {
                        jobTracker.CardEngrResumeId = jobStatusQueue.Id;
                    }
                    else if (serviceType == jobTypePrintingPersoAndMailing.Id)
                    {
                        jobTracker.CardEngrResumeId = jobStatusQueue.Id;
                    }

                    #endregion

                    jobTracker.ModifiedOn           = DateTime.Now;
                    context.Entry(jobTracker).State = EntityState.Modified;
                    await context.SaveChangesAsync();

                    #endregion
                }
            }

            return(Ok <Sid05QA>(entity));
        }
Example #7
0
        public async Task <IHttpActionResult> UpdateJobSlitQCAnalysis(int id, JobSplitQCAnalysis entity)
        {
            string userId = User.Identity.GetUserId();
            //JobSplitQCAnalysis existingEntity = await context.JobSplitQCAnalysis.FindAsync(entity.Id);
            JobSplit jobSplit = await context.JobSplits.FindAsync(entity.JobSplitId);

            //if (entity == null) { return NotFound(); }
            //if (id != entity.Id) { return BadRequest(ModelState); }
            //if (entity == null)
            //{
            //    //return BadRequest(ModelState);
            //    var message = string.Format("Entry is empty");
            //    HttpError err = new HttpError(message);
            //    return ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, err));

            //}

            ////if (existingEntity != null && context.Entry(existingEntity).State != EntityState.Detached)
            ////{
            ////    context.Entry(existingEntity).State = EntityState.Detached;
            ////}

            //var local = context.Set<JobSplitQCAnalysis>().Local.FirstOrDefault(f => f.Id == entity.Id);
            //if (local != null) { context.Entry(local).State = EntityState.Detached; }

            // Update JobTracker
            var jobStatusWIP         = _repo.FindJobStatusByName("WIP");
            var jobStatusCompleted   = _repo.FindJobStatusByName("Completed");
            var jobStatusQueue       = _repo.FindJobStatusByName("Queue");
            var jobStatusNotRequired = _repo.FindJobStatusByName("Not Required");

            var jobTracker = await context.JobTrackers.FindAsync(jobSplit.JobTrackerId);

            var job = await context.Jobs.FindAsync(jobTracker.JobId);

            var jobTypePersoOnly               = _repo.FindJobTypeByName("Perso Only");
            var jobTypePrintingOnly            = _repo.FindJobTypeByName("Printing Only");
            var jobTypePrintingAndPerso        = _repo.FindJobTypeByName("Printing And Perso");
            var jobTypePrintingPersoAndMailing = _repo.FindJobTypeByName("Printing, Perso And Mailing");
            var jobTypePersoAndMailing         = _repo.FindJobTypeByName("Perso And Mailing");
            var serviceType = job.ServiceTypeId;

            // Update JobTracker
            #region JobTrackerUpdateFlow

            if (serviceType == jobTypePrintingOnly.Id)
            {
                jobTracker.DispatchId = jobStatusQueue.Id;
            }
            else if (serviceType == jobTypePersoOnly.Id)
            {
                //jobTracker.DispatchId = jobStatusQueue.Id;
                if (jobTracker.QCId == jobStatusQueue.Id)
                {
                    jobTracker.QCId       = jobStatusWIP.Id;
                    jobTracker.DispatchId = jobStatusQueue.Id;
                }
            }
            else if (serviceType == jobTypePrintingAndPerso.Id)
            {
                // For Perso Region
                if (jobTracker.QCId == jobStatusQueue.Id)
                {
                    jobTracker.QCId       = jobStatusWIP.Id;
                    jobTracker.DispatchId = jobStatusQueue.Id;
                }
            }
            else if (serviceType == jobTypePersoAndMailing.Id)
            {
                //jobTracker.MailingId = jobStatusQueue.Id;
                if (jobTracker.QCId == jobStatusQueue.Id)
                {
                    jobTracker.QCId      = jobStatusWIP.Id;
                    jobTracker.MailingId = jobStatusQueue.Id;
                }
            }
            else if (serviceType == jobTypePrintingPersoAndMailing.Id)
            {
                // For Perso Region
                if (jobTracker.QCId == jobStatusQueue.Id)
                {
                    jobTracker.QCId      = jobStatusWIP.Id;
                    jobTracker.MailingId = jobStatusQueue.Id;
                }
                //jobTracker.MailingId = jobStatusQueue.Id;
            }

            #endregion

            jobTracker.ModifiedOn           = DateTime.Now;
            context.Entry(jobTracker).State = EntityState.Modified;
            await context.SaveChangesAsync();

            return(Ok());
        }
        public async Task <IHttpActionResult> CreateFirstCard(IList <FirstCardModel> entity)
        {
            userId = User.Identity.GetUserId();

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var jobTrackerId = entity[0].JobTrackerId;
            var jobTracker   = await context.JobTrackers.FindAsync(jobTrackerId);

            var job = await context.Jobs.FindAsync(jobTracker.JobId);

            var department = _repo.FindDepartmentByName("Mailing");

            // Create the JobSplit
            foreach (var m in entity)
            {
                var newJobSlit = new JobSplit()
                {
                    JobTrackerId = m.JobTrackerId,
                    DepartmentId = department.Id,
                    SidMachineId = m.SidMachineId,
                    RangeFrom    = m.RangeFrom,
                    RangeTo      = m.RangeTo,
                    CreatedById  = userId,
                    CreatedOn    = DateTime.Now
                };

                // Create the item
                var t1 = await CreateJobSlit(newJobSlit);
            }


            ///
            var jobStatusWIP   = _repo.FindJobStatusByName("WIP");
            var jobStatusQueue = _repo.FindJobStatusByName("Queue");

            var jobTypePersoOnly               = _repo.FindJobTypeByName("Perso Only");
            var jobTypePrintingOnly            = _repo.FindJobTypeByName("Printing Only");
            var jobTypeMailingOnly             = _repo.FindJobTypeByName("Mailing Only");
            var jobTypePrintingAndPerso        = _repo.FindJobTypeByName("Printing And Perso");
            var jobTypePrintingPersoAndMailing = _repo.FindJobTypeByName("Printing, Perso And Mailing");
            var jobTypePersoAndMailing         = _repo.FindJobTypeByName("Perso And Mailing");

            var serviceType = job.ServiceTypeId;

            // Update JobTracker
            jobTracker.MailingId = jobStatusWIP.Id;

            //// JobServiceType
            #region JobTrackerUpdateFlow

            if (serviceType == jobTypeMailingOnly.Id)
            {
                jobTracker.DispatchId = jobStatusQueue.Id;
            }
            else if (serviceType == jobTypePersoAndMailing.Id)
            {
                jobTracker.DispatchId = jobStatusQueue.Id;
            }
            else if (serviceType == jobTypePrintingPersoAndMailing.Id)
            {
                jobTracker.DispatchId = jobStatusQueue.Id;
            }

            #endregion

            jobTracker.ModifiedOn           = DateTime.Now;
            context.Entry(jobTracker).State = EntityState.Modified;
            await context.SaveChangesAsync();

            return(Ok());
        }