Commit af057217 by Tapio Haapala

print serveriin auth tuki ja sortti

1 parent ab11d17f
......@@ -45,6 +45,7 @@
this.printTimer = new System.Windows.Forms.Timer(this.components);
this.toolStrip1 = new System.Windows.Forms.ToolStrip();
this.settingsToolStripButton = new System.Windows.Forms.ToolStripButton();
this.sortByNameCheckBox = new System.Windows.Forms.CheckBox();
this.statusStrip1.SuspendLayout();
this.toolStrip1.SuspendLayout();
this.SuspendLayout();
......@@ -77,6 +78,7 @@
this.listView.TabIndex = 5;
this.listView.UseCompatibleStateImageBehavior = false;
this.listView.View = System.Windows.Forms.View.Details;
this.listView.DoubleClick += new System.EventHandler(this.listView_DoubleClick);
//
// columnHeader1
//
......@@ -185,11 +187,22 @@
this.settingsToolStripButton.Text = "Api Settings";
this.settingsToolStripButton.Click += new System.EventHandler(this.settingsToolStripButton_Click);
//
// sortByNameCheckBox
//
this.sortByNameCheckBox.AutoSize = true;
this.sortByNameCheckBox.Location = new System.Drawing.Point(88, 268);
this.sortByNameCheckBox.Name = "sortByNameCheckBox";
this.sortByNameCheckBox.Size = new System.Drawing.Size(88, 17);
this.sortByNameCheckBox.TabIndex = 14;
this.sortByNameCheckBox.Text = "Sort by name";
this.sortByNameCheckBox.UseVisualStyleBackColor = true;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(406, 322);
this.Controls.Add(this.sortByNameCheckBox);
this.Controls.Add(this.toolStrip1);
this.Controls.Add(this.refreshButton);
this.Controls.Add(this.label4);
......@@ -230,6 +243,7 @@
private System.Windows.Forms.ColumnHeader columnHeader3;
private System.Windows.Forms.ToolStrip toolStrip1;
private System.Windows.Forms.ToolStripButton settingsToolStripButton;
private System.Windows.Forms.CheckBox sortByNameCheckBox;
}
}
......@@ -31,13 +31,12 @@ namespace moyaPrintServer
}
autoPrintCheckBox.Checked = Properties.Settings.Default.AutoPrint;
PrintersComboBox.SelectedItem = Properties.Settings.Default.Printer;
<<<<<<< HEAD
/*
apiKeyTextBox.Text = Properties.Settings.Default.ApiKey;
apiUrlTextBox.Text = Properties.Settings.Default.ApiURL;
if (apiUrlTextBox.Text == "")
apiUrlTextBox.Text = "https://event.domain.ltd/MoyaWeb/rest";
=======
>>>>>>> b730dd7f982f556ecbc4adf437995c3832096919
*/
}
......@@ -67,20 +66,40 @@ namespace moyaPrintServer
{
autoPrintCheckBox.Checked = false;
ListView.SelectedListViewItemCollection items = listView.SelectedItems;
foreach (ListViewItem lvi in items)
if (sortByNameCheckBox.Checked)
{
List<Card> cards = new List<Card>();
cards = cards.OrderBy(c=>c.wholeName).ToList();
foreach (Card card in cards)
{
foreach (ListViewItem lvi in items)
{
if ((Card)lvi.Tag == card)
{
PrintCard(card);
listView.Items.Remove(lvi);
break;
}
}
}
}
else
{
PrintCard((Card)lvi.Tag);
listView.Items.Remove(lvi);
foreach (ListViewItem lvi in items)
{
PrintCard((Card)lvi.Tag);
listView.Items.Remove(lvi);
}
}
}
}
private void PrintCard(Card card)
{
currentUserId = card.cardId;
RestClient client = new RestClient();
string api = Properties.Settings.Default.ApiURL + "/card/GetImage/" + currentUserId;
WebRequest request = WebRequest.Create(api + "?key=" + MD5Hash.CalculateMD5Hash(api));
currentCardId = card.cardId;
string api = RestClient.GetRequestURL(Properties.Settings.Default.ApiURL,"card/GetImage/" + currentCardId);
WebRequest request = WebRequest.Create(api);
try
{
using (WebResponse response = request.GetResponse())
......@@ -108,7 +127,7 @@ namespace moyaPrintServer
pd.Print();
}
int currentUserId = 0;
int currentCardId = 0;
System.Drawing.Image currentImage;
private void PrintPage(object o, System.Drawing.Printing.PrintPageEventArgs ev)
......@@ -118,8 +137,8 @@ namespace moyaPrintServer
// Meillä ei ole kuin yks sivu
try
{
RestClient client = new RestClient(Properties.Settings.Default.ApiURL + "/card/Printed/" + currentUserId);
client.MakeRequest("?key=" + MD5Hash.CalculateMD5Hash(client.EndPoint));
RestClient client = new RestClient(Properties.Settings.Default.ApiURL);
client.MakeRequest("card/Printed/" + currentCardId);
}
catch (Exception e)
{
......@@ -148,7 +167,7 @@ namespace moyaPrintServer
try
{
RestClient client = new RestClient(Properties.Settings.Default.ApiURL + "/card/Reserve/" + card.cardId);
client.MakeRequest("?key=" + MD5Hash.CalculateMD5Hash(client.EndPoint));
client.MakeRequest();
}
catch (Exception ex)
{
......@@ -167,9 +186,9 @@ namespace moyaPrintServer
try
{
string url = Properties.Settings.Default.ApiURL + "/card/ListUnprinted";
RestClient client = new RestClient(url);
string json = client.MakeRequest("?key=" + MD5Hash.CalculateMD5Hash(client.EndPoint));
RestClient client = new RestClient(Properties.Settings.Default.ApiURL);
string json = client.MakeRequest("card/ListUnprinted");
var ser = new JavaScriptSerializer();
PrintQueueList queuelist = ser.Deserialize<PrintQueueList>(json);
......@@ -226,6 +245,18 @@ namespace moyaPrintServer
frm.ShowDialog();
}
private void listView_DoubleClick(object sender, EventArgs e)
{
if (listView.SelectedItems.Count > 0)
{
Card c = (Card)listView.SelectedItems[0].Tag;
PreviewForm frm = new PreviewForm();
frm.CardId = c.cardId;
frm.ShowDialog();
}
}
}
}
namespace moyaPrintServer
{
partial class PreviewForm
{
/// <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.pictureBox1 = new System.Windows.Forms.PictureBox();
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
//
// pictureBox1
//
this.pictureBox1.Location = new System.Drawing.Point(0, -1);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(324, 508);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// statusStrip1
//
this.statusStrip1.Location = new System.Drawing.Point(0, 506);
this.statusStrip1.Name = "statusStrip1";
this.statusStrip1.Size = new System.Drawing.Size(323, 22);
this.statusStrip1.TabIndex = 1;
this.statusStrip1.Text = "statusStrip1";
//
// PreviewForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(323, 528);
this.Controls.Add(this.statusStrip1);
this.Controls.Add(this.pictureBox1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Name = "PreviewForm";
this.Text = "PreviewForm";
this.Load += new System.EventHandler(this.PreviewForm_Load);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.StatusStrip statusStrip1;
}
}
\ 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.Windows.Forms;
using HttpUtils;
using System.Net;
using System.IO;
namespace moyaPrintServer
{
public partial class PreviewForm : Form
{
public PreviewForm()
{
InitializeComponent();
}
public int CardId;
private void PreviewForm_Load(object sender, EventArgs e)
{
string api = RestClient.GetRequestURL(Properties.Settings.Default.ApiURL, "card/GetImage/" + CardId);
WebRequest request = WebRequest.Create(api);
try
{
using (WebResponse response = request.GetResponse())
{
using (Stream stream = response.GetResponseStream())
{
pictureBox1.Image = Bitmap.FromStream(stream);
}
}
}
catch (Exception ex)
{
statusStrip1.Text = ex.Message;
return;
}
}
}
}
<?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>
</root>
\ No newline at end of file
......@@ -67,6 +67,12 @@
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="PreviewForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="PreviewForm.Designer.cs">
<DependentUpon>PreviewForm.cs</DependentUpon>
</Compile>
<Compile Include="PrintQueueList.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
......@@ -77,6 +83,9 @@
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="PreviewForm.resx">
<DependentUpon>PreviewForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!