Ejemplo n.º 1
0
        public ActionResult CheckLogin(string username, string password)
        {

            if (userinfoservice.CheckAccount(username))
            {
                var list = userinfoservice.CheckLogin(username, password);
                if (list.Count > 0)
                {
                    SessionHelp.SetSession("UID", list[0].Id.ToString());
                    //修改用户相关信息
                    var model = list[0];
                    model.LastLoginTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    model.UserNums = model.UserNums != null ? model.UserNums + 1 : 1;
                    if (userinfoservice.Update(model) > 0)
                    {
                        return Json(1);
                    }
                    else
                    {
                        return Json(2);
                    }

                }
                else
                {

                    return Json(0);
                }
            }
            else
            {

                return Json(-1);
            }
        }
        /// <summary>
        /// 搜索页面修改代码数据
        /// </summary>
        /// <param name="Title"></param>
        /// <param name="Code"></param>
        /// <param name="Visible"></param>
        /// <returns></returns>
        public string ModifyCode(string Title, string Code, string Visible)
        {
            var data = CodeData.Where(x => x.Title == Title).Single();

            if (code.ModifyData(new CodeModel {
                fTable = "Code_tb", Visible = Visible, Title = Title, Code = Code, objectId = data.objectId
            }))
            {
                data.Code = Code; data.Visible = Visible; data.Title = Title;
                //添加修改记录--------------------
                if (Visible == "Visible")
                {
                    OperationModel operationModel = new OperationModel("OperationNews_tb");
                    operationModel.User    = (string)SessionHelp.Get("UserName");
                    operationModel.Operate = "修改了";
                    operationModel.Title   = Title;
                    List <string> PathKind = new List <string>();
                    string        id;
                    id = KindData.Where(x => x.objectId == data.KindObjectId).Single().ParentId;
                    KindPath(id, ref PathKind);
                    operationModel.Kind = PathKind[PathKind.Count - 1];
                    operate.Create(operationModel);
                }
                //添加修改记录-------------------
                return("修改成功");
            }

            return("修改失败");
        }
        /// <summary>
        /// 添加代码
        /// </summary>
        /// <param name="Title"></param>
        /// <param name="Kind"></param>
        /// <param name="Code"></param>
        /// <param name="Author"></param>
        /// <returns></returns>
        public string AddData(CodeModel model)
        {
            try
            {
                string codeId, ParentId = model.objectId;//将model里的分类id提取出来作为父项分类id,之前暂存进去的
                string kindId;
                var    data = CodeData.Where(x => x.Title == model.Title).ToList();
                if (data.Count > 0)
                {
                    return("出错,此标题已存在");
                }
                KindModel kindmodel = new KindModel("Kind_tb");
                kindmodel.ParentId = ParentId;
                kindmodel.Name     = model.Title;
                kindId             = kind.Create(kindmodel);
                if (kindId != null)
                {
                    kindmodel.objectId = kindId;
                    KindData.Add(kindmodel);
                    model.KindObjectId = kindId;
                    codeId             = code.Create(model);;
                    if (codeId != null)
                    {
                        model.objectId = codeId;
                        CodeData.Add(model);
                        if (model.Visible == "Visible")
                        {
                            OperationModel operationModel = new OperationModel("OperationNews_tb");
                            operationModel.User = (string)SessionHelp.Get("UserName");
                            List <string> PathKind = new List <string>();
                            KindPath(ParentId, ref PathKind);
                            operationModel.Kind    = PathKind[PathKind.Count - 1];
                            operationModel.Operate = "添加了";
                            operationModel.Title   = model.Title;
                            operate.Create(operationModel);
                        }

                        return(kindId);
                    }
                    else
                    {
                        return("出错,添加代码成功,添加标题失败");
                    }
                }
                else
                {
                    return("出错,添加代码失败");
                }
            }
            catch (Exception e)
            {
                return("出错," + e.Message);
            }
        }
        public ActionResult Index(AccountViewModel account)
        {
            string name = Account.AllowAccount(account);

            if (name != null)
            {
                SessionHelp.Set("UserName", name);
                return(RedirectToAction("Index", "Home"));
            }

            ViewBag.error = "账号密码有误";
            return(View());
        }
Ejemplo n.º 5
0
 public ActionResult Index(AccountViewModel account)
 {
     if (account.User == "shajun")
     {
         if (account.Password == "sj76606729")
         {
             SessionHelp.Set("UserName", "沙俊");
             return(RedirectToAction("Index", "Home"));
         }
     }
     else if (account.User == "shajie")
     {
         if (account.Password == "190750991jie")
         {
             SessionHelp.Set("UserName", "沙杰"); return(RedirectToAction("Index", "Home"));
         }
     }
     else if (account.User == "chenyu")
     {
         if (account.Password == "CHENYU")
         {
             SessionHelp.Set("UserName", "陈煜"); return(RedirectToAction("Index", "Home"));
         }
     }
     else if (account.User == "xichaoqun")
     {
         if (account.Password == "XICHAOQUN")
         {
             SessionHelp.Set("UserName", "奚超群"); return(RedirectToAction("Index", "Home"));
         }
     }
     else if (account.User == "123321")
     {
         if (account.Password == "123321")
         {
             SessionHelp.Set("UserName", "通用账户");
         }
     }
     else if (account.User == "wangyongming")
     {
         if (account.Password == "WANGYONGMING")
         {
             SessionHelp.Set("UserName", "王永明");
             return(RedirectToAction("Index", "Home"));
         }
     }
     ViewBag.error = "账号密码有误";
     return(View());
 }
        /// <summary>
        /// 修改代码数据
        /// </summary>
        /// <param name="Title"></param>
        /// <param name="Code"></param>
        /// <param name="Id"></param>
        /// <returns></returns>
        public string ModifyCode(string Title, string Code, string Id, string OldTitle, string Visible)
        {
            if (Title != OldTitle)
            {
                var test = CodeData.Where(x => x.Title == Title).ToList();
                if (test.Count > 0)
                {
                    return(ToJson("出错,已存在改标题"));
                }
                KindModel kindmodel = new KindModel("Kind_tb");
                kindmodel.objectId = Id; kindmodel.Name = Title;
                if (kind.ModifyData(kindmodel))
                {
                    var data_ = KindData.Where(x => x.objectId == Id).Single();
                    data_.Name = Title;
                }
                else
                {
                    return(ToJson("出错,修改分类失败"));
                }
            }
            var       data  = CodeData.Where(x => x.Title == OldTitle).Single();
            CodeModel model = new CodeModel("Code_tb");

            model.objectId = data.objectId;
            model.Title    = Title;
            model.Code     = Code;
            model.Visible  = Visible;
            if (code.ModifyData(model))
            {
                data.Title = Title; data.Code = Code; data.Visible = Visible;
            }
            //添加修改记录--------------------
            if (Visible == "Visible")
            {
                OperationModel operationModel = new OperationModel("OperationNews_tb");
                operationModel.User    = (string)SessionHelp.Get("UserName");
                operationModel.Operate = "修改了";
                operationModel.Title   = Title;
                List <string> PathKind = new List <string>();
                string        id;
                id = KindData.Where(x => x.objectId == Id).Single().ParentId;
                KindPath(id, ref PathKind);
                operationModel.Kind = PathKind[PathKind.Count - 1];
                operate.Create(operationModel);
            }
            //添加修改记录-------------------
            return(ToJson("修改成功"));
        }
Ejemplo n.º 7
0
        public string Ingresar(string us, string pw)
        {
            string Respuesta = "";
            var    user      = db.t_Usuarios.FirstOrDefault(x => x.Usuario == us && x.Clave == pw);

            if (user != null)
            {
                SessionHelp.AddUserToSession(us);
                Respuesta = "Correcto_" + user;
            }
            else
            {
                Respuesta = "Incorrecto_" + user;
            }
            return(Respuesta);
        }
Ejemplo n.º 8
0
 public ActionResult UpdatePassWord(string oldPass, string newPass)
 {
     var id = SessionHelp.GetSession("UID");
     if (id == "")
     {
         //当前账号信息已失效,提示用户重新登录
         return Json(-2);
     }
     else
     {
         //对比新旧密码
         var model = userinfoservice.GetModel(int.Parse(id));
         if (model.PassWord == oldPass)
         {
             model.PassWord = newPass;
             model.UpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
             //修改
             if (userinfoservice.UpdatePassWord(model) > 0)
             {
                 //修改成功
                 return Json(0);
             }
             else
             {
                 //发生未知错误
                 return Json(1);
             }
         }
         else
         {
             //旧密码输入有误
             return Json(-1);
         }
     }
    
 }
        /// <summary>
        /// 获取操作记录
        /// </summary>
        /// <returns></returns>
        ///

        public string GetAllOperate()
        {
            DateTime date = DateTime.Now.AddDays(-5);
            var      data = (from a in operate.GetAll("OperationNews_tb") where Convert.ToDateTime(a.createdAt) > date && a.User != (string)SessionHelp.Get("UserName") orderby a.createdAt descending select a).ToList();

            return(JsonConvert.SerializeObject(data));
        }
Ejemplo n.º 10
0
        //获取单条数据

        //获取当前登陆用户
        public string GetUserName()
        {
            string username = (string)SessionHelp.Get("UserName");

            return(username);
        }
Ejemplo n.º 11
0
        ///搜索
        public string SearchTitle(string Title, string Select)
        {
            List <ListData> result = new List <ListData>();//搜索完返回结果

            if (KindCodeOperation.CodeData == null)
            {
                return("还未初始化,请等待");
            }

            if (Select == "所有")//判断是否为所有
            {
                Titles("无");
            }
            else
            {
                string id = (from a in KindCodeOperation.KindData where a.ParentId == "无" && a.Name == Select select a).Single().objectId;
                Titles(id);
            }
            if (PublicPermission((string)SessionHelp.Get("UserName")))//判断是否为一半账户,分两组数据类分别存共有和私有
            {
                int i = 0;
                do
                {
                    string data = (string)selectTitles[i];
                    if (KindCodeOperation.CodeData.Where(x => x.Title == data).Single().Visible == "Invisible")
                    {
                        selectTitles.Remove(data); i--;
                    }
                    i++;
                } while (i < selectTitles.Count);
            }
            result = SearchEngines.Search(selectTitles, Title); //开始搜索并返回结果
            foreach (var a in result)                           //使得前端高亮匹配显示
            {
                List <int> count = new List <int>();
                for (int i = 0; i < a.Word.Length - 1; i++)
                {
                    int str = a.Search.ToLower().IndexOf(a.Word[i]);
                    for (int j = str; j < str + a.Word[i].Length; j++)
                    {
                        count.Add(j);
                    }
                }
                string Result = "<li onclick=\"ShowData(&quot;" + a.Search + "&quot;,this)\">";
                for (int i = 0; i < a.Search.Length; i++)
                {
                    if (count.Contains(i))
                    {
                        Result += "<div style=\"color:red\">" + a.Search.Substring(i, 1) + "</div>";
                    }
                    else
                    {
                        Result += "<div>" + a.Search.Substring(i, 1) + "</div>";
                    }
                }
                List <string> PathKind = new List <string>();//找出此标题的父分类
                var           data     = KindCodeOperation.CodeData.Where(x => x.Title == a.Search).Single();
                string        id       = KindCodeOperation.KindData.Where(x => x.objectId == data.KindObjectId).Single().ParentId;
                KindCodeOperation.KindPath(id, ref PathKind);
                Result += "<div class='seach-move'><div style='float:none'>分类:" + PathKind[PathKind.Count - 1] + "</div><div style='float:none'>作者:" + data.Author + "</div></div>";
                Result += "</li>";
                list.Add(new ReturnTitle()
                {
                    title = Result
                });
            }
            string jsonData = JsonConvert.SerializeObject(list);

            return(jsonData);
        }
Ejemplo n.º 12
0
 // GET: login
 public ActionResult Index(string ReturnUrl)
 {
     SessionHelp.Remove("UserName");
     ViewBag.ReturnUrl = ReturnUrl;
     return(View());
 }
        /// <summary>
        /// Json序列化所有分类
        /// </summary>
        /// <param name="table"></param>
        /// <returns></returns>
        public string ToKindJson(IEnumerable <KindModel> KindTable, IEnumerable <CodeModel> CodeTable)
        {
            List <TreeModel> list = new List <TreeModel>();

            foreach (KindModel row in KindTable)
            {
                string Color = "blue";
                string Icon  = "glyphicon glyphicon-folder-open";
                bool   pri   = false;//判断是否为私有账户,true为私有账户,跳过添加
                if (row.ParentId == "无")
                {
                    Color = "brown"; Icon = "glyphicon glyphicon-folder-open";
                }
                else
                {
                    var data = CodeData.Where(x => x.KindObjectId == row.objectId).ToList();
                    if (data.Count == 1)
                    {
                        if (data.First().Visible == "Invisible" && PublicPermission((string)SessionHelp.Get("UserName")))
                        {
                            pri = true;
                        }
                        Color = "black"; Icon = "glyphicon glyphicon-pencil";
                    }
                    else
                    {
                        foreach (KindModel row_ in KindTable)
                        {
                            if (row_.ParentId.ToString() == row.objectId)
                            {
                                Color = "#4B0082"; Icon = "glyphicon glyphicon-folder-open"; break;
                            }
                        }
                    }
                    if (pri)
                    {
                        continue;
                    }
                }

                list.Add(new TreeModel()
                {
                    Id       = row.objectId,
                    ParentId = row.ParentId,
                    text     = row.Name,
                    color    = Color,
                    icon     = Icon
                });
            }
            string JsonData = JsonConvert.SerializeObject(list);

            return(JsonData);
        }