Commit 0f2fab40 by 陶然

init

parent 4c5d4b94
......@@ -4,3 +4,6 @@
/Src/obj/Debug
/Kivii.Client.SampleInbounds.V4.0.sln
/packages
/.vs
/Src/bin/Debug
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<!--<add name="Database" providerName="Sqlite" connectionString="$ROOT\AppData\primary.sqlite"/>-->
</connectionStrings>
</configuration>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Kivii.Client
{
internal class Configs
{
public const string DefaultBaseUrl = "http://k5.jst-gov.com";
public const string TableUiSetting = "ui_settings";
public const string RouteLocationQuery = "/Restful/Kivii.Samples.Entities.Location/Query";
public const string RouteSampleQuery = "/Restful/Kivii.Samples.Entities.Sample/Query";
public const string RouteSamplePrePackaging = "/Restful/Kivii.Samples.Entities.Sample/PrePackaging";
public const string RouteSampleAssign = "/Restful/Kivii.Samples.Entities.Sample/Assign";
public const string RouteSamplePackaging = "/Restful/Kivii.Samples.Entities.Sample/Packaging";
public const string RouteSampleUnPackaging = "/Restful/Kivii.Samples.Entities.Sample/UnPackaging";
}
}

using Kivii.DataAnnotations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Kivii.Samples.Entities
{
public class Sample : EntityWithMetadata, IEntityInAssemblyDb, IEntityHasRemark, IEntityHasCreator, IEntityHasUpdater
{
#region 第三方关联V1.0
[ApiMember(Description = "关联业务,例如:此样品用于具体某一报告,此处记录报告信息")]
[InternalSetter]
[StringLength(200), Default("")]
public string BizId { get; set; }
[ApiMember(Description = "业务Kvid")]
[InternalSetter]
[DefaultEmptyGuid]
public Guid BizKvid { get; set; }
[ApiMember(Description = "业务类型,指实体类型全名称")]
[InternalSetter]
[StringLength(200), Default("")]
public string BizType { get; set; }
[InternalSetter]
[DefaultEmptyGuid]
public Guid OwnerKvid { get; set; }
[InternalSetter]
[StringLength(500)]//所属信息,记录当前数据的所属信息,可以是部门可以是组织可以是个人
public string OwnerName { get; set; }
#endregion
#region 关联信息
[InternalSetter]
[DefaultEmptyGuid]
public Guid RootKvid { get; set; }
[ApiMember(Description = "父级样品Kvid")]
[DefaultEmptyGuid]
public Guid ParentKvid { get; set; }
[ApiMember(Description = "包裹名称")]
[StringLength(200), Default("")]
public string PackageName { get; set; }
[ApiMember(Description = "包裹Kvid,只有在样品打包后会记录当前样品所属的包裹Kvid,包裹也是样品实体,包裹类型")]
[DefaultEmptyGuid]
public Guid PackageKvid { get; set; }
[ApiMember(Description = "来源名称")]
[IgnoreUpdate]
[StringLength(200), Default("")]
public string SourceName { get; set; }
[ApiMember(Description = "来源编号,邮寄则为记录快递号,抽样则为计划编号")]
[IgnoreUpdate]
[StringLength(200), Default("")]
public string SourceNumber { get; set; }
[ApiMember(Description = "来源类型,例如是快递方式则记录,顺丰,中通等")]
[IgnoreUpdate]
[StringLength(200), Default("")]
public string SourceType { get; set; }
#endregion
#region 基本信息
[ApiMember(Description = "样品名称")]
[Required]
[StringLength(200)]
public string Name { get; set; }
[ApiMember(Description = "样品内部编号")]
[StringLength(200), Default("")]
public string InternalCode { get; set; }
[ApiMember(Description = "样品编号")]
[SerialNumber]
[StringLength(100), Default("")]
public string SerialNumber { get; set; }
[ApiMember(Description = "样品批次编号")]
[StringLength(200), Default("")]
public string BatchNumber { get; set; }
[ApiMember(Description = "样品类型,类型:主样,子样,包裹")]
[StringLength(50), Default("")]
public SampleType Type { get; set; }
#region 时间相关
[ApiMember(Description = "抽样时间,一般用于监督,委托抽样使用")]
public DateTime? SamplingTime { get; set; }
[ApiMember(Description = "登记时间")]
public DateTime? RegistTime { get; set; }
[ApiMember(Description = "检验开始日期")]
public DateTime? TestStartDate { get; set; }
[ApiMember(Description = "检验结束日期")]
public DateTime? TestFinishDate { get; set; }
[ApiMember(Description = "样品受理日期")]
public DateTime? DealTime { get; set; }
[ApiMember(Description = "样品完成日期")]
public DateTime? DeadTime { get; set; }
[ApiMember(Description = "操作日期")]
public DateTime OperateTime { get; set; }
#endregion
[ApiMember(Description = "样品分类")]
[StringLength(50), Default("")]
public string Category { get; set; }
[ApiMember(Description = "样品品牌")]
[StringLength(200), Default("")]
public string Brand { get; set; }
[ApiMember(Description = "样品规格")]
[StringLength(200), Default("")]
public string Specification { get; set; }
[ApiMember(Description = "样品型号")]
[StringLength(200), Default("")]
public string Model { get; set; }
[ApiMember(Description = "样品材质")]
[StringLength(200), Default("")]
public string Material { get; set; }
[ApiMember(Description = "样品品级")]
[StringLength(200), Default("")]
public string Grade { get; set; }
[ApiMember(Description = "安全类别")]
[StringLength(200), Default("")]
public string GradeSafety { get; set; }
[ApiMember(Description = "样品状况,一般是指收到样品时的状况,是否完好等")]
[StringLength(200), Default("")]
public string Condition { get; set; }
#endregion
#region 数量相关
[ApiMember(Description = "样品数量")]
[DecimalLength(10, 2), Default(0)]
public decimal Quantity { get; set; }
[ApiMember(Description = "数量单位")]
[StringLength(50), Default("")]
public string QuantityUnit { get; set; }
#endregion
#region 生产单位信息及生产日期
[ApiMember(Description = "生产单位")]
[StringLength(100), Default("")]
public string ManufacturerName { get; set; }
[ApiMember(Description = "生产单位Kvid")]
[DefaultEmptyGuid]
[IgnoreUpdate]
public Guid ManufacturerKvid { get; set; }
[ApiMember(Description = "生产单位联系人姓名")]
[StringLength(50), Default("")]
public string ManufacturerContactName { get; set; }
[ApiMember(Description = "生产单位联系人Kvid")]
[DefaultEmptyGuid]
[IgnoreUpdate]
public Guid ManufacturerContactKvid { get; set; }
[ApiMember(Description = "生产单位联系人电话")]
[StringLength(50), Default("")]
//正则表达式验证:(^(\d{3,4}-)?\d{7,8})$|(13[0-9]{9})
public string ManufacturerContactNumber { get; set; }
[ApiMember(Description = "生产单位地址")]
[StringLength(200), Default("")]
public string ManufacturerAddress { get; set; }
[ApiMember(Description = "生产日期")]
public DateTime? ProductionDate { get; set; }
#endregion
#region 文本 备注
[ApiMember(Description = "摘要")]
[StringLength(1000), Default("")]
public string Summary { get; set; }
[ApiMember(Description = "备注")]
[StringLength(1000), Default("")]
public string Remark { get; set; }
#endregion
[Ignore]
public DateTime? AssignTime { get; set; }
/// <summary>
/// 样品当前所在位置
/// </summary>
[Ignore]
public Location CurrentLocation { get; set; }
/// <summary>
/// 样品当前最新的路由信息
/// </summary>
[Ignore]
public Route CurrentRoute { get; set; }
/// <summary>
/// 样品的所有路由信息
/// </summary>
[Ignore]
public List<Route> Routes { get; set; }
/// <summary>
/// 当前样品下一级的子样品信息
/// </summary>
[Ignore]
public List<Sample> Childrens { get; set; }
/// <summary>
/// 当前样品所在包裹的完整信息
/// </summary>
[Ignore]
public Sample CurrentPackage { get; set; }
#region 创建/更新人V1.0
[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; }
#endregion
}
public class Location : EntityWithMetadata
{
[InternalSetter]
[DefaultEmptyGuid]
public Guid OwnerKvid { get; set; }
[InternalSetter]
[StringLength(500)]//所属信息,记录当前数据的所属信息,可以是部门可以是组织可以是个人
public string OwnerName { get; set; }
[ApiMember(Description = "地点名称")]
[Required]
[StringLength(200)]
public string Title { get; set; }
[ApiMember(Description = "地点地址")]
[StringLength(500), Default("")]
public string Address { get; set; }
/// <summary>
/// 内部编码,唯一,样品在流转过程中必须传入目标地点的InternalCode
/// </summary>
[ApiMember(Description = "内部编码")]
[StringLength(200), Required]
[Unique()]
public string InternalCode { get; set; }
[ApiMember(Description = "配置类型")]
[StringLength(50), Default("")]
public string Type { get; set; }
[InternalSetter]
[DefaultEmptyGuid]
public Guid ManagerKvid { get; set; }
[InternalSetter]
[StringLength(500)]
public string ManagerName { get; set; }
#region 文本 摘要 备注
[ApiMember(Description = "摘要,最大500字")]
//[IgnoreUpdate]
[StringLength(500), Default("")]
public string Summary { get; set; }
[ApiMember(Description = "备注,最大2000字")]
[StringLength(2000), Default("")]
public string Remark { get; set; }
#endregion
}
public class Route : EntityWithMetadata, IEntityHasBiz, IEntityInAssemblyDb, IEntityHasRemark, IEntityHasCreator, IEntityHasUpdater
{
[ApiMember(Description = "样品名称")]
[IgnoreUpdate]
[StringLength(200), Default("")]
public string SampleName { get; set; }
[ApiMember(Description = "样品Kvid")]
[DefaultEmptyGuid]
public Guid SampleKvid { get; set; }
[ApiMember(Description = "主样品Kvid")]
[DefaultEmptyGuid]
public Guid SampleRootKvid { get; set; }
[ApiMember(Description = "父级样品Kvid")]
[DefaultEmptyGuid]
public Guid SampleParentKvid { get; set; }
#region 第三方关联V1.0
[ApiMember(Description = "关联业务,例如:此样品用于具体某一报告,此处记录报告信息")]
[InternalSetter]
[StringLength(200), Default("")]
public string BizId { get; set; }
[ApiMember(Description = "业务Kvid")]
[InternalSetter]
[DefaultEmptyGuid]
public Guid BizKvid { get; set; }
[ApiMember(Description = "业务类型,指实体类型全名称")]
[InternalSetter]
[StringLength(200), Default("")]
public string BizType { get; set; }
#endregion
#region 基本信息
[ApiMember(Description = "样品路由标题")]
[StringLength(200), Required]
public string Title { get; set; }
/// <summary>
/// 送样,快递等
/// </summary>
[ApiMember(Description = "样品路由类型")]
[StringLength(50)]
public string Type { get; set; }
/// <summary>
/// 当前路由地点
/// </summary>
[ApiMember(Description = "当前路由地点")]
[StringLength(200), Required]
public string CurrentLocationTitle { get; set; }
[ApiMember(Description = "当前路由地点Kvid")]
[DefaultEmptyGuid]
public Guid CurrentLocationKvid { get; set; }
/// <summary>
/// 目标地点,目标节点是下一个节点产生后返写的,代表此样品已经从当前节点离开
/// </summary>
[ApiMember(Description = "目标路由地点")]
[StringLength(200)]
public string NextLocationTitle { get; set; }
[ApiMember(Description = "目标路由地点Kvid")]
[DefaultEmptyGuid]
public Guid NextLocationKvid { get; set; }
/// <summary>
/// 操作人
/// </summary>
[ApiMember(Description = "操作人")]
[StringLength(100), Default("")]
public string OperatorName { get; set; }
/// <summary>
/// 操作人Kvid
/// </summary>
[ApiMember(Description = "操作人Kvid")]
public Guid OperatorKvid { get; set; }
/// <summary>
/// 操作日期
/// </summary>
[ApiMember(Description = "操作日期")]
public DateTime OperateTime { get; set; }
/// <summary>
/// 摘要
/// </summary>
[ApiMember(Description = "摘要")]
[StringLength(1000), Default("")]
public string Summary { get; set; }
[ApiMember(Description = "备注")]
[StringLength(1000), Default("")]
public string Remark { 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; }
#endregion
}
public class RfidBound : EntityWithMetadata, IEntityInAssemblyDb
{
[ApiMember(Description = "Tid")]
[Required, Unique]
[StringLength(500)]
public string Tid { get; set; }
[ApiMember(Description = "Epc")]
[StringLength(500)]
public string Epc { get; set; }
}
public enum SampleType
{
Unsupport = 0,
/// <summary>
/// 主样
/// </summary>
Master,
/// <summary>
/// 子样
/// </summary>
Node,
/// <summary>
/// 包裹
/// </summary>
Package
}
public enum PackageStatus
{
/// <summary>
/// 空闲
/// </summary>
Empty = 0,
/// <summary>
/// 装箱
/// </summary>
Full = 100,
/// <summary>
/// 入库
/// </summary>
Inbound = 200
}
}
using Kivii.Configuration;
using Kivii.DataAnnotations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Kivii.Client.SampleInbounds.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
namespace Kivii.Client.SampleInbounds
{
partial class FrmMain
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmMain));
this.plLeft = new System.Windows.Forms.Panel();
this.gbInfo = new System.Windows.Forms.GroupBox();
this.rtbMessage = new System.Windows.Forms.RichTextBox();
this.gbLogin = new System.Windows.Forms.GroupBox();
this.cbSetCurrentPackageOwner = new System.Windows.Forms.ComboBox();
this.tbCurrentPackage = new System.Windows.Forms.TextBox();
this.lbCurrentPackage = new System.Windows.Forms.Label();
this.btnLogout = new System.Windows.Forms.Button();
this.lbCurrentLocation = new System.Windows.Forms.Label();
this.btnLogin = new System.Windows.Forms.Button();
this.lbPackageDepartment = new System.Windows.Forms.Label();
this.tbCurrentLocation = new System.Windows.Forms.TextBox();
this.lblUrl = new System.Windows.Forms.Label();
this.lblUser = new System.Windows.Forms.Label();
this.lblPassword = new System.Windows.Forms.Label();
this.tbxPassword = new System.Windows.Forms.TextBox();
this.tbxServiceUrl = new System.Windows.Forms.TextBox();
this.tbxUserName = new System.Windows.Forms.TextBox();
this.plRight = new System.Windows.Forms.Panel();
this.gbRfid = new System.Windows.Forms.GroupBox();
this.dgvRfidSamples = new System.Windows.Forms.DataGridView();
this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.dataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.dataGridViewTextBoxColumn3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.dataGridViewTextBoxColumn4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.dataGridViewTextBoxColumn5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.dataGridViewTextBoxColumn6 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.dataGridViewTextBoxColumn7 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.gbRightToolBar = new System.Windows.Forms.GroupBox();
this.btnSampleAssign = new System.Windows.Forms.Button();
this.lbTips = new System.Windows.Forms.Label();
this.lbScanSample = new System.Windows.Forms.Label();
this.tbScanSample = new System.Windows.Forms.TextBox();
this.btnScanRfid = new System.Windows.Forms.Button();
this.plMain = new System.Windows.Forms.Panel();
this.gbMain = new System.Windows.Forms.GroupBox();
this.dgvSamples = new System.Windows.Forms.DataGridView();
this.SampleBizId = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.SamplePackageName = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.SampleOwnerName = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.SampleName = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.SampleDealTime = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.SampleDeadTime = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.SampleQuantityUnit = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.gbMainToolBar = new System.Windows.Forms.GroupBox();
this.lbCurrentPackageStatus = new System.Windows.Forms.Label();
this.btnClearCurrentPackage = new System.Windows.Forms.Button();
this.lbSetPackage = new System.Windows.Forms.Label();
this.tbSetCurrentPackage = new System.Windows.Forms.TextBox();
this.plLeft.SuspendLayout();
this.gbInfo.SuspendLayout();
this.gbLogin.SuspendLayout();
this.plRight.SuspendLayout();
this.gbRfid.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dgvRfidSamples)).BeginInit();
this.gbRightToolBar.SuspendLayout();
this.plMain.SuspendLayout();
this.gbMain.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dgvSamples)).BeginInit();
this.gbMainToolBar.SuspendLayout();
this.SuspendLayout();
//
// plLeft
//
this.plLeft.Controls.Add(this.gbInfo);
this.plLeft.Controls.Add(this.gbLogin);
this.plLeft.Dock = System.Windows.Forms.DockStyle.Left;
this.plLeft.Location = new System.Drawing.Point(0, 0);
this.plLeft.Name = "plLeft";
this.plLeft.Size = new System.Drawing.Size(252, 667);
this.plLeft.TabIndex = 0;
//
// gbInfo
//
this.gbInfo.Controls.Add(this.rtbMessage);
this.gbInfo.Dock = System.Windows.Forms.DockStyle.Fill;
this.gbInfo.Location = new System.Drawing.Point(0, 447);
this.gbInfo.Name = "gbInfo";
this.gbInfo.Size = new System.Drawing.Size(252, 220);
this.gbInfo.TabIndex = 2;
this.gbInfo.TabStop = false;
this.gbInfo.Text = "信息";
//
// rtbMessage
//
this.rtbMessage.Dock = System.Windows.Forms.DockStyle.Fill;
this.rtbMessage.Location = new System.Drawing.Point(3, 17);
this.rtbMessage.Name = "rtbMessage";
this.rtbMessage.Size = new System.Drawing.Size(246, 200);
this.rtbMessage.TabIndex = 0;
this.rtbMessage.Text = "";
//
// gbLogin
//
this.gbLogin.Controls.Add(this.cbSetCurrentPackageOwner);
this.gbLogin.Controls.Add(this.tbCurrentPackage);
this.gbLogin.Controls.Add(this.lbCurrentPackage);
this.gbLogin.Controls.Add(this.btnLogout);
this.gbLogin.Controls.Add(this.lbCurrentLocation);
this.gbLogin.Controls.Add(this.btnLogin);
this.gbLogin.Controls.Add(this.lbPackageDepartment);
this.gbLogin.Controls.Add(this.tbCurrentLocation);
this.gbLogin.Controls.Add(this.lblUrl);
this.gbLogin.Controls.Add(this.lblUser);
this.gbLogin.Controls.Add(this.lblPassword);
this.gbLogin.Controls.Add(this.tbxPassword);
this.gbLogin.Controls.Add(this.tbxServiceUrl);
this.gbLogin.Controls.Add(this.tbxUserName);
this.gbLogin.Dock = System.Windows.Forms.DockStyle.Top;
this.gbLogin.Location = new System.Drawing.Point(0, 0);
this.gbLogin.Name = "gbLogin";
this.gbLogin.Size = new System.Drawing.Size(252, 447);
this.gbLogin.TabIndex = 1;
this.gbLogin.TabStop = false;
this.gbLogin.Text = "登录";
//
// cbSetCurrentPackageOwner
//
this.cbSetCurrentPackageOwner.Enabled = false;
this.cbSetCurrentPackageOwner.Font = new System.Drawing.Font("宋体", 20F);
this.cbSetCurrentPackageOwner.FormattingEnabled = true;
this.cbSetCurrentPackageOwner.Location = new System.Drawing.Point(12, 389);
this.cbSetCurrentPackageOwner.Name = "cbSetCurrentPackageOwner";
this.cbSetCurrentPackageOwner.Size = new System.Drawing.Size(222, 35);
this.cbSetCurrentPackageOwner.TabIndex = 31;
this.cbSetCurrentPackageOwner.SelectedValueChanged += new System.EventHandler(this.cbSetCurrentPackageOwner_SelectedValueChanged);
//
// tbCurrentPackage
//
this.tbCurrentPackage.Enabled = false;
this.tbCurrentPackage.Font = new System.Drawing.Font("宋体", 18F);
this.tbCurrentPackage.Location = new System.Drawing.Point(12, 332);
this.tbCurrentPackage.Name = "tbCurrentPackage";
this.tbCurrentPackage.ReadOnly = true;
this.tbCurrentPackage.Size = new System.Drawing.Size(222, 35);
this.tbCurrentPackage.TabIndex = 2;
//
// lbCurrentPackage
//
this.lbCurrentPackage.AutoSize = true;
this.lbCurrentPackage.Font = new System.Drawing.Font("宋体", 12F);
this.lbCurrentPackage.Location = new System.Drawing.Point(9, 313);
this.lbCurrentPackage.Name = "lbCurrentPackage";
this.lbCurrentPackage.Size = new System.Drawing.Size(79, 16);
this.lbCurrentPackage.TabIndex = 6;
this.lbCurrentPackage.Text = "当前箱号:";
//
// btnLogout
//
this.btnLogout.BackColor = System.Drawing.Color.LavenderBlush;
this.btnLogout.Font = new System.Drawing.Font("宋体", 15F);
this.btnLogout.ForeColor = System.Drawing.Color.Crimson;
this.btnLogout.Location = new System.Drawing.Point(131, 213);
this.btnLogout.Name = "btnLogout";
this.btnLogout.Size = new System.Drawing.Size(107, 43);
this.btnLogout.TabIndex = 28;
this.btnLogout.Text = "退 出";
this.btnLogout.UseVisualStyleBackColor = false;
this.btnLogout.Click += new System.EventHandler(this.btnLogout_Click);
//
// lbCurrentLocation
//
this.lbCurrentLocation.AutoSize = true;
this.lbCurrentLocation.Font = new System.Drawing.Font("宋体", 12F);
this.lbCurrentLocation.Location = new System.Drawing.Point(12, 256);
this.lbCurrentLocation.Name = "lbCurrentLocation";
this.lbCurrentLocation.Size = new System.Drawing.Size(79, 16);
this.lbCurrentLocation.TabIndex = 5;
this.lbCurrentLocation.Text = "当前位置:";
//
// btnLogin
//
this.btnLogin.BackColor = System.Drawing.Color.MintCream;
this.btnLogin.Font = new System.Drawing.Font("宋体", 15F);
this.btnLogin.ForeColor = System.Drawing.Color.DarkGreen;
this.btnLogin.Location = new System.Drawing.Point(12, 213);
this.btnLogin.Name = "btnLogin";
this.btnLogin.Size = new System.Drawing.Size(107, 43);
this.btnLogin.TabIndex = 27;
this.btnLogin.Text = "登 录";
this.btnLogin.UseVisualStyleBackColor = false;
this.btnLogin.Click += new System.EventHandler(this.btnLogin_Click);
//
// lbPackageDepartment
//
this.lbPackageDepartment.AutoSize = true;
this.lbPackageDepartment.Font = new System.Drawing.Font("宋体", 12F);
this.lbPackageDepartment.Location = new System.Drawing.Point(9, 370);
this.lbPackageDepartment.Name = "lbPackageDepartment";
this.lbPackageDepartment.Size = new System.Drawing.Size(111, 16);
this.lbPackageDepartment.TabIndex = 4;
this.lbPackageDepartment.Text = "样品所属部门:";
//
// tbCurrentLocation
//
this.tbCurrentLocation.Enabled = false;
this.tbCurrentLocation.Font = new System.Drawing.Font("宋体", 18F);
this.tbCurrentLocation.Location = new System.Drawing.Point(12, 275);
this.tbCurrentLocation.Name = "tbCurrentLocation";
this.tbCurrentLocation.ReadOnly = true;
this.tbCurrentLocation.Size = new System.Drawing.Size(222, 35);
this.tbCurrentLocation.TabIndex = 1;
//
// lblUrl
//
this.lblUrl.AutoSize = true;
this.lblUrl.Font = new System.Drawing.Font("宋体", 18F);
this.lblUrl.Location = new System.Drawing.Point(8, 15);
this.lblUrl.Name = "lblUrl";
this.lblUrl.Size = new System.Drawing.Size(94, 24);
this.lblUrl.TabIndex = 21;
this.lblUrl.Text = "地 址:";
//
// lblUser
//
this.lblUser.AutoSize = true;
this.lblUser.Font = new System.Drawing.Font("宋体", 18F);
this.lblUser.Location = new System.Drawing.Point(8, 80);
this.lblUser.Name = "lblUser";
this.lblUser.Size = new System.Drawing.Size(94, 24);
this.lblUser.TabIndex = 22;
this.lblUser.Text = "用户名:";
//
// lblPassword
//
this.lblPassword.AutoSize = true;
this.lblPassword.Font = new System.Drawing.Font("宋体", 18F);
this.lblPassword.Location = new System.Drawing.Point(8, 145);
this.lblPassword.Name = "lblPassword";
this.lblPassword.Size = new System.Drawing.Size(94, 24);
this.lblPassword.TabIndex = 23;
this.lblPassword.Text = "密 码:";
//
// tbxPassword
//
this.tbxPassword.Font = new System.Drawing.Font("宋体", 18F);
this.tbxPassword.Location = new System.Drawing.Point(12, 172);
this.tbxPassword.Name = "tbxPassword";
this.tbxPassword.PasswordChar = '*';
this.tbxPassword.Size = new System.Drawing.Size(226, 35);
this.tbxPassword.TabIndex = 26;
this.tbxPassword.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tbxPassword_KeyDown);
//
// tbxServiceUrl
//
this.tbxServiceUrl.BackColor = System.Drawing.SystemColors.Window;
this.tbxServiceUrl.Font = new System.Drawing.Font("宋体", 18F);
this.tbxServiceUrl.Location = new System.Drawing.Point(12, 42);
this.tbxServiceUrl.Name = "tbxServiceUrl";
this.tbxServiceUrl.Size = new System.Drawing.Size(226, 35);
this.tbxServiceUrl.TabIndex = 24;
//
// tbxUserName
//
this.tbxUserName.Font = new System.Drawing.Font("宋体", 18F);
this.tbxUserName.Location = new System.Drawing.Point(12, 107);
this.tbxUserName.Name = "tbxUserName";
this.tbxUserName.Size = new System.Drawing.Size(226, 35);
this.tbxUserName.TabIndex = 25;
//
// plRight
//
this.plRight.Controls.Add(this.gbRfid);
this.plRight.Controls.Add(this.gbRightToolBar);
this.plRight.Dock = System.Windows.Forms.DockStyle.Right;
this.plRight.Location = new System.Drawing.Point(659, 0);
this.plRight.Name = "plRight";
this.plRight.Size = new System.Drawing.Size(429, 667);
this.plRight.TabIndex = 1;
//
// gbRfid
//
this.gbRfid.Controls.Add(this.dgvRfidSamples);
this.gbRfid.Dock = System.Windows.Forms.DockStyle.Fill;
this.gbRfid.Location = new System.Drawing.Point(0, 125);
this.gbRfid.Name = "gbRfid";
this.gbRfid.Size = new System.Drawing.Size(429, 542);
this.gbRfid.TabIndex = 2;
this.gbRfid.TabStop = false;
this.gbRfid.Text = "Rfid扫描结果";
//
// dgvRfidSamples
//
this.dgvRfidSamples.AllowUserToAddRows = false;
this.dgvRfidSamples.AllowUserToDeleteRows = false;
this.dgvRfidSamples.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgvRfidSamples.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.dataGridViewTextBoxColumn1,
this.dataGridViewTextBoxColumn2,
this.dataGridViewTextBoxColumn3,
this.dataGridViewTextBoxColumn4,
this.dataGridViewTextBoxColumn5,
this.dataGridViewTextBoxColumn6,
this.dataGridViewTextBoxColumn7});
this.dgvRfidSamples.Dock = System.Windows.Forms.DockStyle.Fill;
this.dgvRfidSamples.Location = new System.Drawing.Point(3, 17);
this.dgvRfidSamples.Name = "dgvRfidSamples";
this.dgvRfidSamples.ReadOnly = true;
this.dgvRfidSamples.RowTemplate.Height = 23;
this.dgvRfidSamples.Size = new System.Drawing.Size(423, 522);
this.dgvRfidSamples.TabIndex = 0;
this.dgvRfidSamples.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(this.dgvRfidSamples_RowPostPaint);
//
// dataGridViewTextBoxColumn1
//
this.dataGridViewTextBoxColumn1.DataPropertyName = "BizId";
this.dataGridViewTextBoxColumn1.Frozen = true;
this.dataGridViewTextBoxColumn1.HeaderText = "样品报告号";
this.dataGridViewTextBoxColumn1.MinimumWidth = 160;
this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1";
this.dataGridViewTextBoxColumn1.ReadOnly = true;
this.dataGridViewTextBoxColumn1.Width = 160;
//
// dataGridViewTextBoxColumn2
//
this.dataGridViewTextBoxColumn2.DataPropertyName = "PackageName";
this.dataGridViewTextBoxColumn2.HeaderText = "箱号";
this.dataGridViewTextBoxColumn2.MinimumWidth = 100;
this.dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2";
this.dataGridViewTextBoxColumn2.ReadOnly = true;
//
// dataGridViewTextBoxColumn3
//
this.dataGridViewTextBoxColumn3.DataPropertyName = "OwnerName";
this.dataGridViewTextBoxColumn3.HeaderText = "所属部门";
this.dataGridViewTextBoxColumn3.MinimumWidth = 90;
this.dataGridViewTextBoxColumn3.Name = "dataGridViewTextBoxColumn3";
this.dataGridViewTextBoxColumn3.ReadOnly = true;
this.dataGridViewTextBoxColumn3.Width = 90;
//
// dataGridViewTextBoxColumn4
//
this.dataGridViewTextBoxColumn4.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.dataGridViewTextBoxColumn4.DataPropertyName = "Name";
this.dataGridViewTextBoxColumn4.HeaderText = "样品名称";
this.dataGridViewTextBoxColumn4.MinimumWidth = 100;
this.dataGridViewTextBoxColumn4.Name = "dataGridViewTextBoxColumn4";
this.dataGridViewTextBoxColumn4.ReadOnly = true;
//
// dataGridViewTextBoxColumn5
//
this.dataGridViewTextBoxColumn5.DataPropertyName = "DealTime";
this.dataGridViewTextBoxColumn5.HeaderText = "委托日期";
this.dataGridViewTextBoxColumn5.MinimumWidth = 100;
this.dataGridViewTextBoxColumn5.Name = "dataGridViewTextBoxColumn5";
this.dataGridViewTextBoxColumn5.ReadOnly = true;
//
// dataGridViewTextBoxColumn6
//
this.dataGridViewTextBoxColumn6.DataPropertyName = "DeadTime";
this.dataGridViewTextBoxColumn6.HeaderText = "完成日期";
this.dataGridViewTextBoxColumn6.MinimumWidth = 100;
this.dataGridViewTextBoxColumn6.Name = "dataGridViewTextBoxColumn6";
this.dataGridViewTextBoxColumn6.ReadOnly = true;
//
// dataGridViewTextBoxColumn7
//
this.dataGridViewTextBoxColumn7.DataPropertyName = "QuantityUnit";
this.dataGridViewTextBoxColumn7.HeaderText = "数量/单位";
this.dataGridViewTextBoxColumn7.MinimumWidth = 100;
this.dataGridViewTextBoxColumn7.Name = "dataGridViewTextBoxColumn7";
this.dataGridViewTextBoxColumn7.ReadOnly = true;
//
// gbRightToolBar
//
this.gbRightToolBar.Controls.Add(this.btnSampleAssign);
this.gbRightToolBar.Controls.Add(this.lbTips);
this.gbRightToolBar.Controls.Add(this.lbScanSample);
this.gbRightToolBar.Controls.Add(this.tbScanSample);
this.gbRightToolBar.Controls.Add(this.btnScanRfid);
this.gbRightToolBar.Dock = System.Windows.Forms.DockStyle.Top;
this.gbRightToolBar.Location = new System.Drawing.Point(0, 0);
this.gbRightToolBar.Name = "gbRightToolBar";
this.gbRightToolBar.Size = new System.Drawing.Size(429, 125);
this.gbRightToolBar.TabIndex = 1;
this.gbRightToolBar.TabStop = false;
this.gbRightToolBar.Text = "操作台";
//
// btnSampleAssign
//
this.btnSampleAssign.BackColor = System.Drawing.Color.LightSteelBlue;
this.btnSampleAssign.Dock = System.Windows.Forms.DockStyle.Right;
this.btnSampleAssign.Font = new System.Drawing.Font("宋体", 29F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic))));
this.btnSampleAssign.ForeColor = System.Drawing.Color.DarkBlue;
this.btnSampleAssign.Location = new System.Drawing.Point(313, 17);
this.btnSampleAssign.Name = "btnSampleAssign";
this.btnSampleAssign.Size = new System.Drawing.Size(113, 105);
this.btnSampleAssign.TabIndex = 84;
this.btnSampleAssign.Text = "确认交接";
this.btnSampleAssign.UseVisualStyleBackColor = false;
this.btnSampleAssign.Click += new System.EventHandler(this.btnSampleAssign_Click);
//
// lbTips
//
this.lbTips.AutoSize = true;
this.lbTips.Font = new System.Drawing.Font("宋体", 10F);
this.lbTips.ForeColor = System.Drawing.SystemColors.ButtonShadow;
this.lbTips.Location = new System.Drawing.Point(112, 27);
this.lbTips.Name = "lbTips";
this.lbTips.Size = new System.Drawing.Size(119, 14);
this.lbTips.TabIndex = 83;
this.lbTips.Text = "(输入完成报告号)";
//
// lbScanSample
//
this.lbScanSample.AutoSize = true;
this.lbScanSample.Font = new System.Drawing.Font("宋体", 18F);
this.lbScanSample.Location = new System.Drawing.Point(3, 17);
this.lbScanSample.Name = "lbScanSample";
this.lbScanSample.Size = new System.Drawing.Size(118, 24);
this.lbScanSample.TabIndex = 82;
this.lbScanSample.Text = "手动交接:";
//
// tbScanSample
//
this.tbScanSample.BackColor = System.Drawing.SystemColors.Window;
this.tbScanSample.Font = new System.Drawing.Font("宋体", 18F);
this.tbScanSample.Location = new System.Drawing.Point(7, 44);
this.tbScanSample.Name = "tbScanSample";
this.tbScanSample.Size = new System.Drawing.Size(209, 35);
this.tbScanSample.TabIndex = 81;
this.tbScanSample.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tbScanSample_KeyDown);
//
// btnScanRfid
//
this.btnScanRfid.BackColor = System.Drawing.Color.PapayaWhip;
this.btnScanRfid.Font = new System.Drawing.Font("宋体", 23F, System.Drawing.FontStyle.Bold);
this.btnScanRfid.ForeColor = System.Drawing.Color.Chocolate;
this.btnScanRfid.Location = new System.Drawing.Point(7, 82);
this.btnScanRfid.Name = "btnScanRfid";
this.btnScanRfid.Size = new System.Drawing.Size(209, 40);
this.btnScanRfid.TabIndex = 77;
this.btnScanRfid.Text = "开始扫描";
this.btnScanRfid.UseVisualStyleBackColor = false;
this.btnScanRfid.Click += new System.EventHandler(this.btnScanRfid_Click);
//
// plMain
//
this.plMain.Controls.Add(this.gbMain);
this.plMain.Controls.Add(this.gbMainToolBar);
this.plMain.Dock = System.Windows.Forms.DockStyle.Fill;
this.plMain.Location = new System.Drawing.Point(252, 0);
this.plMain.Name = "plMain";
this.plMain.Size = new System.Drawing.Size(407, 667);
this.plMain.TabIndex = 2;
//
// gbMain
//
this.gbMain.Controls.Add(this.dgvSamples);
this.gbMain.Dock = System.Windows.Forms.DockStyle.Fill;
this.gbMain.Location = new System.Drawing.Point(0, 125);
this.gbMain.Name = "gbMain";
this.gbMain.Size = new System.Drawing.Size(407, 542);
this.gbMain.TabIndex = 1;
this.gbMain.TabStop = false;
this.gbMain.Text = "箱内样品";
//
// dgvSamples
//
this.dgvSamples.AllowUserToAddRows = false;
this.dgvSamples.AllowUserToDeleteRows = false;
this.dgvSamples.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgvSamples.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.SampleBizId,
this.SamplePackageName,
this.SampleOwnerName,
this.SampleName,
this.SampleDealTime,
this.SampleDeadTime,
this.SampleQuantityUnit});
this.dgvSamples.Dock = System.Windows.Forms.DockStyle.Fill;
this.dgvSamples.Location = new System.Drawing.Point(3, 17);
this.dgvSamples.Name = "dgvSamples";
this.dgvSamples.ReadOnly = true;
this.dgvSamples.RowTemplate.Height = 23;
this.dgvSamples.Size = new System.Drawing.Size(401, 522);
this.dgvSamples.TabIndex = 0;
this.dgvSamples.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(this.dgvSamples_RowPostPaint);
//
// SampleBizId
//
this.SampleBizId.DataPropertyName = "BizId";
this.SampleBizId.Frozen = true;
this.SampleBizId.HeaderText = "样品报告号";
this.SampleBizId.MinimumWidth = 160;
this.SampleBizId.Name = "SampleBizId";
this.SampleBizId.ReadOnly = true;
this.SampleBizId.Width = 160;
//
// SamplePackageName
//
this.SamplePackageName.DataPropertyName = "PackageName";
this.SamplePackageName.HeaderText = "箱号";
this.SamplePackageName.MinimumWidth = 100;
this.SamplePackageName.Name = "SamplePackageName";
this.SamplePackageName.ReadOnly = true;
//
// SampleOwnerName
//
this.SampleOwnerName.DataPropertyName = "OwnerName";
this.SampleOwnerName.HeaderText = "所属部门";
this.SampleOwnerName.MinimumWidth = 90;
this.SampleOwnerName.Name = "SampleOwnerName";
this.SampleOwnerName.ReadOnly = true;
this.SampleOwnerName.Width = 90;
//
// SampleName
//
this.SampleName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.SampleName.DataPropertyName = "Name";
this.SampleName.HeaderText = "样品名称";
this.SampleName.MinimumWidth = 100;
this.SampleName.Name = "SampleName";
this.SampleName.ReadOnly = true;
//
// SampleDealTime
//
this.SampleDealTime.DataPropertyName = "DealTime";
this.SampleDealTime.HeaderText = "委托日期";
this.SampleDealTime.MinimumWidth = 100;
this.SampleDealTime.Name = "SampleDealTime";
this.SampleDealTime.ReadOnly = true;
//
// SampleDeadTime
//
this.SampleDeadTime.DataPropertyName = "DeadTime";
this.SampleDeadTime.HeaderText = "完成日期";
this.SampleDeadTime.MinimumWidth = 100;
this.SampleDeadTime.Name = "SampleDeadTime";
this.SampleDeadTime.ReadOnly = true;
//
// SampleQuantityUnit
//
this.SampleQuantityUnit.DataPropertyName = "QuantityUnit";
this.SampleQuantityUnit.HeaderText = "数量/单位";
this.SampleQuantityUnit.MinimumWidth = 100;
this.SampleQuantityUnit.Name = "SampleQuantityUnit";
this.SampleQuantityUnit.ReadOnly = true;
//
// gbMainToolBar
//
this.gbMainToolBar.Controls.Add(this.lbCurrentPackageStatus);
this.gbMainToolBar.Controls.Add(this.btnClearCurrentPackage);
this.gbMainToolBar.Controls.Add(this.lbSetPackage);
this.gbMainToolBar.Controls.Add(this.tbSetCurrentPackage);
this.gbMainToolBar.Dock = System.Windows.Forms.DockStyle.Top;
this.gbMainToolBar.Location = new System.Drawing.Point(0, 0);
this.gbMainToolBar.Name = "gbMainToolBar";
this.gbMainToolBar.Size = new System.Drawing.Size(407, 125);
this.gbMainToolBar.TabIndex = 0;
this.gbMainToolBar.TabStop = false;
this.gbMainToolBar.Text = "操作台";
//
// lbCurrentPackageStatus
//
this.lbCurrentPackageStatus.AutoSize = true;
this.lbCurrentPackageStatus.Font = new System.Drawing.Font("宋体", 18F);
this.lbCurrentPackageStatus.ForeColor = System.Drawing.Color.Red;
this.lbCurrentPackageStatus.Location = new System.Drawing.Point(6, 82);
this.lbCurrentPackageStatus.Name = "lbCurrentPackageStatus";
this.lbCurrentPackageStatus.Size = new System.Drawing.Size(0, 24);
this.lbCurrentPackageStatus.TabIndex = 81;
//
// btnClearCurrentPackage
//
this.btnClearCurrentPackage.Location = new System.Drawing.Point(130, 18);
this.btnClearCurrentPackage.Name = "btnClearCurrentPackage";
this.btnClearCurrentPackage.Size = new System.Drawing.Size(103, 23);
this.btnClearCurrentPackage.TabIndex = 80;
this.btnClearCurrentPackage.Text = "重设";
this.btnClearCurrentPackage.UseVisualStyleBackColor = true;
this.btnClearCurrentPackage.Click += new System.EventHandler(this.btnClearCurrentPackage_Click);
//
// lbSetPackage
//
this.lbSetPackage.AutoSize = true;
this.lbSetPackage.Font = new System.Drawing.Font("宋体", 18F);
this.lbSetPackage.Location = new System.Drawing.Point(6, 17);
this.lbSetPackage.Name = "lbSetPackage";
this.lbSetPackage.Size = new System.Drawing.Size(118, 24);
this.lbSetPackage.TabIndex = 79;
this.lbSetPackage.Text = "箱号设置:";
//
// tbSetCurrentPackage
//
this.tbSetCurrentPackage.BackColor = System.Drawing.SystemColors.Window;
this.tbSetCurrentPackage.Font = new System.Drawing.Font("宋体", 18F);
this.tbSetCurrentPackage.Location = new System.Drawing.Point(6, 44);
this.tbSetCurrentPackage.Name = "tbSetCurrentPackage";
this.tbSetCurrentPackage.Size = new System.Drawing.Size(227, 35);
this.tbSetCurrentPackage.TabIndex = 78;
this.tbSetCurrentPackage.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tbSetCurrentPackage_KeyDown);
//
// FrmMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1088, 667);
this.Controls.Add(this.plMain);
this.Controls.Add(this.plRight);
this.Controls.Add(this.plLeft);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "FrmMain";
this.Text = "样品入库交接客户端 1.0(23.5.26)";
this.Load += new System.EventHandler(this.FrmMain_Load);
this.plLeft.ResumeLayout(false);
this.gbInfo.ResumeLayout(false);
this.gbLogin.ResumeLayout(false);
this.gbLogin.PerformLayout();
this.plRight.ResumeLayout(false);
this.gbRfid.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dgvRfidSamples)).EndInit();
this.gbRightToolBar.ResumeLayout(false);
this.gbRightToolBar.PerformLayout();
this.plMain.ResumeLayout(false);
this.gbMain.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dgvSamples)).EndInit();
this.gbMainToolBar.ResumeLayout(false);
this.gbMainToolBar.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Panel plLeft;
private System.Windows.Forms.Panel plRight;
private System.Windows.Forms.Panel plMain;
private System.Windows.Forms.GroupBox gbInfo;
private System.Windows.Forms.Label lbCurrentPackage;
private System.Windows.Forms.Label lbCurrentLocation;
private System.Windows.Forms.Label lbPackageDepartment;
private System.Windows.Forms.TextBox tbCurrentPackage;
private System.Windows.Forms.TextBox tbCurrentLocation;
private System.Windows.Forms.GroupBox gbLogin;
private System.Windows.Forms.Button btnLogout;
private System.Windows.Forms.Button btnLogin;
private System.Windows.Forms.Label lblUrl;
private System.Windows.Forms.Label lblUser;
private System.Windows.Forms.Label lblPassword;
private System.Windows.Forms.TextBox tbxPassword;
private System.Windows.Forms.TextBox tbxServiceUrl;
private System.Windows.Forms.TextBox tbxUserName;
private System.Windows.Forms.GroupBox gbMainToolBar;
private System.Windows.Forms.GroupBox gbRightToolBar;
private System.Windows.Forms.RichTextBox rtbMessage;
private System.Windows.Forms.GroupBox gbMain;
private System.Windows.Forms.DataGridView dgvSamples;
private System.Windows.Forms.Button btnClearCurrentPackage;
private System.Windows.Forms.Label lbSetPackage;
private System.Windows.Forms.TextBox tbSetCurrentPackage;
private System.Windows.Forms.DataGridViewTextBoxColumn SampleBizId;
private System.Windows.Forms.DataGridViewTextBoxColumn SamplePackageName;
private System.Windows.Forms.DataGridViewTextBoxColumn SampleOwnerName;
private System.Windows.Forms.DataGridViewTextBoxColumn SampleName;
private System.Windows.Forms.DataGridViewTextBoxColumn SampleDealTime;
private System.Windows.Forms.DataGridViewTextBoxColumn SampleDeadTime;
private System.Windows.Forms.DataGridViewTextBoxColumn SampleQuantityUnit;
private System.Windows.Forms.GroupBox gbRfid;
private System.Windows.Forms.DataGridView dgvRfidSamples;
private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn1;
private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn2;
private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn3;
private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn4;
private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn5;
private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn6;
private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn7;
private System.Windows.Forms.Label lbTips;
private System.Windows.Forms.Label lbScanSample;
private System.Windows.Forms.TextBox tbScanSample;
private System.Windows.Forms.Button btnScanRfid;
private System.Windows.Forms.ComboBox cbSetCurrentPackageOwner;
private System.Windows.Forms.Label lbCurrentPackageStatus;
private System.Windows.Forms.Button btnSampleAssign;
}
}
using Kivii.Client.SampleAssigns;
using Kivii.Client.SampleInbounds.Entities;
using Kivii.Configuration;
using Kivii.Linq;
using Kivii.Samples.Entities;
using Kivii.Samples.Transforms;
using Readers;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;
namespace Kivii.Client.SampleInbounds
{
public partial class FrmMain : Form
{
#region 私有变量
private JsonServiceClient _client;
private Location _currentLocation;
private Sample _currentPackage;
private List<Sample> _currentPackageSamples;
private List<Sample> _currentScanSamples;
private AuthenticateResponse _userInfo;
private Reader reader;
private ReaderSetting currentSetting;
private InventoryBuffer currentInventoryBuffer;
private string defaultPort = "COM2";
private int defaultBaudrate = 115200;
private bool isConnected = false;
//盘存操作前,需要先设置工作天线,用于标识当前是否在执行盘存操作
private bool m_bInventory = false;
private List<string> _currentTotalEpcs;//每次启动交接读出来的epc号集合,每次重启前会清空
#endregion
public FrmMain()
{
InitializeComponent();
}
private void FrmMain_Load(object sender, EventArgs e)
{
connectReader();
initControls();
loadDefault(tbxServiceUrl, tbxUserName, tbxPassword);
}
#region 界面控件默认值
private void initControls()
{
dgvSamples.AutoGenerateColumns = false;
dgvRfidSamples.AutoGenerateColumns = false;
_currentLocation = null;
_currentPackage = null;
_currentPackageSamples = null;
_currentScanSamples = null;
_currentTotalEpcs = null;
_userInfo = null;
tbxServiceUrl.Enabled = true;
tbxUserName.Enabled = true;
tbxPassword.Enabled = true;
tbSetCurrentPackage.Enabled = false;
btnLogin.Enabled = true;
btnLogout.Enabled = false;
btnScanRfid.Enabled = false;
btnSampleAssign.Enabled = false;
tbScanSample.Enabled = false;
tbScanSample.Text = "";
btnClearCurrentPackage.Enabled = false;
tbCurrentLocation.Text = "";
lbCurrentPackageStatus.Text = "";
cbSetCurrentPackageOwner.DataSource = null;
cbSetCurrentPackageOwner.DisplayMember = "OwnerName";
cbSetCurrentPackageOwner.ValueMember = "OwnerKvid";
tbCurrentPackage.Text = "";
tbSetCurrentPackage.Text = "";
dgvSamples.DataSource = null;
dgvRfidSamples.DataSource = null;
}
private void loadDefault(params Control[] ctls)
{
try
{
using (var conn = KiviiContext.GetOpenedDbConnection<UiSetting>())
{
foreach (var ctl in ctls)
{
//UiSetting setting = null;
var setting = conn.Select<UiSetting>(o => o.FormName == this.Name && o.ControlName == ctl.Name).FirstOrDefault();
if (setting == null)
{
if (ctl.Name == tbxServiceUrl.Name) ctl.Text = Configs.DefaultBaseUrl;
continue;
}
ctl.Text = setting.ControlValue;
}
}
}
catch
{
}
}
private void setDefault(params Control[] ctls)
{
try
{
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);
}
}
}
}
catch
{
}
}
/// <summary>
/// 输出消息
/// </summary>
/// <param name="message">消息内容</param>
/// <param name="clearMessage">是否清除消息</param>
private void outputMessage(string message, bool clearMessage = false)
{
if (this.InvokeRequired)
{
this.Invoke(new Action(() => outputMessage(message, clearMessage)));
return;
}
if (clearMessage) rtbMessage.Clear();
if (rtbMessage.Lines.Count() > 500) rtbMessage.Clear();
var time = DateTime.Now.ToString("HH:mm:ss");
rtbMessage.AppendText($"[{time}]{message}{Environment.NewLine}");
rtbMessage.ScrollToCaret();
}
#endregion
#region Reader Function
private void connectReader()
{
reader = new Reader();
currentSetting = new ReaderSetting();
currentInventoryBuffer = new InventoryBuffer();
//设置回调方法
reader.AnalyCallback = AnalyData;
reader.GetFrequencyRegion(currentSetting.btReadId);
Thread.Sleep(500);
currentInventoryBuffer.ClearInventoryPar();
currentInventoryBuffer.btRepeat = Convert.ToByte(1);//设置每条命令盘存次数 1次
currentInventoryBuffer.bLoopCustomizedSession = false;
currentInventoryBuffer.lAntenna.Add(0x00);//设置天线1
currentInventoryBuffer.lAntenna.Add(0x01);//设置天线2
currentInventoryBuffer.lAntenna.Add(0x02);//设置天线3
currentInventoryBuffer.lAntenna.Add(0x03);//设置天线4
string exception = string.Empty;
int nRet = reader.OpenCom(defaultPort, defaultBaudrate, out exception);
if (nRet != 0)
{
isConnected = false;
outputMessage("连接读写器失败,失败原因: " + exception);
return;
}
else
{
isConnected = true;
outputMessage($"当前连接: {Environment.NewLine}{defaultPort}@{defaultBaudrate}");
}
}
private void disConnectReader()
{
//处理串口断开连接读写器
if (reader != null) reader.CloseCom();
reader = null;
isConnected = false;
return;
}
public void AnalyData(MessageTran msgTran)
{
if (msgTran.PacketType != 0xA0)
{
return;
}
switch (msgTran.Cmd)
{
//case 0x81:
// var tid = ReaderExtension.ProcessReadTag(msgTran, reader, currentInventoryBuffer, currentSetting);
// samplePreAssigning(tid);
// break;
case 0x89://读取Epc
var epc = ReaderExtension.ProcessInventoryReal(msgTran, reader, currentInventoryBuffer, currentSetting);
if (epc.IsNullOrEmpty()) return;
if (_currentTotalEpcs.IsNullOrEmpty()) _currentTotalEpcs = new List<string>();
if (!_currentTotalEpcs.Contains(epc))
{
_currentTotalEpcs.Add(epc);
samplePreAssigning(null, epc);
}
this.Invoke(new Action(delegate
{
outputMessage($"共扫描到:{_currentTotalEpcs.Count}个Rfid。");
}));
break;
case 0x74:
ReaderExtension.ProcessSetWorkAntenna(msgTran, reader, currentInventoryBuffer, currentSetting, m_bInventory);
break;
}
}
public void btnRealTimeInventory_Start()
{
this.Invoke(new Action(delegate
{
dgvRfidSamples.DataSource = null;
btnScanRfid.Text = "停止扫描";
btnScanRfid.BackColor = Color.DarkGray;
btnScanRfid.ForeColor = Color.Black;
}));
outputMessage("开始扫描中...");
_currentTotalEpcs = new List<string>();//每次启动交接就要把当前epc号全部清空
_currentScanSamples = null;
m_bInventory = true;
currentInventoryBuffer.bLoopInventory = true;
currentInventoryBuffer.bLoopInventoryReal = true;
currentInventoryBuffer.ClearInventoryRealResult();
byte btWorkAntenna = currentInventoryBuffer.lAntenna[currentInventoryBuffer.nIndexAntenna];
reader.SetWorkAntenna(currentSetting.btReadId, btWorkAntenna);
currentSetting.btWorkAntenna = btWorkAntenna;
return;
}
public void btnRealTimeInventory_Stop()
{
m_bInventory = false;
currentInventoryBuffer.bLoopInventory = false;
this.Invoke(new Action(delegate
{
btnScanRfid.Text = "开始扫描";
btnScanRfid.BackColor = Color.PapayaWhip;
btnScanRfid.ForeColor = Color.Chocolate;
}));
outputMessage("停止扫描");
return;
}
#endregion
#region 业务方法
private void initUserInfo(AuthenticateResponse response = null)
{
if (response == null)
{
_userInfo = null;
_currentLocation = null;
_currentPackage = null;
return;
}
_userInfo = new AuthenticateResponse();
_userInfo.PopulateWith(response);
//tbCurrentPackageDepartment.Text = _userInfo.DepartmentName;
initLocation();
}
private void initLocation()
{
if (_client == null)
{
MessageBox.Show("请先登录!");
return;
}
if (_userInfo == null)
{
MessageBox.Show("未取得登录人信息,请重新登录!");
return;
}
var request = new LocationQuery();
request.OwnerKvid = _userInfo.DepartmentKvid;
request.OwnerKvid = Guid.Parse("5F344646-C9D2-413F-8DC6-500265C01CA2");//仓库
//request.OwnerKvid = Guid.Parse("D4CE47D2-5FC8-479D-A0CA-BACDF1A891BF");//色牢度组
//request.OwnerKvid = Guid.Parse("9D026818-6E78-40F8-A715-2887F96F34DC");//纤检组
//request.OwnerKvid = Guid.Parse("208C24FB-1443-4B9E-9886-02ED3B9A8F45");//安全组
//request.OwnerKvid = Guid.Parse("7CF9CF7B-19F5-4A1A-A94C-5BC21EA8ED76");//纤维含量组
//request.OwnerKvid = Guid.Parse("BB355D5A-9D4E-4337-B577-7BB7A1625F68");//羽绒组
var task = _client.PostAsync(request);
task.Success(resp =>
{
if (resp.Results.Count <= 0)
{
MessageBox.Show("未找到当前登录人所在组及位置信息!", "位置信息");
return;
}
var location = resp.Results.FirstOrDefault();
_currentLocation = new Location();
_currentLocation.PopulateWith(location);
tbSetCurrentPackage.Enabled = _currentLocation != null;
tbCurrentLocation.Text = _currentLocation.Address;
});
task.Error(err =>
{
_currentLocation = null;
tbSetCurrentPackage.Enabled = _currentLocation != null;
MessageBox.Show(err.Message, "位置信息");
});
}
private void searchPackage()
{
if (_client == null)
{
MessageBox.Show("请先登录!");
return;
}
if (tbSetCurrentPackage.Text.IsNullOrEmpty())
{
MessageBox.Show("请输入箱号!");
return;
}
var request = new SampleQuery();
request.Name = tbSetCurrentPackage.Text;
request.Type = SampleType.Package;
var task = _client.PostAsync(request);
task.Success(resp =>
{
if (resp.Results.Count <= 0)
{
_currentPackage = null;
MessageBox.Show("未找到箱号!", "箱号设置");
return;
}
var package = resp.Results.FirstOrDefault();
_currentPackage = new Sample();
_currentPackage.PopulateWith(package);
tbSetCurrentPackage.Enabled = _currentPackage == null;
tbCurrentPackage.Text = _currentPackage.Name + (_currentPackage.PackageName.IsNullOrEmpty() ? "" : $"({_currentPackage.PackageName})");
btnClearCurrentPackage.Enabled = _currentPackage != null;
//cbSetCurrentPackageNode.Enabled = _currentPackage.Status == (int)PackageStatus.Empty || _currentPackage.Status == (int)PackageStatus.Full;
btnScanRfid.Enabled = _currentPackage.Status == (int)PackageStatus.Full;
btnSampleAssign.Enabled = _currentPackage.Status == (int)PackageStatus.Full;
tbScanSample.Enabled = _currentPackage.Status == (int)PackageStatus.Full;
tbScanSample.Text = "";
if (_currentPackage.Status != (int)PackageStatus.Empty)
{
querySampleInPackaged();
}
if (_currentPackage.Status != (int)PackageStatus.Full)
{
lbCurrentPackageStatus.Text = _currentPackage.Status == (int)PackageStatus.Inbound ? "当前箱子已入库" : "当前箱子无样品";
outputMessage($"当前箱子为{(_currentPackage.Status == (int)PackageStatus.Inbound ? "已入库" : "空闲")}状态,无法继续操作!");
return;
}
Thread.Sleep(200);
btnScanRfid_Click(null, null);
});
task.Error(err =>
{
_currentPackage = null;
tbSetCurrentPackage.Enabled = true;
tbCurrentPackage.Text = "";
btnClearCurrentPackage.Enabled = false;
//cbSetCurrentPackageNode.SelectedItem = null;
//cbSetCurrentPackageNode.Enabled = false;
btnScanRfid.Enabled = false;
tbScanSample.Enabled = false;
tbScanSample.Text = "";
outputMessage($"查询箱号错误!原因:{err.GetResponseStatus().Message}");
});
}
private void querySampleInPackaged()
{
if (_client == null)
{
MessageBox.Show("请先登录!");
return;
}
if (_currentPackage == null)
{
MessageBox.Show("请先设置箱号!");
return;
}
this.Invoke(new Action(delegate
{
dgvSamples.DataSource = null;
}));
var request = new SampleQuery2();
request.PackageKvid = _currentPackage.Kvid;
var task = _client.PostAsync(request);
task.Success(resp =>
{
var owners = new List<Sample>();
foreach (var item in resp.Results)
{
if (owners.Exists(o => o.OwnerKvid == item.OwnerKvid)) continue;
owners.Add(item);
}
_currentPackageSamples = resp.Results.ToList();
this.Invoke(new Action(delegate
{
cbSetCurrentPackageOwner.DataSource = owners;
cbSetCurrentPackageOwner.SelectedIndex = 0;
cbSetCurrentPackageOwner.Enabled = true;
dgvSamples.DataSource = _currentPackageSamples;
}));
outputMessage($"成功查询到箱号:{_currentPackage.Name}{_currentPackageSamples.Count}件样品!");
});
task.Error(err =>
{
outputMessage($"查询样品错误!原因:{err.GetResponseStatus().Message}");
//MessageBox.Show(err.Message, "查询样品");
});
}
private void samplePreAssigning(string tid = null, string epc = null, string bizId = null)
{
if (tid.IsNullOrEmpty() && bizId.IsNullOrEmpty() && epc.IsNullOrEmpty()) return;
var request = new SamplePrePackaging();
if (!tid.IsNullOrEmpty()) request.Tid = tid;
if (!bizId.IsNullOrEmpty()) request.BizId = bizId;
if(Guid.TryParse(epc, out var epcKvid))
{
request.BizKvid = epcKvid;
}
var ownerSelected = cbSetCurrentPackageOwner.SelectedItem as Sample;
if (ownerSelected == null)
{
outputMessage("请设置交接组部门信息!");
return;
}
request.OwnerKvid = ownerSelected.OwnerKvid;
try
{
var resp = _client.Post(request);
if (resp.Results.Count <= 0)
{
MessageBox.Show("未找到样品,当前组不包含此样品!", "交接查询");
outputMessage("未找到样品,当前组不包含此样品!");
return;
}
var record = resp.Results[0];
if (_currentScanSamples == null) _currentScanSamples = new List<Sample>();
if (!_currentScanSamples.Exists(o => o.Kvid == record.Kvid))
{
_currentScanSamples.Add(record);
}
this.Invoke(new Action(delegate
{
dgvRfidSamples.DataSource = null;
}));
this.Invoke(new Action(delegate
{
dgvRfidSamples.DataSource = _currentScanSamples;
}));
//sampleAssigning(record);
}
catch (Exception ex)
{
outputMessage($"交接查询错误,{ex.GetResponseStatus().Message}");
}
}
private void samplePackaging(List<Guid> kvids)
{
var request = new SamplePackaging();
request.Package = _currentPackage;
request.Kvids = kvids;
request.Location = _currentLocation;
var rtns = new List<Sample>();
//var task = _client.PostAsync(request);
try
{
var resp = _client.Post(request);
if (resp.Results.Count <= 0)
{
return;
}
if (_currentScanSamples == null) _currentScanSamples = new List<Sample>();
foreach (var record in resp.Results)
{
if (_currentScanSamples.Exists(o => o.Kvid == record.Kvid))
{
_currentScanSamples.RemoveAll(o => o.Kvid == record.Kvid);
outputMessage($"{record.BizId}样品:[{record.Name}]在{_currentLocation.Address}处入箱完成.");
}
this.Invoke(new Action(delegate
{
dgvRfidSamples.DataSource = null;
}));
this.Invoke(new Action(delegate
{
dgvRfidSamples.DataSource = _currentScanSamples;
}));
}
//rtns.AddRange(resp.Results);
}
catch (Exception ex)
{
outputMessage($"入箱错误,原因:{ex.GetResponseStatus().Message}");
}
}
private void sampleAssigning(List<Guid> kvids)
{
var request = new SampleAssign();
request.Kvids = kvids;
request.Location = _currentLocation;
//var task = _client.PostAsync(request);
try
{
var resp = _client.Post(request);
if (resp.Results.Count <= 0)
{
return;
}
if (_currentScanSamples == null) _currentScanSamples = new List<Sample>();
foreach (var record in resp.Results)
{
if (_currentScanSamples.Exists(o => o.Kvid == record.Kvid))
{
_currentScanSamples.RemoveAll(o => o.Kvid == record.Kvid);
outputMessage($"{record.BizId}样品:[{record.Name}]交接至{_currentLocation.Address}完成.");
}
this.Invoke(new Action(delegate
{
dgvRfidSamples.DataSource = null;
}));
this.Invoke(new Action(delegate
{
dgvRfidSamples.DataSource = _currentScanSamples;
}));
}
}
catch (Exception ex)
{
outputMessage($"交接错误,原因:{ex.GetResponseStatus().Message}");
//MessageBox.Show(ex.GetResponseStatus().Message, "样品入箱");
}
}
private void preSampleAssigning(List<Sample> samples)
{
if (samples.IsNullOrEmpty()) return;
var kvids = new List<Guid>();
var unPackageKvids = new List<Guid>();
foreach (var sample in samples)//过滤重复交接的
{
if (sample.PackageKvid == Guid.Empty)//扫描的样品并未在设置的包裹里
{
unPackageKvids.Add(sample.Kvid);
continue;
}
if (sample.CurrentLocation == null)
{
this.Invoke(new Action(delegate
{
dgvRfidSamples.DataSource = null;
}));
_currentScanSamples.RemoveAll(o => o.Kvid == sample.Kvid);
outputMessage($"{sample.BizId}样品:[{sample.Name}]无地点信息,已移除交接.");
this.Invoke(new Action(delegate
{
dgvRfidSamples.DataSource = _currentScanSamples;
}));
continue;
}
if (sample.CurrentLocation.InternalCode == _currentLocation.InternalCode)
{
this.Invoke(new Action(delegate
{
dgvRfidSamples.DataSource = null;
}));
_currentScanSamples.RemoveAll(o => o.Kvid == sample.Kvid);
outputMessage($"{sample.BizId}样品:[{sample.Name}]已经在仓库,重复交接,已自动移除.");
this.Invoke(new Action(delegate
{
dgvRfidSamples.DataSource = _currentScanSamples;
}));
continue;
}
kvids.Add(sample.Kvid);
}
if (!kvids.IsNullOrEmpty())
{
sampleAssigning(kvids);
}
if (!unPackageKvids.IsNullOrEmpty())
{
samplePackaging(unPackageKvids);
}
}
#endregion
private void btnLogin_Click(object sender, EventArgs e)
{
if (_client != null)
{
MessageBox.Show("登陆前先退出原连接");
return;
}
btnLogin.Enabled = false;
_client = new JsonServiceClient(tbxServiceUrl.Text);
var auth = new Authenticate { UserName = tbxUserName.Text, Password = tbxPassword.Text, provider = "Kivii" };
var task = _client.PostAsync(auth);
task.Success(resp =>
{
initUserInfo(resp);
btnLogin.Enabled = false;
btnLogout.Enabled = !btnLogin.Enabled;
tbxServiceUrl.Enabled = btnLogin.Enabled;
tbxUserName.Enabled = btnLogin.Enabled;
tbxPassword.Enabled = btnLogin.Enabled;
//tbSetCurrentPackage.Enabled = !btnLogin.Enabled;
setDefault(tbxServiceUrl, tbxUserName, tbxPassword);
outputMessage($"登录成功,登录人:{resp.DisplayName}", true);
}, true);
task.Error(err =>
{
btnLogin.Enabled = true;
initUserInfo();
_client.Dispose();
_client = null;
outputMessage($"登录失败,原因:{err.GetResponseStatus().Message}");
}, true);
}
private void btnLogout_Click(object sender, EventArgs e)
{
if (_client == null)
{
MessageBox.Show("未连接");
return;
}
btnLogout.Enabled = false;
var auth = new Authenticate { provider = "Logout" };
var task = _client.PostAsync(auth);
task.Success(resp =>
{
initControls();
_client.Dispose();
_client = null;
initUserInfo();
outputMessage($"退出成功");
});
task.Error(err =>
{
btnLogout.Enabled = true;
MessageBox.Show(err.Message, "Logout Error");
outputMessage($"退出失败!原因:{err.GetResponseStatus().Message}");
});
}
private void tbxPassword_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
btnLogin_Click(null, null);
}
}
private void tbSetCurrentPackage_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
searchPackage();
}
}
private void btnClearCurrentPackage_Click(object sender, EventArgs e)
{
_currentPackage = null;
_currentPackageSamples = null;
_currentScanSamples = null;
tbSetCurrentPackage.Enabled = true;
tbCurrentPackage.Text = "";
btnClearCurrentPackage.Enabled = false;
btnScanRfid.Enabled = false;
btnSampleAssign.Enabled = false;
tbScanSample.Enabled = false;
tbScanSample.Text = "";
lbCurrentPackageStatus.Text = "";
cbSetCurrentPackageOwner.DataSource = null;
cbSetCurrentPackageOwner.DisplayMember = "OwnerName";
cbSetCurrentPackageOwner.ValueMember = "OwnerKvid";
cbSetCurrentPackageOwner.Enabled = false;
dgvSamples.DataSource = null;
dgvRfidSamples.DataSource = null;
btnRealTimeInventory_Stop();
outputMessage($"箱号已重设!");
}
private void dgvSamples_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
dgvSamples.TopLeftHeaderCell.Value = "序号";
//自动编号,与数据无关
Rectangle rectangle = new Rectangle(e.RowBounds.Location.X,
e.RowBounds.Location.Y,
dgvSamples.RowHeadersWidth - 4,
e.RowBounds.Height);
TextRenderer.DrawText(e.Graphics,
(e.RowIndex + 1).ToString(),
dgvSamples.RowHeadersDefaultCellStyle.Font,
rectangle,
dgvSamples.RowHeadersDefaultCellStyle.ForeColor,
TextFormatFlags.VerticalCenter | TextFormatFlags.Right);
}
private void dgvRfidSamples_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
dgvSamples.TopLeftHeaderCell.Value = "序号";
//自动编号,与数据无关
Rectangle rectangle = new Rectangle(e.RowBounds.Location.X,
e.RowBounds.Location.Y,
dgvSamples.RowHeadersWidth - 4,
e.RowBounds.Height);
TextRenderer.DrawText(e.Graphics,
(e.RowIndex + 1).ToString(),
dgvSamples.RowHeadersDefaultCellStyle.Font,
rectangle,
dgvSamples.RowHeadersDefaultCellStyle.ForeColor,
TextFormatFlags.VerticalCenter | TextFormatFlags.Right);
}
private void cbSetCurrentPackageOwner_SelectedValueChanged(object sender, EventArgs e)
{
var selected = cbSetCurrentPackageOwner.SelectedItem as Sample;
if (selected != null) outputMessage($"当前设置交接组:{selected.OwnerName}!");
}
private void tbScanSample_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
if (_client == null)
{
MessageBox.Show("请先登录.");
return;
}
if (_currentLocation == null)
{
MessageBox.Show("未获取当前位置.");
return;
}
if (_currentPackage == null)
{
MessageBox.Show("未获取当前箱号.");
return;
}
if (_currentPackage.Status != (int)PackageStatus.Full)
{
outputMessage($"当前箱子为{(_currentPackage.Status == (int)PackageStatus.Inbound ? "已入库" : "空闲")}状态,无法继续操作!");
return;
}
samplePreAssigning(null, null, tbScanSample.Text);
}
}
private void btnScanRfid_Click(object sender, EventArgs e)
{
if (!isConnected || reader == null)
{
MessageBox.Show("读写器未连接,请先连接读写器!");
return;
}
//reader.ReadTag(currentSetting.btReadId, 2, 0, 8);
//if (!isConnected || reader == null)
//{
// connectReader();
// Thread.Sleep(1000);
//}
if (currentInventoryBuffer.bLoopInventory)
{
btnRealTimeInventory_Stop();
}
else
{
btnRealTimeInventory_Start();
}
}
private void btnSampleAssign_Click(object sender, EventArgs e)
{
if (_currentScanSamples.IsNullOrEmpty()) return;
var assignSamples = _currentScanSamples.ToList();//new一个list不影响原来的数组
preSampleAssigning(assignSamples);
}
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{F1CEFFAD-7EA4-4456-B1CA-68CAD975A693}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>Kivii.Client.SampleInbounds</RootNamespace>
<AssemblyName>样品入库交接客户端</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>F.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="Kivii.Common.V4.0, Version=5.6.2023.4000, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Kivii.Common.5.6.2023.4000\lib\net40\Kivii.Common.V4.0.dll</HintPath>
</Reference>
<Reference Include="Kivii.Core.V4.0, Version=5.6.2023.4140, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Kivii.Core.5.6.2023.4140\lib\net40\Kivii.Core.V4.0.dll</HintPath>
</Reference>
<Reference Include="Kivii.Linq.Sqlite.V4.0, Version=5.6.2023.3000, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Kivii.Linq.Sqlite.5.6.2023.3000\lib\net40\Kivii.Linq.Sqlite.V4.0.dll</HintPath>
</Reference>
<Reference Include="Kivii.Linq.V4.0, Version=5.6.2023.4200, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Kivii.Linq.5.6.2023.4200\lib\net40\Kivii.Linq.V4.0.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Configs.cs" />
<Compile Include="Entities\Sample.Entities.cs" />
<Compile Include="Entities\UiSetting.cs" />
<Compile Include="FrmMain.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FrmMain.Designer.cs">
<DependentUpon>FrmMain.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Reader\InventoryBuffer.cs" />
<Compile Include="Reader\ITalker.cs" />
<Compile Include="Reader\MessageTran.cs" />
<Compile Include="Reader\Reader.cs" />
<Compile Include="Reader\Reader.Extensions.cs" />
<Compile Include="Reader\ReaderSetting.cs" />
<Compile Include="Reader\Talker.cs" />
<Compile Include="Requests\RestfulRequests.cs" />
<EmbeddedResource Include="FrmMain.resx">
<DependentUpon>FrmMain.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="App.config" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<Content Include="F.ico" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectView>ProjectFiles</ProjectView>
</PropertyGroup>
</Project>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace Kivii.Client.SampleInbounds.V4._0
{
internal static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new FrmMain());
}
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("Kivii.Client.SampleInbounds.V4.0")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Kivii.Client.SampleInbounds.V4.0")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("f1ceffad-7ea4-4456-b1ca-68cad975a693")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace Kivii.Client.SampleInbounds.Properties {
using System;
/// <summary>
/// 一个强类型的资源类,用于查找本地化的字符串等。
/// </summary>
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// 返回此类使用的缓存的 ResourceManager 实例。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Kivii.Client.SampleInbounds.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// 重写当前线程的 CurrentUICulture 属性,对
/// 使用此强类型资源类的所有资源查找执行重写。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace Kivii.Client.SampleInbounds.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.5.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;
namespace Readers
{
public delegate void MessageReceivedEventHandler(byte[] btAryBuffer);
interface ITalker
{
event MessageReceivedEventHandler MessageReceived; // 接收到发来的消息
bool Connect(IPAddress ip, int port, out string strException); // 连接到服务端
bool SendMessage(byte[] btAryBuffer); // 发送数据包
void SignOut(); // 注销连接
bool IsConnect(); //校验是否连接服务器
}
}
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
namespace Kivii.Client.SampleAssigns
{
public class InventoryBuffer
{
public byte btRepeat;
public byte btSession;
public byte btTarget;
public List<byte> lAntenna;
public bool bLoopInventory;
public int nIndexAntenna;
public int nCommond;
public bool bLoopInventoryReal;
public bool bLoopCustomizedSession;
public int nTagCount;
public int nDataCount; //执行一次命令所返回的标签记录条数
public int nCommandDuration;
public int nReadRate;
public int nCurrentAnt;
public List<int> lTotalRead;
public DateTime dtStartInventory;
public DateTime dtEndInventory;
public int nMaxRSSI;
public int nMinRSSI;
public DataTable dtTagTable;
public DataTable dtTagDetailTable;
public InventoryBuffer()
{
btRepeat = 0x00;
lAntenna = new List<byte>();
bLoopInventory = false;
nIndexAntenna = 0;
nCommond = 0;
bLoopInventoryReal = false;
nTagCount = 0;
nReadRate = 0;
lTotalRead = new List<int>();
dtStartInventory = DateTime.Now;
dtEndInventory = DateTime.Now;
nMaxRSSI = 0;
nMinRSSI = 0;
dtTagTable = new DataTable();
dtTagTable.Columns.Add("COLPC", typeof(string));
dtTagTable.Columns.Add("COLCRC", typeof(string));
dtTagTable.Columns.Add("COLEPC", typeof(string));
dtTagTable.Columns.Add("COLANT", typeof(string));
dtTagTable.Columns.Add("COLRSSI", typeof(string));
dtTagTable.Columns.Add("COLINVCNT", typeof(string));
dtTagTable.Columns.Add("COLFREQ", typeof(string));
dtTagTable.Columns.Add("COLANT1", typeof(string));
dtTagTable.Columns.Add("COLANT2", typeof(string));
dtTagTable.Columns.Add("COLANT3", typeof(string));
dtTagTable.Columns.Add("COLANT4", typeof(string));
dtTagDetailTable = new DataTable();
dtTagDetailTable.Columns.Add("COLEPC", typeof(string));
dtTagDetailTable.Columns.Add("COLRSSI", typeof(string));
dtTagDetailTable.Columns.Add("COLANT", typeof(string));
dtTagDetailTable.Columns.Add("COLFRE", typeof(string));
}
public void ClearInventoryPar()
{
btRepeat = 0x00;
lAntenna.Clear();
//bLoopInventory = false;
nIndexAntenna = 0;
nCommond = 0;
bLoopInventoryReal = false;
}
public void ClearInventoryResult()
{
nTagCount = 0;
nReadRate = 0;
lTotalRead.Clear();
dtStartInventory = DateTime.Now;
dtEndInventory = DateTime.Now;
nMaxRSSI = 0;
nMinRSSI = 0;
dtTagTable.Rows.Clear();
}
public void ClearInventoryRealResult()
{
nTagCount = 0;
nReadRate = 0;
lTotalRead.Clear();
dtStartInventory = DateTime.Now;
dtEndInventory = DateTime.Now;
nMaxRSSI = 0;
nMinRSSI = 0;
dtTagTable.Rows.Clear();
dtTagDetailTable.Clear();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Readers
{
public class MessageTran
{
private byte btPacketType; //数据包头,默认为0xA0
private byte btDataLen; //数据包长度,数据包从‘长度’字节后面开始的字节数,不包含‘长度’字节本身
private byte btReadId; //读写器地址
private byte btCmd; //数据包命令代码
private byte[] btAryData; //数据包命令参数,部分命令无参数
private byte btCheck; //校验和,除校验和本身外所有字节的校验和
private byte[] btAryTranData; //完整数据包
//设置属性
public byte[] AryTranData
{
get
{
return btAryTranData;
}
}
public byte[] AryData
{
get
{
return btAryData;
}
}
public byte ReadId
{
get
{
return btReadId;
}
}
public byte Cmd
{
get
{
return btCmd;
}
}
public byte PacketType
{
get
{
return btPacketType;
}
}
public MessageTran()
{
}
public MessageTran(byte btReadId, byte btCmd, byte[] btAryData)
{
int nLen = btAryData.Length;
this.btPacketType = 0xA0;
this.btDataLen = Convert.ToByte(nLen + 3);
this.btReadId = btReadId;
this.btCmd = btCmd;
this.btAryData = new byte[nLen];
btAryData.CopyTo(this.btAryData, 0);
this.btAryTranData = new byte[nLen + 5];
this.btAryTranData[0] = this.btPacketType;
this.btAryTranData[1] = this.btDataLen;
this.btAryTranData[2] = this.btReadId;
this.btAryTranData[3] = this.btCmd;
this.btAryData.CopyTo(this.btAryTranData, 4);
this.btCheck = CheckSum(this.btAryTranData, 0, nLen + 4);
this.btAryTranData[nLen + 4] = this.btCheck;
}
public MessageTran(byte btReadId, byte btCmd)
{
this.btPacketType = 0xA0;
this.btDataLen = 0x03;
this.btReadId = btReadId;
this.btCmd = btCmd;
this.btAryTranData = new byte[5];
this.btAryTranData[0] = this.btPacketType;
this.btAryTranData[1] = this.btDataLen;
this.btAryTranData[2] = this.btReadId;
this.btAryTranData[3] = this.btCmd;
this.btCheck = CheckSum(this.btAryTranData, 0, 4);
this.btAryTranData[4] = this.btCheck;
}
public MessageTran(byte[] btAryTranData)
{
int nLen = btAryTranData.Length;
this.btAryTranData = new byte[nLen];
btAryTranData.CopyTo(this.btAryTranData, 0);
byte btCK = CheckSum(this.btAryTranData, 0, this.btAryTranData.Length - 1);
if (btCK != btAryTranData[nLen - 1])
{
return;
}
this.btPacketType = btAryTranData[0];
this.btDataLen = btAryTranData[1];
this.btReadId = btAryTranData[2];
this.btCmd = btAryTranData[3];
this.btCheck = btAryTranData[nLen - 1];
if (nLen > 5)
{
this.btAryData = new byte[nLen - 5];
for (int nloop = 0; nloop < nLen - 5; nloop++ )
{
this.btAryData[nloop] = btAryTranData[4 + nloop];
}
}
}
public byte CheckSum(byte[] btAryBuffer, int nStartPos, int nLen)
{
byte btSum = 0x00;
for (int nloop = nStartPos; nloop < nStartPos + nLen; nloop++ )
{
btSum += btAryBuffer[nloop];
}
return Convert.ToByte(((~btSum) + 1) & 0xFF);
}
}
}
using Readers;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Runtime.InteropServices.ComTypes;
using System.Text;
namespace Kivii.Client.SampleAssigns
{
public class ReaderExtension
{
public static string FormatErrorCode(byte btErrorCode)
{
string strErrorCode = "";
switch (btErrorCode)
{
case 0x10:
strErrorCode = "命令已执行";
break;
case 0x11:
strErrorCode = "命令执行失败";
break;
case 0x20:
strErrorCode = "CPU 复位错误";
break;
case 0x21:
strErrorCode = "打开CW 错误";
break;
case 0x22:
strErrorCode = "天线未连接";
break;
case 0x23:
strErrorCode = "写Flash 错误";
break;
case 0x24:
strErrorCode = "读Flash 错误";
break;
case 0x25:
strErrorCode = "设置发射功率错误";
break;
case 0x31:
strErrorCode = "盘存标签错误";
break;
case 0x32:
strErrorCode = "读标签错误";
break;
case 0x33:
strErrorCode = "写标签错误";
break;
case 0x34:
strErrorCode = "锁定标签错误";
break;
case 0x35:
strErrorCode = "灭活标签错误";
break;
case 0x36:
strErrorCode = "无可操作标签错误";
break;
case 0x37:
strErrorCode = "成功盘存但访问失败";
break;
case 0x38:
strErrorCode = "缓存为空";
break;
case 0x40:
strErrorCode = "访问标签错误或访问密码错误";
break;
case 0x41:
strErrorCode = "无效的参数";
break;
case 0x42:
strErrorCode = "wordCnt 参数超过规定长度";
break;
case 0x43:
strErrorCode = "MemBank 参数超出范围";
break;
case 0x44:
strErrorCode = "Lock 数据区参数超出范围";
break;
case 0x45:
strErrorCode = "LockType 参数超出范围";
break;
case 0x46:
strErrorCode = "读卡器地址无效";
break;
case 0x47:
strErrorCode = "Antenna_id 超出范围";
break;
case 0x48:
strErrorCode = "输出功率参数超出范围";
break;
case 0x49:
strErrorCode = "射频规范区域参数超出范围";
break;
case 0x4A:
strErrorCode = "波特率参数超过范围";
break;
case 0x4B:
strErrorCode = "蜂鸣器设置参数超出范围";
break;
case 0x4C:
strErrorCode = "EPC 匹配长度越界";
break;
case 0x4D:
strErrorCode = "EPC 匹配长度错误";
break;
case 0x4E:
strErrorCode = "EPC 匹配参数超出范围";
break;
case 0x4F:
strErrorCode = "频率范围设置参数错误";
break;
case 0x50:
strErrorCode = "无法接收标签的RN16";
break;
case 0x51:
strErrorCode = "DRM 设置参数错误";
break;
case 0x52:
strErrorCode = "PLL 不能锁定";
break;
case 0x53:
strErrorCode = "射频芯片无响应";
break;
case 0x54:
strErrorCode = "输出达不到指定的输出功率";
break;
case 0x55:
strErrorCode = "版权认证未通过";
break;
case 0x56:
strErrorCode = "频谱规范设置错误";
break;
case 0x57:
strErrorCode = "输出功率过低";
break;
case 0xFF:
strErrorCode = "未知错误";
break;
default:
break;
}
return strErrorCode;
}
/// <summary>
/// 16进制字符数组转成字符串
/// </summary>
/// <param name="btAryHex"></param>
/// <param name="nIndex"></param>
/// <param name="nLen"></param>
/// <returns></returns>
public static string ByteArrayToString(byte[] btAryHex, int nIndex, int nLen)
{
if (nIndex + nLen > btAryHex.Length)
{
nLen = btAryHex.Length - nIndex;
}
string strResult = string.Empty;
for (int nloop = nIndex; nloop < nIndex + nLen; nloop++)
{
string strTemp = string.Format(" {0:X2}", btAryHex[nloop]);
strResult += strTemp;
}
return strResult;
}
public static void ProcessSetWorkAntenna(MessageTran msgTran,Reader reader, InventoryBuffer buffer, ReaderSetting setting,bool m_bInventory)
{
int intCurrentAnt = 0;
intCurrentAnt = setting.btWorkAntenna + 1;
string strCmd = "设置工作天线成功,当前工作天线: 天线" + intCurrentAnt.ToString();
string strErrorCode = string.Empty;
if (msgTran.AryData.Length == 1)
{
if (msgTran.AryData[0] == 0x10)
{
setting.btReadId = msgTran.ReadId;
//WriteLog(logRichTxt, strCmd, 0);
//校验是否盘存操作
if (m_bInventory)
{
RunLoopInventroy(reader,buffer,setting);
}
return;
}
else
{
strErrorCode = FormatErrorCode(msgTran.AryData[0]);
}
}
else
{
strErrorCode = "未知错误";
}
string strLog = strCmd + "失败,失败原因: " + strErrorCode;
//WriteLog(logRichTxt, strLog, 1);
if (m_bInventory)
{
buffer.nCommond = 1;
buffer.dtEndInventory = DateTime.Now;
RunLoopInventroy(reader,buffer, setting);
}
}
public static void RunLoopInventroy(Reader reader,InventoryBuffer buffer,ReaderSetting setting)
{
//校验盘存是否所有天线均完成
if (buffer.nIndexAntenna < buffer.lAntenna.Count - 1 || buffer.nCommond == 0)
{
if (buffer.nCommond == 0)
{
buffer.nCommond = 1;
if (buffer.bLoopInventoryReal)
{
//m_bLockTab = true;
//btnInventory.Enabled = false;
if (buffer.bLoopCustomizedSession)//自定义Session和Inventoried Flag
{
reader.CustomizedInventory(setting.btReadId, buffer.btSession, buffer.btTarget, buffer.btRepeat);
}
else //实时盘存
{
reader.InventoryReal(setting.btReadId, buffer.btRepeat);
}
}
else
{
if (buffer.bLoopInventory)
reader.Inventory(setting.btReadId, buffer.btRepeat);
}
}
else
{
buffer.nCommond = 0;
buffer.nIndexAntenna++;
byte btWorkAntenna = buffer.lAntenna[buffer.nIndexAntenna];
reader.SetWorkAntenna(setting.btReadId, btWorkAntenna);
setting.btWorkAntenna = btWorkAntenna;
}
}
//校验是否循环盘存
else if (buffer.bLoopInventory)
{
buffer.nIndexAntenna = 0;
buffer.nCommond = 0;
byte btWorkAntenna = buffer.lAntenna[buffer.nIndexAntenna];
reader.SetWorkAntenna(setting.btReadId, btWorkAntenna);
setting.btWorkAntenna = btWorkAntenna;
}
}
public static string ProcessReadTag(MessageTran msgTran, Reader reader, InventoryBuffer buffer, ReaderSetting setting)
{
string strErrorCode = string.Empty;
if (msgTran.AryData.Length == 1)
{
strErrorCode = FormatErrorCode(msgTran.AryData[0]);
return string.Empty;
}
else
{
int nLen = msgTran.AryData.Length;
int nDataLen = Convert.ToInt32(msgTran.AryData[nLen - 3]);
int nEpcLen = Convert.ToInt32(msgTran.AryData[2]) - nDataLen - 4;
string strPC = ByteArrayToString(msgTran.AryData, 3, 2);
string strEPC = ByteArrayToString(msgTran.AryData, 5, nEpcLen);
string strCRC = ByteArrayToString(msgTran.AryData, 5 + nEpcLen, 2);
string strTid = ByteArrayToString(msgTran.AryData, 7 + nEpcLen, nDataLen);
byte byTemp = msgTran.AryData[nLen - 2];
byte byAntId = (byte)((byTemp & 0x03) + 1);
string strAntId = byAntId.ToString();
string strReadCount = msgTran.AryData[nLen - 1].ToString();
DataRow row = buffer.dtTagTable.NewRow();
row[0] = strPC;
row[1] = strCRC;
row[2] = strEPC;
row[3] = strTid;
row[4] = nDataLen.ToString();
row[5] = strAntId;
row[6] = strReadCount;
buffer.dtTagTable.Rows.Add(row);
buffer.dtTagTable.AcceptChanges();
return strTid;
}
}
public static string ProcessInventoryReal(MessageTran msgTran, Reader reader, InventoryBuffer buffer, ReaderSetting setting)
{
if (msgTran.AryData.Length == 1)
{
RunLoopInventroy(reader,buffer,setting);
return string.Empty;
}
else if (msgTran.AryData.Length == 7)
{
buffer.nReadRate = Convert.ToInt32(msgTran.AryData[1]) * 256 + Convert.ToInt32(msgTran.AryData[2]);
buffer.nDataCount = Convert.ToInt32(msgTran.AryData[3]) * 256 * 256 * 256 + Convert.ToInt32(msgTran.AryData[4]) * 256 * 256 + Convert.ToInt32(msgTran.AryData[5]) * 256 + Convert.ToInt32(msgTran.AryData[6]);
RunLoopInventroy(reader, buffer, setting);
return string.Empty;
}
else
{
int nLength = msgTran.AryData.Length;
int nEpcLength = nLength - 4;
//int nDataLen = Convert.ToInt32(msgTran.AryData[nLength - 3]);
//int nEpcLen = Convert.ToInt32(msgTran.AryData[2]) - nDataLen - 4;
string strEPC = ByteArrayToString(msgTran.AryData, 3, nEpcLength);
string strPC = ByteArrayToString(msgTran.AryData, 1, 2);
//string strTid = ByteArrayToString(msgTran.AryData, 7 + nEpcLen, nDataLen);
string strRSSI = msgTran.AryData[nLength - 1].ToString();
SetMaxMinRSSI(Convert.ToInt32(msgTran.AryData[nLength - 1]), buffer);
byte btTemp = msgTran.AryData[0];
byte btAntId = (byte)((btTemp & 0x03) + 1);
buffer.nCurrentAnt = btAntId;
string strAntId = btAntId.ToString();
byte btFreq = (byte)(btTemp >> 2);
string strFreq = GetFreqString(btFreq, setting);
DataRow[] drs = buffer.dtTagTable.Select(string.Format("COLEPC = '{0}'", strEPC));
if (drs.Length == 0)
{
DataRow row1 = buffer.dtTagTable.NewRow();
row1[0] = strPC;
row1[2] = strEPC;
row1[4] = strRSSI;
row1[5] = "1";
row1[6] = strFreq;
//row1[7] = strTid;
buffer.dtTagTable.Rows.Add(row1);
buffer.dtTagTable.AcceptChanges();
}
else
{
foreach (DataRow dr in drs)
{
dr.BeginEdit();
dr[4] = strRSSI;
dr[5] = (Convert.ToInt32(dr[5]) + 1).ToString();
dr[6] = strFreq;
dr.EndEdit();
}
buffer.dtTagTable.AcceptChanges();
}
buffer.dtEndInventory = DateTime.Now;
return RefreshInventoryReal(0x89, buffer);
}
}
internal static void SetMaxMinRSSI(int nRSSI, InventoryBuffer buffer)
{
if (buffer.nMaxRSSI < nRSSI)
{
buffer.nMaxRSSI = nRSSI;
}
if (buffer.nMinRSSI == 0)
{
buffer.nMinRSSI = nRSSI;
}
else if (buffer.nMinRSSI > nRSSI)
{
buffer.nMinRSSI = nRSSI;
}
}
internal static string GetFreqString(byte btFreq, ReaderSetting setting)
{
string strFreq = string.Empty;
if (setting.btRegion == 4)
{
float nExtraFrequency = btFreq * setting.btUserDefineFrequencyInterval * 10;
float nstartFrequency = ((float)setting.nUserDefineStartFrequency) / 1000;
float nStart = nstartFrequency + nExtraFrequency / 1000;
string strTemp = nStart.ToString("0.000");
return strTemp;
}
else
{
if (btFreq < 0x07)
{
float nStart = 865.00f + Convert.ToInt32(btFreq) * 0.5f;
string strTemp = nStart.ToString("0.00");
return strTemp;
}
else
{
float nStart = 902.00f + (Convert.ToInt32(btFreq) - 7) * 0.5f;
string strTemp = nStart.ToString("0.00");
return strTemp;
}
}
}
public static string RefreshInventoryReal(byte btCmd,InventoryBuffer buffer)
{
if (btCmd != 0x89) return string.Empty;
int nTagCount = buffer.dtTagTable.Rows.Count;
//////列表用变量
//int nEpcCount = _currentEpcs.Count + _currentEpcErrs.Count;
int nEpcLength = buffer.dtTagTable.Rows.Count;
//if (nEpcCount < nEpcLength)
//{
DataRow row = buffer.dtTagTable.Rows[nEpcLength - 1];
return row[2].ToString().Replace(" ", "");
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.IO.Ports;
using System.Threading;
namespace Readers
{
public delegate void ReciveDataCallback(byte[] btAryReceiveData);
public delegate void SendDataCallback(byte[] btArySendData);
public delegate void AnalyDataCallback(MessageTran msgTran);
public class Reader
{
private ITalker italker;
private SerialPort iSerialPort;
private int m_nType = -1;
public ReciveDataCallback ReceiveCallback;
public SendDataCallback SendCallback;
public AnalyDataCallback AnalyCallback;
//记录未处理的接收数据,主要考虑接收数据分段
byte[] m_btAryBuffer = new byte[4096];
//记录未处理数据的有效长度
int m_nLenth = 0;
public Reader()
{
this.italker = new Talker();
italker.MessageReceived += new MessageReceivedEventHandler(ReceivedTcpData);
iSerialPort = new SerialPort();
iSerialPort.DataReceived+=new SerialDataReceivedEventHandler(ReceivedComData);
}
public int OpenCom(string strPort, int nBaudrate, out string strException)
{
strException = string.Empty;
if (iSerialPort.IsOpen)
{
iSerialPort.Close();
}
try
{
iSerialPort.PortName = strPort;
iSerialPort.BaudRate = nBaudrate;
iSerialPort.ReadTimeout = 200;
iSerialPort.Open();
}
catch (System.Exception ex)
{
strException = ex.Message;
return -1;
}
m_nType = 0;
return 0;
}
public void CloseCom()
{
if (iSerialPort.IsOpen)
{
iSerialPort.Close();
}
m_nType = -1;
}
public int ConnectServer(IPAddress ipAddress, int nPort, out string strException)
{
strException = string.Empty;
if (!italker.Connect(ipAddress, nPort, out strException))
{
return -1;
}
m_nType = 1;
return 0;
}
public void SignOut()
{
italker.SignOut();
m_nType = -1;
}
private void ReceivedTcpData(byte[] btAryBuffer)
{
RunReceiveDataCallback(btAryBuffer);
}
private void ReceivedComData(object sender, SerialDataReceivedEventArgs e)
{
try
{
int nCount = iSerialPort.BytesToRead;
if (nCount == 0)
{
return;
}
byte[] btAryBuffer = new byte[nCount];
iSerialPort.Read(btAryBuffer, 0, nCount);
RunReceiveDataCallback(btAryBuffer);
}
catch (System.Exception ex)
{
}
}
private void RunReceiveDataCallback(byte[] btAryReceiveData)
{
try
{
if (ReceiveCallback != null)
{
ReceiveCallback(btAryReceiveData);
}
int nCount = btAryReceiveData.Length;
byte[] btAryBuffer = new byte[nCount + m_nLenth];
Array.Copy(m_btAryBuffer, btAryBuffer, m_nLenth);
Array.Copy(btAryReceiveData, 0, btAryBuffer, m_nLenth, btAryReceiveData.Length);
//分析接收数据,以0xA0为数据起点,以协议中数据长度为数据终止点
int nIndex = 0;//当数据中存在A0时,记录数据的终止点
int nMarkIndex = 0;//当数据中不存在A0时,nMarkIndex等于数据组最大索引
for (int nLoop = 0; nLoop < btAryBuffer.Length; nLoop++)
{
if (btAryBuffer.Length > nLoop + 1)
{
if (btAryBuffer[nLoop] == 0xA0)
{
int nLen = Convert.ToInt32(btAryBuffer[nLoop + 1]);
if (nLoop + 1 + nLen < btAryBuffer.Length)
{
byte[] btAryAnaly = new byte[nLen + 2];
Array.Copy(btAryBuffer, nLoop, btAryAnaly, 0, nLen + 2);
MessageTran msgTran = new MessageTran(btAryAnaly);
if (AnalyCallback != null)
{
AnalyCallback(msgTran);
}
nLoop += 1 + nLen;
nIndex = nLoop + 1;
}
else
{
nLoop += 1 + nLen;
}
}
else
{
nMarkIndex = nLoop;
}
}
}
if (nIndex < nMarkIndex)
{
nIndex = nMarkIndex + 1;
}
if (nIndex < btAryBuffer.Length)
{
m_nLenth = btAryBuffer.Length - nIndex;
Array.Clear(m_btAryBuffer, 0, 4096);
Array.Copy(btAryBuffer, nIndex, m_btAryBuffer, 0, btAryBuffer.Length - nIndex);
}
else
{
m_nLenth = 0;
}
}
catch (System.Exception ex)
{
}
}
public int SendMessage(byte[] btArySenderData)
{
//串口连接方式
if (m_nType == 0)
{
if (!iSerialPort.IsOpen)
{
return -1;
}
iSerialPort.Write(btArySenderData, 0, btArySenderData.Length);
if (SendCallback != null)
{
SendCallback(btArySenderData);
}
return 0;
}
//Tcp连接方式
else if (m_nType == 1)
{
if (!italker.IsConnect())
{
return -1;
}
if (italker.SendMessage(btArySenderData))
{
if (SendCallback != null)
{
SendCallback(btArySenderData);
}
return 0;
}
}
return -1;
}
private int SendMessage(byte btReadId, byte btCmd)
{
MessageTran msgTran = new MessageTran(btReadId, btCmd);
return SendMessage(msgTran.AryTranData);
}
private int SendMessage(byte btReadId, byte btCmd, byte[] btAryData)
{
MessageTran msgTran = new MessageTran(btReadId, btCmd, btAryData);
return SendMessage(msgTran.AryTranData);
}
public byte CheckValue(byte[] btAryData)
{
MessageTran msgTran = new MessageTran();
return msgTran.CheckSum(btAryData, 0, btAryData.Length);
}
public int Reset(byte btReadId)
{
byte btCmd = 0x70;
int nResult = SendMessage(btReadId, btCmd);
return nResult;
}
public int SetUartBaudrate(byte btReadId, int nIndexBaudrate)
{
byte btCmd = 0x71;
byte[] btAryData = new byte[1];
btAryData[0] = Convert.ToByte(nIndexBaudrate);
int nResult = SendMessage(btReadId, btCmd, btAryData);
return nResult;
}
public int GetFirmwareVersion(byte btReadId)
{
byte btCmd = 0x72;
int nResult = SendMessage(btReadId, btCmd);
return nResult;
}
public int SetReaderAddress(byte btReadId, byte btNewReadId)
{
byte btCmd = 0x73;
byte[] btAryData = new byte[1];
btAryData[0] = btNewReadId;
int nResult = SendMessage(btReadId, btCmd, btAryData);
return nResult;
}
public int SetWorkAntenna(byte btReadId, byte btWorkAntenna)
{
byte btCmd = 0x74;
byte[] btAryData = new byte[1];
btAryData[0] = btWorkAntenna;
int nResult = SendMessage(btReadId, btCmd, btAryData);
return nResult;
}
public int GetWorkAntenna(byte btReadId)
{
byte btCmd = 0x75;
int nResult = SendMessage(btReadId, btCmd);
return nResult;
}
public int SetOutputPower(byte btReadId, byte btOutputPower)
{
byte btCmd = 0x76;
byte[] btAryData = new byte[1];
btAryData[0] = btOutputPower;
int nResult = SendMessage(btReadId, btCmd, btAryData);
return nResult;
}
public int GetOutputPower(byte btReadId)
{
byte btCmd = 0x77;
int nResult = SendMessage(btReadId, btCmd);
return nResult;
}
public int MeasureReturnLoss(byte btReadId, byte btFrequency)
{
byte btCmd = 0x7E;
byte[] btAryData = new byte[1];
btAryData[0] = btFrequency;
int nResult = SendMessage(btReadId, btCmd, btAryData);
return nResult;
}
public int SetFrequencyRegion(byte btReadId, byte btRegion, byte btStartRegion, byte btEndRegion)
{
byte btCmd = 0x78;
byte[] btAryData = new byte[3];
btAryData[0] = btRegion;
btAryData[1] = btStartRegion;
btAryData[2] = btEndRegion;
int nResult = SendMessage(btReadId, btCmd, btAryData);
return nResult;
}
public int SetUserDefineFrequency(byte btReadId, int nStartFreq, byte btFreqInterval, byte btChannelQuantity)
{
byte btCmd = 0x78;
byte[] btAryFreq = new byte[3];
byte[] btAryData = new byte[6];
btAryFreq = BitConverter.GetBytes(nStartFreq);
btAryData[0] = 4;
btAryData[1] = btFreqInterval;
btAryData[2] = btChannelQuantity;
btAryData[3] = btAryFreq[2];
btAryData[4] = btAryFreq[1];
btAryData[5] = btAryFreq[0];
int nResult = SendMessage(btReadId, btCmd, btAryData);
return nResult;
}
public int GetFrequencyRegion(byte btReadId)
{
byte btCmd = 0x79;
int nResult = SendMessage(btReadId, btCmd);
return nResult;
}
public int SetBeeperMode(byte btReadId, byte btMode)
{
byte btCmd = 0x7A;
byte[] btAryData = new byte[1];
btAryData[0] = btMode;
int nResult = SendMessage(btReadId, btCmd, btAryData);
return nResult;
}
public int GetReaderTemperature(byte btReadId)
{
byte btCmd = 0x7B;
int nResult = SendMessage(btReadId, btCmd);
return nResult;
}
public int GetAntImpedanceMatch(byte btReadId, byte btFrequency)
{
byte btCmd = 0x7E;
byte[] btAryData = new byte[1];
btAryData[0] = btFrequency;
int nResult = SendMessage(btReadId, btCmd, btAryData);
return nResult;
}
public int SetDrmMode(byte btReadId, byte btDrmMode)
{
byte btCmd = 0x7C;
byte[] btAryData = new byte[1];
btAryData[0] = btDrmMode;
int nResult = SendMessage(btReadId, btCmd, btAryData);
return nResult;
}
public int GetDrmMode(byte btReadId)
{
byte btCmd = 0x7D;
int nResult = SendMessage(btReadId, btCmd);
return nResult;
}
public int ReadGpioValue(byte btReadId)
{
byte btCmd = 0x60;
int nResult = SendMessage(btReadId, btCmd);
return nResult;
}
public int WriteGpioValue(byte btReadId, byte btChooseGpio, byte btGpioValue)
{
byte btCmd = 0x61;
byte[] btAryData = new byte[2];
btAryData[0] = btChooseGpio;
btAryData[1] = btGpioValue;
int nResult = SendMessage(btReadId, btCmd, btAryData);
return nResult;
}
public int SetAntDetector(byte btReadId, byte btDetectorStatus)
{
byte btCmd = 0x62;
byte[] btAryData = new byte[1];
btAryData[0] = btDetectorStatus;
int nResult = SendMessage(btReadId, btCmd, btAryData);
return nResult;
}
public int GetAntDetector(byte btReadId)
{
byte btCmd = 0x63;
int nResult = SendMessage(btReadId, btCmd);
return nResult;
}
public int GetMonzaStatus(byte btReadId)
{
byte btCmd = 0x8e;
int nResult = SendMessage(btReadId, btCmd);
return nResult;
}
public int SetMonzaStatus(byte btReadId, byte btMonzaStatus)
{
byte btCmd = 0x8D;
byte[] btAryData = new byte[1];
btAryData[0] = btMonzaStatus;
int nResult = SendMessage(btReadId, btCmd, btAryData);
return nResult;
}
public int SetRadioProfile(byte btReadId, byte btProfile)
{
byte btCmd = 0x69;
byte[] btAryData = new byte[1];
btAryData[0] = btProfile;
int nResult = SendMessage(btReadId, btCmd, btAryData);
return nResult;
}
public int GetRadioProfile(byte btReadId)
{
byte btCmd = 0x6A;
int nResult = SendMessage(btReadId, btCmd);
return nResult;
}
public int GetReaderIdentifier(byte btReadId)
{
byte btCmd = 0x68;
int nResult = SendMessage(btReadId, btCmd);
return nResult;
}
public int SetReaderIdentifier(byte btReadId, byte[] identifier)
{
byte btCmd = 0x67;
int nResult = SendMessage(btReadId, btCmd, identifier);
return nResult;
}
public int Inventory(byte btReadId, byte byRound)
{
byte btCmd = 0x80;
byte[] btAryData = new byte[1];
btAryData[0] = byRound;
int nResult = SendMessage(btReadId, btCmd, btAryData);
return nResult;
}
public int CustomizedInventory(byte btReadId, byte session, byte target,byte byRound)
{
byte btCmd = 0x8B;
byte[] btAryData = new byte[3];
btAryData[0] = session;
btAryData[1] = target;
btAryData[2] = byRound;
int nResult = SendMessage(btReadId, btCmd, btAryData);
return nResult;
}
public int ReadTag(byte btReadId, byte btMemBank, byte btWordAdd, byte btWordCnt)
{
byte btCmd = 0x81;
byte[] btAryData = new byte[3];
btAryData[0] = btMemBank;
btAryData[1] = btWordAdd;
btAryData[2] = btWordCnt;
int nResult = SendMessage(btReadId, btCmd, btAryData);
return nResult;
}
public int WriteTag(byte btReadId, byte[] btAryPassWord, byte btMemBank, byte btWordAdd, byte btWordCnt, byte[] btAryData)
{
byte btCmd = 0x82;
byte[] btAryBuffer = new byte[btAryData.Length + 7];
btAryPassWord.CopyTo(btAryBuffer, 0);
btAryBuffer[4] = btMemBank;
btAryBuffer[5] = btWordAdd;
btAryBuffer[6] = btWordCnt;
btAryData.CopyTo(btAryBuffer, 7);
int nResult = SendMessage(btReadId, btCmd, btAryBuffer);
return nResult;
}
public int LockTag(byte btReadId, byte[] btAryPassWord, byte btMembank, byte btLockType)
{
byte btCmd = 0x83;
byte[] btAryData = new byte[6];
btAryPassWord.CopyTo(btAryData, 0);
btAryData[4] = btMembank;
btAryData[5] = btLockType;
int nResult = SendMessage(btReadId, btCmd, btAryData);
return nResult;
}
public int KillTag(byte btReadId, byte[] btAryPassWord)
{
byte btCmd = 0x84;
byte[] btAryData = new byte[4];
btAryPassWord.CopyTo(btAryData, 0);
int nResult = SendMessage(btReadId, btCmd, btAryData);
return nResult;
}
public int SetAccessEpcMatch(byte btReadId, byte btMode, byte btEpcLen, byte[] btAryEpc)
{
byte btCmd = 0x85;
int nLen = Convert.ToInt32(btEpcLen) + 2;
byte[] btAryData = new byte[nLen];
btAryData[0] = btMode;
btAryData[1] = btEpcLen;
btAryEpc.CopyTo(btAryData, 2);
int nResult = SendMessage(btReadId, btCmd, btAryData);
return nResult;
}
public int CancelAccessEpcMatch(byte btReadId, byte btMode)
{
byte btCmd = 0x85;
byte[] btAryData = new byte[1];
btAryData[0] = btMode;
int nResult = SendMessage(btReadId, btCmd, btAryData);
return nResult;
}
public int GetAccessEpcMatch(byte btReadId)
{
byte btCmd = 0x86;
int nResult = SendMessage(btReadId, btCmd);
return nResult;
}
public int InventoryReal(byte btReadId, byte byRound)
{
byte btCmd = 0x89;
byte[] btAryData = new byte[1];
btAryData[0] = byRound;
int nResult = SendMessage(btReadId, btCmd, btAryData);
return nResult;
}
public int FastSwitchInventory(byte btReadId, byte[] btAryData)
{
byte btCmd = 0x8A;
int nResult = SendMessage(btReadId, btCmd, btAryData);
return nResult;
}
public int GetInventoryBuffer(byte btReadId)
{
byte btCmd = 0x90;
int nResult = SendMessage(btReadId, btCmd);
return nResult;
}
public int GetAndResetInventoryBuffer(byte btReadId)
{
byte btCmd = 0x91;
int nResult = SendMessage(btReadId, btCmd);
return nResult;
}
public int GetInventoryBufferTagCount(byte btReadId)
{
byte btCmd = 0x92;
int nResult = SendMessage(btReadId, btCmd);
return nResult;
}
public int ResetInventoryBuffer(byte btReadId)
{
byte btCmd = 0x93;
int nResult = SendMessage(btReadId, btCmd);
return nResult;
}
public int SetBufferDataFrameInterval(byte btReadId, byte btInterval)
{
byte btCmd = 0x94;
byte[] btAryData = new byte[1];
btAryData[0] = btInterval;
int nResult = SendMessage(btReadId, btCmd, btAryData);
return nResult;
}
public int GetBufferDataFrameInterval(byte btReadId)
{
byte btCmd = 0x95;
int nResult = SendMessage(btReadId, btCmd);
return nResult;
}
public int InventoryISO18000(byte btReadId)
{
byte btCmd = 0xb0;
int nResult = SendMessage(btReadId, btCmd);
return nResult;
}
public int ReadTagISO18000(byte btReadId, byte[] btAryUID, byte btWordAdd, byte btWordCnt)
{
byte btCmd = 0xb1;
int nLen = btAryUID.Length + 2;
byte[] btAryData = new byte[nLen];
btAryUID.CopyTo(btAryData, 0);
btAryData[nLen - 2] = btWordAdd;
btAryData[nLen - 1] = btWordCnt;
int nResult = SendMessage(btReadId, btCmd, btAryData);
return nResult;
}
public int WriteTagISO18000(byte btReadId, byte[] btAryUID, byte btWordAdd, byte btWordCnt, byte[] btAryBuffer)
{
byte btCmd = 0xb2;
int nLen = btAryUID.Length + 2 + btAryBuffer.Length;
byte[] btAryData = new byte[nLen];
btAryUID.CopyTo(btAryData, 0);
btAryData[btAryUID.Length] = btWordAdd;
btAryData[btAryUID.Length + 1] = btWordCnt;
btAryBuffer.CopyTo(btAryData, btAryUID.Length + 2);
int nResult = SendMessage(btReadId, btCmd, btAryData);
return nResult;
}
public int LockTagISO18000(byte btReadId, byte[] btAryUID, byte btWordAdd)
{
byte btCmd=0xb3;
int nLen = btAryUID.Length + 1;
byte[] btAryData = new byte[nLen];
btAryUID.CopyTo(btAryData, 0);
btAryData[nLen - 1] = btWordAdd;
int nResult = SendMessage(btReadId, btCmd, btAryData);
return nResult;
}
public int QueryTagISO18000(byte btReadId, byte[] btAryUID, byte btWordAdd)
{
byte btCmd = 0xb4;
int nLen = btAryUID.Length + 1;
byte[] btAryData = new byte[nLen];
btAryUID.CopyTo(btAryData, 0);
btAryData[nLen - 1] = btWordAdd;
int nResult = SendMessage(btReadId, btCmd, btAryData);
return nResult;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Kivii.Client.SampleAssigns
{
public class ReaderSetting
{
public byte btReadId;
public byte btMajor;
public byte btMinor;
public byte btIndexBaudrate;
public byte btPlusMinus;
public byte btTemperature;
public byte btOutputPower;
public byte btWorkAntenna;
public byte btDrmMode;
public byte btRegion;
public byte btFrequencyStart;
public byte btFrequencyEnd;
public byte btBeeperMode;
public byte btGpio1Value;
public byte btGpio2Value;
public byte btGpio3Value;
public byte btGpio4Value;
public byte btAntDetector;
public byte btMonzaStatus;
public string btReaderIdentifier;
public byte btAntImpedance;
public byte btImpedanceFrequency;
public int nUserDefineStartFrequency;
public byte btUserDefineFrequencyInterval;
public byte btUserDefineChannelQuantity;
public byte btLinkProfile;
public ReaderSetting()
{
btReadId = 0xFF;
btMajor = 0x00;
btMinor = 0x00;
btIndexBaudrate = 0x00;
btPlusMinus = 0x00;
btTemperature = 0x00;
btOutputPower = 0x00;
btWorkAntenna = 0x00;
btDrmMode = 0x00;
btRegion = 0x00;
btFrequencyStart = 0x00;
btFrequencyEnd = 0x00;
btBeeperMode = 0x00;
btGpio1Value = 0x00;
btGpio2Value = 0x00;
btGpio3Value = 0x00;
btGpio4Value = 0x00;
btAntDetector = 0x00;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.IO;
using System.Threading;
namespace Readers
{
public class Talker:ITalker
{
public event MessageReceivedEventHandler MessageReceived;
TcpClient client;
Stream streamToTran;
private Thread waitThread;
private bool bIsConnect = false;
public bool Connect(IPAddress ipAddress, int nPort, out string strException)
{
strException = string.Empty;
try
{
client = new TcpClient();
client.Connect(ipAddress, nPort);
streamToTran = client.GetStream(); // 获取连接至远程的流
//建立线程收取服务器发送数据
ThreadStart stThead = new ThreadStart(ReceivedData);
waitThread = new Thread(stThead);
waitThread.IsBackground = true;
waitThread.Start();
bIsConnect = true;
return true;
}
catch (System.Exception ex)
{
strException = ex.Message;
return false;
}
}
private void ReceivedData()
{
while (true)
{
try
{
byte[] btAryBuffer = new byte[4096];
int nLenRead = streamToTran.Read(btAryBuffer, 0, btAryBuffer.Length);
if (nLenRead == 0)
{
continue;
}
if (MessageReceived != null)
{
byte[] btAryReceiveData = new byte[nLenRead];
Array.Copy(btAryBuffer, btAryReceiveData, nLenRead);
MessageReceived(btAryReceiveData);
}
}
catch (System.Exception ex)
{
}
}
}
public bool SendMessage(byte[] btAryBuffer)
{
try
{
lock (streamToTran)
{
streamToTran.Write(btAryBuffer, 0, btAryBuffer.Length);
return true;
}
}
catch
{
return false;
}
}
public void SignOut()
{
if (streamToTran != null)
streamToTran.Dispose();
if (client != null)
client.Close();
waitThread.Abort();
bIsConnect = false;
}
public bool IsConnect()
{
return bIsConnect;
}
}
}
using Kivii.Client;
using Kivii.Samples.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Kivii.Samples.Transforms
{
[Route(Configs.RouteLocationQuery)]
public class LocationQuery : IReturn<RestfulQueryResponse<Location>>
{
public Guid OwnerKvid { get; set; }
}
[Route(Configs.RouteSampleQuery)]
public class SampleQuery : IReturn<RestfulQueryResponse<Sample>>
{
public string Name { get; set; }
public SampleType Type { get; set; }
//public Guid PackageKvid { get; set; }
}
[Route(Configs.RouteSampleQuery)]
public class SampleQuery2 : IReturn<RestfulQueryResponse<Sample>>
{
//public bool IncludeLocation { get; set; } = true;
public Guid PackageKvid { get; set; }
}
[Route(Configs.RouteSamplePrePackaging)]
public class SamplePrePackaging:IReturn<RestfulExecutionResponse<Sample>>
{
public string Tid { get; set; }
public string BizId { get; set; }
public Guid BizKvid { get; set; }
public Guid OwnerKvid { get; set; }//要打包的样品的所属信息
public bool IncludeLocation { get; set; } = true;
}
[Route(Configs.RouteSampleAssign)]
public class SampleAssign : IReturn<RestfulUpdateResponse<Sample>>
{
public List<Guid> Kvids { get; set; }//要流转样品信息
public Location Location { get; set; }//地点位置信息,只需要InternalCode
}
[Route(Configs.RouteSamplePackaging)]
public class SamplePackaging : IReturn<RestfulExecutionResponse<Sample>>
{
public List<Guid> Kvids { get; set; }//要流转样品信息
public Location Location { get; set; }//地点位置信息,只需要InternalCode
public Sample Package { get; set; }//指定包裹信息,Package.PackageName可传入包裹的区域信息,例如包裹A0001中的1号袋子
}
[Route(Configs.RouteSampleUnPackaging)]
public class SampleUnPackaging : IReturn<RestfulExecutionResponse<Sample>>
{
public Guid Kvid { get; set; }//要流转样品信息
public Location Location { get; set; }//地点位置信息,只需要InternalCode
}
}
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Kivii.Common" version="5.6.2023.4000" targetFramework="net40" />
<package id="Kivii.Core" version="5.6.2023.4140" targetFramework="net40" />
<package id="Kivii.Linq" version="5.6.2023.4200" targetFramework="net40" />
<package id="Kivii.Linq.Sqlite" version="5.6.2023.3000" targetFramework="net40" />
</packages>
\ No newline at end of file
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