SMS-utskick har lagts till
This commit is contained in:
29
TrackerLibrary/SMSLogic.cs
Normal file
29
TrackerLibrary/SMSLogic.cs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Twilio;
|
||||||
|
using Twilio.Rest.Api.V2010.Account;
|
||||||
|
using Twilio.Types;
|
||||||
|
|
||||||
|
namespace TrackerLibrary
|
||||||
|
{
|
||||||
|
public class SMSLogic
|
||||||
|
{
|
||||||
|
public static void SendSMSMessage(string to, string textMessage)
|
||||||
|
{
|
||||||
|
string accountSid = GlobalConfig.AppKeyLookup("smsAccountSid");
|
||||||
|
string authToken = GlobalConfig.AppKeyLookup("smsAuthToken");
|
||||||
|
string fromPhoneNumber = GlobalConfig.AppKeyLookup("smsFromPhoneNumber");
|
||||||
|
|
||||||
|
TwilioClient.Init(accountSid, authToken);
|
||||||
|
|
||||||
|
var message = MessageResource.Create(
|
||||||
|
to: new PhoneNumber(to),
|
||||||
|
from: new PhoneNumber(fromPhoneNumber),
|
||||||
|
body: textMessage
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -73,11 +73,8 @@ namespace TrackerLibrary
|
|||||||
|
|
||||||
private static void AlertPersonToNewRound(PersonModel p, string teamName, MatchupEntryModel competitor)
|
private static void AlertPersonToNewRound(PersonModel p, string teamName, MatchupEntryModel competitor)
|
||||||
{
|
{
|
||||||
if (p.EmailAddress.Length == 0)
|
if (p.EmailAddress.Length > 0)
|
||||||
{
|
{
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
string subject;
|
string subject;
|
||||||
StringBuilder body = new StringBuilder();
|
StringBuilder body = new StringBuilder();
|
||||||
|
|
||||||
@ -104,7 +101,15 @@ namespace TrackerLibrary
|
|||||||
string to = p.EmailAddress;
|
string to = p.EmailAddress;
|
||||||
|
|
||||||
|
|
||||||
EmailLogic.SendEmail(to, subject, body.ToString()); ;
|
EmailLogic.SendEmail(to, subject, body.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (p.CellPhoneNumber.Length > 0)
|
||||||
|
{
|
||||||
|
SMSLogic.SendSMSMessage(p.CellPhoneNumber, $"You have a new matchup with {competitor.TeamCompeting.TeamName}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int CheckCurrentRound(this TournamentModel model)
|
private static int CheckCurrentRound(this TournamentModel model)
|
||||||
|
|||||||
@ -37,15 +37,31 @@
|
|||||||
<Reference Include="Dapper, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="Dapper, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\Dapper.2.0.30\lib\net461\Dapper.dll</HintPath>
|
<HintPath>..\packages\Dapper.2.0.30\lib\net461\Dapper.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.IdentityModel.Logging, Version=1.1.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\Microsoft.IdentityModel.Logging.1.1.2\lib\net451\Microsoft.IdentityModel.Logging.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.IdentityModel.Tokens, Version=5.1.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\Microsoft.IdentityModel.Tokens.5.1.2\lib\net451\Microsoft.IdentityModel.Tokens.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\Newtonsoft.Json.10.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Configuration" />
|
<Reference Include="System.Configuration" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.IdentityModel.Tokens.Jwt, Version=5.1.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\System.IdentityModel.Tokens.Jwt.5.1.2\lib\net451\System.IdentityModel.Tokens.Jwt.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Net" />
|
||||||
<Reference Include="System.Xml.Linq" />
|
<Reference Include="System.Xml.Linq" />
|
||||||
<Reference Include="System.Data.DataSetExtensions" />
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
<Reference Include="System.Net.Http" />
|
<Reference Include="System.Net.Http" />
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
|
<Reference Include="Twilio, Version=5.39.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\Twilio.5.39.1\lib\net451\Twilio.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="DataAccess\IDataConnection.cs" />
|
<Compile Include="DataAccess\IDataConnection.cs" />
|
||||||
@ -62,9 +78,11 @@
|
|||||||
<Compile Include="Models\TeamModel.cs" />
|
<Compile Include="Models\TeamModel.cs" />
|
||||||
<Compile Include="Models\TournamentModel.cs" />
|
<Compile Include="Models\TournamentModel.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="SMSLogic.cs" />
|
||||||
<Compile Include="TournamentLogic.cs" />
|
<Compile Include="TournamentLogic.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<None Include="app.config" />
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
11
TrackerLibrary/app.config
Normal file
11
TrackerLibrary/app.config
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<configuration>
|
||||||
|
<runtime>
|
||||||
|
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
</assemblyBinding>
|
||||||
|
</runtime>
|
||||||
|
</configuration>
|
||||||
@ -2,4 +2,9 @@
|
|||||||
<packages>
|
<packages>
|
||||||
<package id="Dapper" version="2.0.30" targetFramework="net472" />
|
<package id="Dapper" version="2.0.30" targetFramework="net472" />
|
||||||
<package id="Microsoft.CodeAnalysis.Analyzers" version="3.0.0" targetFramework="net472" developmentDependency="true" />
|
<package id="Microsoft.CodeAnalysis.Analyzers" version="3.0.0" targetFramework="net472" developmentDependency="true" />
|
||||||
|
<package id="Microsoft.IdentityModel.Logging" version="1.1.2" targetFramework="net472" />
|
||||||
|
<package id="Microsoft.IdentityModel.Tokens" version="5.1.2" targetFramework="net472" />
|
||||||
|
<package id="Newtonsoft.Json" version="10.0.1" targetFramework="net472" />
|
||||||
|
<package id="System.IdentityModel.Tokens.Jwt" version="5.1.2" targetFramework="net472" />
|
||||||
|
<package id="Twilio" version="5.39.1" targetFramework="net472" />
|
||||||
</packages>
|
</packages>
|
||||||
@ -6,6 +6,9 @@
|
|||||||
<add key="greaterWins" value="1" />
|
<add key="greaterWins" value="1" />
|
||||||
<add key="senderEmail" value="tommy@oeman.se" />
|
<add key="senderEmail" value="tommy@oeman.se" />
|
||||||
<add key="senderDisplayName" value="Tommy Öman" />
|
<add key="senderDisplayName" value="Tommy Öman" />
|
||||||
|
<add key="smsAccountSid" value="AC722d9a6f2c7812a1eb4e091426ca5581" />
|
||||||
|
<add key="smsAuthToken" value="8383d2239d043690984c7b80a8b0a704" />
|
||||||
|
<add key="smsFromPhoneNumber" value="+12058462699" />
|
||||||
</appSettings>
|
</appSettings>
|
||||||
<connectionStrings>
|
<connectionStrings>
|
||||||
<!--<add name="Tournaments" connectionString="Server=TOMMYASUS\SQLEXPR2017;Database=Tournaments;Trusted_Connection=True;" providerName="System.Data.SqlClient"/>-->
|
<!--<add name="Tournaments" connectionString="Server=TOMMYASUS\SQLEXPR2017;Database=Tournaments;Trusted_Connection=True;" providerName="System.Data.SqlClient"/>-->
|
||||||
@ -22,4 +25,12 @@
|
|||||||
<startup>
|
<startup>
|
||||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||||
</startup>
|
</startup>
|
||||||
|
<runtime>
|
||||||
|
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
</assemblyBinding>
|
||||||
|
</runtime>
|
||||||
</configuration>
|
</configuration>
|
||||||
Reference in New Issue
Block a user