Exemplo n.º 1
0
        public ActionResult DeleteAll(string ids)
        {
            PubResult pr = new PubResult();

            if (string.IsNullOrEmpty(ids))
            {
                pr.Flag = false;
                pr.Msg  = PubConst.Delete2;
            }
            else
            {
                ids = ids.TrimEnd(',');
                string sql  = "delete from SysLog where LogId in (" + ids + ")" + "and 1=@shu";
                var    flag = _iSysLogServices.ExecuteSqlCommand(ids, sql, new SqlParameter[] { new SqlParameter("@shu", "1") });
                if (flag)
                {
                    pr.Flag = true;
                    pr.Msg  = PubConst.Delete1;
                }
                else
                {
                    pr.Flag = false;
                    pr.Msg  = PubConst.Delete1;
                }
            }
            return(Json(pr, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
        public ActionResult AddOrUpdate(SystemUser su, string id)
        {
            PubResult pr = new PubResult();

            if (id != null)
            {
                var entity = _iSysUserServices.FindEntity(c => c.SystemUserId == id);
                return(View("~/Areas/System/Views/User/Add.cshtml"));;
            }
            else
            {
                su.SystemUserId = Guid.NewGuid().ToString().Replace("-", "");
                var flag = _iSysUserServices.InsertAdd(su);
                if (flag == true)
                {
                    pr.Flag = true;
                    pr.Msg  = PubConst.Success2;
                }
                else
                {
                    pr.Flag = false;
                    pr.Msg  = PubConst.Failed6;
                }
            }
            return(Json(pr, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 3
0
        public ActionResult Delete(string ids)
        {
            PubResult pr = new PubResult();

            if (string.IsNullOrEmpty(ids))
            {
                pr.Flag = false;
                pr.Msg  = PubConst.Delete2;
            }
            else if (ids.Length > 40)
            {
                pr.Flag = false;
                pr.Msg  = PubConst.Delete3;
            }
            else
            {
                ids = ids.TrimEnd(',');
                var flag = _iSysUserServices.Delete(c => c.SystemUserId == ids);
                if (flag)
                {
                    pr.Flag = true;
                    pr.Msg  = PubConst.Delete1;
                }
                else
                {
                    pr.Flag = false;
                    pr.Msg  = PubConst.Delete4;
                }
            }
            return(Json(pr, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 4
0
        public PubResult CheckLogin(string tel, string pwd)
        {
            PubResult pr = new PubResult();
            //扩展成从缓存中获取用户信息,如果缓存没有用户信息,再去服务器上查找
            var model = _sysUserRepository.FindEntity(c => c.Telephone == tel);

            if (model == null)
            {
                pr.Msg  = PubConst.Failed2;
                pr.Flag = false;
            }
            else
            {
                if (model.Pwd == pwd)
                {
                    switch (model.IsActive)
                    {
                    case 1:
                        SystemUserDto sud = new SystemUserDto();
                        sud.SystemUserId = model.SystemUserId;
                        //加入cookie 或者 session

                        DateTime expiration = DateTime.Now.AddDays(7);
                        //DateTime expiration2 DateTime.Now.Add(FormsAuthentication.Timeout);
                        FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(2,
                                                                                         model.Telephone,
                                                                                         DateTime.Now,
                                                                                         expiration,
                                                                                         true,
                                                                                         model.SystemUserId,
                                                                                         FormsAuthentication.FormsCookiePath
                                                                                         );
                        string cookieName = "vs2017vs2015xmltool---1wjuijs";
                        //FormsAuthentication.FormsCookieName
                        HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName,
                                                           FormsAuthentication.Encrypt(ticket))
                        {
                            HttpOnly = true,
                            Expires  = expiration
                        };
                        HttpContext.Current.Response.Cookies.Add(cookie);
                        pr.Msg  = PubConst.Success;
                        pr.Flag = true;

                        break;

                    default:
                        pr.Msg  = PubConst.Failed3;
                        pr.Flag = false;
                        break;
                    }
                }
                else
                {
                    pr.Msg  = PubConst.Failed4;
                    pr.Flag = false;
                }
            }
            return(pr);
        }
Exemplo n.º 5
0
        public void MpToObj()
        {
            var a = new PubResult
            {
                Data = null,
                Flag = true,
                Msg  = "123"
            };

            Assert.NotNull(a.MpToJson().MpToObj <PubResult>());
        }
Exemplo n.º 6
0
        public void JilToJson()
        {
            var a = new PubResult
            {
                Data = null,
                Flag = true,
                Msg  = "123"
            };

            Assert.NotNull(a.JilToJson());
        }
Exemplo n.º 7
0
        public ActionResult Add(SystemUser su, string ids, string editor, FormCollection fc)
        {
            var        cf  = fc["editor"];
            var        ds  = fc["editorvalue"];
            SystemUser suk = new SystemUser();
            PubResult  pr  = new PubResult();

            if (IsPost())
            {
                if (!string.IsNullOrEmpty(ids))
                {
                    su.SystemUserId = ids;
                    su.ModifiedBy   = AuthTicket().SystemUserId;
                    su.ModifyTime   = DateTime.Now;
                    var entity = _iSysUserServices.Update2(su);
                    if (entity)
                    {
                        //string js = @"<script>layer.alert('修改成功',{icon: 2,skin: 'layer-ext-moon'});setTimeout(function(){parent.location.reload();layer_close()}, 1000)</script>";
                        ViewBag.js = JsMsgSuccess("修改成功", 1);
                    }
                    else
                    {
                        ViewBag.js = JsMsgFailed("修改失败", 2);
                    }
                }
                else
                {
                    su.SystemUserId = Guid.NewGuid().ToString().Replace("-", "");
                    su.IsActive     = 1;
                    var flag = _iSysUserServices.InsertAdd(su);
                    if (flag)
                    {
                        ViewBag.js = JsMsgSuccess(PubConst.Success2, 1);
                    }
                    else
                    {
                        ViewBag.js = JsMsgFailed(PubConst.Failed6, 2);
                    }
                }
                return(View(su));
            }
            else
            {
                if (ids != null)
                {
                    su = _iSysUserServices.FindEntity(c => c.SystemUserId == ids);
                }
            }
            return(View(su));
        }
Exemplo n.º 8
0
 public void JilToJson2(PubResult a)
 {
     Assert.NotNull(a.JilToJson());
 }