- Added two registration form examples
This commit is contained in:
parent
aa53dc9386
commit
1691d12fc8
@ -33,9 +33,8 @@
|
|||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
<HintPath>..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
<Private>True</Private>
|
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
@ -46,9 +45,8 @@
|
|||||||
<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="Telegram.Bot, Version=14.4.0.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="Telegram.Bot, Version=14.10.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\Telegram.Bot.14.4.0\lib\net45\Telegram.Bot.dll</HintPath>
|
<HintPath>..\packages\Telegram.Bot.14.10.0\lib\net45\Telegram.Bot.dll</HintPath>
|
||||||
<Private>True</Private>
|
|
||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@ -56,6 +54,13 @@
|
|||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Tests\ButtonTestForm.cs" />
|
<Compile Include="Tests\ButtonTestForm.cs" />
|
||||||
<Compile Include="Tests\ProgressTest.cs" />
|
<Compile Include="Tests\ProgressTest.cs" />
|
||||||
|
<Compile Include="Tests\Register\PerForm.cs" />
|
||||||
|
<Compile Include="Tests\Register\PerStep.cs" />
|
||||||
|
<Compile Include="Tests\Register\Start.cs" />
|
||||||
|
<Compile Include="Tests\Register\Steps\Data.cs" />
|
||||||
|
<Compile Include="Tests\Register\Steps\Step3.cs" />
|
||||||
|
<Compile Include="Tests\Register\Steps\Step2.cs" />
|
||||||
|
<Compile Include="Tests\Register\Steps\Step1.cs" />
|
||||||
<Compile Include="Tests\SimpleForm.cs" />
|
<Compile Include="Tests\SimpleForm.cs" />
|
||||||
<Compile Include="Tests\Start.cs" />
|
<Compile Include="Tests\Start.cs" />
|
||||||
<Compile Include="Tests\TestForm.cs" />
|
<Compile Include="Tests\TestForm.cs" />
|
||||||
@ -71,6 +76,7 @@
|
|||||||
<Name>TelegramBotBase</Name>
|
<Name>TelegramBotBase</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup />
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
|||||||
103
TelegramBaseTest/Tests/Register/PerForm.cs
Normal file
103
TelegramBaseTest/Tests/Register/PerForm.cs
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using TelegramBotBase.Base;
|
||||||
|
using TelegramBotBase.Form;
|
||||||
|
|
||||||
|
namespace TelegramBaseTest.Tests.Register
|
||||||
|
{
|
||||||
|
public class PerForm : AutoCleanForm
|
||||||
|
{
|
||||||
|
public String EMail { get; set; }
|
||||||
|
|
||||||
|
public String Firstname { get; set; }
|
||||||
|
|
||||||
|
public String Lastname { get; set; }
|
||||||
|
|
||||||
|
public async override Task Load(MessageResult message)
|
||||||
|
{
|
||||||
|
if (message.MessageText.Trim() == "")
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (this.Firstname == null)
|
||||||
|
{
|
||||||
|
this.Firstname = message.MessageText;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.Lastname == null)
|
||||||
|
{
|
||||||
|
this.Lastname = message.MessageText;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.EMail == null)
|
||||||
|
{
|
||||||
|
this.EMail = message.MessageText;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public async override Task Action(MessageResult message)
|
||||||
|
{
|
||||||
|
var call = message.GetData<CallbackData>();
|
||||||
|
|
||||||
|
await message.ConfirmAction();
|
||||||
|
|
||||||
|
if (call == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
switch (call.Value)
|
||||||
|
{
|
||||||
|
case "back":
|
||||||
|
|
||||||
|
var start = new Start();
|
||||||
|
|
||||||
|
await this.NavigateTo(start);
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public async override Task Render(MessageResult message)
|
||||||
|
{
|
||||||
|
if (this.Firstname == null)
|
||||||
|
{
|
||||||
|
await this.Device.Send("Please sent your firstname:");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.Lastname == null)
|
||||||
|
{
|
||||||
|
await this.Device.Send("Please sent your lastname:");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.EMail == null)
|
||||||
|
{
|
||||||
|
await this.Device.Send("Please sent your email address:");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
String s = "";
|
||||||
|
|
||||||
|
s += "Firstname: " + this.Firstname + "\r\n";
|
||||||
|
s += "Lastname: " + this.Lastname + "\r\n";
|
||||||
|
s += "E-Mail: " + this.EMail + "\r\n";
|
||||||
|
|
||||||
|
ButtonForm bf = new ButtonForm();
|
||||||
|
bf.AddButtonRow(new ButtonBase("Back", new CallbackData("a", "back").Serialize()));
|
||||||
|
|
||||||
|
await this.Device.Send("Your details:\r\n" + s, bf);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
47
TelegramBaseTest/Tests/Register/PerStep.cs
Normal file
47
TelegramBaseTest/Tests/Register/PerStep.cs
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using TelegramBotBase.Base;
|
||||||
|
using TelegramBotBase.Form;
|
||||||
|
|
||||||
|
namespace TelegramBaseTest.Tests.Register
|
||||||
|
{
|
||||||
|
public class PerStep: AutoCleanForm
|
||||||
|
{
|
||||||
|
|
||||||
|
public async override Task Action(MessageResult message)
|
||||||
|
{
|
||||||
|
await message.ConfirmAction();
|
||||||
|
|
||||||
|
switch (message.RawData)
|
||||||
|
{
|
||||||
|
case "start":
|
||||||
|
|
||||||
|
var step1 = new Steps.Step1();
|
||||||
|
|
||||||
|
await this.NavigateTo(step1);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case "back":
|
||||||
|
|
||||||
|
var start = new Start();
|
||||||
|
|
||||||
|
await this.NavigateTo(start);
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async override Task Render(MessageResult message)
|
||||||
|
{
|
||||||
|
ButtonForm bf = new ButtonForm();
|
||||||
|
bf.AddButtonRow(new ButtonBase("Goto Step 1", "start"));
|
||||||
|
bf.AddButtonRow(new ButtonBase("Back", "back"));
|
||||||
|
|
||||||
|
await this.Device.Send("Register Steps", bf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
72
TelegramBaseTest/Tests/Register/Start.cs
Normal file
72
TelegramBaseTest/Tests/Register/Start.cs
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using TelegramBotBase.Base;
|
||||||
|
using TelegramBotBase.Form;
|
||||||
|
|
||||||
|
namespace TelegramBaseTest.Tests.Register
|
||||||
|
{
|
||||||
|
public class Start : AutoCleanForm
|
||||||
|
{
|
||||||
|
public Start()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public async override Task Action(MessageResult message)
|
||||||
|
{
|
||||||
|
var call = message.GetData<CallbackData>();
|
||||||
|
|
||||||
|
await message.ConfirmAction();
|
||||||
|
|
||||||
|
|
||||||
|
if (call == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
switch (call.Value)
|
||||||
|
{
|
||||||
|
case "form":
|
||||||
|
|
||||||
|
var form = new PerForm();
|
||||||
|
|
||||||
|
await this.NavigateTo(form);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case "step":
|
||||||
|
|
||||||
|
var step = new PerStep();
|
||||||
|
|
||||||
|
await this.NavigateTo(step);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case "backtodashboard":
|
||||||
|
|
||||||
|
var start = new Tests.Start();
|
||||||
|
|
||||||
|
await this.NavigateTo(start);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public async override Task Render(MessageResult message)
|
||||||
|
{
|
||||||
|
|
||||||
|
ButtonForm btn = new ButtonForm();
|
||||||
|
|
||||||
|
btn.AddButtonRow(new ButtonBase("#4.1 Per Form", new CallbackData("a", "form").Serialize()));
|
||||||
|
btn.AddButtonRow(new ButtonBase("#4.2 Per Step", new CallbackData("a", "step").Serialize()));
|
||||||
|
btn.AddButtonRow(new ButtonBase("Back", new CallbackData("a", "backtodashboard").Serialize()));
|
||||||
|
|
||||||
|
await this.Device.Send("Choose your test:", btn);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
18
TelegramBaseTest/Tests/Register/Steps/Data.cs
Normal file
18
TelegramBaseTest/Tests/Register/Steps/Data.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace TelegramBaseTest.Tests.Register.Steps
|
||||||
|
{
|
||||||
|
public class Data
|
||||||
|
{
|
||||||
|
public String EMail { get; set; }
|
||||||
|
|
||||||
|
public String Firstname { get; set; }
|
||||||
|
|
||||||
|
public String Lastname { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
53
TelegramBaseTest/Tests/Register/Steps/Step1.cs
Normal file
53
TelegramBaseTest/Tests/Register/Steps/Step1.cs
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using TelegramBotBase.Base;
|
||||||
|
using TelegramBotBase.Form;
|
||||||
|
|
||||||
|
namespace TelegramBaseTest.Tests.Register.Steps
|
||||||
|
{
|
||||||
|
public class Step1 : AutoCleanForm
|
||||||
|
{
|
||||||
|
public Data UserData { get; set; }
|
||||||
|
|
||||||
|
public async override Task Init(params object[] args)
|
||||||
|
{
|
||||||
|
this.UserData = new Data();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async override Task Load(MessageResult message)
|
||||||
|
{
|
||||||
|
if (message.Handled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (message.MessageText.Trim() == "")
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (this.UserData.Firstname == null)
|
||||||
|
{
|
||||||
|
this.UserData.Firstname = message.MessageText;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async override Task Render(MessageResult message)
|
||||||
|
{
|
||||||
|
if (this.UserData.Firstname == null)
|
||||||
|
{
|
||||||
|
await this.Device.Send("Please sent your firstname:");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
message.Handled = true;
|
||||||
|
|
||||||
|
var step2 = new Step2();
|
||||||
|
|
||||||
|
step2.UserData = this.UserData;
|
||||||
|
|
||||||
|
await this.NavigateTo(step2);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
50
TelegramBaseTest/Tests/Register/Steps/Step2.cs
Normal file
50
TelegramBaseTest/Tests/Register/Steps/Step2.cs
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using TelegramBotBase.Base;
|
||||||
|
using TelegramBotBase.Form;
|
||||||
|
|
||||||
|
namespace TelegramBaseTest.Tests.Register.Steps
|
||||||
|
{
|
||||||
|
public class Step2 : AutoCleanForm
|
||||||
|
{
|
||||||
|
public Data UserData { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public async override Task Load(MessageResult message)
|
||||||
|
{
|
||||||
|
if (message.Handled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (message.MessageText.Trim() == "")
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (this.UserData.Lastname == null)
|
||||||
|
{
|
||||||
|
this.UserData.Lastname = message.MessageText;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public async override Task Render(MessageResult message)
|
||||||
|
{
|
||||||
|
if (this.UserData.Lastname == null)
|
||||||
|
{
|
||||||
|
await this.Device.Send("Please sent your lastname:");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
message.Handled = true;
|
||||||
|
|
||||||
|
var step3 = new Step3();
|
||||||
|
|
||||||
|
step3.UserData = this.UserData;
|
||||||
|
|
||||||
|
await this.NavigateTo(step3);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
71
TelegramBaseTest/Tests/Register/Steps/Step3.cs
Normal file
71
TelegramBaseTest/Tests/Register/Steps/Step3.cs
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using TelegramBotBase.Base;
|
||||||
|
using TelegramBotBase.Form;
|
||||||
|
|
||||||
|
namespace TelegramBaseTest.Tests.Register.Steps
|
||||||
|
{
|
||||||
|
public class Step3 : AutoCleanForm
|
||||||
|
{
|
||||||
|
public Data UserData { get; set; }
|
||||||
|
|
||||||
|
public async override Task Load(MessageResult message)
|
||||||
|
{
|
||||||
|
if (message.Handled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (message.MessageText.Trim() == "")
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (this.UserData.EMail == null)
|
||||||
|
{
|
||||||
|
this.UserData.EMail = message.MessageText;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async override Task Action(MessageResult message)
|
||||||
|
{
|
||||||
|
await message.ConfirmAction();
|
||||||
|
|
||||||
|
switch (message.RawData)
|
||||||
|
{
|
||||||
|
case "back":
|
||||||
|
|
||||||
|
var start = new Start();
|
||||||
|
|
||||||
|
await this.NavigateTo(start);
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public async override Task Render(MessageResult message)
|
||||||
|
{
|
||||||
|
if (this.UserData.EMail == null)
|
||||||
|
{
|
||||||
|
await this.Device.Send("Please sent your email:");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
message.Handled = true;
|
||||||
|
|
||||||
|
String s = "";
|
||||||
|
|
||||||
|
s += "Firstname: " + this.UserData.Firstname + "\r\n";
|
||||||
|
s += "Lastname: " + this.UserData.Lastname + "\r\n";
|
||||||
|
s += "E-Mail: " + this.UserData.EMail + "\r\n";
|
||||||
|
|
||||||
|
ButtonForm bf = new ButtonForm();
|
||||||
|
bf.AddButtonRow(new ButtonBase("Back", "back"));
|
||||||
|
|
||||||
|
await this.Device.Send("Your details:\r\n" + s, bf);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -27,8 +27,6 @@ namespace TelegramBaseTest.Tests
|
|||||||
|
|
||||||
var sf = new SimpleForm();
|
var sf = new SimpleForm();
|
||||||
|
|
||||||
await sf.Init();
|
|
||||||
|
|
||||||
await this.NavigateTo(sf);
|
await this.NavigateTo(sf);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -37,8 +35,6 @@ namespace TelegramBaseTest.Tests
|
|||||||
|
|
||||||
var bf = new ButtonTestForm();
|
var bf = new ButtonTestForm();
|
||||||
|
|
||||||
await bf.Init();
|
|
||||||
|
|
||||||
await this.NavigateTo(bf);
|
await this.NavigateTo(bf);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -47,10 +43,16 @@ namespace TelegramBaseTest.Tests
|
|||||||
|
|
||||||
var pf = new ProgressTest();
|
var pf = new ProgressTest();
|
||||||
|
|
||||||
await pf.Init();
|
|
||||||
|
|
||||||
await this.NavigateTo(pf);
|
await this.NavigateTo(pf);
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "registration":
|
||||||
|
|
||||||
|
var reg = new Register.Start();
|
||||||
|
|
||||||
|
await this.NavigateTo(reg);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +66,7 @@ namespace TelegramBaseTest.Tests
|
|||||||
|
|
||||||
btn.AddButtonRow(new ButtonBase("#1 Simple Text", new CallbackData("a", "text").Serialize()), new ButtonBase("#2 Button Test", new CallbackData("a", "buttons").Serialize()));
|
btn.AddButtonRow(new ButtonBase("#1 Simple Text", new CallbackData("a", "text").Serialize()), new ButtonBase("#2 Button Test", new CallbackData("a", "buttons").Serialize()));
|
||||||
btn.AddButtonRow(new ButtonBase("#3 Progress Bar", new CallbackData("a", "progress").Serialize()));
|
btn.AddButtonRow(new ButtonBase("#3 Progress Bar", new CallbackData("a", "progress").Serialize()));
|
||||||
|
btn.AddButtonRow(new ButtonBase("#4 Registration Example", new CallbackData("a", "registration").Serialize()));
|
||||||
|
|
||||||
await this.Device.Send("Choose your test:", btn);
|
await this.Device.Send("Choose your test:", btn);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net452" />
|
<package id="Newtonsoft.Json" version="12.0.1" targetFramework="net452" />
|
||||||
<package id="System.Net.Requests" version="4.3.0" targetFramework="net452" />
|
<package id="System.Net.Requests" version="4.3.0" targetFramework="net452" />
|
||||||
<package id="Telegram.Bot" version="14.4.0" targetFramework="net452" />
|
<package id="Telegram.Bot" version="14.10.0" targetFramework="net452" />
|
||||||
</packages>
|
</packages>
|
||||||
Loading…
x
Reference in New Issue
Block a user