Пример #1
0
        /// <summary>
        /// 创建Excel文件下载模型
        /// </summary>
        /// <param name="ms"></param>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public static DownLoadFileModel CreateDownLoadExcelFileModel(this MemoryStream ms, string fileName)
        {
            DownLoadFileModel dlfm = new DownLoadFileModel(2);

            if (ms == null)
            {
                return(dlfm.Default());
            }
            dlfm.FileStream       = ms;
            dlfm.ContentType      = "application/vnd.ms-excel";
            dlfm.FileDownLoadName = fileName + ".xls";
            return(dlfm);
        }
Пример #2
0
        /// <summary>
        /// 创建异常信息下载模型
        /// </summary>
        /// <param name="exceptionId"></param>
        /// <returns></returns>
        public static DownLoadFileModel CreateExceptionDownLoadFileModel(this string exceptionId)
        {
            DownLoadFileModel dlfm         = new DownLoadFileModel();
            string            errorLogPath = @"C:\EicSystem\WebPlatform\ErrorMsgTrace\";

            errorLogPath.GetFiles().ForEach(f =>
            {
                if (f.IndexOf(exceptionId, StringComparison.CurrentCulture) > 0)
                {
                    StringBuilder sbMsg = new StringBuilder();
                    f.GetFileLines().ForEach(line =>
                    {
                        sbMsg.AppendLine(line);
                    });
                    dlfm = dlfm.Default(sbMsg.ToString());
                    File.Delete(f);
                }
                else
                {
                    dlfm = dlfm.Default();
                }
            });
            return(dlfm);
        }