public QrCodeModel FindById(string qrCodeId) { StartNewUnitOfWork(); QrCodeModel qrCodeModel = qrCodeRepository.Get(qrCodeId); EndUnitOfWork(); return(qrCodeModel); }
public IHttpActionResult CheckQrCode([FromUri] int classId, [FromBody] QrCodeModel model) { int studentId = Ticket.ExtractStudentId(model.QrCode); return(JsonEx(new { result = Logic.CheckQrCode(studentId, classId, model.QrCode) })); }
public void BindProductWithDistributor(string qrCodeId, string productNameId, string distributorId) { QrCodeModel qrCodeModel = qrCodeService.FindById(qrCodeId); ProductModel product = productService.FindById(productNameId); DistributorModel distributor = distributorService.FindById(distributorId); qrCodeModel.Distributor = distributor; qrCodeModel.Product = product; qrCodeService.Update(qrCodeModel); }
public static void BindProductToDistributorWithQrCode(string qrCode, string productName, string distributorName) { QrCodeModel qrCodeModel = qrCodeService.FindById(qrCode); ProductModel product = productService.FindById(productName); DistributorModel distributor = distributorService.FindById(distributorName); qrCodeModel.Distributor = distributor; qrCodeModel.Product = product; qrCodeService.Update(qrCodeModel); }
public MerchantViewModel() { SignInButton = new Command(async => LogIn()); QrCodeModel qrCode = new QrCodeModel { Name = Preferences.Get("Name", ""), BookBank = Preferences.Get("BookBank", "") }; QRCodeValue = JsonConvert.SerializeObject(qrCode); PushToCreateQRCode = new Command(PushToQRPage); }
/// <summary> /// 创建字符型id永久二维码 /// 如果每次使用的str id一样,生成的ticket就一样,图片一样,如果扫描,返回的str id都一样。 /// </summary> /// <param name="scene_str">场景值ID(字符串形式的ID),字符串类型,长度限制为1到64,仅永久二维码支持此字段 </param> /// <returns></returns> public QrCodeResultModel CreateQrCodeByStr(string scene_str) { string url = ApiUrl.GetCreateQrUrl(Config.AccessToken); string postData = QrCodeModel.CreateQrCodeByStrPostData(scene_str); string json = HttpHelper.PostJson(url, postData); ResultModel.CreateInstance(json).HasException(); JObject jo = JObject.Parse(json); QrCodeResultModel rModel = jo.ToObject <QrCodeResultModel>(); return(rModel); }
/// <summary> /// 创建临时二维码 /// 就算每次使用的id一样,生成的ticket也不会一样,图片不一样,如果扫描,返回的id却都一样。 /// </summary> /// <param name="scene_id">场景值ID,临时二维码时为32位非0整型</param> /// <param name="expire_seconds">该二维码有效时间,以秒为单位。 最大不超过2592000(即30天),此字段如果不填,则默认有效期为30秒。 </param> /// <returns></returns> public QrCodeResultModel CreateQrCodeTemp(int scene_id, int?expire_seconds = null) { string url = ApiUrl.GetCreateQrUrl(Config.AccessToken); string postData = QrCodeModel.CreateQrCodeTempPostData(scene_id, expire_seconds); string json = HttpHelper.PostJson(url, postData); ResultModel.CreateInstance(json).HasException(); JObject jo = JObject.Parse(json); QrCodeResultModel rModel = jo.ToObject <QrCodeResultModel>(); return(rModel); }
public void TestBindingService() { string qrcode = "http://192.168.1.101:8080/qrcode-manage/0"; string distributorName = "河北"; string productName = "咳咳音乐"; QrCodeModel qrcodeModel = qrcodeService.FindById(qrcode); DistributorModel distributorModel = distributorService.FindById(distributorName); ProductModel productModel = productService.FindById(productName); qrcodeModel.Distributor = distributorModel; qrcodeModel.Product = productModel; qrcodeService.Add(qrcodeModel); }
public AdminViewModel() { SignInButton = new Command(async => LogIn()); QrCodeModel qrCode = new QrCodeModel { Name = Preferences.Get("Name", ""), BookBank = Preferences.Get("BookBank", ""), MoneyAmount = Preferences.Get("MoneyAmount", ""), Ref = Preferences.Get("Ref", ""), ExpiryDate = Preferences.Get("ExpiryDate", "") }; QRCodeValue = JsonConvert.SerializeObject(qrCode); PushToCreateQRCode = new Command(PushToQRPage); PushToInputMon = new Command(PushToInputMoney); Name = Preferences.Get("Name", ""); MoneyAmount = Preferences.Get("MoneyAmount", ""); Reference = Preferences.Get("Ref", ""); ExpiryDate = Preferences.Get("ExpiryDate", ""); BackToHome = new Command(BackHome); }
public void Update(QrCodeModel qrCode) { StartNewUnitOfWork(); qrCodeRepository.Add(qrCode); EndUnitOfWork(); }
public void ProcessRequest(HttpContext context) { bool auth = context.User.Identity.IsAuthenticated; if (!auth) { context.Response.Redirect("~/account/login.aspx?ReturnUrl=" + context.Request.Url, true); } else { IsoDateTimeConverter isoDateTime = new IsoDateTimeConverter() { DateTimeFormat = "yyyy-MM-dd HH:mm:ss", Culture = new System.Globalization.CultureInfo("zh") }; if (context.Request["action"] == "print") { var json = context.Session["json"].ToString(); if (context.Session["json"] != null) { try { using (QrCodeModel qr = new QrCodeModel()) { var itemMasters = JsonConvert.DeserializeObject(json, typeof(ItemMaster[])) as ItemMaster[]; var qRCodeLists = from itemMaster in itemMasters select new QRCodeList { ItemMaster = itemMaster.料号, ItemName = itemMaster.品名, SerialNo = itemMaster.序列号, SupplierCode = itemMaster.供应商编码, PrintDate = DateTime.Now, UserName = context.User.Identity.Name }; qr.QRCodeLists.AddRange(qRCodeLists); qr.SaveChanges(); } } catch (Exception) { context.Response.Write("发生错误,保存失败"); } } } else if (context.Request["action"] == "getList" && (context.Request["q"] == null || context.Request["q"] == "")) { try { var page = Convert.ToInt32(context.Request["page"]); var rows = Convert.ToInt32(context.Request["rows"]); using (QrCodeModel qr = new QrCodeModel()) { var qRjson = qr.QRCodeLists.OrderByDescending(m => m.PrintDate).Skip(rows * (page - 1)).Take(rows); var json = "{\"total\":" + qr.QRCodeLists.Count() + ",\"rows\":" + JsonConvert.SerializeObject(qRjson, isoDateTime) + "}"; context.Response.Write(json); } } catch (Exception) { } } else if (context.Request["q"] != "") { var q = context.Request["q"]; using (QrCodeModel qr = new QrCodeModel()) { qr.Database.Log = (x) => { File.AppendAllText(@"c:\qrcodewebLog.txt", x); }; var qAarry = q.Split(','); var qRjson = qr.QRCodeLists.Where(x => qAarry.Contains(x.ItemMaster)).OrderByDescending(m => m.PrintDate); //var qRjson = qr.QRCodeLists.Where(m=> m.ItemMaster.Contains(q)).OrderByDescending(m=>m.PrintDate) ; var json = "{\"total\":" + qr.QRCodeLists.Count() + ",\"rows\":" + JsonConvert.SerializeObject(qRjson, isoDateTime) + "}"; context.Response.Write(json); } } } }