Exemplo n.º 1
0
        public async Task <IHttpActionResult> CreateSidQA(Sid05QA entity)
        {
            userId = User.Identity.GetUserId();

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

            var newEntity = entity;

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

            return(Ok <Sid05QA>(newEntity));
        }
Exemplo n.º 2
0
        public async Task <IHttpActionResult> UpdateQAJobChecks(int id, Sid05QA entity)
        {
            string  userId         = User.Identity.GetUserId();
            Sid05QA existingEntity = await context.Sid05QAs.FindAsync(entity.Id);

            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 <Sid05QA>().Local.FirstOrDefault(f => f.Id == entity.Id);

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

            entity.CreatedOn   = DateTime.Now;
            entity.CreatedById = userId;

            context.Sid05QAs.Attach(entity);
            context.Entry(entity).State = EntityState.Modified;
            await context.SaveChangesAsync();

            return(Ok <Sid05QA>(entity));
        }
Exemplo n.º 3
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));
        }
Exemplo n.º 5
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));
        }
Exemplo n.º 6
0
        public async Task <IHttpActionResult> CreateClients(Sid05QA entity)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            context.Sid05QAs.Add(entity);
            await context.SaveChangesAsync();

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

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

            Job 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
            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();

            return(Ok <Sid05QA>(entity));
        }