Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            long CID = TypeParse.ToLong(Request.QueryString["CID"],0);
            if (CID <= 0)
            {
                Response.Write("请选择正确的稿件");
            }
            IFlowFacadeService flowService = ServiceContainer.Instance.Container.Resolve<IFlowFacadeService>();
            // 附件路径
            FlowLogQuery logQuery = new FlowLogQuery();
            logQuery.JournalID = SiteConfig.SiteID;
            logQuery.FlowLogID = 0;
            logQuery.CID = CID;
            string _filePath = flowService.GetFlowLogAttachment(logQuery);
            string fileName = "";
            if (!string.IsNullOrEmpty(_filePath))
            {
                fileName = _filePath.Substring(_filePath.LastIndexOf("/") + 1);
            }

            string downPath = GetUploadPath(_filePath);
            if (!System.IO.File.Exists(downPath))
                Response.Write("文件不存在");
            if (!fileName.Contains("."))
                fileName += Path.GetExtension(downPath);

            IAuthorPlatformFacadeService service = ServiceContainer.Instance.Container.Resolve<IAuthorPlatformFacadeService>();
            ContributionInfoEntity cEntity = service.GetContributionInfoModel(new ContributionInfoQuery { JournalID = SiteConfig.SiteID, CID = CID });
            string docTitle = "";
            if (cEntity != null)
            {
                docTitle = cEntity.Title + Path.GetExtension(downPath);
            }
            else
            {
                docTitle = fileName;
            }

            FileStream fs = new FileStream(downPath, FileMode.Open);
            //fs.Seek(0, SeekOrigin.Begin);
            byte[] bytes = new byte[(int)fs.Length];
            fs.Read(bytes, 0, bytes.Length);
            fs.Close();
            Response.ContentType = "application/octet-stream";
            //通知浏览器下载文件而不是打开
            Response.AddHeader("Content-Disposition", "attachment;  filename=" + docTitle);
            Response.AddHeader("Content-Length", bytes.Length.ToString());
            Response.ContentEncoding = Encoding.UTF8;
            Response.BinaryWrite(bytes);
            Response.Flush();
            Response.End();
        }
        /// <summary>
        /// 查看详情(编辑平台)
        /// </summary>
        /// <param name="CID"></param>
        /// <returns></returns>
        public ActionResult ViewDetail(Int64 CID, long StatusID, long FlowLogID)
        {
            ContributionInfoEntity model = GetModel(CID);
            model.StatusID = StatusID;
            model.FlowLogID = FlowLogID;
            if (model.AuthorList == null)
                model.AuthorList = new List<ContributionAuthorEntity>();
            if (model.ReferenceList == null)
                model.ReferenceList = new List<ContributionReferenceEntity>();
            if (model.FundList == null)
                model.FundList = new List<ContributionFundEntity>();
            if (model.AttModel == null)
                model.AttModel = new ContributionInfoAttEntity();
            model.CRemarkInfo = GetCRemarkModel(CID, CurAuthor.AuthorID);

            # region 更新查看状态

            try
            {
                FlowLogQuery query = new FlowLogQuery();
                query.JournalID = CurAuthor.JournalID;
                query.FlowLogID = FlowLogID;
                IFlowFacadeService flowService = ServiceContainer.Instance.Container.Resolve<IFlowFacadeService>();
                flowService.UpdateFlowLogIsView(query);
            }
            catch (Exception ex)
            {
                WKT.Log.LogProvider.Instance.Error("更新审稿日志的查看状态出现异常:" + ex.Message);
            }

            # endregion

            # region 排版后稿件

            ViewBag.ComposingContribution = "";
            string path = Server.MapPath("/UploadFile/Fangzheng/");
            string fileFullName = path + CID + "_single.pdf";
            if (System.IO.File.Exists(fileFullName))
            {
                ViewBag.ComposingContribution = CID + "_single.pdf";
            }
            # endregion

            return View(model);
        }
Example #3
0
        /// <summary>
        /// 文件下载_根据稿件ID_作者ID
        /// </summary>
        /// <param name="cid">稿件ID</param>
        /// <param name="AuthorID">作者ID</param>
        /// <param name="fileName">文件名</param>
        /// <param name="downType1">下载类型1:1=下载CPath;2=下载FigurePath;3=OtherPath</param>
        /// <param name="downType2">下载类型2:1=原稿件(最后一条数据);2=最新稿件(第一条数据)</param>
        /// <returns></returns>
        public ActionResult DownloadAuthorCID(long cid, long AuthorID, string fileName, int downType1, int downType2,bool isDown)
        {
            string filePath = string.Empty;
            HttpCookie cookie = Request.Cookies["WKT_SSO.CN"];
            IFlowFacadeService flowService = ServiceContainer.Instance.Container.Resolve<IFlowFacadeService>(new ResolverOverride[0]);
            CirculationEntity ce = new CirculationEntity
            {
                CID = cid,
                JournalID = SiteConfig.SiteID,
                GroupID = 2
            };
            long flowLogID = 0;
            IList<FlowLogInfoEntity> flowLogList = flowService.GetFlowLog(ce);
            if (cookie != null)
            {
                if (downType1 == 1)
                {
                    if (downType2 == 1)
                    {
                        filePath = this.GetUploadPath(flowLogList[flowLogList.Count - 1].CPath);
                        flowLogID = flowLogList[flowLogList.Count - 1].FlowLogID;
                    }
                    if (downType2 == 2)
                    {
                        filePath = this.GetUploadPath(flowLogList[0].CPath);
                        flowLogID = flowLogList[0].FlowLogID;
                    }
                }
                if (downType1 == 2)
                {
                    if (downType2 == 1)
                    {
                        filePath = this.GetUploadPath(flowLogList[flowLogList.Count - 1].FigurePath);
                        flowLogID = flowLogList[flowLogList.Count - 1].FlowLogID;
                    }
                    if (downType2 == 2)
                    {
                        filePath = this.GetUploadPath(flowLogList[0].FigurePath);
                        flowLogID = flowLogList[0].FlowLogID;
                    }
                }
                if (downType1 == 3)
                {
                    if (downType2 == 1)
                    {
                        filePath = this.GetUploadPath(flowLogList[flowLogList.Count - 1].OtherPath);
                        flowLogID = flowLogList[flowLogList.Count - 1].FlowLogID;
                    }
                    if (downType2 == 2)
                    {
                        filePath = this.GetUploadPath(flowLogList[0].OtherPath);
                        flowLogID = flowLogList[0].FlowLogID;
                    }
                }
                fileName = fileName + Path.GetExtension(filePath);
                try
                {
                    FileStream myFile = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                    BinaryReader br = new BinaryReader(myFile);
                    try
                    {
                        #region MyRegion
                        Response.AddHeader("Accept-Ranges", "bytes");
                        Response.Buffer = false;
                        long fileLength = myFile.Length;
                        long startBytes = 0;

                        double pack = 10240; //10K bytes
                        //int sleep = 200;   //每秒5次   即5*10K bytes每秒
                        int sleep = (int)Math.Floor(1000 * pack / 204800) + 1;
                        if (Request.Headers["Range"] != null)
                        {
                            Response.StatusCode = 206;
                            string[] range = Request.Headers["Range"].Split(new char[] { '=', '-' });
                            startBytes = Convert.ToInt64(range[1]);
                        }

                        Response.AddHeader("Content-Length", (fileLength - startBytes).ToString());
                        if (startBytes != 0)
                        {
                            //Response.AddHeader("Content-Range", string.Format(" bytes {0}-{1}/{2}", startBytes, fileLength-1, fileLength));
                        }
                        Response.AddHeader("Connection", "Keep-Alive");
                        Response.ContentType = "application/octet-stream";
                        if (Request.Browser.Browser == "Firefox")
                        {
                            Response.AddHeader("Content-Disposition", "attachment;filename=" + fileName);
                        }
                        else
                        {
                            Response.AddHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
                        }
                        br.BaseStream.Seek(startBytes, SeekOrigin.Begin);
                        int maxCount = (int)Math.Floor((fileLength - startBytes) / pack) + 1;

                        for (int i = 0; i < maxCount; i++)
                        {
                            if (Response.IsClientConnected)
                            {
                                Response.BinaryWrite(br.ReadBytes(int.Parse(pack.ToString())));
                                Thread.Sleep(sleep);
                            }
                            else
                            {
                                i = maxCount;
                            }
                        }
                        #endregion

                        # region 更新下载状态
                        if (isDown == false)
                        {
                            try
                            {
                                FlowLogQuery query = new FlowLogQuery();
                                query.JournalID = SiteConfig.SiteID;
                                query.FlowLogID = flowLogID;
                                flowService.UpdateFlowLogIsDown(query);
                            }
                            catch (Exception ex)
                            {
                                WKT.Log.LogProvider.Instance.Error("更新审稿日志的下载状态出现异常:" + ex.Message);
                            }
                        }

                        # endregion
                    }
                    catch (Exception ex)
                    {
                        return Content("无法完成下载!详细信息:" + ex.Message);
                    }
                    finally
                    {
                        br.Close();
                        myFile.Close();
                    }
                }
                catch (Exception ex)
                {

                    return Content("无法完成下载!详细信息:" + ex.Message);
                }
                return null;

            }
            else
                return null;
        }
 /// <summary>
 /// 更新日志的查看状态
 /// </summary>
 /// <param name="flowLogQuery">流程日志ID</param>
 /// <returns></returns>
 public bool UpdateFlowLogIsView(FlowLogQuery flowLogQuery)
 {
     return FlowCirculationDataAccess.Instance.UpdateFlowLogIsView(flowLogQuery);
 }
 /// <summary>
 /// 获取处理日志的附件
 /// </summary>
 /// <param name="flowLogQuery">流程日志ID</param>
 /// <returns></returns>
 public string GetFlowLogAttachment(FlowLogQuery flowLogQuery)
 {
     return FlowCirculationDataAccess.Instance.GetFlowLogAttachment(flowLogQuery);
 }
 /// <summary>
 /// 获取处理日志的附件
 /// </summary>
 /// <param name="flowLogQuery">流程日志ID</param>
 /// <returns></returns>
 public IDictionary<string, string> GetFlowLogAllAttachment(FlowLogQuery flowLogQuery)
 {
     return FlowCirculationDataAccess.Instance.GetFlowLogAllAttachment(flowLogQuery);
 }
    private void GetFilePath()
    {
        // 根据稿件ID或者流程日志ID得到稿件路径
            long CIDParam = 0;
            if (!string.IsNullOrEmpty(Request.QueryString["CID"]))
            {
                CIDParam = TypeParse.ToLong(Request.QueryString["CID"], 0);
            }
            // 日志ID
            long FlowLogID = 0;
            if (!string.IsNullOrEmpty(Request.QueryString["FlowID"]))
            {
                FlowLogID = TypeParse.ToLong(Request.QueryString["FlowID"], 0);
            }

            if (CIDParam > 0)
            {
                IContributionFacadeService cService = ServiceContainer.Instance.Container.Resolve<IContributionFacadeService>();
                // 得到稿件路径
                ContributionInfoQuery cQuery = new ContributionInfoQuery();
                cQuery.JournalID = SiteConfig.SiteID;
                cQuery.CID = CIDParam;
                _filePath = cService.GetContributionAttachment(cQuery);
            }
            else if (FlowLogID > 0)
            {
                IFlowFacadeService flowService = ServiceContainer.Instance.Container.Resolve<IFlowFacadeService>();
                // 附件路径
                FlowLogQuery logQuery = new FlowLogQuery();
                logQuery.JournalID = SiteConfig.SiteID;
                logQuery.FlowLogID = FlowLogID;
                _filePath = flowService.GetFlowLogAttachment(logQuery);
            }

            if (!string.IsNullOrEmpty(Request.QueryString["fileName"]))
            {
                _fileName = Request.QueryString["fileName"];
            }
            else
            {
                _fileName = "在线审阅稿件";
            }
    }
 /// <summary>
 /// 更新日志的查看状态
 /// </summary>
 /// <param name="flowLogQuery">流程日志ID</param>
 /// <returns></returns>
 public bool UpdateFlowLogIsView(FlowLogQuery flowLogQuery)
 {
     return FlowCirculationBusProvider.UpdateFlowLogIsView(flowLogQuery);
 }
 /// <summary>
 /// 获取处理日志的附件
 /// </summary>
 /// <param name="flowLogQuery">流程日志ID</param>
 /// <returns></returns>
 public string GetFlowLogAttachment(FlowLogQuery flowLogQuery)
 {
     return FlowCirculationBusProvider.GetFlowLogAttachment(flowLogQuery);
 }
 /// <summary>
 /// 获取处理日志的附件
 /// </summary>
 /// <param name="flowLogQuery">流程日志ID</param>
 /// <returns></returns>
 public IDictionary<string, string> GetFlowLogAllAttachment(FlowLogQuery flowLogQuery)
 {
     return FlowCirculationBusProvider.GetFlowLogAllAttachment(flowLogQuery);
 }
 private string GetFilePath(string CType, long CID, string AttType, ref string Message)
 {
     string _filePath = "";
     // 根据稿件ID或者流程日志ID得到稿件路径
     if (CID > 0)
     {
         if (CType.Equals("Flow", StringComparison.CurrentCultureIgnoreCase))
         {
             IFlowFacadeService flowService = ServiceContainer.Instance.Container.Resolve<IFlowFacadeService>();
             // 附件路径
             FlowLogQuery logQuery = new FlowLogQuery();
             logQuery.JournalID = SiteConfig.SiteID;
             logQuery.CID = CID;
             IDictionary<string, string> dictPath = flowService.GetFlowLogAllAttachment(logQuery);
             if (dictPath.Count == 1)
             {
                 _filePath = dictPath[dictPath.Keys.Single().ToLower()].ToString();
             }
             else
             {
                 if (!string.IsNullOrEmpty(AttType))
                 {
                     _filePath = dictPath[AttType.ToLower()].ToString();
                 }
                 else
                 {
                     StringBuilder sbMessage = new StringBuilder();
                     foreach (string key in dictPath.Keys)
                     {
                         if (key.Equals("CPath", StringComparison.CurrentCultureIgnoreCase))
                         {
                             sbMessage.AppendFormat("<a href=\"{0}/Contribution/Download/?CID={1}&CType=Flow&AttType=CPath\">稿件附件下载</a><br/>", SiteConfig.RootPath, CID);
                         }
                         else if (key.Equals("FigurePath", StringComparison.CurrentCultureIgnoreCase))
                         {
                             sbMessage.AppendFormat("<a href=\"{0}/Contribution/Download/?CID={1}&CType=Flow&AttType=FigurePath\">附件下载</a><br/>", SiteConfig.RootPath, CID);
                         }
                         else if (key.Equals("OtherPath", StringComparison.CurrentCultureIgnoreCase))
                         {
                             sbMessage.AppendFormat("<a href=\"{0}/Contribution/Download/?CID={1}&CType=Flow&AttType=OtherPath\">其他附件下载</a><br/>", SiteConfig.RootPath, CID);
                         }
                     }
                     Message = sbMessage.ToString();
                 }
             }
         }
         else
         {
             IContributionFacadeService cService = ServiceContainer.Instance.Container.Resolve<IContributionFacadeService>();
             // 得到稿件路径
             ContributionInfoQuery cQuery = new ContributionInfoQuery();
             cQuery.JournalID = SiteConfig.SiteID;
             cQuery.CID = CID;
             _filePath = cService.GetContributionAttachment(cQuery);
         }
     }
     else
     {
         Message = "请指定正确的稿件ID";
     }
     string folder = SiteConfig.UploadPath;
     string uploadPath;
     if (!string.IsNullOrWhiteSpace(folder))
     {
         uploadPath = folder + _filePath.Replace("/", "\\");
     }
     else
     {
         uploadPath = Server.MapPath(_filePath);
     }
     return uploadPath;
 }
Example #12
0
 public string GetFlowLogAttachment(FlowLogQuery flowLogQuery)
 {
     try
     {
         IFlowCirculationService flowCirculationService = ServiceContainer.Instance.Container.Resolve<IFlowCirculationService>();
         string CPath = flowCirculationService.GetFlowLogAttachment(flowLogQuery);
         return CPath;
     }
     catch (Exception ex)
     {
         LogProvider.Instance.Error("获取流程日志附件出现异常:" + ex.Message);
         throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.ExpectationFailed, ex.Message));
     }
 }
Example #13
0
 public ExecResult UpdateFlowLogIsView(FlowLogQuery flowLogQuery)
 {
     ExecResult result = new ExecResult();
     try
     {
         IFlowCirculationService flowService = ServiceContainer.Instance.Container.Resolve<IFlowCirculationService>();
         bool flag = flowService.UpdateFlowLogIsView(flowLogQuery);
         if (flag)
         {
             result.result = EnumJsonResult.success.ToString();
             result.msg = "成功";
         }
         else
         {
             result.result = EnumJsonResult.failure.ToString();
             result.msg = "更新日志的查看状态失败,请确认信息是否正确";
         }
     }
     catch (Exception ex)
     {
         result.result = EnumJsonResult.error.ToString();
         result.msg = "更新日志的查看状态出现异常:" + ex.Message;
     }
     return result;
 }