Exemple #1
0
        public commonresponse downloadpic(picType picType)
        {
            var accinfo = highlevel.GetInfoByToken(Request.Headers);

            if (accinfo.status != responseStatus.ok)
            {
                return(accinfo);
            }

            try
            {
                var fname = Path.Combine(_picpath, accinfo.photofile, accinfo.businessType.ToString(), picType + ".jpg");
                //  highlevel.infolog(_log, "downloadpic", fname);
                var bbytes = CryptographyHelpers.StudyFileDecryptStr(fname);
                var retstr = "data:image/jpeg;base64," + bbytes;
                try
                {
                    var he = Request.Host.ToString();
                    foreach (var a in Request.Headers)
                    {
                        he += "--" + a.Key + "=" + a.Value;
                    }
                    Task.Run(() => highlevel.LogRequest(he + accinfo.photofile + picType + accinfo.Identity,
                                                        "downloadpic", Request.HttpContext.Connection.RemoteIpAddress.ToString(), (short)accinfo.businessType));
                }
                catch (Exception ex) { _log.LogError("dblog error:", ex); }
                return(new downloadresponse {
                    status = responseStatus.ok, picture = retstr
                });
            }
            catch (Exception ex)
            {
                _log.LogError("{0}-{1}-{2}", DateTime.Now, "downloadpic", ex.Message);
                return(new commonresponse {
                    status = responseStatus.processerror, content = ex.Message
                });
            }
        }