public ActionResult CodeGenerate(string code)
        {
            string         accessToken = Common.WeChatPush.WeChatTools.GetAccessoken();
            U_WeChatUserID userInfo    = new U_WeChatUserID();
            string         userInfoStr = Common.WeChatPush.WeChatTools.GetUserInfoByCode(accessToken, code);

            userInfo = Common.JsonHelper.JsonToModel <U_WeChatUserID>(userInfoStr); //用户ID
            //userInfo.UserId = "WangCunBiao";
            var    personInfoModel = _wl.GetUserInfo(userInfo.UserId);              //获取人员表信息
            string file            = personInfoModel.Vguid + ".jpg";
            string forder          = "UploadFile/WeChatQRCode";
            string filePath        = Path.Combine(forder, file);

            string fileName = Server.MapPath(filePath);

            if (System.IO.File.Exists(fileName))
            {
                System.IO.File.Delete(fileName);
            }
            var configStr = _codeGenerateLogic.GetPersonConfiguration(personInfoModel);

            QRCodeHelper.GenerateQRCode(configStr, "/Areas/WeChatPush/Views/_img/logo1.png", forder, file);
            ViewData["Vguid"] = personInfoModel.Vguid;
            ViewData["url"]   = ConfigSugar.GetAppString("OpenHttpAddress") + forder + "/" + file;
            return(View());
        }
コード例 #2
0
ファイル: LessonController.cs プロジェクト: sqddchen/zuqiu
        public ActionResult Detail(int id = 0)
        {
            ViewBag.Title = "课程详情";

            var vip = GetVipInfo();

            if (vip.FeeStatus != 1)
            {
                return(Content($"<script>alert('没有支付无法观看课程');window.location.href='{Url.Action("Categories")}'</script>"));
            }

            var video = dal.Get <Video>(id);

            if (video == null)
            {
                return(RedirectToAction("Categories"));
            }

            var vipId     = 1;
            var qrImg     = $"~/upload/qrcode/qr{vipId.ToString()}.png";
            var qrImgPath = Server.MapPath(qrImg);

            if (!System.IO.File.Exists(qrImgPath))
            {
                QRCodeHelper.GenerateQRCode($"userid={vipId.ToString()}", qrImgPath);
            }
            ViewBag.QrCodePath = qrImg;

            ViewBag.VideoComments = dal.GetAll <VideoComment>().Where(p => p.VideoId == id).OrderByDescending(p => p.CreatedTime).ToList();

            return(View(video));
        }
コード例 #3
0
        public ActionResult Mesas(int id)
        {
            var QRHelper  = new QRCodeHelper();
            var codeImage = QRHelper.GenerateQRCode(id.ToString(), 120);

            codeImage.Save(Server.MapPath("~/Uploads/mesa" + id + ".png"), ImageFormat.Png);
            return(RedirectToAction("Mesas"));
        }
コード例 #4
0
        public GeneratePromoCodeResponse GeneratePromoCode(GeneratePromoCodeRequest _request)
        {
            GeneratePromoCodeResponse response = new GeneratePromoCodeResponse();
            var order = (from o in db_Evoucher.TblPurchaseOrders
                         where o.PurchaseOrderNo == _request.PurchaseOrder_No &&
                         o.VoucherGenerated == false
                         select o
                         ).FirstOrDefault();

            if (order != null)
            {
                for (int i = 0; i < order.Quantity; i++)
                {
                    bool   isUnique  = false;
                    string promoCode = StringHelper.GeneatePromo();
                    string qrCodePath;
                    do
                    {
                        isUnique = !(from gp in db_Evoucher.TblGeneratedEvouchers
                                     where gp.PromoCode == promoCode
                                     select true
                                     ).FirstOrDefault();
                    } while (!isUnique);

                    qrCodePath = QRCodeHelper.GenerateQRCode(promoCode);

                    if (qrCodePath != "")
                    {
                        TblGeneratedEvoucher generatedEvoucher = new TblGeneratedEvoucher
                        {
                            ExpiryDate       = order.ExpiryDate,
                            OwnerName        = order.BuyerName,
                            OwnerPhone       = order.BuyerPhone,
                            PromoCode        = promoCode,
                            PurchaseOrderNo  = order.PurchaseOrderNo,
                            QrImagePath      = qrCodePath,
                            Status           = (int)RecordStatus.Active,
                            VoncherAmount    = order.VoncherAmount,
                            VoucherImagePath = order.ImagePath,
                            VoucherNo        = order.VoucherNo
                        };

                        db_Evoucher.TblGeneratedEvouchers.Add(generatedEvoucher);
                    }
                }
                order.VoucherGenerated = true;
            }
            else
            {
                response.StatusCode   = 404;
                response.ErrorType    = "Not-Found";
                response.ErrorMessage = "Record Not Found";
            }
            db_Evoucher.SaveChanges();
            response.PromoCodeGenerated = true;

            return(response);
        }
コード例 #5
0
        /// <summary>
        /// 显示二维码
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {
            var qrCode = new QRCodeHelper();
            var qrImg  = qrCode.GenerateQRCode("https://www.cnblogs.com/wenha");

            var base64 = "data:image/jpeg;base64," + Convert.ToBase64String(qrImg);

            ViewBag.CodeImg = base64;
            return(View());
        }
コード例 #6
0
        public ActionResult GenerateQRCode(int mesa_id)
        {
            //Save QR code
            var QRHelper  = new QRCodeHelper();
            var codeImage = QRHelper.GenerateQRCode(mesa_id.ToString(), 120);

            codeImage.Save(Server.MapPath("~/Uploads/" + mesa_id + ".png"), ImageFormat.Png);

            return(RedirectToAction("Index"));
        }
コード例 #7
0
        public HttpResponseMessage GetQRCode()
        {
            var qrCode = new QRCodeHelper();

            var url   = "https://www.cnblogs.com/wenha";
            var image = qrCode.GenerateQRCode(url, "博客园地址");

            var resp = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent("data:image/jpeg;base64," + Convert.ToBase64String(image))
            };

            return(resp);
        }
コード例 #8
0
        public ActionResult Guardar(int id = 0)
        {
            if (ModelState.IsValid)
            {
                Racion objracion = new Racion().Obtener(id);

                //Save QR code
                var QRHelper  = new QRCodeHelper();
                var contenido = objracion.desayuno + ", " + objracion.refrigerio + ", " + objracion.almuerzo + ", " + objracion.postre;
                var codeImage = QRHelper.GenerateQRCode(contenido.ToString(), 250);
                codeImage.Save(Server.MapPath("~/Uploads/" + objracion.Ninio.nombre + ".png"), ImageFormat.Png);
            }
            return(Redirect("~/Ninio"));
        }
コード例 #9
0
        public HttpResponseMessage GetQRCodeImg()
        {
            var qrCode = new QRCodeHelper();

            var url   = "https://www.cnblogs.com/wenha";
            var image = qrCode.GenerateQRCode(url, "博客园地址");

            var resp = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new ByteArrayContent(image)
            };

            resp.Content.Headers.ContentType = new MediaTypeHeaderValue("image/jpg");
            return(resp);
        }
コード例 #10
0
        public ActionResult Create([Bind(Include = "mesa_id,restaurante_id_fk,estado")] mesa mesa)
        {
            if (ModelState.IsValid)
            {
                //Add to DataBase
                _db.mesa.Add(mesa);
                _db.SaveChanges();

                //Save QR code
                var QRHelper  = new QRCodeHelper();
                var id        = mesa.mesa_id;
                var codeImage = QRHelper.GenerateQRCode(id.ToString(), 120);
                codeImage.Save(Server.MapPath("~/Uploads/" + id + ".png"), ImageFormat.Png);

                return(RedirectToAction("Index"));
            }

            ViewBag.restaurante_id_fk = new SelectList(_db.restaurante, "restaurante_id", "nombre", mesa.restaurante_id_fk);
            return(View(mesa));
        }
        public string getWeChatQRCode(Business_CleaningCompany cleaning)
        {
            string file     = cleaning.CompanyName + ".jpg";
            string forder   = "UploadFile/WeChatQRCode";
            string filePath = Path.Combine(forder, file);
            string fileName = Server.MapPath(filePath);

            if (System.IO.File.Exists(fileName))
            {
                System.IO.File.Delete(fileName);
            }
            string guid  = cleaning.Vguid.ToString();
            string url   = ConfigSugar.GetAppString("CleaningAddress");
            string appid = ConfigSugar.GetAppString("CorpID");

            url = url + "?VGUID=" + guid;
            var configStr = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + appid + "&redirect_uri=" + url + "&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect";

            QRCodeHelper.GenerateQRCode(configStr, "/Areas/WeChatPush/Views/_img/logo1.png", forder, file);
            return(filePath);
        }
コード例 #12
0
        public string GeneralMeetingImage(dm_basesettingEntity dm_BasesettingEntity, string Join_Url)
        {
            try
            {
                string basePath = System.AppDomain.CurrentDomain.BaseDirectory.TrimEnd("\\".ToCharArray());
                string path1    = basePath + @"/Resource/ShareImage/MeetingDefault.jpg";
                string path2    = basePath + @"/Resource/ShareImage/MeetingDefault2.jpg";
                string path3    = basePath + @"/Resource/ShareImage/MeetingDefault3.jpg";

                //生成推广二维码
                Bitmap qrCode = QRCodeHelper.GenerateQRCode(Join_Url, 300, 300);

                List <string> imageList = new List <string>();
                imageList.Add(GeneralShareImage(dm_BasesettingEntity, path1, qrCode));
                imageList.Add(GeneralShareImage(dm_BasesettingEntity, path2, qrCode, 260, 1050));
                imageList.Add(GeneralShareImage(dm_BasesettingEntity, path3, qrCode, 260, 600));

                string images = "[";
                foreach (var item in imageList)
                {
                    if (images != "[")
                    {
                        images += ",";
                    }
                    images += "\"" + item + "\"";
                }
                images += "]";

                return(images);

                //return JsonConvert.JsonSerializerIO(imageList.ToArray());
            }
            catch (Exception ex)
            {
                return("");
            }
        }
コード例 #13
0
        public async Task <APIResultDto> DownloadQRCodeZip(GetDocumentsInput input)
        {
            var query = _entityRepository.GetAll()
                        .WhereIf(!string.IsNullOrEmpty(input.CategoryCode), e => ("," + e.CategoryCode + ",").Contains(input.CategoryCode))
                        .WhereIf(!string.IsNullOrEmpty(input.KeyWord), e => e.Name.Contains(input.KeyWord) || e.Summary.Contains(input.KeyWord));
            var docs = await query.Select(q => new { q.Id, q.Name, q.CategoryDesc }).ToListAsync();

            string webRootPath = _hostingEnvironment.WebRootPath;
            string filePath    = webRootPath + "/docqrcodes";

            if (Directory.Exists(filePath))
            {
                Directory.Delete(filePath, true);
                Directory.CreateDirectory(filePath);
            }
            else
            {
                Directory.CreateDirectory(filePath);
            }
            foreach (var item in docs)
            {
                QRCodeHelper.GenerateQRCode(item.Id.ToString(), string.Format("{0}/{1}-{2}.jpg", filePath, item.CategoryDesc.Replace(',', '-'), item.Name), QRCoder.QRCodeGenerator.ECCLevel.Q, 20);
            }
            var zipFiles = "/downloads/资料二维码.zip";
            var zipPath  = webRootPath + "/downloads";

            if (!Directory.Exists(zipPath))
            {
                Directory.CreateDirectory(zipPath);
            }
            ZipHelper.ZipFileDirectory(filePath, string.Format("{0}{1}", webRootPath, zipFiles));
            return(new APIResultDto()
            {
                Code = 0, Msg = "生成二维码成功", Data = zipFiles
            });
        }
コード例 #14
0
        private async void BtnRegister_Click(object sender, EventArgs e)
        {
            btnRegister.Enabled = false;

            if (this.ValidateChildren())
            {
                var osobaRequest = new Wellness.Model.Requests.OsobaInsertRequest();

                osobaRequest.Ime           = txtIme.Text;
                osobaRequest.Prezime       = txtPrezime.Text;
                osobaRequest.DatumRodenja  = dtpDatumRodenja.Value;
                osobaRequest.Spol          = (cbSpol.SelectedValue.ToString().Substring(0, 1).ToUpper());
                osobaRequest.GradId        = (int)cbMjestoBoravka.SelectedValue;
                osobaRequest.Jmbg          = txtJMBG.Text;
                osobaRequest.Email         = txtEmail.Text;
                osobaRequest.BrojTelefona  = txtBrojTelefona.Text;
                osobaRequest.KorisnickoIme = txtUserName.Text;
                osobaRequest.UlogaId       = (int)cbUloga.SelectedValue;

                Wellness.Model.Osoba  osoba  = null;
                Wellness.Model.Radnik radnik = null;



                if (_id == null)
                {
                    osobaRequest.Password        = txtPassword.Text;
                    osobaRequest.PasswordPotvrda = txtPasswordPotvrda.Text;



                    osoba = await _apiService.Insert <Wellness.Model.Osoba>(osobaRequest);

                    if (osoba.Uloga.Naziv != "Clan")
                    {
                        var radnikRequest = new Wellness.Model.Requests.RadnikInsertRequest()
                        {
                            Satnica = decimal.Parse(txtSatnica.Text),
                            OsobaId = osoba.Id
                        };

                        radnik = await _apiService_Radnik.Insert <Wellness.Model.Radnik>(radnikRequest);


                        if (osoba.Uloga.Naziv == "Trener")
                        {
                            var trenerRequest = new TrenerInsertRequest()
                            {
                                Specializacija = txtSpecijalizacija.Text,
                                RadnikId       = radnik.Id
                            };

                            var trener = await _apiService_Trener.Insert <Model.Trener>(trenerRequest);
                        }
                    }
                    else
                    {
                        var clanInsertRequest = new ClanInsertRequest()
                        {
                            Aktivan           = true,
                            DatumRegistracije = DateTime.Now,
                            OsobaId           = osoba.Id,
                        };

                        //-----------------------------------------------------------------QR Kod

                        var randomStringPostoji = true;
                        while (randomStringPostoji == true)
                        {
                            var randomString      = _qrCodeHelper.GenerateRandomString(15);
                            var clanSearchRequest = new ClanSearchRequest()
                            {
                                QrCodeText = randomString
                            };
                            var clanList = await _apiService_Clan.Get <List <Model.Requests.ClanViewRequest> >(clanSearchRequest);

                            if (clanList.Count == 0)
                            {
                                randomStringPostoji = false;
                            }

                            clanInsertRequest.QrCodeText = randomString;
                            clanInsertRequest.Qrcode     = _qrCodeHelper.GenerateQRCode(randomString);
                        }
                        //-----------------------------------------------------------------QR Kod

                        var clan = await _apiService_Clan.Insert <Wellness.Model.Clan>(clanInsertRequest);
                    }

                    MessageBox.Show("Uspjesno ste dodali novog korisnika", "success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                else
                {
                    osoba = await _apiService.Update <Wellness.Model.Osoba>(_id, osobaRequest);

                    if (osoba.Uloga.Naziv != "Clan")
                    {
                        var radnikRequest = new Wellness.Model.Requests.RadnikInsertRequest()
                        {
                            Satnica = decimal.Parse(txtSatnica.Text),
                            OsobaId = osoba.Id
                        };

                        var radnikSearchRequest = new RadnikSearchRequest()
                        {
                            OsobaId = radnikRequest.OsobaId
                        };

                        var radnikList = await _apiService_Radnik.Get <List <Wellness.Model.Radnik> >(radnikSearchRequest);

                        radnik = await _apiService_Radnik.Update <Wellness.Model.Radnik>(radnikList[0].Id, radnikRequest);


                        if (osoba.Uloga.Naziv == "Trener")
                        {
                            var trenerRequest = new TrenerInsertRequest()
                            {
                                RadnikId       = radnik.Id,
                                Specializacija = txtSpecijalizacija.Text
                            };

                            var trenerList = await _apiService_Trener.Get <List <Model.Trener> >(new TrenerSearchRequest()
                            {
                                OsobaId = osoba.Id
                            });

                            var trener = _apiService_Trener.Update <Model.Trener>(trenerList[0].Id, trenerRequest);
                        }
                    }


                    MessageBox.Show("Uspjesno ste ažurirali korisnika", "success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
            }

            btnRegister.Enabled = true;
        }