/// <summary> /// 接受客户端视频数据,保存图片 /// </summary> /// <param name="videoString">视频流字符(Base64格式)</param> /// <param name="videoThumb">视频缩略图(Base64格式)</param> /// <param name="recordtype">类型</param> /// <param name="recordid">编号(订单ID)</param> public int SaveRecordVideo(string videoString, string videoThumb, TableRecordType recordtype, int recordid) { int imgcount = 0; if (!string.IsNullOrEmpty(videoString)) { string rootpath = ConfigHelper.GetConfigValueByKey("resource_physical_path"); string savedir = recordtype.ToString().ToLower(); string datepath = DateTime.Now.ToString("yyyyMMdd"); string path = string.Format("{0}\\videos\\{1}\\{2}\\", rootpath, savedir, datepath); //路径 string savepath = string.Format("/videos/{0}/{1}/", savedir, datepath); //保存数据路径 //判断目录是否存在,不存在则创建目录 Utils.CreateDir(Utils.GetMapPath(path)); imgcount++; var videoBytes = NH.Commons.PictureHelper.ConvertBase64ToByte(videoString); string videoFileName = string.Format("{0}_{1}.mp4", recordid, DateTime.Now.ToString("yyMMddHHmmssfff")); //保存视频文件 var fs = new System.IO.FileStream(string.Concat(path, videoFileName), System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.None); fs.Write(videoBytes, 0, videoBytes.Length); fs.Close(); //视频截图 if (!string.IsNullOrEmpty(videoThumb)) { System.Drawing.Image image = null; try { image = NH.Commons.PictureHelper.ConvertBase64ToImage(videoThumb); string imageFilename = string.Concat(path, System.IO.Path.ChangeExtension(videoFileName, ".jpg")); PictureHelper.SaveImage(image, imageFilename, 90L); } catch { } } } return(imgcount); }
/// <summary> /// 接受客户端图片参数,保存图片 /// </summary> /// <param name="argname">参数名称</param> /// <param name="recordtype">类型</param> /// <param name="recordid">编号</param> public int SaveRecordImage(string argname, TableRecordType recordtype, int recordid) { IList <string> imgList = RequestHelper.GetArray(argname); return(SaveRecordImage(imgList, recordtype, recordid)); }
/// <summary> /// 接受客户端图片参数,保存图片 /// </summary> /// <param name="imgList">图片列表</param> /// <param name="recordtype">类型</param> /// <param name="recordid">编号</param> public int SaveRecordImage(IList <string> imgList, TableRecordType recordtype, int recordid) { int imgcount = 0; //if (imgList != null && imgList.Count > 0) //{ // System.Drawing.Image image = null; // string rootpath = ConfigHelper.GetConfigValueByKey("resource_physical_path"); // string savedir = recordtype.ToString().ToLower(); // string datepath = DateTime.Now.ToString("yyyyMMdd"); // string path = string.Format("{0}\\images\\{1}\\{2}\\", rootpath, savedir, datepath); //原图路径 // string savepath = string.Format("/images/{0}/{1}/", savedir, datepath); //保存数据库的路径 // //判断目录是否存在,不存在则创建目录 // Utils.CreateDir(Utils.GetMapPath(path)); // string filename; // #region 循环保存图片 // NH.Commons.Interface.IGenericDAO<V2PictureLibrary, int> plDao = new NH.Commons.Data.GenericHibernateDAO<V2PictureLibrary, int>(); // for (int i = 0; i < imgList.Count; i++) // { // if (Utils.StrIsNullOrEmpty(imgList[i])) // { // continue; // } // try // { // image = NH.Commons.PictureHelper.ConvertBase64ToImage(imgList[i]); // } // catch(Exception ex) // { // NH.Service.LogsService.GetInstance().AddApplicationLogs(userid, "保存订单图片错误", "CONBase > SaveRecordImage", ex.ToString(), Session != null ? Session.SessionID : "", LogsType.Error); // } // if (image != null) // { // filename = string.Format("{0}_{1}_{2}.jpg", recordid, i, DateTime.Now.ToString("yyMMddHHmmssfff")); // bool success = PictureHelper.SaveImage(image, string.Concat(path, filename), 90L); // if (success) // { // imgcount++; // plDao.Insert(new V2PictureLibrary // { // RecordID = recordid, // RecordType = (int)recordtype, // WifiPicUrl = string.Concat(savepath, filename), // GPRSPicUrl = string.Concat(savepath, filename), // ThumbUrl = string.Concat(savepath, filename), // IsLogo = imgcount == 1, // SerialNo = imgcount, // SaveTime = DateTime.Now // }); // } // } // } // #endregion //} return(imgcount); }
private TableRecord CreateTableRecord(DateTime date, Employee employee, Double hours = 0.0, TableRecordType type = TableRecordType.DayOff) { return new TableRecord { Date = date, DayNumber = date.Day, Employee = employee, Hours = hours, Type = type }; }