Example #1
0
        /// <summary>
        /// 获取删除时插入日志表sql
        /// </summary>
        /// <param name="modelInfo"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        protected override string GetInsertDeleteHistory(XModelBase modelInfo, string userId)
        {
            XFileAttachmentInfo info = modelInfo as XFileAttachmentInfo;
            string sql = "Insert Into " + this.HistoryTableName + "(RID,FileId,AtchName,AtchDesc,AtchType,AtchSize,AtchPath,AtchShotGifPath,AtchImag,InputUserId,InputTime,OperateUserId,Operate,OperateTime,NewID) SELECT RID,FileId,AtchName,AtchDesc,AtchType,AtchSize,AtchPath,AtchShotGifPath,AtchImag,InputUserId,InputTime,'" + userId + "','删除',getdate(),newid() FROM " + this.TableName + " WHERE " + this.PrimaryKey + "='" + info.RID + "'";

            return(sql);
        }
Example #2
0
        /// <summary>
        /// 获取插入sql
        /// </summary>
        /// <param name="modelInfo"></param>
        /// <returns></returns>
        public override string GetInsertSql(XModelBase modelInfo)
        {
            XFileAttachmentInfo info = modelInfo as XFileAttachmentInfo;
            string sql = "Insert Into " + this.TableName + "(RID,FileId,AtchName,AtchDesc,AtchType,AtchSize,AtchPath,AtchShotGifPath,AtchImag,InputUserId,InputTime)Values('{0}','{1}','{2}','{3}','{4}',{5},'{6}','{7}','{8}','{9}',{10})";

            sql = String.Format(sql, info.RID, info.FileId, info.AtchName, info.AtchDesc, info.AtchType, info.AtchSize, info.AtchPath, info.AtchShotGifPath, info.AtchImag, info.InputUserId, this.GetServerTimeFuncion());
            return(sql);
        }
Example #3
0
        public static bool Preview(string fileId)
        {
            string where = " and FileId='" + fileId + "'";

            IList <XModelBase> fileAttachInfos = m_FileAttachBusiness.QueryByWhere(where);

            if (fileAttachInfos.Count == 0)
            {
                XMessageBox.ShowError("未找到附件,无法预览!");
                return(false);
            }

            XFileAttachmentInfo fileInfo = fileAttachInfos[0] as XFileAttachmentInfo;

            string[] imageTypes  = new string[] { ".png", ".jpg", ".jpeg" };
            string[] officeTypes = new string[] { ".doc", ".docx", ".xls", ".xlsx" };

            if (!imageTypes.Contains(fileInfo.AtchType) &&
                !officeTypes.Contains(fileInfo.AtchType))
            {
                XMessageBox.ShowError("不支持预览格式为[" + fileInfo.AtchType + "]的文件!");
                return(false);
            }

            string path     = XCommon.TempPath;
            string fileName = Guid.NewGuid().ToString();

            fileName = m_FileAttachBusiness.DownLoadFile(fileId, path, fileName);

            if (imageTypes.Contains(fileInfo.AtchType))
            {
                //如果是图片
                frmImagePreview frm = new frmImagePreview(fileName);
                frm.ShowDialog();
            }
            else
            {
                frmOfficeFilePreview frm = new frmOfficeFilePreview(fileName);
                frm.ShowDialog();
            }

            if (File.Exists(fileName))
            {
                try
                {
                    File.Delete(fileName);
                }
                catch (Exception ex)
                {
                    XErrorLogTool.WriteLog(ex.ToString());
                }
            }

            return(true);
        }
Example #4
0
        /// <summary>
        /// 获取更新Sql
        /// </summary>
        /// <param name="modelInfo"></param>
        /// <returns></returns>
        public override string GetUpdateSql(XModelBase modelInfo)
        {
            string sql = String.Empty;

            XFileAttachmentInfo info = modelInfo as XFileAttachmentInfo;

            sql = "Update " + this.TableName + " Set FileId='{0}',AtchName='{1}',AtchDesc='{2}',AtchType='{3}',AtchSize={4},AtchPath='{5}',AtchShotGifPath='{6}',AtchImag='{7}', Where RID='{8}'";
            sql = string.Format(sql, info.FileId, info.AtchName, info.AtchDesc, info.AtchType, info.AtchSize, info.AtchPath, info.AtchShotGifPath, info.AtchImag, info.RID);

            return(sql);
        }
        /// <summary>
        /// 自定义修改校验
        /// </summary>
        /// <param name="modelInfo"></param>
        /// <returns></returns>
        protected override string GetValidateUpdateCustom(XModelBase modelInfo)
        {
            string validateInfo = string.Empty;
            XFileAttachmentInfo fileattachment = modelInfo as XFileAttachmentInfo;

            if (fileattachment == null)
            {
                return(this.GetNotRightType());
            }
            return(string.Empty);
        }
Example #6
0
        /// <summary>
        /// 将数据行转换为实体
        /// </summary>
        /// <param name="modelRow">数据行记录</param>
        /// <returns>实体信息</returns>
        protected override void DataRow2ModelBase(XModelBase modelInfo, DataRow modelRow)
        {
            XFileAttachmentInfo info = modelInfo as XFileAttachmentInfo;

            info.ID              = XHelper.GetString(XDataRowHelper.GetFieldValue(modelRow, "RID"));             //主键
            info.RID             = XHelper.GetString(XDataRowHelper.GetFieldValue(modelRow, "RID"));             //主键
            info.FileId          = XHelper.GetString(XDataRowHelper.GetFieldValue(modelRow, "FileId"));          //文档主键
            info.AtchName        = XHelper.GetString(XDataRowHelper.GetFieldValue(modelRow, "AtchName"));        //附件名称
            info.AtchDesc        = XHelper.GetString(XDataRowHelper.GetFieldValue(modelRow, "AtchDesc"));        //附件描述
            info.AtchType        = XHelper.GetString(XDataRowHelper.GetFieldValue(modelRow, "AtchType"));        //附件类型
            info.AtchSize        = XHelper.GetDouble(XDataRowHelper.GetFieldValue(modelRow, "AtchSize"));        //附件大小
            info.AtchPath        = XHelper.GetString(XDataRowHelper.GetFieldValue(modelRow, "AtchPath"));        //附件路径
            info.AtchShotGifPath = XHelper.GetString(XDataRowHelper.GetFieldValue(modelRow, "AtchShotGifPath")); //缩略图路径
            info.AtchImag        = XHelper.GetString(XDataRowHelper.GetFieldValue(modelRow, "AtchImag"));        //流文件
            info.InputUserId     = XHelper.GetString(XDataRowHelper.GetFieldValue(modelRow, "InputUserId"));     //录入人
            info.InputTime       = XHelper.GetString(XDataRowHelper.GetFieldValue(modelRow, "InputTime"));       //录入时间
        }