ZHJA_HJGL/HJGL_ZH/FineUIPro.Web/RLSB/UploadImageTrain.aspx.cs

96 lines
3.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
using Web;
namespace FineUIPro.Web.RNSB
{
public partial class UploadImageTrain :PageBase
{
protected void Page_Load(object sender, EventArgs e)
{
if (Request.ServerVariables["Request_Method"] == "POST")
{
DoUpload();
}
else
{
Response.Write("请使用POST方法上传图像!");
}
}
void DoUpload()
{
if (Request.Files.Count != 1)
{
Response.Write("没有上传一个文件!");
return;
}
if (Request.Files[0].FileName == "")
{
Response.Write("上传文件为空!");
return;
}
try
{
string label = Request.Form["label"].Trim();
if (String.IsNullOrEmpty(label))
{
Response.Write("村签不能为空!");
return;
}
string filename = Server.MapPath("~/FileUpload/" + (DateTime.Now).ToString("yyyyMMddHHmmss") + ".jpg");
Request.Files[0].SaveAs(filename);
int nRet = libOpenCV.DoTrainImage(filename, label);
switch (nRet)
{
/* TI_PARAM_NULL = 1,
TI_FILEOPEN,
TI_NO_FACE,
TI_CASCADE,*/
case 0:
var welder = BLL.HJGL_PersonManageService.GetWelderByIdentityCard(label);//焊工采集
if (welder != null)
{
welder.IsFaceTrain = true;
welder.WED_ID = welder.WED_ID;
BLL.HJGL_PersonManageService.UpdateBSWelderIsFaceTrain(welder);
}
var storeman = BLL.StoremanInfoService.GetStoremanByIdentityCard(label);//保管员采集
if (storeman!=null)
{
storeman.IsFaceTrain = true;
storeman.StoremanId = storeman.StoremanId;
BLL.StoremanInfoService.UpdateStoreManIsFaceTrain(storeman);
}
Response.Write("人脸采集成功!");
break;
case 1:
Response.Write("文件打开失败!");
break;
case 2:
Response.Write("未检测到人脸!");
break;
case 3:
Response.Write("人脸检测加载失败!");
break;
default:
Response.Write("未知错误!");
break;
}
System.IO.File.Delete(filename);
}
catch
{
Response.Write("exception!");
}
Response.End();
}
}
}