Exemple #1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        private static HrsLeaveOpinionEntity GetHrsLeaveOpinionModel(DataTable dt)
        {
            if (dt != null && dt.Rows != null && dt.Rows.Count > 0)
            {
                HrsLeaveOpinionEntity model = new HrsLeaveOpinionEntity();
                if (dt.Rows[0]["ID"].ToString() != "")
                {
                    model.ID = int.Parse(dt.Rows[0]["ID"].ToString());
                }

                model.AppInstanceID = dt.Rows[0]["AppInstanceID"].ToString();
                model.ActivityName  = dt.Rows[0]["ActivityName"].ToString();
                model.ActivityID    = dt.Rows[0]["ActivityID"].ToString();
                model.Remark        = dt.Rows[0]["Remark"].ToString();
                if (dt.Rows[0]["ChangedTime"].ToString() != "")
                {
                    model.ChangedTime = DateTime.Parse(dt.Rows[0]["ChangedTime"].ToString());
                }
                if (dt.Rows[0]["ChangedUserID"].ToString() != "")
                {
                    model.ChangedUserID = dt.Rows[0]["ChangedUserID"].ToString();
                }
                model.ChangedUserName = dt.Rows[0]["ChangedUserName"].ToString();

                return(model);
            }
            else
            {
                return(null);
            }
        }
Exemple #2
0
        /// <summary>
        /// 新增一条业务流程数据
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static int AddHrsLeaveOpinion(HrsLeaveOpinionEntity model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into HrsLeaveOpinion(");
            strSql.Append("AppInstanceID,ActivityName,ActivityID,Remark,ChangedTime,ChangedUserID,ChangedUserName");
            strSql.Append(") values (");
            strSql.Append("@AppInstanceID,@ActivityName,@ActivityID,@Remark,@ChangedTime,@ChangedUserID,@ChangedUserName");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@AppInstanceID",   SqlDbType.VarChar,     50),
                new SqlParameter("@ActivityName",    SqlDbType.NVarChar,    50),
                new SqlParameter("@ActivityID",      SqlDbType.VarChar,     50),
                new SqlParameter("@Remark",          SqlDbType.NVarChar,  1000),
                new SqlParameter("@ChangedTime",     SqlDbType.DateTime),
                new SqlParameter("@ChangedUserID",   SqlDbType.VarChar,     50),
                new SqlParameter("@ChangedUserName", SqlDbType.NVarChar, 50)
            };
            int idx = 0;

            parameters[idx++].Value = model.AppInstanceID;
            parameters[idx++].Value = model.ActivityName;
            parameters[idx++].Value = model.ActivityID;
            parameters[idx++].Value = model.Remark;
            parameters[idx++].Value = model.ChangedTime;
            parameters[idx++].Value = model.ChangedUserID;
            parameters[idx++].Value = model.ChangedUserName;

            object obj = SQLHelper.ExecuteScalar(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
        //提交请假信息
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                string  processGUID = this.txtProcessGUID.Value.ToString();
                decimal days        = Helper.ConverToDecimal(this.txtDays.Value);
                int     leaveType   = Helper.ConverToInt32(selectLeaveType.Value);
                string  strNextActivityPerformers = hiddenNextActivityPerformers.Value.ToString().Trim();

                IDictionary <string, PerformerList> nextActivityPerformers = NextActivityPerformers(strNextActivityPerformers);
                if (nextActivityPerformers == null)
                {
                    base.RegisterStartupScript("", "<script>alert('请选择办理步骤或办理人员--Please select next step and user');</script>");
                    return;
                }

                DateTime now = DateTime.Now;

                //请假业务数据
                HrsLeaveEntity hrsLeaveEntity = new HrsLeaveEntity();
                hrsLeaveEntity.LeaveType = leaveType;
                hrsLeaveEntity.Days      = days;
                try
                {
                    hrsLeaveEntity.FromDate = Helper.ConvertToDateTime(this.txtFromDate.Value, now);
                }
                catch (Exception ex)
                {
                    hrsLeaveEntity.FromDate = now;
                }
                try
                {
                    hrsLeaveEntity.ToDate = Helper.ConvertToDateTime(this.txtToDate.Value, now);
                }
                catch (Exception ex)
                {
                    hrsLeaveEntity.ToDate = now;
                }
                hrsLeaveEntity.CurrentActivityText = string.Empty;
                hrsLeaveEntity.Status          = 0;
                hrsLeaveEntity.CreatedUserID   = LoginUserID;
                hrsLeaveEntity.CreatedUserName = this.LoginUserName;
                hrsLeaveEntity.CreatedDate     = now;

                int instanceId = WorkFlows.AddHrsLeave(hrsLeaveEntity);
                if (instanceId > 0)
                {
                    //调用流程
                    IWorkflowService service = new WorkflowService();

                    WfAppRunner initiator = new WfAppRunner();
                    initiator.AppName       = "请假流程(AskforLeaveProcess)";
                    initiator.AppInstanceID = instanceId.ToString();
                    initiator.ProcessGUID   = processGUID;
                    initiator.UserID        = LoginUserID.ToString();
                    initiator.UserName      = LoginUserName;
                    initiator.Conditions    = GetCondition(string.Format("days-{0}", days));
                    WfExecutedResult startedResult = service.StartProcess(initiator);
                    if (startedResult.Status != WfExecutedStatus.Success)
                    {
                        base.RegisterStartupScript("", "<script>alert('" + startedResult.Message + "');</script>");
                        return;
                    }

                    //送往下一步

                    /*
                     * PerformerList pList = new PerformerList();
                     * pList.Add(new Performer(nextUserID.ToString(), nextUserName));
                     *
                     * initiator.NextActivityPerformers = new Dictionary<String, PerformerList>();
                     * initiator.NextActivityPerformers.Add(stepGuid, pList);
                     */
                    initiator.NextActivityPerformers = nextActivityPerformers;
                    WfExecutedResult runAppResult = service.RunProcessApp(initiator);
                    if (runAppResult.Status != WfExecutedStatus.Success)
                    {
                        base.RegisterStartupScript("", "<script>alert('" + runAppResult.Message + "');</script>");
                        return;
                    }
                    //保存业务数据
                    //BizAppFlowEntity AppFlowEntity = new Entity.BizAppFlowEntity();
                    //AppFlowEntity.AppName = "流程发起";
                    //AppFlowEntity.AppInstanceID = instanceId.ToString();
                    //AppFlowEntity.ActivityName = "流程发起";
                    //AppFlowEntity.Remark = string.Format("申请人:{0}-{1}", LoginUserID, LoginUserName);
                    //AppFlowEntity.ChangedTime = now;
                    //AppFlowEntity.ChangedUserID = LoginUserID.ToString();
                    //AppFlowEntity.ChangedUserName = LoginUserName;

                    //WorkFlows.AddBizAppFlow(AppFlowEntity);

                    HrsLeaveOpinionEntity hrsleaveOpinionEntity = new HrsLeaveOpinionEntity();
                    hrsleaveOpinionEntity.AppInstanceID   = instanceId.ToString();
                    hrsleaveOpinionEntity.ActivityID      = System.Guid.Empty.ToString();
                    hrsleaveOpinionEntity.ActivityName    = "流程发起(Apply)";
                    hrsleaveOpinionEntity.Remark          = string.Format("申请人(Applicant):{0}-{1}", LoginUserID, LoginUserName);
                    hrsleaveOpinionEntity.ChangedTime     = now;
                    hrsleaveOpinionEntity.ChangedUserID   = LoginUserID.ToString();
                    hrsleaveOpinionEntity.ChangedUserName = LoginUserName;
                    WorkFlows.AddHrsLeaveOpinion(hrsleaveOpinionEntity);


                    base.RegisterStartupScript("", "<script>alert('流程发起成功--Successed');window.location.href='FlowList.aspx';</script>");
                }
            }
            catch (Exception ex)
            {
                base.RegisterStartupScript("", "<script>alert('流程发起出现异常--EXCEPTION:" + ex.ToString() + "');</script>");
            }
        }
Exemple #4
0
 /// <summary>
 /// 新增一条业务流程数据
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static int AddHrsLeaveOpinion(HrsLeaveOpinionEntity model)
 {
     model.ChangedTime = DateTime.Now;
     return(WorkFlowManager.AddHrsLeaveOpinion(model));
 }
Exemple #5
0
        //送往下一步
        protected void btnSendNext_Click(object sender, EventArgs e)
        {
            try
            {
                DateTime now = DateTime.Now;
                string   CurrentActivityText  = string.Empty;
                string   currentOpinionRemark = string.Empty;
                string   processGUID          = this.txtProcessGUID.Value.ToString();
                decimal  days                      = Helper.ConverToDecimal(this.txtDays.Value);
                string   instanceId                = this.hiddenInstanceId.Value;
                string   DepManagerRemark          = this.txtDepmanagerRemark.Value;
                string   DirectorRemark            = this.txtDirectorRemark.Value;
                string   DeputyGeneralRemark       = this.txtDeputyGeneralRemark.Value;
                string   GeneralManagerRemark      = this.txtGeneralManagerRemark.Value;
                int      activityInstanceID        = Helper.ConverToInt32(hiddenActivityInstanceID.Value);
                string   strNextActivityPerformers = hiddenNextActivityPerformers.Value.ToString().Trim();
                IDictionary <string, PerformerList> nextActivityPerformers = NextActivityPerformers(strNextActivityPerformers);
                if (nextActivityPerformers == null)
                {
                    base.RegisterStartupScript("", "<script>alert('请选择办理步骤或办理人员--Please select next step and user');</script>");
                    return;
                }
                switch (hiddenPerformField.Value.ToString())
                {
                case "DepManager":    //部门经理
                    currentOpinionRemark = this.txtDepmanagerRemark.Value;
                    break;

                case "Director":    //主管总监
                    currentOpinionRemark = this.txtDirectorRemark.Value;
                    break;

                case "Deputy":    //副总经理
                    currentOpinionRemark = this.txtDeputyGeneralRemark.Value;
                    break;

                case "General":    //总经理
                    currentOpinionRemark = this.txtGeneralManagerRemark.Value;
                    break;
                }

                if (!string.IsNullOrEmpty(instanceId))
                {
                    //调用流程
                    IWorkflowService service = new WorkflowService();

                    WfAppRunner initiator = new WfAppRunner();
                    initiator.AppName                = "请假流程--AskforLeaveProcess";
                    initiator.AppInstanceID          = instanceId;
                    initiator.ProcessGUID            = processGUID;
                    initiator.UserID                 = LoginUserID.ToString();
                    initiator.UserName               = LoginUserName;
                    initiator.Conditions             = GetCondition(string.Format("days-{0}", days));
                    initiator.NextActivityPerformers = nextActivityPerformers;
                    WfExecutedResult runAppResult = service.RunProcessApp(initiator);
                    if (runAppResult.Status != WfExecutedStatus.Success)
                    {
                        base.RegisterStartupScript("", "<script>alert('" + runAppResult.Message + "');</script>");
                        return;
                    }

                    ActivityInstanceEntity activityInstanceEntity = service.GetActivityInstance(activityInstanceID);
                    if (activityInstanceEntity != null)
                    {
                        CurrentActivityText = activityInstanceEntity.ActivityName;
                    }
                    try
                    {
                        //保存业务数据
                        //BizAppFlowEntity AppFlowEntity = new Entity.BizAppFlowEntity();
                        //AppFlowEntity.AppName = "请假流程";
                        //AppFlowEntity.AppInstanceID = instanceId.ToString();
                        //AppFlowEntity.ActivityName = CurrentActivityText;
                        //AppFlowEntity.Remark = string.Format("{0}(ID:{1}) {2}", LoginUserName, LoginUserID, currentOpinionRemark);
                        //AppFlowEntity.ChangedTime = now;
                        //AppFlowEntity.ChangedUserID = LoginUserID.ToString();
                        //AppFlowEntity.ChangedUserName = LoginUserName;


                        HrsLeaveOpinionEntity hrsleaveOpinionEntity = new HrsLeaveOpinionEntity();
                        hrsleaveOpinionEntity.AppInstanceID   = instanceId.ToString();
                        hrsleaveOpinionEntity.ActivityID      = activityInstanceEntity.ActivityGUID.ToString();
                        hrsleaveOpinionEntity.ActivityName    = CurrentActivityText;
                        hrsleaveOpinionEntity.Remark          = string.Format("{0}(ID:{1}) {2}", LoginUserName, LoginUserID, currentOpinionRemark);
                        hrsleaveOpinionEntity.ChangedTime     = now;
                        hrsleaveOpinionEntity.ChangedUserID   = LoginUserID.ToString();
                        hrsleaveOpinionEntity.ChangedUserName = LoginUserName;
                        WorkFlows.AddHrsLeaveOpinion(hrsleaveOpinionEntity);
                    }
                    catch (Exception ex)
                    { }

                    try
                    {
                        HrsLeaveEntity hrsLeaveEntity = new Entity.HrsLeaveEntity();
                        hrsLeaveEntity.ID = Helper.ConverToInt32(instanceId);
                        hrsLeaveEntity.DepManagerRemark     = DepManagerRemark;
                        hrsLeaveEntity.DirectorRemark       = DirectorRemark;
                        hrsLeaveEntity.DeputyGeneralRemark  = DeputyGeneralRemark;
                        hrsLeaveEntity.GeneralManagerRemark = GeneralManagerRemark;
                        hrsLeaveEntity.CurrentActivityText  = CurrentActivityText;
                        WorkFlows.UpdateHrsLeave(hrsLeaveEntity);
                    }
                    catch (Exception ex)
                    { }

                    base.RegisterStartupScript("", "<script>alert('办理成功--Successed');window.location.href='FlowList.aspx';</script>");
                }
            }
            catch (Exception ex)
            {
                base.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('流程发起出现异常--EXCEPTION:" + ex.ToString() + "');</script>");
            }
        }