WebAPI/Controllers/CJGL/Cj_StationOutBillController.cs
@@ -7,6 +7,8 @@
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Web;
using System.Web.Http;
@@ -1648,6 +1650,9 @@
                {
                    File.Delete(fileurl);      //删除指定文件
                    files.SaveAs(fileurl);
                    string StrPath = "/files/"+ HBillNo+"/"+ filename;
                    if (File.Exists(fileurl)) 
                    {
@@ -1671,6 +1676,10 @@
                {
                    Directory.CreateDirectory(fileSavePath); //添加文件夹
                    files.SaveAs(fileurl);
                    string StrPath = "/files/" + HBillNo + "/" + filename;
                    if (File.Exists(fileurl))
                    {
@@ -1699,7 +1708,7 @@
            return Result_Ob;
        }
@@ -1768,6 +1777,9 @@
                {
                    File.Delete(fileurl);      //删除指定文件
                    files.SaveAs(fileurl);
                    fileurl = ImgCompress(50L, fileurl, fileSavePath, files);
                    string StrPath = "/files/" + HBillNo + "/" + filename;
                    if (File.Exists(fileurl))
                    {
@@ -1791,6 +1803,9 @@
                {
                    Directory.CreateDirectory(fileSavePath); //添加文件夹
                    files.SaveAs(fileurl);
                    fileurl = ImgCompress(50L, fileurl, fileSavePath, files);
                    string StrPath = "/files/" + HBillNo + "/" + filename;
                    if (File.Exists(fileurl))
                    {
@@ -1819,6 +1834,38 @@
            return Result_Ob;
        }
        //压缩方法
        private string ImgCompress(long level, string fileurl, string fileSavePath, HttpPostedFile files)
        {
            Image img = Image.FromFile(fileurl);
            ImageFormat imgFormat = img.RawFormat;
            EncoderParameters encoderParams = new EncoderParameters();
            encoderParams.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, level);
            ImageCodecInfo codecInfo = GetEncoder(imgFormat);
            var filed = files.FileName.Split('.');
            string filenames = filed[0].ToString() + "_1." + filed[1].ToString();
            fileurl = Path.Combine(fileSavePath, filenames);
            string savePath = fileurl;
            img.Save(savePath, codecInfo, encoderParams);
            img.Dispose();
            return fileurl;
        }
        private ImageCodecInfo GetEncoder(ImageFormat format)
        {
            ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders();
            foreach (ImageCodecInfo codec in codecs)
            {
                if (codec.FormatID == format.Guid)
                {
                    return codec;
                }
            }
            return null;
        }
        /// <summary>
        /// 输出json结果 返回2个值 result (输出succes的值)   returnval (输出str的值)
        /// </summary>