Commit b2e1c0e1 by 陶然

init

parent c6650ecb
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Kivii.Client.Lims.ReportPrinter
{
internal class Configs
{
public const string TableUiSetting = "ui_settings";
public const string RoutePrintPoolQuery = "/Restful/Kivii.PrintPools.Entities.PrintPool/Query";
public const string RoutePrintPoolCreate = "/Restful/Kivii.PrintPools.Entities.PrintPool/Create";
public const string RoutePrintPoolMark = "/Restful/Kivii.PrintPools.Entities.PrintPool/Mark";
public const string RoutePrintPoolComplete = "/Restful/Kivii.PrintPools.Entities.PrintPool/Complete";
public const string RouteReportPrintAssign = "/Restful/Kivii.Lims.Entities.Report/Assign";
}
}
using Kivii.DataAnnotations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Kivii.Client.Lims.ReportPrinter.Entities
{
public class PrintPool : EntityWithMetadata
{
#region 关联相关
[IgnoreUpdate]
[Required]
public Guid OwnerKvid { get; set; }
[StringLength(500)]
public string OwnerName { get; set; }
#endregion
[ApiMember(Description = "打印标题")]
[IgnoreUpdate]
[StringLength(100), Required]
public string Title { get; set; }
[ApiMember(Description = "打印分类")]
[InternalSetter]
[StringLength(50), Default("")]
public string Category { get; set; }
[ApiMember(Description = "是否打印")]
[InternalSetter]
public bool IsPrint { get; set; }
[ApiMember(Description = "打印份数,默认0份")]
[Default(0)]
public int Count { get; set; }
[ApiMember(Description = "打印时间")]
[InternalSetter]
public DateTime? PrintTime { get; set; }
[ApiMember(Description = "打印结果")]
[InternalSetter]
[StringLength(500), Default("")]
public string Result { get; set; }
[ApiMember(Description = "文件地址,要打印的文件地址")]
[StringLength(1000), Required]
public string FilePath { get; set; }
#region 文本 摘要 备注
[ApiMember(Description = "摘要,最大500字")]
[IgnoreUpdate]
[StringLength(500), Default("")]
public string Summary { get; set; }
[ApiMember(Description = "备注,最大3000字")]
[StringLength(3000), Default("")]
public string Remark { get; set; }
#endregion
[ApiMember(Description = "操作日期")]
[IgnoreUpdate]
[Required]
public DateTime OperateTime { get; set; }
[InternalSetter]
[DefaultEmptyGuid]
public Guid OperatorKvid { get; set; }
[ApiMember(Description = "操作人")]
[InternalSetter]
[StringLength(100), Default("")]
public string OperatorName { get; set; }
[ApiMember(Description = "创建人Kvid ")]
[IgnoreUpdate]
[CurrentMemberKvid]
public Guid CreatorKvid { get; set; }
[ApiMember(Description = "创建人")]
[IgnoreUpdate]
[StringLength(50), CurrentMemberName]
public string CreatorName { get; set; }
[ApiMember(Description = "更新人Kvid ")]
[CurrentMemberKvid]
public Guid UpdaterKvid { get; set; }
[ApiMember(Description = "更新人")]
[StringLength(50), CurrentMemberName]
public string UpdaterName { get; set; }
public bool IsSelected { get; set; }
public string PrintStatus { get; set; }
public bool IsSearch { get; set; }
public string AccepterName
{
get
{
var rtns = Metadata.ContainsKey("OperatorName") ? Metadata["OperatorName"] : string.Empty;
return rtns;
}
set
{
if (Metadata.IsNullOrEmpty()) Metadata = new Dictionary<string, string>();
value = Metadata["OperatorName"];
}
}
public string IsPasteSample
{
get
{
var isPasteSample = Metadata.ContainsKey("IsPasteSample") ? Metadata["IsPasteSample"] : string.Empty;
var rtns = "";
if (bool.TryParse(isPasteSample, out bool isPaste))
{
if (isPaste) rtns = "是";
else rtns = "否";
}
return rtns;
}
set
{
if (Metadata.IsNullOrEmpty()) Metadata = new Dictionary<string, string>();
value = Metadata["IsPasteSample"];
}
}
}
}
using Kivii.Configuration;
using Kivii.DataAnnotations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Kivii.Client.Lims.ReportPrinter.Entities
{
[Alias(Configs.TableUiSetting)]
public class UiSetting : Entity
{
[Required]
[Unique("Form-Control")]
public string FormName { get; set; }
[Required]
[Unique("Form-Control")]
public string ControlName { get; set; }
[Default("")]
public string ControlValue { get; set; }
}
}
File added
......@@ -31,7 +31,7 @@
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
this.OperatorName = new System.Windows.Forms.DataGridViewTextBoxColumn();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmMain));
this.cbxFirstPage = new System.Windows.Forms.CheckBox();
this.btnChangeQuantity = new System.Windows.Forms.Button();
this.nudQuantity = new System.Windows.Forms.NumericUpDown();
......@@ -41,26 +41,12 @@
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.label5 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.OperateTime = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.OwnerName = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Title = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.IsSearch = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.pictureBox3 = new System.Windows.Forms.PictureBox();
this.pictureBox2 = new System.Windows.Forms.PictureBox();
this.cbxJianDu = new System.Windows.Forms.CheckBox();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.label4 = new System.Windows.Forms.Label();
this.lblUserInfo = new System.Windows.Forms.Label();
this.AccepterName = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.IsPrint = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.gridPrintJobs = new System.Windows.Forms.DataGridView();
this.Column6 = new System.Windows.Forms.DataGridViewCheckBoxColumn();
this.Summary = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Remark = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.IsPasteSample = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.PrintStatus = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.PrintTime = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.lblPrinterName = new System.Windows.Forms.Label();
this.btnDisconnect = new System.Windows.Forms.Button();
......@@ -71,42 +57,47 @@
this.label1 = new System.Windows.Forms.Label();
this.tbxServiceName = new System.Windows.Forms.TextBox();
this.lblServiceName = new System.Windows.Forms.Label();
this.panel2 = new System.Windows.Forms.Panel();
this.tbSearch = new System.Windows.Forms.TextBox();
this.btnSearch = new System.Windows.Forms.Button();
this.btnPrint = new System.Windows.Forms.Button();
this.btnRefresh = new System.Windows.Forms.Button();
this.btnCompletePrintJob = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.cbxPrintAutoComplete = new System.Windows.Forms.CheckBox();
this.cbxPdfRemoveHeader = new System.Windows.Forms.CheckBox();
this.panel4 = new System.Windows.Forms.Panel();
this.cbxPrinter = new System.Windows.Forms.ComboBox();
this.groupReport = new System.Windows.Forms.GroupBox();
this.lblMessage = new System.Windows.Forms.Label();
this.groupReport = new System.Windows.Forms.GroupBox();
this.gridPrintJobs = new System.Windows.Forms.DataGridView();
this.Column6 = new System.Windows.Forms.DataGridViewCheckBoxColumn();
this.IsPrint = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.IsSearch = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Title = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.OwnerName = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.OperateTime = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.AccepterName = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.OperatorName = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Summary = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Remark = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.IsPasteSample = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.PrintStatus = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.PrintTime = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.panel2 = new System.Windows.Forms.Panel();
this.tbSearch = new System.Windows.Forms.TextBox();
this.btnSearch = new System.Windows.Forms.Button();
this.btnPrint = new System.Windows.Forms.Button();
this.btnRefresh = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.nudQuantity)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();
this.groupBox3.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.gridPrintJobs)).BeginInit();
this.groupBox2.SuspendLayout();
this.panel2.SuspendLayout();
this.groupBox1.SuspendLayout();
this.panel4.SuspendLayout();
this.groupReport.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.gridPrintJobs)).BeginInit();
this.panel2.SuspendLayout();
this.SuspendLayout();
//
// OperatorName
//
this.OperatorName.DataPropertyName = "OperatorName";
this.OperatorName.Frozen = true;
this.OperatorName.HeaderText = "签发";
this.OperatorName.MinimumWidth = 80;
this.OperatorName.Name = "OperatorName";
this.OperatorName.ReadOnly = true;
this.OperatorName.Width = 80;
//
// cbxFirstPage
//
this.cbxFirstPage.Dock = System.Windows.Forms.DockStyle.Top;
......@@ -118,6 +109,7 @@
this.cbxFirstPage.TabIndex = 33;
this.cbxFirstPage.Text = "仅打印首页";
this.cbxFirstPage.UseVisualStyleBackColor = true;
this.cbxFirstPage.Visible = false;
//
// btnChangeQuantity
//
......@@ -131,6 +123,7 @@
this.btnChangeQuantity.TabIndex = 32;
this.btnChangeQuantity.Text = "批量修改";
this.btnChangeQuantity.UseVisualStyleBackColor = false;
this.btnChangeQuantity.Click += new System.EventHandler(this.btnChangeQuantity_Click);
//
// nudQuantity
//
......@@ -165,6 +158,7 @@
this.btnSelectCancel.TabIndex = 30;
this.btnSelectCancel.Text = "取消选中";
this.btnSelectCancel.UseVisualStyleBackColor = false;
this.btnSelectCancel.Click += new System.EventHandler(this.btnSelectCancel_Click);
//
// btnSelectAll
//
......@@ -178,6 +172,7 @@
this.btnSelectAll.TabIndex = 29;
this.btnSelectAll.Text = "全部选中";
this.btnSelectAll.UseVisualStyleBackColor = false;
this.btnSelectAll.Click += new System.EventHandler(this.btnSelectAll_Click);
//
// label6
//
......@@ -219,55 +214,6 @@
this.label3.TabIndex = 18;
this.label3.Text = "打印已标记";
//
// OperateTime
//
this.OperateTime.DataPropertyName = "OperateTime";
this.OperateTime.Frozen = true;
this.OperateTime.HeaderText = "签发日期";
this.OperateTime.MinimumWidth = 130;
this.OperateTime.Name = "OperateTime";
this.OperateTime.ReadOnly = true;
this.OperateTime.Width = 130;
//
// OwnerName
//
this.OwnerName.DataPropertyName = "OwnerName";
this.OwnerName.Frozen = true;
this.OwnerName.HeaderText = "委托单位";
this.OwnerName.MinimumWidth = 8;
this.OwnerName.Name = "OwnerName";
this.OwnerName.ReadOnly = true;
this.OwnerName.Width = 180;
//
// Count
//
this.Count.DataPropertyName = "Count";
this.Count.Frozen = true;
this.Count.HeaderText = "份数";
this.Count.MinimumWidth = 60;
this.Count.Name = "Count";
this.Count.Width = 60;
//
// Title
//
this.Title.DataPropertyName = "Title";
this.Title.Frozen = true;
this.Title.HeaderText = "报告编号";
this.Title.MinimumWidth = 8;
this.Title.Name = "Title";
this.Title.ReadOnly = true;
this.Title.Width = 170;
//
// IsSearch
//
this.IsSearch.DataPropertyName = "IsSearch";
this.IsSearch.Frozen = true;
this.IsSearch.HeaderText = "手动查询";
this.IsSearch.MinimumWidth = 8;
this.IsSearch.Name = "IsSearch";
this.IsSearch.Visible = false;
this.IsSearch.Width = 150;
//
// pictureBox3
//
this.pictureBox3.BackColor = System.Drawing.Color.Tomato;
......@@ -299,6 +245,7 @@
this.cbxJianDu.TabIndex = 15;
this.cbxJianDu.Text = "监督报告";
this.cbxJianDu.UseVisualStyleBackColor = true;
this.cbxJianDu.Visible = false;
//
// groupBox3
//
......@@ -338,119 +285,6 @@
this.lblUserInfo.TabIndex = 0;
this.lblUserInfo.Text = "NULL";
//
// AccepterName
//
this.AccepterName.DataPropertyName = "AccepterName";
this.AccepterName.Frozen = true;
this.AccepterName.HeaderText = "受理";
this.AccepterName.MinimumWidth = 8;
this.AccepterName.Name = "AccepterName";
this.AccepterName.ReadOnly = true;
this.AccepterName.Width = 150;
//
// IsPrint
//
this.IsPrint.DataPropertyName = "IsPrint";
this.IsPrint.Frozen = true;
this.IsPrint.HeaderText = "是否已打印";
this.IsPrint.MinimumWidth = 8;
this.IsPrint.Name = "IsPrint";
this.IsPrint.Visible = false;
this.IsPrint.Width = 150;
//
// gridPrintJobs
//
this.gridPrintJobs.AllowUserToAddRows = false;
this.gridPrintJobs.AllowUserToDeleteRows = false;
this.gridPrintJobs.AllowUserToResizeRows = false;
this.gridPrintJobs.BackgroundColor = System.Drawing.Color.White;
this.gridPrintJobs.ColumnHeadersHeight = 35;
this.gridPrintJobs.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.Column6,
this.IsPrint,
this.IsSearch,
this.Title,
this.Count,
this.OwnerName,
this.OperateTime,
this.AccepterName,
this.OperatorName,
this.Summary,
this.Remark,
this.IsPasteSample,
this.PrintStatus,
this.PrintTime});
this.gridPrintJobs.Dock = System.Windows.Forms.DockStyle.Fill;
this.gridPrintJobs.Location = new System.Drawing.Point(8, 105);
this.gridPrintJobs.Margin = new System.Windows.Forms.Padding(4);
this.gridPrintJobs.Name = "gridPrintJobs";
this.gridPrintJobs.RowHeadersVisible = false;
this.gridPrintJobs.RowHeadersWidth = 65;
dataGridViewCellStyle3.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.gridPrintJobs.RowsDefaultCellStyle = dataGridViewCellStyle3;
this.gridPrintJobs.RowTemplate.Height = 40;
this.gridPrintJobs.Size = new System.Drawing.Size(2122, 1047);
this.gridPrintJobs.TabIndex = 7;
//
// Column6
//
this.Column6.DataPropertyName = "IsSelected";
dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
dataGridViewCellStyle1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
dataGridViewCellStyle1.NullValue = false;
this.Column6.DefaultCellStyle = dataGridViewCellStyle1;
this.Column6.Frozen = true;
this.Column6.HeaderText = "";
this.Column6.MinimumWidth = 8;
this.Column6.Name = "Column6";
this.Column6.Width = 40;
//
// Summary
//
this.Summary.DataPropertyName = "Summary";
this.Summary.HeaderText = "判定";
this.Summary.MinimumWidth = 80;
this.Summary.Name = "Summary";
this.Summary.ReadOnly = true;
this.Summary.Width = 80;
//
// Remark
//
this.Remark.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.Remark.DataPropertyName = "Remark";
this.Remark.HeaderText = "结论";
this.Remark.MinimumWidth = 100;
this.Remark.Name = "Remark";
this.Remark.ReadOnly = true;
//
// IsPasteSample
//
this.IsPasteSample.DataPropertyName = "IsPasteSample";
this.IsPasteSample.HeaderText = "贴样";
this.IsPasteSample.MinimumWidth = 60;
this.IsPasteSample.Name = "IsPasteSample";
this.IsPasteSample.ReadOnly = true;
this.IsPasteSample.Width = 60;
//
// PrintStatus
//
this.PrintStatus.DataPropertyName = "PrintStatus";
dataGridViewCellStyle2.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.PrintStatus.DefaultCellStyle = dataGridViewCellStyle2;
this.PrintStatus.HeaderText = "打印状态";
this.PrintStatus.MinimumWidth = 120;
this.PrintStatus.Name = "PrintStatus";
this.PrintStatus.ReadOnly = true;
this.PrintStatus.Width = 120;
//
// PrintTime
//
this.PrintTime.DataPropertyName = "PrintTime";
this.PrintTime.HeaderText = "最后打印";
this.PrintTime.MinimumWidth = 150;
this.PrintTime.Name = "PrintTime";
this.PrintTime.Width = 150;
//
// groupBox2
//
this.groupBox2.Controls.Add(this.lblPrinterName);
......@@ -495,6 +329,7 @@
this.btnDisconnect.TabIndex = 7;
this.btnDisconnect.Text = "退出";
this.btnDisconnect.UseVisualStyleBackColor = true;
this.btnDisconnect.Click += new System.EventHandler(this.btnDisconnect_Click);
//
// btnConnect
//
......@@ -505,6 +340,7 @@
this.btnConnect.TabIndex = 6;
this.btnConnect.Text = "登录";
this.btnConnect.UseVisualStyleBackColor = true;
this.btnConnect.Click += new System.EventHandler(this.btnConnect_Click);
//
// tbxPassword
//
......@@ -515,6 +351,7 @@
this.tbxPassword.PasswordChar = '*';
this.tbxPassword.Size = new System.Drawing.Size(234, 31);
this.tbxPassword.TabIndex = 5;
this.tbxPassword.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tbxPassword_KeyDown);
//
// label2
//
......@@ -567,86 +404,21 @@
this.lblServiceName.TabIndex = 0;
this.lblServiceName.Text = "服务地址";
//
// panel2
//
this.panel2.Controls.Add(this.tbSearch);
this.panel2.Controls.Add(this.btnSearch);
this.panel2.Controls.Add(this.btnPrint);
this.panel2.Controls.Add(this.btnRefresh);
this.panel2.Dock = System.Windows.Forms.DockStyle.Top;
this.panel2.Location = new System.Drawing.Point(8, 45);
this.panel2.Margin = new System.Windows.Forms.Padding(4);
this.panel2.Name = "panel2";
this.panel2.Padding = new System.Windows.Forms.Padding(8);
this.panel2.Size = new System.Drawing.Size(2122, 60);
this.panel2.TabIndex = 5;
//
// tbSearch
// btnCompletePrintJob
//
this.tbSearch.Dock = System.Windows.Forms.DockStyle.Fill;
this.tbSearch.Location = new System.Drawing.Point(158, 8);
this.tbSearch.Margin = new System.Windows.Forms.Padding(4);
this.tbSearch.Name = "tbSearch";
this.tbSearch.Size = new System.Drawing.Size(1656, 44);
this.tbSearch.TabIndex = 17;
this.btnCompletePrintJob.BackColor = System.Drawing.SystemColors.Highlight;
this.btnCompletePrintJob.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnCompletePrintJob.Font = new System.Drawing.Font("宋体", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnCompletePrintJob.Location = new System.Drawing.Point(12, 296);
this.btnCompletePrintJob.Margin = new System.Windows.Forms.Padding(4);
this.btnCompletePrintJob.Name = "btnCompletePrintJob";
this.btnCompletePrintJob.Size = new System.Drawing.Size(314, 45);
this.btnCompletePrintJob.TabIndex = 12;
this.btnCompletePrintJob.Text = "标记打印任务";
this.btnCompletePrintJob.UseVisualStyleBackColor = false;
this.btnCompletePrintJob.Click += new System.EventHandler(this.btnCompletePrintJob_Click);
//
// btnSearch
//
this.btnSearch.Dock = System.Windows.Forms.DockStyle.Right;
this.btnSearch.Enabled = false;
this.btnSearch.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnSearch.Font = new System.Drawing.Font("宋体", 10F, System.Drawing.FontStyle.Bold);
this.btnSearch.Location = new System.Drawing.Point(1814, 8);
this.btnSearch.Margin = new System.Windows.Forms.Padding(4);
this.btnSearch.Name = "btnSearch";
this.btnSearch.Size = new System.Drawing.Size(150, 44);
this.btnSearch.TabIndex = 16;
this.btnSearch.Text = "搜索";
this.btnSearch.UseVisualStyleBackColor = false;
//
// btnPrint
//
this.btnPrint.BackColor = System.Drawing.SystemColors.Highlight;
this.btnPrint.Dock = System.Windows.Forms.DockStyle.Right;
this.btnPrint.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnPrint.Font = new System.Drawing.Font("宋体", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnPrint.Location = new System.Drawing.Point(1964, 8);
this.btnPrint.Margin = new System.Windows.Forms.Padding(4);
this.btnPrint.Name = "btnPrint";
this.btnPrint.Size = new System.Drawing.Size(150, 44);
this.btnPrint.TabIndex = 11;
this.btnPrint.Text = "开始打印";
this.btnPrint.UseVisualStyleBackColor = false;
//
// btnRefresh
//
this.btnRefresh.BackColor = System.Drawing.Color.LightGreen;
this.btnRefresh.Dock = System.Windows.Forms.DockStyle.Left;
this.btnRefresh.Enabled = false;
this.btnRefresh.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnRefresh.Font = new System.Drawing.Font("宋体", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnRefresh.Location = new System.Drawing.Point(8, 8);
this.btnRefresh.Margin = new System.Windows.Forms.Padding(4);
this.btnRefresh.Name = "btnRefresh";
this.btnRefresh.Size = new System.Drawing.Size(150, 44);
this.btnRefresh.TabIndex = 10;
this.btnRefresh.Text = "刷新数据";
this.btnRefresh.UseVisualStyleBackColor = false;
//
// btnCompletePrintJob
//
this.btnCompletePrintJob.BackColor = System.Drawing.SystemColors.Highlight;
this.btnCompletePrintJob.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnCompletePrintJob.Font = new System.Drawing.Font("宋体", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnCompletePrintJob.Location = new System.Drawing.Point(12, 296);
this.btnCompletePrintJob.Margin = new System.Windows.Forms.Padding(4);
this.btnCompletePrintJob.Name = "btnCompletePrintJob";
this.btnCompletePrintJob.Size = new System.Drawing.Size(314, 45);
this.btnCompletePrintJob.TabIndex = 12;
this.btnCompletePrintJob.Text = "标记打印任务";
this.btnCompletePrintJob.UseVisualStyleBackColor = false;
//
// groupBox1
// groupBox1
//
this.groupBox1.Controls.Add(this.cbxFirstPage);
this.groupBox1.Controls.Add(this.btnChangeQuantity);
......@@ -726,6 +498,19 @@
this.cbxPrinter.Name = "cbxPrinter";
this.cbxPrinter.Size = new System.Drawing.Size(322, 30);
this.cbxPrinter.TabIndex = 10;
this.cbxPrinter.SelectedValueChanged += new System.EventHandler(this.cbxPrinter_SelectedValueChanged);
//
// lblMessage
//
this.lblMessage.Dock = System.Windows.Forms.DockStyle.Bottom;
this.lblMessage.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblMessage.ForeColor = System.Drawing.SystemColors.ControlText;
this.lblMessage.Location = new System.Drawing.Point(0, 1160);
this.lblMessage.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lblMessage.Name = "lblMessage";
this.lblMessage.Size = new System.Drawing.Size(2138, 42);
this.lblMessage.TabIndex = 12;
this.lblMessage.Text = "消息:";
//
// groupReport
//
......@@ -737,55 +522,288 @@
this.groupReport.Margin = new System.Windows.Forms.Padding(4);
this.groupReport.Name = "groupReport";
this.groupReport.Padding = new System.Windows.Forms.Padding(8);
this.groupReport.Size = new System.Drawing.Size(2138, 1160);
this.groupReport.TabIndex = 13;
this.groupReport.Size = new System.Drawing.Size(1784, 1160);
this.groupReport.TabIndex = 14;
this.groupReport.TabStop = false;
this.groupReport.Text = "打印队列";
//
// lblMessage
// gridPrintJobs
//
this.lblMessage.Dock = System.Windows.Forms.DockStyle.Bottom;
this.lblMessage.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblMessage.ForeColor = System.Drawing.SystemColors.ControlText;
this.lblMessage.Location = new System.Drawing.Point(0, 1160);
this.lblMessage.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lblMessage.Name = "lblMessage";
this.lblMessage.Size = new System.Drawing.Size(2138, 42);
this.lblMessage.TabIndex = 12;
this.lblMessage.Text = "消息:";
this.gridPrintJobs.AllowUserToAddRows = false;
this.gridPrintJobs.AllowUserToDeleteRows = false;
this.gridPrintJobs.AllowUserToResizeRows = false;
this.gridPrintJobs.BackgroundColor = System.Drawing.Color.White;
this.gridPrintJobs.ColumnHeadersHeight = 35;
this.gridPrintJobs.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.Column6,
this.IsPrint,
this.IsSearch,
this.Title,
this.Count,
this.OwnerName,
this.OperateTime,
this.AccepterName,
this.OperatorName,
this.Summary,
this.Remark,
this.IsPasteSample,
this.PrintStatus,
this.PrintTime});
this.gridPrintJobs.Dock = System.Windows.Forms.DockStyle.Fill;
this.gridPrintJobs.Location = new System.Drawing.Point(8, 105);
this.gridPrintJobs.Margin = new System.Windows.Forms.Padding(4);
this.gridPrintJobs.Name = "gridPrintJobs";
this.gridPrintJobs.RowHeadersVisible = false;
this.gridPrintJobs.RowHeadersWidth = 65;
dataGridViewCellStyle3.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.gridPrintJobs.RowsDefaultCellStyle = dataGridViewCellStyle3;
this.gridPrintJobs.RowTemplate.Height = 40;
this.gridPrintJobs.Size = new System.Drawing.Size(1768, 1047);
this.gridPrintJobs.TabIndex = 7;
this.gridPrintJobs.RowPrePaint += new System.Windows.Forms.DataGridViewRowPrePaintEventHandler(this.gridPrintJobs_RowPrePaint);
//
// Column6
//
this.Column6.DataPropertyName = "IsSelected";
dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
dataGridViewCellStyle1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
dataGridViewCellStyle1.NullValue = false;
this.Column6.DefaultCellStyle = dataGridViewCellStyle1;
this.Column6.Frozen = true;
this.Column6.HeaderText = "";
this.Column6.MinimumWidth = 8;
this.Column6.Name = "Column6";
this.Column6.Width = 40;
//
// IsPrint
//
this.IsPrint.DataPropertyName = "IsPrint";
this.IsPrint.Frozen = true;
this.IsPrint.HeaderText = "是否已打印";
this.IsPrint.MinimumWidth = 8;
this.IsPrint.Name = "IsPrint";
this.IsPrint.Visible = false;
this.IsPrint.Width = 150;
//
// IsSearch
//
this.IsSearch.DataPropertyName = "IsSearch";
this.IsSearch.Frozen = true;
this.IsSearch.HeaderText = "手动查询";
this.IsSearch.MinimumWidth = 8;
this.IsSearch.Name = "IsSearch";
this.IsSearch.Visible = false;
this.IsSearch.Width = 150;
//
// Title
//
this.Title.DataPropertyName = "Title";
this.Title.Frozen = true;
this.Title.HeaderText = "报告编号";
this.Title.MinimumWidth = 8;
this.Title.Name = "Title";
this.Title.ReadOnly = true;
this.Title.Width = 170;
//
// Count
//
this.Count.DataPropertyName = "Count";
this.Count.Frozen = true;
this.Count.HeaderText = "份数";
this.Count.MinimumWidth = 60;
this.Count.Name = "Count";
this.Count.Width = 60;
//
// OwnerName
//
this.OwnerName.DataPropertyName = "OwnerName";
this.OwnerName.Frozen = true;
this.OwnerName.HeaderText = "委托单位";
this.OwnerName.MinimumWidth = 8;
this.OwnerName.Name = "OwnerName";
this.OwnerName.ReadOnly = true;
this.OwnerName.Width = 180;
//
// OperateTime
//
this.OperateTime.DataPropertyName = "OperateTime";
this.OperateTime.Frozen = true;
this.OperateTime.HeaderText = "签发日期";
this.OperateTime.MinimumWidth = 130;
this.OperateTime.Name = "OperateTime";
this.OperateTime.ReadOnly = true;
this.OperateTime.Width = 130;
//
// AccepterName
//
this.AccepterName.DataPropertyName = "AccepterName";
this.AccepterName.Frozen = true;
this.AccepterName.HeaderText = "受理";
this.AccepterName.MinimumWidth = 8;
this.AccepterName.Name = "AccepterName";
this.AccepterName.ReadOnly = true;
this.AccepterName.Width = 150;
//
// OperatorName
//
this.OperatorName.DataPropertyName = "OperatorName";
this.OperatorName.Frozen = true;
this.OperatorName.HeaderText = "签发";
this.OperatorName.MinimumWidth = 80;
this.OperatorName.Name = "OperatorName";
this.OperatorName.ReadOnly = true;
this.OperatorName.Width = 80;
//
// Summary
//
this.Summary.DataPropertyName = "Summary";
this.Summary.HeaderText = "判定";
this.Summary.MinimumWidth = 80;
this.Summary.Name = "Summary";
this.Summary.ReadOnly = true;
this.Summary.Width = 80;
//
// Remark
//
this.Remark.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.Remark.DataPropertyName = "Remark";
this.Remark.HeaderText = "结论";
this.Remark.MinimumWidth = 100;
this.Remark.Name = "Remark";
this.Remark.ReadOnly = true;
//
// IsPasteSample
//
this.IsPasteSample.DataPropertyName = "IsPasteSample";
this.IsPasteSample.HeaderText = "贴样";
this.IsPasteSample.MinimumWidth = 60;
this.IsPasteSample.Name = "IsPasteSample";
this.IsPasteSample.ReadOnly = true;
this.IsPasteSample.Width = 60;
//
// PrintStatus
//
this.PrintStatus.DataPropertyName = "PrintStatus";
dataGridViewCellStyle2.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.PrintStatus.DefaultCellStyle = dataGridViewCellStyle2;
this.PrintStatus.HeaderText = "打印状态";
this.PrintStatus.MinimumWidth = 120;
this.PrintStatus.Name = "PrintStatus";
this.PrintStatus.ReadOnly = true;
this.PrintStatus.Width = 120;
//
// PrintTime
//
this.PrintTime.DataPropertyName = "PrintTime";
this.PrintTime.HeaderText = "最后打印";
this.PrintTime.MinimumWidth = 150;
this.PrintTime.Name = "PrintTime";
this.PrintTime.Width = 150;
//
// panel2
//
this.panel2.Controls.Add(this.tbSearch);
this.panel2.Controls.Add(this.btnSearch);
this.panel2.Controls.Add(this.btnPrint);
this.panel2.Controls.Add(this.btnRefresh);
this.panel2.Dock = System.Windows.Forms.DockStyle.Top;
this.panel2.Location = new System.Drawing.Point(8, 45);
this.panel2.Margin = new System.Windows.Forms.Padding(4);
this.panel2.Name = "panel2";
this.panel2.Padding = new System.Windows.Forms.Padding(8);
this.panel2.Size = new System.Drawing.Size(1768, 60);
this.panel2.TabIndex = 5;
//
// tbSearch
//
this.tbSearch.Dock = System.Windows.Forms.DockStyle.Fill;
this.tbSearch.Location = new System.Drawing.Point(158, 8);
this.tbSearch.Margin = new System.Windows.Forms.Padding(4);
this.tbSearch.Name = "tbSearch";
this.tbSearch.Size = new System.Drawing.Size(1302, 44);
this.tbSearch.TabIndex = 17;
this.tbSearch.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tbSearch_KeyDown);
//
// btnSearch
//
this.btnSearch.Dock = System.Windows.Forms.DockStyle.Right;
this.btnSearch.Enabled = false;
this.btnSearch.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnSearch.Font = new System.Drawing.Font("宋体", 10F, System.Drawing.FontStyle.Bold);
this.btnSearch.Location = new System.Drawing.Point(1460, 8);
this.btnSearch.Margin = new System.Windows.Forms.Padding(4);
this.btnSearch.Name = "btnSearch";
this.btnSearch.Size = new System.Drawing.Size(150, 44);
this.btnSearch.TabIndex = 16;
this.btnSearch.Text = "搜索";
this.btnSearch.UseVisualStyleBackColor = false;
this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);
//
// btnPrint
//
this.btnPrint.BackColor = System.Drawing.SystemColors.Highlight;
this.btnPrint.Dock = System.Windows.Forms.DockStyle.Right;
this.btnPrint.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnPrint.Font = new System.Drawing.Font("宋体", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnPrint.Location = new System.Drawing.Point(1610, 8);
this.btnPrint.Margin = new System.Windows.Forms.Padding(4);
this.btnPrint.Name = "btnPrint";
this.btnPrint.Size = new System.Drawing.Size(150, 44);
this.btnPrint.TabIndex = 11;
this.btnPrint.Text = "开始打印";
this.btnPrint.UseVisualStyleBackColor = false;
this.btnPrint.Click += new System.EventHandler(this.btnPrint_Click);
//
// btnRefresh
//
this.btnRefresh.BackColor = System.Drawing.Color.LightGreen;
this.btnRefresh.Dock = System.Windows.Forms.DockStyle.Left;
this.btnRefresh.Enabled = false;
this.btnRefresh.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnRefresh.Font = new System.Drawing.Font("宋体", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnRefresh.Location = new System.Drawing.Point(8, 8);
this.btnRefresh.Margin = new System.Windows.Forms.Padding(4);
this.btnRefresh.Name = "btnRefresh";
this.btnRefresh.Size = new System.Drawing.Size(150, 44);
this.btnRefresh.TabIndex = 10;
this.btnRefresh.Text = "刷新数据";
this.btnRefresh.UseVisualStyleBackColor = false;
this.btnRefresh.Click += new System.EventHandler(this.btnRefresh_Click);
//
// FrmMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(2138, 1202);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.groupReport);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.lblMessage);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "FrmMain";
this.Text = "K5报告打印客户端V4.2_24.3050";
this.Activated += new System.EventHandler(this.FrmMain_Activated);
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmMain_FormClosing);
this.Load += new System.EventHandler(this.FrmMain_Load);
((System.ComponentModel.ISupportInitialize)(this.nudQuantity)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit();
this.groupBox3.ResumeLayout(false);
this.groupBox3.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.gridPrintJobs)).EndInit();
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.panel2.ResumeLayout(false);
this.panel2.PerformLayout();
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.panel4.ResumeLayout(false);
this.groupReport.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.gridPrintJobs)).EndInit();
this.panel2.ResumeLayout(false);
this.panel2.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.DataGridViewTextBoxColumn OperatorName;
private System.Windows.Forms.CheckBox cbxFirstPage;
private System.Windows.Forms.Button btnChangeQuantity;
private System.Windows.Forms.NumericUpDown nudQuantity;
......@@ -795,26 +813,12 @@
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.DataGridViewTextBoxColumn OperateTime;
private System.Windows.Forms.DataGridViewTextBoxColumn OwnerName;
private System.Windows.Forms.DataGridViewTextBoxColumn Count;
private System.Windows.Forms.DataGridViewTextBoxColumn Title;
private System.Windows.Forms.DataGridViewTextBoxColumn IsSearch;
private System.Windows.Forms.PictureBox pictureBox3;
private System.Windows.Forms.PictureBox pictureBox2;
private System.Windows.Forms.CheckBox cbxJianDu;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label lblUserInfo;
private System.Windows.Forms.DataGridViewTextBoxColumn AccepterName;
private System.Windows.Forms.DataGridViewTextBoxColumn IsPrint;
private System.Windows.Forms.DataGridView gridPrintJobs;
private System.Windows.Forms.DataGridViewCheckBoxColumn Column6;
private System.Windows.Forms.DataGridViewTextBoxColumn Summary;
private System.Windows.Forms.DataGridViewTextBoxColumn Remark;
private System.Windows.Forms.DataGridViewTextBoxColumn IsPasteSample;
private System.Windows.Forms.DataGridViewTextBoxColumn PrintStatus;
private System.Windows.Forms.DataGridViewTextBoxColumn PrintTime;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.Label lblPrinterName;
private System.Windows.Forms.Button btnDisconnect;
......@@ -825,19 +829,34 @@
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox tbxServiceName;
private System.Windows.Forms.Label lblServiceName;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.TextBox tbSearch;
private System.Windows.Forms.Button btnSearch;
private System.Windows.Forms.Button btnPrint;
private System.Windows.Forms.Button btnRefresh;
private System.Windows.Forms.Button btnCompletePrintJob;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.CheckBox cbxPrintAutoComplete;
private System.Windows.Forms.CheckBox cbxPdfRemoveHeader;
private System.Windows.Forms.Panel panel4;
private System.Windows.Forms.ComboBox cbxPrinter;
private System.Windows.Forms.GroupBox groupReport;
private System.Windows.Forms.Label lblMessage;
private System.Windows.Forms.GroupBox groupReport;
private System.Windows.Forms.DataGridView gridPrintJobs;
private System.Windows.Forms.DataGridViewCheckBoxColumn Column6;
private System.Windows.Forms.DataGridViewTextBoxColumn IsPrint;
private System.Windows.Forms.DataGridViewTextBoxColumn IsSearch;
private System.Windows.Forms.DataGridViewTextBoxColumn Title;
private System.Windows.Forms.DataGridViewTextBoxColumn Count;
private System.Windows.Forms.DataGridViewTextBoxColumn OwnerName;
private System.Windows.Forms.DataGridViewTextBoxColumn OperateTime;
private System.Windows.Forms.DataGridViewTextBoxColumn AccepterName;
private System.Windows.Forms.DataGridViewTextBoxColumn OperatorName;
private System.Windows.Forms.DataGridViewTextBoxColumn Summary;
private System.Windows.Forms.DataGridViewTextBoxColumn Remark;
private System.Windows.Forms.DataGridViewTextBoxColumn IsPasteSample;
private System.Windows.Forms.DataGridViewTextBoxColumn PrintStatus;
private System.Windows.Forms.DataGridViewTextBoxColumn PrintTime;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.TextBox tbSearch;
private System.Windows.Forms.Button btnSearch;
private System.Windows.Forms.Button btnPrint;
private System.Windows.Forms.Button btnRefresh;
}
}
using System;
using Kivii.Client.Lims.ReportPrinter.Entities;
using Kivii.Client.Lims.ReportPrinter.Request;
using Kivii.Configuration;
using Kivii.GhostScript;
using Kivii.Linq;
using Kivii.Pdf;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Printing;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using System.Windows.Forms;
namespace Kivii.Client.Lims.ReportPrinter
{
public partial class FrmMain : Form
{
#region 私有变量
private string _userName = null;
private Guid _userKvid = Guid.Empty;
private string _serverUrl = "";
/// <summary>
/// Restful通讯客户端
/// </summary>
private JsonServiceClient _client = null;
/// <summary>
/// 打印设置信息
/// </summary>
private PrinterSettings _printerSettings;
/// <summary>
/// 打印队列显示
/// </summary>
private List<PrintPool> _printJobs = null;
/// <summary>
/// 正在打印标记,正在打印时,不允许刷新数据
/// </summary>
private bool _isPrinting = false;
/// <summary>
/// 打印线程
/// </summary>
private Thread _printThread = null;
/// <summary>
/// 移除PDF的抬头
/// </summary>
//private bool _removePdfHeader = true;
//private bool _autoCompletePrint = false;
/// <summary>
/// 下载报告客户端
/// </summary>
private WebClient _downloadClient = null;
/// <summary>
/// 设置默认打印机方法
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
[System.Runtime.InteropServices.DllImport("winspool.drv", CharSet = System.Runtime.InteropServices.CharSet.Auto, SetLastError = true)]
private static extern Boolean SetDefaultPrinter(string name);
#endregion
public FrmMain()
{
InitializeComponent();
}
#region 界面控件默认值管理
private void setMessage(string msg)
{
if (InvokeRequired)
{
this.Invoke(new Action(() => { setMessage(msg); }));
return;
}
lblMessage.Text = msg;
if (msg.StartsWith("成功:")) lblMessage.ForeColor = Color.Green;
else if (msg.StartsWith("错误:")) lblMessage.ForeColor = Color.Red;
else if (msg.StartsWith("警告:")) lblMessage.ForeColor = Color.OrangeRed;
else lblMessage.ForeColor = Color.Gray;
}
private void setDefault(params Control[] ctls)
{
using (var conn = KiviiContext.GetOpenedDbConnection<UiSetting>())
{
foreach (var ctl in ctls)
{
var setting = conn.Select<UiSetting>(o => o.FormName == this.Name && o.ControlName == ctl.Name).FirstOrDefault();
if (setting == null)
{
setting = new UiSetting();
setting.FormName = this.Name;
setting.ControlName = ctl.Name;
setting.ControlValue = ctl.Text;
conn.Insert(setting);
}
else
{
setting.ControlValue = ctl.Text;
conn.Update(setting);
}
}
}
}
private void loadDefault(params Control[] ctls)
{
using (var conn = KiviiContext.GetOpenedDbConnection<UiSetting>())
{
foreach (var ctl in ctls)
{
var setting = conn.Select<UiSetting>(o => o.FormName == this.Name && o.ControlName == ctl.Name).FirstOrDefault();
if (setting == null) continue;
ctl.Text = setting.ControlValue;
}
}
}
#endregion
private void FrmMain_Load(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Maximized;
gridPrintJobs.AutoGenerateColumns = false;
loadDefault(tbxServiceName, tbxUserName, tbxPassword);
//_client = new JsonServiceClient(_serverUrl);
_downloadClient = new WebClient();
PrintDocument print = new PrintDocument();
_printerSettings = print.PrinterSettings;//默认打印机名
lblPrinterName.Text = "打印机:" + _printerSettings.PrinterName;
lblPrinterName.BackColor = Color.Green;
foreach (string sPrint in PrinterSettings.InstalledPrinters)//获取所有打印机名称
{
cbxPrinter.Items.Add(sPrint);
if (sPrint == _printerSettings.PrinterName) cbxPrinter.SelectedIndex = cbxPrinter.Items.IndexOf(sPrint);
}
}
private void FrmMain_FormClosing(object sender, FormClosingEventArgs e)
{
if (_client != null) _client.Dispose();
if (_downloadClient != null) _downloadClient.Dispose();
}
private void cbxPrinter_SelectedValueChanged(object sender, EventArgs e)
{
var result = SetDefaultPrinter(cbxPrinter.SelectedItem.ToString());
PrintDocument print = new PrintDocument();
_printerSettings = print.PrinterSettings;//默认打印机名
lblPrinterName.Text = "打印机:" + _printerSettings.PrinterName;
lblPrinterName.BackColor = Color.Green;
}
private void btnConnect_Click(object sender, EventArgs e)
{
if (_client != null) return;
btnConnect.Enabled = false;
_client = new JsonServiceClient(tbxServiceName.Text);
_client.Timeout = TimeSpan.FromSeconds(50);//5秒超时
var auth = new Authenticate { UserName = tbxUserName.Text, Password = tbxPassword.Text, provider = "Kivii" };
var task = _client.PostAsync(auth);
//当成功获取到数据后,异步执行以下的代码
task.Success(onLoginSuccess);
//当执行错误后,执行以下的代码
task.Error(onLoginError);
}
private void onLoginSuccess(AuthenticateResponse resp)
{
setMessage("登录成功:已连接到远程服务器上");
lblUserInfo.Text = "{0}".Fmt(resp.DisplayName);
btnRefresh.Enabled = true;
btnSearch.Enabled = true;
btnConnect.Enabled = false;
btnDisconnect.Enabled = true;
_userName = resp.DisplayName;
_userKvid = resp.Kvid;
setDefault(tbxServiceName, tbxUserName, tbxPassword);
}
private void onLoginError(Exception ex)
{
setMessage($"登陆失败:未能连接到远程服务器,{ex.Message}");
btnConnect.Enabled = true;
_client.Dispose();
_client = null;
}
private void btnDisconnect_Click(object sender, EventArgs e)
{
if (_client == null) return;
_client.Dispose();
_client = null;
btnConnect.Enabled = true;
tbxPassword.Text = null;
tbxPassword.Focus();
lblUserInfo.Text = null;
setMessage("断开服务:已断开服务器");
}
private void FrmMain_Activated(object sender, EventArgs e)
{
tbxPassword.Focus();
}
private void btnRefresh_Click(object sender, EventArgs e)
{
if (_client == null) return;
//如果正在打印,不允许刷新数据源
if (_isPrinting) return;
btnRefresh.Enabled = false;
tbSearch.Text = string.Empty;
var request = new PrintPoolQuery();
request.IsPrint = false;
request.OrderBy = "Title";//2020-08-03前台要求按照AW BW排序,即报告号排序
var task = _client.PostAsync(request);
task.Success(() =>
{
_printJobs = new List<PrintPool>();
if (cbxJianDu.Checked)
{
_printJobs = task.Result.Results;
}
else
{
foreach (var en in task.Result.Results)
{
if (en.Title.Contains("GJ") || en.Title.Contains("FJ") || en.Title.Contains("TJ")) continue;
_printJobs.Add(en);
}
}
gridPrintJobs.DataSource = _printJobs;
setMessage($"成功:{DateTime.Now.ToString("HH:mm:ss")}->加载打印列队{_printJobs.Count}条");
btnRefresh.Enabled = true;
});
task.Error((ex) =>
{
setMessage($"错误:{DateTime.Now.ToString("HH:mm:ss")}->{ex.Message}");
btnRefresh.Enabled = true;
});
}
private void btnSearch_Click(object sender, EventArgs e)
{
if (_client == null) return;
//如果正在打印,不允许刷新数据源
if (_isPrinting) return;
if (tbSearch.Text.IsNullOrEmpty()) return;
btnSearch.Enabled = false;
var request = new PrintPoolQuery();
request.IsPrint = true;
request.QueryKeys = "Title";
request.QueryValues = tbSearch.Text;
var task = _client.PostAsync(request);
task.Success(() =>
{
if (_printJobs.IsNullOrEmpty()) _printJobs = new List<PrintPool>();
_printJobs.RemoveAll(o => o.IsSearch == false);
foreach (var item in task.Result.Results)
{
if (_printJobs.Exists(o => o.Kvid == item.Kvid)) continue;
if (item.IsPrint)
{
if (item.Result == "标记为已打印" || item.Count == 0)
{
item.IsSearch = true;
_printJobs.Add(item);
}
}
else _printJobs.Add(item);
}
gridPrintJobs.DataSource = null;
gridPrintJobs.DataSource = _printJobs;
setMessage($"成功:{DateTime.Now.ToString("HH:mm:ss")}->加载打印列队{_printJobs.Count}条");
btnSearch.Enabled = true;
tbSearch.Text = string.Empty;
});
task.Error((ex) =>
{
setMessage($"错误:{DateTime.Now.ToString("HH:mm:ss")}->{ex.Message}");
btnSearch.Enabled = true;
tbSearch.Text = string.Empty;
});
}
private void btnCompletePrintJob_Click(object sender, EventArgs e)
{
if (_printJobs.IsNullOrEmpty()) return;
btnCompletePrintJob.Enabled = false;
var selectedJobs = _printJobs.Where(o => o.IsSelected).ToList();
if (selectedJobs == null || selectedJobs.Count == 0)
{
selectedJobs = _printJobs.ToList();
}
List<PrintPool> removedJobs = new List<PrintPool>();
foreach (var job in selectedJobs)
{
//手动查询的报告说明是已经归档后重新要打的报告 就不再做重复标记的工作了
if (job.IsSearch)
{
removedJobs.Add(job);
continue;
}
if (!job.IsPrint) continue;//未打印的不标记
try
{
var completeRequest = new PrintPoolComplete();
completeRequest.Kvid = job.Kvid;
completeRequest.Remark = "标记为已打印";
completeRequest.OperatorName = _userName;
completeRequest.OperatorKvid = _userKvid;
_client.Post(completeRequest);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "标记打印任务");
}
try
{
var reportPrintAssign = new ReportPrintAssign();
reportPrintAssign.StatusType = ReportStatusType.ReportPrint;
reportPrintAssign.ReportKvids = new List<Guid>();
reportPrintAssign.ReportKvids.Add(job.OwnerKvid);
_client.Post(reportPrintAssign);
}
catch { }
removedJobs.Add(job);
}
this.Invoke(new Action(() =>
{
gridPrintJobs.DataSource = null;
foreach (var removeJob in removedJobs)
{
_printJobs.Remove(removeJob);
}
gridPrintJobs.DataSource = _printJobs;
btnCompletePrintJob.Enabled = true;
}));
}
private void btnPrint_Click(object sender, EventArgs e)
{
if (_printerSettings == null)
{
MessageBox.Show("请先设置打印机!");
return;
}
if (_printThread == null)
{
btnPrint.Text = "取消打印";
_printThread = new Thread(printJob);
_printThread.Start();
}
else
{
btnPrint.Text = "开始打印";
_printThread.Abort();
_printThread = null;
}
}
private void printJob()
{
_isPrinting = true;
setMessage("开始打印...");
//备注:此变量是为了处理自动标记打印后要移除的项目使用
//原本写法是标记一个移除一个 但这会导致客户端执行一个一个卡死闪退
//原因是dataGridView.DataSource绑定了数据源之后不支持移除数据
//解决办法是 对 dataGridView.DataSource 解绑 即dataGridView.DataSource=null
//之后再对数组进行增删后绑定到dataGridView.DataSource中
var preRemoveJobs = new List<PrintPool>();
try
{
if (_printJobs.IsNullOrEmpty()) return;
var selectedJobs = _printJobs.Where(o => o.IsSelected).ToList();
if (selectedJobs.IsNullOrEmpty())
{
selectedJobs = _printJobs;
}
foreach (var job in selectedJobs)
{
setMessage($"开始下载PDF文件:{job.Title}");
try
{
bool isPrintSucceed = false;
if (job.Count <= 0)
{
job.IsPrint = true;
isPrintSucceed = true;
job.PrintStatus = "打印成功";
setMessage($"成功:PDF文件无需打印:{job.Title}");
}
else
{
var tempDownloadFilePath = KiviiContext.GetTemporaryFilePath(job.Title + ".pdf");
string printFilePath = tempDownloadFilePath;//最终要打印的文件路径
if (job.FilePath.StartsWith("https")) job.FilePath = job.FilePath.Replace("https", "http");
var pdfUrl = job.FilePath;
_downloadClient.DownloadFile(pdfUrl, tempDownloadFilePath);
if (!File.Exists(tempDownloadFilePath))
{
job.IsPrint = false;
job.PrintStatus = "下载失败";
continue;
}
if (cbxPdfRemoveHeader.Checked )
{
setMessage($"开始处理PDF文件(移除抬头):{job.Title}");
printFilePath = KiviiContext.GetTemporaryFilePath(job.Title + ".pdf");//实际打印路径变了
var removeSetting = new StampSetting();
removeSetting.MatchText = "W=800-2000,H=150-400,Y=700-900,R=999";//R=999,移除多次,每页都有抬头,不加只移除首页
removeSetting.Pages = "1-E";
removeSetting.StampType = StampType.Remove;
//2022年11月3日新增 因电子版新增了“电子版”标签,所有电子报告打印时均需移除电子版标签
var stampIsSucceed = removeSetting.Stamp(new PdfReader(tempDownloadFilePath), new FileStream(printFilePath, FileMode.Create));
if (!stampIsSucceed)//不成功也继续打印
{
setMessage($"警告:未能找到PDF文件中的抬头信息:{job.Title}");
job.PrintStatus = "未能移除抬头";
printFilePath = tempDownloadFilePath;
}
}
#region 原写法
//List<string> args = new List<string>();
////args.Add("-dQUIET");
//args.Add("-dPARANOIDSAFER");
//args.Add("-dBATCH");
//args.Add("-dNOPAUSE");
//args.Add("-r320");
////args.Add($"-dNumCopies={job.Count}");
//args.Add("-dNOPROMPT");
//args.Add("-sDEVICE=mswinpr2");//使用Windows的打印驱动来
////args.Add("-sDEVICE=ljet4");
//args.Add($"-dPDFFitPage");
//args.Add($"-dUserArtBox");
//args.Add($"-dPrinted");
////args.Add($"-dNumCopies={job.PrintCount}");
//args.Add("-dNoCancel");//不显示打印提示窗口
// //args.Add("-dEmbedAllFonts=true");
// //args.Add("-r600");
// //if (!string.IsNullOrEmpty(pages)) args.Add($"-sPageList={pages}");
// //args.Add(String.Format("-sPAPERSIZE={0}", "a4"));
////args.Add($"-sPDFDocOptions=\"<</NumCopies {job.PrintCount} /Collate true>> setpagedevice\"");
////args.Add($"--saved-pages=\"print copies={job.PrintCount}, normal\"");
//args.Add($"-sOutputFile=%printer%{ _printerSettings.PrinterName}");
//args.Add(printFilePath);
#endregion
List<string> args = new List<string>();
args.Add("");
args.Add("-dQUIET");
args.Add("-dNOPAUSE");
args.Add("-dBATCH");
if (cbxFirstPage.Checked)
{
args.Add("-dFirstPage=1");
args.Add("-dLastPage=1");
}
args.Add("-c");
args.Add($"\"mark /NoCancel true /BitsPerPixel 8 /OutputFile(%printer%{_printerSettings.PrinterName}) /QueryUser 3 /UserSettings<</DocumentName ({job.Title}) /MaxResolution 320>>(mswinpr2) finddevice putdeviceprops setdevice\"");
args.Add("-f");
args.Add($"\"{printFilePath}\"");
//string s = string.Join(" ", args.ToArray());
//isPrintSucceed |= Kivii.GhostScript.Tools.Run(args.ToArray()) == 0;
for (var i = 0; i < job.Count; i++)
{
var result = Instance.Run(args.ToArray());
isPrintSucceed |= result == 0;
}
}
if (!isPrintSucceed)
{
job.IsPrint = false;
setMessage($"错误:打印PDF文件失败:{job.Title}");
job.PrintStatus = "打印失败";
continue;
}
job.IsPrint = true;
job.PrintTime = DateTime.Now;
job.PrintStatus = "打印成功";
setMessage($"成功:PDF文件打印完成:{job.Title}");
var markRequest = new PrintPoolMark();
markRequest.Kvid = job.Kvid;
markRequest.Copies = job.Count;
markRequest.Remark = job.PrintStatus;
markRequest.OperatorName = _userName;
markRequest.OperatorKvid = _userKvid;
_client.Post(markRequest);
if (cbxPrintAutoComplete.Checked)
{
//手动查询的报告说明是已经归档后重新要打的报告 就不再做重复标记的工作了
if (job.IsSearch)
{
//_printJobs.Remove(job);
preRemoveJobs.Add(job);
continue;
}
try
{
var completeRequest = new PrintPoolComplete();
completeRequest.Kvid = job.Kvid;
completeRequest.Remark = "标记为已打印";
completeRequest.OperatorName = _userName;
completeRequest.OperatorKvid = _userKvid;
_client.Post(completeRequest);
}
catch { }
try
{
var reportPrintAssign = new ReportPrintAssign();
reportPrintAssign.StatusType = ReportStatusType.ReportPrint;
reportPrintAssign.ReportKvids = new List<Guid>();
reportPrintAssign.ReportKvids.Add(job.OwnerKvid);
var task = _client.Post(reportPrintAssign);
}
catch (Exception ex)
{
WriterLog("/Logs", "/报告下达异常捕获.txt", ex.Message, job.Title);
}
preRemoveJobs.Add(job);
//_printJobs.Remove(job);
}
}
catch (Exception ex)
{
job.IsPrint = false;
job.PrintStatus = "打印异常";
try
{
var markErrorRequest = new PrintPoolMark();
markErrorRequest.Kvid = job.Kvid;
markErrorRequest.Copies = job.Count;
markErrorRequest.Remark = job.PrintStatus;
markErrorRequest.OperatorName = _userName;
markErrorRequest.OperatorKvid = _userKvid;
_client.Post(markErrorRequest);
}
catch
{
}
setMessage($"错误:打印PDF文件异常:{job.Title}");
MessageBox.Show(ex.Message, "打印异常");
}
finally
{
this.Invoke(new Action(() =>
{
gridPrintJobs.DataSource = null;
gridPrintJobs.DataSource = _printJobs;
}));
}
}
}
finally
{
setMessage("打印完成...");
this.Invoke(new Action(() =>
{
btnPrint.Text = "开始打印";
_printThread = null;
gridPrintJobs.DataSource = null;
cbxFirstPage.Checked = false;
foreach (var item in preRemoveJobs)
{
_printJobs.Remove(item);
}
if (!_printJobs.IsNullOrEmpty()) gridPrintJobs.DataSource = _printJobs;
}));
_isPrinting = false;
}
}
private void gridPrintJobs_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e)
{
gridPrintJobs.Rows[e.RowIndex].DefaultCellStyle.ForeColor = Color.Green;
var printTime = gridPrintJobs.Rows[e.RowIndex].Cells["PrintTime"].Value;
var isPrint = gridPrintJobs.Rows[e.RowIndex].Cells["IsPrint"].Value;
if (isPrint == null) return;
if (!bool.TryParse(isPrint.ToString(), out var isPrinted)) return;
//已经标记为已打印显示蓝色
if (isPrinted) gridPrintJobs.Rows[e.RowIndex].DefaultCellStyle.ForeColor = Color.SteelBlue;
//已经打印过但没有标记为已打印显示橘色
else if (printTime != null)
{
gridPrintJobs.Rows[e.RowIndex].DefaultCellStyle.ForeColor = Color.Tomato;
}
}
private void tbSearch_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode != Keys.Enter) return;
btnSearch_Click(null, null);
}
private void tbxPassword_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode != Keys.Enter) return;
if (_client != null) return;
btnConnect_Click(null, null);
}
private void btnSelectAll_Click(object sender, EventArgs e)
{
if (_printJobs.IsNullOrEmpty()) return;
foreach (var item in _printJobs)
{
item.IsSelected = true;
}
gridPrintJobs.DataSource = null;
gridPrintJobs.DataSource = _printJobs;
}
private void btnSelectCancel_Click(object sender, EventArgs e)
{
if (_printJobs.IsNullOrEmpty()) return;
foreach (var item in _printJobs)
{
item.IsSelected = false;
}
gridPrintJobs.DataSource = null;
gridPrintJobs.DataSource = _printJobs;
}
private void btnChangeQuantity_Click(object sender, EventArgs e)
{
if (_printJobs.IsNullOrEmpty()) return;
var quantity = (int)nudQuantity.Value;
var selectedJobs = _printJobs.Where(o => o.IsSelected).ToList();
if (selectedJobs.Count <= 0)
{
MessageBox.Show("请先批量选中需要修改份数的报告!");
return;
}
if (MessageBox.Show($"当前选中报告数: {selectedJobs.Count}份\n当前设定份数: {nudQuantity.Value}份\n即将调整份数: {quantity}份", "确认以继续", MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification) == DialogResult.Yes)
{
foreach (var item in selectedJobs)
{
item.Count = quantity;
}
gridPrintJobs.DataSource = null;
gridPrintJobs.DataSource = _printJobs;
}
}
//往本地写文件
public void WriterLog(string path, string logName, string log, string page)
{
System.DateTime tm = DateTime.Now;
string p = AppDomain.CurrentDomain.BaseDirectory + path + logName;
if (!Directory.Exists(path))//判断路径下目录是否存在
{
Directory.CreateDirectory(path);
if (!File.Exists(p))
{
using (StreamWriter sw = File.CreateText(p))
{
sw.WriteLine(log + "----------" + tm + "[" + page + "]");
}
}
else
{
using (StreamWriter sw = File.AppendText(p))
{
sw.WriteLine(log + "----------" + tm + "[" + page + "]");
}
}
}
else
{
if (!File.Exists(p))
{
using (StreamWriter sw = File.CreateText(p))
{
sw.WriteLine(log + "----------" + tm + "[" + page + "]");
}
}
else
{
using (StreamWriter sw = File.AppendText(p))
{
sw.WriteLine(log + "----------" + tm + "[" + page + "]");
}
}
}
}
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -7,7 +7,7 @@
<ProjectGuid>{0E4BC54B-C07B-4D01-880E-5BC9366FE66C}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>Kivii.Client.Lims.ReportPrinter</RootNamespace>
<AssemblyName>Kivii.Client.Lims.ReportPrinter.V4.0</AssemblyName>
<AssemblyName>报告打印客户端</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
......@@ -31,6 +31,9 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>F.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="Kivii.Common.V4.0, Version=5.6.2024.1160, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\Kivii.Common.5.6.2024.1160\lib\net40\Kivii.Common.V4.0.dll</HintPath>
......@@ -62,6 +65,9 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Confings.cs" />
<Compile Include="Entities\PrintPool.cs" />
<Compile Include="Entities\UiSetting.cs" />
<Compile Include="FrmMain.cs">
<SubType>Form</SubType>
</Compile>
......@@ -70,6 +76,7 @@
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Request\PrintPoolRequest.cs" />
<EmbeddedResource Include="FrmMain.resx">
<DependentUpon>FrmMain.cs</DependentUpon>
</EmbeddedResource>
......@@ -95,5 +102,8 @@
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<Content Include="F.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
using Kivii.Client.Lims.ReportPrinter.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Kivii.Client.Lims.ReportPrinter.Request
{
public class PrintPoolQueryResponse : RestfulQueryResponse<PrintPool> { }
[Route(Configs.RoutePrintPoolQuery)]
public class PrintPoolQuery : IReturn<PrintPoolQueryResponse>
{
public string EntityType { get; set; } = "Kivii.Lims.Entities.Report";
public bool IsPrint { get; set; }
public string Category { get; set; }
public Guid OperatorKvid { get; set; }
public string QueryKeys { get; set; }
public string QueryValues { get; set; }
public string OrderBy { get; set; }
}
public class PrintPoolCreateResponse : RestfulCreateResponse<PrintPool> { }
[Route(Configs.RoutePrintPoolCreate)]
public class PrintPoolCreate : IReturn<PrintPoolCreateResponse>
{
public string EntityType { get; set; } = "Kivii.Lims.Entities.Report";
public PrintPool Item { get; set; }
}
public class PrintPoolMarkResponse : RestfulQueryResponse<PrintPool> { }
[Route(Configs.RoutePrintPoolMark)]
public class PrintPoolMark : IReturn<PrintPoolMarkResponse>
{
public string EntityType { get; set; } = "Kivii.Lims.Entities.Report";
public Guid Kvid { get; set; }
public int Copies { get; set; }
public string Remark { get; set; }
public string OperatorName { get; set; }
public Guid OperatorKvid { get; set; }
}
public class PrintPoolCompleteResponse : RestfulQueryResponse<PrintPool> { }
[Route(Configs.RoutePrintPoolComplete)]
public class PrintPoolComplete : IReturn<PrintPoolCompleteResponse>
{
public string EntityType { get; set; } = "Kivii.Lims.Entities.Report";
public Guid Kvid { get; set; }
public string Remark { get; set; }
public string OperatorName { get; set; }
public Guid OperatorKvid { get; set; }
}
public enum ReportStatusType
{
Unsupported = 0,
/// <summary>
/// 委托受理
/// </summary>
CommissionAccept = 100,
/// <summary>
/// 合同评审
/// </summary>
ContractReview = 200,
/// <summary>
/// 任务分派
/// </summary>
TaskAssign = 300,
/// <summary>
/// 数据录入
/// </summary>
DataEntry = 400,
/// <summary>
/// 报告编制
/// </summary>
ReportPreparation = 500,
/// <summary>
/// 报告审核
/// </summary>
ReportReview = 600,
/// <summary>
/// 报告签发
/// </summary>
ReportIssue = 700,
/// <summary>
/// 报告打印
/// </summary>
ReportPrint = 800,
/// <summary>
/// 报告归档
/// </summary>
ReportCollected = int.MaxValue
}
public class ReportPrintAssignResponse : RestfulQueryResponse<Guid> { }
[Route(Configs.RouteReportPrintAssign)]
public class ReportPrintAssign : IReturn<ReportPrintAssignResponse>
{
public List<Guid> ReportKvids { get; set; }
public ReportStatusType StatusType { get; set; }
}
}
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