Commit ed57a528 by Liv Haapala

update

1 parent cb5c96f1
Showing with 2876 additions and 262 deletions
......@@ -53,7 +53,7 @@
this.PortsComboBox.FormattingEnabled = true;
this.PortsComboBox.Location = new System.Drawing.Point(12, 47);
this.PortsComboBox.Name = "PortsComboBox";
this.PortsComboBox.Size = new System.Drawing.Size(313, 21);
this.PortsComboBox.Size = new System.Drawing.Size(310, 21);
this.PortsComboBox.TabIndex = 15;
this.PortsComboBox.SelectedIndexChanged += new System.EventHandler(this.PortsComboBox_SelectedIndexChanged);
//
......@@ -66,7 +66,7 @@
this.status.Multiline = true;
this.status.Name = "status";
this.status.ReadOnly = true;
this.status.Size = new System.Drawing.Size(313, 205);
this.status.Size = new System.Drawing.Size(310, 226);
this.status.TabIndex = 17;
//
// toolStrip1
......@@ -75,7 +75,7 @@
this.settingsToolStripButton});
this.toolStrip1.Location = new System.Drawing.Point(0, 0);
this.toolStrip1.Name = "toolStrip1";
this.toolStrip1.Size = new System.Drawing.Size(340, 25);
this.toolStrip1.Size = new System.Drawing.Size(337, 25);
this.toolStrip1.TabIndex = 18;
this.toolStrip1.Text = "toolStrip1";
//
......@@ -93,7 +93,7 @@
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(340, 291);
this.ClientSize = new System.Drawing.Size(337, 312);
this.Controls.Add(this.toolStrip1);
this.Controls.Add(this.status);
this.Controls.Add(this.label4);
......
......@@ -29,14 +29,11 @@ namespace BarcodeScannerClient
}
PortsComboBox.SelectedItem = Properties.Settings.Default.Port;
// apiKeyTextBox.Text = Properties.Settings.Default.ApiKey;
<<<<<<< HEAD
apiUrlTextBox.Text = Properties.Settings.Default.ApiURL;
if (apiUrlTextBox.Text == "")
//apiUrlTextBox.Text = Properties.Settings.Default.ApiURL;
if (Properties.Settings.Default.ApiURL == "")
{
apiUrlTextBox.Text = "http://my.event.ltd/shop/rfidListener.jsf?reader=demo_reader&tag=%";
Properties.Settings.Default.ApiURL = "http://my.event.ltd/MoyaWeb/shop/rfidListener.jsf?reader=demo_reader&tag=%";
}
=======
>>>>>>> b730dd7f982f556ecbc4adf437995c3832096919
}
string ret = "";
......
......@@ -50,12 +50,6 @@
</ItemGroup>
<ItemGroup>
<Compile Include="DataClasses\MetaData.cs" />
<Compile Include="Forms\AddCardMetaData.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\AddCardMetaData.Designer.cs">
<DependentUpon>AddCardMetaData.cs</DependentUpon>
</Compile>
<Compile Include="DataClasses\Card.cs" />
<Compile Include="DataClasses\CardList.cs" />
<Compile Include="DataClasses\Eventuser.cs" />
......@@ -78,9 +72,6 @@
<Compile Include="DataClasses\ReaderEventList.cs" />
<Compile Include="DataClasses\ReaderList.cs" />
<Compile Include="DataClasses\RestClient.cs" />
<EmbeddedResource Include="Forms\AddCardMetaData.resx">
<DependentUpon>AddCardMetaData.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\ApiSettings.resx">
<DependentUpon>ApiSettings.cs</DependentUpon>
</EmbeddedResource>
......
......@@ -47,8 +47,10 @@
this.forwardSlot2Button = new System.Windows.Forms.Button();
this.forwardSlot3Button = new System.Windows.Forms.Button();
this.toolStrip1 = new System.Windows.Forms.ToolStrip();
this.toolStripButton1 = new System.Windows.Forms.ToolStripButton();
this.settingsToolStripButton = new System.Windows.Forms.ToolStripButton();
this.cardPlaceLabel1 = new System.Windows.Forms.Label();
this.cardPlaceLabel2 = new System.Windows.Forms.Label();
this.cardPlaceLabel3 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).BeginInit();
......@@ -90,7 +92,7 @@
// readersComboBox1
//
this.readersComboBox1.FormattingEnabled = true;
this.readersComboBox1.Location = new System.Drawing.Point(12, 68);
this.readersComboBox1.Location = new System.Drawing.Point(12, 28);
this.readersComboBox1.Name = "readersComboBox1";
this.readersComboBox1.Size = new System.Drawing.Size(159, 21);
this.readersComboBox1.TabIndex = 3;
......@@ -99,7 +101,7 @@
// readersComboBox2
//
this.readersComboBox2.FormattingEnabled = true;
this.readersComboBox2.Location = new System.Drawing.Point(194, 68);
this.readersComboBox2.Location = new System.Drawing.Point(195, 28);
this.readersComboBox2.Name = "readersComboBox2";
this.readersComboBox2.Size = new System.Drawing.Size(159, 21);
this.readersComboBox2.TabIndex = 4;
......@@ -108,7 +110,7 @@
// readersComboBox3
//
this.readersComboBox3.FormattingEnabled = true;
this.readersComboBox3.Location = new System.Drawing.Point(371, 68);
this.readersComboBox3.Location = new System.Drawing.Point(373, 28);
this.readersComboBox3.Name = "readersComboBox3";
this.readersComboBox3.Size = new System.Drawing.Size(159, 21);
this.readersComboBox3.TabIndex = 5;
......@@ -203,7 +205,6 @@
// toolStrip1
//
this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripButton1,
this.settingsToolStripButton});
this.toolStrip1.Location = new System.Drawing.Point(0, 0);
this.toolStrip1.Name = "toolStrip1";
......@@ -211,16 +212,6 @@
this.toolStrip1.TabIndex = 16;
this.toolStrip1.Text = "toolStrip1";
//
// toolStripButton1
//
this.toolStripButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.toolStripButton1.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton1.Image")));
this.toolStripButton1.ImageTransparentColor = System.Drawing.Color.Magenta;
this.toolStripButton1.Name = "toolStripButton1";
this.toolStripButton1.Size = new System.Drawing.Size(23, 22);
this.toolStripButton1.Text = "Syötä korttidataa";
this.toolStripButton1.Click += new System.EventHandler(this.toolStripButton1_Click);
//
// settingsToolStripButton
//
this.settingsToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
......@@ -231,11 +222,44 @@
this.settingsToolStripButton.Text = "Api Settings";
this.settingsToolStripButton.Click += new System.EventHandler(this.settingsToolStripButton_Click);
//
// cardPlaceLabel1
//
this.cardPlaceLabel1.AutoSize = true;
this.cardPlaceLabel1.Font = new System.Drawing.Font("Microsoft Sans Serif", 24F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.cardPlaceLabel1.Location = new System.Drawing.Point(20, 56);
this.cardPlaceLabel1.Name = "cardPlaceLabel1";
this.cardPlaceLabel1.Size = new System.Drawing.Size(151, 37);
this.cardPlaceLabel1.TabIndex = 23;
this.cardPlaceLabel1.Text = "00.00.00";
//
// cardPlaceLabel2
//
this.cardPlaceLabel2.AutoSize = true;
this.cardPlaceLabel2.Font = new System.Drawing.Font("Microsoft Sans Serif", 24F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.cardPlaceLabel2.Location = new System.Drawing.Point(203, 56);
this.cardPlaceLabel2.Name = "cardPlaceLabel2";
this.cardPlaceLabel2.Size = new System.Drawing.Size(151, 37);
this.cardPlaceLabel2.TabIndex = 24;
this.cardPlaceLabel2.Text = "00.00.00";
//
// cardPlaceLabel3
//
this.cardPlaceLabel3.AutoSize = true;
this.cardPlaceLabel3.Font = new System.Drawing.Font("Microsoft Sans Serif", 24F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.cardPlaceLabel3.Location = new System.Drawing.Point(381, 56);
this.cardPlaceLabel3.Name = "cardPlaceLabel3";
this.cardPlaceLabel3.Size = new System.Drawing.Size(151, 37);
this.cardPlaceLabel3.TabIndex = 25;
this.cardPlaceLabel3.Text = "00.00.00";
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(544, 388);
this.Controls.Add(this.cardPlaceLabel3);
this.Controls.Add(this.cardPlaceLabel2);
this.Controls.Add(this.cardPlaceLabel1);
this.Controls.Add(this.toolStrip1);
this.Controls.Add(this.forwardSlot3Button);
this.Controls.Add(this.forwardSlot2Button);
......@@ -283,8 +307,10 @@
private System.Windows.Forms.Button forwardSlot2Button;
private System.Windows.Forms.Button forwardSlot3Button;
private System.Windows.Forms.ToolStrip toolStrip1;
private System.Windows.Forms.ToolStripButton toolStripButton1;
private System.Windows.Forms.ToolStripButton settingsToolStripButton;
private System.Windows.Forms.Label cardPlaceLabel1;
private System.Windows.Forms.Label cardPlaceLabel2;
private System.Windows.Forms.Label cardPlaceLabel3;
}
}
......@@ -133,23 +133,6 @@
<value>431, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="toolStripButton1.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAKcSURBVDhPzc9rT9JhGAZwvkmv2+pFa5mzwyamNU+prclo
lBjTPJAIzhmgZSpzaGBTsLlKB03Rcoqr5UwlJgrTTHCehglMC0ItNNDk8H+u/oL2Ferant3b/eJ3Xw/j
/4m400619Lsoea/LWqtxnD9aR9OkWWEqdGurCt0CVd7yCUfrWCpU1pHKdiukXXYcZstPkcGpH0Q95NxW
aE2XFLrl0cnlfWL3AGNz+5CqjKhv7Qab3xiDhEpLr8nmhkg1FwV6jVt4bdzAgtNPRK2TYf2Ek/hDgHsH
WFynUNJkALgFkJ5jxgCBwjxqXnCDr5iIAr+CgOt7APJXS+CI++D2hUFRFPkdocj6NiBQWjAsqMGVxMxj
YHLCZveisGE4CvSMe9Gud2LJtYc8STfm13agGliHn4YPWxQ1jsFonkVCck4M4Ms/Wr989eGOtA9hGqDo
5/DsQ9w+g1zRSyh0i/DuBkmQbrHpB+4+HISw6jHijxuUyD+sbnh3wa7SIhLtAKy6I7AsbSO7uAVmetZr
HTCtEOwcALcfaBAmDIiqk2NAkeyt2xcIgV3RgQAteOkr884D9Bu+ITVfBsmzacwse+Hw7mHTT8AqV6Pj
TSUS07JiAFvU4fxJAzfL2vDZGcK4LYCR6U10Ds7jGrcOSu0U9IZF9Ly3QamzIKe4GSdcblzkV8UAlkDl
of8InvQ5rvPqEJdRCiZLArZIg0SWGByhGlkFMqRwqhGXXoqELD5SugZwOZdHokDu/bZghAAeXwgTti28
MznR1jWCyoYXOHO1EOyiatQ0a6DVT2HIYMPsigcavQXZvKZYgxv8J/5bQnWYJXhKUrm1JI37iMRnluFs
6j2cTuLi5CUOTjHzSVw6n1zIriBJLEkkI08W+gv84zAYfwDinvxVez/TeQAAAABJRU5ErkJggg==
</value>
</data>
<data name="settingsToolStripButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Script.Serialization;
namespace MoyaAdminLib
{
public class Card
{
public static string CARD_STATE_PRINTED = "PRINTED";
public static string CARD_BARCODE_PREFIX = "277";
//{"cardId":3990,"state":"PENDING_VALIDATION","cardTemplate":"pelaaja","username":"Miketzu","wholeName":"Mirco Renko"}
public int cardId;
public string state;
public string cardTemplate;
public string username;
public string wholeName;
public String Label()
{
return cardId + ", " + username + ", " + wholeName;
}
public static bool ParseCardId(string data, out int id)
{
id = 0;
if (data.Length == 13 && data.Substring(0, 3) == CARD_BARCODE_PREFIX)
{
int.TryParse(data.Substring(3, 9), out id);
if (id > 0)
return true;
}
return false;
}
}
}
......@@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MoyaAdminUI.MoyaAPI
namespace MoyaAdminLib
{
public class EventUsers
{
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MoyaAdminLib
{
public class MetaData
{
public string key;
public string value;
public static MetaData GetValue(string ret)
{
MetaData data = null;
if (ret != null && ret != "")
{
ret = ret.Trim();
if (ret.StartsWith("{") && ret.EndsWith("}"))
{
ret = ret.Replace("{", "");
ret = ret.Replace("}", "");
if (ret.Contains(":"))
{
data = new MetaData();
string[] fields = ret.Split(new string[] { ":" }, StringSplitOptions.RemoveEmptyEntries);
if (fields.Length == 2)
{
if (fields[0].StartsWith("\""))
fields[0] = fields[0].Substring(1, fields[0].Length - 1);
if (fields[0].EndsWith("\""))
fields[0] = fields[0].Substring(0, fields[0].Length - 1);
data.key = fields[0];
if (fields[1].StartsWith("\""))
fields[1] = fields[1].Substring(1, fields[1].Length - 1);
if (fields[1].EndsWith("\""))
fields[1] = fields[1].Substring(0, fields[1].Length - 1);
data.value = fields[1];
}
}
}
}
return data;
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{095CE28F-5B53-4203-85C6-3A9AFD486407}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MoyaAdminLib</RootNamespace>
<AssemblyName>MoyaAdminLib</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Card.cs" />
<Compile Include="eventuser.cs" />
<Compile Include="EventUsers.cs" />
<Compile Include="MetaData.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Reader.cs" />
<Compile Include="ReaderEvent.cs" />
<Compile Include="ReaderEventList.cs" />
<Compile Include="ReaderList.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Service References\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- 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.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("MoyaAdminLib")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MoyaAdminLib")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("9d9047fd-ab37-4245-b2f9-c0e5a0efef42")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MoyaAdminLib
{
public class Reader
{
public string description;
public int readerId;
public string identification;
public string readerType;
public override string ToString()
{
string name = identification;
if (description != "")
name += ":" + description;
return name;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MoyaAdminLib
{
public class ReaderEvent
{
public int readerEventId = 0;
public DateTime readerEventTime = DateTime.MinValue;
public int readerId = 0;
public Eventuser eventuser;
public int printedCardId = 0;
public string printedCardState = "";
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MoyaAdminLib
{
public class ReaderEventList
{
public List<ReaderEvent> readerEvents = new List<ReaderEvent>();
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MoyaAdminLib
{
public class ReaderList
{
public List<Reader> readers = new List<Reader>();
}
}
<?xml version="1.0"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
......@@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MoyaAdminUI.MoyaAPI
namespace MoyaAdminLib
{
//"eventuserId":7019,"firstname":"Topi","lastname":"Kinnunen","login":"xxtopotxx","userId":4902,"nick":"xXtopotXx"},
public class Eventuser
......
......@@ -3,6 +3,8 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Express 2012 for Windows Desktop
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MoyaAdminUI", "MoyaAdminUI\MoyaAdminUI.csproj", "{56D4C2A6-B4A2-4E40-ACFB-19E188AAD703}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MoyaAdminLib", "MoyaAdminLib\MoyaAdminLib.csproj", "{095CE28F-5B53-4203-85C6-3A9AFD486407}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
......@@ -13,6 +15,10 @@ Global
{56D4C2A6-B4A2-4E40-ACFB-19E188AAD703}.Debug|Any CPU.Build.0 = Debug|Any CPU
{56D4C2A6-B4A2-4E40-ACFB-19E188AAD703}.Release|Any CPU.ActiveCfg = Release|Any CPU
{56D4C2A6-B4A2-4E40-ACFB-19E188AAD703}.Release|Any CPU.Build.0 = Release|Any CPU
{095CE28F-5B53-4203-85C6-3A9AFD486407}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{095CE28F-5B53-4203-85C6-3A9AFD486407}.Debug|Any CPU.Build.0 = Debug|Any CPU
{095CE28F-5B53-4203-85C6-3A9AFD486407}.Release|Any CPU.ActiveCfg = Release|Any CPU
{095CE28F-5B53-4203-85C6-3A9AFD486407}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
......@@ -25,6 +25,9 @@
<setting name="ApplicationVersion" serializeAs="String">
<value />
</setting>
<setting name="Port" serializeAs="String">
<value />
</setting>
</MoyaAdminUI.Properties.Settings>
</userSettings>
</configuration>
\ No newline at end of file
using MoyaAdminUI.MoyaAPI;
using MoyaAdminLib;
using MoyaAdminUI.MoyaAPI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
......@@ -28,55 +29,79 @@ namespace MoyaAdminUI
private void CardLocationInput_Load(object sender, EventArgs e)
{
updatePreviewTextBox();
}
private void barcodeTextBox_TextChanged(object sender, EventArgs e)
{
barcodeTimer.Start();
if(barcodeTextBox.Text != "")
barcodeTimer.Start();
}
private void barcodeTimer_Tick(object sender, EventArgs e)
{
if (barcodeTextBox.Text.Length == barcodeLength && barcodeTextBox.Text.Substring(0, 3) == CARD_PREFIX)
barcodeTimer.Stop();
string barcode = barcodeTextBox.Text;
if (barcode.Length == barcodeLength && barcode.Substring(0, 3) == CARD_PREFIX)
{
string idtext = barcodeTextBox.Text.Substring(3,9);
string idtext = barcode.Substring(3, 9);
int id = 0;
int.TryParse(idtext, out id);
if(id != 0)
if (id != 0)
{
RestClient client = new RestClient(Properties.Settings.Default.ApiURL);
string ret = client.MakeRequest("card/Get/" + id);
var ser = new JavaScriptSerializer();
Card card = ser.Deserialize<Card>(ret);
int lastAddedBook = (int)booksNumberNumericUpDown.Value;
int lastAddedPage = (int)pageNumberNumericUpDown.Value;
int lastAddedSlot = (int)slotsNumberNumericUpDown.Value;
string value = "";
if (prefixTextBox.Text != "")
value = prefixTextBox.Text + ".";
value += BooksNumberNumericUpDown.Value.ToString() + "." + PageNumberNumericUpDown.Value.ToString() + "." + SlotsNumberNumericUpDown.Value.ToString();
value += booksNumberNumericUpDown.Value.ToString() + "." + pageNumberNumericUpDown.Value.ToString() + "." + slotsNumberNumericUpDown.Value.ToString();
if ((SlotsNumberNumericUpDown.Value + 1) >= SlotsNumberNumericUpDown.Value)
if ((slotsNumberNumericUpDown.Value + 1) > numberOfCardSlotsnumericUpDown.Value)
{
SlotsNumberNumericUpDown.Value = 1;
PageNumberNumericUpDown.Value++;
slotsNumberNumericUpDown.Value = 1;
pageNumberNumericUpDown.Value++;
}
else
SlotsNumberNumericUpDown.Value++;
slotsNumberNumericUpDown.Value++;
lastAddedBookNumericUpDown.Value = BooksNumberNumericUpDown.Value;
lastAddedPageNumericUpDown.Value = PageNumberNumericUpDown.Value;
lastAddedSlotsNumericUpDown.Value = SlotsNumberNumericUpDown.Value;
string json = "{\"" + key + "\":\"" + value + "\"}";
RestClient client2 = new RestClient(Properties.Settings.Default.ApiURL, HttpVerb.POST, json);
client2.MakeRequest("meta/v1/printedcard/" + card.cardId + "/card-filing");
try
{
client2.MakeRequest("meta/v1/printedcard/" + card.cardId + "/card-filing");
}
catch (ApplicationException ex)
{
if (!ex.Message.Contains("HTTP NoContent"))
return;
}
lastAddedMeta = card;
lastAddedBookNumericUpDown.Value = lastAddedBook;
lastAddedPageNumericUpDown.Value = lastAddedPage;
lastAddedSlotsNumericUpDown.Value = lastAddedSlot;
messageToolStripStatusLabel.Text = "Viimeisin lisätty value: " + value + " kortille: " + card.Label();
}
else
messageToolStripStatusLabel.Text = "Viivakoodin lukeminen ei onnistunut!";
}
else
messageToolStripStatusLabel.Text = "Viivakoodin lukeminen ei onnistunut!";
barcodeTextBox.Text = "";
}
private void BooksNumberNumericUpDown_ValueChanged(object sender, EventArgs e)
......@@ -87,9 +112,9 @@ namespace MoyaAdminUI
private void updatePreviewTextBox()
{
if(prefixTextBox.Text != "")
prefixTextBox.Text = prefixTextBox.Text + "." + BooksNumberNumericUpDown.Value.ToString() + "." + PageNumberNumericUpDown.Value.ToString() + "." + SlotsNumberNumericUpDown.Value.ToString();
previewTextBox.Text = prefixTextBox.Text + "." + booksNumberNumericUpDown.Value.ToString() + "." + pageNumberNumericUpDown.Value.ToString() + "." + slotsNumberNumericUpDown.Value.ToString();
else
prefixTextBox.Text = BooksNumberNumericUpDown.Value.ToString() + "." + PageNumberNumericUpDown.Value.ToString() + "." + SlotsNumberNumericUpDown.Value.ToString();
previewTextBox.Text = booksNumberNumericUpDown.Value.ToString() + "." + pageNumberNumericUpDown.Value.ToString() + "." + slotsNumberNumericUpDown.Value.ToString();
}
private void PageNumberNumericUpDown_ValueChanged(object sender, EventArgs e)
......@@ -107,16 +132,5 @@ namespace MoyaAdminUI
barcodeTextBox.Focus();
}
private void editButton_Click(object sender, EventArgs e)
{
string value = "";
if (prefixTextBox.Text != "")
value = prefixTextBox.Text + ".";
value += lastAddedBookNumericUpDown.Value.ToString() + "." + lastAddedPageNumericUpDown.Value.ToString() + "." + lastAddedSlotsNumericUpDown.Value.ToString();
string json = "{\"" + key + "\":\"" + value + "\"}";
RestClient client2 = new RestClient(Properties.Settings.Default.ApiURL, HttpVerb.POST, json);
client2.MakeRequest("meta/v1/printedcard/" + lastAddedMeta.cardId + "/card-filing");
}
}
}
......@@ -120,4 +120,7 @@
<metadata name="barcodeTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>144, 17</value>
</metadata>
</root>
\ No newline at end of file
......@@ -3,10 +3,10 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MoyaAdminUI.MoyaAPI;
using System.Drawing;
using System.Web.Script.Serialization;
using System.ComponentModel;
using MoyaAdminUI.MoyaAPI;
namespace MoyaAdminUI
{
......@@ -207,10 +207,12 @@ namespace MoyaAdminUI
string json = client.MakeRequest("placeadmin/places/" + mapId);
var ser = new JavaScriptSerializer();
PlaceMap map = ser.Deserialize<PlaceMap>(json);
foreach (Place p in map.places)
if (map != null)
{
ComputerPlace.Cache.Add( new ComputerPlace(p));
foreach (Place p in map.places)
{
ComputerPlace.Cache.Add(new ComputerPlace(p));
}
}
}
......
namespace MoyaAdminUI
{
partial class IncomingForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.cardPictureBox = new System.Windows.Forms.PictureBox();
this.label4 = new System.Windows.Forms.Label();
this.PortsComboBox = new System.Windows.Forms.ComboBox();
((System.ComponentModel.ISupportInitialize)(this.cardPictureBox)).BeginInit();
this.SuspendLayout();
//
// cardPictureBox
//
this.cardPictureBox.Location = new System.Drawing.Point(15, 52);
this.cardPictureBox.Name = "cardPictureBox";
this.cardPictureBox.Size = new System.Drawing.Size(190, 248);
this.cardPictureBox.TabIndex = 0;
this.cardPictureBox.TabStop = false;
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(12, 9);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(71, 13);
this.label4.TabIndex = 18;
this.label4.Text = "Scanner port:";
//
// PortsComboBox
//
this.PortsComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.PortsComboBox.FormattingEnabled = true;
this.PortsComboBox.Location = new System.Drawing.Point(15, 25);
this.PortsComboBox.Name = "PortsComboBox";
this.PortsComboBox.Size = new System.Drawing.Size(310, 21);
this.PortsComboBox.TabIndex = 17;
this.PortsComboBox.SelectedIndexChanged += new System.EventHandler(this.PortsComboBox_SelectedIndexChanged);
//
// IncomingForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(612, 358);
this.Controls.Add(this.label4);
this.Controls.Add(this.PortsComboBox);
this.Controls.Add(this.cardPictureBox);
this.Name = "IncomingForm";
this.Text = "IncomingForm";
this.Load += new System.EventHandler(this.IncomingForm_Load);
((System.ComponentModel.ISupportInitialize)(this.cardPictureBox)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.PictureBox cardPictureBox;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.ComboBox PortsComboBox;
}
}
\ No newline at end of file
using BarcodeScannerClient;
using MoyaAdminLib;
using MoyaAdminUI.MoyaAPI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Script.Serialization;
using System.Windows.Forms;
namespace MoyaAdminUI
{
public partial class IncomingForm : Form
{
public static string TICKET_PREFIX = "279";
public IncomingForm()
{
InitializeComponent();
}
BarCodeScanner scanner = new BarCodeScanner();
private void IncomingForm_Load(object sender, EventArgs e)
{
scanner.BarcodeReceived += new BarCodeScanner.Barcode(scanner_BarcodeReceived);
string[] ports = SerialPort.GetPortNames();
foreach (string port in ports)
{
PortsComboBox.Items.Add(port);
}
PortsComboBox.SelectedItem = Properties.Settings.Default.Port;
}
string ret = "";
private void scanner_BarcodeReceived(string data)
{
int id = 0;
if (parseEventUserId(data, out id))
{
RestClient client = new RestClient(Properties.Settings.Default.ApiURL);
try
{
ret = client.MakeRequest("user/card/" + id);
var ser = new JavaScriptSerializer();
Card card = ser.Deserialize<Card>(ret);
if (card != null)
{
cardPictureBox.ImageLocation = Properties.Settings.Default.ApiURL + "/rest/card/GetImage/" + card.cardId;
}
} catch(Exception ex) {
}
}
}
private bool parseEventUserId(string data, out int id)
{
id = 0;
if (data.Length == 13 && data.Substring(0, 3) == TICKET_PREFIX)
{
int.TryParse(data.Substring(3, 9), out id);
if (id > 0)
return true;
}
return false;
}
private void PortsComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
scanner.Close();
if (PortsComboBox.SelectedItem != null)
{
scanner.Port = PortsComboBox.SelectedItem.ToString();
}
scanner.Listen();
}
}
}
......@@ -117,7 +117,4 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>
\ No newline at end of file
......@@ -44,11 +44,13 @@
this.usersToolStripPrintButton = new System.Windows.Forms.ToolStripButton();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.toolStripButton1 = new System.Windows.Forms.ToolStripButton();
this.cardLocationInputToolStripButton = new System.Windows.Forms.ToolStripButton();
this.TopPanel = new System.Windows.Forms.Panel();
this.label3 = new System.Windows.Forms.Label();
this.MapsComboBox = new System.Windows.Forms.ComboBox();
this.panel1 = new System.Windows.Forms.Panel();
this.cardLocationInputToolStripButton = new System.Windows.Forms.ToolStripButton();
this.incomingFormToolStripButton = new System.Windows.Forms.ToolStripButton();
this.cardInfoToolStripButton = new System.Windows.Forms.ToolStripButton();
((System.ComponentModel.ISupportInitialize)(this.MapPictureBox)).BeginInit();
this.toolStrip1.SuspendLayout();
this.TopPanel.SuspendLayout();
......@@ -131,7 +133,9 @@
this.usersToolStripPrintButton,
this.toolStripSeparator1,
this.toolStripButton1,
this.cardLocationInputToolStripButton});
this.cardLocationInputToolStripButton,
this.incomingFormToolStripButton,
this.cardInfoToolStripButton});
this.toolStrip1.Location = new System.Drawing.Point(0, 0);
this.toolStrip1.Name = "toolStrip1";
this.toolStrip1.Size = new System.Drawing.Size(1042, 25);
......@@ -184,6 +188,16 @@
this.toolStripButton1.Text = "Api settings";
this.toolStripButton1.Click += new System.EventHandler(this.toolStripButton1_Click_1);
//
// cardLocationInputToolStripButton
//
this.cardLocationInputToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.cardLocationInputToolStripButton.Image = ((System.Drawing.Image)(resources.GetObject("cardLocationInputToolStripButton.Image")));
this.cardLocationInputToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta;
this.cardLocationInputToolStripButton.Name = "cardLocationInputToolStripButton";
this.cardLocationInputToolStripButton.Size = new System.Drawing.Size(23, 22);
this.cardLocationInputToolStripButton.Text = "Korttien sijaintien hallinta";
this.cardLocationInputToolStripButton.Click += new System.EventHandler(this.cardLocationInputToolStripButton_Click);
//
// TopPanel
//
this.TopPanel.Controls.Add(this.label3);
......@@ -223,15 +237,25 @@
this.panel1.Size = new System.Drawing.Size(284, 426);
this.panel1.TabIndex = 16;
//
// cardLocationInputToolStripButton
// incomingFormToolStripButton
//
this.cardLocationInputToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.cardLocationInputToolStripButton.Image = ((System.Drawing.Image)(resources.GetObject("cardLocationInputToolStripButton.Image")));
this.cardLocationInputToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta;
this.cardLocationInputToolStripButton.Name = "cardLocationInputToolStripButton";
this.cardLocationInputToolStripButton.Size = new System.Drawing.Size(23, 22);
this.cardLocationInputToolStripButton.Text = "Korttien sijaintien hallinta";
this.cardLocationInputToolStripButton.Click += new System.EventHandler(this.cardLocationInputToolStripButton_Click);
this.incomingFormToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.incomingFormToolStripButton.Image = ((System.Drawing.Image)(resources.GetObject("incomingFormToolStripButton.Image")));
this.incomingFormToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta;
this.incomingFormToolStripButton.Name = "incomingFormToolStripButton";
this.incomingFormToolStripButton.Size = new System.Drawing.Size(23, 22);
this.incomingFormToolStripButton.Text = "Sisäänottonäkymä";
this.incomingFormToolStripButton.Click += new System.EventHandler(this.incomingFormToolStripButton_Click);
//
// cardInfoToolStripButton
//
this.cardInfoToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.cardInfoToolStripButton.Image = ((System.Drawing.Image)(resources.GetObject("cardInfoToolStripButton.Image")));
this.cardInfoToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta;
this.cardInfoToolStripButton.Name = "cardInfoToolStripButton";
this.cardInfoToolStripButton.Size = new System.Drawing.Size(23, 22);
this.cardInfoToolStripButton.Text = "Kortin tiedot";
this.cardInfoToolStripButton.Click += new System.EventHandler(this.cardInfoToolStripButton_Click);
//
// MainForm
//
......@@ -279,6 +303,8 @@
private System.Windows.Forms.ToolStripButton toolStripButton1;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
private System.Windows.Forms.ToolStripButton cardLocationInputToolStripButton;
private System.Windows.Forms.ToolStripButton incomingFormToolStripButton;
private System.Windows.Forms.ToolStripButton cardInfoToolStripButton;
}
}
using System;
using MoyaAdminUI.MoyaAPI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
......@@ -101,7 +102,7 @@ namespace MoyaAdminUI
void loadImage()
{
Size borderSize = this.Size - this.ClientSize;
this.MapPictureBox.Load(MoyaAPI.RestClient.GetRequestURL(Properties.Settings.Default.ApiURL, "placeadmin/background/" + SelectedMap.Id));
this.MapPictureBox.Load(RestClient.GetRequestURL(Properties.Settings.Default.ApiURL, "placeadmin/background/" + SelectedMap.Id));
MapPictureBox.Size = this.MapPictureBox.Image.Size;
this.MinimumSize = this.MapPictureBox.Image.Size + new Size(0, this.TopPanel.Size.Height + 20) + new Size(this.panel1.MinimumSize.Width + 270, 0) + borderSize;
}
......@@ -1074,5 +1075,17 @@ namespace MoyaAdminUI
frm.Show();
}
private void incomingFormToolStripButton_Click(object sender, EventArgs e)
{
IncomingForm frm = new IncomingForm();
frm.Show();
}
private void cardInfoToolStripButton_Click(object sender, EventArgs e)
{
ShowCardInformation frm = new ShowCardInformation();
frm.Show();
}
}
}
......@@ -155,39 +155,39 @@
<data name="usersToolStripPrintButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAALqSURBVDhPjZJ5SBNQHMenhNoilMIiSiRSKhOvwsxNSWlS
2Up3pLYZJXltTlNDp24eeeWVcy51uSPPeWR55H2LUhkkSkkRRZJRkYRmmqnt25z7x0DwAz94731/3y+8
33uEzTA3Nz9KIpGUjscdB83MzFI1R4bryhZhnSUzsqJvwP+8C4hGhpoiCnTS1qhLCeb8HVFgtTMbHE8n
bDcwkumkrSGPZFxfaU7BSkMsGvm030Qi0UEnbcTCjmxKixJGWZIpJzVbfTdOXKA9nRWQEszwXq6LxlJl
GGp5FMUBK6td647/8Lga6DbwQ42Or39QNPxmhlfZrmaXNkCmilvtS6Iu9sdfgEJwTC2orlbTRKqJ07z4
zIPO7i4a6zZtgAWZbPrw4091/acFVE/9Qtn7OWRVFaJLaYlxyT40JBtjcZCAuX5TxJeJwVC0w6+8G7R8
1Yypla2dNkQyPj0tnfwOyatvyB//guyXn5ExOgXh41aUKLkYkh7CbJUeRpT28MyrAFWkwkVxLfZaO3hq
A4QdY60Zzz4gefgdEgbfIqZ3ErGaiul5jejOCUS2jyHsgQqJGUFwF+TjTFIhSNHp85rPYqQNYBdUpke2
jYHb/AKcplEEPXoK/5oh+Fb1w6eyFz7lPbhc1gV2eRecQvggR97GEapfvda8hntYAtO/uh9XNA0MRRvo
siegl7aAdr8Z3tJG0KRN2jVT3gZXngCnuALssbJl6eyal/C5Zsaq6F5aGxBd1rpuLGnUDoyp7IBXUQMu
Seq193bhxsPGN2TZ2NjYRGcnEJhMpkFmsSIiXKp67iepXaDmV8EztxzUghpw6gcRWjcAlrwF5+7IQQ7l
47CHd4/OugH9iIgIk7w8sWNakVLIE8mHvbJl85QkMSgp98C4WwZKciGcg2Ow/wTpps6zKXoBAQE7c3ML
7FPFpTHcnOK+i0miWbdb6XANT1S7U+k2ur4tocdms3fk5IisMySl4UJRSRqfz9+9LhEI/wDfMn6y94K5
5QAAAABJRU5ErkJggg==
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAALsSURBVDhPjZJ7SNNRHMWnhNoilMIiSiQyKnv4KMx0RkqL
ai5zj8w2oyRfm9PU0Kmbj/KR7znNXHNbTufUYb7yrflIqQwSpaSICsmoKEIxzdR2+jX3j4HgB75w7z3f
c+B+7yWthq2t7T53d3eVy2GXfhsbm1vEkfmyskY4pymsrJhrCDjrAbKFOVFkkVFaG7WpIbw/Q0osdWSD
R3PFejOLMqO0NhRRrKuLTalYrItDfZzvLzKZ7GyUVmLnSLFmRIujd1OoR4mtqScvPsiJyQlMDWH5LtTG
YL4yHDUCqnKHvf2mZcd/nLoc5Nn3Q4/2L79R8vj1d0FFq54rr4O8Kn6pJ9l7rjfBGwrRfr1Io9EzJNqx
E4KEzJ1uXh6EdZ0hwI5CsdZ9mNbrPs6iauInyt9NI0tThE7VbowWb0NdiiXm+kmY7rVGQrkULGUb/NVd
YORrv1vbOzgaQopGJydl499Q/PIrCkY/I/vFJ2QMT0Bc34JSFR8Dsl2Y0phgSOUEWl4F6BItzklrsPWA
M80QIG4facl4+h4pg2+R2P8GsT3jiCMqtvsVYjrGENU2gvD7WiRlBMNLVICTyUVwi0mfIT6LhSGAW1iZ
HtU6An7Tc/AahxH84AkCqgdwUdMLv8oe+Km7caG8E1x1J1xDhaBE3cReur/OYP6HV3giO6CqF5eIBpay
Fcyyh2DKm8G41wRfWQMYskbDmq1oxXGBCMf4Imyxd+AY7cRL+F2x4VR0zf8bELOsZdlY2mAYGFvVjvMl
dfAp1hnu7cFPwEG/0AVLS0sro51EYrPZZpl3lZERMu0z/6LqWXqBBrRcNeiF1eDp+hFW2weOohlnbitA
CRNizynfbqN1BaaRkZFWeXlSl7QSlVggUQz6ZJfNUJOloKbeASu/HNQUYnghsdh+xP260bMqJoGBgRtz
cwudbknlsfycu4/oyZIpzxvpOB6RpPeiMw8Z+9aECZfL3ZCTIzmQUSyPEEtK04RC4eZliUT6C6f7fpnt
CsiDAAAAAElFTkSuQmCC
</value>
</data>
<data name="toolStripButton1.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAMLSURBVDhPdVJtT5JhGPUH9KVaX2r5odYLlm6VaVjrRS0t
JckSzWyKFopBMLOcIBKamcsHgkdALchHK9S0gRlUH3IyWi/TadNYzsIVTBzaWtNenOnJR3GurLPdH+6d
6zr3uc51ByxAa3y8lqSsYg1ltRFGi69C/8Cn0DTaJESDOK/UuNZf9m+QlI2pqbeaK9tbQXY3QeOshfq9
Auc72OCqCAiKtebMfBXTX/4n6JfpZukjJcoHCmEd60DXdxdymopQ8e4iuK1RiC5V45SgzJzAly51Qtsu
rDcg88VO6IYKYBtz4PV4H97+GMU9jxkZVSXYX/UWu8suIy79ktjftgh65jTlXfAeJ0LhTMXNjwSM7hKQ
vUbwGhpxRvsZnIohMGqP4iBHZPO3LYIOLId0IbE6C+nP9yP3VTSEhgvg37YiS/sGGZUehJENWF93CHvZ
fJ+/bRF02iLDFFKL5ThARSDyYSJS1ARyqzzIVA4juWwQG4zpCNRHIJyVvVSAXpWg+jP4+hFwxGmI1qVh
V0sqmHUkTpa5wJb1IYofj60F+7Ajlrt0BAlBiUVEJ87qJsEl3iMuPxvbKDYYDUewSVOEmEtdiODnYk9S
CkJjuUtDpD8Jvecz1504RzxBoc6EiyojTkuUWHctHOE5fLB4BITymk8KrWVYqmp2512lKJ5Ey/JLzLqo
NElrTB0/ewc8mPg+g5Evk7A8ewOB3ID4bDn0pg78zYlKb3ljTxcnzQmU6CxtTpcP56SaD6u3s8dDYs9O
Xa1pnzaau0Canv9qftoHXaNjfE3ocefWaF6/pPKu3dDiAPPY+Ta/gHliGsCyzYeHgiK5QbX3X3XPzN6/
fANcI5PoHvyKzt5RrNjCIk4IrwfJSMtQZ48XjANZE3MCRTea2xw9rtk5q+1Jgop+mfpB/3JG/NSyjTFY
OMGR3OEF7kbdM/uV6nYEhiXPO8grr0+SqRq9d9pewt7jxiPHB8jUrYhIEHnjMuXK/3Grgo/OZ0CDIyxn
xaTLKGaC2M2IynAHhidTK0Pi55L+PxcQ8BvLhvT5bcdOCAAAAABJRU5ErkJggg==
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAMMSURBVDhPdVJdTJJhGPW+bqp1U9OLWkWmbZVpWCtTS0tR
s9QyG4KGoijMUiei+JOZiw8FBH8a5Ccl6rSQDKqLmIxWNp06leU0XOHU+TPXNMuZnfwM58o623vx7jzP
ec9zntdlHUrNC1cFaRTISaNJotFPlVU9mSqUN5qEhFaQUaxxdZb9GwrSRJfXG/WS9lYoupsgt9VCNlKI
dHMEWOUEePlKPft2Od1Z/ieol6nm3OdSlA7lwDhjRteiHclNIpR9yASrNQCBxTJc55Xow7m5m51QtnPq
1WC/PQ7VaDZMM1a8n+/H4LdpNIzpEV9ZBL/KQZwsKUAIM0vgbNsANXOc9DE4LyJRaIvFg08ENI4iKHo1
4GgbkaicRXTZKA7WhuFcNN/kbNsAFViywo7I6gQw3/ghpTMQaepb4D40IkHZh3jJGLwVWuytO4/T4clT
zrYNUGnz1cuIzRfjLOkL/2eRuCojkFI5BrZ0HDElw9inYcKtyhfejKTNAtSqeNWz4FZNIloQh0BVHE60
xIJep8C1Ejsi8voRwA2FR/YZHAtmbR5BSJACPtGBm6olsIgRhNxOwhEyAge1F3FALkJQVhd8uSk4FXUV
XsGszSFSn4Tac+J9G1KJl8hR6ZBZrsENoRR77vnAJ5kLBodAmrjmc0Fl27hQ2uTIuEuSHKGS4ZRYdSHR
5dY0mL/3Do1hYfEnJueW0Pa6DzyxGqFJYlTpzPib4xc/mAi+kR+1JlCkajPY7FNIzZV/3HU0fN4zOHH5
bk37ikbfBXnDmx/Nr/qh0lnnd3tdtnkEcgaEkscWdYsV9EvphjWBQtXThRUAW2gXRt39We61zZ3dP1fv
c18B++QSuoe/oKN3GtsPMYgraffdRYq20Y6eCdD8EhbWBEQVzQZrj311zmpLFK9sIE/2ZGAbLXR56/4g
rB9P//jxda6i7rXlTnU73LxjfjvIKK2PEpXrJh4Z3sHS48Bz60fkyVrhG86fCGGLpf/jdnqG/c6AQnRa
KSOImUfSwwQOWgDT4eYTQ+44HLqW9P85F5dfmuP00hyPtXQAAAAASUVORK5CYII=
</value>
</data>
<data name="cardLocationInputToolStripButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
......@@ -203,6 +203,40 @@
SUVORK5CYII=
</value>
</data>
<data name="incomingFormToolStripButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG
YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9
0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw
bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc
VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9
c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32
Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo
mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+
kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D
TgDQASA1MVpwzwAAAABJRU5ErkJggg==
</value>
</data>
<data name="cardInfoToolStripButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAL0SURBVDhPdVNbSJNhGP7FRt2YiEVelIc55zRPWOYpD6Wm
/jvPTZ2nNJU0zbQyhEAjbNv/OzdbHrLpsrpJugoi6KLWgYSExCijMBCtvBRGsJvB3t73nwojeuGB8b/P
83zv93zvmKAqGtoTzVryYlnTZJzcshKv4P6IEfSbvlGPONvs4EpUcWGxrLk/QcWvZ9TY/blN45B7dgKy
GhyQUTMGSVreL1Fy62LkEHdbFqiYoqF9Yrl5OFln9Raem4LKrlkovzAD8osuqOiagTw0OlZ3G1L0oyBV
cV7ikmZbzjBipcmYrBvxlHbcA3XvnGDAds/C4xef4Pmbz1DYPAaZxtuQZrDjJFZIVHMe0gjiqIpbB6Ua
3l3QMgWavgeg6LkvnF7eOQMT8wsw++Q1ZNeaIb3ajhPYIFEzAlI1Dwkqzk1aRiw3sRnV9i0lCsmA7XZB
cds05DdPClfQ9rpApuFAouIBM4B4hUWATGvdEss5lsHGQE7TuI9GL+t0CqNKVBw0D87D8vdNeOZeBpny
JsRUmgFD3kWSzuqTohbT5y10GoVH41EzptIEJzD998tr8HbxKyQphv4xOFo1inzewsg0/AA+ky8ex9tp
EpnCevnhx/8N9KM+zG6ASVBzbJretiXGewUR8IRXiwGDZNUNwGVCBHqUQZrBtkVa4RUyDDY37gDEYZOC
kqpHIKveAe+W1mBh6RtkVZsEQ5oKF014DTQIvAKVTGM1ZhrHPKkGGxAoyB7uKXxZ3YSV1Z9w2TIP2fVj
cLzOIRhnN97xkEYQU9FW4TWGT7ZMegswTAqUXqX2GqJ/DrSXnFDSPgWlHU4obr3rJW7QJlJF4n6n6+39
uAMbih6Xn3ZCd+UhVF19BHqEpm/Of6p9eiMVOcTdlu1WCELERIjDj+SfL0tRDU7nNVo/lrQ6fp1uc/zO
rx9ZSlFed0bltFYw4dERyKXTQ0m4U/QXJddDiBhGJEoN3R97RnRAZhRFShtCw6Ll6J+JPQniMIJM9jIM
E/IXKNeqRqbswa0AAAAASUVORK5CYII=
</value>
</data>
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
AAABAAYAMDAAAAEACACoDgAAZgAAACAgAAABAAgAqAgAAA4PAAAQEAAAAQAIAGgFAAC2FwAAMDAAAAEA
......
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
......
......@@ -84,6 +84,7 @@ namespace MoyaAdminUI.MoyaAPI
int timestamp = ConvertToTimestamp(DateTime.Now);
string hash = CalculateSHA1("/" + parameters + "+" + Properties.Settings.Default.ApiApplicationKey + "+" + Properties.Settings.Default.ApiUser + "+" + timestamp + "+" + Properties.Settings.Default.ApiPass);
string url = server + "/rest/" + parameters + "?appkey=" + Properties.Settings.Default.ApiApplicationKey + "&appuser=" + Properties.Settings.Default.ApiUser + "&appstamp=" + timestamp + "&appmac=" + hash;
Console.WriteLine(url);
return url;
}
public string MakeRequest(string parameters)
......@@ -122,14 +123,17 @@ namespace MoyaAdminUI.MoyaAPI
}
// grab the response
using (var responseStream = response.GetResponseStream())
{
if (responseStream != null)
using (var reader = new StreamReader(responseStream))
{
responseValue = reader.ReadToEnd();
}
}
//if (response.ContentLength > 0)
//{
using (var responseStream = response.GetResponseStream())
{
if (responseStream != null)
using (var reader = new StreamReader(responseStream))
{
responseValue = reader.ReadToEnd();
}
}
//}
return responseValue;
}
......
......@@ -49,7 +49,10 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="AutoUpdateLib">
<HintPath>..\res\AutoUpdateLib.dll</HintPath>
<HintPath>..\..\..\PrintServer\moyaPrintServer\moyaPrintServer\bin\Debug\AutoUpdateLib.dll</HintPath>
</Reference>
<Reference Include="MoyaAdminLib">
<HintPath>..\MoyaAdminLib\bin\Debug\MoyaAdminLib.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
......@@ -71,12 +74,24 @@
<Compile Include="ApiSettings.Designer.cs">
<DependentUpon>ApiSettings.cs</DependentUpon>
</Compile>
<Compile Include="CardLocationInput.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="CardLocationInput.Designer.cs">
<DependentUpon>CardLocationInput.cs</DependentUpon>
</Compile>
<Compile Include="ComputerPlaceGridSettings.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="ComputerPlaceGridSettings.designer.cs">
<DependentUpon>ComputerPlaceGridSettings.cs</DependentUpon>
</Compile>
<Compile Include="IncomingForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="IncomingForm.Designer.cs">
<DependentUpon>IncomingForm.cs</DependentUpon>
</Compile>
<Compile Include="MainForm.cs">
<SubType>Form</SubType>
</Compile>
......@@ -84,16 +99,27 @@
<DependentUpon>MainForm.cs</DependentUpon>
</Compile>
<Compile Include="Map.cs" />
<Compile Include="MoyaAPI\Card.cs" />
<Compile Include="MoyaAPI\eventuser.cs" />
<Compile Include="MoyaAPI\EventUsers.cs" />
<Compile Include="MoyaAPI\Maps.cs" />
<Compile Include="MoyaAPI\Place.cs" />
<Compile Include="ComputerPlace.cs" />
<Compile Include="MoyaAPI\PlaceMap.cs" />
<Compile Include="MoyaAPI\RestClient.cs" />
<Compile Include="MoyaApi\Maps.cs" />
<Compile Include="MoyaUtils.cs" />
<Compile Include="MoyaApi\Place.cs" />
<Compile Include="MoyaApi\PlaceMap.cs" />
<Compile Include="OrgMealCounter.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="OrgMealCounter.Designer.cs">
<DependentUpon>OrgMealCounter.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="MoyaApi\RestClient.cs" />
<Compile Include="Scanner.cs" />
<Compile Include="ShowCardInformation.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="ShowCardInformation.Designer.cs">
<DependentUpon>ShowCardInformation.cs</DependentUpon>
</Compile>
<Compile Include="User.cs" />
<Compile Include="UserInfoForm.cs">
<SubType>Form</SubType>
......@@ -110,12 +136,21 @@
<EmbeddedResource Include="ApiSettings.resx">
<DependentUpon>ApiSettings.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="CardLocationInput.resx">
<DependentUpon>CardLocationInput.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="ComputerPlaceGridSettings.resx">
<DependentUpon>ComputerPlaceGridSettings.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="IncomingForm.resx">
<DependentUpon>IncomingForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="MainForm.resx">
<DependentUpon>MainForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="OrgMealCounter.resx">
<DependentUpon>OrgMealCounter.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
......@@ -125,6 +160,9 @@
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<EmbeddedResource Include="ShowCardInformation.resx">
<DependentUpon>ShowCardInformation.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UserInfoForm.resx">
<DependentUpon>UserInfoForm.cs</DependentUpon>
</EmbeddedResource>
......
using System;
using MoyaAdminLib;
using MoyaAdminUI.MoyaAPI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Script.Serialization;
namespace MoyaAdminUI.MoyaAPI
namespace MoyaAdminUI
{
public class Card
public class MoyaUtils
{
//{"cardId":3990,"state":"PENDING_VALIDATION","cardTemplate":"pelaaja","username":"Miketzu","wholeName":"Mirco Renko"}
public int cardId;
public string state;
public string cardTemplate;
public string username;
public string wholeName;
public static Card GetByEventUserId(int id)
{
RestClient client = new RestClient(Properties.Settings.Default.ApiURL);
string json = client.MakeRequest("user/card/" + id);
var ser = new JavaScriptSerializer();
return ser.Deserialize<Card>(json);
}
}
}
namespace MoyaAdminUI
{
partial class OrgMealCounter
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.readersComboBox = new System.Windows.Forms.ComboBox();
this.label1 = new System.Windows.Forms.Label();
this.amountsPerDayListView = new System.Windows.Forms.ListView();
this.amountsPerPersonListView = new System.Windows.Forms.ListView();
this.SuspendLayout();
//
// readersComboBox
//
this.readersComboBox.FormattingEnabled = true;
this.readersComboBox.Location = new System.Drawing.Point(13, 28);
this.readersComboBox.Name = "readersComboBox";
this.readersComboBox.Size = new System.Drawing.Size(580, 21);
this.readersComboBox.TabIndex = 0;
this.readersComboBox.SelectedIndexChanged += new System.EventHandler(this.readersComboBox_SelectedIndexChanged);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(13, 13);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(35, 13);
this.label1.TabIndex = 1;
this.label1.Text = "Lukija";
//
// amountsPerDayListView
//
this.amountsPerDayListView.Location = new System.Drawing.Point(13, 56);
this.amountsPerDayListView.Name = "amountsPerDayListView";
this.amountsPerDayListView.Size = new System.Drawing.Size(580, 97);
this.amountsPerDayListView.TabIndex = 2;
this.amountsPerDayListView.UseCompatibleStateImageBehavior = false;
//
// amountsPerPersonListView
//
this.amountsPerPersonListView.Location = new System.Drawing.Point(13, 160);
this.amountsPerPersonListView.Name = "amountsPerPersonListView";
this.amountsPerPersonListView.Size = new System.Drawing.Size(580, 248);
this.amountsPerPersonListView.TabIndex = 3;
this.amountsPerPersonListView.UseCompatibleStateImageBehavior = false;
//
// OrgMealCounter
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(605, 420);
this.Controls.Add(this.amountsPerPersonListView);
this.Controls.Add(this.amountsPerDayListView);
this.Controls.Add(this.label1);
this.Controls.Add(this.readersComboBox);
this.Name = "OrgMealCounter";
this.Text = "OrgMealCounter";
this.Load += new System.EventHandler(this.OrgMealCounter_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.ComboBox readersComboBox;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ListView amountsPerDayListView;
private System.Windows.Forms.ListView amountsPerPersonListView;
}
}
\ No newline at end of file
using CardDisplay.DataClasses;
using HttpUtils;
using System;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Script.Serialization;
using System.Windows.Forms;
using MoyaAdminUI.MoyaAPI;
using MoyaAdminLib;
namespace CardDisplay
namespace MoyaAdminUI
{
public partial class AddCardMetaData : Form
public partial class OrgMealCounter : Form
{
public AddCardMetaData()
public OrgMealCounter()
{
InitializeComponent();
}
string statePrinted = "PRINTED";
string apiUrl = "";
string readerApiUrl = "http://vectorama.moya.fi/MoyaWeb/rest/reader/List";
bool active = false;
int slot1ReaderEventId = 0;
int bookNumber = 0;
int slotNumber = 0;
int pageNumber = 0;
DateTime started = DateTime.MinValue;
private void button1_Click(object sender, EventArgs e)
{
active = !active;
BooksNumberNumericUpDown.Enabled = !active;
NumberOfCardSlotsnumericUpDown.Enabled = !active;
SlotsNumberNumericUpDown.Enabled = !active;
PageNumberNumericUpDown.Enabled = !active;
prefixTextBox.Enabled = !active;
bookNumber = (int) BooksNumberNumericUpDown.Value;
slotNumber = (int) SlotsNumberNumericUpDown.Value;
pageNumber = (int) PageNumberNumericUpDown.Value;
if (active)
startButton.Text = "Keskeytä";
else
startButton.Text = "Aloita";
timer1.Enabled = true;
started = DateTime.Now;
}
private void AddCardMetaData_Load(object sender, EventArgs e)
private void OrgMealCounter_Load(object sender, EventArgs e)
{
string ret = "";
RestClient client = new RestClient(Properties.Settings.Default.ApiURL);
try
{
ret = client.MakeRequest("reader/List");
var ser = new JavaScriptSerializer();
ReaderList readers = ser.Deserialize<ReaderList>(ret);
readersComboBox1.Items.Clear();
readersComboBox.Items.Clear();
foreach (Reader reader in readers.readers)
{
readersComboBox1.Items.Add(reader);
readersComboBox.Items.Add(reader);
}
}
catch (Exception ex)
{
ret = ex.Message;
}
}
string ret = "";
private void timer1_Tick(object sender, EventArgs e)
private void readersComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
if (readersComboBox1.SelectedItem != null)
if (readersComboBox.SelectedItem != null && readersComboBox.SelectedItem is Reader)
{
Reader reader = (Reader)readersComboBox1.SelectedItem;
string ret = "";
Reader reader = (Reader) readersComboBox.SelectedItem;
RestClient client = new RestClient(Properties.Settings.Default.ApiURL);
Dictionary<DateTime, int> amountsPerDay = new Dictionary<DateTime, int>();
int totalAmount = 0;
try
{
ret = client.MakeRequest("reader/readerevents/" + reader.readerId + "/" + slot1ReaderEventId);
ret = client.MakeRequest("reader/readerevents/" + reader.readerId + "/0");
var ser = new JavaScriptSerializer();
ReaderEventList events = ser.Deserialize<ReaderEventList>(ret);
events.readerEvents = events.readerEvents.OrderBy(r => r.readerEventTime).ToList();
foreach (ReaderEvent re in events.readerEvents)
if (events != null && events.readerEvents != null)
{
if (re.printedCardId != 0 && re.printedCardState == statePrinted && re.readerEventTime >= started)
foreach (ReaderEvent re in events.readerEvents)
{
client = new RestClient(Properties.Settings.Default.ApiURL);
ret = client.MakeRequest("card/Get/" + re.printedCardId);
Card card = ser.Deserialize<Card>(ret);
slot1ReaderEventId = re.readerEventId;
string key = "cardplace";
string value = "";
if (prefixTextBox.Text != "")
value = prefixTextBox.Text + ".";
value += bookNumber.ToString() + "." + pageNumber.ToString() + "." + slotNumber.ToString();
MetaData data = new MetaData();
data.key = key;
data.value = value;
if ((slotNumber + 1) >= SlotsNumberNumericUpDown.Value)
{
slotNumber = 1;
pageNumber++;
}
DateTime date = re.readerEventTime.Date;
if (amountsPerDay.Keys.Contains(date))
amountsPerDay[date] += 1;
else
slotNumber++;
lastAddedTextBox.Text = key + ":" + value;
string json = "{\"" + data.key + "\":\"" + data.value + "\"}";
HttpUtils.RestClient client2 = new HttpUtils.RestClient(Properties.Settings.Default.ApiURL, HttpVerb.POST, json);
client2.MakeRequest("meta/v1/printedcard/" + card.cardId + "/card-filing");
amountsPerDay.Add(date, 1);
totalAmount++;
}
foreach (DateTime date in amountsPerDay.Keys)
{
amountsPerDayListView.Columns.Add(new ColumnHeader(date.ToShortDateString()));
}
amountsPerDayListView.Columns.Add(new ColumnHeader("Yhteensä"));
ListViewItem lvi = new ListViewItem();
foreach (DateTime date in amountsPerDay.Keys)
{
lvi.SubItems.Add(amountsPerDay[date].ToString());
}
lvi.SubItems.Add(totalAmount.ToString());
}
}
catch (Exception ex)
{
}
}
}
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.18408
// Runtime Version:4.0.30319.18449
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
......@@ -82,5 +82,17 @@ namespace MoyaAdminUI.Properties {
this["ApplicationVersion"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string Port {
get {
return ((string)(this["Port"]));
}
set {
this["Port"] = value;
}
}
}
}
......@@ -17,5 +17,8 @@
<Setting Name="ApplicationVersion" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="Port" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
</Settings>
</SettingsFile>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO.Ports;
namespace BarcodeScannerClient
{
public class BarCodeScanner
{
private SerialPort serialport = new SerialPort();
private string port = "COM1";
public string Port
{
get
{
return this.port;
}
set
{
this.port = value;
}
}
public BarCodeScanner()
{
this.serialport.DataReceived += new SerialDataReceivedEventHandler(serialport_DataReceived);
}
public void Listen(string port)
{
this.port = port;
Listen();
}
public void Listen()
{
try
{
if (this.serialport.IsOpen)
this.serialport.Close();
this.serialport.PortName = this.port;
this.serialport.Open();
buffertimer.Elapsed += new System.Timers.ElapsedEventHandler(buffertimer_Elapsed);
}
catch
{
System.Windows.Forms.MessageBox.Show("Cannot open barcode scanner on port" + this.serialport);
}
}
void buffertimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
buffertimer.Enabled = false;
Console.WriteLine(this.buffer);
// If input is not regular card flush it!
/*
if (!buffer.StartsWith("C") && !buffer.StartsWith("R")) buffer = "";
// if input is ready send it
if (buffer.EndsWith("E") || buffer.EndsWith("E\r"))
{
// Trim white space away
if (buffer.EndsWith("E\r"))
buffer = buffer.Trim();
onBarcodeReceived(buffer);
buffer = "";
}
*/
onBarcodeReceived(buffer.Trim());
buffer = "";
}
public void Close()
{
try
{
this.serialport.Close();
}
catch (Exception e)
{
}
}
public enum BarcodeType { Card, Receipt };
private string buffer;
System.Timers.Timer buffertimer = new System.Timers.Timer(500);
void serialport_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
// Add new data to buffer
this.buffer += serialport.ReadExisting();
buffertimer.Start();
}
private void onBarcodeReceived(string text)
{
if (BarcodeReceived == null) return;
text = text.TrimStart(new char[] { '0' });
BarcodeReceived(text);
//int data = 0 ;
/*
try
{
data = Convert.ToInt32(text.Substring(1, text.Length - 2));
}
catch
{
Console.WriteLine("Error in barcode parser! :" + text + ":");
}
if (text.StartsWith("C"))
{
BarcodeReceived(data, BarcodeType.Card);
}
else if (text.StartsWith("R"))
{
BarcodeReceived(data, BarcodeType.Receipt);
}
else
{
System.Windows.Forms.MessageBox.Show("Unknown barcode!");
}
*/
}
//public delegate void Barcode (int data, BarcodeType type);
public delegate void Barcode(string data);
public event Barcode BarcodeReceived;
public static int CalculateEanChecksum(string code)
{
if (code == null || code.Length != 12)
throw new ArgumentException("Code length should be 12, i.e. excluding the checksum digit");
int sum = 0;
for (int i = 0; i < 12; i++)
{
int v;
if (!int.TryParse(code[i].ToString(), out v))
throw new ArgumentException("Invalid character encountered in specified code.");
sum += (i % 2 == 0 ? v : v * 3);
}
int check = 10 - (sum % 10);
return check % 10;
}
private bool CheckEanCode(string code)
{
if (code == null || code.Length != 13)
return false;
int res;
foreach (char c in code)
if (!int.TryParse(c.ToString(), out res))
return false;
char check = (char)('0' + CalculateEanChecksum(code.Substring(0, 12)));
return code[12] == check;
}
}
}
using MoyaAdminLib;
using MoyaAdminUI.MoyaAPI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Script.Serialization;
using System.Windows.Forms;
namespace MoyaAdminUI
{
public partial class ShowCardInformation : Form
{
public static string CARD_PREFIX = "277";
public static string TICKET_PREFIX = "279";
public static string CARD_PLACE = "cardplace";
public ShowCardInformation()
{
InitializeComponent();
}
private void barcodeTimer_Tick(object sender, EventArgs e)
{
barcodeTimer.Stop();
int id = 0;
string ret = "";
RestClient client = new RestClient(Properties.Settings.Default.ApiURL);
if (parseCardId(barcodeTextBox.Text, out id))
ret = client.MakeRequest("card/Get/" + id);
else if (parseEventUserId(barcodeTextBox.Text, out id))
ret = client.MakeRequest("user/card/" + id);
var ser = new JavaScriptSerializer();
Card card = ser.Deserialize<Card>(ret);
if (card != null)
{
nameTextBox.Text = card.wholeName;
nickTextBox.Text = card.username;
cardTemplateTextBox.Text = card.cardTemplate;
cardStateTextBox.Text = card.state;
pictureBox1.ImageLocation = RestClient.GetRequestURL(Properties.Settings.Default.ApiURL, "card/GetImage/" + card.cardId);
if (card.state == Card.CARD_STATE_PRINTED)
{
ret = "";
client = new RestClient(Properties.Settings.Default.ApiURL);
try
{
ret = client.MakeRequest("meta/v1/printedcard/" + card.cardId + "/card-filing");
}
catch (ApplicationException ex)
{
if (!ex.Message.Contains("HTTP NoContent"))
return;
}
if (ret != null && ret != "")
{
MetaData data = getValue(ret);
int bookNumber = 0;
int pageNumber = 0;
int slotNumber = 0;
getCardPlace(data, out bookNumber, out pageNumber, out slotNumber);
if (bookNumber > 0)
bookNumericUpDown.Value = bookNumber;
if (pageNumber > 0)
pageNumericUpDown.Value = pageNumber;
if (slotNumber > 0)
slotNumericUpDown.Value = slotNumber;
}
}
}
barcodeTextBox.Text = "";
}
public void getCardPlace(MetaData data, out int bookNumber, out int pageNumber, out int slotNumber)
{
bookNumber = 0;
pageNumber = 0;
slotNumber = 0;
if (data != null)
{
if (data.key == CARD_PLACE)
{
if (data.value != null && data.value != "")
{
string[] fields = data.value.Split(new string[] { "." }, StringSplitOptions.None);
if (fields.Length > 2)
{
if (fields.Length == 3)
{
int.TryParse(fields[0], out bookNumber);
int.TryParse(fields[1], out pageNumber);
int.TryParse(fields[2], out slotNumber);
}
}
}
}
}
}
private MetaData getValue(string ret)
{
MetaData data = null;
if (ret != null && ret != "")
{
ret = ret.Trim();
if (ret.StartsWith("{") && ret.EndsWith("}"))
{
ret = ret.Replace("{", "");
ret = ret.Replace("}", "");
if (ret.Contains(":"))
{
data = new MetaData();
string[] fields = ret.Split(new string[] { ":" }, StringSplitOptions.RemoveEmptyEntries);
if (fields.Length == 2)
{
if (fields[0].StartsWith("\""))
fields[0] = fields[0].Substring(1, fields[0].Length -1);
if (fields[0].EndsWith("\""))
fields[0] = fields[0].Substring(0, fields[0].Length - 1);
data.key = fields[0];
if (fields[1].StartsWith("\""))
fields[1] = fields[1].Substring(1, fields[1].Length - 1);
if (fields[1].EndsWith("\""))
fields[1] = fields[1].Substring(0, fields[1].Length - 1);
data.value = fields[1];
}
}
}
}
return data;
}
private bool parseCardId(string data, out int id)
{
id = 0;
if (data.Length == 13 && data.Substring(0, 3) == CARD_PREFIX)
{
int.TryParse(data.Substring(3, 9), out id);
if (id > 0)
return true;
}
return false;
}
private bool parseEventUserId(string data, out int id)
{
id = 0;
if (data.Length == 13 && data.Substring(0, 3) == TICKET_PREFIX)
{
int.TryParse(data.Substring(3, 9), out id);
if (id > 0)
return true;
}
return false;
}
private void barcodeTextBox_TextChanged(object sender, EventArgs e)
{
if (barcodeTextBox.Text != "")
barcodeTimer.Start();
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="barcodeTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>
\ No newline at end of file
using MoyaAdminUI.MoyaAPI;
using MoyaAdminLib;
using MoyaAdminUI.MoyaAPI;
using System;
using System.Collections.Generic;
using System.Linq;
......@@ -61,15 +62,18 @@ namespace MoyaAdminUI
public static void LoadAll()
{
User.Cache.Clear();
RestClient client = new RestClient(Properties.Settings.Default.ApiURL);
string json = client.MakeRequest("user/eventusers");
var ser = new JavaScriptSerializer();
EventUsers users = ser.Deserialize<EventUsers>(json);
User.Cache.Clear();
RestClient client = new RestClient(Properties.Settings.Default.ApiURL);
string json = client.MakeRequest("user/eventusers");
var ser = new JavaScriptSerializer();
EventUsers users = ser.Deserialize<EventUsers>(json);
if (users != null)
{
foreach (Eventuser u in users.eventusers)
{
User.Cache.Add(new User(u));
}
}
}
}
......
using System;
using MoyaAdminLib;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
......@@ -21,7 +22,7 @@ namespace MoyaAdminUI
set
{
propertyGrid1.SelectedObject = value;
MoyaAdminUI.MoyaAPI.Card card = MoyaAdminUI.MoyaAPI.Card.GetByEventUserId(value.EventUserId);
Card card = MoyaUtils.GetByEventUserId(value.EventUserId);
try
{
cardPictureBox.Load(Properties.Settings.Default.ApiURL + "/dydata/usercard/" + card.cardId + ".png?pfdrid_c=true");
......

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Express 2012 for Windows Desktop
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OrgMealCounter", "OrgMealCounter\OrgMealCounter.csproj", "{A1C035B7-FC96-4D40-A595-E98A60525C80}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MoyaAdminLib", "..\MoyaAdmin\MoyaAdminUI\MoyaAdminLib\MoyaAdminLib.csproj", "{095CE28F-5B53-4203-85C6-3A9AFD486407}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A1C035B7-FC96-4D40-A595-E98A60525C80}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A1C035B7-FC96-4D40-A595-E98A60525C80}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A1C035B7-FC96-4D40-A595-E98A60525C80}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A1C035B7-FC96-4D40-A595-E98A60525C80}.Release|Any CPU.Build.0 = Release|Any CPU
{095CE28F-5B53-4203-85C6-3A9AFD486407}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{095CE28F-5B53-4203-85C6-3A9AFD486407}.Debug|Any CPU.Build.0 = Debug|Any CPU
{095CE28F-5B53-4203-85C6-3A9AFD486407}.Release|Any CPU.ActiveCfg = Release|Any CPU
{095CE28F-5B53-4203-85C6-3A9AFD486407}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
No preview for this file type
namespace OrgMealCounter
{
partial class ApiSettings
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.label4 = new System.Windows.Forms.Label();
this.ApiPassTextBox = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.ApiUserTextBox = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.ApiKeyTextBox = new System.Windows.Forms.TextBox();
this.SaveButton = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.apiURLTextBox = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(12, 148);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(48, 13);
this.label4.TabIndex = 17;
this.label4.Text = "Api Pass";
//
// ApiPassTextBox
//
this.ApiPassTextBox.Location = new System.Drawing.Point(12, 164);
this.ApiPassTextBox.Name = "ApiPassTextBox";
this.ApiPassTextBox.PasswordChar = 'ῷ';
this.ApiPassTextBox.Size = new System.Drawing.Size(260, 20);
this.ApiPassTextBox.TabIndex = 16;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(12, 109);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(47, 13);
this.label3.TabIndex = 15;
this.label3.Text = "Api User";
//
// ApiUserTextBox
//
this.ApiUserTextBox.Location = new System.Drawing.Point(12, 125);
this.ApiUserTextBox.Name = "ApiUserTextBox";
this.ApiUserTextBox.Size = new System.Drawing.Size(260, 20);
this.ApiUserTextBox.TabIndex = 14;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(12, 70);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(79, 13);
this.label2.TabIndex = 13;
this.label2.Text = "Application key";
//
// ApiKeyTextBox
//
this.ApiKeyTextBox.Location = new System.Drawing.Point(12, 86);
this.ApiKeyTextBox.Name = "ApiKeyTextBox";
this.ApiKeyTextBox.Size = new System.Drawing.Size(260, 20);
this.ApiKeyTextBox.TabIndex = 12;
//
// SaveButton
//
this.SaveButton.Location = new System.Drawing.Point(197, 210);
this.SaveButton.Name = "SaveButton";
this.SaveButton.Size = new System.Drawing.Size(75, 23);
this.SaveButton.TabIndex = 11;
this.SaveButton.Text = "Save";
this.SaveButton.UseVisualStyleBackColor = true;
this.SaveButton.Click += new System.EventHandler(this.SaveButton_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 27);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(47, 13);
this.label1.TabIndex = 10;
this.label1.Text = "Moya url";
//
// apiURLTextBox
//
this.apiURLTextBox.Location = new System.Drawing.Point(12, 43);
this.apiURLTextBox.Name = "apiURLTextBox";
this.apiURLTextBox.Size = new System.Drawing.Size(260, 20);
this.apiURLTextBox.TabIndex = 9;
//
// ApiSettings
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(284, 261);
this.Controls.Add(this.label4);
this.Controls.Add(this.ApiPassTextBox);
this.Controls.Add(this.label3);
this.Controls.Add(this.ApiUserTextBox);
this.Controls.Add(this.label2);
this.Controls.Add(this.ApiKeyTextBox);
this.Controls.Add(this.SaveButton);
this.Controls.Add(this.label1);
this.Controls.Add(this.apiURLTextBox);
this.Name = "ApiSettings";
this.Text = "ApiSettings";
this.Load += new System.EventHandler(this.ApiSettings_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox ApiPassTextBox;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox ApiUserTextBox;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox ApiKeyTextBox;
private System.Windows.Forms.Button SaveButton;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox apiURLTextBox;
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace OrgMealCounter
{
public partial class ApiSettings : Form
{
public ApiSettings()
{
InitializeComponent();
}
private void SaveButton_Click(object sender, EventArgs e)
{
Properties.Settings.Default.ApiURL = apiURLTextBox.Text;
Properties.Settings.Default.ApiKey = ApiKeyTextBox.Text;
Properties.Settings.Default.ApiUser = ApiUserTextBox.Text;
Properties.Settings.Default.ApiPass = ApiPassTextBox.Text;
Properties.Settings.Default.Save();
this.DialogResult = System.Windows.Forms.DialogResult.OK;
}
private void ApiSettings_Load(object sender, EventArgs e)
{
apiURLTextBox.Text = Properties.Settings.Default.ApiURL;
ApiKeyTextBox.Text = Properties.Settings.Default.ApiKey;
ApiUserTextBox.Text = Properties.Settings.Default.ApiUser;
ApiPassTextBox.Text = Properties.Settings.Default.ApiPass;
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="OrgMealCounter.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<userSettings>
<OrgMealCounter.Properties.Settings>
<setting name="ApiURL" serializeAs="String">
<value />
</setting>
<setting name="ApiUser" serializeAs="String">
<value />
</setting>
<setting name="ApiPass" serializeAs="String">
<value />
</setting>
<setting name="ApiKey" serializeAs="String">
<value />
</setting>
</OrgMealCounter.Properties.Settings>
</userSettings>
</configuration>
\ No newline at end of file
namespace OrgMealCounter
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.barcodeTextBox = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
this.messageToolStripStatusLabel = new System.Windows.Forms.ToolStripStatusLabel();
this.nameTextBox = new System.Windows.Forms.TextBox();
this.nickTextBox = new System.Windows.Forms.TextBox();
this.barcodeTimer = new System.Windows.Forms.Timer(this.components);
this.timer = new System.Windows.Forms.Timer(this.components);
this.toolStrip1 = new System.Windows.Forms.ToolStrip();
this.apiSettingsToolStripButton = new System.Windows.Forms.ToolStripButton();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.statusStrip1.SuspendLayout();
this.toolStrip1.SuspendLayout();
this.SuspendLayout();
//
// barcodeTextBox
//
this.barcodeTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.barcodeTextBox.Location = new System.Drawing.Point(13, 41);
this.barcodeTextBox.Name = "barcodeTextBox";
this.barcodeTextBox.Size = new System.Drawing.Size(531, 20);
this.barcodeTextBox.TabIndex = 0;
this.barcodeTextBox.TextChanged += new System.EventHandler(this.barcodeTextBox_TextChanged);
this.barcodeTextBox.Leave += new System.EventHandler(this.barcodeTextBox_Leave);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 25);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(56, 13);
this.label1.TabIndex = 1;
this.label1.Text = "Viivakoodi";
//
// pictureBox1
//
this.pictureBox1.Location = new System.Drawing.Point(15, 68);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(254, 438);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pictureBox1.TabIndex = 2;
this.pictureBox1.TabStop = false;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(275, 71);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(27, 13);
this.label2.TabIndex = 3;
this.label2.Text = "Nimi";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(275, 97);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(29, 13);
this.label3.TabIndex = 4;
this.label3.Text = "Nick";
//
// statusStrip1
//
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.messageToolStripStatusLabel});
this.statusStrip1.Location = new System.Drawing.Point(0, 515);
this.statusStrip1.Name = "statusStrip1";
this.statusStrip1.Size = new System.Drawing.Size(556, 22);
this.statusStrip1.TabIndex = 5;
this.statusStrip1.Text = "statusStrip1";
//
// messageToolStripStatusLabel
//
this.messageToolStripStatusLabel.Name = "messageToolStripStatusLabel";
this.messageToolStripStatusLabel.Size = new System.Drawing.Size(39, 17);
this.messageToolStripStatusLabel.Text = "Status";
//
// nameTextBox
//
this.nameTextBox.Location = new System.Drawing.Point(308, 68);
this.nameTextBox.Name = "nameTextBox";
this.nameTextBox.ReadOnly = true;
this.nameTextBox.Size = new System.Drawing.Size(236, 20);
this.nameTextBox.TabIndex = 6;
//
// nickTextBox
//
this.nickTextBox.Location = new System.Drawing.Point(308, 94);
this.nickTextBox.Name = "nickTextBox";
this.nickTextBox.ReadOnly = true;
this.nickTextBox.Size = new System.Drawing.Size(236, 20);
this.nickTextBox.TabIndex = 7;
//
// barcodeTimer
//
this.barcodeTimer.Interval = 500;
this.barcodeTimer.Tick += new System.EventHandler(this.barcodeTimer_Tick);
//
// timer
//
this.timer.Interval = 6000;
this.timer.Tick += new System.EventHandler(this.timer_Tick);
//
// toolStrip1
//
this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.apiSettingsToolStripButton});
this.toolStrip1.Location = new System.Drawing.Point(0, 0);
this.toolStrip1.Name = "toolStrip1";
this.toolStrip1.Size = new System.Drawing.Size(556, 25);
this.toolStrip1.TabIndex = 8;
this.toolStrip1.Text = "toolStrip1";
//
// apiSettingsToolStripButton
//
this.apiSettingsToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.apiSettingsToolStripButton.Image = ((System.Drawing.Image)(resources.GetObject("apiSettingsToolStripButton.Image")));
this.apiSettingsToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta;
this.apiSettingsToolStripButton.Name = "apiSettingsToolStripButton";
this.apiSettingsToolStripButton.Size = new System.Drawing.Size(23, 22);
this.apiSettingsToolStripButton.Text = "Apiasetukset";
this.apiSettingsToolStripButton.Click += new System.EventHandler(this.apiSettingsToolStripButton_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(556, 537);
this.Controls.Add(this.toolStrip1);
this.Controls.Add(this.nickTextBox);
this.Controls.Add(this.nameTextBox);
this.Controls.Add(this.statusStrip1);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.label1);
this.Controls.Add(this.barcodeTextBox);
this.Name = "Form1";
this.Text = "Org ruokailu";
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.statusStrip1.ResumeLayout(false);
this.statusStrip1.PerformLayout();
this.toolStrip1.ResumeLayout(false);
this.toolStrip1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox barcodeTextBox;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.StatusStrip statusStrip1;
private System.Windows.Forms.ToolStripStatusLabel messageToolStripStatusLabel;
private System.Windows.Forms.TextBox nameTextBox;
private System.Windows.Forms.TextBox nickTextBox;
private System.Windows.Forms.Timer barcodeTimer;
private System.Windows.Forms.Timer timer;
private System.Windows.Forms.ToolStrip toolStrip1;
private System.Windows.Forms.ToolStripButton apiSettingsToolStripButton;
}
}
using MoyaAdminLib;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Script.Serialization;
using System.Windows.Forms;
namespace OrgMealCounter
{
public partial class Form1 : Form
{
private static string reader = "orgruokailu";
private string readerProperties = "shop/rfidListener.jsf?reader=" + reader +"&tag=%";
public Form1()
{
InitializeComponent();
}
private void barcodeTextBox_Leave(object sender, EventArgs e)
{
barcodeTextBox.Focus();
}
private void barcodeTextBox_TextChanged(object sender, EventArgs e)
{
timer.Start();
if (barcodeTextBox.Text != "")
barcodeTimer.Start();
}
private void barcodeTimer_Tick(object sender, EventArgs e)
{
barcodeTimer.Stop();
int id = 0;
string ret = "";
RestClient client = new RestClient(Properties.Settings.Default.ApiURL);
if (Card.ParseCardId(barcodeTextBox.Text, out id))
ret = client.MakeRequest("card/Get/" + id, true);
var ser = new JavaScriptSerializer();
Card card = ser.Deserialize<Card>(ret);
if (card != null)
{
nameTextBox.Text = card.wholeName;
nickTextBox.Text = card.username;
pictureBox1.ImageLocation = RestClient.GetRequestURL(Properties.Settings.Default.ApiURL, "card/GetImage/" + card.cardId);
string url = (Properties.Settings.Default.ApiURL + readerProperties).Replace("%", barcodeTextBox.Text);
client = new RestClient(url);
try
{
ret = client.MakeRequest("", false);
}
catch (Exception ex)
{
messageToolStripStatusLabel.Text = ex.Message;
}
messageToolStripStatusLabel.Text = "Yksi ruokailu merkitty henkilölle " + card.wholeName + "!";
}
barcodeTextBox.Text = "";
}
private void timer_Tick(object sender, EventArgs e)
{
timer.Stop();
pictureBox1.ImageLocation = null;
nameTextBox.Text = "";
nickTextBox.Text = "";
}
private void apiSettingsToolStripButton_Click(object sender, EventArgs e)
{
ApiSettings frm = new ApiSettings();
frm.ShowDialog();
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="barcodeTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>133, 17</value>
</metadata>
<metadata name="timer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>260, 17</value>
</metadata>
<metadata name="toolStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>340, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="apiSettingsToolStripButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACWSURBVDhPrZCLDcAgCAWd1hVcwRVcwRVcwRWcxeYRSCjV
hn4uIWkFTiT8Tu99jjEo+OgZKaXZWiOByDi1xxZZCR/vQZEtLKXQ2Sp3AbfZQt1ca70XYGTdYAMXcOke
jKwnseFapkgwst2BWyJA8FkCVhIEp33gSdKIJ8quOO1DGvmXJuNPPxDIDrTsETnniYgxvhOcCeEASkcG
PKycdQEAAAAASUVORK5CYII=
</value>
</data>
</root>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{A1C035B7-FC96-4D40-A595-E98A60525C80}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OrgMealCounter</RootNamespace>
<AssemblyName>OrgMealCounter</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="MoyaAdminLib">
<HintPath>..\..\MoyaAdmin\MoyaAdminUI\MoyaAdminLib\bin\Debug\MoyaAdminLib.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ApiSettings.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="ApiSettings.Designer.cs">
<DependentUpon>ApiSettings.cs</DependentUpon>
</Compile>
<Compile Include="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RestClient.cs" />
<EmbeddedResource Include="ApiSettings.resx">
<DependentUpon>ApiSettings.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- 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.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace OrgMealCounter
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("OrgMealCounter")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OrgMealCounter")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("3105692d-2bb9-4413-ac0e-36fca7db758f")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.18449
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace OrgMealCounter.Properties
{
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("OrgMealCounter.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.18449
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace OrgMealCounter.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string ApiURL {
get {
return ((string)(this["ApiURL"]));
}
set {
this["ApiURL"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string ApiUser {
get {
return ((string)(this["ApiUser"]));
}
set {
this["ApiUser"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string ApiPass {
get {
return ((string)(this["ApiPass"]));
}
set {
this["ApiPass"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string ApiKey {
get {
return ((string)(this["ApiKey"]));
}
set {
this["ApiKey"] = value;
}
}
}
}
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="OrgMealCounter.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="ApiURL" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="ApiUser" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="ApiPass" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="ApiKey" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
</Settings>
</SettingsFile>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
namespace OrgMealCounter
{
public enum HttpVerb
{
GET,
POST,
PUT,
DELETE
}
public class RestClient
{
public string EndPoint { get; set; }
public HttpVerb Method { get; set; }
public string ContentType { get; set; }
public string PostData { get; set; }
public RestClient()
{
EndPoint = "";
Method = HttpVerb.GET;
ContentType = "application/json";
PostData = "";
}
public RestClient(string endpoint)
{
EndPoint = endpoint;
Method = HttpVerb.GET;
ContentType = "application/json";
PostData = "";
}
public RestClient(string endpoint, HttpVerb method)
{
EndPoint = endpoint;
Method = method;
ContentType = "application/json";
PostData = "";
}
public RestClient(string endpoint, HttpVerb method, string postData)
{
EndPoint = endpoint;
Method = method;
ContentType = "application/json";
PostData = postData;
}
public static string CalculateSHA1(string text)
{
// Convert the input string to a byte array
byte[] buffer = Encoding.GetEncoding("iso-8859-1").GetBytes(text);
// In doing your test, you won't want to re-initialize like this every time you test a
// string.
SHA1CryptoServiceProvider cryptoTransformSHA1 =
new SHA1CryptoServiceProvider();
// The replace won't be necessary for your tests so long as you are consistent in what
// you compare.
string hash = BitConverter.ToString(cryptoTransformSHA1.ComputeHash(buffer)).Replace("-", "").ToLower();
return hash;
}
private static int ConvertToTimestamp(DateTime value)
{
//create Timespan by subtracting the value provided from
//the Unix Epoch
TimeSpan span = (value - new DateTime(1970, 1, 1, 0, 0, 0, 0).ToLocalTime());
//return the total seconds (which is a UNIX timestamp)
return (int)span.TotalSeconds;
}
public static string GetRequestURL(string server, string parameters)
{
int timestamp = ConvertToTimestamp(DateTime.Now);
string hash = CalculateSHA1("/" + parameters + "+" + Properties.Settings.Default.ApiKey + "+" + Properties.Settings.Default.ApiUser + "+" + timestamp + "+" + Properties.Settings.Default.ApiPass);
string url = server + "/rest/" + parameters + "?appkey=" + Properties.Settings.Default.ApiKey + "&appuser=" + Properties.Settings.Default.ApiUser + "&appstamp=" + timestamp + "&appmac=" + hash;
Console.WriteLine(url);
return url;
}
public string MakeRequest(string parameters, bool useAuth)
{
///placeadmin/places/30+abcdefg+testuser-asdf+1393735570144+acdcabbacd
///
string url = "";
if (useAuth)
url = GetRequestURL(EndPoint, parameters);
else
url = EndPoint + parameters;
var request = (HttpWebRequest)WebRequest.Create(url);
request.Method = Method.ToString();
request.ContentLength = 0;
request.ContentType = ContentType;
if (!string.IsNullOrEmpty(PostData) && (Method == HttpVerb.POST || Method == HttpVerb.PUT))
{
var encoding = new UTF8Encoding();
var bytes = Encoding.GetEncoding("iso-8859-1").GetBytes(PostData);
request.ContentLength = bytes.Length;
using (var writeStream = request.GetRequestStream())
{
writeStream.Write(bytes, 0, bytes.Length);
}
}
using (var response = (HttpWebResponse)request.GetResponse())
{
var responseValue = string.Empty;
if (response.StatusCode != HttpStatusCode.OK)
{
var message = String.Format("Request failed. Received HTTP {0}", response.StatusCode);
throw new ApplicationException(message);
}
// grab the response
//if (response.ContentLength > 0)
//{
using (var responseStream = response.GetResponseStream())
{
if (responseStream != null)
using (var reader = new StreamReader(responseStream))
{
responseValue = reader.ReadToEnd();
}
}
//}
return responseValue;
}
}
} // class
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!