123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Data;
- using SysBaseLibs;
- using System.Web.Script.Serialization;
- using System.Web.UI.WebControls;
- using System.Web;
- using System.IO;
- namespace SysDataLibs.TableClass
- {
- #region Sys_AttachFiles
- public partial class Sys_AttachFiles_info : ITableInfo
- {
- #region Sys_AttachFiles表 字段信息
- /// <summary>
- /// 为关键字段: Y --- PrimaryKey;
- /// 自动增长: Y;
- /// 数据类型: int;
- /// 数据长度: 4;
- /// 是否允许为空: N;
- /// 默认值: ;
- /// 描述: AttachID;
- /// </summary>
- public const string cAttachID = "AttachID";
- /// <summary>
- /// 为关键字段: N ;
- /// 自动增长: N;
- /// 数据类型: nvarchar;
- /// 数据长度: 160;
- /// 是否允许为空: N;
- /// 默认值: ;
- /// 描述: ColumnId;
- /// </summary>
- public const string cColumnId = "ColumnId";
- /// <summary>
- /// 为关键字段: N ;
- /// 自动增长: N;
- /// 数据类型: nvarchar;
- /// 数据长度: -1;
- /// 是否允许为空: Y;
- /// 默认值: ;
- /// 描述: Description;
- /// </summary>
- public const string cDescription = "Description";
- /// <summary>
- /// 为关键字段: N ;
- /// 自动增长: N;
- /// 数据类型: nvarchar;
- /// 数据长度: 100;
- /// 是否允许为空: N;
- /// 默认值: ;
- /// 描述: FileExt;
- /// </summary>
- public const string cFileExt = "FileExt";
- /// <summary>
- /// 为关键字段: N ;
- /// 自动增长: N;
- /// 数据类型: nvarchar;
- /// 数据长度: 1000;
- /// 是否允许为空: N;
- /// 默认值: ;
- /// 描述: FileName;
- /// </summary>
- public const string cFileName = "FileName";
- /// <summary>
- /// 为关键字段: N ;
- /// 自动增长: N;
- /// 数据类型: nvarchar;
- /// 数据长度: 1000;
- /// 是否允许为空: N;
- /// 默认值: ;
- /// 描述: FilePath;
- /// </summary>
- public const string cFilePath = "FilePath";
- /// <summary>
- /// 为关键字段: N ;
- /// 自动增长: N;
- /// 数据类型: nvarchar;
- /// 数据长度: 500;
- /// 是否允许为空: Y;
- /// 默认值: ;
- /// 描述: FileTitle;
- /// </summary>
- public const string cFileTitle = "FileTitle";
- /// <summary>
- /// 为关键字段: N ;
- /// 自动增长: N;
- /// 数据类型: nchar;
- /// 数据长度: 20;
- /// 是否允许为空: N;
- /// 默认值: ;
- /// 描述: FileType;
- /// </summary>
- public const string cFileType = "FileType";
- /// <summary>
- /// 为关键字段: N ;
- /// 自动增长: N;
- /// 数据类型: varchar;
- /// 数据长度: 250;
- /// 是否允许为空: N;
- /// 默认值: ;
- /// 描述: SourceKey;
- /// </summary>
- public const string cSourceKey = "SourceKey";
- /// <summary>
- /// 为关键字段: N ;
- /// 自动增长: N;
- /// 数据类型: nvarchar;
- /// 数据长度: 160;
- /// 是否允许为空: N;
- /// 默认值: ;
- /// 描述: TableId;
- /// </summary>
- public const string cTableId = "TableId";
- /// <summary>
- /// 为关键字段: N ;
- /// 自动增长: N;
- /// 数据类型: smalldatetime;
- /// 数据长度: 4;
- /// 是否允许为空: N;
- /// 默认值: (getdate());
- /// 描述: TimeCreated;
- /// </summary>
- public const string cTimeCreated = "TimeCreated";
- /// <summary>
- /// 为关键字段: N ;
- /// 自动增长: N;
- /// 数据类型: smalldatetime;
- /// 数据长度: 4;
- /// 是否允许为空: N;
- /// 默认值: (getdate());
- /// 描述: TimeLastMod;
- /// </summary>
- public const string cTimeLastMod = "TimeLastMod";
- /// <summary>
- /// 为关键字段: N ;
- /// 自动增长: N;
- /// 数据类型: varchar;
- /// 数据长度: 30;
- /// 是否允许为空: N;
- /// 默认值: ;
- /// 描述: UserIDLastMod;
- /// </summary>
- public const string cUserIDLastMod = "UserIDLastMod";
- #endregion
- public Sys_AttachFiles_info() { }
- public Sys_AttachFiles_info(DataRow poRow)
- {
- CreateTableInfo(poRow);
- }
- public void CreateTableInfo(DataRow poRow)
- {
- _AttachID = UtilStr.StrFromObj(poRow[cAttachID]);
- _ColumnId = UtilStr.StrFromObj(poRow[cColumnId]);
- _Description = UtilStr.StrFromObj(poRow[cDescription]);
- _FileExt = UtilStr.StrFromObj(poRow[cFileExt]);
- _FileName = UtilStr.StrFromObj(poRow[cFileName]);
- _FilePath = UtilStr.StrFromObj(poRow[cFilePath]);
- _FileTitle = UtilStr.StrFromObj(poRow[cFileTitle]);
- _FileType = UtilStr.StrFromObj(poRow[cFileType]);
- _SourceKey = UtilStr.StrFromObj(poRow[cSourceKey]);
- _TableId = UtilStr.StrFromObj(poRow[cTableId]);
- _TimeCreated = UtilStr.StrFromObj(poRow[cTimeCreated]);
- _TimeLastMod = UtilStr.StrFromObj(poRow[cTimeLastMod]);
- _UserIDLastMod = UtilStr.StrFromObj(poRow[cUserIDLastMod]);
- }
- public Sys_AttachFiles_info(string pcAttachID, DBConnSql poDBConn)
- {
- if (pcAttachID.Trim().Length > 0 && poDBConn != null)
- {
- string lcSql = "select * from " + Tn.Sys_AttachFiles + " where AttachID='" + pcAttachID + "' order by AttachID desc ";
- rsQuery loQuery = poDBConn.OpenQuery(lcSql);
- if (loQuery != null && loQuery.IsOpened && loQuery.RecCount == 1)
- {
- loQuery.MoveFirst();
- CreateTableInfo(loQuery.CurrentRow);
- }
- }
- }
- public Sys_AttachFiles_info(string pcTableId, string pcColumnId, string pcSourceKey, DBConnSql poDBConn)
- {
- if (pcTableId.Trim().Length > 0 && pcColumnId.Length > 0 && poDBConn != null)
- {
- string lcSql = "select * from " + Tn.Sys_AttachFiles + " where TableId='" + pcTableId + "' AND ColumnId='" + pcColumnId + "' AND SourceKey='" + pcSourceKey + "' order by AttachID desc ";
- rsQuery loQuery = poDBConn.OpenQuery(lcSql);
- if (loQuery != null && loQuery.IsOpened && loQuery.RecCount > 0)
- {
- loQuery.MoveFirst();
- CreateTableInfo(loQuery.CurrentRow);
- }
- }
- }
- private string _AttachID = "";
- public string AttachID
- {
- get { return _AttachID; }
- set { _AttachID = value; }
- }
- private string _ColumnId = "";
- public string ColumnId
- {
- get { return _ColumnId; }
- set { _ColumnId = value; }
- }
- private string _Description = "";
- public string Description
- {
- get { return _Description; }
- set { _Description = value; }
- }
- private string _FileExt = "";
- public string FileExt
- {
- get { return _FileExt; }
- set { _FileExt = value; }
- }
- private string _FileName = "";
- public string FileName
- {
- get { return _FileName; }
- set { _FileName = value; }
- }
- private string _FilePath = "";
- public string FilePath
- {
- get { return _FilePath; }
- set { _FilePath = value; }
- }
- private string _FileTitle = "";
- public string FileTitle
- {
- get { return _FileTitle; }
- set { _FileTitle = value; }
- }
- private string _FileType = "";
- public string FileType
- {
- get { return _FileType; }
- set { _FileType = value; }
- }
- private string _SourceKey = "";
- public string SourceKey
- {
- get { return _SourceKey; }
- set { _SourceKey = value; }
- }
- private string _TableId = "";
- public string TableId
- {
- get { return _TableId; }
- set { _TableId = value; }
- }
- private string _TimeCreated = "";
- public string TimeCreated
- {
- get { return _TimeCreated; }
- set { _TimeCreated = value; }
- }
- private string _TimeLastMod = "";
- public string TimeLastMod
- {
- get { return _TimeLastMod; }
- set { _TimeLastMod = value; }
- }
- private string _UserIDLastMod = "";
- public string UserIDLastMod
- {
- get { return _UserIDLastMod; }
- set { _UserIDLastMod = value; }
- }
- public string DownPath()
- {
- return "../" + FilePath + "/" + FileName;
- }
- [ScriptIgnore]
- public rsXmlNode DataXMLNode
- {
- get
- {
- rsXmlNode loMainNode = new rsXmlNode("Sys_AttachFilesRecord", "");
- rsXmlNode loNode = null;
- loNode = new rsXmlNode(cAttachID, AttachID);
- loMainNode.AddChild(loNode);
- loNode = new rsXmlNode(cColumnId, ColumnId);
- loMainNode.AddChild(loNode);
- loNode = new rsXmlNode(cDescription, Description);
- loMainNode.AddChild(loNode);
- loNode = new rsXmlNode(cFileExt, FileExt);
- loMainNode.AddChild(loNode);
- loNode = new rsXmlNode(cFileName, FileName);
- loMainNode.AddChild(loNode);
- loNode = new rsXmlNode(cFilePath, FilePath);
- loMainNode.AddChild(loNode);
- loNode = new rsXmlNode(cFileTitle, FileTitle);
- loMainNode.AddChild(loNode);
- loNode = new rsXmlNode(cFileType, FileType);
- loMainNode.AddChild(loNode);
- loNode = new rsXmlNode(cSourceKey, SourceKey);
- loMainNode.AddChild(loNode);
- loNode = new rsXmlNode(cTableId, TableId);
- loMainNode.AddChild(loNode);
- loNode = new rsXmlNode(cTimeCreated, TimeCreated);
- loMainNode.AddChild(loNode);
- loNode = new rsXmlNode(cTimeLastMod, TimeLastMod);
- loMainNode.AddChild(loNode);
- loNode = new rsXmlNode(cUserIDLastMod, UserIDLastMod);
- loMainNode.AddChild(loNode);
- return loMainNode;
- }
- }
- public string InsertSql()
- {
- return " insert into " + Tn.Sys_AttachFiles + " " +
- " (" + cColumnId + "," + cDescription + "," + cFileExt + "," + cFileName + "," + cFilePath + "," + cFileTitle + "," + cFileType + "," + cSourceKey + "," + cTableId + "," + cTimeCreated + "," + cTimeLastMod + "," + cUserIDLastMod + ") " +
- " values ('" + _ColumnId + "','" + _Description + "','" + _FileExt + "','" + _FileName + "','" + _FilePath + "','" + _FileTitle + "','" + _FileType + "','" + _SourceKey + "','" + _TableId + "','" + _TimeCreated + "','" + _TimeLastMod + "','" + _UserIDLastMod + "') ";
- }
- public string UpdateSql()
- {
- return " update " + Tn.Sys_AttachFiles + " " +
- " set " + cColumnId + "='" + _ColumnId + "'," + cDescription + "='" + _Description + "'," + cFileExt + "='" + _FileExt + "'," + cFileName + "='" + _FileName + "'," + cFilePath + "='" + _FilePath + "'," + cFileTitle + "='" + _FileTitle + "'," + cFileType + "='" + _FileType + "'," + cSourceKey + "='" + _SourceKey + "'," + cTableId + "='" + _TableId + "'," + cTimeCreated + "='" + _TimeCreated + "'," + cTimeLastMod + "='" + _TimeLastMod + "'," + cUserIDLastMod + "='" + _UserIDLastMod + "' " +
- " where " + cAttachID + "=" + _AttachID + "";
- }
- public string DeleteSql()
- {
- return "Delete " + Tn.Sys_AttachFiles + " where " + cAttachID + "=" + _AttachID + "";
- }
- public bool UpdateFile(FileUpload poFileUpload, UserSession poSession)
- {
- bool lbRetVal = false;
- //检查要上传的文件是否存在
- if (poFileUpload.PostedFile.FileName.Trim() != "")
- {
- try
- {
- string UploadFileName = "";
- string UploadFileDestination = "";
- UploadFileName = poFileUpload.PostedFile.FileName;
- if (MyUtils.IsValidFileType(UploadFileName))
- {
- UploadFileName = UploadFileName.Substring(UploadFileName.LastIndexOf("\\") + 1);
- this.FileExt = UploadFileName.Substring(UploadFileName.LastIndexOf(".") + 1, UploadFileName.Length - UploadFileName.LastIndexOf(".") - 1);
- if (string.IsNullOrEmpty(this.FileTitle))
- this.FileTitle = UploadFileName.Remove(UploadFileName.LastIndexOf("."));
- this.FilePath = SysDataLibs.AppEnv.SysSetObj.GetString("DOWNLOADPATH") + "/" + AppEnv.SysSetObj.GetString("ATTACHFILES") + "/" + this.TableId.ToUpper();
- UploadFileDestination = HttpContext.Current.Request.PhysicalApplicationPath;
- UploadFileDestination += this.FilePath;
- if (!Directory.Exists(UploadFileDestination))
- {
- Directory.CreateDirectory(UploadFileDestination);
- }
- string lcDateRd = this.FileTitle + "-" + DateTime.Now.ToString("yyyyMMddHHmmssffffff") + "." + this.FileExt;
- this.FileName = lcDateRd.Replace(" ", "");
- poFileUpload.PostedFile.SaveAs(UploadFileDestination + "/" + this.FileName);
- lbRetVal = poSession.DBConn.ExcuteSqlTran(this.InsertSql());
- ThreadLog.LogInfo(poSession.UserInfo.Names + "(" + poSession.UserInfo.UserID + ")" + " update File " + this.DownPath());
- lbRetVal = true;
- }
- }
- catch (Exception e)
- {
- ThreadLog.LogException(e);
- ThreadLog.LogErr("文件上传异常");
- ThreadLog.LogException(e);
- lbRetVal = false;
- }
- }
- return lbRetVal;
- }
- }
- #endregion
- #region
- public class Sys_AttachFiles_Qry : rsQuery
- {
- public Int64 AttachID
- {
- get { return GetInt(Sys_AttachFiles_info.cAttachID); }
- // set { SetField(Sys_AttachFiles_info.cAttachID, value); }
- }
- public String ColumnId
- {
- get { return GetString(Sys_AttachFiles_info.cColumnId); }
- // set { SetField(Sys_AttachFiles_info.cColumnId, value); }
- }
- public String Description
- {
- get { return GetString(Sys_AttachFiles_info.cDescription); }
- // set { SetField(Sys_AttachFiles_info.cDescription, value); }
- }
- public String FileExt
- {
- get { return GetString(Sys_AttachFiles_info.cFileExt); }
- // set { SetField(Sys_AttachFiles_info.cFileExt, value); }
- }
- public String FileName
- {
- get { return GetString(Sys_AttachFiles_info.cFileName); }
- // set { SetField(Sys_AttachFiles_info.cFileName, value); }
- }
- public String FilePath
- {
- get { return GetString(Sys_AttachFiles_info.cFilePath); }
- // set { SetField(Sys_AttachFiles_info.cFilePath, value); }
- }
- public String FileTitle
- {
- get { return GetString(Sys_AttachFiles_info.cFileTitle); }
- // set { SetField(Sys_AttachFiles_info.cFileTitle, value); }
- }
- public String FileType
- {
- get { return GetString(Sys_AttachFiles_info.cFileType); }
- // set { SetField(Sys_AttachFiles_info.cFileType, value); }
- }
- public String SourceKey
- {
- get { return GetString(Sys_AttachFiles_info.cSourceKey); }
- // set { SetField(Sys_AttachFiles_info.cSourceKey, value); }
- }
- public String TableId
- {
- get { return GetString(Sys_AttachFiles_info.cTableId); }
- // set { SetField(Sys_AttachFiles_info.cTableId, value); }
- }
- public DateTime TimeCreated
- {
- get { return GetDateTime(Sys_AttachFiles_info.cTimeCreated); }
- // set { SetField(Sys_AttachFiles_info.cTimeCreated, value); }
- }
- public DateTime TimeLastMod
- {
- get { return GetDateTime(Sys_AttachFiles_info.cTimeLastMod); }
- // set { SetField(Sys_AttachFiles_info.cTimeLastMod, value); }
- }
- public String UserIDLastMod
- {
- get { return GetString(Sys_AttachFiles_info.cUserIDLastMod); }
- // set { SetField(Sys_AttachFiles_info.cUserIDLastMod, value); }
- }
- }
- #endregion
- }
|