/// <summary> /// 获取图片 /// </summary> /// <param name="type">类型</param> public void GetImg(string type) { HomeConfigEntity entity = GetEntityByType(type); string img = ""; if (entity != null && !string.IsNullOrEmpty(entity.F_Img)) { ImgEntity imgEntity = imgIBLL.GetEntity(entity.F_Img); if (imgEntity != null && !string.IsNullOrEmpty(imgEntity.F_Content)) { FileDownHelper.DownLoadBase64(imgEntity.F_Content, imgEntity.F_Name); return; } } else { img = "/Content/images/plhome/addImg.png"; } if (string.IsNullOrEmpty(img)) { img = "/Content/images/plhome/addImg.png"; } FileDownHelper.DownLoad(img); }
public int Add(ImgEntity model) { DataAccess da = new DataAccess("newConnLink"); da.CreateConnection(); StringBuilder strSql = new StringBuilder(); strSql.Append("insert into sns_Img("); strSql.Append("ImgUrl,addtime,Status)"); strSql.Append(" values ("); strSql.Append("@ImgUrl,@addtime,@Status)"); strSql.Append(";select @@IDENTITY"); DbParameter[] parameters = { new SqlParameter("@ImgUrl", SqlDbType.VarChar, 50), new SqlParameter("@addtime", SqlDbType.DateTime), new SqlParameter("@Status", SqlDbType.Int, 4) }; parameters[0].Value = model.ImgUrl; parameters[1].Value = model.addtime; parameters[2].Value = model.Status; object obj = da.ExecuteScalar(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 获取图片 /// </summary> /// <param name="keyValue">主键</param> public void GetImg(string keyValue) { ArticleEntity entity = GetEntity(keyValue); string img = ""; if (entity != null && !string.IsNullOrEmpty(entity.F_Img)) { ImgEntity imgEntity = imgIBLL.GetEntity(entity.F_Img); if (imgEntity != null && !string.IsNullOrEmpty(imgEntity.F_Content)) { FileDownHelper.DownLoadBase64(imgEntity.F_Content, imgEntity.F_Name); return; } } else { img = "/Content/images/plhome/banner_df.jpg"; } if (string.IsNullOrEmpty(img)) { img = "/Content/images/plhome/banner_df.jpg"; } FileDownHelper.DownLoad(img); }
/// <summary> /// 得到一个对象实体 /// </summary> private ImgEntity DataRowToModel(DataRow row) { ImgEntity model = new ImgEntity(); if (row != null) { if (row["ImgId"] != null && row["ImgId"].ToString() != "") { model.ImgId = int.Parse(row["ImgId"].ToString()); } if (row["ImgUrl"] != null) { model.ImgUrl = row["ImgUrl"].ToString(); } if (row["addtime"] != null && row["addtime"].ToString() != "") { model.addtime = DateTime.Parse(row["addtime"].ToString()); } if (row["Status"] != null && row["Status"].ToString() != "") { model.Status = int.Parse(row["Status"].ToString()); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(ImgEntity model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into sns_Img("); strSql.Append("ImgUrl,addtime,Status)"); strSql.Append(" values ("); strSql.Append("@ImgUrl,@addtime,@Status)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@ImgUrl", SqlDbType.VarChar, 50), new SqlParameter("@addtime", SqlDbType.DateTime), new SqlParameter("@Status", SqlDbType.Int, 4) }; parameters[0].Value = model.ImgUrl; parameters[1].Value = model.addtime; parameters[2].Value = model.Status; object obj = SqlHelper.Instance.ExecSqlScalar(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
public ActionResult UploadFile(string keyValue, LR_StampManageEntity entity) { HttpFileCollection files = System.Web.HttpContext.Current.Request.Files; if (files[0].ContentLength == 0 || string.IsNullOrEmpty(files[0].FileName)) { lr_StampManageIBLL.SaveEntity(keyValue, entity); } else { string FileEextension = Path.GetExtension(files[0].FileName); ImgEntity imgEntity = null; if (string.IsNullOrEmpty(entity.F_ImgFile)) { imgEntity = new ImgEntity(); } else { imgEntity = imgIBLL.GetEntity(entity.F_ImgFile); } imgEntity.F_Name = files[0].FileName; imgEntity.F_ExName = FileEextension; byte[] bytes = new byte[files[0].InputStream.Length]; files[0].InputStream.Read(bytes, 0, bytes.Length); imgEntity.F_Content = Convert.ToBase64String(bytes); imgIBLL.SaveEntity(entity.F_ImgFile, imgEntity); entity.F_ImgFile = imgEntity.F_Id; lr_StampManageIBLL.SaveEntity(keyValue, entity); } return(Success("保存成功。")); }
public object GetShare(int num) { DataTable shareTable = ExchangeBll.Instance.GetList2(num, "a.Status='1'", "a.addTime DESC,a.id DESC").Tables[0]; //分享 //获得封面 for (int i = 0; i < shareTable.Rows.Count; i++) { if (shareTable.Rows[i]["cover"].ToString() != "") { shareTable.Rows[i]["cover"] = SmallImgBll.Instance.GetModel(Convert.ToInt32(shareTable.Rows[i]["cover"]))?.ImgUrl; } if (shareTable.Rows[i]["Certificate"] != null && shareTable.Rows[i]["Certificate"].ToString() != "") { shareTable.Rows[i]["Certificate"] = ImgBll.Instance.GetModel(Convert.ToInt32(shareTable.Rows[i]["Certificate"]))?.ImgUrl; } if (shareTable.Rows[i]["Imgs"].ToString() != "") { string[] imgIds = shareTable.Rows[i]["Imgs"].ToString().Split(','); string imgs = ""; foreach (string imgId in imgIds) { ImgEntity imgEntity = ImgBll.Instance.GetModel(int.Parse(imgId)); imgs += imgEntity.ImgUrl + ","; } shareTable.Rows[i]["Imgs"] = imgs; } } return(new DataTableModels() { Dt = shareTable, Status = StatusEnum.success }); }
public object GetCoo(int num) { DataTable cooTable = CooperationBll.Instance.GetList(num, "Status='1'", "ReleaseTime DESC,id DESC"); //合作 //获得封面 for (int i = 0; i < cooTable.Rows.Count; i++) { if (cooTable.Rows[i]["cover"].ToString() != "") { string[] imgIds = cooTable.Rows[i]["cover"].ToString().Split(','); string imgs = ""; foreach (string imgId in imgIds) { ImgEntity imgEntity = ImgBll.Instance.GetModel(int.Parse(imgId)); imgs += imgEntity?.ImgUrl + ","; } cooTable.Rows[i]["cover"] = imgs; } } return(new DataTableModels() { Dt = cooTable, Status = StatusEnum.success }); }
/// <summary> /// 获取图片 /// </summary> /// <param name="keyValue">主键</param> public void GetImg(string keyValue) { //首先获取实体 LR_StampManageEntity entity = GetEntity(keyValue); string img = ""; //实体是否存在 if (entity != null && !string.IsNullOrEmpty(entity.F_ImgFile)) { ImgEntity imgEntity = imgIBLL.GetEntity(entity.F_ImgFile); if (imgEntity != null && !string.IsNullOrEmpty(imgEntity.F_Content)) { FileDownHelper.DownLoadBase64(imgEntity.F_Content, imgEntity.F_Name); return; } } else { img = "/Content/images/add.jpg"; } if (string.IsNullOrEmpty(img)) { img = "/Content/images/add.jpg"; } FileDownHelper.DownLoad(img); }
/// <summary> /// 保存轮播图片 /// </summary> /// <param name="strBase64">图片字串</param> /// <param name="fileNmae">文件名</param> /// <param name="fileExName">文件扩展名</param> /// <param name="keyValue">主键</param> public void SaveImg2(string strBase64, string fileNmae, string fileExName, string keyValue, int sort) { HomeConfigEntity entity = null; if (string.IsNullOrEmpty(keyValue)) { entity = new HomeConfigEntity(); entity.Create(); entity.F_Type = "8"; } else { entity = GetEntity(keyValue); if (entity == null) { entity = new HomeConfigEntity(); entity.F_Id = keyValue; entity.F_Type = "8"; keyValue = ""; } } entity.F_Sort = sort; string imgKey = null; ImgEntity imgEntity = null; if (!string.IsNullOrEmpty(entity.F_Img)) { imgEntity = imgIBLL.GetEntity(entity.F_Img); if (imgEntity != null) { imgKey = entity.F_Img; } else { imgEntity = new ImgEntity(); } } else { imgEntity = new ImgEntity(); } imgEntity.F_Content = strBase64; imgEntity.F_Name = fileNmae; imgEntity.F_ExName = fileExName; imgIBLL.SaveEntity(imgKey, imgEntity); entity.F_Img = imgEntity.F_Id; homeConfigService.SaveEntity(keyValue, entity); }
public object GetCooByPage(int currentPage) { string typeValue = ""; //类型 int pageSize = 10; //每页行数 int pageStartRow = (currentPage - 1) * pageSize + 1; //开始行数 int pageEndRow = currentPage * pageSize; //结束行数 int nextPage = currentPage + 1; //下一页 int totalRowsAmount; //总行数 int totalPages; //总页数 bool hasNext; //下一页 int previousPage = currentPage - 1; //上一页 bool hasPrevious = previousPage >= 1; //上一页 totalRowsAmount = CooperationBll.Instance.GetRecordCount("Status='1'"); DataTable cooTable = CooperationBll.Instance.GetListByPage("Status='1'", "ReleaseTime DESC,id DESC", pageStartRow, pageEndRow); //获得封面 for (int i = 0; i < cooTable.Rows.Count; i++) { string[] imgIds = cooTable.Rows[i]["cover"].ToString().Split(','); string imgs = ""; foreach (string imgId in imgIds) { if (!string.IsNullOrEmpty(imgId)) { ImgEntity imgEntity = ImgBll.Instance.GetModel(int.Parse(imgId)); imgs += imgEntity.ImgUrl + ","; } } cooTable.Rows[i]["cover"] = imgs; } totalPages = int.Parse(Math.Ceiling(totalRowsAmount / 10.0).ToString(CultureInfo.InvariantCulture)); hasNext = nextPage <= totalPages; DataTablePageModels dataTablePageModels = new DataTablePageModels { CurrentPage = currentPage, TypeValue = typeValue, PageSize = pageSize, PageStartRow = pageStartRow, PageEndRow = pageEndRow, NextPage = nextPage, TotalRowsAmount = totalRowsAmount, TotalPages = totalPages, HasNext = hasNext, PreviousPage = previousPage, HasPrevious = hasPrevious, Dt = cooTable, Status = StatusEnum.success }; return(dataTablePageModels); }
/// <summary> /// 绑定图片 /// </summary> private void BindImage() { string[] imgs = rentEntity.Imgs.Split(','); string s = ""; foreach (string t in imgs) { ImgEntity imgEntity = ImgBll.Instance.GetModel(int.Parse(t)); s += $"<img src='{imgEntity.ImgUrl.Replace("\\", "/")}' alt=''>"; } litImgList.Text = s; }
/// <summary> /// 增加一条数据 /// </summary> public int Add(ImgEntity model) { try { return(ImgDb.Instance.Add(model)); } catch (Exception ex) { WriteLog.WriteError(ex); throw ex; } }
/// <summary> /// 绑定凭证 /// </summary> private void BindCertificate() { string img = rentEntity.Certificate; string s = ""; if (!string.IsNullOrEmpty(img)) { ImgEntity imgEntity = ImgBll.Instance.GetModel(int.Parse(img)); s += $"<img src='{imgEntity.ImgUrl.Replace("\\", "/")}' alt=''>"; } litCertificate.Text = s; }
/// <summary> /// 保存图片 /// </summary> /// <param name="strBase64">图片字串</param> /// <param name="fileNmae">文件名</param> /// <param name="fileExName">文件扩展名</param> /// <param name="type">类型</param> public void SaveImg(string strBase64, string fileNmae, string fileExName, string type) { HomeConfigEntity entity = GetEntityByType(type); string keyValue = null; if (entity == null) { entity = new HomeConfigEntity(); entity.Create(); entity.F_Type = type; } else { keyValue = entity.F_Id; } string imgKey = null; ImgEntity imgEntity = null; if (!string.IsNullOrEmpty(entity.F_Img)) { imgEntity = imgIBLL.GetEntity(entity.F_Img); if (imgEntity != null) { imgKey = entity.F_Img; } else { imgEntity = new ImgEntity(); } } else { imgEntity = new ImgEntity(); } imgEntity.F_Content = strBase64; imgEntity.F_Name = fileNmae; imgEntity.F_ExName = fileExName; imgIBLL.SaveEntity(imgKey, imgEntity); entity.F_Img = imgEntity.F_Id; homeConfigService.SaveEntity(keyValue, entity); }
public void ProcessRequest(HttpContext context) { string img = context.Request.Form["b"]; //原图base64 string img2 = context.Request.Form["b2"]; //缩略图base64 string s = "{\"status\":\"error\"}"; //获取时间戳 TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0); Random ro = new Random(); string tt = Convert.ToInt64(ts.TotalSeconds).ToString() + ro.Next(); ImgEntity imgEntity = new ImgEntity(); imgEntity.ImgUrl = UploadFile.UploadImg(img, "Upload\\COS\\", tt); imgEntity.addtime = DateTime.Now; imgEntity.Status = 1; if ((imgEntity.ImgId = ImgBll.Instance.Add(imgEntity)) > 0) { SmallImgEntity smallImgEntity = new SmallImgEntity(); smallImgEntity.ImgUrl = UploadFile.UploadImg(img2, "Upload\\COS\\", tt + "320x180"); smallImgEntity.addtime = DateTime.Now; smallImgEntity.Status = 1; if ((smallImgEntity.ImgId = SmallImgBll.Instance.Add(smallImgEntity)) > 0) { s = "{\"status\":\"success\",\"imgid\":\"" + imgEntity.ImgId + "\",\"img2id\":\"" + smallImgEntity.ImgId + "\",\"img\":\"" + imgEntity.ImgUrl.Replace("\\", "\\\\") + "\",\"img2\":\"" + smallImgEntity.ImgUrl.Replace("\\", "\\\\") + "\"}"; } else { s = "{\"status\":\"error\"}"; } } else { s = "{\"status\":\"error\"}"; } context.Response.ContentType = "text/plain"; context.Response.Write(s); }
public object GetShareEntity(int eid) { ExchangeEntity shaerEntity = ExchangeBll.Instance.GetModel(eid); if (shaerEntity == null) { return(new KeyValuePair <string, StatusEnum>("status", StatusEnum.empty)); } if (!string.IsNullOrWhiteSpace(shaerEntity.Cover)) { shaerEntity.Cover = SmallImgBll.Instance.GetModel(Convert.ToInt32(shaerEntity.Cover))?.ImgUrl; } if (!string.IsNullOrWhiteSpace(shaerEntity.Certificate)) { string[] imgIds = shaerEntity.Certificate.Split(','); string imgs = ""; foreach (string imgId in imgIds) { ImgEntity imgEntity = ImgBll.Instance.GetModel(int.Parse(imgId)); imgs += imgEntity.ImgUrl + ","; } shaerEntity.Certificate = imgs; } if (!string.IsNullOrWhiteSpace(shaerEntity.Imgs)) { string[] imgIds = shaerEntity.Imgs.Split(','); string imgs = ""; foreach (string imgId in imgIds) { ImgEntity imgEntity = ImgBll.Instance.GetModel(int.Parse(imgId)); imgs += imgEntity.ImgUrl + ","; } shaerEntity.Imgs = imgs; } return(new DataTableModels { Dt = shaerEntity, Status = StatusEnum.success }); }
public ActionResult UploadFile(string keyValue, ArticleEntity entity) { entity.F_Content = entity.F_Content.Replace("script", ""); HttpFileCollection files = System.Web.HttpContext.Current.Request.Files; //没有文件上传,直接返回 if (files[0].ContentLength == 0 || string.IsNullOrEmpty(files[0].FileName)) { articleIBLL.SaveEntity(keyValue, entity); } else { string FileEextension = Path.GetExtension(files[0].FileName); ImgEntity imgEntity = null; if (string.IsNullOrEmpty(entity.F_Img)) { imgEntity = new ImgEntity(); } else { imgEntity = imgIBLL.GetEntity(entity.F_Img); } imgEntity.F_Name = files[0].FileName; imgEntity.F_ExName = FileEextension; byte[] bytes = new byte[files[0].InputStream.Length]; files[0].InputStream.Read(bytes, 0, bytes.Length); imgEntity.F_Content = Convert.ToBase64String(bytes); imgIBLL.SaveEntity(entity.F_Img, imgEntity); entity.F_ImgName = imgEntity.F_Name; entity.F_Img = imgEntity.F_Id; articleIBLL.SaveEntity(keyValue, entity); } return(Success("保存成功。")); }
/// <summary> /// 得到一个对象实体 /// </summary> public ImgEntity GetModel(int imgId) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ImgId,ImgUrl,addtime,Status from sns_Img "); strSql.Append(" where ImgId=@ImgId"); SqlParameter[] parameters = { new SqlParameter("@ImgId", SqlDbType.Int, 4) }; parameters[0].Value = imgId; ImgEntity model = new ImgEntity(); DataSet ds = SqlHelper.Instance.ExecSqlDataSet(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
public object ShareSearch(string sea, string p) { int currentPage = int.Parse(p); //当前页 int pageSize = 10; //每页行数 int pageStartRow = (currentPage - 1) * pageSize + 1; //开始行数 int pageEndRow = currentPage * pageSize; //结束行数 int nextPage = currentPage + 1; //下一页 int totalRowsAmount; //总行数 int totalPages; //总页数 bool hasNext; //下一页 int previousPage = currentPage - 1; //上一页 bool hasPrevious = previousPage >= 1; //上一页 StringBuilder strWhere = new StringBuilder("t.status=1 "); StringBuilder sb = new StringBuilder("status=1 "); if (!string.IsNullOrEmpty(sea)) { strWhere.Append("and t.title like '%" + sea + "%'"); sb.Append("and title like '%" + sea + "%'"); } totalRowsAmount = ExchangeBll.Instance.GetRecordCount(sb.ToString()); DataTable shareTable = ExchangeBll.Instance.GetListByPage2(strWhere.ToString(), "addTime DESC", pageStartRow, pageEndRow).Tables[0]; //获得封面 for (int i = 0; i < shareTable.Rows.Count; i++) { if (!string.IsNullOrEmpty(shareTable.Rows[i]["cover"].ToString())) { shareTable.Rows[i]["cover"] = SmallImgBll.Instance.GetModel(Convert.ToInt32(shareTable.Rows[i]["cover"]))?.ImgUrl; } if (!string.IsNullOrEmpty(shareTable.Rows[i]["Certificate"].ToString())) { string[] imgIds = shareTable.Rows[i]["Certificate"].ToString().Split(','); string imgs = ""; foreach (string imgId in imgIds) { int imgid; if (int.TryParse(imgId, out imgid)) { ImgEntity imgEntity = ImgBll.Instance.GetModel(imgid); imgs += imgEntity.ImgUrl + ","; } } shareTable.Rows[i]["Certificate"] = imgs; } if (!string.IsNullOrEmpty(shareTable.Rows[i]["Imgs"].ToString())) { string[] imgIds = shareTable.Rows[i]["Imgs"].ToString().Split(','); string imgs = ""; foreach (string imgId in imgIds) { int imgid; if (int.TryParse(imgId, out imgid)) { ImgEntity imgEntity = ImgBll.Instance.GetModel(imgid); imgs += imgEntity.ImgUrl + ","; } } shareTable.Rows[i]["Imgs"] = imgs; } } totalPages = int.Parse(Math.Ceiling(totalRowsAmount / 10.0).ToString()); hasNext = nextPage <= totalPages; DataTablePageModels dataTablePageModels = new DataTablePageModels { CurrentPage = currentPage, TypeValue = "", PageSize = pageSize, PageStartRow = pageStartRow, PageEndRow = pageEndRow, NextPage = nextPage, TotalRowsAmount = totalRowsAmount, TotalPages = totalPages, HasNext = hasNext, PreviousPage = previousPage, HasPrevious = hasPrevious, Dt = shareTable, Status = StatusEnum.success }; return(dataTablePageModels); }
public object GetShareByPage(int currentPage) { string typeValue = ""; //类型 int pageSize = 10; //每页行数 int pageStartRow = (currentPage - 1) * pageSize + 1; //开始行数 int pageEndRow = currentPage * pageSize; //结束行数 int nextPage = currentPage + 1; //下一页 int totalRowsAmount; //总行数 int totalPages; //总页数 bool hasNext; //下一页 int previousPage = currentPage - 1; //上一页 bool hasPrevious = previousPage >= 1; //上一页 totalRowsAmount = ExchangeBll.Instance.GetRecordCount("Status='1'"); DataTable shareTable = ExchangeBll.Instance.GetListByPage2("t.Status='1'", "addTime DESC", pageStartRow, pageEndRow).Tables[0]; //获得封面 for (int i = 0; i < shareTable.Rows.Count; i++) { if (shareTable.Rows[i]["cover"].ToString() != "") { shareTable.Rows[i]["cover"] = SmallImgBll.Instance.GetModel(Convert.ToInt32(shareTable.Rows[i]["cover"]))?.ImgUrl; } if (shareTable.Rows[i]["Certificate"].ToString() != "") { shareTable.Rows[i]["Certificate"] = ImgBll.Instance.GetModel(Convert.ToInt32(shareTable.Rows[i]["Certificate"]))?.ImgUrl; } if (shareTable.Rows[i]["Imgs"].ToString() != "") { string[] imgIds = shareTable.Rows[i]["Imgs"].ToString().Split(','); string imgs = ""; foreach (string imgId in imgIds) { int imgid; if (int.TryParse(imgId, out imgid)) { ImgEntity imgEntity = ImgBll.Instance.GetModel(imgid); imgs += imgEntity.ImgUrl + ","; } } shareTable.Rows[i]["Imgs"] = imgs; } } totalPages = int.Parse(Math.Ceiling(totalRowsAmount / 10.0).ToString()); hasNext = nextPage <= totalPages; DataTablePageModels dataTablePageModels = new DataTablePageModels { CurrentPage = currentPage, TypeValue = typeValue, PageSize = pageSize, PageStartRow = pageStartRow, PageEndRow = pageEndRow, NextPage = nextPage, TotalRowsAmount = totalRowsAmount, TotalPages = totalPages, HasNext = hasNext, PreviousPage = previousPage, HasPrevious = hasPrevious, Dt = shareTable, Status = StatusEnum.success }; return(dataTablePageModels); }
private void button2_Click(object sender, EventArgs e) { DataAccess oldda = new DataAccess("oldConnLink"); oldda.CreateConnection(); string sql = "SELECT * FROM dbo.cos_member"; DataTable dt = oldda.GetDataTable(sql); foreach (DataRow dataRow in dt.Rows) { MemberEntity newMemberEntity = new MemberEntity(); newMemberEntity.User_name = dataRow["User_name"].ToString(); newMemberEntity.Password = dataRow["Password"].ToString(); newMemberEntity.Real_name = dataRow["Real_name"].ToString(); newMemberEntity.Gender = dataRow["Gender"].ToString(); newMemberEntity.Birthday = dataRow["Birthday"].ToString(); newMemberEntity.Reg_time = Convert.ToDateTime(dataRow["Reg_time"]); newMemberEntity.Last_login = Convert.ToDateTime(dataRow["Last_login"].ToString()); newMemberEntity.Portrait = dataRow["Portrait"].ToString(); newMemberEntity.integral = Convert.ToInt32(dataRow["integral"].ToString()); newMemberEntity.ardent = Convert.ToInt32(dataRow["ardent"].ToString()); newMemberEntity.Growth = Convert.ToInt32(dataRow["Growth"].ToString()); int userid = MemberDb.Instance.Add(newMemberEntity); sql = $@"SELECT * FROM dbo.sns_ordinaryNote WHERE User_id='{dataRow["User_id"]}'"; DataTable note = oldda.GetDataTable(sql); foreach (DataRow row in note.Rows) { sql = $@"SELECT * FROM dbo.sns_noteImg WHERE NoteId='{row["NoteId"]}'"; DataTable img = oldda.GetDataTable(sql); string iss = ""; foreach (DataRow dataRow1 in img.Rows) { ImgEntity imgEntity = new ImgEntity(); imgEntity.ImgUrl = "/" + dataRow1["ImgUrl"].ToString(); imgEntity.addtime = DateTime.Now; imgEntity.Status = 1; MemberDb.Instance.Add(imgEntity); iss += "<img src='/" + dataRow1["ImgUrl"] + "' alt=''>"; } WorksEntity worksEntity = new WorksEntity(); worksEntity.User_id = userid.ToString(); worksEntity.WorksTitle = row["notetitle"].ToString(); worksEntity.WorksType = "20"; worksEntity.Type2 = "24"; worksEntity.LabelDesc = row["LabelDesc"].ToString(); worksEntity.WorksContent = "<div>" + row["notecontent"] + "</div>" + iss; worksEntity.Root = "0"; worksEntity.Keep = "1"; worksEntity.Watermark = "1"; worksEntity.ReleaseTime = Convert.ToDateTime(row["ReleaseTime"]); worksEntity.UpdateTime = Convert.ToDateTime(row["UpdateTime"]); worksEntity.Status = 1; worksEntity.source = "original"; MemberDb.Instance.Add(worksEntity); } } MessageBox.Show("完成"); }