完成附件功能
This commit is contained in:
		
							parent
							
								
									8ea15b2ab7
								
							
						
					
					
						commit
						e7f8aaed1f
					
				@ -20,7 +20,9 @@ namespace CalendarNotepad.Extends
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        public void DbInit() {
 | 
					        public void DbInit() {
 | 
				
			||||||
            using var db = new DbContext();
 | 
					            using var db = new DbContext();
 | 
				
			||||||
            db.CodeFirst.InitTables<WorkUnit>();
 | 
					            db.CodeFirst.InitTables<WorkUnit>(); 
 | 
				
			||||||
 | 
					            db.CodeFirst.InitTables<PlusFileUnit>();
 | 
				
			||||||
 | 
					            db.CodeFirst.InitTables<WorkUnitPlusFile>();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										66
									
								
								CalendarNotepad/Extends/PlusFile.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										66
									
								
								CalendarNotepad/Extends/PlusFile.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,66 @@
 | 
				
			|||||||
 | 
					using System.Security.Cryptography;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace CalendarNotepad.Extends
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    /// <summary>
 | 
				
			||||||
 | 
					    /// 附件操作
 | 
				
			||||||
 | 
					    /// </summary>
 | 
				
			||||||
 | 
					    public static class PlusFile
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 获取MD5码
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        public static string GetMd5(string fileContent) {
 | 
				
			||||||
 | 
					            var ibs = Encoding.UTF8.GetBytes(fileContent);
 | 
				
			||||||
 | 
					            return GetMd5(ibs);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 获取MD5码
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        public static string GetMd5(byte[] content) {
 | 
				
			||||||
 | 
					            using var md5 = MD5.Create();
 | 
				
			||||||
 | 
					            var md5bs = md5.ComputeHash(content);
 | 
				
			||||||
 | 
					            StringBuilder sb = new(md5bs.Length * 2);
 | 
				
			||||||
 | 
					            for(int i = 0;i < md5bs.Length;i++) {
 | 
				
			||||||
 | 
					                sb.Append(md5bs[i].ToString("X2"));
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            return sb.ToString();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 读取文件内容
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        /// <param name="fullFilePath"></param>
 | 
				
			||||||
 | 
					        /// <returns></returns>
 | 
				
			||||||
 | 
					        public static byte[] LoadFile(string fullFilePath) {
 | 
				
			||||||
 | 
					            if(!File.Exists(fullFilePath)) {
 | 
				
			||||||
 | 
					                throw new FileNotFoundException();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            var fileInfo = new FileInfo(fullFilePath);
 | 
				
			||||||
 | 
					            var fileSize = fileInfo.Length;
 | 
				
			||||||
 | 
					            if(fileSize > 4 * 1024 * 1024) {
 | 
				
			||||||
 | 
					                throw new OutOfMemoryException();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            using FileStream fs = fileInfo.OpenRead();
 | 
				
			||||||
 | 
					            using BinaryReader br = new BinaryReader(fs);
 | 
				
			||||||
 | 
					            var length = (int)fs.Length;
 | 
				
			||||||
 | 
					            var buf = br.ReadBytes(length);
 | 
				
			||||||
 | 
					            return buf;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 写入文件内容
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        /// <param name="fullFilePath"></param>
 | 
				
			||||||
 | 
					        /// <param name="content"></param>
 | 
				
			||||||
 | 
					        public static void SaveFile(string fullFilePath,byte[] content) {
 | 
				
			||||||
 | 
					            if(File.Exists(fullFilePath)) {
 | 
				
			||||||
 | 
					                File.Delete(fullFilePath);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            using var fs = new FileStream(fullFilePath,FileMode.CreateNew,FileAccess.Write);
 | 
				
			||||||
 | 
					            using var bw = new BinaryWriter(fs);
 | 
				
			||||||
 | 
					            bw.Write(content);
 | 
				
			||||||
 | 
					            bw.Flush();
 | 
				
			||||||
 | 
					            bw.Close();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -45,7 +45,6 @@ namespace CalendarNotepad
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        private void rtbMsg_TextChanged(object sender,EventArgs e) {
 | 
					        private void rtbMsg_TextChanged(object sender,EventArgs e) {
 | 
				
			||||||
            var data = new WorkUnit {
 | 
					            var data = new WorkUnit {
 | 
				
			||||||
                DayRange = GetDateRange(),
 | 
					 | 
				
			||||||
                WorkDay = this.mcWorkDay.SelectionStart.ToString("yyyyMMdd"),
 | 
					                WorkDay = this.mcWorkDay.SelectionStart.ToString("yyyyMMdd"),
 | 
				
			||||||
                WorkMessage = this.rtbMsg.Text,
 | 
					                WorkMessage = this.rtbMsg.Text,
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										17
									
								
								CalendarNotepad/Models/PlusFileUnit.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								CalendarNotepad/Models/PlusFileUnit.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,17 @@
 | 
				
			|||||||
 | 
					namespace CalendarNotepad.Models
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    /// <summary>
 | 
				
			||||||
 | 
					    /// 附件文件单元
 | 
				
			||||||
 | 
					    /// </summary>
 | 
				
			||||||
 | 
					    public class PlusFileUnit
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 文件指纹ID
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        public string? FileId { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 文件内容
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        public byte[]? FileContent { get; set; }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -27,7 +27,7 @@ namespace CalendarNotepad.Models
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        public void AddOrReplace(WorkUnit unit) {
 | 
					        public void AddOrReplace(WorkUnit unit) {
 | 
				
			||||||
            lock(_lockObj) {
 | 
					            lock(_lockObj) {
 | 
				
			||||||
                var qu = this.WorkList.Where(a => a.WorkDay == unit.WorkDay && a.DayRange == unit.DayRange);
 | 
					                var qu = this.WorkList.Where(a => a.WorkDay == unit.WorkDay);
 | 
				
			||||||
                if(qu.Any() && unit.WorkMessage.IsNullOrEmpty()) {
 | 
					                if(qu.Any() && unit.WorkMessage.IsNullOrEmpty()) {
 | 
				
			||||||
                    qu.ToList().ForEach(a => this.WorkList.Remove(a));
 | 
					                    qu.ToList().ForEach(a => this.WorkList.Remove(a));
 | 
				
			||||||
                    return;
 | 
					                    return;
 | 
				
			||||||
@ -53,8 +53,8 @@ namespace CalendarNotepad.Models
 | 
				
			|||||||
        /// <param name="workRange">工作范围</param>
 | 
					        /// <param name="workRange">工作范围</param>
 | 
				
			||||||
        /// <returns></returns>
 | 
					        /// <returns></returns>
 | 
				
			||||||
        public WorkUnit GetUnit(string workDay,string workRange) {
 | 
					        public WorkUnit GetUnit(string workDay,string workRange) {
 | 
				
			||||||
            var qu = this.WorkList.Where(a => a.WorkDay == workDay && a.DayRange == workRange);
 | 
					            var qu = this.WorkList.Where(a => a.WorkDay == workDay);
 | 
				
			||||||
            return qu.Any() ? qu.First() : new WorkUnit { DayRange = workRange,WorkDay = workDay,WorkMessage = "" };
 | 
					            return qu.Any() ? qu.First() : new WorkUnit { WorkDay = workDay,WorkMessage = "" };
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public void SaveToFile() {
 | 
					        public void SaveToFile() {
 | 
				
			||||||
 | 
				
			|||||||
@ -1,4 +1,5 @@
 | 
				
			|||||||
using System.ComponentModel.DataAnnotations.Schema;
 | 
					using System.ComponentModel.DataAnnotations;
 | 
				
			||||||
 | 
					using System.ComponentModel.DataAnnotations.Schema;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace CalendarNotepad.Models
 | 
					namespace CalendarNotepad.Models
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -11,12 +12,9 @@ namespace CalendarNotepad.Models
 | 
				
			|||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// 工作日期
 | 
					        /// 工作日期
 | 
				
			||||||
        /// </summary>
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [Key]
 | 
				
			||||||
        public string? WorkDay { get; set; }
 | 
					        public string? WorkDay { get; set; }
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// 时间段
 | 
					 | 
				
			||||||
        /// </summary>
 | 
					 | 
				
			||||||
        public string? DayRange { get; set; }
 | 
					 | 
				
			||||||
        /// <summary>
 | 
					 | 
				
			||||||
        /// 内容
 | 
					        /// 内容
 | 
				
			||||||
        /// </summary>
 | 
					        /// </summary>
 | 
				
			||||||
        public string? WorkMessage { get; set; }
 | 
					        public string? WorkMessage { get; set; }
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										21
									
								
								CalendarNotepad/Models/WorkUnitPlusFile.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								CalendarNotepad/Models/WorkUnitPlusFile.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,21 @@
 | 
				
			|||||||
 | 
					namespace CalendarNotepad.Models
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    /// <summary>
 | 
				
			||||||
 | 
					    /// 工作单元附件对应关系
 | 
				
			||||||
 | 
					    /// </summary>
 | 
				
			||||||
 | 
					    public class WorkUnitPlusFile
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 工作日期
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        public string? WorkDay { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 文件指纹
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        public string? FileKey { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 文件名称
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        public string? FileName { get; set; }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										75
									
								
								CalendarNotepad/WorkMain.Designer.cs
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										75
									
								
								CalendarNotepad/WorkMain.Designer.cs
									
									
									
										generated
									
									
									
								
							@ -25,6 +25,7 @@
 | 
				
			|||||||
        /// the contents of this method with the code editor.
 | 
					        /// the contents of this method with the code editor.
 | 
				
			||||||
        /// </summary>
 | 
					        /// </summary>
 | 
				
			||||||
        private void InitializeComponent() {
 | 
					        private void InitializeComponent() {
 | 
				
			||||||
 | 
					            components = new System.ComponentModel.Container();
 | 
				
			||||||
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(WorkMain));
 | 
					            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(WorkMain));
 | 
				
			||||||
            tabControl1 = new TabControl();
 | 
					            tabControl1 = new TabControl();
 | 
				
			||||||
            tpWorkManage = new TabPage();
 | 
					            tpWorkManage = new TabPage();
 | 
				
			||||||
@ -47,9 +48,15 @@
 | 
				
			|||||||
            radioButton5 = new RadioButton();
 | 
					            radioButton5 = new RadioButton();
 | 
				
			||||||
            mcWorkDay = new MonthCalendar();
 | 
					            mcWorkDay = new MonthCalendar();
 | 
				
			||||||
            rtbMsg = new RichTextBox();
 | 
					            rtbMsg = new RichTextBox();
 | 
				
			||||||
 | 
					            FileListView = new ListView();
 | 
				
			||||||
 | 
					            cms_FileList = new ContextMenuStrip(components);
 | 
				
			||||||
 | 
					            删除ToolStripMenuItem = new ToolStripMenuItem();
 | 
				
			||||||
 | 
					            导入ToolStripMenuItem = new ToolStripMenuItem();
 | 
				
			||||||
            toolStrip1 = new ToolStrip();
 | 
					            toolStrip1 = new ToolStrip();
 | 
				
			||||||
            tsp_Copy = new ToolStripButton();
 | 
					            tsp_Copy = new ToolStripButton();
 | 
				
			||||||
            tsb_palse = new ToolStripButton();
 | 
					            tsb_palse = new ToolStripButton();
 | 
				
			||||||
 | 
					            OpenFileDlg = new OpenFileDialog();
 | 
				
			||||||
 | 
					            下载ToolStripMenuItem = new ToolStripMenuItem();
 | 
				
			||||||
            tabControl1.SuspendLayout();
 | 
					            tabControl1.SuspendLayout();
 | 
				
			||||||
            tpWorkManage.SuspendLayout();
 | 
					            tpWorkManage.SuspendLayout();
 | 
				
			||||||
            ((System.ComponentModel.ISupportInitialize)splitContainer1).BeginInit();
 | 
					            ((System.ComponentModel.ISupportInitialize)splitContainer1).BeginInit();
 | 
				
			||||||
@ -61,6 +68,7 @@
 | 
				
			|||||||
            flowLayoutPanel1.SuspendLayout();
 | 
					            flowLayoutPanel1.SuspendLayout();
 | 
				
			||||||
            gbWorkTypes.SuspendLayout();
 | 
					            gbWorkTypes.SuspendLayout();
 | 
				
			||||||
            C_WorkTypes.SuspendLayout();
 | 
					            C_WorkTypes.SuspendLayout();
 | 
				
			||||||
 | 
					            cms_FileList.SuspendLayout();
 | 
				
			||||||
            toolStrip1.SuspendLayout();
 | 
					            toolStrip1.SuspendLayout();
 | 
				
			||||||
            SuspendLayout();
 | 
					            SuspendLayout();
 | 
				
			||||||
            // 
 | 
					            // 
 | 
				
			||||||
@ -71,7 +79,7 @@
 | 
				
			|||||||
            tabControl1.Location = new Point(0,0);
 | 
					            tabControl1.Location = new Point(0,0);
 | 
				
			||||||
            tabControl1.Name = "tabControl1";
 | 
					            tabControl1.Name = "tabControl1";
 | 
				
			||||||
            tabControl1.SelectedIndex = 0;
 | 
					            tabControl1.SelectedIndex = 0;
 | 
				
			||||||
            tabControl1.Size = new Size(695,490);
 | 
					            tabControl1.Size = new Size(717,443);
 | 
				
			||||||
            tabControl1.TabIndex = 0;
 | 
					            tabControl1.TabIndex = 0;
 | 
				
			||||||
            // 
 | 
					            // 
 | 
				
			||||||
            // tpWorkManage
 | 
					            // tpWorkManage
 | 
				
			||||||
@ -80,7 +88,7 @@
 | 
				
			|||||||
            tpWorkManage.Location = new Point(4,26);
 | 
					            tpWorkManage.Location = new Point(4,26);
 | 
				
			||||||
            tpWorkManage.Name = "tpWorkManage";
 | 
					            tpWorkManage.Name = "tpWorkManage";
 | 
				
			||||||
            tpWorkManage.Padding = new Padding(3);
 | 
					            tpWorkManage.Padding = new Padding(3);
 | 
				
			||||||
            tpWorkManage.Size = new Size(687,460);
 | 
					            tpWorkManage.Size = new Size(709,413);
 | 
				
			||||||
            tpWorkManage.TabIndex = 1;
 | 
					            tpWorkManage.TabIndex = 1;
 | 
				
			||||||
            tpWorkManage.Text = "录入记录";
 | 
					            tpWorkManage.Text = "录入记录";
 | 
				
			||||||
            tpWorkManage.UseVisualStyleBackColor = true;
 | 
					            tpWorkManage.UseVisualStyleBackColor = true;
 | 
				
			||||||
@ -102,8 +110,9 @@
 | 
				
			|||||||
            // splitContainer1.Panel2
 | 
					            // splitContainer1.Panel2
 | 
				
			||||||
            // 
 | 
					            // 
 | 
				
			||||||
            splitContainer1.Panel2.Controls.Add(rtbMsg);
 | 
					            splitContainer1.Panel2.Controls.Add(rtbMsg);
 | 
				
			||||||
 | 
					            splitContainer1.Panel2.Controls.Add(FileListView);
 | 
				
			||||||
            splitContainer1.Panel2.Controls.Add(toolStrip1);
 | 
					            splitContainer1.Panel2.Controls.Add(toolStrip1);
 | 
				
			||||||
            splitContainer1.Size = new Size(681,454);
 | 
					            splitContainer1.Size = new Size(703,407);
 | 
				
			||||||
            splitContainer1.SplitterDistance = 236;
 | 
					            splitContainer1.SplitterDistance = 236;
 | 
				
			||||||
            splitContainer1.TabIndex = 9;
 | 
					            splitContainer1.TabIndex = 9;
 | 
				
			||||||
            // 
 | 
					            // 
 | 
				
			||||||
@ -178,7 +187,7 @@
 | 
				
			|||||||
            flowLayoutPanel1.AutoSize = true;
 | 
					            flowLayoutPanel1.AutoSize = true;
 | 
				
			||||||
            flowLayoutPanel1.Controls.Add(btSave);
 | 
					            flowLayoutPanel1.Controls.Add(btSave);
 | 
				
			||||||
            flowLayoutPanel1.Controls.Add(btReset);
 | 
					            flowLayoutPanel1.Controls.Add(btReset);
 | 
				
			||||||
            flowLayoutPanel1.Location = new Point(6,420);
 | 
					            flowLayoutPanel1.Location = new Point(6,373);
 | 
				
			||||||
            flowLayoutPanel1.Name = "flowLayoutPanel1";
 | 
					            flowLayoutPanel1.Name = "flowLayoutPanel1";
 | 
				
			||||||
            flowLayoutPanel1.Size = new Size(220,29);
 | 
					            flowLayoutPanel1.Size = new Size(220,29);
 | 
				
			||||||
            flowLayoutPanel1.TabIndex = 8;
 | 
					            flowLayoutPanel1.TabIndex = 8;
 | 
				
			||||||
@ -297,17 +306,51 @@
 | 
				
			|||||||
            rtbMsg.EnableAutoDragDrop = true;
 | 
					            rtbMsg.EnableAutoDragDrop = true;
 | 
				
			||||||
            rtbMsg.Location = new Point(0,25);
 | 
					            rtbMsg.Location = new Point(0,25);
 | 
				
			||||||
            rtbMsg.Name = "rtbMsg";
 | 
					            rtbMsg.Name = "rtbMsg";
 | 
				
			||||||
            rtbMsg.Size = new Size(441,429);
 | 
					            rtbMsg.Size = new Size(463,297);
 | 
				
			||||||
            rtbMsg.TabIndex = 7;
 | 
					            rtbMsg.TabIndex = 7;
 | 
				
			||||||
            rtbMsg.Text = "";
 | 
					            rtbMsg.Text = "";
 | 
				
			||||||
            rtbMsg.LinkClicked += rtbMsg_LinkClicked;
 | 
					            rtbMsg.LinkClicked += rtbMsg_LinkClicked;
 | 
				
			||||||
 | 
					            rtbMsg.TextChanged += rtbMsg_TextChanged_1;
 | 
				
			||||||
 | 
					            // 
 | 
				
			||||||
 | 
					            // FileListView
 | 
				
			||||||
 | 
					            // 
 | 
				
			||||||
 | 
					            FileListView.ContextMenuStrip = cms_FileList;
 | 
				
			||||||
 | 
					            FileListView.Dock = DockStyle.Bottom;
 | 
				
			||||||
 | 
					            FileListView.FullRowSelect = true;
 | 
				
			||||||
 | 
					            FileListView.GridLines = true;
 | 
				
			||||||
 | 
					            FileListView.Location = new Point(0,322);
 | 
				
			||||||
 | 
					            FileListView.Name = "FileListView";
 | 
				
			||||||
 | 
					            FileListView.Size = new Size(463,85);
 | 
				
			||||||
 | 
					            FileListView.TabIndex = 9;
 | 
				
			||||||
 | 
					            FileListView.UseCompatibleStateImageBehavior = false;
 | 
				
			||||||
 | 
					            FileListView.View = View.Details;
 | 
				
			||||||
 | 
					            // 
 | 
				
			||||||
 | 
					            // cms_FileList
 | 
				
			||||||
 | 
					            // 
 | 
				
			||||||
 | 
					            cms_FileList.Items.AddRange(new ToolStripItem[] { 删除ToolStripMenuItem,导入ToolStripMenuItem,下载ToolStripMenuItem });
 | 
				
			||||||
 | 
					            cms_FileList.Name = "contextMenuStrip1";
 | 
				
			||||||
 | 
					            cms_FileList.Size = new Size(181,92);
 | 
				
			||||||
 | 
					            // 
 | 
				
			||||||
 | 
					            // 删除ToolStripMenuItem
 | 
				
			||||||
 | 
					            // 
 | 
				
			||||||
 | 
					            删除ToolStripMenuItem.Name = "删除ToolStripMenuItem";
 | 
				
			||||||
 | 
					            删除ToolStripMenuItem.Size = new Size(180,22);
 | 
				
			||||||
 | 
					            删除ToolStripMenuItem.Text = "删除";
 | 
				
			||||||
 | 
					            删除ToolStripMenuItem.Click += 删除ToolStripMenuItem_Click;
 | 
				
			||||||
 | 
					            // 
 | 
				
			||||||
 | 
					            // 导入ToolStripMenuItem
 | 
				
			||||||
 | 
					            // 
 | 
				
			||||||
 | 
					            导入ToolStripMenuItem.Name = "导入ToolStripMenuItem";
 | 
				
			||||||
 | 
					            导入ToolStripMenuItem.Size = new Size(180,22);
 | 
				
			||||||
 | 
					            导入ToolStripMenuItem.Text = "导入";
 | 
				
			||||||
 | 
					            导入ToolStripMenuItem.Click += 导入ToolStripMenuItem_Click;
 | 
				
			||||||
            // 
 | 
					            // 
 | 
				
			||||||
            // toolStrip1
 | 
					            // toolStrip1
 | 
				
			||||||
            // 
 | 
					            // 
 | 
				
			||||||
            toolStrip1.Items.AddRange(new ToolStripItem[] { tsp_Copy,tsb_palse });
 | 
					            toolStrip1.Items.AddRange(new ToolStripItem[] { tsp_Copy,tsb_palse });
 | 
				
			||||||
            toolStrip1.Location = new Point(0,0);
 | 
					            toolStrip1.Location = new Point(0,0);
 | 
				
			||||||
            toolStrip1.Name = "toolStrip1";
 | 
					            toolStrip1.Name = "toolStrip1";
 | 
				
			||||||
            toolStrip1.Size = new Size(441,25);
 | 
					            toolStrip1.Size = new Size(463,25);
 | 
				
			||||||
            toolStrip1.TabIndex = 8;
 | 
					            toolStrip1.TabIndex = 8;
 | 
				
			||||||
            toolStrip1.Text = "toolStrip1";
 | 
					            toolStrip1.Text = "toolStrip1";
 | 
				
			||||||
            // 
 | 
					            // 
 | 
				
			||||||
@ -331,11 +374,22 @@
 | 
				
			|||||||
            tsb_palse.Text = "粘贴";
 | 
					            tsb_palse.Text = "粘贴";
 | 
				
			||||||
            tsb_palse.Click += tsb_palse_Click;
 | 
					            tsb_palse.Click += tsb_palse_Click;
 | 
				
			||||||
            // 
 | 
					            // 
 | 
				
			||||||
 | 
					            // OpenFileDlg
 | 
				
			||||||
 | 
					            // 
 | 
				
			||||||
 | 
					            OpenFileDlg.Multiselect = true;
 | 
				
			||||||
 | 
					            // 
 | 
				
			||||||
 | 
					            // 下载ToolStripMenuItem
 | 
				
			||||||
 | 
					            // 
 | 
				
			||||||
 | 
					            下载ToolStripMenuItem.Name = "下载ToolStripMenuItem";
 | 
				
			||||||
 | 
					            下载ToolStripMenuItem.Size = new Size(180,22);
 | 
				
			||||||
 | 
					            下载ToolStripMenuItem.Text = "下载";
 | 
				
			||||||
 | 
					            下载ToolStripMenuItem.Click += 下载ToolStripMenuItem_Click;
 | 
				
			||||||
 | 
					            // 
 | 
				
			||||||
            // WorkMain
 | 
					            // WorkMain
 | 
				
			||||||
            // 
 | 
					            // 
 | 
				
			||||||
            AutoScaleDimensions = new SizeF(7F,17F);
 | 
					            AutoScaleDimensions = new SizeF(7F,17F);
 | 
				
			||||||
            AutoScaleMode = AutoScaleMode.Font;
 | 
					            AutoScaleMode = AutoScaleMode.Font;
 | 
				
			||||||
            ClientSize = new Size(695,490);
 | 
					            ClientSize = new Size(717,443);
 | 
				
			||||||
            Controls.Add(tabControl1);
 | 
					            Controls.Add(tabControl1);
 | 
				
			||||||
            Name = "WorkMain";
 | 
					            Name = "WorkMain";
 | 
				
			||||||
            StartPosition = FormStartPosition.CenterScreen;
 | 
					            StartPosition = FormStartPosition.CenterScreen;
 | 
				
			||||||
@ -357,6 +411,7 @@
 | 
				
			|||||||
            gbWorkTypes.ResumeLayout(false);
 | 
					            gbWorkTypes.ResumeLayout(false);
 | 
				
			||||||
            C_WorkTypes.ResumeLayout(false);
 | 
					            C_WorkTypes.ResumeLayout(false);
 | 
				
			||||||
            C_WorkTypes.PerformLayout();
 | 
					            C_WorkTypes.PerformLayout();
 | 
				
			||||||
 | 
					            cms_FileList.ResumeLayout(false);
 | 
				
			||||||
            toolStrip1.ResumeLayout(false);
 | 
					            toolStrip1.ResumeLayout(false);
 | 
				
			||||||
            toolStrip1.PerformLayout();
 | 
					            toolStrip1.PerformLayout();
 | 
				
			||||||
            ResumeLayout(false);
 | 
					            ResumeLayout(false);
 | 
				
			||||||
@ -388,5 +443,11 @@
 | 
				
			|||||||
        private ToolStrip toolStrip1;
 | 
					        private ToolStrip toolStrip1;
 | 
				
			||||||
        private ToolStripButton tsp_Copy;
 | 
					        private ToolStripButton tsp_Copy;
 | 
				
			||||||
        private ToolStripButton tsb_palse;
 | 
					        private ToolStripButton tsb_palse;
 | 
				
			||||||
 | 
					        private ListView FileListView;
 | 
				
			||||||
 | 
					        private ContextMenuStrip cms_FileList;
 | 
				
			||||||
 | 
					        private ToolStripMenuItem 删除ToolStripMenuItem;
 | 
				
			||||||
 | 
					        private ToolStripMenuItem 导入ToolStripMenuItem;
 | 
				
			||||||
 | 
					        private OpenFileDialog OpenFileDlg;
 | 
				
			||||||
 | 
					        private ToolStripMenuItem 下载ToolStripMenuItem;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -25,6 +25,16 @@ namespace CalendarNotepad
 | 
				
			|||||||
                    rab.CheckedChanged += Rab_CheckedChanged;
 | 
					                    rab.CheckedChanged += Rab_CheckedChanged;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					            var fieViewWidth = this.FileListView.Width;
 | 
				
			||||||
 | 
					            this.FileListView.Columns.Add(new ColumnHeader {
 | 
				
			||||||
 | 
					                Text = "附件",Width = fieViewWidth - 200,TextAlign = HorizontalAlignment.Left,
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					            this.FileListView.Columns.Add(new ColumnHeader {
 | 
				
			||||||
 | 
					                Text = "类型",Width = 100,TextAlign = HorizontalAlignment.Left,
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					            this.FileListView.Columns.Add(new ColumnHeader {
 | 
				
			||||||
 | 
					                Text = "文件指纹",Width = 100,TextAlign = HorizontalAlignment.Left,
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private void Rab_CheckedChanged(object? sender,EventArgs e) {
 | 
					        private void Rab_CheckedChanged(object? sender,EventArgs e) {
 | 
				
			||||||
@ -44,18 +54,28 @@ namespace CalendarNotepad
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        private void mcWorkDay_DateChanged(object sender,DateRangeEventArgs e) {
 | 
					        private void mcWorkDay_DateChanged(object sender,DateRangeEventArgs e) {
 | 
				
			||||||
            var wd = this.mcWorkDay.SelectionStart.ToString("yyyyMMdd");
 | 
					            var wd = this.mcWorkDay.SelectionStart.ToString("yyyyMMdd");
 | 
				
			||||||
            var sr = "全天";
 | 
					            this.FileListView.Items.Clear();
 | 
				
			||||||
            var qu = this.Db.Queryable<WorkUnit>().Where(a => a.DayRange == sr && a.WorkDay == wd).ToList();
 | 
					            var qu = this.Db.Queryable<WorkUnit>().Where(a => a.WorkDay == wd).ToList();
 | 
				
			||||||
 | 
					            if(!qu.Any()) {
 | 
				
			||||||
 | 
					                this.rtbMsg.Text = "";
 | 
				
			||||||
 | 
					                this.SetWorkType("休假");
 | 
				
			||||||
 | 
					                this.SetWorkOut("无");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            if(qu.Any()) {
 | 
					            if(qu.Any()) {
 | 
				
			||||||
                var fir = qu.First();
 | 
					                var fir = qu.First();
 | 
				
			||||||
                this.rtbMsg.Text = fir.WorkMessage;
 | 
					                this.rtbMsg.Text = fir.WorkMessage;
 | 
				
			||||||
                this.SetWorkType(fir.WorkType);
 | 
					                this.SetWorkType(fir.WorkType);
 | 
				
			||||||
                this.SetWorkOut(fir.Workout ?? "无");
 | 
					                this.SetWorkOut(fir.Workout ?? "无");
 | 
				
			||||||
            }
 | 
					
 | 
				
			||||||
            else {
 | 
					                var plsq = this.Db.Queryable<WorkUnitPlusFile>().Where(a => a.WorkDay == wd).ToList();
 | 
				
			||||||
                this.rtbMsg.Text = "";
 | 
					                if(plsq.Any()) {
 | 
				
			||||||
                this.SetWorkType("休假");
 | 
					                    foreach(var i in plsq) {
 | 
				
			||||||
                this.SetWorkOut("无");
 | 
					                        var lit1 = new ListViewItem(i.FileName);
 | 
				
			||||||
 | 
					                        lit1.SubItems.Add(new ListViewItem.ListViewSubItem { Text = "已载入" });
 | 
				
			||||||
 | 
					                        lit1.SubItems.Add(new ListViewItem.ListViewSubItem { Text = i.FileKey });
 | 
				
			||||||
 | 
					                        this.FileListView.Items.Add(lit1);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            this.DataReset();
 | 
					            this.DataReset();
 | 
				
			||||||
            Task.Factory.StartNew(() => {
 | 
					            Task.Factory.StartNew(() => {
 | 
				
			||||||
@ -116,11 +136,10 @@ namespace CalendarNotepad
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        private void btSave_Click(object sender,EventArgs e) {
 | 
					        private void btSave_Click(object sender,EventArgs e) {
 | 
				
			||||||
            var wd = this.mcWorkDay.SelectionStart.ToString("yyyyMMdd");
 | 
					            var wd = this.mcWorkDay.SelectionStart.ToString("yyyyMMdd");
 | 
				
			||||||
            var dr = "全天";
 | 
					 | 
				
			||||||
            var msg = this.rtbMsg.Text;
 | 
					            var msg = this.rtbMsg.Text;
 | 
				
			||||||
            var wt = GetWorkType();
 | 
					            var wt = GetWorkType();
 | 
				
			||||||
            var wo = this.GetWorkOut();
 | 
					            var wo = this.GetWorkOut();
 | 
				
			||||||
            var exp = Expressionable.Create<WorkUnit>().And(a => a.DayRange == dr && a.WorkDay == wd).ToExpression();
 | 
					            var exp = Expressionable.Create<WorkUnit>().And(a => a.WorkDay == wd).ToExpression();
 | 
				
			||||||
            var qu = this.Db.Queryable<WorkUnit>().Where(exp).ToList();
 | 
					            var qu = this.Db.Queryable<WorkUnit>().Where(exp).ToList();
 | 
				
			||||||
            if(qu.Any() && msg.IsNullOrEmpty()) {
 | 
					            if(qu.Any() && msg.IsNullOrEmpty()) {
 | 
				
			||||||
                this.Db.Deleteable<WorkUnit>().Where(exp).ExecuteCommand();
 | 
					                this.Db.Deleteable<WorkUnit>().Where(exp).ExecuteCommand();
 | 
				
			||||||
@ -138,7 +157,7 @@ namespace CalendarNotepad
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
            if(!qu.Any() && msg.IsNotNullOrEmpty()) {
 | 
					            if(!qu.Any() && msg.IsNotNullOrEmpty()) {
 | 
				
			||||||
                this.Db.Insertable<WorkUnit>(new WorkUnit {
 | 
					                this.Db.Insertable<WorkUnit>(new WorkUnit {
 | 
				
			||||||
                    DayRange = dr,WorkDay = wd,
 | 
					                    WorkDay = wd,
 | 
				
			||||||
                    WorkMessage = msg,WorkType = wt,Workout = wo,
 | 
					                    WorkMessage = msg,WorkType = wt,Workout = wo,
 | 
				
			||||||
                }).ExecuteCommand();
 | 
					                }).ExecuteCommand();
 | 
				
			||||||
                this.DataReset();
 | 
					                this.DataReset();
 | 
				
			||||||
@ -206,5 +225,85 @@ namespace CalendarNotepad
 | 
				
			|||||||
        private void tsb_palse_Click(object sender,EventArgs e) {
 | 
					        private void tsb_palse_Click(object sender,EventArgs e) {
 | 
				
			||||||
            this.rtbMsg.AppendText(Clipboard.GetText());
 | 
					            this.rtbMsg.AppendText(Clipboard.GetText());
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private void rtbMsg_TextChanged_1(object sender,EventArgs e) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private void 删除ToolStripMenuItem_Click(object sender,EventArgs e) {
 | 
				
			||||||
 | 
					            var wd = this.mcWorkDay.SelectionStart.ToString("yyyyMMdd");
 | 
				
			||||||
 | 
					            var items = this.FileListView.SelectedItems;
 | 
				
			||||||
 | 
					            if(items.Count == 0) {
 | 
				
			||||||
 | 
					                MessageBox.Show("没有选择列表项!");
 | 
				
			||||||
 | 
					                return;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if(MessageBox.Show($"共选择了{items.Count}项,是否全部删除?","警告",MessageBoxButtons.OKCancel) == DialogResult.Cancel) {
 | 
				
			||||||
 | 
					                return;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            foreach(ListViewItem i in items) {
 | 
				
			||||||
 | 
					                this.FileListView.Items.Remove(i);
 | 
				
			||||||
 | 
					                this.Db.Deleteable<WorkUnitPlusFile>()
 | 
				
			||||||
 | 
					                    .Where(a => a.WorkDay == wd && a.FileKey == i.SubItems[2].Text)
 | 
				
			||||||
 | 
					                    .ExecuteCommand();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private void 导入ToolStripMenuItem_Click(object sender,EventArgs e) {
 | 
				
			||||||
 | 
					            var dlgFile = OpenFileDlg.ShowDialog();
 | 
				
			||||||
 | 
					            if(dlgFile == DialogResult.Cancel) {
 | 
				
			||||||
 | 
					                return;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if(OpenFileDlg.SafeFileNames.Length == 0) {
 | 
				
			||||||
 | 
					                return;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            var wd = this.mcWorkDay.SelectionStart.ToString("yyyyMMdd");
 | 
				
			||||||
 | 
					            foreach(var f in OpenFileDlg.FileNames) {
 | 
				
			||||||
 | 
					                var lit1 = new ListViewItem(Path.GetFileName(f));
 | 
				
			||||||
 | 
					                lit1.SubItems.Add(new ListViewItem.ListViewSubItem { Text = "导入中" });
 | 
				
			||||||
 | 
					                lit1.SubItems.Add(new ListViewItem.ListViewSubItem { Text = "" });
 | 
				
			||||||
 | 
					                this.FileListView.Items.Add(lit1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                var fc = PlusFile.LoadFile(f);
 | 
				
			||||||
 | 
					                var fk = PlusFile.GetMd5(fc);
 | 
				
			||||||
 | 
					                lit1.SubItems[2].Text = fk;
 | 
				
			||||||
 | 
					                var pfu = new PlusFileUnit { FileContent = fc,FileId = fk };
 | 
				
			||||||
 | 
					                var qu = this.Db.Queryable<PlusFileUnit>().Where(a => a.FileId == fk);
 | 
				
			||||||
 | 
					                if(!qu.Any()) {
 | 
				
			||||||
 | 
					                    this.Db.Insertable(pfu).ExecuteCommand();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                this.Db.Insertable(new WorkUnitPlusFile {
 | 
				
			||||||
 | 
					                    FileKey = fk,
 | 
				
			||||||
 | 
					                    WorkDay = wd,
 | 
				
			||||||
 | 
					                    FileName = Path.GetFileName(f),
 | 
				
			||||||
 | 
					                }).ExecuteCommand();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private void 下载ToolStripMenuItem_Click(object sender,EventArgs e) {
 | 
				
			||||||
 | 
					            var items = this.FileListView.SelectedItems;
 | 
				
			||||||
 | 
					            if(items.Count == 0) {
 | 
				
			||||||
 | 
					                MessageBox.Show("没有选择文件");
 | 
				
			||||||
 | 
					                return;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            foreach(ListViewItem i in items) {
 | 
				
			||||||
 | 
					                var sdlg = new SaveFileDialog {
 | 
				
			||||||
 | 
					                    Title = "保存附件",
 | 
				
			||||||
 | 
					                    FileName = Path.GetFileName(i.Text),
 | 
				
			||||||
 | 
					                };
 | 
				
			||||||
 | 
					                var dresult = sdlg.ShowDialog();
 | 
				
			||||||
 | 
					                if(dresult != DialogResult.OK) {
 | 
				
			||||||
 | 
					                    return;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                var filePath = sdlg.FileName;
 | 
				
			||||||
 | 
					                var fileKey = i.SubItems[2].Text;
 | 
				
			||||||
 | 
					                var qu = this.Db.Queryable<PlusFileUnit>().Where(a => a.FileId == fileKey).ToList();
 | 
				
			||||||
 | 
					                if(qu.Any()) {
 | 
				
			||||||
 | 
					                    var fir = qu.First();
 | 
				
			||||||
 | 
					                    if(fir.FileContent != null) {
 | 
				
			||||||
 | 
					                        PlusFile.SaveFile(filePath,fir.FileContent);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -117,6 +117,9 @@
 | 
				
			|||||||
  <resheader name="writer">
 | 
					  <resheader name="writer">
 | 
				
			||||||
    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
 | 
					    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
 | 
				
			||||||
  </resheader>
 | 
					  </resheader>
 | 
				
			||||||
 | 
					  <metadata name="cms_FileList.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
 | 
				
			||||||
 | 
					    <value>127, 17</value>
 | 
				
			||||||
 | 
					  </metadata>
 | 
				
			||||||
  <metadata name="toolStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
 | 
					  <metadata name="toolStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
 | 
				
			||||||
    <value>17, 17</value>
 | 
					    <value>17, 17</value>
 | 
				
			||||||
  </metadata>
 | 
					  </metadata>
 | 
				
			||||||
@ -130,4 +133,10 @@
 | 
				
			|||||||
        AAAAAElFTkSuQmCC
 | 
					        AAAAAElFTkSuQmCC
 | 
				
			||||||
</value>
 | 
					</value>
 | 
				
			||||||
  </data>
 | 
					  </data>
 | 
				
			||||||
 | 
					  <metadata name="OpenFileDlg.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
 | 
				
			||||||
 | 
					    <value>248, 17</value>
 | 
				
			||||||
 | 
					  </metadata>
 | 
				
			||||||
 | 
					  <metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
 | 
				
			||||||
 | 
					    <value>36</value>
 | 
				
			||||||
 | 
					  </metadata>
 | 
				
			||||||
</root>
 | 
					</root>
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user