public static SpaceAttachmentInfo GetSpaceAttachmentInfo(IDataReader idatareader) { if (idatareader == null) { return(null); } if (idatareader.Read()) { SpaceAttachmentInfo spaceattachmentinfo = new SpaceAttachmentInfo(); spaceattachmentinfo.AID = TypeConverter.ObjectToInt(idatareader["aid"]); spaceattachmentinfo.UID = TypeConverter.ObjectToInt(idatareader["uid"]); spaceattachmentinfo.SpacePostID = TypeConverter.ObjectToInt(idatareader["spacepostid"]); spaceattachmentinfo.PostDateTime = Convert.ToDateTime(idatareader["postdatetime"]); spaceattachmentinfo.FileName = idatareader["filename"].ToString(); spaceattachmentinfo.FileType = idatareader["filetype"].ToString(); spaceattachmentinfo.FileSize = TypeConverter.ObjectToInt(idatareader["filesize"]); spaceattachmentinfo.Attachment = idatareader["attachment"].ToString(); spaceattachmentinfo.Downloads = TypeConverter.ObjectToInt(idatareader["downloads"]); idatareader.Close(); return(spaceattachmentinfo); } else { idatareader.Close(); return(null); } }
private void InsertSapceAttachment(string filename, string filetype, int filesize, string attachment) { SpaceAttachmentInfo spaceattachmentinfo = new SpaceAttachmentInfo(); spaceattachmentinfo.UID = userid; spaceattachmentinfo.SpacePostID = Convert.ToInt32(ViewState["postid"].ToString()); spaceattachmentinfo.PostDateTime = DateTime.Now; spaceattachmentinfo.FileName = filename; spaceattachmentinfo.FileType = filetype; spaceattachmentinfo.FileSize = filesize; spaceattachmentinfo.Attachment = attachment; spaceattachmentinfo.Downloads = 0; Space.Data.DbProvider.GetInstance().AddSpaceAttachment(spaceattachmentinfo); }
/// <summary> /// 保存附件 /// </summary> /// <param name="mediaObject"></param> /// <param name="uid"></param> /// <param name="filename"></param> private static void SaveSpaceAttachment(MediaObject mediaObject, int uid, string filename) { SpaceAttachmentInfo spaceattachmentinfo = new SpaceAttachmentInfo(); spaceattachmentinfo.UID = uid; spaceattachmentinfo.SpacePostID = 0; spaceattachmentinfo.PostDateTime = DateTime.Now; spaceattachmentinfo.FileName = filename; spaceattachmentinfo.FileType = mediaObject.type; spaceattachmentinfo.FileSize = mediaObject.bits.Length; spaceattachmentinfo.Attachment = mediaObject.name; spaceattachmentinfo.Downloads = 0; DbProvider.GetInstance().AddSpaceAttachment(spaceattachmentinfo); }
public static SpaceAttachmentInfo[] GetSpaceAttachmentInfo(DataTable dt) { if (dt == null || dt.Rows.Count == 0) { return(null); } SpaceAttachmentInfo[] spaceattachmentinfoarray = new SpaceAttachmentInfo[dt.Rows.Count]; for (int i = 0; i < dt.Rows.Count; i++) { spaceattachmentinfoarray[i] = new SpaceAttachmentInfo(); spaceattachmentinfoarray[i].AID = TypeConverter.ObjectToInt(dt.Rows[i]["aid"]); spaceattachmentinfoarray[i].UID = TypeConverter.ObjectToInt(dt.Rows[i]["uid"]); spaceattachmentinfoarray[i].SpacePostID = TypeConverter.ObjectToInt(dt.Rows[i]["spacepostid"]); spaceattachmentinfoarray[i].PostDateTime = Convert.ToDateTime(dt.Rows[i]["postdatetime"]); spaceattachmentinfoarray[i].FileName = dt.Rows[i]["filename"].ToString(); spaceattachmentinfoarray[i].FileType = dt.Rows[i]["filetype"].ToString(); spaceattachmentinfoarray[i].FileSize = TypeConverter.ObjectToInt(dt.Rows[i]["filesize"]); spaceattachmentinfoarray[i].Attachment = dt.Rows[i]["attachment"].ToString(); spaceattachmentinfoarray[i].Downloads = TypeConverter.ObjectToInt(dt.Rows[i]["downloads"]); } dt.Dispose(); return(spaceattachmentinfoarray); }