/// <summary>
        /// </summary>
        /// <param name="keyword">
        /// </param>
        /// <param name="ordering">
        /// </param>
        /// <param name="pageIndex">
        /// </param>
        /// <param name="search">
        /// </param>
        /// <param name="toExcelFile">
        /// </param>
        /// <returns>
        /// </returns>
        public async Task <IActionResult> Index(string keyword, string ordering, int pageIndex = 1, bool search = false, bool toExcelFile = false)
        {
            var model = jsonDataService.GetAll <Holiday>()

                        .Select(
                a =>
                new
            {
                Title     = SqlDbFunctions.JsonValue(a.JsonDataStr, "$.Title"),
                Work      = SqlDbFunctions.JsonValue(a.JsonDataStr, "$.Work"),
                StartDate = DateTime.Parse(SqlDbFunctions.JsonValue(a.JsonDataStr, "$.StartDate")),
                EndDate   = DateTime.Parse(SqlDbFunctions.JsonValue(a.JsonDataStr, "$.EndDate")),
                CreatedBy = a.UserCreatedBy.UserName,
                a.CreatedDateTime,
                UpdatedBy = a.UserUpdatedBy.UserName,
                a.UpdatedDateTime,
                a.Remark,
                a.Id
            }).Search(keyword);

            if (search)
            {
                model = model.Search(Request.Query);
            }
            if (!string.IsNullOrEmpty(ordering))
            {
                model = model.OrderBy(ordering);
            }
            if (toExcelFile)
            {
                return(model.ToExcelFile());
            }
            return(View(model.PageResult(pageIndex, 20)));
        }
示例#2
0
        public async Task <IActionResult> Create(string file)
        {
            var excel = new ExcelPackage(Request.Form.Files[0].OpenReadStream());

            var count = 0;

            for (var i = 2; i <= excel.Workbook.Worksheets[0].Dimension.End.Row; i++)
            {
                var dic = new DataDictionary()
                {
                    Category = excel.Workbook.Worksheets[0].Cells[i, 1].Text,
                    Name     = excel.Workbook.Worksheets[0].Cells[i, 2].Text,
                    SystemId = excel.Workbook.Worksheets[0].Cells[i, 3].Text,
                    Enable   = (bool)excel.Workbook.Worksheets[0].Cells[i, 4].Value,
                    Remark   = excel.Workbook.Worksheets[0].Cells[i, 5].Text,
                };

                //去重

                if (!jsonDataService.GetAll <DataDictionary>(a => SqlDbFunctions.JsonValue(a.JsonDataStr, "$.Category") == dic.Category && SqlDbFunctions.JsonValue(a.JsonDataStr, "$.Name") == dic.Name && SqlDbFunctions.JsonValue(a.JsonDataStr, "$.SystemId") == dic.SystemId).Any())
                {
                    //添加
                    await jsonDataService.SaveAsync(null, dic);

                    count++;
                }
            }

            await _unitOfWork.CommitAsync();

            TempData[AlertType.Alerts.Success] = count + "行数据导入成功!";

            return(RedirectToAction("Index"));
        }
        public async Task <IActionResult> Get(string keyword, string Category, bool?isEnable)
        {
            var model = jsonDataService.GetAll <DataDictionary>().Select(a => new
            {
                Category = SqlDbFunctions.JsonValue(a.JsonDataStr, "$.Category"),

                Name = SqlDbFunctions.JsonValue(a.JsonDataStr, "$.Name"),

                SystemId = SqlDbFunctions.JsonValue(a.JsonDataStr, "$.SystemId"),

                Enable = Convert.ToBoolean(SqlDbFunctions.JsonValue(a.JsonDataStr, "$.Enable")),

                a.Id
            }).Search(keyword);

            model = model.Where(a => a.Category == Category);

            if (isEnable.HasValue)
            {
                model = model.Where(a => a.Enable == isEnable.Value);
            }

            model = model.OrderBy(a => a.SystemId);

            _IResInfo.Data = model;

            return(Ok(_IResInfo));
        }
        /// <summary>
        /// </summary>
        /// <param name="keyword">
        /// </param>
        /// <param name="ordering">
        /// </param>
        /// <param name="pageIndex">
        /// </param>
        /// <param name="pageSize">
        /// </param>
        /// <param name="search">
        /// </param>
        /// <returns>
        /// </returns>
        public async Task <IActionResult> IndexAsync(string keyword, string ordering, int pageIndex = 1, int pageSize = 20, bool search = false, bool toExcelFile = false)
        {
            var model = jsonDataService.GetAll <KnowledgeBase>()
                        .Select(
                a =>
                new
            {
                KnowledgeCategory = SqlDbFunctions.JsonValue(a.JsonDataStr, "$.KnowledgeCategorys"),
                Title             = SqlDbFunctions.JsonValue(a.JsonDataStr, "$.Title"),
                Content           = SqlDbFunctions.JsonValue(a.JsonDataStr, "$.Content"),
                UsageCount        = SqlDbFunctions.JsonValue(a.JsonDataStr, "$.UsageCount"),
                a.UserCreatedBy,
                a.CreatedDateTime,
                a.UserUpdatedBy,
                a.UpdatedDateTime,
                a.Id
            }).Search(keyword);

            if (search)
            {
                model = model.Search(Request.Query);
            }
            if (!string.IsNullOrEmpty(ordering))
            {
                model = model.OrderBy(ordering);
            }

            if (toExcelFile)
            {
                return(model.ToExcelFile());
            }

            return(View(model.PageResult(pageIndex, pageSize)));
        }
示例#5
0
        /// <summary>
        /// </summary>
        /// <param name="keyword">搜索关键词
        /// </param>
        /// <param name="ordering">排序
        /// </param>
        /// <param name="pageIndex">当前页
        /// </param>
        /// <param name="pageSize">每页大小
        /// </param>
        /// <param name="search">多条件搜索
        /// </param>
        /// <param name="recyclebin">已删除的数据</param>
        /// <param name="toExcelFile">导出到excel</param>
        /// <returns>
        /// </returns>
        public async Task <IActionResult> IndexAsync(string keyword, string ordering, int pageIndex = 1, int pageSize = 20, bool search = false, bool recyclebin = false, bool toExcelFile = false)
        {
            ViewBag.Import = true; //允许导入数据

            var DataDictionarys = jsonDataService.GetAll <DataDictionary>();

            //数据回收站
            if (recyclebin)
            {
                DataDictionarys = DataDictionarys.IgnoreQueryFilters().Where(a => a.IsDeleted == true);
            }

            var model = DataDictionarys
                        .Select(
                a =>
                new
            {
                Category = SqlDbFunctions.JsonValue(a.JsonDataStr, "$.Category"),
                Name     = SqlDbFunctions.JsonValue(a.JsonDataStr, "$.Name"),
                SystemId = SqlDbFunctions.JsonValue(a.JsonDataStr, "$.SystemId"),
                Enable   = Convert.ToBoolean(SqlDbFunctions.JsonValue(a.JsonDataStr, "$.Enable")),
                Remark   = SqlDbFunctions.JsonValue(a.JsonDataStr, "$.Remark"),
                a.UserCreatedBy,
                a.CreatedDateTime,
                a.UserUpdatedBy,
                a.UpdatedDateTime,
                a.Id
            }).Search(keyword);

            if (search)
            {
                model = model.Search(Request.Query);
            }

            if (!string.IsNullOrEmpty(ordering))
            {
                model = model.OrderBy(ordering);
            }
            else
            {
                model = model.OrderBy(a => a.Category).ThenBy(a => a.SystemId);
            }

            if (toExcelFile)
            {
                return(model.ToExcelFile());
            }

            return(View(model.PageResult(pageIndex, pageSize)));
        }
        /// <summary>
        /// </summary>
        /// <param name="keyword">
        /// </param>
        /// <param name="ordering">
        /// </param>
        /// <param name="pageIndex">
        /// </param>
        /// <param name="pageSize">
        /// </param>
        /// <param name="search">
        /// </param>
        /// <returns>
        /// </returns>
        public async Task <IActionResult> IndexAsync(string keyword, string ordering, int pageIndex = 1, int pageSize = 20, bool search = false, bool toExcelFile = false)
        {
            var model = jsonDataService.GetAll <CityCode>()
                        .Select(
                a =>
                new
            {
                Name     = SqlDbFunctions.JsonValue(a.JsonDataStr, "$.Name"),
                ZipCode  = SqlDbFunctions.JsonValue(a.JsonDataStr, "$.ZipCode"),
                SystemId = SqlDbFunctions.JsonValue(a.JsonDataStr, "$.SystemId"),
                Enable   = SqlDbFunctions.JsonValue(a.JsonDataStr, "$.Enable"),
                a.UserCreatedBy,
                a.CreatedDateTime,
                a.UserUpdatedBy,
                a.UpdatedDateTime,
                a.Id
            }).Search(keyword);

            if (search)
            {
                model = model.Search(Request.Query);
            }
            if (!string.IsNullOrEmpty(ordering))
            {
                model = model.OrderBy(ordering);
            }
            else
            {
                model = model.OrderBy(a => a.SystemId);
            }
            if (toExcelFile)
            {
                return(model.ToExcelFile());
            }

            return(View(model.PageResult(pageIndex, pageSize)));
        }
        public async Task <IActionResult> EditAsync(string id, KnowledgeBase collection)
        {
            if (!ModelState.IsValid)
            {
                ViewBag.KnowledgeCategorys = new MultiSelectList(jsonDataService.GetAll <KnowledgeCategory>(a => SqlDbFunctions.JsonValue(a.JsonDataStr, "$.Enable") == "True").OrderBy(a => SqlDbFunctions.JsonValue(a.JsonDataStr, "$.SystemId")).Select(a => new { a.Id, Name = "(" + SqlDbFunctions.JsonValue(a.JsonDataStr, "$.SystemId") + ")" + SqlDbFunctions.JsonValue(a.JsonDataStr, "$.Name"), }), "Name", "Name", collection.KnowledgeCategorys);

                return(View(collection));
            }

            await jsonDataService.SaveAsync(id, collection);

            await _unitOfWork.CommitAsync();

            return(new EditSuccessResult(id));
        }
        // GET: /Platform/iDepartment/Edit/5
        /// <summary>
        /// </summary>
        /// <param name="id">
        /// </param>
        /// <returns>
        /// </returns>
        public async Task <IActionResult> EditAsync(string id)
        {
            var item = new KnowledgeBase();

            if (!string.IsNullOrEmpty(id))
            {
                item = JsonConvert.DeserializeObject <KnowledgeBase>(jsonDataService.FindAsync(id).Result.JsonDataStr);
            }

            ViewBag.KnowledgeCategorys = new MultiSelectList(jsonDataService.GetAll <KnowledgeCategory>(a => SqlDbFunctions.JsonValue(a.JsonDataStr, "$.Enable") == "True").OrderBy(a => SqlDbFunctions.JsonValue(a.JsonDataStr, "$.SystemId")).Select(a => new { a.Id, Name = "(" + SqlDbFunctions.JsonValue(a.JsonDataStr, "$.SystemId") + ")" + SqlDbFunctions.JsonValue(a.JsonDataStr, "$.Name"), }), "Name", "Name", item.KnowledgeCategorys);

            return(View(item));
        }