Example #1
0
        /// <summary>
        /// 生成二维码并展示到页面上
        /// </summary>
        /// <param name="precreateResult">二维码串</param>
        private void DoWaitProcess(AlipayF2FPrecreateResult precreateResult)
        {
            //打印出 preResponse.QrCode 对应的条码
            Bitmap        bt;
            string        enCodeString  = precreateResult.response.QrCode;
            QRCodeEncoder qrCodeEncoder = new QRCodeEncoder();

            qrCodeEncoder.QRCodeEncodeMode   = QRCodeEncoder.ENCODE_MODE.BYTE;
            qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.H;
            qrCodeEncoder.QRCodeScale        = 3;
            qrCodeEncoder.QRCodeVersion      = 8;
            bt = qrCodeEncoder.Encode(enCodeString, Encoding.UTF8);

            string filename = System.DateTime.Now.ToString("yyyyMMddHHmmss") + "0000" + (new Random()).Next(1, 10000).ToString() + ".jpg";
            string vPath    = string.Format("/Images/QrCode/AliPay/{0}/{1}", DateTime.Now.ToString("yyyy-MM-dd"), filename);
            string pPath    = WebFunctions.MapServerResourcePath(vPath);

            WebFunctions.CreateDirectory(pPath);

            bt.Save(pPath);

            var relativelyPath = WebFunctions.ResourceMapRoot + vPath;

            qrCodeUrl = WebFunctions.ToAbsoluteResourceUrl(relativelyPath.TrimStart('~'));

            //轮询订单结果
            //根据业务需要,选择是否新起线程进行轮询
            //ParameterizedThreadStart ParStart = new ParameterizedThreadStart(LoopQuery);
            //Thread myThread = new Thread(ParStart);
            //object o = precreateResult.response.OutTradeNo;
            //myThread.Start(o);
        }
Example #2
0
 public ModelCourseData(OnlineCourseData item)
 {
     name    = item.name;
     linkUrl = item.dataLink;
     imgUrl  = WebFunctions.ToAbsoluteResourceUrl(item.img);
     sort    = item.sort;
 }
Example #3
0
        /// <summary>
        /// 生成二维码并展示到页面上
        /// </summary>
        private void DoWaitProcess(WxPayData result)
        {
            string url = result.GetValue("code_url").ToString(); //获得统一下单接口返回的二维码链接
                                                                 //初始化二维码生成工具
            QRCodeEncoder qrCodeEncoder = new QRCodeEncoder();

            qrCodeEncoder.QRCodeEncodeMode   = QRCodeEncoder.ENCODE_MODE.BYTE;
            qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M;
            qrCodeEncoder.QRCodeVersion      = 0;
            qrCodeEncoder.QRCodeScale        = 4;

            //将字符串生成二维码图片
            Bitmap bt = qrCodeEncoder.Encode(url, Encoding.Default);

            string filename = System.DateTime.Now.ToString("yyyyMMddHHmmss") + "0000" + (new Random()).Next(1, 10000).ToString() + ".jpg";
            string vPath    = string.Format("/Images/QrCode/WxPay/{0}/{1}", DateTime.Now.ToString("yyyy-MM-dd"), filename);
            string pPath    = WebFunctions.MapServerResourcePath(vPath);

            WebFunctions.CreateDirectory(pPath);

            bt.Save(pPath);

            var relativelyPath = WebFunctions.ResourceMapRoot + vPath;

            qrCodeUrl = WebFunctions.ToAbsoluteResourceUrl(relativelyPath.TrimStart('~'));

            //轮询订单结果
            //根据业务需要,选择是否新起线程进行轮询
        }
Example #4
0
 public ModelQualificationsImage(PlaceholderImage item)
 {
     ImgUrl        = WebFunctions.ToAbsoluteResourceUrl(item.imgUrl);
     Name          = item.text1;
     Qualification = item.text2;
     Sort          = item.sort;
     LinkUrl       = item.linkUrl;
 }
Example #5
0
 public ModelCourse(OnlineCourse item)
 {
     id          = item.id;
     title       = item.name;
     simpleIntro = item.simpleIntro;
     price       = item.price.HasValue ? item.price.Value : 0;
     teacher     = item.lecturer;
     imgUrl      = WebFunctions.ToAbsoluteResourceUrl(item.img);
 }
Example #6
0
 public ModelCompanyInfo(CompanyInfo item)
 {
     Tel     = item.Tel;
     Email   = item.Email;
     Address = item.Address;
     Blog    = item.Blog;
     Chat    = item.Chat;
     QR1     = WebFunctions.ToAbsoluteResourceUrl(item.QR1);
     QR2     = WebFunctions.ToAbsoluteResourceUrl(item.QR2);
 }
Example #7
0
 public ModelTeacher(Teacher item)
 {
     id          = item.id;
     photo       = WebFunctions.ToAbsoluteResourceUrl(item.photo);
     name        = item.name;
     description = item.description;
     lever       = item.lever;
     type        = item.type;
     name_en     = item.name_en;
     sort        = item.sort;
 }
Example #8
0
 public ModelPlaceholderImage(PlaceholderImage item)
 {
     id        = item.id;
     model     = item.model;
     imgUrl    = WebFunctions.ToAbsoluteResourceUrl(item.imgUrl);
     linkUrl   = item.linkUrl;
     width     = item.width;
     height    = item.height;
     sort      = item.sort;
     linkUrlMB = item.linkUrlMB;
 }
Example #9
0
        public HttpResponseMessage UploadPortrait()
        {
            if (HttpContext.Current.Request.Files.Count == 0)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, string.Format("请上传文件。")));
            }

            try
            {
                HttpPostedFile file = HttpContext.Current.Request.Files[0];

                string vPath = string.Format(WebFunctions.ResourceMapRoot + "/Images/Customer/{0}/{1}", AuthCustomer.CustomerId, file.FileName);
                string pPath = HttpContext.Current.Server.MapPath(vPath);

                var directory = Path.GetDirectoryName(pPath);
                if (!Directory.Exists(directory))
                {
                    Directory.CreateDirectory(directory);
                }

                file.SaveAs(pPath);

                var cus = DB.Customer.Where(x => x.CUSTOMER_ID == AuthCustomer.CustomerId).FirstOrDefault();
                cus.HEAD_PORTEAIT = vPath.TrimStart('~');
                DB.SaveChanges();

                var result = new
                {
                    message   = "头像修改成功。",
                    AvatarUrl = WebFunctions.ToAbsoluteResourceUrl(cus.HEAD_PORTEAIT),
                };

                return(Request.CreateResponse(HttpStatusCode.OK, result));
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
            }
        }
Example #10
0
 protected string ToAbsoluteResourceUrl(string url)
 {
     return(WebFunctions.ToAbsoluteResourceUrl(url));
 }