Пример #1
0
        //
        // GET: /Image/

        public ActionResult GetSignPic(string userId, bool isAutoDefault = true)
        {
            ImageActionResult result  = null;
            IUserService      service = FormulaHelper.GetService <IUserService>();

            byte[] signImg = service.GetSignImg(userId);
            if (signImg != null)
            {
                Image image = ImageHelper.BytesToImage(signImg);
                if (image != null)
                {
                    ImageFormat imageFormat = ImageHelper.GetImageFormat(image);
                    result = new ImageActionResult(image, imageFormat);
                }
            }
            else if (isAutoDefault && !string.IsNullOrEmpty(userId))
            {
                UserInfo user = service.GetUserInfoByID(userId);
                if (user != null)
                {
                    Bitmap bitMap = ImageHelper.GetImageFromStr(user.UserName);
                    if (bitMap != null)
                    {
                        result = new ImageActionResult(bitMap);
                    }
                }
            }

            if (result == null)
            {
                string noneImageName = Server.MapPath(@"/CommonWebResource/RelateResource/image/signname.jpg");
                result = new ImageActionResult(noneImageName, ImageFormat.Jpeg);
            }
            return(result);
        }
Пример #2
0
        public ActionResult GetPic(string id)
        {
            ImageActionResult result = null;
            Image             image  = null;
            var entity = this.GetEntityByID(id);

            if (entity != null)
            {
                byte[] img = entity.SealInfo;
                if (img != null)
                {
                    image = ImageHelper.BytesToImage(img);
                }
            }
            else
            {
                var path = Server.MapPath("/Project/Scripts/Images/PlotSeal.png");
                if (System.IO.File.Exists(path))
                {
                    image = Image.FromFile(path);
                }
            }
            if (image != null)
            {
                ImageFormat imageFormat = ImageHelper.GetImageFormat(image);
                result = new ImageActionResult(image, imageFormat);
            }
            return(result);
        }
Пример #3
0
        public ActionResult Get(string id, string type)
        {
            var ip      = System.Configuration.ConfigurationManager.AppSettings["WeChatIP"];
            var key     = System.Configuration.ConfigurationManager.AppSettings["QrCodeKey"];
            var content = type + "|" + id;

            content = DesEncrypt(content, GetLegalKey(key));

            ip      = (ip.StartsWith("http://") || ip.StartsWith("https://")) ? ip : "http://" + ip;
            content = (ip.EndsWith("/") ? ip : ip + "/") + "QrCode/Show?k=" + content;
            content = content.Replace("+", "%2b");
            int strLength = Encoding.GetEncoding("UTF-8").GetByteCount(content);

            ImageActionResult result = null;

            QRCodeEncoder endocder = new QRCodeEncoder();

            //二维码背景颜色
            endocder.QRCodeBackgroundColor = System.Drawing.Color.White;
            //二维码编码方式
            endocder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE;
            //每个小方格的宽度
            endocder.QRCodeScale = 3;
            //二维码版本号
            endocder.QRCodeVersion = 11;

            //纠错等级
            endocder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.H;

            Bitmap bitmap = endocder.Encode(content, System.Text.Encoding.UTF8);

            result = new ImageActionResult(bitmap, ImageFormat.Bmp);
            return(result);
        }
Пример #4
0
        public ActionResult GetPic(string id, string imageType)
        {
            ImageActionResult result  = null;
            IUserService      service = FormulaHelper.GetService <IUserService>();

            T_Employee entity = entities.Set <T_Employee>().Find(id);

            byte[] img = null;
            if (entity != null)
            {
                switch (imageType)
                {
                case "Portrait":
                    img = entity.Portrait;
                    break;

                case "IdentityCardFace":
                    img = entity.IdentityCardFace;
                    break;

                case "IdentityCardBack":
                    img = entity.IdentityCardBack;
                    break;

                case "Sign":
                    img = entity.SignImage;
                    break;
                }

                if (img != null)
                {
                    Image image = ImageHelper.BytesToImage(img);
                    if (image != null)
                    {
                        ImageFormat imageFormat = ImageHelper.GetImageFormat(image);
                        result = new ImageActionResult(image, imageFormat);
                    }
                }
            }


            if (result == null)
            {
                string noneImageName = GetNoneImageName(imageType);
                result = new ImageActionResult(noneImageName, ImageFormat.Jpeg);
            }
            return(result);
        }
Пример #5
0
        public ActionResult GetSealPic(string id)
        {
            ImageActionResult result = null;
            S_EP_PlotSealInfo entity = this.BusinessEntities.Set <S_EP_PlotSealInfo>().Find(id);

            byte[] img = entity.SealInfo;
            if (img != null)
            {
                Image image = ImageHelper.BytesToImage(img);
                if (image != null)
                {
                    ImageFormat imageFormat = ImageHelper.GetImageFormat(image);
                    result = new ImageActionResult(image, imageFormat);
                }
            }
            return(result);
        }
Пример #6
0
        public ActionResult GetPic(string id)
        {
            ImageActionResult result = null;
            var entity = this.GetEntityByID(id);

            if (entity != null)
            {
                byte[] img = entity.SealInfo;
                if (img != null)
                {
                    Image image = ImageHelper.BytesToImage(img);
                    if (image != null)
                    {
                        ImageFormat imageFormat = ImageHelper.GetImageFormat(image);
                        result = new ImageActionResult(image, imageFormat);
                    }
                }
            }
            return(result);
        }
Пример #7
0
        public ActionResult GetPic(string id, string imageType)
        {
            ImageActionResult result  = null;
            IUserService      service = FormulaHelper.GetService <IUserService>();

            S_HR_Employee entity = ComprehensiveDbContext.Set <S_HR_Employee>().Find(id);

            byte[] img = null;
            if (entity != null)
            {
                switch (imageType)
                {
                case "Portrait":
                    img = entity.Portrait;
                    break;

                case "IdentityCardFace":
                    img = entity.IdentityCardFace;
                    break;

                case "IdentityCardBack":
                    img = entity.IdentityCardBack;
                    break;

                case "Sign":
                    img = entity.SignImage;
                    break;
                }

                if (img != null)
                {
                    Image image = ImageHelper.BytesToImage(img);
                    if (image != null)
                    {
                        ImageFormat imageFormat = ImageHelper.GetImageFormat(image);
                        result = new ImageActionResult(image, imageFormat);
                    }
                }
            }
            return(result);
        }
Пример #8
0
        public ActionResult GetUserPic(string userId)
        {
            ImageActionResult result  = null;
            IUserService      service = FormulaHelper.GetService <IUserService>();

            byte[] signImg = service.GetUserImg(userId);
            if (signImg != null)
            {
                Image image = ImageHelper.BytesToImage(signImg);
                if (image != null)
                {
                    ImageFormat imageFormat = ImageHelper.GetImageFormat(image);
                    result = new ImageActionResult(image, imageFormat);
                }
            }
            if (result == null)
            {
                string noneImageName = Server.MapPath(@"/CommonWebResource/RelateResource/image/photo.jpg");
                result = new ImageActionResult(noneImageName, ImageFormat.Jpeg);
            }
            return(result);
        }
Пример #9
0
        public ActionResult GetImg(string id)
        {
            ImageActionResult result = null;

            T_Car_Base entity = BusinessEntities.Set <T_Car_Base>().Find(id);

            byte[] img = null;
            if (entity != null)
            {
                img = entity.CarPhoto;

                if (img != null)
                {
                    Image image = ImageHelper.BytesToImage(img);
                    if (image != null)
                    {
                        ImageFormat imageFormat = ImageHelper.GetImageFormat(image);
                        result = new ImageActionResult(image, imageFormat);
                    }
                }
            }

            return(result);
        }