|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Drawing;
|
|
|
using System.IO;
|
|
|
using System.Linq;
|
|
|
using System.Web;
|
|
|
using System.Web.Services;
|
|
|
using TradeData;
|
|
|
using NetLibrary.Data;
|
|
|
using System.Data;
|
|
|
using TradeModel;
|
|
|
using NetLibrary.ReportPrint;
|
|
|
using NetLibrary;
|
|
|
using NetLibrary.Express;
|
|
|
using System.Text.RegularExpressions;
|
|
|
using NetLibrary.OnlineTrade;
|
|
|
using System.Web.Script.Serialization;
|
|
|
using System.Text;
|
|
|
using NetLibrary.Log;
|
|
|
using System.Threading;
|
|
|
using ApiNew;
|
|
|
using PdfiumViewer;
|
|
|
using System.Drawing.Imaging;
|
|
|
|
|
|
namespace TradeManageNew.EBOOK
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// EBookService 的摘要说明
|
|
|
/// </summary>
|
|
|
[WebService(Namespace = "http://tempuri.org/")]
|
|
|
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
|
|
|
[System.ComponentModel.ToolboxItem(false)]
|
|
|
// 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消注释以下行。
|
|
|
[System.Web.Script.Services.ScriptService]
|
|
|
public class EBookService : System.Web.Services.WebService
|
|
|
{
|
|
|
|
|
|
[WebMethod]
|
|
|
public string HelloWorld()
|
|
|
{
|
|
|
return "Hello World";
|
|
|
}
|
|
|
|
|
|
[WebMethod(EnableSession = true)]
|
|
|
public string GetImg(string umgbase)
|
|
|
{
|
|
|
// Pages.Login(this.Session);
|
|
|
|
|
|
|
|
|
string strbase64 = umgbase.Substring(umgbase.IndexOf(',') + 1);
|
|
|
strbase64 = strbase64.Trim('\0');
|
|
|
var gg = new Guid();
|
|
|
|
|
|
string imgUrl = "attached/ebook/" + Guid.NewGuid().ToString().Substring(0, 20) + ".jpg";
|
|
|
Base64ToImage(strbase64, imgUrl);
|
|
|
// var imgUrl = "https://winwoo-file.oss-cn-hangzhou.aliyuncs.com/" + name;
|
|
|
// Product.AliyunOSSAPI.UploadFile(name, strbase64);
|
|
|
|
|
|
return "../"+imgUrl;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// base64 转 Image
|
|
|
/// </summary>
|
|
|
/// <param name="base64"></param>
|
|
|
public static void Base64ToImage(string base64,string url)
|
|
|
{
|
|
|
base64 = base64.Replace("data:image/png;base64,", "").Replace("data:image/jgp;base64,", "").Replace("data:image/jpg;base64,", "").Replace("data:image/jpeg;base64,", "");//将base64头部信息替换
|
|
|
byte[] bytes = Convert.FromBase64String(base64);
|
|
|
MemoryStream memStream = new MemoryStream(bytes);
|
|
|
Image mImage = Image.FromStream(memStream);
|
|
|
string iurl= System.AppDomain.CurrentDomain.BaseDirectory + url;
|
|
|
mImage.Save(iurl, System.Drawing.Imaging.ImageFormat.Jpeg);//注意保存路径
|
|
|
|
|
|
//Bitmap bp = new Bitmap(mImage);
|
|
|
//bp.Save("D:/资源/" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);//注意保存路径
|
|
|
}
|
|
|
#region 保存
|
|
|
[WebMethod(EnableSession = true)]
|
|
|
public int Save_BooksImg(E_BookList model, List<E_BookPages> list2, List<E_BookPopedom> rolelist)
|
|
|
{
|
|
|
PagesNew.Login(this.Session);
|
|
|
if(model.id==0)
|
|
|
{
|
|
|
model.indate = DateTime.Now;
|
|
|
model.inname = Session["Name"].ToString();
|
|
|
|
|
|
|
|
|
}
|
|
|
if (list2 != null && list2.Count > 0)
|
|
|
{
|
|
|
model.fristimg = list2[0].pageimg;
|
|
|
model.pages = list2.Count;
|
|
|
}
|
|
|
// model.isuse = 1;
|
|
|
|
|
|
int id=EBookData.Save_BookList(model);
|
|
|
if (model.imgedit == 1)
|
|
|
{
|
|
|
EBookData.Delete_BookPagesAll(id,1);
|
|
|
if (list2 != null)
|
|
|
{
|
|
|
foreach (var md in list2)
|
|
|
{
|
|
|
md.id = 0;
|
|
|
md.bookid = id;
|
|
|
EBookData.Save_BookPages(md);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
EBookData.DeleteBookPopedom(id);
|
|
|
if (rolelist != null&& model.popedom==1)
|
|
|
{
|
|
|
|
|
|
foreach (var md in rolelist)
|
|
|
{
|
|
|
md.bookid = id;
|
|
|
md.popedom = 1;
|
|
|
EBookData.Save_BookPopedom(md);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 保存
|
|
|
[WebMethod(EnableSession = true)]
|
|
|
public int Save_BooksImgPrice(E_BookList model, List<E_BookPages> list2)
|
|
|
{
|
|
|
PagesNew.Login(this.Session);
|
|
|
if (model.id == 0)
|
|
|
{
|
|
|
model.indate = DateTime.Now;
|
|
|
model.inname = Session["Name"].ToString();
|
|
|
|
|
|
|
|
|
}
|
|
|
//if (list2 != null && list2.Count > 0)
|
|
|
//{
|
|
|
// model.fristimg = list2[0].pageimg;
|
|
|
// model.pages = list2.Count;
|
|
|
//}
|
|
|
// model.isuse = 1;
|
|
|
|
|
|
int id = model.id.Value;// EBookData.Save_BookList(model);
|
|
|
|
|
|
EBookData.Delete_BookPagesAll(id,2);
|
|
|
if (list2 != null)
|
|
|
{
|
|
|
foreach (var md in list2)
|
|
|
{
|
|
|
md.id = 0;
|
|
|
md.bookid = id;
|
|
|
EBookData.Save_BookPages(md);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
}
|
|
|
#endregion
|
|
|
#region 分页查询书本
|
|
|
|
|
|
[WebMethod(EnableSession = true)]
|
|
|
public JsonModel<List<E_BookList>> GetListBookList(string name, string sortname,string gcname,string gccs,string gcxz, int PageIndex, int PageSize)
|
|
|
{
|
|
|
PagesNew.Login(this.Session);
|
|
|
if (sortname.Trim()== "")
|
|
|
sortname = "";
|
|
|
string where = "where isuse=1";
|
|
|
if (name != "")
|
|
|
where += " and bookname like '%" + name + "%' ";// + where.Substring(4);
|
|
|
if (sortname != "")
|
|
|
where += " and type_name like '%" + sortname + "%' ";
|
|
|
if (gcname != "")
|
|
|
where += " and type_name3 like '%" + gcname + "%' ";
|
|
|
var resultModel = new JsonModel<List<E_BookList>>();
|
|
|
int RowCount = 0;
|
|
|
resultModel.DataSource = EBookData.GetListBookList(where, PageIndex, PageSize, sortname, out RowCount);
|
|
|
resultModel.RowCount = RowCount;
|
|
|
return resultModel;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
#region 分页查询书本
|
|
|
|
|
|
[WebMethod(EnableSession = true)]
|
|
|
public JsonModel<List<E_BookList>> GetListBookMyList(string name, string sortname, string gcname, string gccs, string gcxz, int PageIndex, int PageSize)
|
|
|
{
|
|
|
PagesNew.Login(this.Session);
|
|
|
int UserId = Convert.ToInt32(Session["UserId"]);
|
|
|
|
|
|
string where = "where isuse=1";
|
|
|
if (name != "")
|
|
|
where += " and bookname like '%" + name + "%' ";// + where.Substring(4);
|
|
|
if (sortname != "-1")
|
|
|
where += " and type_name='" + sortname + "' ";
|
|
|
if (gcname != "-1")
|
|
|
where += " and type_name3='" + gcname + "' ";
|
|
|
if (gccs != "-1")
|
|
|
where += " and type_name4='" + gccs + "' ";
|
|
|
if (gcxz != "-1")
|
|
|
where += " and type_name5='" + gcxz + "' ";
|
|
|
|
|
|
var resultModel = new JsonModel<List<E_BookList>>();
|
|
|
int RowCount = 0;
|
|
|
resultModel.DataSource = EBookData.GetListMyBookList(where, UserId,PageIndex, PageSize, "sort,indate desc", out RowCount);
|
|
|
resultModel.RowCount = RowCount;
|
|
|
return resultModel;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 分页查询书本
|
|
|
|
|
|
[WebMethod(EnableSession = true)]
|
|
|
public JsonModel<List<E_BookList>> GetListOutBookList(string code, int PageIndex, int PageSize)
|
|
|
{
|
|
|
// PagesNew.Login(this.Session);
|
|
|
// int UserId = Convert.ToInt32(Session["UserId"]);
|
|
|
|
|
|
string where = "where isuse=1";
|
|
|
|
|
|
|
|
|
var resultModel = new JsonModel<List<E_BookList>>();
|
|
|
int RowCount = 0;
|
|
|
resultModel.DataSource = EBookData.GetListOutBookList(where, code, PageIndex, PageSize, "sort", out RowCount);
|
|
|
resultModel.RowCount = RowCount;
|
|
|
return resultModel;
|
|
|
}
|
|
|
#endregion
|
|
|
#region 删除
|
|
|
[WebMethod(EnableSession = true)]
|
|
|
public bool Delete_BookList(int id)
|
|
|
{
|
|
|
PagesNew.Login(this.Session);
|
|
|
EBookData.Delete_BookList(id);
|
|
|
return true;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 删除
|
|
|
[WebMethod(EnableSession = true)]
|
|
|
public bool Delete_BookPages(List<E_BookPages> plist)
|
|
|
{
|
|
|
PagesNew.Login(this.Session);
|
|
|
foreach (var md in plist)
|
|
|
{
|
|
|
EBookData.Delete_BookPages(md.id.Value);
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
#endregion
|
|
|
#region 返回Model
|
|
|
[WebMethod(EnableSession = true)]
|
|
|
public E_BookList GetModel_Book(int id)
|
|
|
{
|
|
|
PagesNew.Login(this.Session);
|
|
|
var Model = EBookData.GetModel_Book(id);
|
|
|
return Model;
|
|
|
}
|
|
|
#endregion
|
|
|
#region 普通查询列表
|
|
|
[WebMethod(EnableSession = true)]
|
|
|
public List<E_BookPages> GetListBookPages(int BookId)
|
|
|
{
|
|
|
PagesNew.Login(this.Session);
|
|
|
var ListModel = EBookData.GetListBookPages(BookId,1);
|
|
|
return ListModel;
|
|
|
}
|
|
|
#endregion
|
|
|
#region 普通查询列表
|
|
|
[WebMethod(EnableSession = true)]
|
|
|
public List<E_BookPages> GetListBookPagesPrice(int BookId)
|
|
|
{
|
|
|
PagesNew.Login(this.Session);
|
|
|
var ListModel = EBookData.GetListBookPages(BookId, 2);
|
|
|
return ListModel;
|
|
|
}
|
|
|
#endregion
|
|
|
#region 普通查询列表
|
|
|
[WebMethod(EnableSession = true)]
|
|
|
public List<E_BookPages> GetListBookPages2(string gocode)
|
|
|
{
|
|
|
// PagesNew.Login(this.Session);
|
|
|
var ListModel = EBookData.GetListBookPages2(gocode);
|
|
|
return ListModel;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 普通查询列表
|
|
|
[WebMethod(EnableSession = true)]
|
|
|
public List<E_BookPages> GetListBookPagesInfo(string gocode,int type)
|
|
|
{
|
|
|
//PagesNew.Login(this.Session);
|
|
|
var ListModel = EBookData.GetListBookPagesImgs(gocode, type);
|
|
|
return ListModel;
|
|
|
}
|
|
|
#endregion
|
|
|
#region 普通查询列表
|
|
|
[WebMethod(EnableSession = true)]
|
|
|
public List<E_BookPages> GetListPDFImg(string url)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
PagesNew.Login(this.Session);
|
|
|
if (Session["IsPdf"].ToString() == "1")
|
|
|
{
|
|
|
return null;
|
|
|
}
|
|
|
string ph = AppDomain.CurrentDomain.BaseDirectory + url;
|
|
|
string dd = DateTime.Today.ToString("yyyyMMdd");
|
|
|
string wph = AppDomain.CurrentDomain.BaseDirectory + "attached/ebook/"+ dd;
|
|
|
if (Directory.Exists(wph) == false) Directory.CreateDirectory(wph);
|
|
|
string oph = AppDomain.CurrentDomain.BaseDirectory + "attached/ebook/" + dd;
|
|
|
Session["IsPdf"] = "1";
|
|
|
var list = PDFConvertTo(ph, oph,dd, ImageFormat.Jpeg);
|
|
|
Session["IsPdf"] ="0";
|
|
|
return list;
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
ErrorFollow.TraceWrite("GetListPDFImg", "",ex.Message);
|
|
|
Session["IsPdf"] = "0";
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
/// <summary>
|
|
|
/// 根据传入参数直接转换
|
|
|
/// </summary>
|
|
|
/// <param name="inFilePath">入参示例:E:\\download\\1111.pdf</param>
|
|
|
/// <param name="outFilePath">入参示例:E:\\download</param>
|
|
|
/// <param name="format">入参示例:Jpeg (转换后文件格式,如:Jpeg,Png等)</param>
|
|
|
public static List<E_BookPages> PDFConvertTo(string inFilePath, string outFilePath,string dd, ImageFormat format)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
List<E_BookPages> plist = new List<E_BookPages>();
|
|
|
|
|
|
string fname = DateTime.Now.ToString("yyyyMMdd-HHmmss");
|
|
|
outFilePath = $"{outFilePath}\\{fname}";
|
|
|
using (var document = PdfDocument.Load(inFilePath))
|
|
|
{
|
|
|
var pageCount = document.PageCount;
|
|
|
for (int i = 0; i < pageCount; i++)
|
|
|
{
|
|
|
string s = (i + 1).ToString(); ;
|
|
|
string outFile = $"{outFilePath}({s}).{"jpg"}";
|
|
|
var dpi = 300;
|
|
|
using (var image = document.Render(i, dpi, dpi, PdfRenderFlags.CorrectFromDpi))
|
|
|
{
|
|
|
var encoder = ImageCodecInfo.GetImageEncoders()
|
|
|
.First(c => c.FormatID == format.Guid);
|
|
|
var encParams = new EncoderParameters(1);
|
|
|
encParams.Param[0] = new EncoderParameter(
|
|
|
System.Drawing.Imaging.Encoder.Quality, 10L);
|
|
|
|
|
|
image.Save(outFile, encoder, encParams);
|
|
|
E_BookPages emd = new E_BookPages();
|
|
|
emd.pageimg = "../attached/ebook/" + dd + "/" + fname + "(" + s + ").jpg";
|
|
|
plist.Add(emd);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return plist;
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#region JC_BaseCodeDetail页
|
|
|
#region 保存
|
|
|
[WebMethod(EnableSession = true)]
|
|
|
public int Save_BaseCodeDetail(JC_BaseCodeDetailNew Model)
|
|
|
{
|
|
|
PagesNew.Login(this.Session);
|
|
|
return DataNew.Save_BaseCodeDetail(Model);
|
|
|
}
|
|
|
#endregion
|
|
|
#region 删除
|
|
|
[WebMethod(EnableSession = true)]
|
|
|
public bool Delete_BaseCodeDetail(int Code)
|
|
|
{
|
|
|
PagesNew.Login(this.Session);
|
|
|
DataNew.Delete_BaseCodeDetail(Code);
|
|
|
return true;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 是否重复判断
|
|
|
[WebMethod(EnableSession = true)]
|
|
|
public bool CheckName_BaseCodeDetail(int Code, string Name)
|
|
|
{
|
|
|
PagesNew.Login(this.Session);
|
|
|
return DataNew.CheckName_BaseCodeDetail(Code, Name);
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 普通查询列表
|
|
|
[WebMethod(EnableSession = true)]
|
|
|
public List<JC_BaseCodeDetailNew> GetListBaseCodeDetail3(string keyname)
|
|
|
{
|
|
|
PagesNew.Login(this.Session);
|
|
|
var ListModel = DataNew.GetListBaseCodeDetail(keyname);
|
|
|
return ListModel;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
#region 分页查询
|
|
|
[WebMethod(EnableSession = true)]
|
|
|
public JsonModel<List<JC_BaseCodeDetailNew>> GetListBaseCodeDetail(string cs, int PageIndex, int PageSize)
|
|
|
{
|
|
|
PagesNew.Login(this.Session);
|
|
|
string where = CustomIO.Base64StringToString(cs);
|
|
|
if (where != "") where = "where " + where.Substring(4);
|
|
|
var resultModel = new JsonModel<List<JC_BaseCodeDetailNew>>();
|
|
|
int RowCount = 0;
|
|
|
resultModel.DataSource = DataNew.GetListBaseCodeDetail(where, PageIndex, PageSize, "", out RowCount);
|
|
|
resultModel.RowCount = RowCount;
|
|
|
return resultModel;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
#region 多角色权限
|
|
|
[WebMethod(EnableSession = true)]
|
|
|
public List<E_BookPopedom> GetListBookPopedom2(int bookid)
|
|
|
{
|
|
|
PagesNew.Login(this.Session);
|
|
|
RefParameterCollection where = new RefParameterCollection();
|
|
|
var ListModel = EBookData.GetListJC_RoleInfo();
|
|
|
var list = EBookData.GetListBookPopedom(bookid);
|
|
|
List<E_BookPopedom> slist = new List<E_BookPopedom>();
|
|
|
if (ListModel != null)
|
|
|
{
|
|
|
|
|
|
foreach(var md in ListModel)
|
|
|
{
|
|
|
E_BookPopedom smd = new E_BookPopedom();
|
|
|
smd.roleid = md.RoleID;
|
|
|
smd.rolename = md.RoleName;
|
|
|
if (list != null)
|
|
|
{
|
|
|
var sssmd = list.Find(n => n.roleid == md.RoleID);
|
|
|
if (sssmd != null)
|
|
|
{
|
|
|
smd.ischeck = 1;
|
|
|
}
|
|
|
else
|
|
|
smd.ischeck = 0;
|
|
|
}
|
|
|
slist.Add(smd);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
return slist;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 保存
|
|
|
[WebMethod(EnableSession = true)]
|
|
|
public int Save_BookPopedom(List<E_BookPopedom> list)
|
|
|
{
|
|
|
PagesNew.Login(this.Session);
|
|
|
foreach (var md in list)
|
|
|
{
|
|
|
EBookData.Save_BookPopedom(md);
|
|
|
}
|
|
|
return 1;
|
|
|
}
|
|
|
#endregion
|
|
|
#region 保存外链
|
|
|
[WebMethod(EnableSession = true)]
|
|
|
public string Save_BookWebLink(List<E_BookList> list)
|
|
|
{
|
|
|
PagesNew.Login(this.Session);
|
|
|
string code= Guid.NewGuid().ToString();
|
|
|
foreach (var md in list)
|
|
|
{
|
|
|
E_BookPopedom smd = new E_BookPopedom();
|
|
|
smd.bookid = md.id;
|
|
|
smd.roleid = 0;
|
|
|
smd.popedom = 1;
|
|
|
smd.Code = code;
|
|
|
EBookData.Save_BookPopedom(smd);
|
|
|
}
|
|
|
return code;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 工厂
|
|
|
[WebMethod(EnableSession = true)]
|
|
|
public List<E_BookList> GetListGC()
|
|
|
{
|
|
|
PagesNew.Login(this.Session);
|
|
|
var ListModel = EBookData.GetListGC();
|
|
|
return ListModel;
|
|
|
}
|
|
|
#endregion
|
|
|
#region 产地
|
|
|
[WebMethod(EnableSession = true)]
|
|
|
public List<E_BookList> GetListCD()
|
|
|
{
|
|
|
PagesNew.Login(this.Session);
|
|
|
var ListModel = EBookData.GetListCD();
|
|
|
return ListModel;
|
|
|
}
|
|
|
#endregion
|
|
|
#region 分类
|
|
|
[WebMethod(EnableSession = true)]
|
|
|
public List<E_BookList> GetListFL()
|
|
|
{
|
|
|
PagesNew.Login(this.Session);
|
|
|
var ListModel = EBookData.GetListFL();
|
|
|
return ListModel;
|
|
|
}
|
|
|
#endregion
|
|
|
#region 工厂性质
|
|
|
[WebMethod(EnableSession = true)]
|
|
|
public List<E_BookList> GetListGCXZ()
|
|
|
{
|
|
|
PagesNew.Login(this.Session);
|
|
|
var ListModel = EBookData.GetListGCXZ();
|
|
|
return ListModel;
|
|
|
}
|
|
|
#endregion
|
|
|
}
|
|
|
}
|