private int Save(int rRunId, int rStepId)
        {
            //1.获取模型
            WX.Flow.Model.Run.MODEL     runmodel = WX.Flow.Model.Run.NewDataModel(rRunId);
            WX.Flow.Model.Process.MODEL process  = WX.Flow.Model.Process.GetModel("select * from FL_Process where FlowID=" + runmodel.FlowId.ToString() + " and StepNo=" + (runmodel.StepNo.ToInt32() + 1));
            if (process == null)
            {
                runmodel.Deal_Flag.value = WX.Flow.DealFlag.HasOperated;
            }
            else
            {
                runmodel.Deal_Flag.value = WX.Flow.DealFlag.NotReceived;
                if (process.Next_Nodes.ToString() != "")
                {
                    runmodel.Next_Nodes.value = process.Next_Nodes.value;
                }
                else
                {
                    WX.Flow.Model.Process.MODEL proc = WX.Flow.Model.Process.GetModel("select * from FL_Process where FlowID=" + runmodel.FlowId.ToString() + " and StepNo=" + runmodel.StepNo.ToInt32());
                    runmodel.Next_Nodes.value = proc.Next_Nodes.value;
                }
                runmodel.StepNo.value = process.StepNo.value;
            }
            //2.取表单值
            runmodel.LoadMyForm(false);
            WX.Flow.FormFieldCollection ffc = runmodel.MyForm.GetPostedDatas();
            //3.上传附件并取得附件列表
            string attach_nameList = String.Empty;
            string attache_idlist  = String.Empty;
            //4.取得手写与签章信息
            int iR = runmodel.Save(rStepId, ffc, attache_idlist, attach_nameList, "", "", 0);//最后两个参数为会签意见和手写签章信息

            runmodel.Update();
            return(0);// iR;
        }
        /// <summary>
        /// 清空手写签章信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void ClearSignData(object sender, EventArgs e)
        {
            WX.Flow.Model.Run.MODEL runmodel = WX.Flow.Model.Run.GetModel("select * from FL_Run where Id=" + this.rRunId);

            string sSql = String.Format("update FL_RunFeedBack set SignData=NULL where RunId={0} and StepNo={1} and UserId='{2}'", rRunId, runmodel.StepNo.ToString(), WX.Main.CurUser.UserID);
            int    iR   = ULCode.QDA.XSql.Execute(sSql);

            if (iR > 0)
            {
                Response.Redirect(this.Request.RawUrl);
            }
        }
Example #3
0
            /// <summary>
            /// 生成当前工作N步中表单Html
            /// </summary>
            /// <param name="step"></param>
            /// <returns></returns>
            public String GenerateHtmls(int id)
            {
                WX.Flow.Model.Run.MODEL runmodel = WX.Flow.Model.Run.NewDataModel(id);
                FormFieldCollection     datas    = this.GetDatas_FormFieldCollection();

                this.MyFlow.LoadProcessList(false);
                Process.MODEL process = this.MyFlow.ProcessList.Find(delegate(Process.MODEL prcs_dele) { return(prcs_dele.StepNo.ToInt32() == runmodel.StepNo.ToInt32()); });
                if (process == null)
                {
                    return(null);
                }
                return(this.MyForm.GenerateHtmls(datas, process.Editable_FormFieldCollection, process.Hidden_FormFieldCollection, runmodel.BeginUser.ToString()));
            }
        //删除处理过程
        protected void Del(object sender, EventArgs e)
        {
            //1.验证用户权限
            if (!this.Master.A_Del)
            {
                Response.Write("你没有权限访问此功能!");
                Response.End();
                return;
            }
            //2.取得用户变量
            LinkButton lb = (LinkButton)sender;
            int        id = Convert.ToInt32(lb.CommandName);
            //下面语句是UI开发人员的语句,后台开发人员需删除掉。
            //ULCode.Debug.we(String.Format("已经收到id:{0}", id));
            //return;

            //以下代码由后台开发人员填写
            //3.验证用户变量,包含Request.QueryString及Request.Form

            //4.业务处理过程
            bool bDeal = false;

            //填写主要业务逻辑代码
            WX.Flow.Model.Run.MODEL runmodel = WX.Flow.Model.Run.NewDataModel(id);
            if (runmodel != null && runmodel.Deal_Flag.ToInt32() > 0)
            {
                ULCode.Debug.Alert(this, "此流程已经应用,不能删除!");
                return;
            }

            int iR = runmodel.Del();

            //5.(用户及业务对象)统计与状态

            //6.登记日志
            if (iR > 0)
            {
                WX.Main.AddLog(WX.LogType.Default, String.Format("删除流程({0})成功!", id), "");
            }

            //7.返回处理结果或返回其它页面。
            if (iR > 0)
            {
                this.BindData(true);
            }
            else
            {
                ULCode.Debug.Alert(this, "删除流程失败!");
            }
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            //Process.MODEL process = new Process.MODEL();
            WX.Flow.Model.Flow.MODEL flow = WX.Flow.Model.Flow.GetCache(rFlowId); //WX.Flow.Model.Flow.NewDataModel(rFlowId);
            flow.LoadProcessList(false);
            if (flow.GetProcessByStep(1).ExecIn(null) == 0)
            {
                ULCode.Debug.Alert(this, "程序出错,请联系管理员!");
                return;
            }
            int newRunId = flow.NewWork(this.txtSerialNumber.Text);

            this.Save(newRunId, 1);
            if (newRunId > 0)
            {
                WX.Flow.Model.Run.MODEL     runmodel = WX.Flow.Model.Run.GetModel("select * from FL_Run where Id=" + newRunId);
                WX.Flow.Model.Process.MODEL process  = WX.Flow.Model.Process.GetCache(runmodel.FlowId.ToInt32(), runmodel.StepNo.ToInt32());
                WX.Model.User.MODEL         squser   = WX.Model.User.NewDataModel(runmodel.BeginUser.ToString());
                if (process.Auto_Type.ToString() == "1")//经办人为流程发起人的
                {
                    WX.Main.MessageSend("<a href=/Manage/Work/Work_MyCheck.aspx?flag=0&mes=1>" + flow.Name.ToString() + "(" + WX.CommonUtils.GetRealNameListByUserIdList(runmodel.BeginUser.ToString()) + ")——请尽快审批!</a>", "/Manage/Main/messagelist.aspx", runmodel.BeginUser.ToString(), WX.Main.CurUser.UserID, 12, 0);
                }
                else if (process.Auto_Type.ToString() == "2")//经办人为部门主管的
                {
                    WX.Main.MessageSend("<a href=/Manage/Work/Work_MyCheck.aspx?flag=0&mes=1>" + flow.Name.ToString() + "(" + WX.CommonUtils.GetRealNameListByUserIdList(runmodel.BeginUser.ToString()) + ")——请尽快审批!</a>", "/Manage/Main/messagelist.aspx", WX.CommonUtils.GetDeptUserID(1, "[Host]", squser.DepartmentID.ToInt32()), WX.Main.CurUser.UserID, 12, 0);
                }
                else if (process.Auto_Type.ToString() == "4")
                {
                    WX.Main.MessageSend("<a href=/Manage/Work/Work_MyCheck.aspx?flag=0&mes=1>" + flow.Name.ToString() + "(" + WX.CommonUtils.GetRealNameListByUserIdList(runmodel.BeginUser.ToString()) + ")——请尽快审批!</a>", "/Manage/Main/messagelist.aspx", WX.CommonUtils.GetParentDeptHost(squser.DepartmentID.ToInt32(), "Host"), WX.Main.CurUser.UserID, 12, 0);
                }
                else if (process.Auto_Type.ToString() == "5")
                {
                    WX.Main.MessageSend("<a href=/Manage/Work/Work_MyCheck.aspx?flag=0&mes=1>" + flow.Name.ToString() + "(" + WX.CommonUtils.GetRealNameListByUserIdList(runmodel.BeginUser.ToString()) + ")——请尽快审批!</a>", "/Manage/Main/messagelist.aspx", WX.CommonUtils.GetParentDeptHost(squser.DepartmentID.ToInt32(), "SubHosts"), WX.Main.CurUser.UserID, 12, 0);
                }
                else
                {
                    System.Data.DataTable dt = ULCode.QDA.XSql.GetDataTable("select UserID from Tu_Users where 1=1" + (process.Priv_UserList.ToString() != "" ? " and UserID in(" + process.Priv_UserList.ToString() + ")" : "") + (process.Priv_DutyList.ToString() != "" ? " and DutyId in(select ID from TE_DutyDetail where DutyID in(" + process.Priv_DutyList.ToString() + "))" : "") + (process.Priv_DeptList.ToString() != "" ? " and Priv_DeptList in(" + process.Priv_DeptList.ToString() + ")" : ""));
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        WX.Main.MessageSend("<a href=/Manage/Work/Work_MyCheck.aspx?flag=0&mes=1>" + flow.Name.ToString() + "(" + WX.CommonUtils.GetRealNameListByUserIdList(runmodel.BeginUser.ToString()) + ")——请尽快审批!</a>", "/Manage/Main/messagelist.aspx", dt.Rows[i][0].ToString(), WX.Main.CurUser.UserID, 12, 0);
                    }
                }

                //转到下一页
                Response.Redirect("/Manage/Work/Work_MyWork.aspx?flag=0 ");
            }
        }
        /// <summary>
        /// 保存表单及其它功能按钮
        /// </summary>
        private int Save(int rRunId, int rStepId)
        {
            //1.获取模型
            WX.Flow.Model.Run.MODEL     runmodel = WX.Flow.Model.Run.NewDataModel(rRunId);
            WX.Flow.Model.Process.MODEL process  = WX.Flow.Model.Process.GetModel("select * from FL_Process where FlowID=" + runmodel.FlowId.ToString() + " and StepNo=" + rStepId);
            if (process == null)
            {
                runmodel.Deal_Flag.value = WX.Flow.DealFlag.HasOperated;
            }
            else
            {
                runmodel.Deal_Flag.value = WX.Flow.DealFlag.NotReceived;
                if (process.Next_Nodes.ToString() != "")
                {
                    runmodel.Next_Nodes.value = process.Next_Nodes.value;
                }
                else
                {
                    WX.Flow.Model.Process.MODEL proc = WX.Flow.Model.Process.GetModel("select * from FL_Process where FlowID=" + runmodel.FlowId.ToString() + " and StepNo=" + runmodel.StepNo.ToInt32());
                    runmodel.Next_Nodes.value = proc.Next_Nodes.value;
                }
                runmodel.StepNo.value = process.StepNo.value;
            }
            //2.取表单值

            WX.Flow.FormFieldCollection ffc = new WX.Flow.FormFieldCollection();
            //3.上传附件并取得附件列表
            string attach_nameList = String.Empty;
            string attache_idlist  = String.Empty;

            //WX.Flow.FormFieldCollection ffc = new WX.Flow.FormFieldCollection();
            //foreach (WX.Flow.FormField ff in runmodel.MyForm.Items_FormFieldCollection)
            //{
            //    ff.Value = this.Request.Form[ff.Id] == null ? "" : this.Request.Form[ff.Id];
            //    ffc.Add(ff);
            //}
            //
            //4.取得手写与签章信息
            int iR = runmodel.Save(rStepId, ffc, attache_idlist, attach_nameList, "", "", 0);//最后两个参数为会签意见和手写签章信息

            runmodel.Update();
            return(iR);
        }
        }/// <summary>

        /// 保存表单及其它功能按钮
        /// </summary>
        private int Save(int rRunId, int rStepId)
        {
            //1.获取模型
            WX.Flow.Model.Run.MODEL     runmodel = WX.Flow.Model.Run.NewDataModel(rRunId);
            WX.Flow.Model.Process.MODEL process  = WX.Flow.Model.Process.GetModel("select * from FL_Process where FlowID=" + runmodel.FlowId.ToString() + " and StepNo=" + (runmodel.StepNo.ToInt32() + 1));
            if (process == null)
            {
                runmodel.Deal_Flag.value = DealFlag.HasOperated;
            }
            else
            {
                runmodel.Deal_Flag.value = DealFlag.NotReceived;
                if (process.Next_Nodes.ToString() != "")
                {
                    runmodel.Next_Nodes.value = process.Next_Nodes.value;
                }
                else
                {
                    WX.Flow.Model.Process.MODEL proc = WX.Flow.Model.Process.GetModel("select * from FL_Process where FlowID=" + runmodel.FlowId.ToString() + " and StepNo=" + runmodel.StepNo.ToInt32());
                    runmodel.Next_Nodes.value = proc.Next_Nodes.value;
                }
                runmodel.StepNo.value = process.StepNo.value;
            }
            //2.取表单值
            runmodel.LoadMyForm(false);
            WX.Flow.FormFieldCollection ffc = runmodel.MyForm.GetPostedDatas();
            //3.上传附件并取得附件列表
            string             attach_nameList = String.Empty;
            string             attache_idlist  = String.Empty;
            string             uploadUserId    = WX.Main.CurUser.UserID;
            string             uploadIp        = WX.Main.getIp(this);
            HttpFileCollection hfc             = Request.Files;

            for (int i = 0; i < hfc.Count; i++)
            {
                HttpPostedFile hpf = hfc[i];
                // 取文件后缀名
                string oldFileName = System.IO.Path.GetFileName(hpf.FileName);
                string ext         = System.IO.Path.GetExtension(hpf.FileName);
                string newFileName = DateTime.Now.ToString("yyyyMMddhhmmss fff") + ext;
                string newPath     = String.Format("/UploadFiles/Run/{0}", newFileName);
                if (hpf.ContentLength > 0)
                {
                    try
                    {
                        hpf.SaveAs(Server.MapPath(newPath));
                        //上传成功了
                        DateTime uploadTime = DateTime.Now;
                        string   cmdText    = String.Format("INSERT INTO FL_RunAttachs (RunId,StepNo,NewFileName,OldFileName,UploadUserID,UploadTime,UploadIP)"
                                                            + " VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}');SELECT @@IDENTITY as  IdentityID;"
                                                            , rRunId, rStepId, newPath, oldFileName, uploadUserId, DateTime.Now, uploadIp);
                        int id = ULCode.QDA.XSql.GetData(cmdText).ToInt32();
                        if (attach_nameList.Length > 0)
                        {
                            attach_nameList = attach_nameList + ",";
                        }
                        attach_nameList = attach_nameList + oldFileName;
                        if (attache_idlist.Length > 0)
                        {
                            attache_idlist = attache_idlist + ",";
                        }
                        attache_idlist = attache_idlist + id;
                    }
                    catch
                    {
                        ;
                    }
                }
            }
            //WX.Flow.FormFieldCollection ffc = new WX.Flow.FormFieldCollection();
            //foreach (WX.Flow.FormField ff in runmodel.MyForm.Items_FormFieldCollection)
            //{
            //    ff.Value = this.Request.Form[ff.Id] == null ? "" : this.Request.Form[ff.Id];
            //    ffc.Add(ff);
            //}
            //
            //4.取得手写与签章信息
            int iR = runmodel.Save(rStepId, ffc, attache_idlist, attach_nameList, "", "", 0);//最后两个参数为会签意见和手写签章信息

            runmodel.Update();
            return(0);// iR;
        }
        private void pageinit()
        {
            model  = WX.Request.rNotifyFile;
            stepno = model.StepNo.ToInt32();
            string[] signarry = WX.Flow.Model.Run.GetSignList(model.RunID.ToInt32(), WX.Main.CurUser.UserID);
            this.txt_sign.Text            = signarry[0];
            this.txtSealData.Value        = signarry[1];
            this.liCurUserSealButton.Text = signarry[2];
            this.liSignList.Text          = signarry[3];
            bool flag = true;

            if (model.state.ToInt32() >= 4)
            {
                flag            = false;
                Button2.Visible = model.state.ToInt32() == 4;
            }
            else
            {
                WX.Main.CurUser.LoadDutyUser(); WX.Main.CurUser.LoadMyDepartment(flag);
                WX.Flow.Model.Process.MODEL proc = WX.Flow.Model.Process.GetModel("select * from FL_Process where FlowID=" + model.FlowID.ToString() + " and StepNo=" + model.StepNo.ToString());
                int next_n = model.StepNo.ToInt32();
                if (proc != null && proc.Next_Nodes.ToString() != "")
                {
                    next_n = proc.StepNo.ToInt32();
                }
                WX.Flow.Model.Process.MODEL process = WX.Flow.Model.Process.GetModel("select * from FL_Process where FlowID=" + model.FlowID.ToString() + " and StepNo=" + next_n + " and(Priv_UserList like '%" + WX.Main.CurUser.UserID + "%'	or Priv_DutyList like'%" + WX.Main.CurUser.DutyUser.ID.ToString() + "%' or Priv_DeptList like'%" + WX.Main.CurUser.MyDepartMent.ID.ToString() + "%')");
                WX.Flow.Model.Process.MODEL proc2   = WX.Flow.Model.Process.GetModel("select * from FL_Process where FlowID=" + model.FlowID.ToString() + " and StepNo=" + next_n);


                WX.Flow.Model.Run.MODEL runmodel = WX.Flow.Model.Run.GetModel("select * from FL_Run where Id=" + model.RunID.ToString());
                WX.Model.User.MODEL     squser   = WX.Model.User.GetCache(model.UserID.ToString());
                if (runmodel.Deal_Flag.ToInt32() < 3)
                {
                    if (process != null)//经办人设置为我的
                    {
                        flag = true;
                    }
                    else if (proc2 != null)
                    {
                        if (proc2.Auto_Type.ToString() == "1" && runmodel.BeginUser.ToString() == WX.Main.CurUser.UserID)//经办人为流程发起人的
                        {
                            flag = true;
                        }
                        else if (proc2.Auto_Type.ToString() == "2" && WX.WXUser.GetDeptIDByUserID(runmodel.BeginUser.ToString()) == WX.Main.CurUser.MyDepartMent.ID.ToInt32() && (WX.Main.CurUser.MyDepartMent.Host.ToString() == WX.Main.CurUser.UserID || WX.Main.IsBestDuty(WX.Main.CurUser.MyDepartMent.ID.ToInt32(), WX.Main.CurUser.UserID)))//经办人为部门主管的
                        {
                            flag = true;
                        }
                        else if (proc2.Auto_Type.ToString() == "4" && WX.CommonUtils.GetParentDeptHost(squser.DepartmentID.ToInt32(), "Host") == WX.Main.CurUser.UserID)
                        {
                            flag = true;
                        }
                        else if (proc2.Auto_Type.ToString() == "5" && WX.CommonUtils.GetParentDeptHost(squser.DepartmentID.ToInt32(), "SubHosts") == WX.Main.CurUser.UserID)
                        {
                            flag = true;
                        }
                        else
                        {
                            flag = false;
                        }
                    }
                    else
                    {
                        flag = false;
                    }
                }
            }
            qz.Visible = flag;
            System.Data.DataTable query = ULCode.QDA.XSql.GetDataTable("select A.StepNo,A.Name,A.Next_Nodes from FL_Process A Left join FL_Run B on A.FlowID=B.FlowID where A.FlowId=" + model.FlowID.ToString() + " and B.ID=" + model.RunID.ToString() + " order by A.StepNo asc");
            this.ProcessRepeater.DataSource = query;
            this.ProcessRepeater.DataBind();
        }
        /// <summary>
        /// 保存表单及其它功能按钮
        /// </summary>
        private int Save(int state)
        {
            WX.XZ.NotifyFiles.MODEL model = WX.Request.rNotifyFile;
            //1.获取模型
            WX.Flow.Model.Run.MODEL runmodel = WX.Flow.Model.Run.GetModel("select * from FL_Run where Id=" + model.RunID.ToString());
            int stepno = model.StepNo.ToInt32();

            //2.取表单值
            runmodel.LoadMyForm(false);
            WX.Flow.FormFieldCollection ffc = runmodel.MyForm.GetPostedDatas();
            //3.上传附件并取得附件列表
            string             attach_nameList = String.Empty;
            string             attache_idlist  = String.Empty;
            string             uploadUserId    = WX.Main.CurUser.UserID;
            string             uploadIp        = WX.Main.getIp(this);
            HttpFileCollection hfc             = Request.Files;
            //WX.Flow.FormFieldCollection ffc = new WX.Flow.FormFieldCollection();
            //foreach (WX.Flow.FormField ff in runmodel.MyForm.Items_FormFieldCollection)
            //{
            //    ff.Value = this.Request.Form[ff.Id] == null ? "" : this.Request.Form[ff.Id];
            //    ffc.Add(ff);
            //}
            //
            //4.取得手写与签章信息
            string sealData = this.txtSealData.Value;

            WX.Flow.Model.Process.MODEL proc;

            WX.Flow.Model.Process.MODEL process = null;
            int iR = 0;

            if (state == 2)
            {
                model.state.value    = 2;
                model.StepNo.value   = 1;
                model.StepName.value = "文件拟写";
                proc    = WX.Flow.Model.Process.GetModel("select * from FL_Process where FlowID=" + runmodel.FlowId.ToString() + " and StepNo=" + model.StepNo.ToInt32());
                process = WX.Flow.Model.Process.GetModel("select * from FL_Process where FlowID=" + runmodel.FlowId.ToString() + " and StepNo=" + proc.Next_Nodes.ToInt32());
                runmodel.StepNo.value     = model.StepNo.value;
                runmodel.Next_Nodes.value = proc.Next_Nodes.value;
                WX.Main.AddLog(WX.LogType.Default, "文件通知审批未通过!", String.Format("{0}-{1}", model.ID.ToString(), model.Title.ToString()));
                //向拟写人发消息
                WX.Main.MessageSend("<a href=/Manage/XZ/NotifyFiles.aspx?mes=1&NotifyFileId=" + model.ID.ToString() + ">你似写的文件《" + model.Title.ToString() + "》——审批未通过被退回</a>", "/Manage/Main/messagelist.aspx", model.UserID.ToString(), WX.Main.CurUser.UserID, 5, 0);
            }
            else
            {
                proc = WX.Flow.Model.Process.GetModel("select * from FL_Process where FlowID=" + runmodel.FlowId.ToString() + " and StepNo=" + model.StepNo.ToInt32());
                if (proc != null && proc.Next_Nodes.ToString() != "" && proc.Next_Nodes.ToInt32() > 0)
                {
                    process = WX.Flow.Model.Process.GetModel("select * from FL_Process where FlowID=" + runmodel.FlowId.ToString() + " and StepNo=" + proc.Next_Nodes.ToInt32());
                }

                if (process == null)
                {
                    runmodel.Deal_Flag.value = WX.Flow.DealFlag.HasOperated;
                    model.state.value        = 4;
                    model.StepNo.value       = 0;
                    model.StepName.value     = "行政发布";
                    //审批完成,向行政发消息发布文件

                    WX.Main.MessageSend("<a href=/Manage/XZ/NotifyFileDetail.aspx?NotifyFileId=" + model.ID.ToString() + ">文件《" + model.Title.ToString() + "》通过审批!请行政尽快发布</a>", "/Manage/Main/messagelist.aspx", WX.CommonUtils.GetCAUserID, WX.Main.CurUser.UserID, 5, 0);
                    WX.Main.MessageSend("<a href=/Manage/XZ/NotifyFileDetail.aspx?NotifyFileId=" + model.ID.ToString() + ">文件《" + model.Title.ToString() + "》通过审批!请行政尽快发布</a>", "/Manage/Main/messagelist.aspx", WX.CommonUtils.GetAdminUserID, WX.Main.CurUser.UserID, 5, 0);
                }
                else
                {
                    runmodel.Deal_Flag.value = 1;
                    runmodel.StepNo.value    = model.StepNo.value = process.StepNo.value;
                    if (process.Next_Nodes.ToInt32() > 0)
                    {
                        runmodel.Next_Nodes.value = process.Next_Nodes.value;
                    }
                    else
                    {
                        runmodel.Next_Nodes.value = 0;
                    }
                    iR = 1;
                    model.state.value    = 3;
                    model.StepName.value = process.Name.value;
                    //向下一个人发消息,提醒审批
                    // WX.Main.MessageSend("<a href=/Manage/XZ/NotifyFileDetail.aspx?NotifyFileId=" + model.ID.ToString() + ">文件《" + model.Title.ToString() + "》通过审批!请行政尽快发布</a>", "/Manage/Main/messagelist.aspx", WX.CommonUtils.GetCAUserID, WX.Main.CurUser.UserID, 5, 0);
                    WX.Model.User.MODEL squser = WX.Model.User.NewDataModel(model.UserID.ToString());
                    if (process.Auto_Type.ToString() == "1")//经办人为流程发起人的
                    {
                        WX.Main.MessageSend("<a href=/Manage/XZ/NotifyFileDetail.aspx?NotifyFileId=" + model.ID.ToString() + ">" + squser.RealName.ToString() + "拟写的文件《" + model.Title.ToString() + "》!申请审批</a>", "/Manage/Main/messagelist.aspx", model.UserID.ToString(), WX.Main.CurUser.UserID, 5, 0);
                    }
                    else if (process.Auto_Type.ToString() == "2")//经办人为部门主管的
                    {
                        WX.Main.MessageSend("<a href=/Manage/XZ/NotifyFileDetail.aspx?NotifyFileId=" + model.ID.ToString() + ">" + squser.RealName.ToString() + "拟写的文件《" + model.Title.ToString() + "》申请主管审批!</a>", "/Manage/Main/messagelist.aspx", WX.CommonUtils.GetDeptUserID(1, "[Host]", squser.DepartmentID.ToInt32()), WX.Main.CurUser.UserID, 5, 0);
                    }
                    else if (process.Auto_Type.ToString() == "4")
                    {
                        WX.Main.MessageSend("<a href=/Manage/XZ/NotifyFileDetail.aspx?NotifyFileId=" + model.ID.ToString() + ">" + squser.RealName.ToString() + "拟写的文件《" + model.Title.ToString() + "》申请上级审批!</a>", "/Manage/Main/messagelist.aspx", WX.CommonUtils.GetParentDeptHost(squser.DepartmentID.ToInt32(), "Host"), WX.Main.CurUser.UserID, 5, 0);
                    }
                    else if (process.Auto_Type.ToString() == "5")
                    {
                        WX.Main.MessageSend("<a href=/Manage/XZ/NotifyFileDetail.aspx?NotifyFileId=" + model.ID.ToString() + ">" + squser.RealName.ToString() + "拟写的文件《" + model.Title.ToString() + "》申请分管领导审批!</a>", "/Manage/Main/messagelist.aspx", WX.CommonUtils.GetParentDeptHost(squser.DepartmentID.ToInt32(), "SubHosts"), WX.Main.CurUser.UserID, 5, 0);
                    }
                    else
                    {
                        System.Data.DataTable dt = ULCode.QDA.XSql.GetDataTable("select UserID from Tu_Users where 1=1" + (process.Priv_UserList.ToString() != "" ? " and UserID in('" + process.Priv_UserList.ToString().Replace(",", "','") + "')" : "") + (process.Priv_DutyList.ToString() != "" ? " and DutyId in(select ID from TE_DutyDetail where DutyID in(" + process.Priv_DutyList.ToString() + "))" : "") + (process.Priv_DeptList.ToString() != "" ? " and Priv_DeptList in(" + process.Priv_DeptList.ToString() + ")" : ""));
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            WX.Main.MessageSend("<a href=/Manage/XZ/NotifyFileDetail.aspx?NotifyFileId=" + model.ID.ToString() + ">" + squser.RealName.ToString() + "拟写的文件《" + model.Title.ToString() + "》!申请审批</a>", "/Manage/Main/messagelist.aspx", dt.Rows[i][0].ToString(), WX.Main.CurUser.UserID, 5, 0);
                        }
                    }
                }
                WX.Main.AddLog(WX.LogType.Default, "文件通知审批通过!", String.Format("{0}-{1}", model.ID.ToString(), model.Title.ToString()));
            }
            model.PublishTime.value = DateTime.Now;
            model.Update();
            runmodel.Save(stepno, ffc, attache_idlist, attach_nameList, this.txt_sign.Text, sealData, 1);

            pageinit();
            return(iR);
        }
        /// <summary>
        /// 保存表单及其它功能按钮
        /// </summary>
        private int Save()
        {
            //1.获取模型
            WX.Flow.Model.Run.MODEL runmodel = WX.Flow.Model.Run.GetModel("select * from FL_Run where Id=" + this.rRunId);

            //2.取表单值
            runmodel.LoadMyForm(false);
            WX.Flow.FormFieldCollection ffc = runmodel.MyForm.GetPostedDatas();
            //3.上传附件并取得附件列表
            string             attach_nameList = String.Empty;
            string             attache_idlist  = String.Empty;
            string             uploadUserId    = WX.Main.CurUser.UserID;
            string             uploadIp        = WX.Main.getIp(this);
            HttpFileCollection hfc             = Request.Files;

            for (int i = 0; i < hfc.Count; i++)
            {
                HttpPostedFile hpf = hfc[i];
                // 取文件后缀名
                string oldFileName = System.IO.Path.GetFileName(hpf.FileName);
                string ext         = System.IO.Path.GetExtension(hpf.FileName);
                string newFileName = DateTime.Now.ToString("yyyyMMddhhmmss fff") + ext;
                string newPath     = String.Format("/UploadFiles/Run/{0}", newFileName);
                if (hpf.ContentLength > 0)
                {
                    try
                    {
                        hpf.SaveAs(Server.MapPath(newPath));
                        //上传成功了
                        DateTime uploadTime = DateTime.Now;
                        string   cmdText    = String.Format("INSERT INTO FL_RunAttachs (RunId,StepNo,NewFileName,OldFileName,UploadUserID,UploadTime,UploadIP)"
                                                            + " VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}');SELECT @@IDENTITY as  IdentityID;"
                                                            , rRunId, runmodel.StepNo.ToString(), newPath, oldFileName, uploadUserId, DateTime.Now, uploadIp);
                        int id = ULCode.QDA.XSql.GetData(cmdText).ToInt32();
                        if (attach_nameList.Length > 0)
                        {
                            attach_nameList = attach_nameList + ",";
                        }
                        attach_nameList = attach_nameList + oldFileName;
                        if (attache_idlist.Length > 0)
                        {
                            attache_idlist = attache_idlist + ",";
                        }
                        attache_idlist = attache_idlist + id;
                    }
                    catch
                    {
                        ;
                    }
                }
            }
            //WX.Flow.FormFieldCollection ffc = new WX.Flow.FormFieldCollection();
            //foreach (WX.Flow.FormField ff in runmodel.MyForm.Items_FormFieldCollection)
            //{
            //    ff.Value = this.Request.Form[ff.Id] == null ? "" : this.Request.Form[ff.Id];
            //    ffc.Add(ff);
            //}
            //
            //4.取得手写与签章信息
            string sealData = this.txtSealData.Value;

            WX.Flow.Model.Process.MODEL proc = WX.Flow.Model.Process.GetModel("select * from FL_Process where FlowID=" + runmodel.FlowId.ToString() + " and StepNo=" + runmodel.StepNo.ToInt32());

            WX.Flow.Model.Process.MODEL process = WX.Flow.Model.Process.GetModel("select * from FL_Process where FlowID=" + runmodel.FlowId.ToString() + " and StepNo=" + (runmodel.StepNo.ToInt32() + 1));

            if (process == null)
            {
                runmodel.Deal_Flag.value = WX.Flow.DealFlag.HasOperated;
            }
            else
            {
                runmodel.Deal_Flag.value = 1;
                runmodel.StepNo.value    = runmodel.StepNo.ToInt32() + 1;
                if (process.Next_Nodes.ToString() != "")
                {
                    runmodel.Next_Nodes.value = process.Next_Nodes.value;
                }
                if (proc.Next_Nodes.ToString() == "")
                {
                    WX.Flow.Model.Process.MODEL proc2 = WX.Flow.Model.Process.GetModel("select * from FL_Process where FlowID=" + runmodel.FlowId.ToString() + " and StepNo=" + (runmodel.Next_Nodes.ToInt32() + 1));
                    if (proc2 == null)
                    {
                        runmodel.Deal_Flag.value = WX.Flow.DealFlag.HasOperated;
                    }
                }
            }
            int iR = runmodel.Save(proc.Next_Nodes.ToString() == "" ? runmodel.Next_Nodes.ToInt32() : proc.StepNo.ToInt32(), ffc, attache_idlist, attach_nameList, this.FORM_CONTENT.Text, sealData, 1);

            if (process != null)
            {
                WX.Model.User.MODEL squser = WX.Model.User.NewDataModel(runmodel.BeginUser.ToString());
                if (process.Auto_Type.ToString() == "1")//经办人为流程发起人的
                {
                    WX.Main.MessageSend("<a href=/Manage/Work/Work_MyCheck.aspx?flag=0&mes=1>" + runmodel.Name.ToString() + "(" + WX.CommonUtils.GetRealNameListByUserIdList(runmodel.BeginUser.ToString()) + ")——请尽快审批!</a>", "/Manage/Main/messagelist.aspx", runmodel.BeginUser.ToString(), WX.Main.CurUser.UserID, 12, 0);
                }
                else if (process.Auto_Type.ToString() == "2")//经办人为部门主管的
                {
                    WX.Main.MessageSend("<a href=/Manage/Work/Work_MyCheck.aspx?flag=0&mes=1>" + runmodel.Name.ToString() + "(" + WX.CommonUtils.GetRealNameListByUserIdList(runmodel.BeginUser.ToString()) + ")——请尽快审批!</a>", "/Manage/Main/messagelist.aspx", WX.CommonUtils.GetDeptUserID(1, "[Host]", squser.DepartmentID.ToInt32()), WX.Main.CurUser.UserID, 12, 0);
                }
                else if (process.Auto_Type.ToString() == "4")
                {
                    WX.Main.MessageSend("<a href=/Manage/Work/Work_MyCheck.aspx?flag=0&mes=1>" + runmodel.Name.ToString() + "(" + WX.CommonUtils.GetRealNameListByUserIdList(runmodel.BeginUser.ToString()) + ")——请尽快审批!</a>", "/Manage/Main/messagelist.aspx", WX.CommonUtils.GetParentDeptHost(squser.DepartmentID.ToInt32(), "Host"), WX.Main.CurUser.UserID, 12, 0);
                }
                else if (process.Auto_Type.ToString() == "5")
                {
                    WX.Main.MessageSend("<a href=/Manage/Work/Work_MyCheck.aspx?flag=0&mes=1>" + runmodel.Name.ToString() + "(" + WX.CommonUtils.GetRealNameListByUserIdList(runmodel.BeginUser.ToString()) + ")——请尽快审批!</a>", "/Manage/Main/messagelist.aspx", WX.CommonUtils.GetParentDeptHost(squser.DepartmentID.ToInt32(), "SubHosts"), WX.Main.CurUser.UserID, 12, 0);
                }
                else
                {
                    System.Data.DataTable dt = ULCode.QDA.XSql.GetDataTable("select UserID from Tu_Users where 1=1" + (process.Priv_UserList.ToString() != "" ? " and UserID in('" + process.Priv_UserList.ToString().Replace(",", "','") + "')" : "") + (process.Priv_DutyList.ToString() != "" ? " and DutyId in(select ID from TE_DutyDetail where DutyID in(" + process.Priv_DutyList.ToString() + "))" : "") + (process.Priv_DeptList.ToString() != "" ? " and Priv_DeptList in(" + process.Priv_DeptList.ToString() + ")" : ""));
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        WX.Main.MessageSend("<a href=/Manage/Work/Work_MyCheck.aspx?flag=0&mes=1>" + runmodel.Name.ToString() + "(" + WX.CommonUtils.GetRealNameListByUserIdList(runmodel.BeginUser.ToString()) + ")——请尽快审批!</a>", "/Manage/Main/messagelist.aspx", dt.Rows[i][0].ToString(), WX.Main.CurUser.UserID, 12, 0);
                    }
                }
            }
            return(iR);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request["TrainID"] != null && Request["TrainID"] != "")
                {
                    WX.XZ.Train.MODEL trainmodel = WX.XZ.Train.NewDataModel(Request["TrainID"]);
                    li_title.Text           = trainmodel.Title.ToString();
                    drop_type.SelectedValue = trainmodel.Type.ToString();
                    li_addr.Text            = trainmodel.Addr.ToString();
                    li_runtime.Text         = trainmodel.RunTime.ToString();
                    li_usersname.Text       = trainmodel.UsersName.ToString();
                    li_content.Text         = trainmodel.Content.ToString();
                    string userid = WX.Main.CurUser.UserID;
                    if (Request["UserID"] != null && Request["UserID"] != "")
                    {
                        userid = Request["UserID"];
                    }
                    WX.XZ.TrainUsers.MODEL tusermodel = WX.XZ.TrainUsers.GetModelToTrainID(trainmodel.ID.ToInt32(), userid);
                    if (tusermodel != null)
                    {
                        if (tusermodel.RunID.ToString() != "")
                        {
                            WX.Flow.Model.Run.MODEL runmodel = WX.Flow.Model.Run.GetModel("select * from FL_Run where Id=" + tusermodel.RunID.ToString());
                            //2.装载Form表单
                            runmodel.LoadMyForm(false);
                            li_formcontent.Text = runmodel.GenerateHtmls(runmodel.Id.ToInt32());
                        }
                        else if (trainmodel.FlowID.ToString() != "")
                        {
                            WX.Flow.Model.Flow.MODEL    flow      = WX.Flow.Model.Flow.GetCache(trainmodel.FlowID.ToInt32());
                            WX.Flow.Model.Form.MODEL    formmodel = WX.Flow.Model.Form.NewDataModel(flow.FormId);
                            WX.Flow.FormFieldCollection ffedit    = new WX.Flow.FormFieldCollection();
                            WX.Flow.FormFieldCollection ffhidden  = new WX.Flow.FormFieldCollection();
                            li_formcontent.Text = formmodel.GenerateHtmls(formmodel.Items_FormFieldCollection, ffedit, ffhidden, WX.Main.CurUser.UserID).Replace("-SYS_IP-", getIp());

                            if (Request["UserID"] == null || Request["UserID"].ToString() == "")
                            {
                                Button1.Visible = true;
                                if (tusermodel.State.ToInt32() == 0)
                                {
                                    tusermodel.State.value = 1;
                                    tusermodel.Update();
                                }
                            }
                        }
                        if (Request["UserID"] == null || Request["UserID"].ToString() == "")
                        {
                            try
                            {
                                WX.Main.MessageToHistory_where(String.Format("SendToUserId='{0}' and RedirectToUrl like'%?TrainID={1}%'", WX.Main.CurUser.UserID, Request["TrainID"]));
                            }
                            catch
                            {
                            }
                        }
                        if (li_formcontent.Text != "")
                        {
                            Literal1.Text = "学习心得";
                        }
                    }
                }
            }
        }