예제 #1
0
        private async Task SendMessages(Contract contract, VetMember sender)
        {
            var stakeHolders = await GetStakeHolders(contract.Id);

            var trade = DbContext.Contracts.AsQueryable().Where(c => c.Id == contract.Id).Select(c => c.Trade).First();

            EmbedBuilder builder = new EmbedBuilder();

            builder.WithTitle(trade.Title)
            .WithAuthor(sender.Name, sender.GetAvaterIconUrl(), sender.GetMemberPageUrl(StaticSettings.SiteBaseUrl))
            .WithUrl($"https://vetcoin.azurewebsites.net/Trades/Contracts?contractId={contract.Id}")
            .AddField("アクション", "提案がありました")
            .AddField("報酬", contract.Reword, true)
            .AddField("納期", GetNotEmptyStr(contract.DeliveryDate), true)
            .AddField("提案内容", GetNotEmptyStr(contract.AgreementContent));

//            var dmMessage = $@"提案がありました。確認してください。
//タイトル:{trade.Title}
//提案主:{sender.Name}
//URL:https://vetcoin.azurewebsites.net/Trades/Contracts?contractId={contract.Id}
//{contract.AgreementContent}";

            var messageTargets = stakeHolders.Where(c => c.Id != sender.Id).ToArray();

            await CoreService.SendDirectMessage(messageTargets, string.Empty, builder.Build());
        }
예제 #2
0
        private async Task SendMessages(Contract contract, VetMember sender, string message)
        {
            var stakeHolders = await GetStakeHolders(contract.Id);

            var trade = DbContext.Contracts.AsQueryable().Where(c => c.Id == contract.Id).Select(c => c.Trade).First();


            //            var dmMessage = $@"
            //メッセージ元:{trade.Title}
            //URL:https://vetcoin.azurewebsites.net/Trades/Contracts?contractId={contract.Id}
            //差出人:{sender.Name}
            //{message}";
            Discord.EmbedBuilder builder = new Discord.EmbedBuilder();
            builder.WithTitle(trade.Title)
            .WithAuthor(sender.Name, sender.GetAvaterIconUrl(), sender.GetMemberPageUrl(StaticSettings.SiteBaseUrl))
            .WithUrl($"https://vetcoin.azurewebsites.net/Trades/Contracts?contractId={contract.Id}")
            // .AddField("アクション", "メッセージがあります")
            .AddField("メッセージ内容", message);


            var messageTargets = stakeHolders.Where(c => c.Id != sender.Id).ToArray();


//#if DEBUG
//            messageTargets = new[] { sender };
//#endif

            await CoreService.SendDirectMessage(messageTargets, string.Empty, builder.Build());
        }
예제 #3
0
        private async Task SendMessages(Trade trade, VetMember sender, string message)
        {
            var senderIsOwner = trade.VetMemberId == sender.Id;

            var messageTargets =
                senderIsOwner ? DbContext.TradeMessages.AsQueryable().Where(c => c.TradeId == trade.Id).Select(c => c.VetMember).Distinct().ToArray()
                            : new[] { trade.VetMember };

            var dmMessage = $@"
メッセージ元:{trade.Title}
URL:{StaticSettings.SiteBaseUrl}Trades/Details?id={trade.Id}
差出人:{sender.Name}
{message}";

            Discord.EmbedBuilder builder = new Discord.EmbedBuilder();
            builder.WithTitle(trade.Title)
            .WithAuthor(sender.Name, sender.GetAvaterIconUrl(), sender.GetMemberPageUrl(StaticSettings.SiteBaseUrl))
            .WithUrl($"{StaticSettings.SiteBaseUrl}Trades/Details?id={trade.Id}")
            // .AddField("アクション", "メッセージがあります")
            .AddField("メッセージ内容", message);



            await CoreService.SendDirectMessage(messageTargets, string.Empty, builder.Build());
        }
예제 #4
0
        //private async Task<VetMember[]> GetStakeHolders(int id)
        //{
        //    var contractMember = DbContext.Contracts.AsQueryable().Where(c => c.Id == id).Select(c => c.VetMember);
        //    var tradeMember = DbContext.Contracts.AsQueryable().Where(c => c.Id == id).Select(c => c.Trade.VetMember);
        //    var messageMembers = DbContext.TradeMessages.AsQueryable().Where(c => c.TradeId == id).Select(c => c.VetMember);

        //    var stakeHolders = contractMember.Concat(tradeMember).Concat(messageMembers).Distinct();


        //    return await stakeHolders.ToArrayAsync();
        //}

        private async Task SendMessages(Contract contract, VetMember sender, VetMember reciver, VetMember postUser)
        {
            //var stakeHolders = await GetStakeHolders(contract.Id);
            var trade = DbContext.Contracts.AsQueryable().Where(c => c.Id == contract.Id).Select(c => c.Trade).First();

            Discord.EmbedBuilder builder = new Discord.EmbedBuilder();
            builder.WithTitle(trade.Title)
            .WithAuthor(postUser.Name, postUser.GetAvaterIconUrl(), postUser.GetMemberPageUrl(StaticSettings.SiteBaseUrl))
            .WithUrl($"https://vetcoin.azurewebsites.net/Trades/Contracts?contractId={contract.Id}")
            .AddField("アクション", "作業完了通知")
            .AddField("メッセージ内容", @"作業完了したようです。
納品物などを確認して契約完了ボタンをおしてください");



            var messageTargets = new[] { sender };

            await CoreService.SendDirectMessage(messageTargets, string.Empty, builder.Build());
        }
예제 #5
0
        private async Task SendMessages(Vender vender, VetMember sender, string message)
        {
            var senderIsOwner = vender.VetMemberId == sender.Id;

            var messageTargets =
                senderIsOwner ? DbContext.VenderMessages
                .AsQueryable()
                .Where(c => c.VenderId == vender.Id)
                .Select(c => c.VetMember).Distinct().ToArray()
                            : new[] { vender.VetMember };


            Discord.EmbedBuilder builder = new Discord.EmbedBuilder();
            builder.WithTitle($"{ vender.Title} 【メッセージ】")
            .WithAuthor(sender.Name, sender.GetAvaterIconUrl(), sender.GetMemberPageUrl(StaticSettings.SiteBaseUrl))
            .WithUrl($"{StaticSettings.SiteBaseUrl}Venders/Details?id={vender.Id}")
            .AddField("内容", message);

            await CoreService.SendDirectMessage(messageTargets, string.Empty, builder.Build());
        }
예제 #6
0
        private async Task Notification(VetMember from, VetMember to, long amount, string message, long totalAmount)
        {
            var builder = new Discord.EmbedBuilder();

            builder
            .WithTitle($"{from.Name} から{amount}{StaticSettings.CurrenryUnit} 送金されました")
            .WithAuthor(
                from.Name,
                from.GetAvaterIconUrl(),
                from.GetMemberPageUrl(StaticSettings.SiteBaseUrl)
                )
            .AddField("金額", $"{amount}{StaticSettings.CurrenryUnit}", false)
            .AddField("残高", $"{totalAmount}{StaticSettings.CurrenryUnit}", false);

            if (!string.IsNullOrEmpty(message))
            {
                builder
                .AddField("メッセージ", message, false);
            }

            var messageTargets = new[] { to };
            await CoreService.SendDirectMessage(messageTargets, string.Empty, builder.Build());
        }