Beispiel #1
0
        public async Task RetrieveJobAndCheckCanBeProcessed_ApiReturnsIncomplete_ReturnsCorrectly()
        {
            //Arrange
            var jobsApiClient = Substitute.For <IJobsApiClient>();
            var policies      = new JobManagementResiliencePolicies {
                JobsApiClient = Policy.NoOpAsync()
            };
            var logger = Substitute.For <ILogger>();

            var jvm = new JobViewModel {
                CompletionStatus = null
            };

            var jobApiResponse = new ApiResponse <JobViewModel>(HttpStatusCode.OK, jvm);

            jobsApiClient
            .GetJobById(Arg.Any <string>())
            .Returns(jobApiResponse);

            var jobManagement = new JobManagement(jobsApiClient, logger, policies);

            var jobId = "3456";

            //Act
            var viewModel = await jobManagement.RetrieveJobAndCheckCanBeProcessed(jobId);

            //Assert
            await jobsApiClient
            .Received(1)
            .GetJobById(jobId);

            viewModel
            .Should()
            .Be(jvm);
        }
        public async Task UpdateJobStatus_ApiResponseSuccess_Runs()
        {
            //Arrange
            IJobsApiClient jobsApiClient             = Substitute.For <IJobsApiClient>();
            JobManagementResiliencePolicies policies = new JobManagementResiliencePolicies
            {
                JobsApiClient = Policy.NoOpAsync()
            };
            IMessengerService messengerService = Substitute.For <IMessengerService>();
            ILogger           logger           = Substitute.For <ILogger>();

            ApiResponse <JobLog> jobLogApiResponse = new ApiResponse <JobLog>(HttpStatusCode.OK, new JobLog());

            jobsApiClient
            .AddJobLog(Arg.Any <string>(), Arg.Any <JobLogUpdateModel>())
            .Returns(jobLogApiResponse);

            JobLogUpdateModel updateModel = new JobLogUpdateModel();

            JobManagement jobManagement = new JobManagement(jobsApiClient, logger, policies, messengerService);

            string jobId = "3456";

            //Act
            await jobManagement.UpdateJobStatus(jobId, updateModel);

            //Assert
            await jobsApiClient
            .Received(1)
            .AddJobLog(jobId, updateModel);

            logger
            .Received(0)
            .Write(Arg.Any <LogEventLevel>(), Arg.Any <string>());
        }
Beispiel #3
0
        public static void UpdateJobMove(string JobId)
        {
            try
            {
                Form     form = Application.OpenForms["FormRunningScreen"];
                CheckBox tb;

                if (form == null)
                {
                    return;
                }

                tb = form.Controls.Find("use_loadport01_ck", true).FirstOrDefault() as CheckBox;

                if (tb == null)
                {
                    return;
                }

                if (tb.InvokeRequired)
                {
                    UpdatePresent ph = new UpdatePresent(UpdateJobMove);
                    tb.BeginInvoke(ph, JobId);
                }
                else
                {
                    Job Job = JobManagement.Get(JobId);
                    if (Job != null)
                    {
                        Node LastNode    = NodeManagement.Get(Job.LastNode);
                        Node CurrentNode = NodeManagement.Get(Job.Position);
                        if (LastNode != null)
                        {
                            Label present = form.Controls.Find(Job.LastNode + "_Slot_" + Job.LastSlot, true).FirstOrDefault() as Label;
                            if (present != null)
                            {
                                present.Text      = "No wafer";
                                present.BackColor = Color.DimGray;
                                present.ForeColor = Color.White;
                            }
                        }
                        if (CurrentNode != null)
                        {
                            Label present = form.Controls.Find(Job.Position + "_Slot_" + Job.Slot, true).FirstOrDefault() as Label;
                            if (present != null)
                            {
                                present.Text = Job.Host_Job_Id;

                                present.BackColor = Color.Green;
                                present.ForeColor = Color.White;
                            }
                        }
                    }
                }
            }
            catch
            {
                logger.Error("UpdateJobMove: Update fail.");
            }
        }
        public async Task AddJobLog_Called_ReturnsJobLog()
        {
            string jobId = "5678";

            IJobsApiClient jobsApiClient             = Substitute.For <IJobsApiClient>();
            JobManagementResiliencePolicies policies = new JobManagementResiliencePolicies
            {
                JobsApiClient = Policy.NoOpAsync()
            };
            IMessengerService messengerService = Substitute.For <IMessengerService>();
            ILogger           logger           = Substitute.For <ILogger>();

            JobLog jobLog = new JobLog
            {
                JobId = jobId
            };
            ApiResponse <JobLog> jobLogApiResponse = new ApiResponse <JobLog>(HttpStatusCode.OK, jobLog);

            JobLogUpdateModel jobLogUpdateModel = new JobLogUpdateModel();

            jobsApiClient
            .AddJobLog(jobId, jobLogUpdateModel)
            .Returns(jobLogApiResponse);

            JobManagement jobManagement = new JobManagement(jobsApiClient, logger, policies, messengerService);

            //Act
            JobLog result = await jobManagement.AddJobLog(jobId, jobLogUpdateModel);

            Assert.AreEqual(result, jobLog);

            await jobsApiClient
            .Received(1)
            .AddJobLog(jobId, jobLogUpdateModel);
        }
        public async Task UpdateJobStatusInternal_ApiResponseFailure_Logs(ApiResponse <JobLog> jobLogApiResponse)
        {
            //Arrange
            IJobsApiClient jobsApiClient             = Substitute.For <IJobsApiClient>();
            JobManagementResiliencePolicies policies = new JobManagementResiliencePolicies
            {
                JobsApiClient = Policy.NoOpAsync()
            };
            IMessengerService messengerService = Substitute.For <IMessengerService>();
            ILogger           logger           = Substitute.For <ILogger>();

            jobsApiClient
            .AddJobLog(Arg.Any <string>(), Arg.Any <JobLogUpdateModel>())
            .Returns(jobLogApiResponse);

            JobLogUpdateModel updateModel = new JobLogUpdateModel();

            JobManagement jobManagement = new JobManagement(jobsApiClient, logger, policies, messengerService);

            string jobId = "3456";

            //Act
            await jobManagement.UpdateJobStatus(jobId, updateModel);

            //Assert
            await jobsApiClient
            .Received(1)
            .AddJobLog(jobId, updateModel);

            logger
            .Received(1)
            .Write(LogEventLevel.Error, $"Failed to add a job log for job id '{jobId}'");
        }
Beispiel #6
0
        private void FormWafer_Layout(object sender, LayoutEventArgs e)
        {
            WaferList_tv.Nodes.Clear();
            Position_cb.Items.Clear();

            foreach (Node node in NodeManagement.GetList())
            {
                if (!node.Type.Equals("OCR"))
                {
                    TreeNode each = new TreeNode(node.Name);

                    Position_cb.Items.Add(node.Name);
                    List <Job> jobList = node.JobList.Values.ToList();
                    jobList.Sort((x, y) => { return(Convert.ToInt16(x.Slot).CompareTo(Convert.ToInt16(y.Slot))); });
                    foreach (Job j in jobList)
                    {
                        if (JobManagement.Get(j.Job_Id) != null)
                        {
                            each.Nodes.Add(j.Job_Id, j.Job_Id + "(Slot-" + j.Slot + ")");
                        }
                    }
                    WaferList_tv.Nodes.Add(each);
                }
            }
        }
        public async Task GetJobDetails_ReturnsJobViewModel()
        {
            IJobsApiClient jobsApiClient             = Substitute.For <IJobsApiClient>();
            JobManagementResiliencePolicies policies = new JobManagementResiliencePolicies
            {
                JobsApiClient = Policy.NoOpAsync()
            };
            IMessengerService messengerService = Substitute.For <IMessengerService>();
            ILogger           logger           = Substitute.For <ILogger>();

            JobViewModel jvm = new JobViewModel
            {
                CompletionStatus = null
            };

            ApiResponse <JobViewModel> jobApiResponse = new ApiResponse <JobViewModel>(HttpStatusCode.OK, jvm);

            jobsApiClient
            .GetJobById(Arg.Any <string>())
            .Returns(jobApiResponse);

            JobManagement jobManagement = new JobManagement(jobsApiClient, logger, policies, messengerService);

            string jobId = "3456";

            //Act
            JobViewModel viewModel = await jobManagement.GetJobById(jobId);

            //Assert
            viewModel
            .Should()
            .Be(jvm);
        }
Beispiel #8
0
        public async Task RetrieveJobAndCheckCanBeProcessed_Fails_LogsAndErrors(ApiResponse <JobViewModel> jobApiResponse,
                                                                                string jobId,
                                                                                string errorMessage,
                                                                                LogEventLevel logEventLevel)
        {
            //Arrange
            var jobsApiClient = Substitute.For <IJobsApiClient>();
            var policies      = new JobManagementResiliencePolicies {
                JobsApiClient = Policy.NoOpAsync()
            };
            var logger = Substitute.For <ILogger>();

            jobsApiClient
            .GetJobById(Arg.Any <string>())
            .Returns(jobApiResponse);

            var jobManagement = new JobManagement(jobsApiClient, logger, policies);

            Func <Task> test = async() => await jobManagement.RetrieveJobAndCheckCanBeProcessed(jobId);

            test
            .Should().Throw <Exception>()
            .Which
            .Message
            .Should().Be(errorMessage);

            await jobsApiClient
            .Received(1)
            .GetJobById(jobId);

            logger
            .Received(1)
            .Write(logEventLevel, errorMessage);
        }
        public async Task WaitForJobsToCompleteWithJobsFailed_ReturnsFalse(bool useServiceBus)
        {
            IJobsApiClient jobsApiClient             = Substitute.For <IJobsApiClient>();
            JobManagementResiliencePolicies policies = new JobManagementResiliencePolicies
            {
                JobsApiClient = Policy.NoOpAsync()
            };

            IMessengerService messengerService = null;

            if (useServiceBus)
            {
                messengerService = Substitute.For <IMessengerService, IServiceBusService>();
            }
            else
            {
                messengerService = Substitute.For <IMessengerService, IQueueService>();
            }

            ILogger logger = Substitute.For <ILogger>();

            JobManagement jobManagement = new JobManagement(jobsApiClient, logger, policies, messengerService);

            string jobId = "3456";

            jobsApiClient
            .GetLatestJobsForSpecification("specificationId", Arg.Is <string[]>(_ => _.Single() == "PopulateScopedProviders"))
            .Returns(new ApiResponse <IDictionary <string, JobSummary> >(HttpStatusCode.OK, new Dictionary <string, JobSummary> {
                { string.Empty, new JobSummary {
                      RunningStatus = RunningStatus.Completed, CompletionStatus = CompletionStatus.Failed, JobId = jobId
                  } }
            }));

            messengerService
            .ReceiveMessage("topic/Subscriptions/correlationId", Arg.Any <Predicate <JobSummary> >(), TimeSpan.FromMilliseconds(600000))
            .Returns(new JobSummary
            {
                CompletionStatus = CompletionStatus.Failed
            });

            //Act
            bool jobsComplete = await jobManagement.QueueJobAndWait(async() => await Task.Run(() => { return(true); }), "PopulateScopedProviders", "specificationId", "correlationId", "topic");

            //Assert
            if (useServiceBus)
            {
                await((IServiceBusService)messengerService)
                .Received(1)
                .CreateSubscription("topic", "correlationId", Arg.Is <TimeSpan>(_ => _.Days == 1));

                await messengerService
                .Received(1)
                .ReceiveMessage("topic/Subscriptions/correlationId", Arg.Any <Predicate <JobSummary> >(), TimeSpan.FromMilliseconds(600000));
            }

            jobsComplete
            .Should()
            .BeFalse();
        }
        public async Task <JobManagement> ApplytoJob(JobManagement appliance)
        {
            await _context.JobManagements.AddAsync(appliance);

            await _context.SaveChangesAsync();

            return(appliance);
        }
Beispiel #11
0
        private void UnAssignPort(object sender, EventArgs e)
        {
            if ((CurrentSelected as DataGridView).SelectedRows.Count == 0)
            {
                MessageBox.Show("請選擇來源Slot");
            }
            else if ((CurrentSelected as DataGridView).SelectedRows.Count == 1)
            {
                string waferId     = (CurrentSelected as DataGridView).SelectedRows[0].Cells["Job_Id"].Value.ToString();
                string OrgDest     = (CurrentSelected as DataGridView).SelectedRows[0].Cells["Destination"].Value.ToString();
                string OrgDestSlot = (CurrentSelected as DataGridView).SelectedRows[0].Cells["DestinationSlot"].Value.ToString();
                Job    wafer       = JobManagement.Get(waferId);
                if (wafer != null)
                {
                    wafer.UnAssignPort();
                    wafer.NeedProcess = false;
                    //wafer.Position = PortName;
                    if (!OrgDest.Equals(""))
                    {
                        NodeManagement.Get(OrgDest).RemoveReserve(OrgDestSlot);
                    }

                    (CurrentSelected as DataGridView).Refresh();
                }
                else
                {
                    MessageBox.Show("找不到此Wafer資料:" + wafer.Job_Id);
                }
            }
            else if ((CurrentSelected as DataGridView).SelectedRows.Count > 1)
            {
                foreach (DataGridViewRow each in (CurrentSelected as DataGridView).SelectedRows)
                {
                    string waferId     = each.Cells["Job_Id"].Value.ToString();
                    string OrgDest     = each.Cells["Destination"].Value.ToString();
                    string OrgDestSlot = each.Cells["DestinationSlot"].Value.ToString();
                    Job    wafer       = JobManagement.Get(waferId);
                    if (wafer != null)
                    {
                        wafer.UnAssignPort();
                        wafer.NeedProcess = false;
                        if (!OrgDest.Equals(""))
                        {
                            NodeManagement.Get(OrgDest).RemoveReserve(OrgDestSlot);
                        }
                    }
                }
                (CurrentSelected as DataGridView).Refresh();
                MonitoringUpdate.UpdateNodesJob((CurrentSelected as DataGridView).Name.Replace("Assign_Gv", ""));
            }
        }
Beispiel #12
0
        private Node SearchLoadport()
        {
            Node result          = null;
            var  AvailableWafers = from job in JobManagement.GetJobList()
                                   where job.NeedProcess
                                   orderby job.AssignTime
                                   select job;

            if (AvailableWafers.Count() != 0)
            {
                result = NodeManagement.Get(AvailableWafers.First().Position);
            }
            return(result);
        }
Beispiel #13
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            Job job = JobManagement.Get(WaferID_tb.Text);

            if (job != null)
            {
                //job.Job_Id = WaferID_tb.Text;
                job.NeedProcess = NeedProcess_ck.Checked;
                job.ProcessFlag = ProcessFlag_ck.Checked;
                job.AlignerFlag = AlignFlag_ck.Checked;
                job.OCRFlag     = OCRFlag_ck.Checked;
                Node NewPosition = NodeManagement.Get(Position_cb.Text);
                if (NewPosition != null)
                {
                    Job tmp;
                    if (!job.Position.ToUpper().Equals(Position_cb.Text) || !job.Slot.Equals(Slot_cb.Text))
                    {
                        if (NewPosition.JobList.TryAdd(Slot_cb.Text, job))
                        {
                            Node OrgPosition = NodeManagement.Get(job.Position);
                            if (OrgPosition != null)
                            {
                                OrgPosition.JobList.TryRemove(job.Slot, out tmp);
                                job.LastNode = job.Position;
                                job.LastSlot = job.Slot;

                                job.Position = Position_cb.Text;
                                job.Slot     = Slot_cb.Text;

                                MonitoringUpdate.UpdateJobMove(job.Job_Id);
                            }
                        }
                        else
                        {
                            MessageBox.Show("Wafer is Exist in new Position");
                            Position_cb.Text = job.Position;
                            Slot_cb.Text     = job.Slot;
                        }
                    }
                }



                job.Host_Job_Id = OCRResult_tb.Text;
                MessageBox.Show("成功");
            }
        }
        public async Task TryQueueJobs_Called_ReturnsJobCreateResults()
        {
            IJobsApiClient jobsApiClient             = Substitute.For <IJobsApiClient>();
            JobManagementResiliencePolicies policies = new JobManagementResiliencePolicies
            {
                JobsApiClient = Policy.NoOpAsync()
            };
            IMessengerService messengerService = Substitute.For <IMessengerService>();
            ILogger           logger           = Substitute.For <ILogger>();

            JobCreateModel createModelOne = new JobCreateModel();
            JobCreateModel createModelTwo = new JobCreateModel();

            JobCreateResult expectedCreateResultOne = new JobCreateResult();
            JobCreateResult expectedCreateResultTwo = new JobCreateResult();

            IEnumerable <JobCreateModel> createModels =
                new []
            {
                createModelOne,
                createModelTwo
            };

            jobsApiClient
            .TryCreateJobs(Arg.Is <IEnumerable <JobCreateModel> >(_ => _.SequenceEqual(createModels)))
            .Returns(new ApiResponse <IEnumerable <JobCreateResult> >(HttpStatusCode.OK, new[]
            {
                expectedCreateResultOne,
                expectedCreateResultTwo
            }));

            JobManagement jobManagement = new JobManagement(jobsApiClient, logger, policies, messengerService);

            //Act
            IEnumerable <JobCreateResult> actualResult = await jobManagement.TryQueueJobs(createModels);

            actualResult
            .Should()
            .BeEquivalentTo <JobCreateResult>(new []
            {
                expectedCreateResultOne,
                expectedCreateResultTwo
            });
        }
Beispiel #15
0
        private void WaferList_tv_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            Job job = JobManagement.Get(e.Node.Name);

            if (job != null)
            {
                WaferID_tb.Text        = job.Job_Id;
                NeedProcess_ck.Checked = job.NeedProcess;
                ProcessFlag_ck.Checked = job.ProcessFlag;
                AlignFlag_ck.Checked   = job.AlignerFlag;
                OCRFlag_ck.Checked     = job.OCRFlag;
                Position_cb.Text       = job.Position.ToUpper();
                Slot_cb.Text           = job.Slot;
                OCRResult_tb.Text      = job.Host_Job_Id;
                List <Job> tmp = new List <Job>();
                tmp.Add(job);
                WaferInfo_gv.DataSource = tmp;
            }
        }
        public async Task QueueJobs_Called_ReturnsJobs()
        {
            string specificationId = "1234";
            string jobId           = "3456";

            IJobsApiClient jobsApiClient             = Substitute.For <IJobsApiClient>();
            JobManagementResiliencePolicies policies = new JobManagementResiliencePolicies
            {
                JobsApiClient = Policy.NoOpAsync()
            };
            IMessengerService messengerService = Substitute.For <IMessengerService>();
            ILogger           logger           = Substitute.For <ILogger>();

            IEnumerable <Job> jobApiResponse = new List <Job>
            {
                new Job
                {
                    Id = jobId
                }
            };

            IEnumerable <JobCreateModel> jobCreateModel =
                new List <JobCreateModel>
            {
                new JobCreateModel
                {
                    SpecificationId = specificationId
                }
            };

            jobsApiClient
            .CreateJobs(jobCreateModel)
            .Returns(jobApiResponse);

            JobManagement jobManagement = new JobManagement(jobsApiClient, logger, policies, messengerService);

            //Act
            await jobManagement.QueueJobs(jobCreateModel);

            await jobsApiClient
            .Received(1)
            .CreateJobs(jobCreateModel);
        }
        public async Task GetNonCompletedJobsWithinTimeFrame_Called_ReturnsJobSummaries()
        {
            string jobId = "5678";

            DateTimeOffset from = DateTimeOffset.UtcNow.AddDays(-2);
            DateTimeOffset to   = DateTimeOffset.UtcNow.AddDays(-1);

            IJobsApiClient jobsApiClient             = Substitute.For <IJobsApiClient>();
            JobManagementResiliencePolicies policies = new JobManagementResiliencePolicies
            {
                JobsApiClient = Policy.NoOpAsync()
            };
            IMessengerService messengerService = Substitute.For <IMessengerService>();
            ILogger           logger           = Substitute.For <ILogger>();


            JobSummary jobSummary = new JobSummary
            {
                JobId = jobId
            };
            IEnumerable <JobSummary> jobSummaries = new List <JobSummary>
            {
                jobSummary
            };
            ApiResponse <IEnumerable <JobSummary> > jobSummariesApiResponse
                = new ApiResponse <IEnumerable <JobSummary> >(HttpStatusCode.OK, jobSummaries);

            jobsApiClient
            .GetNonCompletedJobsWithinTimeFrame(from, to)
            .Returns(jobSummariesApiResponse);

            JobManagement jobManagement = new JobManagement(jobsApiClient, logger, policies, messengerService);

            //Act
            IEnumerable <JobSummary> result = await jobManagement.GetNonCompletedJobsWithinTimeFrame(from, to);

            Assert.AreEqual(result, jobSummaries);

            await jobsApiClient
            .Received(1)
            .GetNonCompletedJobsWithinTimeFrame(from, to);
        }
Beispiel #18
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            Job job = JobManagement.Get(WaferID_tb.Text);

            if (job != null)
            {
                Node OrgPosition = NodeManagement.Get(job.Position);
                Job  tmp;
                OrgPosition.JobList.TryRemove(job.Slot, out tmp);
                job.LastNode = job.Position;
                job.LastSlot = job.Slot;
                job.Position = "";
                job.Slot     = "";
                MonitoringUpdate.UpdateJobMove(job.Job_Id);

                JobManagement.Remove(tmp.Job_Id);
                ClearForm();
                MessageBox.Show("成功");
            }
        }
        public async Task GetLatestJobForSpecification_Called_ReturnsJobSummary()
        {
            string specificationId = "1234";
            string jobType         = "3456";
            string jobId           = "5678";

            IJobsApiClient jobsApiClient             = Substitute.For <IJobsApiClient>();
            JobManagementResiliencePolicies policies = new JobManagementResiliencePolicies
            {
                JobsApiClient = Policy.NoOpAsync()
            };
            IMessengerService messengerService = Substitute.For <IMessengerService>();
            ILogger           logger           = Substitute.For <ILogger>();

            string[] jobTypes = new string[]
            {
                jobType
            };

            IDictionary <string, JobSummary> jobSummary = new Dictionary <string, JobSummary> {
                { string.Empty, new JobSummary {
                      JobId = jobId
                  } }
            };
            ApiResponse <IDictionary <string, JobSummary> > jobSummaryApiResponse = new ApiResponse <IDictionary <string, JobSummary> >(HttpStatusCode.OK, jobSummary);

            jobsApiClient
            .GetLatestJobsForSpecification(specificationId, jobTypes)
            .Returns(jobSummaryApiResponse);

            JobManagement jobManagement = new JobManagement(jobsApiClient, logger, policies, messengerService);

            //Act
            IDictionary <string, JobSummary> result = await jobManagement.GetLatestJobsForSpecification(specificationId, jobTypes);

            Assert.AreEqual(result, jobSummary);

            await jobsApiClient
            .Received(1)
            .GetLatestJobsForSpecification(specificationId, jobTypes);
        }
        public void TryQueueJob_ThrowsJobsNotCreatedExceptionIfApiResponseNull()
        {
            string specificationId = "1234";

            JobManagement jobManagement = new JobManagement(Substitute.For <IJobsApiClient>(),
                                                            Logger.None,
                                                            new JobManagementResiliencePolicies
            {
                JobsApiClient = Policy.NoOpAsync()
            },
                                                            Substitute.For <IMessengerService>());

            Func <Task <JobCreateResult> > invocation = () => jobManagement.TryQueueJob(new JobCreateModel
            {
                SpecificationId = specificationId
            });

            invocation
            .Should()
            .Throw <JobsNotCreatedException>();
        }
        public void GetLatestJobForSpecification_UnsuccessfulApiResponse_ThrowsJobsNotRetrievedException()
        {
            string specificationId = "1234";
            string jobType         = "3456";

            IJobsApiClient jobsApiClient             = Substitute.For <IJobsApiClient>();
            JobManagementResiliencePolicies policies = new JobManagementResiliencePolicies
            {
                JobsApiClient = Policy.NoOpAsync()
            };
            IMessengerService messengerService = Substitute.For <IMessengerService>();
            ILogger           logger           = Substitute.For <ILogger>();

            string[] jobTypes = new string[]
            {
                jobType
            };

            string message = $"Error while retrieving latest jobs for Specifiation: {specificationId} and JobTypes: {string.Join(',', jobTypes)}";

            ApiResponse <IDictionary <string, JobSummary> > jobSummaryApiResponse = new ApiResponse <IDictionary <string, JobSummary> >(HttpStatusCode.BadRequest);

            jobsApiClient
            .GetLatestJobsForSpecification(specificationId, jobTypes)
            .Returns(jobSummaryApiResponse);

            JobManagement jobManagement = new JobManagement(jobsApiClient, logger, policies, messengerService);

            //Act
            Func <Task> invocation = async() => await jobManagement.GetLatestJobsForSpecification(specificationId, jobTypes);

            //Arrange
            invocation.Should()
            .Throw <JobsNotRetrievedException>()
            .WithMessage(message);
        }
        public async Task WaitForJobsToCompleteWithNoJobsRunning_ReturnsTrue()
        {
            IJobsApiClient jobsApiClient             = Substitute.For <IJobsApiClient>();
            JobManagementResiliencePolicies policies = new JobManagementResiliencePolicies
            {
                JobsApiClient = Policy.NoOpAsync()
            };
            IMessengerService messengerService = Substitute.For <IMessengerService>();
            ILogger           logger           = Substitute.For <ILogger>();

            JobManagement jobManagement = new JobManagement(jobsApiClient, logger, policies, messengerService);

            jobsApiClient
            .GetLatestJobsForSpecification("specificationId", Arg.Is <string[]>(_ => _.Single() == "PopulateScopedProviders"))
            .Returns(new ApiResponse <IDictionary <string, JobSummary> >(HttpStatusCode.NoContent));

            //Act
            bool jobsComplete = await jobManagement.QueueJobAndWait(async() => await Task.Run(() => { return(true); }), "PopulateScopedProviders", "specificationId", "correlationId", "topic");

            //Assert
            jobsComplete
            .Should()
            .BeTrue();
        }
Beispiel #23
0
        public async Task <IActionResult> ApplyToJob([FromBody] JobManagement appliance)
        {
            var _appliance = await _jobManagementRepository.ApplytoJob(appliance);

            return(Ok(_appliance));
        }
Beispiel #24
0
        private void AssignPort(object sender, EventArgs e)
        {
            string PortName = (sender as MenuItem).Text.Split('-')[0];
            string LDPort   = (CurrentSelected as DataGridView).Name.Replace("Assign_Gv", "");
            Node   UD       = NodeManagement.Get(PortName);
            Node   LD       = NodeManagement.Get(LDPort);

            UD.Mode     = "UD";
            LD.Mode     = "LD";
            LD.DestPort = UD.Name;
            WaferAssignUpdate.UpdateLoadPortMode(UD.Name, UD.Mode);
            WaferAssignUpdate.UpdateLoadPortMode(LD.Name, LD.Mode);
            string Slot = (sender as MenuItem).Text.Split('-')[1];

            if ((CurrentSelected as DataGridView).SelectedRows.Count == 0)
            {
                MessageBox.Show("請選擇來源Slot");
            }
            else if ((CurrentSelected as DataGridView).SelectedRows.Count == 1)
            {
                string waferId     = (CurrentSelected as DataGridView).SelectedRows[0].Cells["Job_Id"].Value.ToString();
                string OrgDest     = (CurrentSelected as DataGridView).SelectedRows[0].Cells["Destination"].Value.ToString();
                string OrgDestSlot = (CurrentSelected as DataGridView).SelectedRows[0].Cells["DestinationSlot"].Value.ToString();

                Job UDSlot = UD.GetJob(Slot);
                if (UDSlot == null)
                {
                    MessageBox.Show(PortName + "沒有FOUP或是尚未進行Mapping");
                    return;
                }
                if (UDSlot.MapFlag == false || LD.Name.Equals(UD.Name))
                {
                    Job wafer = JobManagement.Get(waferId);
                    if (wafer != null)
                    {
                        wafer.AssignPort(PortName, Slot);

                        wafer.NeedProcess = true;
                        wafer.ProcessFlag = false;
                        //wafer.Position = PortName;
                        if (!OrgDest.Equals(""))
                        {
                            NodeManagement.Get(OrgDest).RemoveReserve(OrgDestSlot);
                        }
                        NodeManagement.Get(PortName).AddReserve(Slot, wafer);
                        (CurrentSelected as DataGridView).Refresh();
                        MonitoringUpdate.UpdateNodesJob((CurrentSelected as DataGridView).Name.Replace("Assign_Gv", ""));
                    }
                    else
                    {
                        MessageBox.Show("找不到此Wafer資料");
                    }
                }
            }
            else if ((CurrentSelected as DataGridView).SelectedRows.Count > 1)
            {
                int StartSlot = Convert.ToInt32(Slot);
                List <DataGridViewRow> tmp = new List <DataGridViewRow>();
                foreach (DataGridViewRow each in (CurrentSelected as DataGridView).SelectedRows)
                {
                    tmp.Add(each);
                }
                tmp.Sort((x, y) => { return(-x.Index.CompareTo(y.Index)); });
                foreach (DataGridViewRow each in tmp)
                {
                    string waferId     = each.Cells["Job_Id"].Value.ToString();
                    string OrgDest     = each.Cells["Destination"].Value.ToString();
                    string OrgDestSlot = each.Cells["DestinationSlot"].Value.ToString();
                    Job    wafer       = JobManagement.Get(waferId);
                    if (wafer != null)
                    {
                        while (true)
                        {
                            if (NodeManagement.Get(PortName).GetJob(StartSlot.ToString()).MapFlag == false || LD.Name.Equals(UD.Name))
                            {
                                wafer.AssignPort(PortName, StartSlot.ToString());

                                //wafer.Position = PortName;
                                wafer.NeedProcess = true;
                                wafer.ProcessFlag = false;
                                if (!OrgDest.Equals(""))
                                {
                                    NodeManagement.Get(OrgDest).RemoveReserve(OrgDestSlot);
                                }
                                NodeManagement.Get(PortName).AddReserve(StartSlot.ToString(), wafer);

                                break;
                            }
                            else
                            {
                                StartSlot++;
                                if (StartSlot > 25)
                                {
                                    break;
                                }
                            }
                        }
                        StartSlot++;
                        if (StartSlot > 25)
                        {
                            break;
                        }
                    }
                }
                (CurrentSelected as DataGridView).Refresh();
                MonitoringUpdate.UpdateNodesJob((CurrentSelected as DataGridView).Name.Replace("Assign_Gv", ""));
            }
        }
Beispiel #25
0
        private void Assign_Gv_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                ContextMenu m = new ContextMenu();


                string PortName = (sender as DataGridView).Name.Replace("Assign_Gv", "");
                //if (NodeManagement.Get(PortName).Mode.Equals("LD"))
                // {
                if (!NodeManagement.Get(PortName).IsMapping)
                {
                    return;
                }

                CurrentSelected = sender;
                foreach (Node eachPort in NodeManagement.GetLoadPortList())
                {
                    if (!eachPort.IsMapping)
                    {
                        continue;
                    }
                    List <MenuItem> tmpAry    = new List <MenuItem>();
                    bool            findFirst = false;
                    for (int i = 1; i <= 25; i++)
                    {
                        MenuItem tmp = new MenuItem();
                        if (eachPort.Name.Equals(PortName.ToUpper()))
                        {
                            tmp = new MenuItem(eachPort.Name + "-" + i.ToString(), AssignPort);
                            if (!findFirst)
                            {
                                List <DataGridViewRow> JobList = new List <DataGridViewRow>();
                                foreach (DataGridViewRow each in (CurrentSelected as DataGridView).SelectedRows)
                                {
                                    JobList.Add(each);
                                }
                                JobList.Sort((x, y) => { return(-x.Index.CompareTo(y.Index)); });

                                foreach (DataGridViewRow each in JobList)
                                {
                                    string waferId = each.Cells["Job_Id"].Value.ToString();
                                    Job    wafer   = JobManagement.Get(waferId);
                                    if (wafer == null)
                                    {
                                        MessageBox.Show("請選擇Wafer");
                                        return;
                                    }
                                    if (!eachPort.ReserveList.ContainsKey(i.ToString()))
                                    {
                                        if (wafer.Slot.Equals(i.ToString()))
                                        {
                                            tmp.Enabled = true;
                                            findFirst   = true;
                                            break;
                                        }
                                        else
                                        {
                                            tmp.Enabled = false;
                                        }
                                    }
                                    else
                                    {
                                        tmp.Enabled = false;
                                    }
                                }
                            }
                            else
                            {
                                tmp.Enabled = false;
                            }
                        }
                        else
                        {
                            if (!eachPort.ReserveList.ContainsKey(i.ToString()))
                            {
                                if (eachPort.JobList.ContainsKey(i.ToString()))
                                {
                                    if (eachPort.JobList[i.ToString()].MapFlag)
                                    {
                                        tmp = new MenuItem(eachPort.Name + "-" + i.ToString(), AssignPort);


                                        tmp.Enabled = false;
                                    }
                                    else
                                    {
                                        tmp = new MenuItem(eachPort.Name + "-" + i.ToString(), AssignPort);
                                    }
                                }
                                else
                                {
                                    tmp = new MenuItem(eachPort.Name + "-" + i.ToString(), AssignPort);
                                }
                            }
                            else
                            {
                                tmp         = new MenuItem(eachPort.Name + "-" + i.ToString(), AssignPort);
                                tmp.Enabled = false;
                            }
                        }
                        tmpAry.Add(tmp);
                    }
                    m.MenuItems.Add(eachPort.Name, tmpAry.ToArray());
                }
                m.MenuItems.Add(new MenuItem("取消", UnAssignPort));

                //}

                m.Show((DataGridView)sender, new Point(e.X, e.Y));
            }
        }
Beispiel #26
0
        public static void UpdateLoadPortMapping(string PortName, string Mapping)
        {
            try
            {
                Form         form = Application.OpenForms["FormWaferMapping"];
                DataGridView Port_gv;
                if (form == null)
                {
                    return;
                }

                Port_gv = form.Controls.Find(PortName + "Assign_Gv", true).FirstOrDefault() as DataGridView;
                if (Port_gv == null)
                {
                    return;
                }

                if (Port_gv.InvokeRequired)
                {
                    UpdatePort ph = new UpdatePort(UpdateLoadPortMapping);
                    Port_gv.BeginInvoke(ph, PortName, Mapping);
                }
                else
                {
                    Node port = NodeManagement.Get(PortName);
                    //List<Job> MappingData = new List<Job>();
                    //port.IsMapping = true;
                    if (Mapping.Equals(""))
                    {
                        foreach (Job eachJob in port.JobList.Values)
                        {
                            JobManagement.Remove(eachJob.Job_Id);
                        }
                        port.JobList.Clear();
                        port.ReserveList.Clear();
                        JobManagement.ClearAssignJobByPort(port.Name);
                    }
                    else
                    {
                        int currentIdx = 1;
                        for (int i = 0; i < Mapping.Length; i++)
                        {
                            Job wafer = RouteControl.CreateJob();
                            wafer.Slot         = (i + 1).ToString();
                            wafer.FromPort     = PortName;
                            wafer.FromPortSlot = wafer.Slot;
                            wafer.Position     = PortName;
                            wafer.AlignerFlag  = false;
                            wafer.RecipeID     = "300MM";
                            string Slot = (i + 1).ToString("00");
                            switch (Mapping[i])
                            {
                            case '0':
                                wafer.Job_Id      = "No wafer";
                                wafer.Host_Job_Id = wafer.Job_Id;
                                //MappingData.Add(wafer);
                                break;

                            case '1':
                                while (true)
                                {
                                    wafer.Job_Id      = "Wafer" + currentIdx.ToString("00");
                                    wafer.Host_Job_Id = wafer.Job_Id;
                                    wafer.MapFlag     = true;
                                    if (JobManagement.Add(wafer.Job_Id, wafer))
                                    {
                                        //MappingData.Add(wafer);
                                        break;
                                    }
                                    currentIdx++;
                                }

                                break;

                            case '2':
                                wafer.Job_Id      = "Crossed";
                                wafer.Host_Job_Id = wafer.Job_Id;
                                wafer.MapFlag     = true;
                                //MappingData.Add(wafer);
                                break;

                            case '?':
                                wafer.Job_Id      = "Undefined";
                                wafer.Host_Job_Id = wafer.Job_Id;
                                wafer.MapFlag     = true;
                                //MappingData.Add(wafer);
                                break;

                            case 'W':
                                wafer.Job_Id      = "Double";
                                wafer.Host_Job_Id = wafer.Job_Id;
                                wafer.MapFlag     = true;
                                //MappingData.Add(wafer);
                                break;
                            }
                            if (!port.AddJob(wafer.Slot, wafer))
                            {
                                Job org = port.GetJob(wafer.Slot);
                                JobManagement.Remove(org.Job_Id);
                                port.RemoveJob(wafer.Slot);
                                port.AddJob(wafer.Slot, wafer);
                            }
                        }
                    }
                    List <Job> tmp = port.JobList.Values.ToList();
                    tmp.Sort((x, y) => { return(-Convert.ToInt16(x.Slot).CompareTo(Convert.ToInt16(y.Slot))); });
                    Port_gv.DataSource                          = tmp;
                    Port_gv.Columns["Slot"].Width               = 25;
                    Port_gv.Columns["Slot"].HeaderText          = "S";
                    Port_gv.Columns["Host_Job_Id"].Width        = 75;
                    Port_gv.Columns["DisplayDestination"].Width = 55;
                    Port_gv.Columns["DestinationSlot"].Width    = 30;
                    Port_gv.Columns["Offset"].Visible           = false;
                    Port_gv.Columns["Angle"].Visible            = false;
                    Port_gv.Columns["Job_Id"].Visible           = false;
                    Port_gv.Columns["Destination"].Visible      = false;
                    Port_gv.Columns["ProcessFlag"].Visible      = false;
                    // Port_gv.Columns["Piority"].Visible = false;
                    Port_gv.Columns["AlignerFlag"].Visible     = false;
                    Port_gv.Columns["OCRFlag"].Visible         = false;
                    Port_gv.Columns["AlignerFinished"].Visible = false;
                    Port_gv.Columns["OCRFinished"].Visible     = false;
                    Port_gv.Columns["Position"].Visible        = false;
                    Port_gv.Columns["FromPort"].Visible        = false;
                    Port_gv.Columns["LastNode"].Visible        = false;
                    Port_gv.Columns["CurrentState"].Visible    = false;
                    Port_gv.Columns["WaitToDo"].Visible        = false;
                    //Port_gv.Columns["FetchRobot"].Visible = false;
                    Port_gv.Columns["ProcessNode"].Visible           = false;
                    Port_gv.Columns["MapFlag"].Visible               = false;
                    Port_gv.Columns["DisplayDestination"].HeaderText = "Dest";
                    Port_gv.Columns["DestinationSlot"].HeaderText    = "DS";
                    Port_gv.Columns["Host_Job_Id"].HeaderText        = "ID";
                    Port_gv.ColumnHeadersDefaultCellStyle.Font       = new Font("Arial", 10);
                    Port_gv.Columns["NeedProcess"].Visible           = false;
                    Port_gv.Columns["OCRImgPath"].Visible            = false;
                    Port_gv.Columns["OCRScore"].Visible              = false;
                    Port_gv.Columns["LastSlot"].Visible              = false;
                    Port_gv.Columns["FromPortSlot"].Visible          = false;
                    Port_gv.Columns["AssignTime"].Visible            = false;
                    Port_gv.Columns["DefaultOCR"].Visible            = false;
                    Port_gv.Columns["RecipeID"].Visible              = false;
                    Port_gv.Columns["ErrPosition"].Visible           = false;
                    Port_gv.Columns["InProcess"].Visible             = false;
                    Port_gv.Columns["Host_Lot_Id"].Visible           = false;

                    MonitoringUpdate.UpdateNodesJob(PortName);
                    port.IsMapping = true;
                }
            }
            catch (Exception e)
            {
                logger.Error("UpdateLoadPortMapping: Update fail:" + e.StackTrace);
            }
        }
Beispiel #27
0
        private void button4_Click(object sender, EventArgs e)
        {
            LockUI(true);
            if (!MainProcess._Mode.Equals("Stop") && !MainProcess._Mode.Equals(""))
            {
                AlarmUpdate.UpdateMessage("目前狀態為 " + MainProcess._Mode + " 模式,請先停止動作。");
                return;
            }

            NodeManagement.InitialNodes();
            JobManagement.Initial();

            if (PortSetting1Active_ck.Checked)
            {
                if (!PortSetting1Aligner_cb.Text.Equals(""))
                {
                    Node Aligner1 = NodeManagement.Get(PortSetting1Aligner_cb.Text);
                    if (Aligner1 != null)
                    {
                        Aligner1.LockByNode = PortSetting1Name_cb.Text;
                    }
                }
                Node P1 = NodeManagement.Get(PortSetting1Name_cb.Text);

                int SlotMode = 0;
                if (PortSetting1SlotMode_ck.Checked)
                {
                    SlotMode = 1;
                }
                else
                {
                    SlotMode = 2;
                }
                for (int i = Convert.ToInt16(PortSetting1StartSlot_tb.Text); i <= Convert.ToInt16(PortSetting1EndSlot_tb.Text); i = i + SlotMode)
                {
                    Job w = new Job();
                    w.Job_Id = "Wafer" + i.ToString("000");

                    w.AlignerFlag     = true;
                    w.OCRFlag         = false;
                    w.Position        = P1.Name;
                    w.ProcessFlag     = false;
                    w.FromPort        = P1.Name;
                    w.Slot            = i.ToString();
                    w.Destination     = PortSetting1Dest_cb.Text;
                    w.DestinationSlot = i.ToString();;
                    JobManagement.Add(w.Job_Id, w);
                    P1.JobList.TryAdd(w.Slot, w);
                }
            }

            if (PortSetting2Active_ck.Checked)
            {
                if (!PortSetting2Aligner_cb.Text.Equals(""))
                {
                    Node Aligner2 = NodeManagement.Get(PortSetting2Aligner_cb.Text);
                    if (Aligner2 != null)
                    {
                        Aligner2.LockByNode = PortSetting2Name_cb.Text;
                    }
                }
                Node P2 = NodeManagement.Get(PortSetting2Name_cb.Text);

                int SlotMode = 0;
                if (PortSetting2SlotMode_ck.Checked)
                {
                    SlotMode = 1;
                }
                else
                {
                    SlotMode = 2;
                }
                if (Convert.ToInt16(PortSetting2StartSlot_tb.Text) != 0 && Convert.ToInt16(PortSetting2EndSlot_tb.Text) != 0)
                {
                    for (int i = Convert.ToInt16(PortSetting2StartSlot_tb.Text); i <= Convert.ToInt16(PortSetting2EndSlot_tb.Text); i = i + SlotMode)
                    {
                        Job w = new Job();
                        w.Job_Id = "Wafer" + (i + 25).ToString("000");

                        w.AlignerFlag     = true;
                        w.OCRFlag         = false;
                        w.Position        = P2.Name;
                        w.ProcessFlag     = false;
                        w.FromPort        = P2.Name;
                        w.Slot            = i.ToString();
                        w.Destination     = PortSetting2Dest_cb.Text;
                        w.DestinationSlot = i.ToString();;
                        JobManagement.Add(w.Job_Id, w);
                        P2.JobList.TryAdd(w.Slot, w);
                    }
                }
            }
            NodeManagement.UpdatePortToUI();
            if (AutoIni_ck.Checked)
            {
                MainProcess.SetMode("AutoInitial");//initial
            }
            else
            {
                MainProcess.SetMode("Auto");
            }
        }
Beispiel #28
0
 public JobPostsController()
 {
     JobManager = new JobManagement(db);
 }