Exemple #1
0
        /// <summary>
        /// 导出数据到Excel表 导出的excel表为 .xls 格式
        /// </summary>
        /// <returns></returns>
        public FileResult ExportData()
        {
            var currentUser = LoginManager.GetCurrentUser();

            try
            {
                List <Information> informationList = _informationBLL.GetInformation(DataCacheManager.GetDataCache(CachaKey.Key));
                List <CustomItem>  customItemList  = new List <CustomItem>();
                _customItemBLL.GetCustomItems(currentUser.Account, ref customItemList);
                List <CustomItemValue> customItemValueList = new List <CustomItemValue>();

                foreach (var item in informationList)
                {
                    foreach (var ci in customItemList)
                    {
                        var tmp = _customItemValueBLL.GetCustomItemValueByCustomItemIdAndInforId(ci.Id, item.Id);

                        if (tmp != null)
                        {
                            customItemValueList.Add(tmp);
                        }
                    }
                }

                MemoryStream ms = _excelManager.DataTOExcel(informationList, customItemList, customItemValueList);

                return(File(ms, "application/vnd.ms-excel", TimeManager.GetTimeSpan() + ".xls"));
            }
            catch (Exception ex)
            {
                LogHelper.writeLog_error(ex.Message);
                LogHelper.writeLog_error(ex.StackTrace);
                throw;
            }
        }
Exemple #2
0
        public ActionResult SearchCache()
        {
            AjaxResult ar = new AjaxResult();

            try
            {
                List <InformationModel> modelList = DataCacheManager.GetDataCache(CachaKey.Key);
                ar.state = ResultType.success.ToString();
                ar.data  = modelList.ToJson();
            }
            catch (Exception ex)
            {
                LogHelper.writeLog_error(ex.Message);
                LogHelper.writeLog_error(ex.StackTrace);

                ar.state   = ResultType.error.ToString();
                ar.message = "获取缓存数据失败";
            }

            return(Json(ar, JsonRequestBehavior.AllowGet));
        }