Ejemplo n.º 1
0
        //首页
        public ActionResult admin(string timestamp)
        {
            if (!FormsAuth.IsAuthenticated)
            {
                return(RedirectToAction("Index", "Login"));
            }

            initLan();

            ViewBag.Token     = CreateToken();
            ViewBag.user_info = JTS.Utils.DESEncrypt.Encrypt("/sys/sysbase]user_info", EncryptKey);
            var loginer = FormsAuth.GetBaseLoginerData();

            ViewBag.Title    = System.Configuration.ConfigurationManager.AppSettings["title"].ToString();;
            ViewBag.UserId   = loginer.UserId;
            ViewBag.UserCode = loginer.UserCode;
            ViewBag.UserName = loginer.UserName;
            // ViewBag.navigation = "menubutton";
            ViewBag.navigation = "accordion";
            ViewBag.Settings   = new { gridrows = 20, navigation = "accordion" };
            if (CurrentUser.DepartmentCode.Length > 0)
            {
                ViewBag.LoginUser = "******" + loginer.UserCode + "]" + loginer.UserName + "-" + CurrentUser.DepartmentCode;
            }
            else
            {
                ViewBag.LoginUser = "******" + loginer.UserCode + "]" + loginer.UserName;
            }
            ViewBag.EasyuiVersion = JTS.Utils.ConfigUtil.GetConfigString("EasyuiVersion"); //easyui版本
            ViewBag.SystemVersion = JTS.Utils.ConfigUtil.GetConfigString("SystemVersion"); //系统版本
            CookiesUtil.WriteCookies("EasyuiTheme", 0, "");
            CookiesUtil.WriteCookies("EasyuiVersion", 0, JTS.Utils.ConfigUtil.GetConfigString("EasyuiVersion"));

            JObject data = new JObject();

            data["role_ids"]  = loginer.RoleIDs;
            data["slanguage"] = Session["slanguage"].ToString();
            DataSet dt = base.RunProcedureDataSet(data, "vdp_get_menu", "sys");

            EncryptKey = System.Configuration.ConfigurationManager.AppSettings["EncryptKey"].ToString();;

            foreach (DataRow r in dt.Tables[0].Rows)
            {
                r["menu_token"] = Server.UrlEncode(JTS.Utils.DESEncrypt.Encrypt(r["url"] + "]" + r["menu_code"], EncryptKey));
            }


            var model = new
            {
                //  userSettings = userSettings,
                UserId   = loginer.UserId,
                UserCode = loginer.UserCode,
                UserName = loginer.UserName //,
                                            //  UserMenus2 =Dtb2Json( dt.Tables[0])
            };

            ViewBag.UserMenus = Dtb2Json(dt.Tables[0]);
            return(View(model));
        }
Ejemplo n.º 2
0
 public ActionResult KM()
 {
     ViewBag.CnName = "KM企业快速开发框架";
     ViewBag.EnName = "KM EnterpriseRapid Development Framework.";
     CookiesUtil.RemoveCookie("KMAUTH");
     CookiesUtil.RemoveCookie("EasyuiTheme");
     CookiesUtil.RemoveCookie("EasyuiVersion");
     return(View("Index"));
 }
Ejemplo n.º 3
0
        public void Login(UserVM form)
        {
            if (string.IsNullOrEmpty(form.UserName))
            {
                throw new BaseException(SuperConstants.AJAX_RETURN_STATE_ERROR, "用户名为空");
            }
            else if (string.IsNullOrEmpty(form.Password))
            {
                throw new BaseException(SuperConstants.AJAX_RETURN_STATE_ERROR, "密码为空");
            }
            else if (string.IsNullOrEmpty(form.CheckCode))
            {
                throw new BaseException(SuperConstants.AJAX_RETURN_STATE_ERROR, "验证码为空");
            }
            else
            {
                string code = Ext.ToString(HttpContext.Current.Session[SuperConstants.LOGIN_VALIDATE_CODE]);
                if (!code.ToLower().Equals(form.CheckCode.ToLower()))
                {
                    throw new BaseException(SuperConstants.AJAX_RETURN_STATE_ERROR, "验证码错误");
                }

                form.Password = MD5Encrypt.Encrypt(form.Password);
                Sys_User user = this._userRepository.Entity(ContextDB.managerDBContext, t => t.UserName == form.UserName && t.Password == form.Password);
                if (user == null)
                {
                    throw new BaseException(SuperConstants.AJAX_RETURN_STATE_ERROR, "用户名或密码错误");
                }
                //ContextDB.managerDBContext.Database.Log += c => _Logger.Info(c);

                UserSession us = new UserSession
                {
                    UserId   = user.Id,
                    UserName = user.UserName,
                    TokenId  = CommonUtil.GUID()
                };
                CookiesUtil.SetCookies("username", us.UserName);
                CookiesUtil.SetCookies(SuperConstants.COOKIESID, us.TokenId);
                this._cacheManager.Set(us.TokenId, us);
                List <ModuleVM> moduleList = GetModule(us);
                CreateMenu(moduleList);

                Message msg = this._messageService.GetMessage();
            }
        }
Ejemplo n.º 4
0
        //首页
        public ActionResult Index(string timestamp)
        {
            if (!FormsAuth.IsAuthenticated)
            {
                return(RedirectToAction("Index", "Login"));
            }
            // 无限光年网络科技
            var loginer = FormsAuth.GetBaseLoginerData();

            ViewBag.Title     = "KM企业快速开发框架";
            ViewBag.UserId    = loginer.UserId;
            ViewBag.UserCode  = loginer.UserCode;
            ViewBag.UserName  = loginer.UserName;
            ViewBag.LoginUser = "******" + loginer.UserCode + "]" + loginer.UserName;
            var userSettings = Base_UserService.Instance.GetCurrentUserSettings();

            ViewBag.Settings      = userSettings;
            ViewBag.EasyuiTheme   = userSettings["theme"].ToString();
            ViewBag.EasyuiVersion = JTS.Utils.ConfigUtil.GetConfigString("EasyuiVersion");
            ViewBag.SystemVersion = JTS.Utils.ConfigUtil.GetConfigString("SystemVersion");
            CookiesUtil.WriteCookies("EasyuiTheme", 0, userSettings["theme"].ToString());
            CookiesUtil.WriteCookies("EasyuiVersion", 0, JTS.Utils.ConfigUtil.GetConfigString("EasyuiVersion"));
            var list = Base_MenuService.Instance.GetUserMenus(this.CurrentUser.UserId, this.CurrentUser.IsSuperAdmin == 1);
            //测试发送一条验证短信
            //Random rnd = new Random();
            //int num = rnd.Next(304001, 504001);
            //var result = KM.TaobaoApi.ApiManager.Instance.SendSMS(loginer.UserId.ToString(), num.ToString(), "13520075291,15301024100");
            //var smsStr = JsonConvert.SerializeObject(result);
            //LogHelper.Write("测试短信发送结果:" + smsStr);
            var model = new
            {
                userSettings = userSettings,
                UserId       = loginer.UserId,
                UserCode     = loginer.UserCode,
                UserName     = loginer.UserName,
                UserMenus    = list
            };


            return(View(model));
        }
Ejemplo n.º 5
0
        public static UserSession UserSession()
        {
            string token = CookiesUtil.GetCookiesValue(SuperConstants.COOKIESID);

            if (string.IsNullOrEmpty(token))
            {
                return(null);
            }
            else
            {
                ICacheManager cacheManager = ServiceContainer.Resolve <ICacheManager>();
                UserSession   userSession  = cacheManager.Get <UserSession>(token);
                if (userSession == null)
                {
                    return(null);
                }
                else
                {
                    return(userSession);
                }
            }
        }
Ejemplo n.º 6
0
        public ActionResult Index()
        {
            var loginer = FormsAuth.GetBaseLoginerData();

            ViewBag.Title    = "MangoGreen";
            ViewBag.UserId   = loginer.UserId;
            ViewBag.UserCode = loginer.UserCode;
            ViewBag.UserName = loginer.UserName;

            ViewBag.LoginUser = loginer.UserName;


            //var server = GetService<ISys_MenuService>();
            // var userSettings = Base_UserService.Instance.GetCurrentUserSettings();
            var userSettings = new Dictionary <string, string>();

            userSettings.Add("navigation", "menubutton1");
            userSettings.Add("theme", "bootstrap");
            ViewBag.Settings      = userSettings;
            ViewBag.EasyuiTheme   = userSettings["theme"].ToString();
            ViewBag.EasyuiVersion = ConfigUtil.GetConfigString("EasyuiVersion"); //easyui版本
            ViewBag.SystemVersion = ConfigUtil.GetConfigString("SystemVersion"); //系统版本
            CookiesUtil.WriteCookies("EasyuiTheme", 0, userSettings["theme"].ToString());
            CookiesUtil.WriteCookies("EasyuiVersion", 0, ConfigUtil.GetConfigString("EasyuiVersion"));
            var server = GetService <ISys_MenuService>();
            var list   = server.GetUserMenus(loginer);
            var model  = new
            {
                userSettings = userSettings,
                UserId       = loginer.UserId,
                UserCode     = loginer.UserCode,
                UserName     = loginer.UserName,
                UserMenus    = list
            };

            return(View(model));
        }
Ejemplo n.º 7
0
 public ActionResult LogOut()
 {
     this._cacheManager.Remove(CookiesUtil.GetCookiesValue(SuperConstants.COOKIESID));
     return(RedirectToAction("Index", "Login"));
 }