Esempio n. 1
0
        /// <summary>
        /// 文件下载_根据稿件ID_流程ID
        /// </summary>
        /// <param name="cid">稿件ID</param>
        /// <param name="fileName">文件名</param>
        /// <param name="downType1">下载类型1:1=下载CPath;2=下载FigurePath;3=OtherPath</param>
        /// <param name="downType2">下载类型2:1=原稿件(最后一条数据);2=最新稿件(第一条数据);3=过程稿件</param>
        /// <param name="isDown">是否下载过:false=未下载过;true=下载过</param>
        /// <returns></returns>
        public ActionResult Download(long cid, long FlowLogID, string fileName, int downType1, int downType2, bool isDown)
        {
            string             filePath    = string.Empty;
            HttpCookie         cookie      = System.Web.HttpContext.Current.Request.Cookies["WKT_SSO.CN"];
            IFlowFacadeService flowService = ServiceContainer.Instance.Container.Resolve <IFlowFacadeService>();
            CirculationEntity  ce          = new CirculationEntity();

            ce.CID       = cid;
            ce.JournalID = SiteConfig.SiteID;
            ce.GroupID   = 1;
            IList <FlowLogInfoEntity> flowLogList = flowService.GetFlowLog(ce);

            if (cookie != null)
            {
                #region MyRegion
                if (downType2 == 1)//下载原稿件
                {
                    if (downType1 == 1)
                    {
                        filePath = GetUploadPath(flowLogList[flowLogList.Count - 1].CPath);
                    }
                    if (downType1 == 2)
                    {
                        filePath = GetUploadPath(flowLogList[flowLogList.Count - 1].FigurePath);
                    }
                    if (downType1 == 3)
                    {
                        filePath = GetUploadPath(flowLogList[flowLogList.Count - 1].OtherPath);
                    }
                }
                #endregion
                #region MyRegion
                if (downType2 == 2)//下载最新稿件
                {
                    if (downType1 == 1)
                    {
                        filePath = GetUploadPath(flowLogList[0].CPath);
                    }
                    if (downType1 == 2)
                    {
                        filePath = GetUploadPath(flowLogList[0].FigurePath);
                    }
                    if (downType1 == 3)
                    {
                        filePath = GetUploadPath(flowLogList[flowLogList.Count - 1].OtherPath);
                    }
                }
                #endregion
                #region MyRegion
                if (downType2 == 3)//下载过程稿件
                {
                    for (int i = 0; i < flowLogList.Count; i++)
                    {
                        if (flowLogList[i].FlowLogID == FlowLogID)
                        {
                            if (downType1 == 1)
                            {
                                filePath = GetUploadPath(flowLogList[i].CPath);
                            }
                            if (downType1 == 2)
                            {
                                filePath = GetUploadPath(flowLogList[i].FigurePath);
                            }
                            if (downType1 == 3)
                            {
                                filePath = GetUploadPath(flowLogList[i].OtherPath);
                            }
                        }
                    }
                }
                #endregion
                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();
                    }
                }
Esempio n. 2
0
        public ActionResult BatchSavePayNotice(PayNoticeEntity model)
        {
            IFinanceFacadeAPIService service = ServiceContainer.Instance.Container.Resolve <IFinanceFacadeAPIService>();
            IList <PayNoticeEntity>  list    = (IList <PayNoticeEntity>)TempData["list"];

            if (list != null && list.Count > 0)
            {
                #region 批量改变稿件状态  为 通知交审稿费
                int actionID = 0;
                ISiteConfigFacadeService facadeService = ServiceContainer.Instance.Container.Resolve <ISiteConfigFacadeService>();
                DictEntity dicteEntity = null;
                if (model.PayType == 1)//审稿费
                {
                    dicteEntity = facadeService.GetDictModelByKey(new DictQuery()
                    {
                        JournalID = CurAuthor.JournalID, DictKey = "PayNotice"
                    });
                }
                else //版面费
                {
                    dicteEntity = facadeService.GetDictModelByKey(new DictQuery()
                    {
                        JournalID = CurAuthor.JournalID, DictKey = "PayPageNotice"
                    });
                }
                if (dicteEntity != null)
                {
                    ISiteConfigFacadeService currentService = ServiceContainer.Instance.Container.Resolve <ISiteConfigFacadeService>();
                    IList <DictValueEntity>  currentList    = currentService.GetDictValueList(new DictValueQuery()
                    {
                        JournalID = CurAuthor.JournalID, DictKey = dicteEntity.DictKey
                    });
                    if (currentList != null && currentList.Count > 0)
                    {
                        DictValueEntity entity = currentList.Single <DictValueEntity>();
                        if (entity != null)
                        {
                            actionID = entity.ValueID;
                            IFlowFacadeService flowFacadeService = ServiceContainer.Instance.Container.Resolve <IFlowFacadeService>();

                            #region 获取流程操作

                            FlowActionQuery actionQuery = new FlowActionQuery();
                            actionQuery.JournalID  = JournalID;
                            actionQuery.ToStatusID = actionID;
                            IFlowFacadeService       flowService      = ServiceContainer.Instance.Container.Resolve <IFlowFacadeService>();
                            IList <FlowActionEntity> actionEntityList = flowService.GetFlowActionList(actionQuery);
                            #endregion

                            foreach (var item in list)
                            {
                                item.Status   = 0;
                                item.Body     = Server.UrlDecode(model.Body).Replace("${金额}$", model.Amount.ToString()).Replace("${接收人}$", item.AuthorName).Replace("${邮箱}$", item.LoginName).Replace("${稿件编号}$", item.CNumber).Replace("${稿件标题}$", item.CTitle).Replace("${手机}$", item.Mobile);
                                item.SendUser = CurAuthor.AuthorID;
                                item.Amount   = model.Amount;
                                item.Title    = model.Title;
                                if (item.NoticeID == 0)
                                {
                                    #region 根据审稿状态获取  审稿流程日志ID

                                    CirculationEntity cirQuery = new CirculationEntity();
                                    cirQuery.CID       = item.CID;
                                    cirQuery.JournalID = JournalID;
                                    cirQuery.GroupID   = 1;
                                    IFlowFacadeService        flowInfoLogService = ServiceContainer.Instance.Container.Resolve <IFlowFacadeService>();
                                    IList <FlowLogInfoEntity> flowLogEntityList  = flowInfoLogService.GetFlowLog(cirQuery);
                                    FlowActionEntity          single             = null;
                                    FlowLogInfoEntity         flowLogEntity      = null;
                                    if (flowLogEntityList != null && flowLogEntityList.Count > 0)
                                    {
                                        flowLogEntity = flowLogEntityList.OrderByDescending(o => o.FlowLogID).Take(1).SingleOrDefault();
                                        single        = actionEntityList.Where(o => o.StatusID == flowLogEntity.TargetStatusID).SingleOrDefault();
                                    }
                                    #endregion

                                    #region 批量提交审稿状态

                                    AuditBillEntity auditBillEntity = new AuditBillEntity();
                                    auditBillEntity.JournalID  = JournalID;
                                    auditBillEntity.Processer  = CurAuthor.AuthorID;
                                    auditBillEntity.ActionType = 1;
                                    auditBillEntity.CID        = item.CID;
                                    if (single != null && flowLogEntity != null)
                                    {
                                        auditBillEntity.ActionID     = single.ActionID;
                                        auditBillEntity.StatusID     = single.StatusID;
                                        auditBillEntity.ReveiverList = flowLogEntity.RecUserID.ToString();
                                        auditBillEntity.FlowLogID    = flowLogEntity.FlowLogID;
                                        auditBillEntity.CPath        = string.IsNullOrEmpty(flowLogEntity.CPath) ? "" : flowLogEntity.CPath;
                                        auditBillEntity.FigurePath   = string.IsNullOrEmpty(flowLogEntity.FigurePath) ? "" : flowLogEntity.FigurePath;
                                        auditBillEntity.OtherPath    = string.IsNullOrEmpty(flowLogEntity.OtherPath) ? "" : flowLogEntity.OtherPath;
                                        flowFacadeService.SubmitAuditBill(auditBillEntity);
                                    }

                                    #endregion
                                }
                            }
                        }
                    }
                }
                #endregion
            }

            ExecResult result = service.BatchSavePayNotice(list);

            return(Json(new { result = result.result, msg = result.msg }));
        }
Esempio n. 3
0
        public JsonResult CheckAuthorFileAjax(long cid, long AuthorID)
        {
            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
            };
            IList <FlowLogInfoEntity> flowLogList = flowService.GetFlowLog(ce);

            if (flowLogList.Count == 1)//如果是新稿件
            {
                if (flowLogList[0].FigurePath != "" && flowLogList[0].OtherPath != "")
                {
                    return(base.Json(new { flag = "19" }));
                }
                else if (flowLogList[0].FigurePath != "")
                {
                    return(base.Json(new { flag = "12" }));
                }
                else if (flowLogList[0].OtherPath != "")
                {
                    return(base.Json(new { flag = "13" }));
                }
                else
                {
                    return(base.Json(new { flag = "10" }));
                }
            }
            else //如果不是新稿件
            {
                if (flowLogList[0].CPath != "")//如果存在修改稿
                {
                    #region 判断最新的附件/介绍信
                    if (flowLogList[0].FigurePath != "" && flowLogList[0].OtherPath != "")
                    {
                        return(base.Json(new { flag = "29" }));
                    }
                    else if (flowLogList[0].FigurePath != "")
                    {
                        return(base.Json(new { flag = "22" }));
                    }
                    else if (flowLogList[0].OtherPath != "")
                    {
                        return(base.Json(new { flag = "23" }));
                    }
                    //else
                    //    return base.Json(new { flag = "20" });
                    #endregion

                    #region 判断原始的附件/介绍信
                    if (flowLogList[flowLogList.Count - 1].FigurePath != "" && flowLogList[flowLogList.Count - 1].OtherPath != "")
                    {
                        return(base.Json(new { flag = "39" }));
                    }
                    else if (flowLogList[flowLogList.Count - 1].FigurePath != "")
                    {
                        return(base.Json(new { flag = "32" }));
                    }
                    else if (flowLogList[flowLogList.Count - 1].OtherPath != "")
                    {
                        return(base.Json(new { flag = "33" }));
                    }
                    else
                    {
                        return(base.Json(new { flag = "30" }));
                    }
                    #endregion
                }
                else//如果不存在修改稿
                {
                    #region 判断最新的附件/介绍信
                    if (flowLogList[0].FigurePath != "" && flowLogList[0].OtherPath != "")
                    {
                        return(base.Json(new { flag = "49" }));
                    }
                    else if (flowLogList[0].FigurePath != "")
                    {
                        return(base.Json(new { flag = "42" }));
                    }
                    else if (flowLogList[0].OtherPath != "")
                    {
                        return(base.Json(new { flag = "43" }));
                    }
                    //else
                    //    return base.Json(new { flag = "40" });
                    #endregion

                    #region 判断原始的附件/介绍信
                    if (flowLogList[flowLogList.Count - 1].FigurePath != "" && flowLogList[flowLogList.Count - 1].OtherPath != "")
                    {
                        return(base.Json(new { flag = "59" }));
                    }
                    else if (flowLogList[flowLogList.Count - 1].FigurePath != "")
                    {
                        return(base.Json(new { flag = "52" }));
                    }
                    else if (flowLogList[flowLogList.Count - 1].OtherPath != "")
                    {
                        return(base.Json(new { flag = "53" }));
                    }
                    else
                    {
                        return(base.Json(new { flag = "50" }));
                    }
                    #endregion
                }
            }
        }
Esempio n. 4
0
        public ActionResult SavePayNotice(PayNoticeEntity model)
        {
            IFinanceFacadeAPIService service = ServiceContainer.Instance.Container.Resolve <IFinanceFacadeAPIService>();

            model.JournalID = CurAuthor.JournalID;
            model.SendUser  = CurAuthor.AuthorID;
            model.Status    = 0;
            model.Body      = Server.UrlDecode(model.Body).Replace("${金额}$", model.Amount.ToString());
            if (model.NoticeID == 0)
            {
                #region 改变稿件状态  为 通知交审稿费

                int actionID = 0;
                ISiteConfigFacadeService facadeService = ServiceContainer.Instance.Container.Resolve <ISiteConfigFacadeService>();
                DictEntity dicteEntity = null;
                if (model.PayType == 1)//审稿费
                {
                    dicteEntity = facadeService.GetDictModelByKey(new DictQuery()
                    {
                        JournalID = CurAuthor.JournalID, DictKey = "PayNotice"
                    });
                }
                else //版面费
                {
                    dicteEntity = facadeService.GetDictModelByKey(new DictQuery()
                    {
                        JournalID = CurAuthor.JournalID, DictKey = "PayPageNotice"
                    });
                }
                if (dicteEntity != null)
                {
                    ISiteConfigFacadeService currentService = ServiceContainer.Instance.Container.Resolve <ISiteConfigFacadeService>();
                    IList <DictValueEntity>  list           = currentService.GetDictValueList(new DictValueQuery()
                    {
                        JournalID = CurAuthor.JournalID, DictKey = dicteEntity.DictKey
                    });
                    if (list != null && list.Count > 0)
                    {
                        DictValueEntity entity = list.Single <DictValueEntity>();
                        if (entity != null)
                        {
                            actionID = entity.ValueID;
                            #region 获取流程操作

                            FlowActionQuery actionQuery = new FlowActionQuery();
                            actionQuery.JournalID  = JournalID;
                            actionQuery.ToStatusID = actionID;
                            IFlowFacadeService       flowService      = ServiceContainer.Instance.Container.Resolve <IFlowFacadeService>();
                            IList <FlowActionEntity> actionEntityList = flowService.GetFlowActionList(actionQuery);
                            //long statusID = actionEntity != null ? actionEntity.StatusID : 0;

                            #endregion

                            #region 根据审稿状态获取  审稿流程日志ID

                            CirculationEntity cirQuery        = new CirculationEntity();
                            AuditBillEntity   auditBillEntity = new AuditBillEntity();
                            cirQuery.CID       = model.CID;
                            cirQuery.JournalID = JournalID;
                            cirQuery.GroupID   = 1;
                            IFlowFacadeService        flowInfoLogService = ServiceContainer.Instance.Container.Resolve <IFlowFacadeService>();
                            IList <FlowLogInfoEntity> flowLogEntityList  = flowInfoLogService.GetFlowLog(cirQuery);
                            FlowActionEntity          single             = null;
                            FlowLogInfoEntity         flowLogEntity      = null;
                            if (flowLogEntityList != null && flowLogEntityList.Count > 0)
                            {
                                auditBillEntity.ReveiverList = flowLogEntityList[flowLogEntityList.Count - 1].SendUserID.ToString();
                                flowLogEntity = flowLogEntityList.OrderByDescending(o => o.FlowLogID).Take(1).SingleOrDefault();
                                single        = actionEntityList.Where(o => o.StatusID == flowLogEntity.TargetStatusID).FirstOrDefault();
                            }

                            #endregion

                            IFlowFacadeService flowFacadeService = ServiceContainer.Instance.Container.Resolve <IFlowFacadeService>();

                            auditBillEntity.JournalID = JournalID;
                            auditBillEntity.Processer = CurAuthor.AuthorID;


                            if (single != null)
                            {
                                auditBillEntity.ActionID = single.ActionID;
                                auditBillEntity.StatusID = single.StatusID;
                            }
                            auditBillEntity.ActionType = 1;
                            auditBillEntity.CID        = model.CID;
                            if (flowLogEntity != null)
                            {
                                auditBillEntity.FlowLogID  = flowLogEntity.FlowLogID;
                                auditBillEntity.CPath      = "";
                                auditBillEntity.FigurePath = "";
                                auditBillEntity.OtherPath  = "";
                            }
                            flowFacadeService.SubmitAuditBill(auditBillEntity);
                        }
                    }
                }

                #endregion
            }
            ExecResult result = service.SavePayNotice(model);

            return(Json(new { result = result.result, msg = result.msg }));
        }