public List <FilesEntity> GetFileListBySourceId(int Sid, FileSourceType type) { List <FilesEntity> list = new List <FilesEntity>(); StringBuilder strSql = new StringBuilder(); strSql.Append("select * from Files "); switch (type) { case FileSourceType.Ticket: strSql.Append(" where TicketId=@Sid "); break; case FileSourceType.Project: strSql.Append(" where ProjectId=@Sid "); break; case FileSourceType.FeedBack: strSql.Append(" where FeedbackId=@Sid "); break; case FileSourceType.WorkRequest: strSql.Append(" where WorkRequestId=@Sid "); break; case FileSourceType.KnowledgeShare: strSql.Append(" where SourceID=@Sid "); break; default: break; } strSql.Append(" and SourceType=@SourceType and Isdelete =0"); strSql.Append(" order by CreatedOn desc"); Database db = DatabaseFactory.CreateDatabase(); using (DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString())) { db.AddInParameter(dbCommand, "Sid", DbType.Int32, Sid); db.AddInParameter(dbCommand, "SourceType", DbType.Int32, (int)type); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { while (dataReader.Read()) { list.Add(FilesEntity.ReaderBind(dataReader)); } } } return(list); }
/// <summary> /// Get an object entity /// </summary> public FilesEntity Get(int FileID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from Files "); strSql.Append(" where FileID=@FileID "); Database db = DatabaseFactory.CreateDatabase(); using (DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString())) { db.AddInParameter(dbCommand, "FileID", DbType.Int32, FileID); FilesEntity model = null; using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { if (dataReader.Read()) { model = FilesEntity.ReaderBind(dataReader); } } return(model); } }
public FilesEntity Get(int fileId, decimal size) { StringBuilder strSql = new StringBuilder(); strSql.Append("select FileID,CompanyID,ProjectId,TicketId,FeedbackId,SourceType,FileTitle,ContentType,FileSize,FilePath,ThumbPath,CreatedOn,CreatedBy,IsDelete,IsPublic from Files "); strSql.Append(" where FileID=@FileID "); Database db = DatabaseFactory.CreateDatabase(); using (DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString())) { db.AddInParameter(dbCommand, "FileID", DbType.Int32, fileId); db.AddInParameter(dbCommand, "FileSize", DbType.Int32, size); FilesEntity model = null; using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { if (dataReader.Read()) { model = FilesEntity.ReaderBind(dataReader); } } return(model); } }