добавляет форму с журналом
This commit is contained in:
parent
59b5b18baf
commit
51a2bb4ee9
@ -113,6 +113,11 @@ namespace AwesomeEmailExtractor
|
|||||||
|
|
||||||
command.ExecuteNonQuery();
|
command.ExecuteNonQuery();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
new public string ToString()
|
||||||
|
{
|
||||||
|
return this.Login;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class AdminUtils
|
public class AdminUtils
|
||||||
|
@ -86,6 +86,12 @@
|
|||||||
<Compile Include="ExtactEmailsAlgorithm.cs" />
|
<Compile Include="ExtactEmailsAlgorithm.cs" />
|
||||||
<Compile Include="FormManager.cs" />
|
<Compile Include="FormManager.cs" />
|
||||||
<Compile Include="Globals.cs" />
|
<Compile Include="Globals.cs" />
|
||||||
|
<Compile Include="JournalForm.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="JournalForm.Designer.cs">
|
||||||
|
<DependentUpon>JournalForm.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Logs.cs" />
|
<Compile Include="Logs.cs" />
|
||||||
<Compile Include="MainForm.cs">
|
<Compile Include="MainForm.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
@ -110,6 +116,9 @@
|
|||||||
<EmbeddedResource Include="AuthorizationForm.resx">
|
<EmbeddedResource Include="AuthorizationForm.resx">
|
||||||
<DependentUpon>AuthorizationForm.cs</DependentUpon>
|
<DependentUpon>AuthorizationForm.cs</DependentUpon>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Include="JournalForm.resx">
|
||||||
|
<DependentUpon>JournalForm.cs</DependentUpon>
|
||||||
|
</EmbeddedResource>
|
||||||
<EmbeddedResource Include="MainForm.resx">
|
<EmbeddedResource Include="MainForm.resx">
|
||||||
<DependentUpon>MainForm.cs</DependentUpon>
|
<DependentUpon>MainForm.cs</DependentUpon>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
|
@ -72,6 +72,9 @@ namespace AwesomeEmailExtractor
|
|||||||
command.CommandText = "CREATE TABLE IF NOT EXISTS logs (id INTEGER PRIMARY KEY AUTOINCREMENT, user_id INTEGER NOT NULL, date TEXT NOT NULL, action INTEGER NOT NULL, message TEXT NOT NULL, FOREIGN KEY(action) REFERENCES logs_actions(id));";
|
command.CommandText = "CREATE TABLE IF NOT EXISTS logs (id INTEGER PRIMARY KEY AUTOINCREMENT, user_id INTEGER NOT NULL, date TEXT NOT NULL, action INTEGER NOT NULL, message TEXT NOT NULL, FOREIGN KEY(action) REFERENCES logs_actions(id));";
|
||||||
command.ExecuteNonQuery();
|
command.ExecuteNonQuery();
|
||||||
|
|
||||||
|
command.CommandText = "ATTACH DATABASE @dbpath AS appDB";
|
||||||
|
command.Parameters.AddWithValue("@dbpath", Globals.getAppDatabase());
|
||||||
|
command.ExecuteNonQuery();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void CreateTables()
|
public static void CreateTables()
|
||||||
|
174
JournalForm.Designer.cs
generated
Normal file
174
JournalForm.Designer.cs
generated
Normal file
@ -0,0 +1,174 @@
|
|||||||
|
namespace AwesomeEmailExtractor
|
||||||
|
{
|
||||||
|
partial class JournalForm
|
||||||
|
{
|
||||||
|
/// <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.dataGridView1 = new System.Windows.Forms.DataGridView();
|
||||||
|
this.panel1 = new System.Windows.Forms.Panel();
|
||||||
|
this.label1 = new System.Windows.Forms.Label();
|
||||||
|
this.label2 = new System.Windows.Forms.Label();
|
||||||
|
this.label3 = new System.Windows.Forms.Label();
|
||||||
|
this.dataLabel = new System.Windows.Forms.Label();
|
||||||
|
this.actionLabel = new System.Windows.Forms.Label();
|
||||||
|
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
|
||||||
|
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
|
||||||
|
this.panel1.SuspendLayout();
|
||||||
|
this.tableLayoutPanel1.SuspendLayout();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// dataGridView1
|
||||||
|
//
|
||||||
|
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.dataGridView1.Location = new System.Drawing.Point(10, 10);
|
||||||
|
this.dataGridView1.MultiSelect = false;
|
||||||
|
this.dataGridView1.Name = "dataGridView1";
|
||||||
|
this.dataGridView1.ReadOnly = true;
|
||||||
|
this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
|
||||||
|
this.dataGridView1.Size = new System.Drawing.Size(414, 451);
|
||||||
|
this.dataGridView1.TabIndex = 0;
|
||||||
|
this.dataGridView1.SelectionChanged += new System.EventHandler(this.dataGridView1_SelectionChanged);
|
||||||
|
//
|
||||||
|
// panel1
|
||||||
|
//
|
||||||
|
this.panel1.Controls.Add(this.tableLayoutPanel1);
|
||||||
|
this.panel1.Dock = System.Windows.Forms.DockStyle.Right;
|
||||||
|
this.panel1.Location = new System.Drawing.Point(424, 10);
|
||||||
|
this.panel1.Name = "panel1";
|
||||||
|
this.panel1.Size = new System.Drawing.Size(458, 451);
|
||||||
|
this.panel1.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
this.label1.AutoSize = true;
|
||||||
|
this.label1.Location = new System.Drawing.Point(13, 10);
|
||||||
|
this.label1.Name = "label1";
|
||||||
|
this.label1.Size = new System.Drawing.Size(36, 13);
|
||||||
|
this.label1.TabIndex = 2;
|
||||||
|
this.label1.Text = "Дата:";
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
this.label2.AutoSize = true;
|
||||||
|
this.label2.Location = new System.Drawing.Point(13, 30);
|
||||||
|
this.label2.Name = "label2";
|
||||||
|
this.label2.Size = new System.Drawing.Size(54, 13);
|
||||||
|
this.label2.TabIndex = 3;
|
||||||
|
this.label2.Text = "Событие:";
|
||||||
|
//
|
||||||
|
// label3
|
||||||
|
//
|
||||||
|
this.label3.AutoSize = true;
|
||||||
|
this.label3.Location = new System.Drawing.Point(13, 50);
|
||||||
|
this.label3.Name = "label3";
|
||||||
|
this.label3.Size = new System.Drawing.Size(68, 13);
|
||||||
|
this.label3.TabIndex = 4;
|
||||||
|
this.label3.Text = "Сообщение:";
|
||||||
|
//
|
||||||
|
// dataLabel
|
||||||
|
//
|
||||||
|
this.dataLabel.AutoSize = true;
|
||||||
|
this.dataLabel.Location = new System.Drawing.Point(141, 10);
|
||||||
|
this.dataLabel.Name = "dataLabel";
|
||||||
|
this.dataLabel.Size = new System.Drawing.Size(54, 13);
|
||||||
|
this.dataLabel.TabIndex = 5;
|
||||||
|
this.dataLabel.Text = "dataLabel";
|
||||||
|
//
|
||||||
|
// actionLabel
|
||||||
|
//
|
||||||
|
this.actionLabel.AutoSize = true;
|
||||||
|
this.actionLabel.Location = new System.Drawing.Point(141, 30);
|
||||||
|
this.actionLabel.Name = "actionLabel";
|
||||||
|
this.actionLabel.Size = new System.Drawing.Size(62, 13);
|
||||||
|
this.actionLabel.TabIndex = 6;
|
||||||
|
this.actionLabel.Text = "actionLabel";
|
||||||
|
//
|
||||||
|
// richTextBox1
|
||||||
|
//
|
||||||
|
this.richTextBox1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.richTextBox1.Location = new System.Drawing.Point(141, 53);
|
||||||
|
this.richTextBox1.Name = "richTextBox1";
|
||||||
|
this.richTextBox1.Size = new System.Drawing.Size(304, 385);
|
||||||
|
this.richTextBox1.TabIndex = 7;
|
||||||
|
this.richTextBox1.Text = "";
|
||||||
|
//
|
||||||
|
// tableLayoutPanel1
|
||||||
|
//
|
||||||
|
this.tableLayoutPanel1.ColumnCount = 2;
|
||||||
|
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 29.2876F));
|
||||||
|
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 70.7124F));
|
||||||
|
this.tableLayoutPanel1.Controls.Add(this.label1, 0, 0);
|
||||||
|
this.tableLayoutPanel1.Controls.Add(this.label3, 0, 2);
|
||||||
|
this.tableLayoutPanel1.Controls.Add(this.richTextBox1, 1, 2);
|
||||||
|
this.tableLayoutPanel1.Controls.Add(this.dataLabel, 1, 0);
|
||||||
|
this.tableLayoutPanel1.Controls.Add(this.actionLabel, 1, 1);
|
||||||
|
this.tableLayoutPanel1.Controls.Add(this.label2, 0, 1);
|
||||||
|
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
|
||||||
|
this.tableLayoutPanel1.Padding = new System.Windows.Forms.Padding(10);
|
||||||
|
this.tableLayoutPanel1.RowCount = 3;
|
||||||
|
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
|
||||||
|
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
|
||||||
|
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||||
|
this.tableLayoutPanel1.Size = new System.Drawing.Size(458, 451);
|
||||||
|
this.tableLayoutPanel1.TabIndex = 8;
|
||||||
|
//
|
||||||
|
// JournalForm
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(892, 471);
|
||||||
|
this.Controls.Add(this.dataGridView1);
|
||||||
|
this.Controls.Add(this.panel1);
|
||||||
|
this.Name = "JournalForm";
|
||||||
|
this.Padding = new System.Windows.Forms.Padding(10);
|
||||||
|
this.Text = "Журнал";
|
||||||
|
this.Load += new System.EventHandler(this.JournalForm_Load);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
|
||||||
|
this.panel1.ResumeLayout(false);
|
||||||
|
this.tableLayoutPanel1.ResumeLayout(false);
|
||||||
|
this.tableLayoutPanel1.PerformLayout();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.DataGridView dataGridView1;
|
||||||
|
private System.Windows.Forms.Panel panel1;
|
||||||
|
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
|
||||||
|
private System.Windows.Forms.Label label1;
|
||||||
|
private System.Windows.Forms.Label label3;
|
||||||
|
private System.Windows.Forms.RichTextBox richTextBox1;
|
||||||
|
private System.Windows.Forms.Label dataLabel;
|
||||||
|
private System.Windows.Forms.Label actionLabel;
|
||||||
|
private System.Windows.Forms.Label label2;
|
||||||
|
}
|
||||||
|
}
|
43
JournalForm.cs
Normal file
43
JournalForm.cs
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
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 AwesomeEmailExtractor
|
||||||
|
{
|
||||||
|
public partial class JournalForm : Form
|
||||||
|
{
|
||||||
|
public JournalForm()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void JournalForm_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var logs = Logs.GetLogsList(Globals.currentUser);
|
||||||
|
|
||||||
|
dataGridView1.DataSource = logs;
|
||||||
|
dataGridView1.Columns[0].Visible = false;
|
||||||
|
dataGridView1.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void dataGridView1_SelectionChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView1.SelectedRows.Count > 0)
|
||||||
|
{
|
||||||
|
dataLabel.Text = dataGridView1.SelectedRows[0].Cells[1].Value.ToString();
|
||||||
|
actionLabel.Text = dataGridView1.SelectedRows[0].Cells[2].Value.ToString();
|
||||||
|
richTextBox1.Text = dataGridView1.SelectedRows[0].Cells[3].Value.ToString();
|
||||||
|
} else {
|
||||||
|
dataLabel.Text = "";
|
||||||
|
actionLabel.Text = "";
|
||||||
|
richTextBox1.Text = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
JournalForm.resx
Normal file
120
JournalForm.resx
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?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>
|
58
Logs.cs
58
Logs.cs
@ -10,10 +10,10 @@ namespace AwesomeEmailExtractor
|
|||||||
public class Logs
|
public class Logs
|
||||||
{
|
{
|
||||||
public class LogData {
|
public class LogData {
|
||||||
public User user;
|
public User User { get; set; }
|
||||||
public string date;
|
public string Date { get; set; }
|
||||||
public Action action;
|
public Action Action { get; set; }
|
||||||
public string message;
|
public string Message { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Action
|
public enum Action
|
||||||
@ -37,33 +37,49 @@ namespace AwesomeEmailExtractor
|
|||||||
command.ExecuteNonQuery();
|
command.ExecuteNonQuery();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<LogData> GetLogs(User user)
|
public static List<LogData> GetLogsList(User user)
|
||||||
{
|
{
|
||||||
SqliteCommand command = new SqliteCommand();
|
SqliteDataReader reader = GetLogsDataReader(user);
|
||||||
command.Connection = Globals.logsDb;
|
|
||||||
|
|
||||||
command.CommandText = "SELECT date, action, message FROM logs WHERE user_id = @user_id ORDER BY date DESC";
|
|
||||||
command.Parameters.AddWithValue("@user_id", user.ID);
|
|
||||||
|
|
||||||
SqliteDataReader reader = command.ExecuteReader();
|
|
||||||
|
|
||||||
List<LogData> logs = new List<LogData>();
|
List<LogData> logs = new List<LogData>();
|
||||||
while (reader.Read())
|
while (reader.Read())
|
||||||
{
|
{
|
||||||
logs.Add(new LogData()
|
logs.Add(new LogData()
|
||||||
{
|
{
|
||||||
user = user,
|
User = user,
|
||||||
date = reader.GetString(0),
|
Date = reader.GetString(0),
|
||||||
action = (Action)reader.GetInt32(1),
|
Action = (Action)reader.GetInt32(1),
|
||||||
message = reader.GetString(2)
|
Message = reader.GetString(2)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reader.Close();
|
||||||
|
|
||||||
return logs;
|
return logs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<LogData> GetLogs()
|
private static SqliteDataReader GetLogsDataReader(User user)
|
||||||
{
|
{
|
||||||
|
if (Globals.currentUser.ID != user.ID && Globals.currentUser.Role != UserRoles.ADMIN)
|
||||||
|
{
|
||||||
|
throw new Exception("У вас нет прав на просмотр логов");
|
||||||
|
}
|
||||||
|
|
||||||
|
SqliteCommand command = new SqliteCommand();
|
||||||
|
command.Connection = Globals.logsDb;
|
||||||
|
command.CommandText = "SELECT date, action, message FROM logs WHERE user_id = @user_id ORDER BY date DESC";
|
||||||
|
command.Parameters.AddWithValue("@user_id", user.ID);
|
||||||
|
|
||||||
|
return command.ExecuteReader();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<LogData> GetLogsList()
|
||||||
|
{
|
||||||
|
if (Globals.currentUser.Role != UserRoles.ADMIN)
|
||||||
|
{
|
||||||
|
throw new Exception("У вас нет прав на просмотр логов");
|
||||||
|
}
|
||||||
|
|
||||||
SqliteCommand command = new SqliteCommand();
|
SqliteCommand command = new SqliteCommand();
|
||||||
command.Connection = Globals.logsDb;
|
command.Connection = Globals.logsDb;
|
||||||
command.CommandText = "ATTACH DATABASE @dbpath AS appDB";
|
command.CommandText = "ATTACH DATABASE @dbpath AS appDB";
|
||||||
@ -87,10 +103,10 @@ namespace AwesomeEmailExtractor
|
|||||||
{
|
{
|
||||||
logs.Add(new LogData()
|
logs.Add(new LogData()
|
||||||
{
|
{
|
||||||
user = new User(reader.GetInt32(0), reader.GetString(1), (UserRoles)reader.GetInt32(2)),
|
User = new User(reader.GetInt32(0), reader.GetString(1), (UserRoles)reader.GetInt32(2)),
|
||||||
date = reader.GetString(3),
|
Date = reader.GetString(3),
|
||||||
action = (Action)reader.GetInt32(4),
|
Action = (Action)reader.GetInt32(4),
|
||||||
message = reader.GetString(5)
|
Message = reader.GetString(5)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
12
MainForm.Designer.cs
generated
12
MainForm.Designer.cs
generated
@ -41,6 +41,7 @@
|
|||||||
this.administrationToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.administrationToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.journalToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.resultStatusStrip.SuspendLayout();
|
this.resultStatusStrip.SuspendLayout();
|
||||||
this.menuStrip1.SuspendLayout();
|
this.menuStrip1.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
@ -57,7 +58,7 @@
|
|||||||
"bob@example.com"});
|
"bob@example.com"});
|
||||||
this.uniqueListBox.Location = new System.Drawing.Point(424, 32);
|
this.uniqueListBox.Location = new System.Drawing.Point(424, 32);
|
||||||
this.uniqueListBox.Name = "uniqueListBox";
|
this.uniqueListBox.Name = "uniqueListBox";
|
||||||
this.uniqueListBox.Size = new System.Drawing.Size(225, 304);
|
this.uniqueListBox.Size = new System.Drawing.Size(225, 324);
|
||||||
this.uniqueListBox.TabIndex = 0;
|
this.uniqueListBox.TabIndex = 0;
|
||||||
//
|
//
|
||||||
// sourceRichTextBox
|
// sourceRichTextBox
|
||||||
@ -133,6 +134,7 @@
|
|||||||
// аккаунтToolStripMenuItem
|
// аккаунтToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.аккаунтToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
this.аккаунтToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.journalToolStripMenuItem,
|
||||||
this.settingsToolStripMenuItem,
|
this.settingsToolStripMenuItem,
|
||||||
this.administrationToolStripMenuItem,
|
this.administrationToolStripMenuItem,
|
||||||
this.exitToolStripMenuItem});
|
this.exitToolStripMenuItem});
|
||||||
@ -166,6 +168,13 @@
|
|||||||
this.helpToolStripMenuItem.Size = new System.Drawing.Size(65, 20);
|
this.helpToolStripMenuItem.Size = new System.Drawing.Size(65, 20);
|
||||||
this.helpToolStripMenuItem.Text = "Справка";
|
this.helpToolStripMenuItem.Text = "Справка";
|
||||||
//
|
//
|
||||||
|
// journalToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.journalToolStripMenuItem.Name = "journalToolStripMenuItem";
|
||||||
|
this.journalToolStripMenuItem.Size = new System.Drawing.Size(189, 22);
|
||||||
|
this.journalToolStripMenuItem.Text = "Журнал";
|
||||||
|
this.journalToolStripMenuItem.Click += new System.EventHandler(this.journalToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
// MainForm
|
// MainForm
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
@ -205,6 +214,7 @@
|
|||||||
private System.Windows.Forms.ToolStripMenuItem settingsToolStripMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem settingsToolStripMenuItem;
|
||||||
private System.Windows.Forms.ToolStripMenuItem administrationToolStripMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem administrationToolStripMenuItem;
|
||||||
private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem journalToolStripMenuItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,5 +68,11 @@ namespace AwesomeEmailExtractor
|
|||||||
AuthorizationForm authorization = FormManager.Current.CreateForm<AuthorizationForm>();
|
AuthorizationForm authorization = FormManager.Current.CreateForm<AuthorizationForm>();
|
||||||
FormManager.Current.Navigate(this, authorization);
|
FormManager.Current.Navigate(this, authorization);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void journalToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
JournalForm journalForm = FormManager.Current.CreateForm<JournalForm>();
|
||||||
|
journalForm.ShowDialog(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user