protected override void OnInit(EventArgs e) { if (!IsPostBack) { if (!string.IsNullOrEmpty(Request["BusinessID"])) { var host = new LJTH.BusinessIndicators.Web.AjaxHander.ProProcessController(); host.BusinessID = Request["BusinessID"]; if (BPF.Workflow.Client.WFClientSDK.Exist(host.BusinessID)) { BPF.Workflow.Object.WorkflowContext wc = BPF.Workflow.Client.WFClientSDK.GetProcess(null, host.BusinessID); if (!wc.CurrentUserHasTodoTask) { Server.Transfer("~/BusinessReport/ProTargetApprove.aspx?BusinessID=" + host.BusinessID); } } //WfClientListener.Listen(host, null); //if (WfClientContext.Current.ProcessResponse.FromReadOnly) //{ // HttpContext.Current.Response.Clear(); // Server.Transfer("~/BusinessReport/ProTargetApprove.aspx?BusinessID=" + host.BusinessID); //} } } PermissionHelper.GetPermission(); if (PermissionHelper.EnablePermission) { PermissionList = PermissionHelper.GetStartProcessList(); ExceptionHelper.TrueThrow <ArgumentNullException>(PermissionList == null, "Argument GetStartProcessList is Empty"); } }
/// <summary> /// 添加月度报告数据 /// </summary> public void AddMonthlyReport() { HidSystemID.Value = ddlSystem.SelectedValue; HideProcessCode.Value = StaticResource.Instance[ddlSystem.SelectedValue.ToGuid(), DateTime.Now].Configuration.Element("ProcessCode").Value; B_SystemBatch BatchModel = null; // 公用的批次 实体 B_MonthlyReport bmr = null; // 公用B_MonthlyReport 实体 //首先判断系统, 是否是包含在批次里 string Gtypt = StaticResource.Instance[ddlSystem.SelectedValue.ToGuid(), DateTime.Now].GroupType; if (!string.IsNullOrEmpty(Gtypt)) { #region 包含在批次里的数据的业务系统 //判断当前URL是否存在BusinessID if (string.IsNullOrEmpty(Request["BusinessID"])) { B_MonthlyReport _statreRpt = null; //-状态B_MonthlyReport - BatchModel = B_SystemBatchOperator.Instance.GetSystemBatch("ProSystem", FinYear, FinMonth); //判断批次表中是否有数据 if (BatchModel == null) { BatchModel = AddSystemBatch(); } else { //批次不为Null,且批次还是在审批中的。 //批次是草稿状态 List <V_SubReport> V_SubReportList = JsonConvert.DeserializeObject <List <V_SubReport> >(BatchModel.SubReport); //获取上报月报的ID var subRpt = V_SubReportList.Find(SR => SR.SystemID == HidSystemID.Value.ToGuid()); B_MonthlyReport monthRpt = B_MonthlyreportOperator.Instance.GetMonthlyreport(subRpt.ReportID); #region 批次存在 //审批进行中,是要被跳转到审批页面的,但是审批完成就需要重新开启新的流程 if (BatchModel.WFBatchStatus == "Progress" || monthRpt.WFStatus == "Progress") { //批次是草稿状态 var model = V_SubReportList.Find(p => p.SystemID == HidSystemID.Value.ToGuid()); //--------------------------------------------------------------------------------------------------------------------------------------------- //这里批次需要控制,每次审批的状态只能是唯一的 // 暂时注销掉 BatchModel = AddSystemBatch(); var host = new LJTH.BusinessIndicators.Web.AjaxHander.ProProcessController(); host.BusinessID = model.ReportID.ToString(); if (BPF.Workflow.Client.WFClientSDK.Exist(host.BusinessID)) { BPF.Workflow.Object.WorkflowContext wc = BPF.Workflow.Client.WFClientSDK.GetProcess(null, host.BusinessID); if (!wc.CurrentUserHasTodoTask) { Server.Transfer("~/BusinessReport/ProTargetApprove.aspx?BusinessID=" + host.BusinessID); } else { bmr = monthRpt; hideMonthReportID.Value = monthRpt.ID.ToString(); } } //WfClientListener.Listen(host, null); //if (WfClientContext.Current.ProcessResponse.FromReadOnly) //{ // HttpContext.Current.Response.Clear(); // Server.Transfer("~/BusinessReport/ProTargetApprove.aspx?BusinessID=" + host.BusinessID); //} //--------------------------------------------------------------------------------------------------------------------------------------------- } else if (BatchModel.WFBatchStatus == "Approved") //如果审批是完成状态,重新生产 { BatchModel = AddSystemBatch(); } else { //批次是草稿状态 V_SubReportList.ForEach(p => { //选择的是那个系统? if (p.SystemID == Guid.Parse(ddlSystem.SelectedValue)) { //根据选择的系统,将明细数据展示出来 _statreRpt = B_MonthlyreportOperator.Instance.GetMonthlyreport(p.ReportID); if (_statreRpt.WFStatus == "Cancel") //如果当前月报是作废的状态,则重新生产一个新的ID ( 这里针对作废后,重新起一个流程) { _statreRpt.ID = Guid.NewGuid(); //替换实体ID _statreRpt.WFStatus = "Draft"; _statreRpt.Status = 2; Guid _BRptID = B_MonthlyreportOperator.Instance.AddMonthlyreport(_statreRpt); p.ReportID = _BRptID; HiddenBatch.Value = BatchModel.ID.ToString(); //批次ID不变 hideMonthReportID.Value = p.ReportID.ToString(); } else { //注意这里 hideMonthReportID.Value = p.ReportID.ToString(); HiddenBatch.Value = p.ReportID.ToString(); } AddBMRD(_statreRpt); bmr = _statreRpt; MutipleUpload.LoadByBusinessID(_statreRpt.ID.ToString()); } }); //这里重新序列,将作废后,重新生成的新ID 序列化到批次里 BatchModel.SubReport = JsonConvert.SerializeObject(V_SubReportList); B_SystemBatchOperator.Instance.UpdateSystemBatch(BatchModel); } #endregion } } else { //如果是传过来的BusinessID,就直接去查询,不做操作 //通过BusinessID,首先获取批次的实体,根据权限,然后在批次中寻找 HiddenBatch.Value = Request["BusinessID"]; bmr = B_MonthlyreportOperator.Instance.GetMonthlyreport(Request["BusinessID"].ToGuid()); ExceptionHelper.TrueThrow <ArgumentNullException>(bmr == null ? true : false, "Argument B_MonthlyReport is Null"); if (bmr.SystemBatchID != Guid.Empty) { BatchModel = B_SystemBatchOperator.Instance.GetSystemBatch(bmr.SystemBatchID); List <V_SubReport> rptLsit = JsonConvert.DeserializeObject <List <V_SubReport> >(BatchModel.SubReport); V_SubReport rptModel = rptLsit.Find(f => f.SystemID == ddlSystem.SelectedValue.ToGuid()); hideMonthReportID.Value = rptModel.ReportID.ToString(); bmr = B_MonthlyreportOperator.Instance.GetMonthlyreport(rptModel.ReportID); ExceptionHelper.TrueThrow <ArgumentNullException>(bmr == null ? true : false, "Argument B_MonthlyReport is Null"); MutipleUpload.LoadByBusinessID(bmr.ID.ToString()); UserControl.SetButtonSpanStyle(bmr.Status); } } #endregion } else { #region 没有包含在批次里系统 if (string.IsNullOrEmpty(Request["BusinessID"])) //正常上报 { //添加月报说明 bmr = B_MonthlyreportOperator.Instance.GetMonthlyReportDraft(Guid.Parse(ddlSystem.SelectedValue), FinYear, FinMonth); if (bmr == null) { bmr = AddMR(); } else { if (bmr.WFStatus == "Progress" || bmr.WFStatus == "Approved") { bmr = AddMR(); } } //为当前月度经营报告(bmr),插入月度经营明细数据 AddBMRD(bmr); hideMonthReportID.Value = bmr.ID.ToString(); } else { hideMonthReportID.Value = Request["BusinessID"]; bmr = B_MonthlyreportOperator.Instance.GetMonthlyreport(Request["BusinessID"].ToGuid()); ddlSystem.SelectedValue = bmr.SystemID.ToString(); FinYear = bmr.FinYear; FinMonth = bmr.FinMonth; lblName.Text = ""; lblName.Text = FinYear + "-" + FinMonth + "月度经营报告上报"; } if (bmr != null) { MutipleUpload.LoadByBusinessID(bmr.ID.ToString()); UserControl.SetButtonSpanStyle(bmr.Status); } #endregion } if (bmr != null) { List <BPF.Workflow.Object.ProcessLog> lstBatchProcessLog = new List <BPF.Workflow.Object.ProcessLog>(); if (bmr.SystemBatchID != Guid.Empty) { //if (BPF.Workflow.Client.WFClientSDK.Exist(bmr.SystemBatchID.ToString())) //{ // lstBatchProcessLog = BPF.Workflow.Client.WFClientSDK.GetProcessLogList(bmr.SystemBatchID.ToString()); //} } //List<BPF.Workflow.Object.ProcessLog> lstCurrentProcessLog = BPF.Workflow.Client.WFClientSDK.GetProcessLogList(bmr.ID.ToString()); //if (lstBatchProcessLog!=null) //{ // lstCurrentProcessLog.AddRange(lstBatchProcessLog); //} //HideOpinions.Value = JsonConvert.SerializeObject(lstCurrentProcessLog.OrderByDescending(p => p.FinishDateTime)); } }