/// <summary> /// Create new QR Code object /// </summary> private void AddNewRecord(string qrCodeId) { Device.BeginInvokeOnMainThread(async() => { var r = await UserDialogs.Instance.PromptAsync(AppResources.qrcode_name, inputType: InputType.Name); await Task.Delay(500); if (!r.Ok) { return; } var name = r.Text; if (string.IsNullOrEmpty(name)) { return; } App.ShowToast(AppResources.qrcode_saved + " " + name); var qrCode = new QRCodeModel() { Id = qrCodeId, Name = name, Enabled = true, }; _oListSource.Add(qrCode); SaveAndRefresh(); }); }
// GET: Merchants/Create public ActionResult QRCode(int?merchantId) { Merchant merchant = null; using (MerchantService _merchantService = new MerchantService(User.Identity)) { merchant = _merchantService.Merchant(); } List <QRCodeModel> qRCodelist = new List <QRCodeModel>(); foreach (var s in merchant.Staffs) { QRCodeModel qrCodes = new QRCodeModel(); //MerchantStaff merchantStaff = new MerchantStaff(); //merchantStaff.MerchantGuid = merchant.Guid; //merchantStaff.MerchantName = merchant.Name; //merchantStaff.StaffGuid = s.Guid; //List<MerchantStaff> list = new List<MerchantStaff>(); string merchantStaff = merchant.Guid + ":" + s.Guid + ":" + merchant.Name; List <string> list = new List <string>(); list.Add(merchantStaff); var content = JsonConvert.SerializeObject(list); qrCodes.QRCode = QRCodeService.GenerateQRCode(content); qrCodes.Merchant = merchant.Name; qrCodes.Staff = s.Name; qrCodes.PhoneNumber = s.PhoneNumber; qRCodelist.Add(qrCodes); } //string encrypted = ConfigurationManager.AppSettings["encryptedvalue"]; //string decrypted = CryptoService.Decrypt(encrypted); ViewBag.MerchantId = merchantId; return(View(qRCodelist)); }
/// <summary> /// Connect device to QR Code /// </summary> private async void btnConnect_Clicked(object sender, EventArgs e) { _oSelectedQrCode = (QRCodeModel)((Button)sender).BindingContext; var oSwitchPopup = new SwitchPopup(); oSwitchPopup.DeviceSelectedMethod += DelegateMethod; await PopupNavigation.PushAsync(oSwitchPopup); }
public ActionResult Generate(QRCodeModel qrcode) { try { qrcode.QRCodeImagePath = GenerateQRCode(qrcode.QRCodeText); ViewBag.Message = "QR Code Created successfully"; } catch (Exception ex) { } return(View(qrcode)); }
public ActionResult QR_Login(QRCodeModel model) { if (Request.Files.Count > 0) { var file = Request.Files[0]; if (file != null && file.ContentLength > 0) { var filename = Path.GetFileName(file.FileName); String[] IMAGES_EXTENSION = new[] { ".png", ".jpg", ".jpeg", ".gif" }; if (!IMAGES_EXTENSION.Contains(Path.GetExtension(filename))) { TempData["result_code"] = -1; TempData["message"] = "Extension file not allowed"; TempData.Keep(); return(View(model)); } var formattedFileName = string.Format("{0}-{1}{2}" , Path.GetFileNameWithoutExtension(filename) , Guid.NewGuid().ToString("N") , Path.GetExtension(filename)); var path = Path.Combine(Server.MapPath(QRCodeModel.SAVE_PATH), formattedFileName); file.SaveAs(path); var readCode = ReadQRCode(formattedFileName); var user = db2.User.FirstOrDefault(x => x.code == readCode.QRCodeText); if (user != null) { FormsAuthentication.SetAuthCookie(user.id.ToString(), true); Session.Clear(); User u = new User(); u.id = user.id; u.full_name = user.full_name; u.email = user.code; u.password = user.password; u.status = user.status; u.isSecond = true; u.reduction = user.reduction; Session.Add("me", u); return(RedirectToAction("Index", "Home")); } TempData["result_code"] = -1; TempData["message"] = "Account not found. Please choose correct QR Code"; TempData.Keep(); return(View()); } } TempData["result_code"] = -1; TempData["message"] = "QR code not found, choose a QR code file"; TempData.Keep(); return(View()); }
public ActionResult Generate(QRCodeModel qrcode) { try { qrcode.QRCodeImagePath = GenerateQRCode(qrcode); ViewBag.Message = "QR Code Created successfully"; } catch (Exception ex) { //catch exception if there is any } return(View("QrCode", qrcode)); }
/// <summary> /// GS ( k pL pH cn fn n1 n2 /// </summary> /// <exception cref="ArgumentNullException"><paramref name="content"/> is <see langword="null"/>.</exception> public static byte[] PrintQRCode(string content, QRCodeModel qrCodemodel = QRCodeModel.Model1, QRCodeCorrection qrodeCorrection = QRCodeCorrection.Percent7, QRCodeSize qrCodeSize = QRCodeSize.Normal) { var model = new byte[] { 0x1D, 0x28, 0x6B, 0x04, 0x00, 0x31, 0x41, (byte)qrCodemodel, 0x00 }; var size = new byte[] { 0x1D, 0x28, 0x6B, 0x03, 0x00, 0x31, 0x43, (byte)qrCodeSize }; var errorCorrection = new byte[] { 0x1D, 0x28, 0x6B, 0x03, 0x00, 0x31, 0x45, (byte)qrodeCorrection }; int num = content.Length + 3; int pL = num % 256; int pH = num / 256; var storeData = new byte[] { 0x1D, 0x28, 0x6B, (byte)pL, (byte)pH, 0x31, 0x50, 0x30 }; var data = Encoding.UTF8.GetBytes(content); var print = new byte[] { 0x1D, 0x28, 0x6B, 0x03, 0x00, 0x31, 0x51, 0x30 }; return(model.Add(size, errorCorrection, storeData, data, print)); }
/// <summary> /// 插入UUID /// </summary> /// <param name="connectionId"></param> /// <returns></returns> public bool InsertUUID(string connectionId) { lock (LockObject) { if (QRCodeLists.ContainsKey(connectionId)) { QRCodeLists.Remove(connectionId); } QRCodeModel model = new QRCodeModel { UUID = Guid.NewGuid() }; QRCodeLists.Add(connectionId, model); return(true); } }
private void AddQrCodeData(string qrCode, string codeType) { QRCodeModel qrTemp = bllQrCode.GetModel(qrCode); if (qrTemp != null) { MessageBox.Show("此二维码数据表中已经存在!"); return; } QRCodeModel qrCodeModel = new QRCodeModel(); qrCodeModel.PintStatus = "待申请"; qrCodeModel.QRCode = qrCode; qrCodeModel.QRType = codeType; bllQrCode.Add(qrCodeModel); RefreshQrCode(); }
/// <summary> /// 获取有效的QRCodeModel /// </summary> /// <param name="connectionId"></param> /// <returns></returns> public QRCodeModel GetValidModel(string connectionId) { lock (LockObject) { QRCodeModel model; if (QRCodeLists.ContainsKey(connectionId)) { model = QRCodeLists[connectionId]; if (model.IsValid()) //有效 { return(model); } QRCodeLists.Remove(connectionId); } model = new QRCodeModel(); QRCodeLists.Add(connectionId, model); return(model); } }
private QRCodeModel ReadQRCode(HttpPostedFile Image) { QRCodeModel barcodeModel = new QRCodeModel(); string barcodeText = ""; string imagePath = Image.FileName; //string barcodePath =Server.MapPath(imagePath); var barcodeReader = new BarcodeReader(); var result = barcodeReader.Decode(new Bitmap(Image.InputStream)); if (result != null) { barcodeText = result.Text; } return(new QRCodeModel() { QRCodeText = barcodeText, QRCodeImagePath = imagePath }); }
public ActionResult QRCodeGen(string id, string type) { if (string.IsNullOrEmpty(id)) { QRCodeModel qrcode = new QRCodeModel(); qrcode.FolderPath = "~/Admin/Images/QRCode"; if (type == "Inventory") { qrcode.QRCodeText = "ninc.gov.np/meseum/api/meseumapi/getinventory/" + id; qrcode.FilePath = "~/Admin/Images/QRCode/Inventory" + id + ".jpg"; } qrcode.QRCodeImagePath = GenerateQRCode(qrcode); return(View("QrCode", qrcode)); } else { return(RedirectToAction("Dashboard", "Home")); } }
private QRCodeModel ReadQRCode() { QRCodeModel barcodeModel = new QRCodeModel(); string barcodeText = ""; string imagePath = "~/Images/QrCode.jpg"; string barcodePath = Server.MapPath(imagePath); var barcodeReader = new BarcodeReader(); var result = barcodeReader.Decode(new Bitmap(barcodePath)); if (result != null) { barcodeText = result.Text; } return(new QRCodeModel() { QRCodeText = barcodeText, QRCodeImagePath = imagePath }); }
private string GenerateQRCode(QRCodeModel qr) { //string folderPath = "~/Admin/Images/QRCode"; //string imagePath = "~/Admin/Images/QRCode/QrCode.jpg"; // If the directory doesn't exist then create it. if (!Directory.Exists(Server.MapPath("~/Admin"))) { Directory.CreateDirectory(Server.MapPath("~/Admin")); } if (!Directory.Exists(Server.MapPath("~/Admin/Images"))) { Directory.CreateDirectory(Server.MapPath("~/Admin/Images")); } if (!Directory.Exists(Server.MapPath(qr.FolderPath))) { Directory.CreateDirectory(Server.MapPath(qr.FolderPath)); } var barcodeWriter = new BarcodeWriter(); barcodeWriter.Format = BarcodeFormat.QR_CODE; var result = barcodeWriter.Write(qr.QRCodeText); string barcodePath = Server.MapPath(qr.FilePath); var barcodeBitmap = new Bitmap(result); using (MemoryStream memory = new MemoryStream()) { using (FileStream fs = new FileStream(barcodePath, FileMode.Create, FileAccess.ReadWrite)) { barcodeBitmap.Save(memory, System.Drawing.Imaging.ImageFormat.Jpeg); byte[] bytes = memory.ToArray(); fs.Write(bytes, 0, bytes.Length); } } return(qr.FilePath); }
private QRCodeModel GenerateQRCode(string qrcodeText) { string folderPath = QRCodeModel.SAVE_PATH; string imagePath = folderPath + qrcodeText + ".jpg"; // If the directory doesn't exist then create it. if (!Directory.Exists(Server.MapPath(folderPath))) { Directory.CreateDirectory(Server.MapPath(folderPath)); } var barcodeWriter = new BarcodeWriter(); barcodeWriter.Format = BarcodeFormat.QR_CODE; var result = barcodeWriter.Write(qrcodeText); string barcodePath = Server.MapPath(imagePath); var barcodeBitmap = new Bitmap(result); using (MemoryStream memory = new MemoryStream()) { using (FileStream fs = new FileStream(barcodePath, FileMode.Create, FileAccess.ReadWrite)) { barcodeBitmap.Save(memory, ImageFormat.Jpeg); byte[] bytes = memory.ToArray(); fs.Write(bytes, 0, bytes.Length); fs.Close(); fs.Dispose(); } } QRCodeModel qRCodeModel = new QRCodeModel(); qRCodeModel.QRCodeText = qrcodeText; qRCodeModel.QRCodeImagePath = imagePath; return(qRCodeModel); }
public IActionResult QRCode(QRCodeModel model) { byte[] byteImg = qrCodeService.Create(model.InputText); return(File(byteImg, "image/png")); //return Ok(new { Value = true, model.InputText }); }
public static bool ToPrinterQRCodeModel(string value, out QRCodeModel output) { return(PrinterQRCodeModelDictionary.TryGetKey(value, out output)); }
public ActionResult Pay(Payment item) { var me = (User)Session["me"]; if (me == null) { return(RedirectToAction("Index")); } var stripeToken = Request.Form["stripeToken"]; if (String.IsNullOrEmpty(stripeToken)) { TempData["result_code"] = -1; TempData["message"] = "Stripe set an error with your informations"; TempData.Keep(); return(RedirectToAction("Index")); } var Email = Request.Form["stripeEmail"]; var stripeTokenType = Request.Form["stripeTokenType"]; var productService = new ProductService(); var priceService = new PriceService(); var invoiceItemService = new InvoiceItemService(); var invoiceServices = new InvoiceService(); var customerService = new CustomerService(); var planService = new PlanService(); var subscriptionService = new SubscriptionService(); var original_amount = 500; var amount = Convert.ToInt32(me.reduction > 0 ? original_amount * me.reduction : original_amount); var product = productService.Create(new ProductCreateOptions { Name = "Name of Service", }); var price = priceService.Create(new PriceCreateOptions { Product = product.Id, UnitAmount = amount, Currency = "usd", Recurring = new PriceRecurringOptions { Interval = "month", }, }); var customer = customerService.Create(new CustomerCreateOptions { Email = Email, Source = stripeToken, }); var plan = planService.Create(new PlanCreateOptions { Amount = amount, Currency = "usd", Interval = "month", IntervalCount = 1, Product = product.Id, // "prod_IinH4BV2oyao8L", }); var subscription = subscriptionService.Create(new SubscriptionCreateOptions { Customer = customer.Id, Items = new List <SubscriptionItemOptions> { new SubscriptionItemOptions { Plan = plan.Id, }, }, }); if (subscription.Status == "active") { item.original_amount = 500; item.amount = amount; item.code = QRCodeModel.GenerateRandomString(); item.payer_id = me.id; db1.Payment.Add(item); db1.SaveChanges(); TempData["result_code"] = 1; TempData["message"] = "Subscription done successfully"; TempData.Keep(); return(RedirectToAction("Payments")); } TempData["result_code"] = -1; TempData["message"] = "An error occured during the payment"; TempData.Keep(); return(RedirectToAction("Index")); }
public ActionResult Register(User item) { if (ModelState.IsValid) { try { if (db1.User.Any(u => u.email == item.email)) { ModelState.AddModelError("Email", "Email address already exists. Please change email address."); return(View(item)); } var qRCodeModel = GenerateQRCode(item.email); WebClient myWebClient = new WebClient(); try { string pdfPath = Server.MapPath(qRCodeModel.QRCodeImagePath); Response.ContentType = "iamges/jpeg"; Response.AppendHeader("content-disposition", "attachment; filename=" + item.email + ".jpg"); Response.TransmitFile(pdfPath); Response.End(); //myWebClient.DownloadFile(Server.MapPath(qRCodeModel.QRCodeImagePath), Server.MapPath(qRCodeModel.QRCodeImagePath)); } catch (Exception e) { TempData["result_code"] = -1; TempData["message"] = "An error occured"; TempData.Keep(); ModelState.AddModelError("Exception", "QR code can't downloaded. Updade your browser before."); return(View(item)); } db1.User.Add(item); db1.SaveChanges(); Models.SecondModel.User user2 = new Models.SecondModel.User(); user2.full_name = item.full_name; user2.status = true; user2.password = item.password; user2.code = qRCodeModel.QRCodeText; user2.reduction = Convert.ToDecimal(QRCodeModel.randomDouble(0, 1)); db2.User.Add(user2); db2.SaveChanges(); TempData["result_code"] = 1; TempData["message"] = "Account created successfully"; TempData.Keep(); return(RedirectToAction("Index", "Home")); } catch (Exception e) { TempData["result_code"] = -1; TempData["message"] = "An error occured"; TempData.Keep(); ModelState.AddModelError("Exception", e.Message); return(View(item)); } } TempData["result_code"] = -1; TempData["message"] = "Datas not valid"; TempData.Keep(); ModelState.AddModelError("Exception", "Datas not valid"); return(View(item)); }
public ActionResult GenerateQrCode(QRCodeModel qRCodeModel) { qRCodeModel.QRCodeImagePath = qRCodeModel.QRCodeText.GenerateQrCode(); return(Json(qRCodeModel.QRCodeImagePath, JsonRequestBehavior.AllowGet)); }
public QRCodePolicyDetails GetQRCodes(string QRCode) { QRCodePolicyDetails details = new QRCodePolicyDetails(); try { details.Policies = new List <QRCodeModel>(); // InsuranceContext.CertSerialNoDetails var CertSerialNoDetails = InsuranceContext.CertSerialNoDetails.Single(where : $"CertSerialNo='" + QRCode + "'"); PolicyDetail policyDetetials = null; if (CertSerialNoDetails != null) { policyDetetials = InsuranceContext.PolicyDetails.Single(CertSerialNoDetails.PolicyId); } if (policyDetetials != null) { var receiptHistory = InsuranceContext.ReceiptHistorys.Single(where : "PolicyNumber='" + policyDetetials.PolicyNumber + "'"); if (receiptHistory != null) { QRCodeModel model = new QRCodeModel { CustomerId = 0 }; details.Policies.Add(model); details.RecieptNumber = 0; details.Message = "QRCode has been already read."; return(details); } } var query = "Select VehicleLicenceFee,Email,IsCustomEmail,StampDuty,ZTSCLevy,Premium,Customer.Id as CustomerId,ModelDescription,VehicleDetail.RenewalDate, RadioLicenseCost, IncludeRadioLicenseCost, CoverType.Name as CoverTypeName,"; query += " PaymentTerm.Name as PaymentTermName,Covertype.Name, FirstName,LastName,PolicyNumber,RegistrationNo,SummaryDetail.Id as SummaryId, case when PaymentMethod.Name<>'PayLater' then 'Paid' else 'PayLater' end as PaymentStatus from VehicleDetail"; query += " join PolicyDetail on VehicleDetail.PolicyId=PolicyDetail.Id"; query += " Left join Customer on PolicyDetail.CustomerId=Customer.Id"; query += " Left Join CoverType on VehicleDetail.CoverTypeId=CoverType.Id"; query += " Left Join PaymentTerm on VehicleDetail.PaymentTermId=PaymentTerm.Id"; query += " Left Join VehicleModel On VehicleDetail.ModelId=VehicleModel.ModelCode"; query += " Left Join SummaryVehicleDetail On VehicleDetail.Id=SummaryVehicleDetail.VehicleDetailsId"; query += " Left Join SummaryDetail On SummaryVehicleDetail.SummaryDetailId=SummaryDetail.Id"; query += " left join AspNetUsers on Customer.UserID=AspNetUsers.Id"; query += " left join PaymentMethod on SummaryDetail.PaymentMethodId= PaymentMethod.Id "; query += " left join CertSerialNoDetail on PolicyDetail.Id=CertSerialNoDetail.PolicyId where VehicleDetail.IsActive=1 and CertSerialNo= '" + QRCode + "'"; //var query = "select policyDetail.Number as PolicyNumber"; List <QRCodeModel> list = InsuranceContext.Query(query).Select(c => new QRCodeModel { Message = "Successfully.", CustomerId = c.CustomerId, CustomerName = c.FirstName + " " + c.LastName, PolicyNumber = c.PolicyNumber, Registrationno = c.RegistrationNo, ModelDescription = c.ModelDescription, Covertype = c.CoverTypeName, PaymentTerm = c.PaymentTermName, ExpireDate = c.RenewalDate, IncludeRadioLicenseCost = Convert.ToBoolean(c.IncludeRadioLicenseCost), RadioLicenseCost = c.IncludeRadioLicenseCost == false ? 0 : Convert.ToDecimal(c.IncludeRadioLicenseCost), TotalPremium = c.VehicleLicenceFee + c.StampDuty + c.ZTSCLevy + c.Premium + c.RadioLicenseCost, SummaryId = c.SummaryId, Email = c.Email, IsCustomEmail = c.IsCustomEmail, PaymentStatus = c.PaymentStatus }).ToList(); // in case of renew //test var query1 = "SELECT top 1 [Id] FROM ReceiptModuleHistory order by Id Desc"; //var re = InsuranceContext.ReceiptHistorys.All(x => x.Id); var receipt = InsuranceContext.Query(query1).Select(x => new ReceiptModuleHistory() { Id = x.Id, }).FirstOrDefault(); // var receiptid=InsuranceContext.r details.RecieptNumber = receipt == null ? 100000 : receipt.Id + 1; details.Policies = list; if (list.Count() > 0) { details.AmountDue = list.Sum(c => c.TotalPremium); details.Message = "Records found."; } else { details.Message = "No records found."; } } catch (Exception ex) { details.Message = "Exception."; } return(details); }