Beispiel #1
0
        public ActionResult VerifyEdit(string code)
        {
            DbQRInfo info = TF.QR.Config.Helper.CreateWhere <DbQRInfo>().Where(o => o.Code == code).FirstOrDefault(null);

            if (info == null)
            {
                return(base.RedirectError("编码信息错误"));
            }
            if (string.IsNullOrEmpty(info.OpenID))
            {
                return(base.RedirectToAction("Bind", new { code = code }));
            }
            return(base.RedirectToAction("Edit", new { code = code }));
        }
Beispiel #2
0
        public ActionResult QRStorageDelete(int id)
        {
            DbQRInfo poco = Config.Helper.SingleOrDefaultById <DbQRInfo>(id);

            if (poco == null)
            {
                return(base.Error("信息不存在"));
            }
            if (!poco.CanBeAcessed)
            {
                return(base.Error("无权限操作"));
            }
            Config.Helper.Delete <DbQRInfo>(poco);
            return(base.Success("删除成功"));
        }
Beispiel #3
0
 public ActionResult QRStorageSubmit(DbQRInfo info)
 {
     if (string.IsNullOrEmpty(info.Code))
     {
         return(base.Error("编码不能为空"));
     }
     if ((info.Id == 0L) && Config.Helper.Exists <DbQRInfo>("where code=@0", new object[] { info.Code }))
     {
         return(base.Error("相同编码已存在"));
     }
     if (!info.CanBeAcessed)
     {
         return(base.Error("无权限操作"));
     }
     Config.Helper.Save(info);
     return(base.Success("提交成功"));
 }
Beispiel #4
0
        public ActionResult Export()
        {
            ParameterExpression expression5;
            string str       = base.Request.QueryString["activate"];
            string str2      = base.Request.QueryString["expired"];
            string searchkey = base.Request.QueryString["searchkey"];
            DbUser user      = Config.GetCurrentUser();
            var    list      = Config.Helper.CreateWhere <DbQRInfo>()
                               .IfTrue(user.DbRoleType != DbRoleType.Administrator).Where(o => o.BindAdministrator == user.Id)
                               .IfTrue((str == "1")).Where(o => o.ActivateDate != null)
                               .IfTrue((str == "-1")).Where(o => o.ActivateDate == null)
                               .IfTrue((str2 == "1")).Where(o => (o.ExpireDate != null) && (o.ExpireDate < Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"))))
                               //.IfTrue((str2 == "-1")).Where(Expression.Lambda<Func<DbQRInfo, bool>>(Expression.OrElse(Expression.Equal(Expression.Property(expression5 = Expression.Parameter(typeof(DbQRInfo), "o"), (MethodInfo)methodof(DbQRInfo.get_ExpireDate)), Expression.Convert(Expression.Constant(null, typeof(DateTime?)), typeof(DateTime?)), false, (MethodInfo)methodof(DateTime.op_Equality)), Expression.GreaterThan(Expression.Property(expression5, (MethodInfo)methodof(DbQRInfo.get_ExpireDate)), Expression.Convert(Expression.Call(null, (MethodInfo)methodof(Convert.ToDateTime), new Expression[] { Expression.Call(Expression.Property(null, (MethodInfo)methodof(DateTime.get_Now)), (MethodInfo)methodof(DateTime.ToString), new Expression[] { Expression.Constant("yyyy-MM-dd", typeof(string)) }) }), typeof(DateTime?)), false, (MethodInfo)methodof(DateTime.op_GreaterThan))), new ParameterExpression[] { expression5 }))
                               .IfSet(searchkey).Where(o => ((((((o.Code.Contains(searchkey) || o.RealName.Contains(searchkey)) || o.ContactName.Contains(searchkey)) || o.ContactMobile.Contains(searchkey)) || o.ContactName2.Contains(searchkey)) || o.ContactMobile2.Contains(searchkey)) || o.Address.Contains(searchkey)) || o.Tip.Contains(searchkey)).OrderBy <DateTime>(o => o.CreateTime, OrderType.Desc).Select(null);

            DbQRInfo.Export(list);
            return(base.File(base.Server.MapPath("/编码信息.txt")));
        }
Beispiel #5
0
 public ActionResult Edit(string code)
 {
     try
     {
         string   openid = base.Request.Cookies["openid"].Value;
         DbQRInfo model  = TF.QR.Config.Helper.CreateWhere <DbQRInfo>().Where(o => o.Code == code).Where(o => o.OpenID == openid).FirstOrDefault(null);
         if (model == null)
         {
             return(base.RedirectError("对不起,无权修改此编码信息"));
         }
         JsSdkUiPackage package = JSSDKHelper.GetJsSdkUiPackage(TF.QR.Config.AppId, TF.QR.Config.AppSecret, base.Request.Url.AbsoluteUri);
         base.ViewData["jssdk"] = package;
         return(base.View(model));
     }
     catch (Exception exception)
     {
         return(base.RedirectError(exception.Message));
     }
 }
Beispiel #6
0
        public ActionResult Bind(string code, string verifycode)
        {
            DbQRInfo poco = TF.QR.Config.Helper.CreateWhere <DbQRInfo>().Where(o => o.Code == code).FirstOrDefault(null);

            if (poco == null)
            {
                return(base.Error("编码错误"));
            }
            if (!string.IsNullOrEmpty(poco.OpenID))
            {
                return(base.Error("此编码已经被绑定"));
            }
            if (poco.VerifyCode == verifycode)
            {
                poco.OpenID = base.Request.Cookies["openid"].Value;
                TF.QR.Config.Helper.Save(poco);
                return(base.Success("设置成功"));
            }
            return(base.Error("验证码不正确"));
        }
Beispiel #7
0
        public ActionResult Index(string code)
        {
            DbQRInfo model = TF.QR.Config.Helper.CreateWhere <DbQRInfo>().Where(o => o.Code == code).SingleOrDefault(null);

            if (model == null)
            {
                return(base.RedirectError("未找到数据"));
            }
            if (!model.ActivateDate.HasValue)
            {
                return(base.RedirectError("此编码尚未被激活,编码:" + code));
            }
            if (model.ExpireDate.HasValue)
            {
                DateTime now        = DateTime.Now;
                DateTime?expireDate = model.ExpireDate;
                if (expireDate.HasValue ? (now > expireDate.GetValueOrDefault()) : false)
                {
                    return(base.RedirectError("此编码已经过期"));
                }
            }
            return(base.View(model));
        }
Beispiel #8
0
        public ActionResult Edit(DbQRInfo info)
        {
            DbQRInfo poco = TF.QR.Config.Helper.SingleById <DbQRInfo>(info.Id);

            if (poco.OpenID != base.Request.Cookies["openid"].Value)
            {
                return(base.Error("没有操作权限"));
            }
            string str = base.Request.Form["mediaid"];

            if (!string.IsNullOrEmpty(str))
            {
                string accessTokenOrAppId = AccessTokenContainer.TryGetAccessToken(TF.QR.Config.AppId, TF.QR.Config.AppSecret, false);
                string path = string.Concat(new object[] { "/upload/", DateTime.Now.Year, "/", DateTime.Now.Month.ToString("D2"), "/", DateTime.Now.Day.ToString("D2"), "/" });
                if (!Directory.Exists(base.Server.MapPath(path)))
                {
                    Directory.CreateDirectory(base.Server.MapPath(path));
                }
                Guid       guid   = Guid.NewGuid();
                string     str4   = path + guid + ".jpg";
                FileStream stream = new FileStream(base.Server.MapPath(str4), FileMode.Create);
                MediaApi.Get(accessTokenOrAppId, str, stream);
                stream.Close();
                poco.Photo = str4;
            }
            poco.RealName       = info.RealName;
            poco.Sex            = info.Sex;
            poco.BirthDay       = info.BirthDay;
            poco.Address        = info.Address;
            poco.ContactName    = info.ContactName;
            poco.ContactMobile  = info.ContactMobile;
            poco.ContactName2   = info.ContactName2;
            poco.ContactMobile2 = info.ContactMobile2;
            poco.Tip            = info.Tip;
            TF.QR.Config.Helper.Save(poco);
            return(base.Success("提交成功"));
        }