Commit 1debe12ff4ab9f90964978db6d6421277acb6918
1 parent
99c770eb84
Exists in
master
RM2077: Add new project procees AmazonDynamoDB
Showing 10 changed files with 543 additions and 0 deletions Inline Diff
- sources/RoboforkApp.AWS/App.config
- sources/RoboforkApp.AWS/Contracts/ITableDataService.cs
- sources/RoboforkApp.AWS/DynamoDb/DynamoService.cs
- sources/RoboforkApp.AWS/Entities/DynamoTable.cs
- sources/RoboforkApp.AWS/Properties/AssemblyInfo.cs
- sources/RoboforkApp.AWS/RoboforkApp.AWS.csproj
- sources/RoboforkApp/Entities/Fork2PC.cs
- sources/RoboforkApp/Entities/Robofork15Demo.cs
- sources/RoboforkApp/Services/Fork2PCTableService.cs
- sources/RoboforkApp/Services/Robofork15DemoService.cs
sources/RoboforkApp.AWS/App.config
File was created | 1 | <?xml version="1.0"?> | |
2 | <configuration> | ||
3 | <appSettings> | ||
4 | <add key="AWSProfileName" value="Development"/> | ||
5 | <add key="AWSRegion" value="ap-northeast-1" /> | ||
6 | </appSettings> | ||
7 | <startup> | ||
8 | <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> | ||
9 | </startup> | ||
10 | </configuration> | ||
11 |
sources/RoboforkApp.AWS/Contracts/ITableDataService.cs
File was created | 1 | using System; | |
2 | using System.Collections.Generic; | ||
3 | using System.Linq; | ||
4 | using System.Text; | ||
5 | using System.Threading.Tasks; | ||
6 | |||
7 | namespace RoboforkApp.AWS.Contracts | ||
8 | { | ||
9 | public interface ITableDataService | ||
10 | { | ||
11 | void Store<T>(T item) where T : new(); | ||
12 | void BatchStore<T>(IEnumerable<T> items) where T : class; | ||
13 | IEnumerable<T> GetAll<T>() where T : class; | ||
14 | T GetItem<T>(string key) where T : class; | ||
15 | } | ||
16 | } | ||
17 |
sources/RoboforkApp.AWS/DynamoDb/DynamoService.cs
File was created | 1 | using System.Collections.Generic; | |
2 | using Amazon.DynamoDBv2; | ||
3 | using Amazon.DynamoDBv2.DataModel; | ||
4 | using RoboforkApp.AWS.Contracts; | ||
5 | |||
6 | namespace RoboforkApp.AWS.DynamoDb | ||
7 | { | ||
8 | public class DynamoService : ITableDataService | ||
9 | { | ||
10 | public readonly DynamoDBContext DbContext; | ||
11 | public AmazonDynamoDBClient DynamoClient; | ||
12 | |||
13 | public DynamoService() | ||
14 | { | ||
15 | DynamoClient = new AmazonDynamoDBClient(); | ||
16 | |||
17 | DbContext = new DynamoDBContext(DynamoClient, new DynamoDBContextConfig | ||
18 | { | ||
19 | //Setting the Consistent property to true ensures that you'll always get the latest | ||
20 | ConsistentRead = true, | ||
21 | SkipVersionCheck = true | ||
22 | }); | ||
23 | } | ||
24 | |||
25 | /// <summary> | ||
26 | /// The Store method allows you to save a POCO to DynamoDb | ||
27 | /// </summary> | ||
28 | /// <typeparam name="T"></typeparam> | ||
29 | /// <param name="item"></param> | ||
30 | public void Store<T>(T item) where T : new() | ||
31 | { | ||
32 | DbContext.Save(item); | ||
33 | } | ||
34 | |||
35 | /// <summary> | ||
36 | /// The BatchStore Method allows you to store a list of items of type T to dynamoDb | ||
37 | /// </summary> | ||
38 | /// <typeparam name="T"></typeparam> | ||
39 | /// <param name="items"></param> | ||
40 | public void BatchStore<T>(IEnumerable<T> items) where T : class | ||
41 | { | ||
42 | var itemBatch = DbContext.CreateBatchWrite<T>(); | ||
43 | |||
44 | foreach (var item in items) | ||
45 | { | ||
46 | itemBatch.AddPutItem(item); | ||
47 | } | ||
48 | |||
49 | itemBatch.Execute(); | ||
50 | } | ||
51 | /// <summary> | ||
52 | /// Uses the scan operator to retrieve all items in a table | ||
53 | /// <remarks>[CAUTION] This operation can be very expensive if your table is large</remarks> | ||
54 | /// </summary> | ||
55 | /// <typeparam name="T"></typeparam> | ||
56 | /// <returns></returns> | ||
57 | public IEnumerable<T> GetAll<T>() where T : class | ||
58 | { | ||
59 | IEnumerable<T> items = DbContext.Scan<T>(); | ||
60 | return items; | ||
61 | } | ||
62 | |||
63 | /// <summary> | ||
64 | /// Retrieves an item based on a search key | ||
65 | /// </summary> | ||
66 | /// <typeparam name="T"></typeparam> | ||
67 | /// <param name="key"></param> | ||
68 | /// <returns></returns> | ||
69 | public T GetItem<T>(string key) where T : class | ||
70 | { | ||
71 | return DbContext.Load<T>(key); | ||
72 | } | ||
73 | |||
74 | /// <summary> | ||
75 | /// Method Updates and existing item in the table | ||
76 | /// </summary> | ||
77 | /// <typeparam name="T"></typeparam> | ||
78 | /// <param name="item"></param> | ||
79 | public void UpdateItem<T>(T item) where T : class | ||
80 | { | ||
81 | T savedItem = DbContext.Load(item); | ||
82 | |||
83 | if (savedItem == null) | ||
84 | { | ||
85 | throw new AmazonDynamoDBException("The item does not exist in the Table"); | ||
86 | } | ||
87 | |||
88 | DbContext.Save(item); | ||
89 | } | ||
90 | |||
91 | /// <summary> | ||
92 | /// Deletes an Item from the table. | ||
93 | /// </summary> | ||
94 | /// <typeparam name="T"></typeparam> | ||
95 | /// <param name="item"></param> | ||
96 | public void DeleteItem<T>(T item) | ||
97 | { | ||
98 | var savedItem = DbContext.Load(item); | ||
99 | |||
100 | if (savedItem == null) | ||
101 | { | ||
102 | throw new AmazonDynamoDBException("The item does not exist in the Table"); | ||
103 | } | ||
104 | |||
105 | DbContext.Delete(item); | ||
106 | } | ||
107 | |||
108 | } | ||
109 | } | ||
110 |
sources/RoboforkApp.AWS/Entities/DynamoTable.cs
File was created | 1 | namespace RoboforkApp.AWS.Entities | |
2 | { | ||
3 | public class DynamoTable | ||
4 | { | ||
5 | public string PrimaryKey { get; set; } | ||
6 | public string HashKey { get; set; } | ||
7 | public string RangeKey { get; set; } | ||
8 | } | ||
9 | } | ||
10 |
sources/RoboforkApp.AWS/Properties/AssemblyInfo.cs
File was created | 1 | using System.Reflection; | |
2 | using System.Runtime.CompilerServices; | ||
3 | using System.Runtime.InteropServices; | ||
4 | |||
5 | // General Information about an assembly is controlled through the following | ||
6 | // set of attributes. Change these attribute values to modify the information | ||
7 | // associated with an assembly. | ||
8 | [assembly: AssemblyTitle("RoboforkApp.AWS")] | ||
9 | [assembly: AssemblyDescription("")] | ||
10 | [assembly: AssemblyConfiguration("")] | ||
11 | [assembly: AssemblyCompany("")] | ||
12 | [assembly: AssemblyProduct("RoboforkApp.AWS")] | ||
13 | [assembly: AssemblyCopyright("Copyright © 2017")] | ||
14 | [assembly: AssemblyTrademark("")] | ||
15 | [assembly: AssemblyCulture("")] | ||
16 | |||
17 | // Setting ComVisible to false makes the types in this assembly not visible | ||
18 | // to COM components. If you need to access a type in this assembly from | ||
19 | // COM, set the ComVisible attribute to true on that type. | ||
20 | [assembly: ComVisible(false)] | ||
21 | |||
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM | ||
23 | // [assembly: Guid("9dfd12bf-548c-4489-8b66-5d7717541002")] | ||
24 | |||
25 | // Version information for an assembly consists of the following four values: | ||
26 | // | ||
27 | // Major Version | ||
28 | // Minor Version | ||
29 | // Build Number | ||
30 | // Revision | ||
31 | // | ||
32 | // You can specify all the values or you can default the Build and Revision Numbers | ||
33 | // by using the '*' as shown below: | ||
34 | // [assembly: AssemblyVersion("1.0.*")] | ||
35 | [assembly: AssemblyVersion("1.0.0.0")] | ||
36 | [assembly: AssemblyFileVersion("1.0.0.0")] | ||
37 |
sources/RoboforkApp.AWS/RoboforkApp.AWS.csproj
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
3 | <PropertyGroup> | ||
4 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
5 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
6 | <ProductVersion>9.0.30729</ProductVersion> | ||
7 | <SchemaVersion>2.0</SchemaVersion> | ||
8 | <ProjectGuid>{A4DB3A6A-7959-4517-844B-4D00AE09436C}</ProjectGuid> | ||
9 | <OutputType>Library</OutputType> | ||
10 | <AppDesignerFolder>Properties</AppDesignerFolder> | ||
11 | <RootNamespace>RoboforkApp.AWS</RootNamespace> | ||
12 | <AssemblyName>RoboforkApp.AWS</AssemblyName> | ||
13 | <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> | ||
14 | <FileAlignment>512</FileAlignment> | ||
15 | <IsWebBootstrapper>false</IsWebBootstrapper> | ||
16 | <FileUpgradeFlags> | ||
17 | </FileUpgradeFlags> | ||
18 | <OldToolsVersion>3.5</OldToolsVersion> | ||
19 | <UpgradeBackupLocation /> | ||
20 | <PublishUrl>publish\</PublishUrl> | ||
21 | <Install>true</Install> | ||
22 | <InstallFrom>Disk</InstallFrom> | ||
23 | <UpdateEnabled>false</UpdateEnabled> | ||
24 | <UpdateMode>Foreground</UpdateMode> | ||
25 | <UpdateInterval>7</UpdateInterval> | ||
26 | <UpdateIntervalUnits>Days</UpdateIntervalUnits> | ||
27 | <UpdatePeriodically>false</UpdatePeriodically> | ||
28 | <UpdateRequired>false</UpdateRequired> | ||
29 | <MapFileExtensions>true</MapFileExtensions> | ||
30 | <ApplicationRevision>0</ApplicationRevision> | ||
31 | <ApplicationVersion>1.0.0.%2a</ApplicationVersion> | ||
32 | <UseApplicationTrust>false</UseApplicationTrust> | ||
33 | <BootstrapperEnabled>true</BootstrapperEnabled> | ||
34 | <TargetFrameworkProfile /> | ||
35 | </PropertyGroup> | ||
36 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
37 | <DebugSymbols>true</DebugSymbols> | ||
38 | <DebugType>full</DebugType> | ||
39 | <Optimize>false</Optimize> | ||
40 | <OutputPath>bin\Debug\</OutputPath> | ||
41 | <DefineConstants>DEBUG;TRACE</DefineConstants> | ||
42 | <ErrorReport>prompt</ErrorReport> | ||
43 | <WarningLevel>4</WarningLevel> | ||
44 | <DocumentationFile> | ||
45 | </DocumentationFile> | ||
46 | <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet> | ||
47 | </PropertyGroup> | ||
48 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
49 | <DebugType>pdbonly</DebugType> | ||
50 | <Optimize>true</Optimize> | ||
51 | <OutputPath>bin\Release\</OutputPath> | ||
52 | <DefineConstants>TRACE</DefineConstants> | ||
53 | <ErrorReport>prompt</ErrorReport> | ||
54 | <WarningLevel>4</WarningLevel> | ||
55 | <DocumentationFile> | ||
56 | </DocumentationFile> | ||
57 | <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet> | ||
58 | </PropertyGroup> | ||
59 | <PropertyGroup> | ||
60 | <StartupObject /> | ||
61 | </PropertyGroup> | ||
62 | <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
63 | <!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
64 | Other similar extension points exist, see Microsoft.Common.targets. | ||
65 | <Target Name="BeforeBuild"> | ||
66 | </Target> | ||
67 | <Target Name="AfterBuild"> | ||
68 | </Target> | ||
69 | --> | ||
70 | <Choose> | ||
71 | <When Condition=" '$(TargetFrameworkVersion)' == 'v3.5' Or '$(TargetFrameworkVersion)' == 'v4.0' "> | ||
72 | <ItemGroup> | ||
73 | <Reference Include="AWSSDK.Core, Version=3.0.0.0, Culture=neutral, processorArchitecture=MSIL"> | ||
74 | <SpecificVersion>False</SpecificVersion> | ||
75 | <Private>True</Private> | ||
76 | <HintPath>C:\Program Files (x86)\AWS SDK for .NET\bin\Net35\AWSSDK.Core.dll</HintPath> | ||
77 | </Reference> | ||
78 | <Reference Include="AWSSDK.S3, Version=3.0.0.0, Culture=neutral, processorArchitecture=MSIL"> | ||
79 | <SpecificVersion>False</SpecificVersion> | ||
80 | <Private>True</Private> | ||
81 | <HintPath>C:\Program Files (x86)\AWS SDK for .NET\bin\Net35\AWSSDK.S3.dll</HintPath> | ||
82 | </Reference> | ||
83 | </ItemGroup> | ||
84 | </When> | ||
85 | <Otherwise /> | ||
86 | </Choose> | ||
87 | <ItemGroup> | ||
88 | <Reference Include="AWSSDK"> | ||
89 | <HintPath>C:\Program Files (x86)\AWS SDK for .NET\past-releases\Version-2\Net45\AWSSDK.dll</HintPath> | ||
90 | </Reference> | ||
91 | <Reference Include="System" /> | ||
92 | <Reference Include="System.Core" /> | ||
93 | <Reference Include="System.Xml.Linq" /> | ||
94 | <Reference Include="System.Data.DataSetExtensions" /> | ||
95 | <Reference Include="Microsoft.CSharp" /> | ||
96 | <Reference Include="System.Data" /> | ||
97 | <Reference Include="System.Xml" /> | ||
98 | </ItemGroup> | ||
99 | <ItemGroup> | ||
100 | <Compile Include="Contracts\ITableDataService.cs" /> | ||
101 | <Compile Include="DynamoDb\DynamoService.cs" /> | ||
102 | <Compile Include="Entities\DynamoTable.cs" /> | ||
103 | <Compile Include="Properties\AssemblyInfo.cs" /> | ||
104 | </ItemGroup> | ||
105 | <ItemGroup> | ||
106 | <BootstrapperPackage Include="Microsoft.Net.Client.3.5"> | ||
107 | <Visible>False</Visible> | ||
108 | <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName> | ||
109 | <Install>false</Install> | ||
110 | </BootstrapperPackage> | ||
111 | <BootstrapperPackage Include="Microsoft.Net.Framework.2.0"> | ||
112 | <Visible>False</Visible> | ||
113 | <ProductName>.NET Framework 2.0 %28x86%29</ProductName> | ||
114 | <Install>true</Install> | ||
115 | </BootstrapperPackage> | ||
116 | <BootstrapperPackage Include="Microsoft.Net.Framework.3.0"> | ||
117 | <Visible>False</Visible> | ||
118 | <ProductName>.NET Framework 3.0 %28x86%29</ProductName> | ||
119 | <Install>false</Install> | ||
120 | </BootstrapperPackage> | ||
121 | <BootstrapperPackage Include="Microsoft.Net.Framework.3.5"> | ||
122 | <Visible>False</Visible> | ||
123 | <ProductName>.NET Framework 3.5</ProductName> | ||
124 | <Install>false</Install> | ||
125 | </BootstrapperPackage> | ||
126 | <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1"> | ||
127 | <Visible>False</Visible> | ||
128 | <ProductName>.NET Framework 3.5 SP1</ProductName> | ||
129 | <Install>false</Install> | ||
130 | </BootstrapperPackage> | ||
131 | </ItemGroup> | ||
132 | <ItemGroup> | ||
133 | <None Include="App.config" /> | ||
134 | </ItemGroup> | ||
135 | </Project> |
sources/RoboforkApp/Entities/Fork2PC.cs
File was created | 1 | using System.Collections.Generic; | |
2 | using Amazon.DynamoDBv2.DataModel; | ||
3 | |||
4 | namespace RoboforkApp.Entities | ||
5 | { | ||
6 | [DynamoDBTable("Fork2PCTable")] | ||
7 | public class Fork2PC | ||
8 | { | ||
9 | // フォークリフトそれぞれの ID ※ID は”1”固定 | ||
10 | [DynamoDBHashKey] | ||
11 | public int ForkID { get; set; } | ||
12 | // 実舵角 ※10 進数 LSB 0.1 | ||
13 | public byte ang_str { get; set; } | ||
14 | // 駆動コントローラフェールフラグ | ||
15 | public byte fail_con1 { get; set; } | ||
16 | // ステアコントローラフェールフラグ | ||
17 | public byte fail_con2 { get; set; } | ||
18 | // ハンディコントローラのフェールフラグ | ||
19 | public byte fail_hand { get; set; } | ||
20 | // リフト高さセンサのフェールフラグ | ||
21 | public byte fail_high { get; set; } | ||
22 | // 走行モータのフェールフラグ | ||
23 | public byte fail_mot1 { get; set; } | ||
24 | // ステアモータのフェールフラグ | ||
25 | public byte fail_mot2 { get; set; } | ||
26 | // リフト油圧モータのフェールフラグ | ||
27 | public byte fail_mot3 { get; set; } | ||
28 | // 車速センサのフェールフラグ | ||
29 | public byte fail_spd { get; set; } | ||
30 | // 舵角センサのフェールフラグ | ||
31 | public byte fail_str { get; set; } | ||
32 | // 重度バッテリ低下フラグ | ||
33 | public byte flag_bat_hi { get; set; } | ||
34 | // 軽度バッテリ低下フラグ | ||
35 | public byte flag_bat_lo { get; set; } | ||
36 | // 緊急停止フラグ | ||
37 | public byte flag_emestp { get; set; } | ||
38 | // 軽度エラーフラグ | ||
39 | public byte flag_err1 { get; set; } | ||
40 | // 重度エラーフラグ | ||
41 | public byte flag_err2 { get; set; } | ||
42 | // ハンディ操作中フラグ | ||
43 | public byte flag_handy { get; set; } | ||
44 | // READY フラグ | ||
45 | public byte flag_ready { get; set; } | ||
46 | // スキャナによる停止中フラグ | ||
47 | public byte flag_stop { get; set; } | ||
48 | // 出発時点からの x 変位※10 進数 LSB 0.001 m ←GPS 使用 | ||
49 | public double ForkPos_x { get; set; } | ||
50 | // 出発地点からの y 変位 ※10 進数 LSB 0.001 m ←GPS 使用 | ||
51 | public double ForkPos_y { get; set; } | ||
52 | // 実リフト高さ ※10 進数 LSB 0.001 m | ||
53 | public double height_lift { get; set; } | ||
54 | // 実速度 ※10 進数 LSB 0.001m | ||
55 | public double spd_veh { get; set; } | ||
56 | // GPS データ ※GPRMC 方式 このデータのみ String | ||
57 | public string GPS_data { get; set; } | ||
58 | |||
59 | //public override string ToString() | ||
60 | //{ | ||
61 | // return string.Format(@"{0} – {1} Actors: {2}", Title, ReleaseYear, string.Join(", ", ActorNames.ToArray())); | ||
62 | //} | ||
63 | } | ||
64 | } | ||
65 |
sources/RoboforkApp/Entities/Robofork15Demo.cs
File was created | 1 | using System.Collections.Generic; | |
2 | using Amazon.DynamoDBv2.DataModel; | ||
3 | |||
4 | namespace RoboforkApp.Entities | ||
5 | { | ||
6 | [DynamoDBTable("Robofork15Demo")] | ||
7 | public class Robofork15Demo | ||
8 | { | ||
9 | // フォークリフト毎の ID(No.)今回は"1"固定 | ||
10 | [DynamoDBHashKey] | ||
11 | public int ForkID { get; set; } | ||
12 | // ラストノードフラグ 最後のノードでは”1” | ||
13 | public byte LastNodeFlag { get; set; } | ||
14 | // スタート位置からのノードの ID | ||
15 | public int NodeID { get; set; } | ||
16 | // ノードの目標リフト高さ ※10 進数 LSB 0.001 m | ||
17 | public double NodeLftHeight { get; set; } | ||
18 | // スタート位置からの x 差分 ※10 進数 LSB 0.001 m | ||
19 | public double NodePos_x { get; set; } | ||
20 | // スタート位置からの y 差分 ※10 進数 LSB 0.001 m | ||
21 | public double NodePos_y { get; set; } | ||
22 | // ノードの目標速度 ※10 進数 LSB 0.001m | ||
23 | public double NodeVehSpd { get; set; } | ||
24 | // ノードの車両角度(前ノードとの差分) | ||
25 | public double NodeVehAng { get; set; } | ||
26 | } | ||
27 | } | ||
28 |
sources/RoboforkApp/Services/Fork2PCTableService.cs
File was created | 1 | using System; | |
2 | using System.Collections.Generic; | ||
3 | using Amazon.DynamoDBv2; | ||
4 | using Amazon.DynamoDBv2.DocumentModel; | ||
5 | using Amazon.DynamoDBv2.Model; | ||
6 | using RoboforkApp.AWS.DynamoDb; | ||
7 | using RoboforkApp.Entities; | ||
8 | |||
9 | namespace RoboforkApp.Services | ||
10 | { | ||
11 | public class Fork2PCTableService | ||
12 | { | ||
13 | private readonly DynamoService _dynamoService; | ||
14 | |||
15 | public Fork2PCTableService() | ||
16 | { | ||
17 | _dynamoService = new DynamoService(); | ||
18 | } | ||
19 | |||
20 | /// <summary> | ||
21 | /// AddFork2PC will accept a Fork2PC object and creates an Item on Amazon DynamoDB | ||
22 | /// </summary> | ||
23 | /// <param name="fork2PC"></param> | ||
24 | public void AddFork2PC(Fork2PC fork2PC) | ||
25 | { | ||
26 | _dynamoService.Store(fork2PC); | ||
27 | } | ||
28 | |||
29 | /// <summary> | ||
30 | /// ModifyFork2PC tries to load an existing Fork2PC, modifies and saves it back. If the Item doesn’t exist, it raises an exception | ||
31 | /// </summary> | ||
32 | /// <param name="fork2PC"></param> | ||
33 | public void ModifyFork2PC(Fork2PC fork2PC) | ||
34 | { | ||
35 | _dynamoService.UpdateItem(fork2PC); | ||
36 | } | ||
37 | |||
38 | /// <summary> | ||
39 | /// GetALllFork2PCs will perform a Table Scan operation to return all the Fork2PCs | ||
40 | /// </summary> | ||
41 | /// <returns></returns> | ||
42 | public IEnumerable<Fork2PC> GetAllFork2PCs() | ||
43 | { | ||
44 | return _dynamoService.GetAll<Fork2PC>(); | ||
45 | } | ||
46 | |||
47 | /// <summary> | ||
48 | /// SearchFork2PCs will search all data Fork2PCs with id | ||
49 | /// </summary> | ||
50 | /// <param name="title"></param> | ||
51 | /// <param name="releaseYear"></param> | ||
52 | /// <returns></returns> | ||
53 | public IEnumerable<Fork2PC> SearchFork2PCs(int forkId) | ||
54 | { | ||
55 | IEnumerable<Fork2PC> filteredFork2PCs = _dynamoService.DbContext.Query<Fork2PC>(forkId, QueryOperator.Equal); | ||
56 | |||
57 | return filteredFork2PCs; | ||
58 | } | ||
59 | |||
60 | /// <summary> | ||
61 | /// Delete Fork2PC will remove an item from DynamoDb | ||
62 | /// </summary> | ||
63 | /// <param name="fork2PC"></param> | ||
64 | public void DeleteFork2PC(Fork2PC fork2PC) | ||
65 | { | ||
66 | _dynamoService.DeleteItem(fork2PC); | ||
67 | } | ||
68 | } | ||
69 | } | ||
70 |
sources/RoboforkApp/Services/Robofork15DemoService.cs
File was created | 1 | using System; | |
2 | using System.Collections.Generic; | ||
3 | using Amazon.DynamoDBv2; | ||
4 | using Amazon.DynamoDBv2.DocumentModel; | ||
5 | using Amazon.DynamoDBv2.Model; | ||
6 | using RoboforkApp.AWS.DynamoDb; | ||
7 | using RoboforkApp.Entities; | ||
8 | |||
9 | namespace RoboforkApp.Services | ||
10 | { | ||
11 | public class Robofork15DemoService | ||
12 | { | ||
13 | private readonly DynamoService _dynamoService; | ||
14 | |||
15 | public Robofork15DemoService() | ||
16 | { | ||
17 | _dynamoService = new DynamoService(); | ||
18 | } | ||
19 | |||
20 | /// <summary> | ||
21 | /// AddRobofork15Demo will accept a Robofork15Demo object and creates an Item on Amazon DynamoDB | ||
22 | /// </summary> | ||
23 | /// <param name="robofork15Demo"></param> | ||
24 | public void AddRobofork15Demo(Robofork15Demo robofork15Demo) | ||
25 | { | ||
26 | _dynamoService.Store(robofork15Demo); | ||
27 | } | ||
28 | |||
29 | /// <summary> | ||
30 | /// ModifyRobofork15Demo tries to load an existing Robofork15Demo, modifies and saves it back. If the Item doesn’t exist, it raises an exception | ||
31 | /// </summary> | ||
32 | /// <param name="robofork15Demo"></param> | ||
33 | public void ModifyRobofork15Demo(Robofork15Demo robofork15Demo) | ||
34 | { | ||
35 | _dynamoService.UpdateItem(robofork15Demo); | ||
36 | } | ||
37 | |||
38 | /// <summary> | ||
39 | /// GetALllRobofork15Demos will perform a Table Scan operation to return all the Robofork15Demos | ||
40 | /// </summary> | ||
41 | /// <returns></returns> | ||
42 | public IEnumerable<Robofork15Demo> GetAllRobofork15Demos() | ||
43 | { | ||
44 | return _dynamoService.GetAll<Robofork15Demo>(); | ||
45 | } | ||
46 | |||
47 | /// <summary> | ||
48 | /// SearchRobofork15Demos will search all data Robofork15Demos with id | ||
49 | /// </summary> | ||
50 | /// <param name="forkId">Fork Id</param> | ||
51 | /// <returns></returns> | ||
52 | public IEnumerable<Robofork15Demo> SearchRobofork15Demos(int forkId) | ||
53 | { | ||
54 | IEnumerable<Robofork15Demo> filteredRobofork15Demos = _dynamoService.DbContext.Query<Robofork15Demo>(forkId, QueryOperator.Equal); | ||
55 | |||
56 | return filteredRobofork15Demos; | ||
57 | } | ||
58 | |||
59 | /// <summary> | ||
60 | /// Delete Robofork15Demo will remove an item from DynamoDb | ||
61 | /// </summary> | ||
62 | /// <param name="robofork15Demo"></param> | ||
63 | public void DeleteRobofork15Demo(Robofork15Demo robofork15Demo) | ||
64 | { | ||
65 | _dynamoService.DeleteItem(robofork15Demo); | ||
66 | } | ||
67 | } | ||
68 | } | ||
69 |