/// <summary>Print the specified job event to the console.</summary> /// <param name="jobEvent">the job event to print</param> /// <param name="type">the type of event</param> public void WriteEvent(JobEvent jobEvent, string type) { JPPFJob job = jobEvent.getJob(); java.util.List tasks = jobEvent.getJobTasks(); Console.WriteLine("[.Net] Job '" + job.getName() + "' " + type + (tasks != null ? " with " + tasks.size() + " tasks" : "")); }
// Helper function to raise IJobServer.JobEvent private void NotifyClients(JobEventArgs args) { // // Manually invoke each event handler to // catch disconnected clients. System.Delegate[] invkList = JobEvent.GetInvocationList(); IEnumerator ie = invkList.GetEnumerator(); while (ie.MoveNext()) { JobEventHandler handler = (JobEventHandler)ie.Current; try { //handler.Invoke(this, args); //help to debug handler.BeginInvoke(this, args, null, null); } catch (System.Exception e) { JobEvent -= handler; Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(e.Message); Console.ResetColor(); } } }
/// <summary>Job dispatched notification</summary> /// <param name="jobEvent">encapsulates the job and the tasks that were disptached of whose results have been received</param> public virtual void JobDispatched(java.lang.Object jobEvent) { JobEvent e = jobEvent as JobEvent; if (verbose) { WriteEvent(e, "dispatched"); } listener.JobDispatched(e as JobEvent); }
public Task Execute(IJobExecutionContext context) { JobEvent ev = new JobEvent() { JsonData = (string)context.Get(JobNames.JobData) }; // Launch event to azure with json data return(Task.CompletedTask); }
/// <summary>Job started notification</summary> /// <param name="jobEvent">encapsulates the job and the tasks that were disptached of whose results have been received</param> public virtual void JobEnded(java.lang.Object jobEvent) { JobEvent e = jobEvent as JobEvent; if (verbose) { WriteEvent(e, "ended"); } listener.JobEnded(e); }
public ActionResult Index() { var jobEvent = new JobEvent { id = 1, title = "test", start = "2020-10-10" }; return(View(jobEvent)); }
// [START job_search_create_client_event] public static object CreateClientEvent(string projectId, string tenantId, string requestId, string eventId, IEnumerable <string> jobIds) { EventServiceClient eventServiceClient = EventServiceClient.Create(); TenantName tenantName = TenantName.FromProjectTenant(projectId, tenantId); long seconds = 1L; Timestamp createTime = new Timestamp { Seconds = seconds }; // The type of event attributed to the behavior of the end user. JobEventType type = JobEventType.View; // List of job names associated with this event. List <string> jobs = new List <string>(); foreach (var jobId in jobIds) { //build full path of job IDs JobName name = JobName.FromProjectTenantJob(projectId, tenantId, jobId); jobs.Add(name.ToString()); } JobEvent jobEvent = new JobEvent { Type = type }; jobEvent.Jobs.Add(jobs); ClientEvent clientEvent = new ClientEvent { RequestId = requestId, EventId = eventId, CreateTime = createTime, JobEvent = jobEvent }; CreateClientEventRequest request = new CreateClientEventRequest { ParentAsTenantName = tenantName, ClientEvent = clientEvent }; ClientEvent response = eventServiceClient.CreateClientEvent(request); Console.WriteLine($"Created client event."); Console.WriteLine(response); return(0); }
protected async virtual Task StartJob() { watch.Start(); await JobEvent.StartJob(jobDescription, jobMaxProgress); LogEvent.LogMessage(JobStartMessage); if (!string.IsNullOrEmpty(jobTitle)) { ToastEvent.ShowToast(JobStartMessage, ToastType.INFO); } }
public ActionResult GetEvents() { var jobEvent = new JobEvent { id = 1, title = "test", start = "2020-10-08", end = "2020-10-09" }; return(Json(jobEvent, JsonRequestBehavior.AllowGet)); }
public ActionResult GetEvents() { var jobEvent = new JobEvent { id = 1, title = "test", start = "2020-10-10", }; return(new JsonResult { Data = jobEvent, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
#pragma warning restore CS1998 protected async virtual Task EndJob(Exception ex = null) { watch.Stop(); await JobEvent.EndJob(); if (ex == null) { LogEvent.LogMessage($"{JobSuccessMessage} Elapsed time: {watch.Elapsed}."); if (!string.IsNullOrEmpty(jobTitle)) { ToastEvent.ShowToast(JobSuccessMessage, ToastType.SUCCESS); } } else { LogEvent.LogError(ex, $"{JobFailMessage} Elapsed time: {watch.Elapsed}."); if (!string.IsNullOrEmpty(jobTitle)) { ToastEvent.ShowToast($"{JobFailMessage} Reason: {ex.Message}.", ToastType.DANGER); } } }
/// <summary>Called when a set of tasks returns from the server</summary> /// <param name="jobEvent">encapsulates the event</param> public virtual void JobReturned(JobEvent jobEvent) { }
/// <summary>Called when a set of tasks is dispatched to the server</summary> /// <param name="jobEvent">encapsulates the event</param> public virtual void JobDispatched(JobEvent jobEvent) { }
/// <summary>Called when the job has completed</summary> /// <param name="jobEvent">encapsulates the event</param> public virtual void JobEnded(JobEvent jobEvent) { }
/// <summary>Job dispatched notification</summary> /// <param name="jobEvent">The actual job event received from the Java side</param> public override void JobDispatched(JobEvent jobEvent) { WriteEvent(jobEvent, "dispatched"); }
protected override async Task ExecuteJob() { List <Task> requests = new List <Task>(); AnimeApiEnumerator api = new AnimeApiEnumerator(); ConcurrentBag <AnimeModel> persistableEntries = new ConcurrentBag <AnimeModel>(); JobEvent.NotifyJobProgressChange(0, "Querying API"); for (int i = 0; i < entries.Count(); i = i + EntriesPerRequest) { var currEntries = entries.Skip(i).Take(EntriesPerRequest); requests.Add( Task.Run(async() => { var requestResult = await api.GetByMalIdSet(currEntries.Select(entry => int.Parse(entry.Element("id").Value)).ToArray()); foreach (AnimeModel entry in requestResult) { var currEntry = currEntries.FirstOrDefault(e => e.Element("id").Value == entry.IdMal.ToString()); entry.DateAdded = DateTime.Now; var viewingStatus = currEntry.Element("viewingstatus").Value; switch (viewingStatus) { case "Watched": viewingStatus = StatusView.VIEWED; break; case "Dropped": viewingStatus = StatusView.DROPPEDANIME; break; case "Watching": viewingStatus = StatusView.WATCHING; break; default: viewingStatus = StatusView.TOWATCH; break; } entry.ViewingStatus = viewingStatus; string review = currEntry.Element("review").Value; bool isReviewEmpty = string.IsNullOrEmpty(review); string dropReason = currEntry.Element("dropreason").Value; bool isDropReasonEmpty = string.IsNullOrEmpty(dropReason); if (!isReviewEmpty && isDropReasonEmpty) { entry.PersonalReview = review; } else if (isReviewEmpty && !isDropReasonEmpty) { entry.PersonalReview = dropReason; } else if (!isReviewEmpty && !isDropReasonEmpty) { entry.PersonalReview = $"--- DW1 REVIEW ---{Environment.NewLine}{Environment.NewLine}{review}{Environment.NewLine}{Environment.NewLine}--- DW1 DROP REASON ---{Environment.NewLine}{Environment.NewLine}{dropReason}"; } if (double.TryParse(currEntry.Element("personal_score").Value, out double personalScore) && personalScore != -1) { entry.PersonalScore = (int)(personalScore * 10); } if (int.TryParse(currEntry.Element("currepisode").Value, out int currentEpisode)) { entry.CurrentEpisode = currentEpisode; } if (int.TryParse(currEntry.Element("watch_priority").Value, out int watchPriority) && watchPriority != -1) { entry.WatchPriority = watchPriority; } persistableEntries.Add(entry); JobEvent.NotifyJobProgressChange(1, isIncremental: true); } })); } await Task.WhenAll(requests); JobEvent.NotifyJobProgressChange(0, "Saving results", true); _animeService.AddOrUpdateRange(persistableEntries, (progress) => { JobEvent.NotifyJobProgressChange((int)progress, isIncremental: true); }); }
protected override async Task ExecuteJob() { if (animes.Any()) { ConcurrentBag <AnimeModel> updatedAnimeEntries = new ConcurrentBag <AnimeModel>(); AnimeApiEnumerator animeApi = new AnimeApiEnumerator(); List <Task> animeRequests = new List <Task>(); JobEvent.NotifyJobProgressChange(0, "Querying animes"); for (int i = 0; i < animes.Count(); i = i + EntriesPerRequest) { var currEntries = animes.Skip(i).Take(EntriesPerRequest); animeRequests.Add( Task.Run(async() => { var requestResult = await animeApi.GetByIdSet(currEntries.Select(e => e.Id).ToArray()); foreach (AnimeModel entry in requestResult) { updatedAnimeEntries.Add(entry); JobEvent.NotifyJobProgressChange(1, isIncremental: true); } })); } await Task.WhenAll(animeRequests); JobEvent.NotifyJobProgressChange(0, "Updating animes", true); animeService.AddOrUpdateRange(updatedAnimeEntries, (progress) => { JobEvent.NotifyJobProgressChange((int)progress, isIncremental: true); }); await Task.Delay(100); } if (mangas.Any()) { ConcurrentBag <MangaModel> updatedMangaEntries = new ConcurrentBag <MangaModel>(); MangaApiEnumerator mangaApi = new MangaApiEnumerator(); List <Task> mangaRequests = new List <Task>(); JobEvent.NotifyJobProgressChange(0, "Querying mangas", true); for (int i = 0; i < mangas.Count(); i = i + EntriesPerRequest) { var currEntries = mangas.Skip(i).Take(EntriesPerRequest); mangaRequests.Add( Task.Run(async() => { var requestResult = await mangaApi.GetByIdSet(currEntries.Select(e => e.Id).ToArray(), false); foreach (MangaModel entry in requestResult) { updatedMangaEntries.Add(entry); JobEvent.NotifyJobProgressChange(1, isIncremental: true); } })); } await Task.WhenAll(mangaRequests); JobEvent.NotifyJobProgressChange(0, "Updating mangas", true); mangaService.AddOrUpdateRange(updatedMangaEntries, (progress) => { JobEvent.NotifyJobProgressChange((int)progress, isIncremental: true); }); } }
public ActionResult FirstRun() { var identity = HttpContext.GetOwinContext().Authentication.GetExternalIdentity(DefaultAuthenticationTypes.ApplicationCookie); using (var userManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(new DatabaseContext()))) using (var roleManager = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>(new DatabaseContext()))) using (var dbContext = new DatabaseContext()) { var userId = userManager.FindByName(identity.Name).Id; var admin = dbContext.Users.FirstOrDefault(x => x.Email == identity.Name); admin.IsActivated = true; dbContext.SaveChanges(); if (!roleManager.RoleExists("Admin")) { roleManager.Create(new IdentityRole { Name = "Admin" }); } if (!userManager.IsInRole(userId, "Admin")) { userManager.AddToRole(userId, "Admin"); } //CreditsNets dbContext.CreditsNets.Add(new CreditsNet { Name = "CreditsNetwork", EndPoint = "http://wallet.credits.com/Main/api/UnsafeTransaction" }); dbContext.CreditsNets.Add(new CreditsNet { Name = "testnet-r4_2", EndPoint = "http://wallet.credits.com/testnet-r4_2/api/UnsafeTransaction" }); dbContext.CreditsNets.Add(new CreditsNet { Name = "DevsDappsTestnet", EndPoint = "http://wallet.credits.com/DevsDappsTestnet/api/UnsafeTransaction" }); dbContext.SaveChanges(); //SmartJobs 1 var sj = new SmartJob(); sj.Address = "5kXTAm4wYJ6P1DLACk9ehUQEzjUKLHHBKA2EK1yinvz6"; sj.CreatedAt = DateTime.Now; sj.CreatedBy = admin; sj.CreditsNet = dbContext.CreditsNets.FirstOrDefault(x => x.Name == "Credits network"); sj.Events = new List <JobEvent>(); sj.ExecutionMode = SmartJob.ExecutionModeEnum.Regular; sj.IsActive = true; sj.Method = "Method 1"; sj.Name = "Задача 1"; sj.Rule = new Rule(); sj.Rule.RegularDateFrom = "10.07.2019 05:05:19"; sj.Rule.RegularDateTo = "31.07.2019 22:03:07"; sj.Rule.RegularPeriod = PeriodEnum.Minute; sj.Rule.RegularValue = 5; sj.Rule.Presentation = Rule.GeneratePresentation(sj); dbContext.SmartJobs.Add(sj); //SmartJobs 2 sj = new SmartJob(); sj.Address = "5kXTAm4wYJ6P1DLACk9ehUQEzjUKLHHBKA2EK1yinvz6"; sj.CreatedAt = DateTime.Now; sj.CreatedBy = admin; sj.CreditsNet = dbContext.CreditsNets.FirstOrDefault(x => x.Name == "Test net"); sj.Events = new List <JobEvent>(); sj.ExecutionMode = SmartJob.ExecutionModeEnum.Once; sj.IsActive = true; sj.Method = "Method 2"; sj.Name = "Задача 2"; sj.Rule = new Rule(); sj.Rule.OnceDate = "10.07.2019 05:05:19"; sj.Rule.Presentation = Rule.GeneratePresentation(sj); dbContext.SmartJobs.Add(sj); //SmartJobs 3 sj = new SmartJob(); sj.Address = "5kXTAm4wYJ6P1DLACk9ehUQEzjUKLHHBKA2EK1yinvz6"; sj.CreatedAt = DateTime.Now; sj.CreatedBy = admin; sj.CreditsNet = dbContext.CreditsNets.FirstOrDefault(x => x.Name == "Devs & dapps"); sj.Events = new List <JobEvent>(); sj.ExecutionMode = SmartJob.ExecutionModeEnum.CronExpression; sj.IsActive = false; sj.Method = "Method 3"; sj.Name = "Задача 3"; sj.Rule = new Rule(); sj.Rule.CronExpression = "0,13 0,55 0/7 5,16 * ? *"; sj.Rule.Presentation = Rule.GeneratePresentation(sj); dbContext.SmartJobs.Add(sj); //SmartJobs 4 sj = new SmartJob(); sj.Address = "5kXTAm4wYJ6P1DLACk9ehUQEzjUKLHHBKA2EK1yinvz6"; sj.CreatedAt = DateTime.Now; sj.CreatedBy = admin; sj.CreditsNet = dbContext.CreditsNets.FirstOrDefault(x => x.Name == "Credits network"); sj.Events = new List <JobEvent>(); sj.ExecutionMode = SmartJob.ExecutionModeEnum.Regular; sj.IsActive = true; sj.Method = "Method 4"; sj.Name = "Задача 4"; sj.Rule = new Rule(); sj.Rule.RegularDateFrom = "10.07.2019 05:05:19"; sj.Rule.RegularDateTo = "31.07.2019 22:03:07"; sj.Rule.RegularPeriod = PeriodEnum.Minute; sj.Rule.RegularValue = 5; sj.Rule.Presentation = Rule.GeneratePresentation(sj); dbContext.SmartJobs.Add(sj); //SmartJobs 5 sj = new SmartJob(); sj.Address = "5kXTAm4wYJ6P1DLACk9ehUQEzjUKLHHBKA2EK1yinvz6"; sj.CreatedAt = DateTime.Now; sj.CreatedBy = admin; sj.CreditsNet = dbContext.CreditsNets.FirstOrDefault(x => x.Name == "Test net"); sj.Events = new List <JobEvent>(); sj.ExecutionMode = SmartJob.ExecutionModeEnum.Once; sj.IsActive = true; sj.Method = "Method 5"; sj.Name = "Задача 5"; sj.Rule = new Rule(); sj.Rule.OnceDate = "10.07.2019 05:05:19"; sj.Rule.Presentation = Rule.GeneratePresentation(sj); dbContext.SmartJobs.Add(sj); //SmartJobs 6 sj = new SmartJob(); sj.Address = "5kXTAm4wYJ6P1DLACk9ehUQEzjUKLHHBKA2EK1yinvz6"; sj.CreatedAt = DateTime.Now; sj.CreatedBy = admin; sj.CreditsNet = dbContext.CreditsNets.FirstOrDefault(x => x.Name == "Devs & dapps"); sj.Events = new List <JobEvent>(); sj.ExecutionMode = SmartJob.ExecutionModeEnum.CronExpression; sj.IsActive = false; sj.Method = "Method 6"; sj.Name = "Задача 6"; sj.Rule = new Rule(); sj.Rule.CronExpression = "0,13 0,55 0/7 5,16 * ? *"; sj.Rule.Presentation = Rule.GeneratePresentation(sj); dbContext.SmartJobs.Add(sj); //SmartJobs 7 sj = new SmartJob(); sj.Address = "5kXTAm4wYJ6P1DLACk9ehUQEzjUKLHHBKA2EK1yinvz6"; sj.CreatedAt = DateTime.Now; sj.CreatedBy = admin; sj.CreditsNet = dbContext.CreditsNets.FirstOrDefault(x => x.Name == "Credits network"); sj.Events = new List <JobEvent>(); sj.ExecutionMode = SmartJob.ExecutionModeEnum.Regular; sj.IsActive = true; sj.Method = "Method 7"; sj.Name = "Задача 7"; sj.Rule = new Rule(); sj.Rule.RegularDateFrom = "10.07.2019 05:05:19"; sj.Rule.RegularDateTo = "31.07.2019 22:03:07"; sj.Rule.RegularPeriod = PeriodEnum.Minute; sj.Rule.RegularValue = 5; sj.Rule.Presentation = Rule.GeneratePresentation(sj); dbContext.SmartJobs.Add(sj); //SmartJobs 8 sj = new SmartJob(); sj.Address = "5kXTAm4wYJ6P1DLACk9ehUQEzjUKLHHBKA2EK1yinvz6"; sj.CreatedAt = DateTime.Now; sj.CreatedBy = admin; sj.CreditsNet = dbContext.CreditsNets.FirstOrDefault(x => x.Name == "Test net"); sj.Events = new List <JobEvent>(); sj.ExecutionMode = SmartJob.ExecutionModeEnum.Once; sj.IsActive = true; sj.Method = "Method 8"; sj.Name = "Задача 8"; sj.Rule = new Rule(); sj.Rule.OnceDate = "10.07.2019 05:05:19"; sj.Rule.Presentation = Rule.GeneratePresentation(sj); dbContext.SmartJobs.Add(sj); //SmartJobs 9 sj = new SmartJob(); sj.Address = "5kXTAm4wYJ6P1DLACk9ehUQEzjUKLHHBKA2EK1yinvz6"; sj.CreatedAt = DateTime.Now; sj.CreatedBy = admin; sj.CreditsNet = dbContext.CreditsNets.FirstOrDefault(x => x.Name == "Devs & dapps"); sj.Events = new List <JobEvent>(); sj.ExecutionMode = SmartJob.ExecutionModeEnum.CronExpression; sj.IsActive = false; sj.Method = "Method 9"; sj.Name = "Задача 9"; sj.Rule = new Rule(); sj.Rule.CronExpression = "0,13 0,55 0/7 5,16 * ? *"; sj.Rule.Presentation = Rule.GeneratePresentation(sj); dbContext.SmartJobs.Add(sj); //10 sj = new SmartJob(); sj.Address = "5kXTAm4wYJ6P1DLACk9ehUQEzjUKLHHBKA2EK1yinvz6"; sj.CreatedAt = DateTime.Now; sj.CreatedBy = admin; sj.CreditsNet = dbContext.CreditsNets.FirstOrDefault(x => x.Name == "Credits network"); sj.Events = new List <JobEvent>(); sj.ExecutionMode = SmartJob.ExecutionModeEnum.Regular; sj.IsActive = true; sj.Method = "Method 10"; sj.Name = "Задача 10"; sj.Rule = new Rule(); sj.Rule.RegularDateFrom = "10.07.2019 05:05:19"; sj.Rule.RegularDateTo = "31.07.2019 22:03:07"; sj.Rule.RegularPeriod = PeriodEnum.Minute; sj.Rule.RegularValue = 5; sj.Rule.Presentation = Rule.GeneratePresentation(sj); dbContext.SmartJobs.Add(sj); //SmartJobs 11 sj = new SmartJob(); sj.Address = "5kXTAm4wYJ6P1DLACk9ehUQEzjUKLHHBKA2EK1yinvz6"; sj.CreatedAt = DateTime.Now; sj.CreatedBy = admin; sj.CreditsNet = dbContext.CreditsNets.FirstOrDefault(x => x.Name == "Test net"); sj.Events = new List <JobEvent>(); sj.ExecutionMode = SmartJob.ExecutionModeEnum.Once; sj.IsActive = true; sj.Method = "Method 11"; sj.Name = "Задача 11"; sj.Rule = new Rule(); sj.Rule.OnceDate = "10.07.2019 05:05:19"; sj.Rule.Presentation = Rule.GeneratePresentation(sj); dbContext.SmartJobs.Add(sj); //SmartJobs 12 sj = new SmartJob(); sj.Address = "5kXTAm4wYJ6P1DLACk9ehUQEzjUKLHHBKA2EK1yinvz6"; sj.CreatedAt = DateTime.Now; sj.CreatedBy = admin; sj.CreditsNet = dbContext.CreditsNets.FirstOrDefault(x => x.Name == "Devs & dapps"); sj.Events = new List <JobEvent>(); sj.ExecutionMode = SmartJob.ExecutionModeEnum.CronExpression; sj.IsActive = false; sj.Method = "Method 12"; sj.Name = "Задача 12"; sj.Rule = new Rule(); sj.Rule.CronExpression = "0,13 0,55 0/7 5,16 * ? *"; sj.Rule.Presentation = Rule.GeneratePresentation(sj); dbContext.SmartJobs.Add(sj); dbContext.SaveChanges(); var date = new DateTime(2019, 1, 1); foreach (var sJob in dbContext.SmartJobs.ToList()) { for (int i = 0; i < 45; i++) { var sEvent = new JobEvent() { SmartJob = sJob, IsSuccessed = true, RequestDate = date.AddMinutes(i), ResponseDate = date.AddMinutes(i).AddSeconds(i), Text = "Ok!" }; dbContext.JobEvents.Add(sEvent); dbContext.SaveChanges(); } date = date.AddHours(1); } } return(RedirectToAction("Index", "Home")); }
/// <summary>Job started notification</summary> /// <param name="jobEvent">The actual job event received from the Java side</param> public override void JobStarted(JobEvent jobEvent) { WriteEvent(jobEvent, "started"); }
/// <summary>Job ended notification</summary> /// <param name="jobEvent">The actual job event received from the Java side</param> public override void JobEnded(JobEvent jobEvent) { WriteEvent(jobEvent, "ended"); }
static void Main(string[] args) { // 输入格式: JobName 15:02 17:02 var nowRunning = 0; // 正在运行的程序数量 var maxIdle = 0; var maxBusy = 0; var items = int.Parse(Console.ReadLine()); var jobs = new JobEvent[items * 2]; for (var i = 0; i < jobs.Length; i += 2) { jobs[i] = new JobEvent(); jobs[i + 1] = new JobEvent(); jobs[i].IsFinished = false; // 开始事件 jobs[i + 1].IsFinished = true; // 停止事件 var record = Console.ReadLine().Split(new char[] { ' ', ':' }, StringSplitOptions.RemoveEmptyEntries); jobs[i].JobName = record[0]; jobs[i + 1].JobName = record[0]; jobs[i].Time = int.Parse(record[1]) * 60 + int.Parse(record[2]); jobs[i + 1].Time = int.Parse(record[3]) * 60 + int.Parse(record[4]); } Array.Sort(jobs); // 事件处理 var idleStart = 0; var busyStart = 0; for (var i = 0; i < jobs.Length; i++) { // 启动事件 if (!jobs[i].IsFinished) { // 空闲状态结束 if (nowRunning == 0) { var idle = jobs[i].Time - idleStart; if (idle > maxIdle) { maxIdle = idle; } // 开始忙碌 busyStart = jobs[i].Time; } nowRunning++; } else { nowRunning--; // 忙碌状态结束 if (nowRunning == 0) { var busy = jobs[i].Time - busyStart; if (busy > maxBusy) { maxBusy = busy; } // 开始空闲 idleStart = jobs[i].Time; } } } Console.WriteLine("Max Idle: " + maxIdle); Console.WriteLine("Max Busy: " + maxBusy); }
/// <summary>Job returned notification</summary> /// <param name="jobEvent">The actual job event received from the Java side</param> public override void JobReturned(JobEvent jobEvent) { WriteEvent(jobEvent, "returned"); }
/// <summary> /// 向GUI线程报告进度,在GUI线程处理完成前阻塞当前线程。 /// </summary> /// <param name="jobItem"></param> /// <param name="jobEvent">赋与jobItem的Event属性,以新的工作事件。</param> private void SetJobEventAndReportProgress(JobItem jobItem, JobEvent jobEvent) { jobItem.Event = jobEvent; this.SynchReportProgress(jobItem); }
/// <summary>Print a console message describing a received event notification</summary> /// <param name="positions">the positions in the job of the tasks that were disptached of whose reuslts have been received</param> /// <param name="type">a string describing the type of even notification</param> private void WriteEvent(JobEvent jobEvent, string type) { Console.WriteLine("[.Net] dispatcher: Job '" + jobEvent.getJob().getName() + "' " + type + " with " + jobEvent.getJobTasks().size() + " tasks"); }
/// <summary>Called when the job is submitted or re-submitted</summary> /// <param name="jobEvent">encapsulates the event</param> public virtual void JobStarted(JobEvent jobEvent) { }
private void FillGridMain() { string[] searchTokens = textSearch.Text.ToLower().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries); long[] userNums = new long[0]; JobCategory[] jobCats = new JobCategory[0]; JobPhase[] jobPhases = new JobPhase[0]; long[] jobPriorities = new long[0]; if (listBoxUsers.SelectedIndices.Count > 0 && !listBoxUsers.SelectedIndices.Contains(0)) { userNums = listBoxUsers.SelectedIndices.Cast <int>().Select(x => _listUsers[x - 1].UserNum).ToArray(); } if (listBoxCategory.SelectedIndices.Count > 0 && !listBoxCategory.SelectedIndices.Contains(0)) { jobCats = listBoxCategory.SelectedIndices.Cast <int>().Select(x => (JobCategory)(x - 1)).ToArray(); } if (listBoxPhases.SelectedIndices.Count > 0 && !listBoxPhases.SelectedIndices.Contains(0)) { jobPhases = listBoxPhases.SelectedIndices.Cast <int>().Select(x => (JobPhase)(x - 1)).ToArray(); } if (listBoxPriorities.SelectedIndices.Count > 0 && !listBoxPriorities.SelectedIndices.Contains(0)) { jobPriorities = listBoxPriorities.GetListSelected <Def>().Select(x => x.DefNum).ToArray(); } Action actionCloseProgress = ODProgress.Show(ODEventType.Job, typeof(JobEvent), "Getting job data..."); #region Get Missing Data //This entire section will go out to the database and get any data that is unknown based on some of the filters. //The other filters will be applied later via the cached lists. try { List <Job> listJobs = Jobs.GetForSearch(dateFrom.Value, dateTo.Value, jobPhases.ToList(), jobPriorities.ToList(), _listJobsAll.Select(x => x.JobNum).ToList()); Jobs.FillInMemoryLists(listJobs, true); _listJobsAll.AddRange(listJobs); } catch (OutOfMemoryException oome) { actionCloseProgress(); oome.DoNothing(); MsgBox.Show(this, "Not enough memory to complete the search. Please refine search filters."); return; } //Only get the feature request entries that we care about. JobEvent.Fire(ODEventType.Job, "Getting feature request data..."); List <long> listFeatureRequestNums = _listJobsAll.SelectMany(x => x.ListJobLinks) .Where(x => x.LinkType == JobLinkType.Request) .Select(x => x.FKey) .Distinct() .ToList(); //Don't download any feature requests that we already know about. listFeatureRequestNums.RemoveAll(x => x.In(_listFeatureRequestsAll.Select(y => y.FeatReqNum))); if (!listFeatureRequestNums.IsNullOrEmpty()) { _listFeatureRequestsAll.AddRange(FeatureRequests.GetAll(listFeatureRequestNums)); } //Only get the bug entries that we care about. JobEvent.Fire(ODEventType.Job, "Getting bug data..."); List <long> listBugIds = _listJobsAll.SelectMany(x => x.ListJobLinks) .Where(x => x.LinkType == JobLinkType.Bug) .Select(x => x.FKey) .Distinct() .ToList(); //Don't download any bugs that we already know about. listBugIds.RemoveAll(x => x.In(_listBugsAll.Select(y => y.BugId))); if (!listBugIds.IsNullOrEmpty()) { _listBugsAll.AddRange(Bugs.GetMany(listBugIds)); } #endregion JobEvent.Fire(ODEventType.Job, "Filling grid..."); gridMain.BeginUpdate(); gridMain.ListGridColumns.Clear(); gridMain.ListGridColumns.Add(new GridColumn("Job\r\nNum", 50, GridSortingStrategy.AmountParse)); gridMain.ListGridColumns.Add(new GridColumn("Priority", 50, HorizontalAlignment.Center)); gridMain.ListGridColumns.Add(new GridColumn("Phase", 85)); gridMain.ListGridColumns.Add(new GridColumn("Category", 80)); gridMain.ListGridColumns.Add(new GridColumn("Job Title", -1)); gridMain.ListGridColumns.Add(new GridColumn("Version", 80)); gridMain.ListGridColumns.Add(new GridColumn("Est. Version", 80)); gridMain.ListGridColumns.Add(new GridColumn("Expert", 75)); gridMain.ListGridColumns.Add(new GridColumn("Engineer", 75)); gridMain.ListGridColumns.Add(new GridColumn("Est.\r\nHours", 60, GridSortingStrategy.AmountParse)); gridMain.ListGridColumns.Add(new GridColumn("Act.\r\nHours", 60, GridSortingStrategy.AmountParse)); gridMain.ListGridColumns.Add(new GridColumn("Job\r\nMatch", 45, HorizontalAlignment.Center)); gridMain.ListGridColumns.Add(new GridColumn("Bug\r\nMatch", 45, HorizontalAlignment.Center)); gridMain.ListGridColumns.Add(new GridColumn("FR\r\nMatch", 45, HorizontalAlignment.Center)); gridMain.ListGridRows.Clear(); _listJobsFiltered = new List <Job>(); foreach (Job jobCur in _listJobsAll) { if (jobCats.Length > 0 && !jobCats.Contains(jobCur.Category)) { continue; } if (jobPhases.Length > 0 && !jobPhases.Contains(jobCur.PhaseCur)) { continue; } if (jobPriorities.Length > 0 && !jobPriorities.Contains(jobCur.Priority)) { continue; } if (userNums.Length > 0 && !userNums.All(x => Jobs.GetUserNums(jobCur).Contains(x))) { continue; } if (!jobCur.DateTimeEntry.Between(dateFrom.Value, dateTo.Value)) { continue; } bool isJobMatch = false; bool isBugMatch = false; bool isFeatureReqMatch = false; if (searchTokens.Length > 0) { bool addRow = false; List <Bug> listBugs = jobCur.ListJobLinks.FindAll(x => x.LinkType == JobLinkType.Bug) .Select(x => _listBugsAll.FirstOrDefault(y => x.FKey == y.BugId)) .Where(x => x != null) .ToList(); List <FeatureRequest> listFeatures = jobCur.ListJobLinks.FindAll(x => x.LinkType == JobLinkType.Request) .Select(x => _listFeatureRequestsAll.FirstOrDefault(y => x.FKey == y.FeatReqNum)) .Where(x => x != null) .ToList(); foreach (string token in searchTokens.Distinct()) { bool isFound = false; //JOB MATCHES if (jobCur.Title.ToLower().Contains(token) || jobCur.Implementation.ToLower().Contains(token) || jobCur.Requirements.ToLower().Contains(token) || jobCur.Documentation.ToLower().Contains(token) || jobCur.JobNum.ToString().Contains(token)) { isFound = true; isJobMatch = true; } //BUG MATCHES if (!isFound || !isBugMatch) { if (listBugs.Any(x => x.Description.ToLower().Contains(token) || x.Discussion.ToLower().Contains(token))) { isFound = true; isBugMatch = true; } } //FEATURE REQUEST MATCHES if (!isFound || !isFeatureReqMatch) { if (listFeatures.Any(x => x.Description.Contains(token) || x.FeatReqNum.ToString().ToLower().Contains(token))) { isFound = true; isFeatureReqMatch = true; } } addRow = isFound; if (!isFound) { break; //stop looking for additional tokens, we didn't find this one. } } if (!addRow) { continue; //we did not find one of the search terms. } } _listJobsFiltered.Add(jobCur); Def jobPriority = _listJobPriorities.FirstOrDefault(y => y.DefNum == jobCur.Priority); GridRow row = new GridRow(); row.Cells.Add(jobCur.JobNum.ToString()); row.Cells.Add(new GridCell(jobPriority.ItemName) { ColorBackG = jobPriority.ItemColor, ColorText = (jobCur.Priority == _listJobPriorities.FirstOrDefault(y => y.ItemValue.Contains("Urgent")).DefNum) ? Color.White : Color.Black, }); row.Cells.Add(jobCur.PhaseCur.ToString()); row.Cells.Add(jobCur.Category.ToString()); row.Cells.Add(jobCur.Title); row.Cells.Add(jobCur.JobVersion.ToString()); row.Cells.Add(jobCur.ProposedVersion.ToString()); row.Cells.Add(Userods.GetName(jobCur.UserNumExpert)); row.Cells.Add(Userods.GetName(jobCur.UserNumEngineer)); row.Cells.Add(jobCur.HoursEstimate.ToString()); row.Cells.Add(jobCur.HoursActual.ToString()); row.Cells.Add(isJobMatch ? "X" : ""); row.Cells.Add(isBugMatch ? "X" : ""); row.Cells.Add(new GridCell(isFeatureReqMatch ? "X" : "") { ColorBackG = _listFeatureRequestsAll.Count == 0 ? Control.DefaultBackColor : Color.Empty }); row.Tag = jobCur; gridMain.ListGridRows.Add(row); } gridMain.EndUpdate(); actionCloseProgress(); }
public override Boolean Loop(Genie.Yuk.Event _event) { WinUtility win = Service.Resolve <WinUtility>(); GameGraphics gg = Service.Resolve <GameGraphics>(); CancellationToken token = Service.Resolve <CancellationToken>(); if (_event != null) { if (_event.GetType() == typeof(StartEvent)) { Action myAction0 = (Action)(() => { gg.Start(); }); Task taskA = Task.Run(myAction0); taskA.Wait(); Action myAction1 = (Action)(() => { while (!token.IsCancellationRequested) { gg.AlwaysRun(); } }); win.OnUiThread(myAction1); EventQueueClient.Enqueue(new GraphicsEvent()); } else if (_event.GetType() == typeof(GraphicsEvent)) { lock (WriteServer.balanceLock) { ComponentManager.Update(); gg.Run(token); System.Console.WriteLine("Draw Client"); } EventQueueClient.Enqueue(new GraphicsEvent()); } else if (_event.GetType() == typeof(JobEvent)) { JobEvent job = (JobEvent)_event; Boolean doLoop = true; while (doLoop) { try { Genie.Yuk.Event tmpEvent = job.Dequeue(); Loop(tmpEvent); } catch (InvalidOperationException e) { doLoop = false; } } } else if (_event.GetType() == typeof(StopEvent)) { System.Console.WriteLine("Stop"); return(false); } } return(true); }