private PackageOwnerInfo GetPackageOwnerInfo(int ownerId, bool openForCollab, int contentId) { var owner = MembershipHelper.GetById(ownerId); var ownerInfo = new PackageOwnerInfo { Karma = owner.Karma(), Owner = owner.Name, OwnerAvatar = Utils.GetMemberAvatar(owner, 200, true) }; if (openForCollab) { var service = new ContributionService(DatabaseContext); var contributors = service.GetContributors(contentId).ToList(); if (contributors != null && contributors.Any()) { var names = new List <string>(); foreach (var contributor in contributors) { var member = MembershipHelper.GetById(contributor.MemberId); if (member != null) { names.Add(member.Name); } } ownerInfo.Contributors = names.ToArray(); } } return(ownerInfo); }
public static async Task RunAsync( IReadOnlyList <string> organizations, string githubLogin, string githubPassword, bool includePrivateRepositories, bool includeUngroupedRepositories) { var committerGroups = organizations.SelectMany(CrappyCommitterGroupService.Get).ToList(); var client = GitHubClientFactory.Create(typeof(Program).Namespace, githubLogin, githubPassword); var repositoryService = new RepositoryService(client); var ungroupedRepositories = (await Task.WhenAll(committerGroups .SelectMany(@group => @group.RepositoryList.Select(id => id.Owner)) .Concat(organizations) .Distinct() .Select(owner => repositoryService.Get(owner)))) .SelectMany(_ => _) .Where(repository => includePrivateRepositories || !repository.IsPrivate) .Where(repository => !committerGroups.Any(group => group.RepositoryList.Contains(repository.Id))) .ToList(); foreach (var repository in ungroupedRepositories.OrderBy(_ => _)) { log.WarnFormat("{@Repository} is not grouped.", repository); } if (includeUngroupedRepositories) { committerGroups = committerGroups .Concat(ungroupedRepositories .GroupBy(repository => repository.Id.Owner) .Select(group => new CommitterGroup( $"{group.Key}-ungrouped", ListModule.OfSeq(group.Select(repository => repository.Id))))) .ToList(); } var contributions = (await Task.WhenAll( ContributionService.Get(committerGroups, new CommitService(client)), ContributionService.Get(committerGroups, new IssueService(client)), ContributionService.Get(committerGroups, new PullRequestService(client)))) .SelectMany(_ => _) .GroupBy(contribution => new { contribution.Group, contribution.Login }) .Select(group => new Contribution(group.Key.Group, group.Key.Login, group.Sum(contribution => contribution.Score))) .ToList(); TsvContributionsRepository.Save(contributions); }
public HttpResponseMessage DeleteContributor(int projectId, int memberId) { var project = Umbraco.TypedContent(projectId); if (project.GetPropertyValue <int>("owner") == Members.GetCurrentMemberId()) { var cs = new ContributionService(DatabaseContext); cs.DeleteContributor(projectId, memberId); return(Request.CreateResponse(HttpStatusCode.Accepted)); } else { return(Request.CreateResponse(HttpStatusCode.Forbidden)); } }
private PackageOwnerInfo GetPackageOwnerInfo(int ownerId, bool openForCollab, int contentId) { var owner = MembershipHelper.GetById(ownerId); var avatarService = new AvatarService(); var avatarPath = avatarService.GetMemberAvatar(owner); var avatar = $"{avatarPath}?width=200&height=200&mode=crop&upscale=true"; var ownerInfo = new PackageOwnerInfo { Karma = owner?.Karma() ?? 0, Owner = owner?.Name ?? "", OwnerAvatar = avatar }; if (openForCollab) { var service = new ContributionService(DatabaseContext); var contributors = service.GetContributors(contentId).ToList(); if (contributors != null && contributors.Any()) { var names = new List <string>(); foreach (var contributor in contributors) { var member = MembershipHelper.GetById(contributor.MemberId); if (member != null) { names.Add(member.Name); } } ownerInfo.Contributors = names.ToArray(); } } return(ownerInfo); }
public ContributionController(ContributionService contributionService) { this.contributionService = contributionService; }
public ContributionController(ContributionService contributionService, ProjectService projectService) { this.projectService = projectService; this.contributionService = contributionService; }
private async void ChangeDisplayOfTimeline(TweetDisplayMode newValue) { if (Setting.TweetDisplayMode.Value == newValue) { RaisePropertyChanged(); return; } var showDonationInfo = false; if (Setting.TweetDisplayMode.Value == Settings.TweetDisplayMode.Expanded && (newValue == Settings.TweetDisplayMode.SingleLine || newValue == Settings.TweetDisplayMode.Mixed)) { var resp = this.Messenger.GetResponse(new TaskDialogMessage(new TaskDialogOptions { Title = "一行表示モードの警告", MainIcon = VistaTaskDialogIcon.Warning, MainInstruction = "一行表示モードを有効にしようとしています。", Content = "一行表示モードは複数行表示モードに比べ、リソースを大量に消費します。" + Environment.NewLine + "また、Krile StarryEyesは一行表示モードをベースとして設計されてはいないため、意図しない動作をする可能性があります。" + Environment.NewLine + "一行表示モードを本当に有効にしますか?", CommonButtons = TaskDialogCommonButtons.YesNo })); if (resp.Response.Result == TaskDialogSimpleResult.No) { this.TweetDisplayMode = (int)Settings.TweetDisplayMode.Expanded; return; } showDonationInfo = true; } await DispatcherHolder.BeginInvoke(() => { var ww = new WorkingWindow( "changing timeline mode...", async() => { await Task.Run(() => Setting.TweetDisplayMode.Value = newValue); RaisePropertyChanged(() => IsDonationVisible); await DispatcherHolder.BeginInvoke(async() => { await Dispatcher.Yield(DispatcherPriority.Background); }); }); if (showDonationInfo && !ContributionService.IsContributor()) { ww.Closed += async(o, e) => { await this.Messenger.RaiseAsync(new TaskDialogMessage(new TaskDialogOptions { Title = "Krileの開発にご協力ください。", MainIcon = VistaTaskDialogIcon.Information, MainInstruction = "Krileの開発にご協力ください。", Content = "多くのユーザーの補助によってKrileが開発されています。" + Environment.NewLine + "Krileの開発を継続するため、寄付にご協力ください。", CustomButtons = new[] { "開発者に寄付" } })); BrowserHelper.Open(App.DonationUrl); }; } ww.ShowDialog(); }); }