private bool CheckJobForFilter(IndustryJobFilter filter, JsonClasses.IndustryJob job, bool isCorp) { if (isCorp && !filter.FeedCorporateJobs) { return(false); } if (!isCorp && !filter.FeedPersonalJobs) { return(false); } if (!filter.FeedCancelledJobs && job.StatusValue == IndustryJobStatusEnum.cancelled) { return(false); } if (!filter.FeedStartingJobs && job.StatusValue == IndustryJobStatusEnum.active) { return(false); } if (!filter.FeedReadyJobs && job.StatusValue == IndustryJobStatusEnum.ready) { return(false); } if (!filter.FeedDeliveredJobs && job.StatusValue == IndustryJobStatusEnum.delivered) { return(false); } if (!filter.FeedRevertedJobs && job.StatusValue == IndustryJobStatusEnum.reverted) { return(false); } if (!filter.FeedPausedJobs && job.StatusValue == IndustryJobStatusEnum.paused) { return(false); } if (!filter.FeedResearchJobs && (job.Activity == IndustryJobActivity.me || job.Activity == IndustryJobActivity.te || job.Activity == IndustryJobActivity.techResearch)) { return(false); } if (!filter.FeedBuildJobs && job.Activity == IndustryJobActivity.build) { return(false); } if (!filter.FeedCopyingJobs && job.Activity == IndustryJobActivity.copy) { return(false); } if (!filter.FeedInventionJobs && job.Activity == IndustryJobActivity.inventing) { return(false); } if (!filter.FeedReactionJobs && job.Activity == IndustryJobActivity.reaction) { return(false); } return(true); }
private async Task SendDiscordMessage(JsonClasses.IndustryJob job, bool isStatusChange, List <ulong> discordChannels, bool isCorp, string token) { if (job == null) { return; } string statusText; string timeToComplete = null; switch (job.StatusValue) { case IndustryJobStatusEnum.active: statusText = LM.Get("industryJobsStatusActive"); timeToComplete = TimeSpan.FromSeconds(job.duration).ToFormattedString(" "); break; case IndustryJobStatusEnum.cancelled: statusText = LM.Get("industryJobsStatusCancelled"); break; case IndustryJobStatusEnum.delivered: statusText = LM.Get("industryJobsStatusDelivered"); break; case IndustryJobStatusEnum.paused: statusText = LM.Get("industryJobsStatusPaused"); break; case IndustryJobStatusEnum.ready: statusText = LM.Get("industryJobsStatusReady"); break; case IndustryJobStatusEnum.reverted: statusText = LM.Get("industryJobsStatusReverted"); break; default: throw new ArgumentOutOfRangeException($"Unknown job status: {job.StatusValue}"); } string activityText; switch (job.Activity) { case IndustryJobActivity.none: activityText = LM.Get("industryJobsActivityNone"); break; case IndustryJobActivity.build: activityText = LM.Get("industryJobsActivityBuild"); break; case IndustryJobActivity.techResearch: activityText = LM.Get("industryJobsActivityTechResearch"); break; case IndustryJobActivity.te: activityText = LM.Get("industryJobsActivityTEResearch"); break; case IndustryJobActivity.me: activityText = LM.Get("industryJobsActivityMEResearch"); break; case IndustryJobActivity.copy: activityText = LM.Get("industryJobsActivityCopying"); break; case IndustryJobActivity.duplicating: activityText = LM.Get("industryJobsActivityDuplicating"); break; case IndustryJobActivity.reverseEng: activityText = LM.Get("industryJobsActivityReverseEng"); break; case IndustryJobActivity.inventing: activityText = LM.Get("industryJobsActivityInventing"); break; case IndustryJobActivity.reaction: activityText = LM.Get("industryJobsActivityReaction"); break; case IndustryJobActivity.reaction2: activityText = LM.Get("industryJobsActivityReaction"); break; default: throw new ArgumentOutOfRangeException($"Unknown activity {job.activity_id}"); } var bpType = await APIHelper.ESIAPI.GetTypeId(Reason, job.blueprint_type_id); var productType = await APIHelper.ESIAPI.GetTypeId(Reason, job.product_type_id); var completedBy = job.completed_character_id > 0 ? await APIHelper.ESIAPI.GetCharacterData(Reason, job.completed_character_id) : null; var unk = LM.Get("Unknown"); var installer = job.installer_id > 0 ? await APIHelper.ESIAPI.GetCharacterData(Reason, job.installer_id) : null; var station = (await APIHelper.ESIAPI.GetStationData(Reason, job.facility_id, token))?.name ?? (await APIHelper.ESIAPI.GetStructureData(Reason, job.facility_id, token))?.name; var header = isStatusChange ? LM.Get("industryJobsStatusHeader") : LM.Get("industryJobsNewHeader"); var sb = new StringBuilder(); var color = isStatusChange ? null : "fix"; var colorMark = string.Empty; var colorMove = string.Empty; if (job.StatusValue == IndustryJobStatusEnum.cancelled || job.StatusValue == IndustryJobStatusEnum.reverted) { color = "diff"; colorMark = "-"; colorMove = " "; } if (job.StatusValue == IndustryJobStatusEnum.ready || job.StatusValue == IndustryJobStatusEnum.delivered) { color = "diff"; colorMark = "+"; colorMove = " "; } sb.AppendLine($"```{color}"); sb.AppendLine($"*{header}*"); sb.AppendLine($"{colorMove}{LM.Get("industryJobsRowActivity"),-11}: {activityText}"); sb.AppendLine($"{colorMark}{LM.Get("industryJobsRowStatus"),-11}: {statusText}"); if (job.Activity == IndustryJobActivity.build || job.Activity == IndustryJobActivity.inventing || job.Activity == IndustryJobActivity.reverseEng) { sb.AppendLine($"{colorMove}{LM.Get("industryJobsRowFrom"),-11}: {bpType?.name ?? unk}"); sb.AppendLine($"{colorMove}{LM.Get("industryJobsRowTo"),-11}: {productType?.name ?? unk}"); } else { sb.AppendLine($"{colorMove}{LM.Get("industryJobsRowBPO"),-11}: {productType?.name ?? unk}"); } if (!string.IsNullOrEmpty(timeToComplete)) { sb.AppendLine($"{colorMove}{LM.Get("industryJobsRowDuration"),-11}: {timeToComplete}"); } if (installer != null) { sb.AppendLine($"{colorMove}{LM.Get("industryJobsRowInstaller"),-11}: {installer.name}"); } if (completedBy != null && isCorp) { sb.AppendLine($"{colorMove}{LM.Get("industryJobsRowCompletedBy"),-11}: {completedBy.name}"); } sb.AppendLine($"{colorMark}{LM.Get("industryJobsRowStation"),-11}: {station ?? LM.Get("Unknown")}"); sb.AppendLine("```"); //sb.Append($"{LM.Get("industryJobsRowTime"),10}": {job.}); foreach (var channel in discordChannels) { await APIHelper.DiscordAPI.SendMessageAsync(channel, sb.ToString()); } }