160 lines
5.3 KiB
C#
160 lines
5.3 KiB
C#
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Drawing;
|
|||
|
|
using System.IO;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Web;
|
|||
|
|
using System.Web.Mvc;
|
|||
|
|
|
|||
|
|
namespace dccdc.Controllers
|
|||
|
|
{
|
|||
|
|
public class CommonController : Controller
|
|||
|
|
{
|
|||
|
|
// GET: Common
|
|||
|
|
/// <summary>
|
|||
|
|
/// 采集照片
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public ActionResult FlashCapture()
|
|||
|
|
{
|
|||
|
|
return View();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 拍照
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public ActionResult StartCamera()
|
|||
|
|
{
|
|||
|
|
return View();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 保存照片
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public ActionResult savePhoto()
|
|||
|
|
{
|
|||
|
|
string path = Server.MapPath("~/photo/");
|
|||
|
|
if(!Directory.Exists(path))
|
|||
|
|
{
|
|||
|
|
Directory.CreateDirectory(path);
|
|||
|
|
}
|
|||
|
|
var erpUser = Session["loginUser"] as Models.ERPUser;
|
|||
|
|
path += erpUser.ID + "\\";
|
|||
|
|
if (!Directory.Exists(path))
|
|||
|
|
{
|
|||
|
|
Directory.CreateDirectory(path);
|
|||
|
|
}
|
|||
|
|
path += DateTime.Now.ToString("yyyyMMddHHmmss") + ".jpg";
|
|||
|
|
FileStream sf = new FileStream(path,FileMode.Create,FileAccess.ReadWrite);
|
|||
|
|
//BinaryWriter sw = new BinaryWriter(sf);
|
|||
|
|
byte[] bs = new byte[Request.InputStream.Length];
|
|||
|
|
Request.InputStream.Read(bs, 0, bs.Length);
|
|||
|
|
//sw.Write(bs);
|
|||
|
|
//sw.Close();
|
|||
|
|
sf.Write(bs,0,bs.Length);
|
|||
|
|
sf.Close();
|
|||
|
|
Session["PhotoPath"] = path;
|
|||
|
|
return Json(new { });
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 新保存照片
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public ActionResult Xin_savePhoto(string base64img)
|
|||
|
|
{
|
|||
|
|
base64img = base64img.Replace("data:image/png;base64,", "");
|
|||
|
|
byte[] bytes = Convert.FromBase64String(base64img);
|
|||
|
|
MemoryStream memStream = new MemoryStream(bytes);
|
|||
|
|
System.Drawing.Image mImage = System.Drawing.Image.FromStream(memStream);
|
|||
|
|
|
|||
|
|
Bitmap bp = new Bitmap(mImage);
|
|||
|
|
|
|||
|
|
string path = Server.MapPath("~/photo/");
|
|||
|
|
|
|||
|
|
if (!Directory.Exists(path))
|
|||
|
|
{
|
|||
|
|
Directory.CreateDirectory(path);
|
|||
|
|
}
|
|||
|
|
var erpUser = Session["loginUser"] as Models.ERPUser;
|
|||
|
|
path += erpUser.ID + "\\";
|
|||
|
|
if (!Directory.Exists(path))
|
|||
|
|
{
|
|||
|
|
Directory.CreateDirectory(path);
|
|||
|
|
}
|
|||
|
|
path += DateTime.Now.ToString("yyyyMMddHHmmss") + ".jpg";
|
|||
|
|
|
|||
|
|
bp.Save(path, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
|
|||
|
|
bp.Dispose();
|
|||
|
|
Session["PhotoPath"] = path;
|
|||
|
|
return Json(new { path });
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 获取照片
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public JsonResult getPhote()
|
|||
|
|
{
|
|||
|
|
string path;
|
|||
|
|
if(Session["PhotoPath"]==null|| Session["PhotoPath"].ToString()=="")
|
|||
|
|
{
|
|||
|
|
return Json(new { State=0,Message="保存照片失败!"});
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
path = Session["PhotoPath"].ToString();
|
|||
|
|
if(!System.IO.File.Exists(path))
|
|||
|
|
{
|
|||
|
|
return Json(new { State = 0, Message = "保存照片失败!服务器上没有生成照片!" });
|
|||
|
|
}
|
|||
|
|
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
|
|||
|
|
byte[] photo = new byte[fs.Length];
|
|||
|
|
fs.Read(photo, 0, photo.Length);
|
|||
|
|
fs.Close();
|
|||
|
|
return Json(new { State=1,Message= "data:image/jpeg;base64," + Convert.ToBase64String(photo)});
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public ActionResult SelectCompany(string lx)
|
|||
|
|
{
|
|||
|
|
ViewBag.lx = lx;
|
|||
|
|
return View();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public JsonResult getQyList(int page,int pagesize,string qyname,string lx)
|
|||
|
|
{
|
|||
|
|
int count = new BLL.EnterpriceInfoMaintainBll().getCount(qyname, lx);
|
|||
|
|
List < Models.EnterpriceInfoMaintainModel > list= new BLL.EnterpriceInfoMaintainBll().getListPage(page, pagesize, qyname, lx);
|
|||
|
|
return Json( new {Total=count,Rows=list});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public ActionResult SelectChargeProjectAdd(string lx)
|
|||
|
|
{
|
|||
|
|
ViewBag.lx = lx;
|
|||
|
|
return View();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public JsonResult getChargeList(int page, int pagesize, string chargeName)
|
|||
|
|
{
|
|||
|
|
int count = new BLL.ChargeProjectMaintainBll().getAddCount(chargeName);
|
|||
|
|
List<Models.ChargeProjectMaintainModel> list = new BLL.ChargeProjectMaintainBll().getAddList(page, pagesize, chargeName);
|
|||
|
|
return Json(new { Total = count, Rows = list });
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public ActionResult SelectChargeProjectV(string lx)
|
|||
|
|
{
|
|||
|
|
ViewBag.lx = lx;
|
|||
|
|
return View();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public JsonResult getVChargeList(int page, int pagesize, string chargeName)
|
|||
|
|
{
|
|||
|
|
int count = new BLL.ChargeProjectMaintainBll().getVCount(chargeName);
|
|||
|
|
List<Models.ChargeProjectMaintainModel> list = new BLL.ChargeProjectMaintainBll().getVList(page, pagesize, chargeName);
|
|||
|
|
return Json(new { Total = count, Rows = list });
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|