69 lines
2.2 KiB
C#
69 lines
2.2 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Web;
|
|||
|
using System.Web.UI;
|
|||
|
using System.Web.UI.WebControls;
|
|||
|
using System.Runtime.InteropServices;
|
|||
|
using System.Diagnostics;
|
|||
|
using BLL;
|
|||
|
|
|||
|
namespace FineUIPro.Web.RNSB
|
|||
|
{
|
|||
|
public partial class UploadImageCheck : System.Web.UI.Page
|
|||
|
{
|
|||
|
private string fileUrl = string.Empty;
|
|||
|
|
|||
|
protected void Page_Load(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (Request.ServerVariables["Request_Method"] == "POST")
|
|||
|
{
|
|||
|
DoUpload();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
Response.Write("请使用POST方法,上传图像!");
|
|||
|
}
|
|||
|
}
|
|||
|
//次回调,是识别回调,是照片与标签对应关系,标签可以和数据库中匹配并返回相关数据,标签是惟一的。可以由DEMO中程序定义并添加》
|
|||
|
|
|||
|
unsafe void CheckCallBack(
|
|||
|
string szLabel,
|
|||
|
double d)
|
|||
|
{
|
|||
|
//string strLabel = str.ToString();
|
|||
|
string label = szLabel;
|
|||
|
//identityCard = szLabel;
|
|||
|
Debug.WriteLine(string.Format("{0},{1}", label, d));
|
|||
|
Response.Write(label + "#" + d + "|" + fileUrl);
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
void DoUpload()
|
|||
|
{
|
|||
|
if (Request.Files.Count != 1)
|
|||
|
{
|
|||
|
Response.Write("没有上传一个文件!");
|
|||
|
return;
|
|||
|
}
|
|||
|
if (Request.Files[0].FileName == "")
|
|||
|
{
|
|||
|
Response.Write("上传文件为空!");
|
|||
|
return;
|
|||
|
}
|
|||
|
string filename = "FileUpload//" + (DateTime.Now).ToString("yyyyMMddHHmmss") + ".jpg";
|
|||
|
fileUrl = filename;
|
|||
|
Request.Files[0].SaveAs(Funs.RootPath + filename);
|
|||
|
unsafe
|
|||
|
{
|
|||
|
CheckCallBack ccb = new BLL.CheckCallBack( CheckCallBack );
|
|||
|
libOpenCV.DoCheckImage(Funs.RootPath + filename, ccb);
|
|||
|
}
|
|||
|
//System.IO.File.Delete(Funs.RootPath + filename);
|
|||
|
//BLL.UploadFileService.DeleteFile(Funs.RootPath, filename);//删除文件内容,该删除操作调整到焊材发放页面进行操作,因领料单需要打印照片,故暂不删除
|
|||
|
Response.End();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|