/// <summary> /// 删除实体 /// </summary> /// <param name="param">删除条件实体</param> /// <returns></returns> public WCFAddUpdateResult DelInfo(Sys_RootDirMappingParam param) { this.CheckSession(); WCFAddUpdateResult ret = new WCFAddUpdateResult(); int affect = 0; try { #region 判断 if (param.MGuid == null) { throw new WarnException("请指定要删除的映射表guid!"); } #endregion WhereClip whereClip = GetWhereClip(param); Sys_RootDirMappingResult info = new Sys_RootDirMappingResult(); info.IsDeleted = true; affect = this.Update <Sys_RootDirMappingResult>(info, whereClip); #region 设置返回值 ret.Key = affect; #endregion } catch (WarnException exp) { throw exp; } catch (System.Exception exp) { LogInfoBLL.WriteLog(this.SessionInfo, exp); } return(ret); }
public Sys_RootDirMappingResult GetInfo(Sys_RootDirMappingParam param) { Sys_RootDirMappingResult ret = new Sys_RootDirMappingResult(); ExeResult rst = new ExeResult(); rst = this.Execute("ZNLCRM.BLL.Sys.Sys_RootDirMappingBLL", "GetInfo", param); ret = rst == null ? new Sys_RootDirMappingResult() : rst.Result as Sys_RootDirMappingResult; return(ret); }
public WCFAddUpdateResult AddOrUpdate(Sys_RootDirMappingResult param) { WCFAddUpdateResult ret = new WCFAddUpdateResult(); ExeResult rst = new ExeResult(); rst = this.Execute("ZNLCRM.BLL.Sys.Sys_RootDirMappingBLL", "AddOrUpdate", param); ret = (rst == null ? new WCFAddUpdateResult() : rst.Result as WCFAddUpdateResult); return(ret); }
/// <summary> /// 获取一条信息记录 /// </summary> /// <param name="param"></param> /// <returns></returns> public Sys_RootDirMappingResult GetInfo(Sys_RootDirMappingParam param) { this.CheckSession(); Sys_RootDirMappingResult rst = new Sys_RootDirMappingResult(); //#region 判断 //if (param.MGuid == null) throw new WarnException("请指定映射表GUID!"); //#endregion #region 获取实体 rst = this.Select <Sys_RootDirMappingResult>(GetWhereClip(param)); #endregion return(rst); }
private void btnSave_Click(object sender, EventArgs e) { Sys_RootDirMappingResult info = new Sys_RootDirMappingResult(); info = this.ConvertControlToEntity <Sys_RootDirMappingResult>(this.panelEdit.Controls, info, null); WCFAddUpdateResult result = this.AsyncExecute <WCFAddUpdateResult, Sys_RootDirMappingResult>(info, logic.AddOrUpdate, (a) => { if (a.Key > 0) { BindDataGridView(pgMapping.PageIndex); this.HidEditWindow(); } }); }
/// <summary> /// 批量上传 /// </summary> /// <param name="paramList"></param> /// <returns></returns> public List <Sys_AttachFilesResult> UploadAttach(List <Sys_AttachFilesResult> list) { this.CheckSession(); WCFAddUpdateResult ret = new WCFAddUpdateResult(); try { #region 判断 if (list.Count <= 0) { throw new WarnException("没有需要操作的对象!"); } if (list.Exists(a => a.AttachType == null)) { throw new WarnException("没有设置上传的附件类型!"); } #endregion AttachType type = list[0].AttachType; string attachType = string.Empty; switch (type) { case AttachType.Bill: attachType = "Bill"; break; case AttachType.Pic: attachType = "Pic"; break; } Sys_RootDirMappingBLL mBLL = new Sys_RootDirMappingBLL(); mBLL.SessionInfo = this.SessionInfo; //获取根目录 Sys_RootDirMappingResult mRst = mBLL.GetInfo(new Sys_RootDirMappingParam() { AttachType = attachType, IsEffect = true }); if (mRst == null) { throw new WarnException("根目录映射表没有有效的设置信息!"); } mRst.PhysicalRootPath = mRst.PhysicalRootPath.Replace("{Company}", this.SessionInfo.CompanyID.ToStringHasNull()); //设置文件目录 string folderPath = mRst.PhysicalRootPath + @"\" + DateTime.Now.Year + @"\" + DateTime.Now.ToString("yyyyMMdd"); string thumbnailFolderPath = string.Empty; if (!Directory.Exists(folderPath)) { Directory.CreateDirectory(folderPath); } ////如果有图片才形成压缩图片的存放目录 //if (list.Exists(a => ".bmp.png.jpg.gif.jpeg.BMP.PNG.JPG.GIF.JPEG".Contains(a.FileSuffix))) //{ // //设置压缩图片的存放目录 // thumbnailFolderPath= folderPath + @"\Thumbnail"; // if (!Directory.Exists(thumbnailFolderPath)) // { // Directory.CreateDirectory(thumbnailFolderPath); // } //} foreach (Sys_AttachFilesResult rst in list) { rst.FileName = DateTime.Now.ToString("yyyyMMddHHmmssms") + new Random().Next(10000, 99999); rst.FilePath = folderPath + @"\" + rst.FileName + rst.FileSuffix; using (FileStream fs = new FileStream(rst.FilePath, FileMode.CreateNew)) { fs.Write(rst.File, 0, rst.FileSize.ToInt32()); fs.Close(); } if (rst.TBNFile != null) { rst.TBNFileName = rst.FileName + "_TBN" + ".JPG";; rst.TBNFilePath = folderPath + @"\" + rst.TBNFileName; using (FileStream fs = new FileStream(rst.TBNFilePath, FileMode.CreateNew)) { fs.Write(rst.TBNFile, 0, rst.TBNFile.Length.ToInt32()); fs.Close(); } } } } catch (WarnException exp) { throw exp; } catch (System.Exception exp) { LogInfoBLL.WriteLog(this.SessionInfo, exp); throw exp; } return(list); }
/// <summary> /// 添加和新增修改 /// </summary> /// <param name="param">新增或修改的实体</param> /// <returns></returns> public WCFAddUpdateResult AddOrUpdate(Sys_RootDirMappingResult param) { this.CheckSession(); WCFAddUpdateResult ret = new WCFAddUpdateResult(); try { int affect = 0; #region 判断 if (string.IsNullOrEmpty(param.AttachType)) { throw new WarnException("请指定单据类型!"); } if (string.IsNullOrEmpty(param.PhysicalRootPath)) { throw new WarnException("请指定物理根目录路径!"); } if (string.IsNullOrEmpty(param.MappingIdentifier)) { throw new WarnException("请指定映射标示符!"); } #endregion #region if (param.MGuid != null) { WhereClip where = Sys_RootDirMapping._.MGuid == param.MGuid; param.UpdatedEmpID = this.SessionInfo.UserID; param.UpdatedEmpName = this.SessionInfo.UserName; param.UpdatedTime = DateTime.Now; affect = this.Update <Sys_RootDirMappingResult>(param, where); List <Sys_RootDirMappingResult> rstList = this.SelectList <Sys_RootDirMappingResult>(Sys_RootDirMapping._.MGuid != param.MGuid && Sys_RootDirMapping._.AttachType == param.AttachType && Sys_RootDirMapping._.GCompanyID == this.SessionInfo.CompanyID); if (rstList != null) { rstList.ForEach(a => { a.IsEffect = false; }); } this.BatchInsertOrUpdate <Sys_RootDirMappingResult>(rstList); } else { param.MGuid = Guid.NewGuid(); param.GCompanyID = this.SessionInfo.CompanyID; param.IsDeleted = false; param.CreatedEmpID = this.SessionInfo.UserID; param.CreatedEmpName = this.SessionInfo.UserName; param.CreatedTime = DateTime.Now; affect = this.Insert <Sys_RootDirMappingResult>(param); param = this.Select <Sys_RootDirMappingResult>(new List <Field>() { Sys_RootDirMapping._.All }, Sys_RootDirMapping._.MGuid == param.MGuid); } #region 设置返回值 ret.Key = param.MID; ret.KeyGuid = param.MGuid; ret.CreatedTime = param.CreatedTime; ret.CreatedEmpID = param.CreatedEmpID; ret.CreatedEmpName = param.CreatedEmpName; ret.UpdatedEmpID = param.UpdatedEmpID; ret.UpdatedEmpName = param.UpdatedEmpName; ret.UpdatedTime = param.UpdatedTime; #endregion #endregion } catch (WarnException exp) { throw exp; } catch (System.Exception exp) { LogInfoBLL.WriteLog(this.SessionInfo, exp); throw exp; } return(ret); }