Esempio n. 1
0
        public async Task <IActionResult> IndexLogin(string LogNumber, string PassWord)
        {
            HelpStaffs StaffsDb = new HelpStaffs();
            var        user     = StaffsDb.LoadEntityies(u => u.JobNumber == LogNumber);

            if (user == null)
            {
                return(Json(ResultMsg.FormatResult(400, "存在错误!", "不存在该用户!")));
            }
            else
            {
                user = StaffsDb.LoadEntityies(u => u.JobNumber == LogNumber && u.Password == PassWord);
                if (user == null)
                {
                    return(Json(ResultMsg.FormatResult(400, "存在错误!", "密码错误")));
                }

                foreach (var item in user.ToList())
                {
                    ConstVal.Roles = item.Roleds.ToString();
                }

                var claims = new ClaimsIdentity(CookieAuthenticationDefaults.AuthenticationScheme);
                //记住用户名
                claims.AddClaim(new Claim(ClaimTypes.Name, LogNumber));
                //记录用户角色
                claims.AddClaim(new Claim(ClaimTypes.Role, ConstVal.Roles));
                //保存用户信息
                claims.AddClaim(new Claim(ClaimTypes.IsPersistent, $"{true}"));
                var claimsPrincipal = new ClaimsPrincipal(claims);
                await HttpContext.SignInAsync(claimsPrincipal);

                return(Json(ResultMsg.FormatResult(200)));
            }
        }
Esempio n. 2
0
 public IActionResult ContentPage(string Stides, string interest, string TopicName, string CharactersSize, string OptionSet)
 {
     //return Json(new { string1= Stides, string2= interest, string3= TopicName, string4= CharactersSize, string5= OptionSet, string6= Isempty });
     try
     {
         //name关键字生成规则【题号+选项ID+10-99随机数】
         string fromName = Stides + interest + Seesion.sj.Next(10, 100).ToString();
         CharactersSize = CharactersSize == null ? "0" : CharactersSize;
         Stides         = Stides == null ? "0" : Stides;
         Topicgroups InsertModel = new Topicgroups()
         {
             id             = Guid.NewGuid().ToString(),
             TopicName      = TopicName,
             CharactersSize = CharactersSize,
             SetsettingId   = interest,
             OptionText     = OptionSet,
             Stide          = int.Parse(Stides),
             FromName       = fromName,
             //  Isnull = Isempty == null ? "空" : Isempty,
             FromID = Seesion.FromIds
         };
         int request = HelpTopicgroup.Insert(InsertModel);
         if (request > 0)
         {
             return(Json(data: ResultMsg.FormatResult()));
         }
         return(Json(data: ResultMsg.FormatResult(0, "插入数据库失败", "错误")));
     }
     catch (Exception ex)
     {
         return(Json(data: ResultMsg.FormatResult(ex)));
     }
 }
Esempio n. 3
0
        public ActionResult Index(string userName, string passWord)
        {
            if (userName != null)
            {
                try
                {
                    /**
                     * 登陆后获取token ,
                     * 获取传递的token,去保存用户信息
                     **/
                    ClaimsIdentity identity = new ClaimsIdentity("Forms");
                    identity.AddClaim(new Claim(ClaimTypes.Sid, "Admin"));
                    identity.AddClaim(new Claim(ClaimTypes.Name, userName));
                    ClaimsPrincipal principal = new ClaimsPrincipal(identity);
                    HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, principal);

                    Seesion.UserName = User.Identity.Name;
                    var queryId = Databases.Instance.Query <Formsettings>("select FormID from `qp.formsettings` where FormCreater = '" + userName + "'").Single().FormID;
                    Seesion.FromIds = queryId;
                }
                catch (Exception ex)
                {
                    Seesion.FromIds = "1";
                }
                return(Redirect(Url.Action("Index", "Home")));
            }
            else
            {
                return(Json(ResultMsg.FormatResult(0, "登陆失败", "失败")));
            }
        }
Esempio n. 4
0
 public IActionResult AddSurvey(string title, string brief, string copy)
 {
     try
     {
         // 表单ID
         string       formId      = Guid.NewGuid().ToString();
         Formsettings InsertModel = new Formsettings()
         {
             FormID         = formId,
             FormNote       = brief,
             FormTitle      = title,
             FormCopyright  = copy,
             FormCreateDate = DateTime.Parse(DateTime.Now.ToShortDateString()),
             FormStatus     = 1,
             FormCreater    = Seesion.UserName
         };
         //给全局的表单ID赋值
         var InsertState = HelpFormsettings.Insert(InsertModel);
         Seesion.FromIds = formId;
         if (InsertState > 0)
         {
             return(Json(ResultMsg.FormatResult(200, Seesion.FromIds, Seesion.UserName)));
         }
         return(Json(ResultMsg.FormatResult(0, "数据添加失败", "失败")));
     }
     catch (Exception el)
     {
         return(Json(ResultMsg.FormatResult(el)));
     }
 }
Esempio n. 5
0
 /// <summary>
 /// 删除
 /// </summary>
 /// <returns></returns>
 public IActionResult Delete(string id)
 {
     if (HelpTopicgroup.Delete(id))
     {
         return(Json(ResultMsg.FormatResult()));
     }
     return(Json(ResultMsg.FormatResult(0, "删除失败", "删除失败")));
 }
Esempio n. 6
0
        public IActionResult Index(IFormCollection model, List <IFormFile> files)
        {
            //在文件上传的时候, 只能采用表单的提交后台才能够获取到文件?? 而Ajax的方式不行?
            string paths = FileSave(files);
            Dictionary <string, string> keyValuePairs = new Dictionary <string, string>()
            {
            };

            foreach (var item in model)
            {
                // 去掉莫名上传的Cookies防伪标志
                if (item.Key.IndexOf("_") != 0)
                {
                    //前端会上传类型路径的字符串,如果存在就替换成上传路径!
                    if (item.Value.ToString().IndexOf("\\") > -1)
                    {
                        keyValuePairs.Add(item.Key, paths);
                    }
                    else
                    {
                        string Value = item.Value.ToString() == "" ? "..." : item.Value.ToString();
                        //keyValuePairs.Add(item.Key, item.Value);
                        keyValuePairs.Add(item.Key, Value);
                    }
                }
            }
            AnswerGroup InsertModel = new AnswerGroup()
            {
                id     = Guid.NewGuid().ToString(),
                FromID = Seesion.FromIds,
                Answer = JObject.FromObject(new { FormName = keyValuePairs.Keys, Values = keyValuePairs.Values }).ToString()
            };

            try
            {
                int flage = HelpAnswerGroup.Insert(InsertModel);
                if (flage > 0)
                {
                    //RedirectToAction 只能够在本页面跳转
                    return(RedirectToAction("Succeed"));
                }
                return(Json("插入失败"));
            }
            catch (Exception el)
            {
                return(Json(ResultMsg.FormatResult(el)));
            }
        }
Esempio n. 7
0
        /// <summary>
        /// 动态生成表格的数据
        /// </summary>
        /// <param name="page"></param>
         /// <param name="rows"></param>
        /// <returns></returns>
        public ActionResult GetJson(int?page, int?rows)
        {
            try
            {
                page = page == null ? 1 : page;  //第几页
                rows = rows == null ? 10 : rows; //行数
                try
                {
                    //后台接受前台数据是一个对象,所以先要实例化Tostring()
                    EndDate   = Request.Form["EndDate"].ToString() == string.Empty ? EndDate : Request.Form["EndDate"].ToString();
                    StartDate = Request.Form["StartDate"].ToString() == string.Empty ? StartDate : Request.Form["StartDate"].ToString();
                    Queryid   = Request.Form["Queryid"].ToString() == string.Empty ? Queryid : Request.Form["Queryid"].ToString();
                    SelectVal = Request.Form["SelectVal"].ToString() == string.Empty ? SelectVal : Request.Form["SelectVal"].ToString();
                    InputVals = Request.Form["inputVals"].ToString() == string.Empty ? InputVals : Request.Form["inputVals"].ToString();
                    shopID    = Request.Form["shopID"].ToString() == string.Empty ? "" : Request.Form["shopID"].ToString();
                }
                catch (Exception ex)
                {
                    return(Json(data: new { exs = ex.Message }));
                }

                StaffInfoparam staffInfoparam = new StaffInfoparam()
                {
                    _endDate   = DateTime.Parse(EndDate),   //结束时间
                    _startDate = DateTime.Parse(StartDate), //起始时间
                    _queryName = Queryid,                   //时间查询字段
                    _rows      = (int)rows,                 //行数
                    _page      = (int)page,                 //页数
                    _total     = 0,                         //总行数
                    _fileName  = "",                        //导出文件名
                    _selectVal = SelectVal,                 //输入查询字段
                    _inputVals = InputVals,                 //用户信息
                    _shopID    = shopID                     // 门店ID
                };

                // return Json(data: new { shopids = staffInfoparam._shopID }); //??? 单独测试,存在数据
                var json = helpStaffs.Contaion(_hostingEnvironment, staffInfoparam, export);
                return(Json(new { rows = json, total = staffInfoparam._total }));
            }
            catch (Exception ex)
            {
                return(Json(ResultMsg.FormatResult(ex)));
            }
        }
Esempio n. 8
0
        /// <summary>
        ///添加提项
        /// </summary>
        /// <returns></returns>
        public ActionResult ContentPage()
        {
            // 赋值题号
            try
            {
                int order = int.Parse(Databases.Instance.Query <Topicgroups>("select Stide from `qp.topicgroup`").Max(u => u.Stide).ToString()) + 1;
                ViewData["stide"] = order.ToString();
            }
            catch (Exception el)
            {
                return(Json(data: ResultMsg.FormatResult(el)));
            }
            List <Setsetting> query = new List <Setsetting>()
            {
            };

            //模型类里面的字段要和表结构要一一对应
            query             = Databases.Instance.Query <Setsetting>("select id,TopicClass from `qp.setsetting`").ToList();
            ViewData["Group"] = new SelectList(Dropdown.createDropdown(query), "Key", "Value");
            return(View());
        }
Esempio n. 9
0
        /// <summary>
        ///  导出数据
        /// </summary>
        /// <returns></returns>
        public IActionResult GetExcel()
        {
            export = Request.Form["export"];
            StaffInfoparam staffInfoparam = new StaffInfoparam()
            {
                _endDate   = DateTime.Parse(EndDate),
                _startDate = DateTime.Parse(StartDate),
                _queryName = Queryid,
                _rows      = (int)rows,
                _page      = (int)page,
                _total     = 0,
                _fileName  = ""
            };

            var json = helpStaffs.Contaion(_hostingEnvironment, staffInfoparam, export);

            if (staffInfoparam._fileName == "")
            {
                return(Json(ResultMsg.FormatResult(404, "没有找到该文件啊", "处理有误")));
            }

            return(File(staffInfoparam._fileName, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"));
        }
Esempio n. 10
0
 public IActionResult Edit()
 {
     try
     {
         var topicID        = Request.Form["id"];
         var stIdes         = Request.Form["Stide"];
         var stsettingId    = Request.Form["SetsettingId"];
         var topicName      = Request.Form["TopicName"];
         var charactersSize = Request.Form["CharactersSize"];
         var optionText     = Request.Form["OptionText"];
         ///题号修改规则
         /// 先判断该题号是否修改,如果没有动直接修改全部
         /// 如果题号不一致 , 去查询是否存在改动题号, 题号存在,内容和题号全部替换  不存在直接修改题号
         if (stIdes == Seesion._stide)
         {
             string      fromName    = Seesion._stide + stsettingId + Seesion.sj.Next(10, 100).ToString();
             Topicgroups updateModel = new Topicgroups()
             {
                 TopicName      = topicName,
                 CharactersSize = charactersSize,
                 SetsettingId   = stsettingId,
                 OptionText     = optionText,
                 Stide          = int.Parse(Seesion._stide),
                 id             = topicID,
                 FromName       = fromName,
                 FromID         = Seesion.FromIds
             };
             if (HelpTopicgroup.Update(updateModel))
             {
                 return(RedirectToAction("Index"));
             }
             return(Json(ResultMsg.FormatResult(0, "修改失败", "修改失败")));
         }
         else
         {
             //把用户修改的题号 拿去数据库中对比,如果存在就两两相互替换,不修改其他内容,不存在就直接修改,并且修改所用
             var existStide = Databases.Instance.Query <Topicgroups>("select  id,TopicName,CharactersSize,SetsettingId ,OptionText ,Stide from  `qp.topicgroup`  where Stide =@Stide", new
             {
                 Stide = stIdes
             });
             if (existStide.Count() > 0)
             {
                 try
                 {
                     Topicgroups updateModel;
                     foreach (var item in existStide)
                     {
                         string fromNamed = Seesion._stide + item.SetsettingId + Seesion.sj.Next(10, 100).ToString();
                         // 更改成被修改的题号,同时内容也全部替换
                         updateModel = new Topicgroups()
                         {
                             id             = Guid.NewGuid().ToString(),
                             TopicName      = item.TopicName,
                             CharactersSize = item.CharactersSize,
                             SetsettingId   = item.SetsettingId,
                             OptionText     = item.OptionText,
                             Stide          = int.Parse(Seesion._stide),
                             FromName       = fromNamed,
                             FromID         = Seesion.FromIds
                         };
                         HelpTopicgroup.Insert(updateModel);
                         HelpTopicgroup.Delete(item.id);
                     }
                     HelpTopicgroup.Delete(topicID);
                     //就相当于新增加一组数据,把新的题号带上 !!!!
                     string fromName = stIdes + stsettingId + Seesion.sj.Next(10, 100).ToString();
                     updateModel = new Topicgroups()
                     {
                         TopicName      = topicName,
                         CharactersSize = charactersSize,
                         SetsettingId   = stsettingId,
                         OptionText     = optionText,
                         id             = topicID,
                         Stide          = int.Parse(stIdes),
                         FromName       = fromName,
                         FromID         = Seesion.FromIds
                     };
                     HelpTopicgroup.Insert(updateModel);
                     return(View("Index"));
                 }
                 catch (Exception el)
                 {
                     return(Json(ResultMsg.FormatResult(el)));
                 }
             }
             else
             {
                 //不存在这个题号的时候直接修改题号不需要搭理内容
                 try
                 {
                     Databases.Instance.Execute("update `qp.topicgroup` set Stide =@Stide where id=@id", new
                     {
                         id    = topicID,
                         Stide = stIdes
                     });
                     return(RedirectToAction("Index"));
                 }
                 catch (Exception el)
                 {
                     return(Json(ResultMsg.FormatResult(el)));
                 }
             }
         }
     }
     catch (Exception el)
     {
         return(Json(ResultMsg.FormatResult(el)));
     }
 }