Example for C# Client by Custom Development

Execute Example "Manage Item by Barcode" to create Endpoint beforehand.

First, install Dropbox and create account. Next, office will set up shared folder for the account. Then notification will be sent to the account for the shared forlder. Please accept it by pushing OK. By doing that, files will be downloaded into Dropbox folder in local PC. (This step is as same as "Example for Edit or Add Endpoint by Custom Development Option".)

Then, add Project Output Setting for C# Client.

Output path is set based on existing Proxy Setting.

"Target Server's Source Output" is corresponding setting of Proxy Server which is connect from this setting. You can choose from selection on Dropdown list.

Start Build. (See Step 5 on Quick Start Guide about how to do it)

After Build, some classes will be created to call proxy from C#. Then, file is saved in Dropbox's Shared Folder.

Create Project by Visual Studio. Now, choose WPF Project.

Add Source File in the Project.

Add "Reference" on the Visual Studio Project.

Add button on WPF Window, then assign Click Event.

Change source as follows. Access Endpoint to get data by Barcode based on example "Manage Item by Barcode".

private async void button_Click(object sender, RoutedEventArgs e)     ← set "async" because it is asynchronoze.
{
DBClasses.AssetInfoProxyGetSpecificAssetByBarcodeRequestParams param = new DBClasses.AssetInfoProxyGetSpecificAssetByBarcodeRequestParams(); ← Class for Parameter
param.TOKEN = "????"; ← Set TOKEN
param.param_AssetInfo_Barcode_where = "9784845623556"; ← Set Parameter

DBClasses.AssetInfoProxyClient client = new DBClasses.AssetInfoProxyClient(); ← Use Client Class
DBClasses.AssetInfoProxyGetSpecificAssetByBarcodeProxyResult result = await client.GetSpecificAssetByBarcode(param); ← Execute by asynctonize
if (result.Status == DBClasses.ProxyResultStatusType.OK)
{
Console.WriteLine("Success!"); ← Success
Console.WriteLine("Item Name: " + result.Result.ItemName); ← Display result on console
Console.WriteLine("Description: " + result.Result.Description); Display result on console
}
else
{
Console.WriteLine("Failed! Result: " + result.Status); Failed
}
}

After execute, output result as follows.

Success!
Item Name: def book
Description: this is def...

This is another example. Access Endpoint to get all data based on example "Manage Item by Barcode".

private async void button1_Click(object sender, RoutedEventArgs e)
{
DBClasses.AssetInfoProxyGetAllListRequestParams param = new DBClasses.AssetInfoProxyGetAllListRequestParams();
param.TOKEN = "????";

DBClasses.AssetInfoProxyClient client = new DBClasses.AssetInfoProxyClient();
DBClasses.AssetInfoProxyGetAllListProxyResult result = await client.GetAllList(param);
if (result.Status == DBClasses.ProxyResultStatusType.OK)
{
Console.WriteLine("Success!");
for(int i = 0; i < result.Result.Count; i++) ← Get data by list
{
Console.WriteLine(string.Format("Item {0}/{1}:", i + 1, result.Result.Count));
Console.WriteLine("Barcode: " + result.Result[i].Barcode);
Console.WriteLine("Item Name: " + result.Result[i].ItemName);
Console.WriteLine("Description: " + result.Result[i].Description);
}
}
else
{
Console.WriteLine("Failed! Result: " + result.Status);
}
}

After execute, output result as follows.

Success!

Item 1/2:
Barcode: 1923073020005
Item Name: ABC book
Description: This is ABC...

Item 2/2:
Barcode: 9784845623556
Item Name: DEF Travel Book
Description: This is DEF...

This is another example. Access Endpoint to add data based on example "Manage Item by Barcode".

private async void button2_Click(object sender, RoutedEventArgs e)
{
DBClasses.AssetInfoProxyInsertAssetRequestParams param = new DBClasses.AssetInfoProxyInsertAssetRequestParams();
param.TOKEN = "????";
param.AssetInfoObj = new DBClasses.AssetInfoData();
param.AssetInfoObj.Barcode = "9784845623556";
param.AssetInfoObj.ItemName = "New Item Name";
param.AssetInfoObj.Description = "New Description";

DBClasses.AssetInfoProxyClient client = new DBClasses.AssetInfoProxyClient();
DBClasses.AssetInfoProxyInsertAssetProxyResult result = await client.InsertAsset(param);
if (result.Status == DBClasses.ProxyResultStatusType.OK)
{
Console.WriteLine("Success!");
}
else
{
Console.WriteLine("Failed! Result: " + result.Status);
}
}

This is another example. Access Endpoint to update data by Barcode based on example "Manage Item by Barcode".

private async void button3_Click(object sender, RoutedEventArgs e)
{
DBClasses.AssetInfoProxyUpdateAssetRequestParams param = new DBClasses.AssetInfoProxyUpdateAssetRequestParams();
param.TOKEN = "????";
param.AssetInfoObj = new DBClasses.AssetInfoData();
param.AssetInfoObj.Barcode = "9784845623556";
param.AssetInfoObj.ItemName = "Updated Item Name";
param.AssetInfoObj.Description = "Updated Description";

DBClasses.AssetInfoProxyClient client = new DBClasses.AssetInfoProxyClient();
DBClasses.AssetInfoProxyUpdateAssetProxyResult result = await client.UpdateAsset(param);
if (result.Status == DBClasses.ProxyResultStatusType.OK)
{
Console.WriteLine("Success!");
}
else
{
Console.WriteLine("Failed! Result: " + result.Status);
}
}

※Please refer example "Access Endpoint by C#" to access Endpoint without Custom Development Option.

Back to top

LoginLogin with this Site's User Name (ID)
Quick Login:Quick Login by Facebook ID (Keep Login Option:ON) / Newly Register


Inquiry

© 2016-2019 Matsuesoft Corporation