Commit 1c70aa27 authored by tr's avatar tr

1、添加模块:流程共享

parent 7de75e4d
......@@ -88,26 +88,6 @@ namespace Tools.MyUtils
return s;
}
#endregion
#region 打开文件
/// <summary>
/// 打开指定文件
/// </summary>
/// <param name="fileName">文件名称</param>
public static void OpenFile(string fileName)
{
Process.Start(fileName);
}
/// <summary>
/// 用记事本打开指定文件
/// </summary>
/// <param name="fileName">文件名称</param>
public static void OpenFileWithNotepad(string fileName)
{
Process.Start("notepad.exe", fileName);
}
#endregion
#region 加密解密
......@@ -205,6 +185,68 @@ namespace Tools.MyUtils
#endregion
#region 打开文件
/// <summary>
/// 打开指定文件
/// </summary>
/// <param name="fileName">文件名称</param>
public static void OpenFile(string fileName)
{
Process.Start(fileName);
}
/// <summary>
/// 用记事本打开指定文件
/// </summary>
/// <param name="fileName">文件名称</param>
public static void OpenFileWithNotepad(string fileName)
{
Process.Start("notepad.exe", fileName);
}
#endregion
#region 选择文件
/// <summary>
/// 选择文件
/// </summary>
/// <param name="isMulti"></param>
/// <param name="filter"></param>
/// <returns></returns>
public static List<string> SelectFile(bool isMulti, string filter = "所有文件|*.*")
{
var result = new List<string>();
var dlg = new OpenFileDialog()
{
CheckFileExists = true,
CheckPathExists = true,
Multiselect = isMulti,
Filter = filter,
InitialDirectory = Utils.DesktopPath,
};
if (dlg.ShowDialog() == DialogResult.OK)
{
result = dlg.FileNames.ToList();
}
return result;
}
#endregion
#region 检查文件大小
/// <summary>
/// 检查文件尺寸
/// </summary>
/// <param name="len">文件总长度</param>
/// <param name="mb">限制大小(MB)</param>
/// <returns></returns>
public static bool CheckSize(int len, decimal mb)
{
return len <= mb * 1024 * 1024;
}
#endregion
#region winform:提示;帮助窗口;异步UI支持
/// <summary>
......@@ -318,6 +360,7 @@ namespace Tools.MyUtils
}
#endregion
#region (扩展)DataTable増行
/// <summary>
......
......@@ -174,6 +174,12 @@
<Compile Include="UI\wEvaluationOfEmployee.Designer.cs">
<DependentUpon>wEvaluationOfEmployee.cs</DependentUpon>
</Compile>
<Compile Include="UI\wFlowShare.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="UI\wFlowShare.Designer.cs">
<DependentUpon>wFlowShare.cs</DependentUpon>
</Compile>
<Compile Include="UI\wImageSearch.cs">
<SubType>Form</SubType>
</Compile>
......@@ -361,6 +367,9 @@
<EmbeddedResource Include="UI\wEvaluationOfEmployee.resx">
<DependentUpon>wEvaluationOfEmployee.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UI\wFlowShare.resx">
<DependentUpon>wFlowShare.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UI\wImageSearch.resx">
<DependentUpon>wImageSearch.cs</DependentUpon>
</EmbeddedResource>
......
......@@ -56,7 +56,7 @@ namespace Tools.UI.sys
//事件:上传
private void btnUpload_Click(object sender, EventArgs e)
{
var list = this.SelectFile(true);
var list = Utils.SelectFile(true);
if (list.Count > 0)
{
foreach (string path in list)
......@@ -106,7 +106,7 @@ namespace Tools.UI.sys
Utils.Tip("更新必须且只能选中一行!");
return;
}
var list = this.SelectFile(false);
var list = Utils.SelectFile(false);
if (list.Count > 0)
{
//更新文件
......@@ -127,41 +127,17 @@ namespace Tools.UI.sys
this.btnUpdate.Enabled = enable;
}
//选择文件
private List<string> SelectFile(bool isMulti, string filter = "所有文件|*.*")
{
var result = new List<string>();
var dlg = new OpenFileDialog()
{
CheckFileExists = true,
CheckPathExists = true,
Multiselect = isMulti,
Filter = filter,
InitialDirectory = Utils.DesktopPath,
};
if (dlg.ShowDialog() == DialogResult.OK)
{
result = dlg.FileNames.ToList();
}
return result;
}
//检查文件尺寸
private bool CheckSize(decimal kb)
{
return kb <= 50 * 1024;
}
//填充数据行
private bool FillRowData(DataRow dr, string path)
{
//读取文件
var bytes = File.ReadAllBytes(path);
var KB = bytes.Length / 1024M;
//超过50M直接忽略
if (!this.CheckSize(KB))
if (!Utils.CheckSize(bytes.Length, 50))
return false;
//添加文件
dr["dName"] = Path.GetFileName(path);
dr["dSize"] = KB.ToString("0.##");
dr["dSize"] = (bytes.Length / 1024M).ToString("0.##");
dr["dData"] = bytes;
dr["CreateDate"] = DateTime.Now;
dr.EndEdit();
......
namespace Tools.UI
{
partial class wFlowShare
{
/// <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.toolStrip1 = new System.Windows.Forms.ToolStrip();
this.tsbAdd = new System.Windows.Forms.ToolStripButton();
this.tsbUpdate = new System.Windows.Forms.ToolStripButton();
this.tsbSave = new System.Windows.Forms.ToolStripButton();
this.dgvDetail = new System.Windows.Forms.DataGridView();
this.Column6 = new System.Windows.Forms.DataGridViewButtonColumn();
this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.toolStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dgvDetail)).BeginInit();
this.SuspendLayout();
//
// toolStrip1
//
this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.tsbAdd,
this.tsbUpdate,
this.tsbSave});
this.toolStrip1.Location = new System.Drawing.Point(0, 0);
this.toolStrip1.Name = "toolStrip1";
this.toolStrip1.Size = new System.Drawing.Size(707, 25);
this.toolStrip1.TabIndex = 0;
this.toolStrip1.Text = "toolStrip1";
//
// tsbAdd
//
this.tsbAdd.Image = global::Tools.Properties.Resources.新增;
this.tsbAdd.ImageTransparentColor = System.Drawing.Color.Magenta;
this.tsbAdd.Name = "tsbAdd";
this.tsbAdd.Size = new System.Drawing.Size(76, 22);
this.tsbAdd.Text = "添加文件";
this.tsbAdd.Click += new System.EventHandler(this.tsbAdd_Click);
//
// tsbUpdate
//
this.tsbUpdate.Image = global::Tools.Properties.Resources.更新;
this.tsbUpdate.ImageTransparentColor = System.Drawing.Color.Magenta;
this.tsbUpdate.Name = "tsbUpdate";
this.tsbUpdate.Size = new System.Drawing.Size(76, 22);
this.tsbUpdate.Text = "更新文件";
this.tsbUpdate.Click += new System.EventHandler(this.tsbUpdate_Click);
//
// tsbSave
//
this.tsbSave.Image = global::Tools.Properties.Resources.保存;
this.tsbSave.ImageTransparentColor = System.Drawing.Color.Magenta;
this.tsbSave.Name = "tsbSave";
this.tsbSave.Size = new System.Drawing.Size(52, 22);
this.tsbSave.Text = "保存";
this.tsbSave.Click += new System.EventHandler(this.tsbSave_Click);
//
// dgvDetail
//
this.dgvDetail.BackgroundColor = System.Drawing.SystemColors.Window;
this.dgvDetail.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgvDetail.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.Column6,
this.Column2,
this.Column3,
this.Column4,
this.Column5});
this.dgvDetail.Dock = System.Windows.Forms.DockStyle.Fill;
this.dgvDetail.Location = new System.Drawing.Point(0, 25);
this.dgvDetail.Name = "dgvDetail";
this.dgvDetail.RowTemplate.Height = 23;
this.dgvDetail.Size = new System.Drawing.Size(707, 433);
this.dgvDetail.TabIndex = 1;
//
// Column6
//
this.Column6.HeaderText = "操作";
this.Column6.Name = "Column6";
this.Column6.Resizable = System.Windows.Forms.DataGridViewTriState.True;
this.Column6.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
this.Column6.Text = "下载";
this.Column6.UseColumnTextForButtonValue = true;
this.Column6.Width = 65;
//
// Column2
//
this.Column2.DataPropertyName = "dName";
this.Column2.HeaderText = "文件名称";
this.Column2.Name = "Column2";
this.Column2.Width = 200;
//
// Column3
//
this.Column3.DataPropertyName = "dSize";
this.Column3.HeaderText = "文件大小(K)";
this.Column3.Name = "Column3";
//
// Column4
//
this.Column4.DataPropertyName = "CreateDate";
this.Column4.HeaderText = "创建日期";
this.Column4.Name = "Column4";
this.Column4.Width = 120;
//
// Column5
//
this.Column5.DataPropertyName = "UpdateDate";
this.Column5.HeaderText = "更新日期";
this.Column5.Name = "Column5";
this.Column5.Width = 120;
//
// wFlowShare
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.SystemColors.Window;
this.ClientSize = new System.Drawing.Size(707, 458);
this.Controls.Add(this.dgvDetail);
this.Controls.Add(this.toolStrip1);
this.Name = "wFlowShare";
this.Text = "wFlowShare";
this.Load += new System.EventHandler(this.wFlowShare_Load);
this.toolStrip1.ResumeLayout(false);
this.toolStrip1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.dgvDetail)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.ToolStrip toolStrip1;
private System.Windows.Forms.ToolStripButton tsbAdd;
private System.Windows.Forms.ToolStripButton tsbUpdate;
private System.Windows.Forms.DataGridView dgvDetail;
private System.Windows.Forms.ToolStripButton tsbSave;
private System.Windows.Forms.DataGridViewButtonColumn Column6;
private System.Windows.Forms.DataGridViewTextBoxColumn Column2;
private System.Windows.Forms.DataGridViewTextBoxColumn Column3;
private System.Windows.Forms.DataGridViewTextBoxColumn Column4;
private System.Windows.Forms.DataGridViewTextBoxColumn Column5;
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
//
using Tools.MyCommon;
using Tools.MyData;
using Tools.MyUtils;
namespace Tools.UI
{
public partial class wFlowShare : wEditBasic
{
public wFlowShare()
{
InitializeComponent();
}
private void wFlowShare_Load(object sender, EventArgs e)
{
//初始化模块表
this.ModuleTableList = new List<TQuery> { new TQuery("FTT_Share", "SELECT * FROM FTT_Share") };
//初始化数据访问对象
this.InitDBHelper(Utils.GetDbLinkString204("FTT_Work"));
//初始化
this.InitUI();
Task.Run(() => this.InitData());
}
public override void InitUI()
{
//表格初始化
this.dgvDetail.AllowUserToAddRows = false;
this.dgvDetail.AutoGenerateColumns = false;
this.dgvDetail.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
//表格事件
this.dgvDetail.CellContentClick += DgvDetail_CellContentClick;
this.dgvDetail.CellBeginEdit += DgvDetail_CellBeginEdit;
}
public override void InitData()
{
this.AsyncUI(() => {
this._ds = this._db.GetData(this.ModuleTableList, true);
this.dgvDetail.DataSource = this._ds.Tables[0].DefaultView;
});
}
//表格:编辑控制
private void DgvDetail_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
{
//只许编辑类型
e.Cancel = dgvDetail.Columns[e.ColumnIndex].DataPropertyName != "dType";
}
//表格:下载文件
private void DgvDetail_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex < 0)
return;
if (dgvDetail.Columns[e.ColumnIndex] is DataGridViewButtonColumn)
{
//选择文件夹
var dlg = new FolderBrowserDialog()
{
RootFolder = Environment.SpecialFolder.Desktop,
ShowNewFolderButton = true,
Description = "选择一个文件夹",
};
if (dlg.ShowDialog() == DialogResult.OK)
{
for (int i = 0; i < this.dgvDetail.SelectedRows.Count; i++)
{
var index = this.dgvDetail.SelectedRows[i].Index;
var drNow = this._ds.Tables[0].DefaultView[index];
var fileName = drNow["dName"].ToString();
File.WriteAllBytes($@"{dlg.SelectedPath}\{fileName}", drNow["dData"] as byte[]);
}
Utils.Tip("下载成功!");
}
}
}
//工具栏:添加文件
private void tsbAdd_Click(object sender, EventArgs e)
{
var list = Utils.SelectFile(true);
if (list.Count > 0)
{
foreach (string path in list)
{
//添加文件
var drNew = this._ds.Tables[0].NewRow();
if (this.FillRowData(drNew, path))
{
drNew["CreateDate"] = DateTime.Now;
this._ds.Tables[0].Rows.Add(drNew);
}
}
this.Save();
}
}
//工具栏:更新文件
private void tsbUpdate_Click(object sender, EventArgs e)
{
if (this.dgvDetail.SelectedRows.Count != 1)
{
Utils.Tip("更新必须且只能选中一行!");
return;
}
var list = Utils.SelectFile(false);
if (list.Count > 0)
{
//更新文件
var index = this.dgvDetail.SelectedRows[0].Index;
var drNow = this._ds.Tables[0].DefaultView[index].Row;
if (this.FillRowData(drNow, list[0]))
{
drNow["UpdateDate"] = DateTime.Now;
this.Save();
}
}
}
//工具栏:保存
private void tsbSave_Click(object sender, EventArgs e)
{
this.Save();
}
//填充数据行
private bool FillRowData(DataRow dr, string path)
{
//读取文件
var bytes = File.ReadAllBytes(path);
//单个文件限制在20M以内
if (!Utils.CheckSize(bytes.Length, 20))
{
Utils.Tip("单个文件大小不能超过20M!");
return false;
}
//添加文件
dr["dName"] = Path.GetFileName(path);
dr["dSize"] = (bytes.Length / 1024M).ToString("0.##");
dr["dData"] = bytes;
dr.EndEdit();
return true;
}
}
}
<?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="toolStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="Column6.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column2.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column3.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column4.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column5.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>
\ No newline at end of file
......@@ -23,6 +23,7 @@ namespace Tools
return new List<ModuleInfo>
{
//-------------------------------
this.CreateModule(Tools_uni, typeof(UI.wFlowShare), "流程共享", "tr:助力业务沉淀与流程共享"),
this.CreateModule(Tools_uni, typeof(UI.wTaskBoard), "任务看板", "tr:任务看板的简易化工具,免除翻页困扰"),
this.CreateModule(Tools_uni, typeof(UI.wLoginPwd), "密码解析", "tr:用于登陆密码的解密加密"),
this.CreateModule(Tools_uni, typeof(UI.wDbLinkMngr), "数据库链接管理", "tr:现有数据库链接的管理和查看"),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment