基线 SVN r240
SVN-Revision: r240
This commit is contained in:
@@ -0,0 +1,377 @@
|
||||
/***********************
|
||||
* 说明:拍照模板
|
||||
* 创建人:龚宇超
|
||||
* 创建日期:2018-06-11
|
||||
* 修改人:
|
||||
* 修改日期:
|
||||
* 修改备注:
|
||||
* 版本:1.0.0.0
|
||||
***********************/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using Lskj.Control;
|
||||
using Lskj.Business.Impl;
|
||||
using Lskj.Util;
|
||||
using System.Collections;
|
||||
using System.Reflection;
|
||||
using Lskj.Data;
|
||||
using System.Threading;
|
||||
using System.IO;
|
||||
using Lskj.Control.Model;
|
||||
using System.Diagnostics;
|
||||
using Lskj.Model;
|
||||
using Lskj.Business;
|
||||
using System.Text.RegularExpressions;
|
||||
using Lskj.Core;
|
||||
|
||||
namespace Lskj.CmCapture
|
||||
{
|
||||
public partial class FrmMain : BaseForm
|
||||
{
|
||||
public FrmMain()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
#region 公用变量
|
||||
public DynamicCmCapture SysModelObj;
|
||||
///// <summary>
|
||||
///// 目录ID
|
||||
///// </summary>
|
||||
///// <value>The dir identifier.</value>
|
||||
//public string DirId { get; set; }
|
||||
///// <summary>
|
||||
///// 目录树节点ID
|
||||
///// </summary>
|
||||
///// <value>The spesies no.</value>
|
||||
//public string SpesiesNo { get; set; }
|
||||
#endregion
|
||||
|
||||
#region 私有变量
|
||||
/// <summary>
|
||||
/// 0摄像头,1拍摄仪,2辅助拍摄
|
||||
/// </summary>
|
||||
private int _typeCode = 0;
|
||||
/// <summary>
|
||||
/// 文件目录
|
||||
/// </summary>
|
||||
private string _fileDir = "\\temp_cm_capture\\";
|
||||
/// <summary>
|
||||
/// 拍照文件集合
|
||||
/// </summary>
|
||||
private List<FileModel> _files = new List<FileModel>();
|
||||
/// <summary>
|
||||
/// 当前附件名
|
||||
/// </summary>
|
||||
private string _currentFileName;
|
||||
/// <summary>
|
||||
/// 当前附件的大小
|
||||
/// </summary>
|
||||
private long _currentFileSize;
|
||||
#endregion
|
||||
/// <summary>
|
||||
/// <para>说明:窗体加载</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2018-06-11 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.InitializeSetting();
|
||||
this.axCmCaptureOcx1.Initial();
|
||||
this.axCmCaptureOcx1.StartRun(_typeCode);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
string Message = ErrorMessage.PromptErrorMessage(ex);
|
||||
MessageUtil.Show(Message,ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Lskj.Control.Model.AutoSizeChange.ControllInitializeSize(this);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:初始化属性</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2018-06-11 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
private void InitializeSetting()
|
||||
{
|
||||
//初始化列
|
||||
DataTable dtColumn = AttachImpl.GetCameraFileData();
|
||||
this.gridControlEx.SetReadOnlyColumns(dtColumn);
|
||||
this.gridControlEx.GridView.DoubleClick += new EventHandler(OnGridViewDoubleClick);
|
||||
AttachHelper.OnUploadSuccess += new EventHandler(AttachHelper_OnUploadSuccess);
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:上传方法</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2018-06-11 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
private void UpLoad()
|
||||
{
|
||||
try
|
||||
{
|
||||
DataTable dt = gridControlEx.gridControl.DataSource as DataTable;
|
||||
for (int i = 0; i < dt.Rows.Count;i++ )
|
||||
{
|
||||
this._currentFileName = dt.Rows[i]["Name"] + "";
|
||||
string filePath = PubUtil.AbsolutelyPath + _fileDir + this._currentFileName;
|
||||
if (!File.Exists(filePath))
|
||||
{
|
||||
MessageUtil.Show(ResourceKeys.NotLoaclFile);
|
||||
return;
|
||||
}
|
||||
//获取图片文件大小
|
||||
FileStream info = File.OpenRead(filePath);
|
||||
byte[] img = new byte[info.Length];
|
||||
info.Read(img, 0, Convert.ToInt32(info.Length));
|
||||
info.Close();
|
||||
_currentFileSize = Convert.ToInt64(img.Length);
|
||||
AttachHelper.UpLoadFile(this.Handle, SysModelObj.DirId, this._currentFileName, "001");
|
||||
}
|
||||
this.progressBar1.Value = dt.Rows.Count;
|
||||
this.btnAdd.Enabled = this.btnDelete.Enabled = this.btnUpload.Enabled = true;
|
||||
this.lb_Text.Text = ResourceKeys.Completed;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string Message = ErrorMessage.PromptErrorMessage(ex);
|
||||
MessageUtil.Show(Message,ex.Message);
|
||||
LogHelper.Instance.WriteError(ex);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:RadioButton 切换模式</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2018-06-11 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="o">The o.</param>
|
||||
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
||||
protected void OnRadioClick(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
RadioButton rb = sender as RadioButton;
|
||||
_typeCode = Convert.ToInt32(rb.Tag);
|
||||
axCmCaptureOcx1.StartRun(this._typeCode);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string Message = ErrorMessage.PromptErrorMessage(ex);
|
||||
MessageUtil.Show(Message,ex.Message);
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:表格双击</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2018-06-12 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="sender">The sender.</param>
|
||||
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
||||
protected void OnGridViewDoubleClick(object sender,EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
DataRow rowItem = this.gridControlEx.GridView.GetFocusedDataRow();
|
||||
Process.Start(PubUtil.AbsolutelyPath + _fileDir + rowItem["name"] + "");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string Message = ErrorMessage.PromptErrorMessage(ex);
|
||||
MessageUtil.Show(Message,ex.Message);
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:拍照添加</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2018-06-11 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="o">The o.</param>
|
||||
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
||||
protected void OnAddClick(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
string Id = Guid.NewGuid() + "";
|
||||
string fileName = Id + ".bmp";
|
||||
this.axCmCaptureOcx1.CaptureImage(PubUtil.AbsolutelyPath + _fileDir + fileName);
|
||||
FileModel model = new FileModel(_files.Count + 1, fileName, DateTime.Now, Id);
|
||||
_files.Add(model);
|
||||
this.gridControlEx.SetGridViewDataSource(_files.ToDataTable<FileModel>());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string Message = ErrorMessage.PromptErrorMessage(ex);
|
||||
MessageUtil.Show(Message,ex.Message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>说明:删除</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2018-06-11 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="o">The o.</param>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
protected void OnDeleteClick(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
int[] rows = this.gridControlEx.GridView.GetSelectedRows();
|
||||
for (int i = 0; i < rows.Length; i++)
|
||||
{
|
||||
DataRow row = this.gridControlEx.GridView.GetDataRow(rows[i]);
|
||||
string guid = row["key"] + "";
|
||||
_files.Remove(_files.FirstOrDefault(s => s.key == guid));
|
||||
string file = _fileDir + guid + ".bmp";
|
||||
if (File.Exists(file)) File.Delete(file);
|
||||
}
|
||||
this.gridControlEx.SetGridViewDataSource(_files.ToDataTable<FileModel>());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string Message = ErrorMessage.PromptErrorMessage(ex);
|
||||
MessageUtil.Show(Message,ex.Message);
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:上传服务器</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2018-06-11 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="o">The o.</param>
|
||||
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
||||
protected void OnUpLoadClick(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (this.gridControlEx.GridView.DataRowCount == 0)
|
||||
{
|
||||
MessageUtil.Show(ResourceKeys.NotUploadFile);
|
||||
return;
|
||||
}
|
||||
this.lb_Text.Text = ResourceKeys.FileUpLoading;
|
||||
this.btnAdd.Enabled = this.btnDelete.Enabled = this.btnUpload.Enabled = false;
|
||||
this.progressBar1.Maximum = this.gridControlEx.GridView.DataRowCount;
|
||||
new Thread(UpLoad).Start();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string Message = ErrorMessage.PromptErrorMessage(ex);
|
||||
MessageUtil.Show(Message,ex.Message);
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:上传成功</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2018-06-12 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
||||
protected void AttachHelper_OnUploadSuccess(object sender,EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
//附件上传成功处理
|
||||
if (AttachHelper.IsDefWndProc(this.Handle, (System.Windows.Forms.Message)sender))
|
||||
{
|
||||
int result = AttachImpl.InsertUpLoadFile(this._currentFileName, SysModelObj.DirId, _currentFileSize, SysModelObj.SpesiesNo);
|
||||
MessageUtil.Show(result > 0 ? ResourceKeys.UpLoadFileSuccess : ResourceKeys.UploadFileFail);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string Message = ErrorMessage.PromptErrorMessage(ex);
|
||||
MessageUtil.Show(Message,ex.Message);
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:窗口消息</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2018-06-12 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="m">要处理的 Windows<see cref="T:System.Windows.Forms.Message" />。</param>
|
||||
protected override void DefWndProc(ref Message m)
|
||||
{
|
||||
base.DefWndProc(ref m);
|
||||
|
||||
if (this.Handle == m.HWnd)
|
||||
AttachHelper.DefWndProc(m);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 拍照附件模型
|
||||
/// </summary>
|
||||
class FileModel
|
||||
{
|
||||
public FileModel(int Id, String Name, DateTime Created, String key)
|
||||
{
|
||||
this.Id = Id;
|
||||
this.Name = Name;
|
||||
this.Created = Created;
|
||||
this.key = key;
|
||||
}
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public DateTime Created { get; set; }
|
||||
public string key { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user