コード例 #1
0
 public MainThread(string pID, PTBase pInfo)
 {
     this.PTName = pInfo.PTName;
     ConfigurationStatus.LotteryConfig config = AppInfo.Current.LotteryDic[pID];
     this.downCode   = new DownData(this, config.Type, pInfo, config.RefreshExpect, config.SaveExpect);
     this.loadThread = new Thread(new ParameterizedThreadStart(this.LoadThread));
     this.loadThread.IsBackground = true;
     this.loadThread.Start(true);
     this.cyclicThread = new Thread(new ThreadStart(this.CyclicThread));
     this.cyclicThread.IsBackground = true;
     this.cyclicThread.Start();
     this.verifyCodeThread = new Thread(new ThreadStart(this.VerifyCodeThread));
     this.verifyCodeThread.IsBackground = true;
     this.verifyCodeThread.Start();
     this.checkPTLineThread = new Thread(new ThreadStart(this.CheckPTLineThread));
     this.checkPTLineThread.IsBackground = true;
     this.checkPTLineThread.Start();
     this.webDataThread = new Thread(new ThreadStart(this.WebDataThread));
     this.webDataThread.IsBackground = true;
     this.webDataThread.Start();
     this.ThreadList.Add(this.loadThread);
     this.ThreadList.Add(this.cyclicThread);
     this.ThreadList.Add(this.verifyCodeThread);
     this.ThreadList.Add(this.checkPTLineThread);
     this.ThreadList.Add(this.webDataThread);
     this.ThreadList.Add(this.loadConfigurationThread);
     this.ThreadList.Add(this.refreshLSDataThread);
     this.ThreadList.Add(this.refreshTJDataThread);
 }
コード例 #2
0
        public DownData DownLoadRecord(int intFileId)
        {
            ExportData expData = _exportDataRepository.Get(intFileId);
            var        user    = GetCurrentUserAsync().Result;//当前登录者

            if (expData == null || expData.Id <= 0)
            {
                EasyMan.Dtos.ErrorInfo err = new EasyMan.Dtos.ErrorInfo();
                err.IsError = false;
                err.Message = "导出文件后,保存至下载记录表数据库出错";
                return(null);
            }
            //数据下载记录表
            DownData downData = new DownData();

            downData.DisplayName   = expData.DisplayName;
            downData.DownBeginTime = DateTime.Now;
            downData.DownEndTime   = DateTime.Now;
            downData.ExportDataId  = intFileId;
            downData.FileName      = expData.FileName;
            downData.FilePath      = expData.FilePath;
            downData.FileSize      = expData.FileSize;
            downData.Status        = "成功";
            downData.UserId        = user.Id;
            long lngResult = _downDataRepository.InsertOrUpdateAndGetId(downData);

            if (lngResult <= 0)
            {
                EasyMan.Dtos.ErrorInfo err = new EasyMan.Dtos.ErrorInfo();
                err.IsError = false;
                err.Message = "导出文件后,保存至下载记录表数据库出错";
                return(null);
            }
            return(downData);
        }
コード例 #3
0
        public ActionResult DownLoadRecord()
        {
            if (Request["id"] == null)
            {
                return(Content("导出时,参数有误。"));
            }
            int intFileId = Convert.ToInt32(Request["id"].Trim());

            if (intFileId <= 0)
            {
                return(Content("导出时,参数值有误。"));
            }
            try
            {
                DownData downData = _exportAppService.DownLoadRecord(intFileId);
                if (downData != null)
                {
                    string     strMapPath = Request.MapPath(downData.FilePath);
                    FileStream fsObj      = new FileStream(strMapPath, FileMode.Open);
                    byte[]     bytes      = new byte[(int)fsObj.Length];
                    fsObj.Read(bytes, 0, bytes.Length);
                    fsObj.Close();
                    System.Web.HttpContext.Current.Response.ContentType = "application/octet-stream;charset=GB2312";
                    //通知浏览器下载文件而不是打开
                    System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;  filename=" + downData.FileName);
                    System.Web.HttpContext.Current.Response.BinaryWrite(bytes);
                    System.Web.HttpContext.Current.Response.Flush();
                    System.Web.HttpContext.Current.Response.End();
                }
            }
            catch (Exception ex)
            {
                string strHtml = "<script src=\"../Scripts/jquery-2.2.4.min.js\"></script>";
                strHtml += "<script src=\"../Common/rootUrl.js\"></script>";
                strHtml += "<script src=\"../Common/Scripts/errorPage/error.js\"></script>";
                strHtml += "<script>$(function () {SendErrorInfo('导出提示1', '导出时,程序异常。代码:" + ex.Message + ",请联系管理员')})</script>";
                return(Content(strHtml));
            }
            return(Content(""));
        }
コード例 #4
0
        /// <summary>
        /// 将生成的数据保存数据库
        /// </summary>
        /// <param name="strPath">保存后的虚拟路径</param>
        /// <param name="strMapPath">保存后的物理路径</param>
        public void SavaDBSql(string strPath, string strMapPath, ExportDataModel exp)
        {
            long lngUserId = (long)(exp.ExportWay == "online" ? GetCurrentUserAsync().Result.Id : exp.UserId);

            #region 更新文件表
            //文件管理列表
            Easyman.Domain.Files files = new Easyman.Domain.Files();
            files.FileType   = exp.ExportWay;
            files.Name       = exp.DisplayName;
            files.TrueName   = exp.FileName;
            files.UploadTime = DateTime.Now;
            files.UserId     = lngUserId;

            if (exp.ExportWay == "online")
            {
                files.Id = 0;
            }
            else
            {
                files.Id = exp.FilesId == null ? 0 : (int)exp.FilesId;
            }
            if (strPath != null && strMapPath != null && strPath != "" && strMapPath != "")
            {
                strPath = strPath.Replace("\\", "/");
                System.IO.FileInfo FileObj = new FileInfo(strMapPath);
                files.Length = FileObj.Length;//文件大小
                files.Path   = strPath;
                files.Url    = strPath;

                exp.FileSize = (int)FileObj.Length;
                exp.EndTime  = DateTime.Now;
                exp.FilePath = strPath;
                exp.Status   = "生成成功";
            }
            exp.FilesId = _filesRepository.InsertOrUpdateAndGetId(files); //更新文件管理列表
            if (exp.FilesId <= 0)
            {
                lngUserId = 0;
                EasyMan.Dtos.ErrorInfo err = new EasyMan.Dtos.ErrorInfo();
                err.IsError = false;
                err.Message = "导出文件后,保存至文件管理数据库出错";
                return;
            }
            #endregion


            exp.FilesId = exp.FilesId;
            exp.UserId  = lngUserId;
            if (exp.ExportWay == "online")
            {
                exp.BeginTime = DateTime.Now;
                exp.Id        = 0;
            }

            if (strPath == null || strMapPath == null)
            {
                ///向导出数据生成记录里面插入数据
                exp.BeginTime = DateTime.Now;
                exp.FileSize  = 0;
                exp.Status    = "生成中";
            }

            var ent = AutoMapper.Mapper.Map <ExportData>(exp);
            exp.Id = _exportDataRepository.InsertOrUpdateAndGetId(ent); //更新导出数据生成记录

            if (exp.Id <= 0)
            {
                EasyMan.Dtos.ErrorInfo err = new EasyMan.Dtos.ErrorInfo();
                err.IsError = false;
                err.Message = "导出文件后,保存至生成记录数据库出错";
                return;
            }

            if (exp.ExportWay == "online")
            {
                DateTime dtmCreateTime = DateTime.Now;
                //数据下载记录表
                DownData downData = new DownData();
                downData.DisplayName   = exp.DisplayName;
                downData.DownBeginTime = dtmCreateTime;
                downData.DownEndTime   = dtmCreateTime;
                downData.ExportDataId  = exp.Id;
                downData.FileName      = exp.FileName;
                downData.FilePath      = strPath;
                downData.FileSize      = exp.FileSize;
                downData.Status        = "成功";
                downData.UserId        = lngUserId;
                if (_downDataRepository.InsertOrUpdateAndGetId(downData) <= 0)
                {
                    EasyMan.Dtos.ErrorInfo err = new EasyMan.Dtos.ErrorInfo();
                    err.IsError = false;
                    err.Message = "导出文件后,保存至下载记录表数据库出错";
                    return;
                }
            }
        }