Beispiel #1
0
        /// <summary>ワークフロー承認を依頼します。</summary>
        /// <param name="nextWorkflow">選択したワークフロー承認依頼</param>
        /// <param name="workflowControlNo">ワークフロー管理番号(必須)</param>
        /// <param name="fromUserId">FromユーザID(必須)</param>
        /// <param name="toUserId">ToユーザID(TurnBack、Replyの際に必要)</param>
        /// <param name="currentWorkflowReserveArea">T_CurrentWorkflowの予備領域(任意)</param>
        /// <param name="replyDeadline">回答希望日(任意)</param>
        /// <returns>メール・テンプレートID</returns>
        public int RequestWfApproval(
            DataRow nextWorkflow, string workflowControlNo,
            decimal fromUserId, decimal?toUserId,
            string currentWorkflowReserveArea, DateTime?replyDeadline)
        {
            #region チェック処理を実装

            if (nextWorkflow == null)
            {
                throw new BusinessSystemException(
                          MyBusinessSystemExceptionMessage.WORKFLOW_ERROR[0],
                          String.Format(MyBusinessSystemExceptionMessage.WORKFLOW_ERROR[1],
                                        String.Format(MyBusinessSystemExceptionMessage.WORKFLOW_ERROR_CHECK_EMPTY, "nextWorkflow")));
            }
            else if (!nextWorkflow.Table.Columns.Contains("SubSystemId"))
            {
                throw new BusinessSystemException(
                          MyBusinessSystemExceptionMessage.WORKFLOW_ERROR[0],
                          String.Format(MyBusinessSystemExceptionMessage.WORKFLOW_ERROR[1],
                                        String.Format(MyBusinessSystemExceptionMessage.WORKFLOW_ERROR_CHECK_FIELD_ISNT_CONTAINED,
                                                      "SubSystemId", "nextWorkflow")));
            }
            else if (string.IsNullOrEmpty(workflowControlNo))
            {
                throw new BusinessSystemException(
                          MyBusinessSystemExceptionMessage.WORKFLOW_ERROR[0],
                          String.Format(MyBusinessSystemExceptionMessage.WORKFLOW_ERROR[1],
                                        String.Format(MyBusinessSystemExceptionMessage.WORKFLOW_ERROR_CHECK_EMPTY, "workflowControlNo")));
            }

            // ユーザIDからユーザ情報を取得
            string fromUserInfo = Workflow.GetUserInfo(fromUserId);

            string toUserInfo = "";

            if (toUserId.HasValue &&
                (string)nextWorkflow["ActionType"] != "End")    // Endの時は不要
            {
                toUserInfo = Workflow.GetUserInfo(toUserId.Value);
            }

            #endregion

            // --------------------------------------------------
            // 現在の履歴件数を取得。
            // --------------------------------------------------
            // T_WorkflowHistoryのCount
            // --------------------------------------------------
            CmnDao dao = new CmnDao(this.Dam);

            dao.SQLFileName = "RequestApproval_Count.sql";
            dao.SetParameter("WorkflowControlNo", workflowControlNo);
            int recordCount = ((int)dao.ExecSelectScalar());

            // --------------------------------------------------
            // ワークフロー承認を依頼
            // --------------------------------------------------
            // T_CurrentWorkflowのUPDATE
            // --------------------------------------------------
            DaoT_CurrentWorkflow daoT_CurrentWorkflow = new DaoT_CurrentWorkflow(this.Dam);

            // 主キー情報
            daoT_CurrentWorkflow.PK_WorkflowControlNo = workflowControlNo;

            // 履歴番号は履歴件数+1
            daoT_CurrentWorkflow.Set_HistoryNo_forUPD = recordCount + 1;

            daoT_CurrentWorkflow.Set_WfPositionId_forUPD = nextWorkflow["WfPositionId"];
            daoT_CurrentWorkflow.Set_WorkflowNo_forUPD   = nextWorkflow["WorkflowNo"];
            daoT_CurrentWorkflow.Set_FromUserId_forUPD   = fromUserId; // 実際のユーザIDを入力する。
            daoT_CurrentWorkflow.Set_FromUserInfo_forUPD = fromUserInfo;
            daoT_CurrentWorkflow.Set_ActionType_forUPD   = nextWorkflow["ActionType"];

            if (toUserId.HasValue &&
                ((string)nextWorkflow["ActionType"] == "TurnBack" || (string)nextWorkflow["ActionType"] == "Reply"))
            {
                // ActionTypeがTurnBack or Replyで、toUserIDがnullで無い場合、
                // 指定のtoUserIDにTurnBack or Replyする。
                daoT_CurrentWorkflow.Set_ToUserId_forUPD = toUserId;
            }
            else
            {
                // 上記以外は、nextWorkflow["ToUserId"]を指定する。
                daoT_CurrentWorkflow.Set_ToUserId_forUPD = nextWorkflow["ToUserId"];
            }

            daoT_CurrentWorkflow.Set_ToUserInfo_forUPD             = toUserInfo;
            daoT_CurrentWorkflow.Set_ToUserPositionTitlesId_forUPD = nextWorkflow["ToUserPositionTitlesId"];
            daoT_CurrentWorkflow.Set_NextWfPositionId_forUPD       = nextWorkflow["NextWfPositionId"];
            daoT_CurrentWorkflow.Set_NextWorkflowNo_forUPD         = nextWorkflow["NextWorkflowNo"];
            daoT_CurrentWorkflow.Set_ReserveArea_forUPD            = currentWorkflowReserveArea;
            //daoT_CurrentWorkflow.Set_ExclusiveKey_forUPD = "";

            if ((string)nextWorkflow["ActionType"] == "TurnBack" ||
                (string)nextWorkflow["ActionType"] == "Reply")
            {
                // ActionTypeがTurnBack or Replyの場合
                daoT_CurrentWorkflow.Set_ReplyDeadline_forUPD = DBNull.Value;
            }
            else
            {
                daoT_CurrentWorkflow.Set_ReplyDeadline_forUPD = replyDeadline;
            }

            daoT_CurrentWorkflow.Set_StartDate_forUPD          = DateTime.Now;
            daoT_CurrentWorkflow.Set_AcceptanceDate_forUPD     = DBNull.Value;
            daoT_CurrentWorkflow.Set_AcceptanceUserId_forUPD   = DBNull.Value;
            daoT_CurrentWorkflow.Set_AcceptanceUserInfo_forUPD = DBNull.Value;

            daoT_CurrentWorkflow.D3_Update();

            // --------------------------------------------------
            // 完了(T_WorkflowHistoryのEndDate項目を更新)
            // --------------------------------------------------
            // T_WorkflowHistoryのUPDATE
            // --------------------------------------------------
            DaoT_WorkflowHistory daoT_WorkflowHistory = new DaoT_WorkflowHistory(this.Dam);

            // PK
            daoT_WorkflowHistory.PK_WorkflowControlNo = workflowControlNo;
            daoT_WorkflowHistory.PK_HistoryNo         = recordCount;

            // EndDate
            daoT_WorkflowHistory.Set_EndDate_forUPD = DateTime.Now;

            daoT_WorkflowHistory.S3_Update();

            //---

            // 完了
            if ((string)nextWorkflow["ActionType"] == "End")
            {
                // --------------------------------------------------
                // 完了の場合(T_WorkflowのEndDate項目を更新)
                // --------------------------------------------------
                // T_WorkflowのUPDATE
                // --------------------------------------------------
                DaoT_Workflow daoT_Workflow = new DaoT_Workflow(this.Dam);

                // PK
                daoT_Workflow.PK_WorkflowControlNo = workflowControlNo;

                // EndDate
                daoT_Workflow.Set_EndDate_forUPD = DateTime.Now;

                daoT_Workflow.S3_Update();

                // --------------------------------------------------
                // 履歴に移動
                // --------------------------------------------------
                // T_CurrentWorkflow→T_WorkflowHistory
                // --------------------------------------------------
                dao.SQLFileName = "RequestApproval_Move.sql";
                dao.SetParameter("WorkflowControlNo", workflowControlNo);
                dao.ExecInsUpDel_NonQuery();
            }

            // リターン(MailTemplateId)
            if (nextWorkflow["MailTemplateId"] == DBNull.Value)
            {
                return(0);
            }
            else
            {
                return((int)nextWorkflow["MailTemplateId"]);
            }
        }
Beispiel #2
0
        /// <summary>
        /// This method is used to terminate the workflow forecefully
        /// by updating EndDate column of T_Workflow table with enddate.
        /// </summary>
        /// <param name="nextWorkflow"></param>
        /// <param name="workflowControlNo"></param>
        /// <param name="fromUserId"></param>
        /// <param name="currentWorkflowReserveArea"></param>
        /// <returns></returns>
        public int ForcedTermination(DataRow nextWorkflow, string workflowControlNo, decimal fromUserId, string currentWorkflowReserveArea)
        {
            #region チェック処理を実装

            if (nextWorkflow == null)
            {
                throw new BusinessSystemException(
                          MyBusinessSystemExceptionMessage.WORKFLOW_ERROR[0],
                          String.Format(MyBusinessSystemExceptionMessage.WORKFLOW_ERROR[1],
                                        String.Format(MyBusinessSystemExceptionMessage.WORKFLOW_ERROR_CHECK_EMPTY, "nextWorkflow")));
            }
            else if (!nextWorkflow.Table.Columns.Contains("SubSystemId"))
            {
                throw new BusinessSystemException(
                          MyBusinessSystemExceptionMessage.WORKFLOW_ERROR[0],
                          String.Format(MyBusinessSystemExceptionMessage.WORKFLOW_ERROR[1],
                                        String.Format(MyBusinessSystemExceptionMessage.WORKFLOW_ERROR_CHECK_FIELD_ISNT_CONTAINED,
                                                      "SubSystemId", "nextWorkflow")));
            }
            else if (string.IsNullOrEmpty(workflowControlNo))
            {
                throw new BusinessSystemException(
                          MyBusinessSystemExceptionMessage.WORKFLOW_ERROR[0],
                          String.Format(MyBusinessSystemExceptionMessage.WORKFLOW_ERROR[1],
                                        String.Format(MyBusinessSystemExceptionMessage.WORKFLOW_ERROR_CHECK_EMPTY, "workflowControlNo")));
            }

            // ユーザIDからユーザ情報を取得
            string fromUserInfo = Workflow.GetUserInfo(fromUserId);

            string toUserInfo = "";

            #endregion

            // --------------------------------------------------
            // 現在の履歴件数を取得。
            // --------------------------------------------------
            //Gets the record count from T_WorkflowHistory table
            // --------------------------------------------------
            CmnDao dao = new CmnDao(this.Dam);

            dao.SQLFileName = "RequestApproval_Count.sql";
            dao.SetParameter("WorkflowControlNo", workflowControlNo);
            int recordCount = ((int)dao.ExecSelectScalar());

            // --------------------------------------------------
            // ワークフロー承認を依頼
            // --------------------------------------------------
            // T_CurrentWorkflowのUPDATE
            // --------------------------------------------------
            DaoT_CurrentWorkflow daoT_CurrentWorkflow = new DaoT_CurrentWorkflow(this.Dam);

            // 主キー情報
            daoT_CurrentWorkflow.PK_WorkflowControlNo = workflowControlNo;

            // 履歴番号は履歴件数+1
            daoT_CurrentWorkflow.Set_HistoryNo_forUPD = recordCount + 1;

            daoT_CurrentWorkflow.Set_WfPositionId_forUPD = nextWorkflow["WfPositionId"];
            daoT_CurrentWorkflow.Set_WorkflowNo_forUPD   = nextWorkflow["WorkflowNo"];
            daoT_CurrentWorkflow.Set_FromUserId_forUPD   = fromUserId; // 実際のユーザIDを入力する。
            daoT_CurrentWorkflow.Set_FromUserInfo_forUPD = fromUserInfo;
            //Updates the ActionType with Abnormal termination
            daoT_CurrentWorkflow.Set_ActionType_forUPD = "ABEnd";

            // 上記以外は、nextWorkflow["ToUserId"]を指定する。
            daoT_CurrentWorkflow.Set_ToUserId_forUPD = nextWorkflow["ToUserId"];

            daoT_CurrentWorkflow.Set_ToUserInfo_forUPD             = toUserInfo;
            daoT_CurrentWorkflow.Set_ToUserPositionTitlesId_forUPD = nextWorkflow["ToUserPositionTitlesId"];
            daoT_CurrentWorkflow.Set_NextWfPositionId_forUPD       = nextWorkflow["NextWfPositionId"];
            daoT_CurrentWorkflow.Set_NextWorkflowNo_forUPD         = nextWorkflow["NextWorkflowNo"];
            daoT_CurrentWorkflow.Set_ReserveArea_forUPD            = currentWorkflowReserveArea;

            daoT_CurrentWorkflow.Set_StartDate_forUPD          = DateTime.Now;
            daoT_CurrentWorkflow.Set_AcceptanceDate_forUPD     = DBNull.Value;
            daoT_CurrentWorkflow.Set_AcceptanceUserId_forUPD   = DBNull.Value;
            daoT_CurrentWorkflow.Set_AcceptanceUserInfo_forUPD = DBNull.Value;

            daoT_CurrentWorkflow.D3_Update();

            // --------------------------------------------------
            // 完了(T_WorkflowHistoryのEndDate項目を更新)
            // --------------------------------------------------
            // T_WorkflowHistoryのUPDATE
            // --------------------------------------------------
            DaoT_WorkflowHistory daoT_WorkflowHistory = new DaoT_WorkflowHistory(this.Dam);

            // PK
            daoT_WorkflowHistory.PK_WorkflowControlNo = workflowControlNo;
            daoT_WorkflowHistory.PK_HistoryNo         = recordCount;

            //Updates the EndDate to current date for forceful termination
            daoT_WorkflowHistory.Set_EndDate_forUPD = DateTime.Now;

            daoT_WorkflowHistory.S3_Update();

            //---

            // 完了
            // --------------------------------------------------
            // 完了の場合(T_WorkflowのEndDate項目を更新)
            // --------------------------------------------------
            // T_WorkflowのUPDATE
            // --------------------------------------------------
            DaoT_Workflow daoT_Workflow = new DaoT_Workflow(this.Dam);

            // PK
            daoT_Workflow.PK_WorkflowControlNo = workflowControlNo;

            //Updates the EndDate to current date for forceful termination
            daoT_Workflow.Set_EndDate_forUPD = DateTime.Now;

            daoT_Workflow.S3_Update();

            // --------------------------------------------------
            // 履歴に移動
            // --------------------------------------------------
            // T_CurrentWorkflow→T_WorkflowHistory
            // --------------------------------------------------
            dao.SQLFileName = "RequestApproval_Move.sql";
            dao.SetParameter("WorkflowControlNo", workflowControlNo);
            dao.ExecInsUpDel_NonQuery();

            // リターン(MailTemplateId)
            if (nextWorkflow["MailTemplateId"] == DBNull.Value)
            {
                return(0);
            }
            else
            {
                return((int)nextWorkflow["MailTemplateId"]);
            }
        }
Beispiel #3
0
        /// <summary>新しいワークフローを開始します。</summary>
        /// <param name="startWorkflow">新規ワークフロー</param>
        /// <param name="workflowControlNo">ワークフロー管理番号(必須)</param>
        /// <param name="fromUserId">FromユーザID(個人ID 必須)</param>
        /// <param name="toUserId">ToユーザID(個人ID 任意)</param>
        /// <param name="workflowReserveArea">T_Workflowの予備領域(任意)</param>
        /// <param name="currentWorkflowReserveArea">T_CurrentWorkflowの予備領域(任意)</param>
        /// <param name="replyDeadline">回答希望日(任意)</param>
        /// <returns>メール・テンプレートID</returns>
        public int StartWorkflow(DataRow startWorkflow,
                                 string workflowControlNo, decimal fromUserId, decimal toUserId,
                                 string workflowReserveArea, string currentWorkflowReserveArea, DateTime?replyDeadline)
        {
            #region チェック処理を実装

            if (string.IsNullOrEmpty(workflowControlNo))
            {
                throw new BusinessSystemException(
                          MyBusinessSystemExceptionMessage.WORKFLOW_ERROR[0],
                          String.Format(MyBusinessSystemExceptionMessage.WORKFLOW_ERROR[1],
                                        String.Format(MyBusinessSystemExceptionMessage.WORKFLOW_ERROR_CHECK_EMPTY, "workflowControlNo")));
            }

            #endregion

            // ユーザIDからユーザ情報を取得
            string fromUserInfo = Workflow.GetUserInfo(fromUserId);
            string toUserInfo   = string.Empty;
            if (toUserId == 0)
            {
                toUserInfo = Workflow.GetUserInfo((decimal)startWorkflow["ToUserId"]);
                toUserId   = (decimal)startWorkflow["ToUserId"];
            }
            else
            {
                toUserInfo = Workflow.GetUserInfo(toUserId);
            }

            // --------------------------------------------------
            // 新しいワークフローを開始
            // --------------------------------------------------
            // T_WorkflowへのINSERT
            // --------------------------------------------------
            DaoT_Workflow daoT_Workflow = new DaoT_Workflow(this.Dam);

            daoT_Workflow.PK_WorkflowControlNo = workflowControlNo;
            daoT_Workflow.SubSystemId          = startWorkflow["SubSystemId"];
            daoT_Workflow.WorkflowName         = startWorkflow["WorkflowName"];
            daoT_Workflow.UserId      = fromUserId; // 個人IDが必要。
            daoT_Workflow.UserInfo    = fromUserInfo;
            daoT_Workflow.ReserveArea = workflowReserveArea;
            daoT_Workflow.StartDate   = DateTime.Now;
            //daoT_Workflow.EndDate = DBNull.Value;

            daoT_Workflow.D1_Insert();

            // --------------------------------------------------
            // T_CurrentWorkflowへのINSERT
            // --------------------------------------------------
            DaoT_CurrentWorkflow daoT_CurrentWorkflow = new DaoT_CurrentWorkflow(this.Dam);

            daoT_CurrentWorkflow.PK_WorkflowControlNo   = workflowControlNo;
            daoT_CurrentWorkflow.HistoryNo              = 1; // スタートなので「1」固定
            daoT_CurrentWorkflow.WfPositionId           = startWorkflow["WfPositionId"];
            daoT_CurrentWorkflow.WorkflowNo             = startWorkflow["WorkflowNo"];
            daoT_CurrentWorkflow.FromUserId             = fromUserId;   // 実際のユーザIDを入力する。
            daoT_CurrentWorkflow.FromUserInfo           = fromUserInfo; // ユーザ入力が必要。
            daoT_CurrentWorkflow.ActionType             = startWorkflow["ActionType"];
            daoT_CurrentWorkflow.ToUserId               = toUserId;
            daoT_CurrentWorkflow.ToUserInfo             = toUserInfo; // ユーザ入力が必要。
            daoT_CurrentWorkflow.ToUserPositionTitlesId = startWorkflow["ToUserPositionTitlesId"];
            daoT_CurrentWorkflow.NextWfPositionId       = startWorkflow["NextWfPositionId"];
            daoT_CurrentWorkflow.NextWorkflowNo         = startWorkflow["NextWorkflowNo"];
            daoT_CurrentWorkflow.ReserveArea            = currentWorkflowReserveArea;
            //daoT_CurrentWorkflow.ExclusiveKey = "";
            daoT_CurrentWorkflow.ReplyDeadline = replyDeadline;
            daoT_CurrentWorkflow.StartDate     = DateTime.Now;
            //daoT_CurrentWorkflow.AcceptanceDate = DBNull.Value;
            //daoT_CurrentWorkflow.AcceptanceUserId = DBNull.Value;
            //daoT_CurrentWorkflow.AcceptanceUserInfo = DBNull.Value;

            daoT_CurrentWorkflow.D1_Insert();

            // リターン(MailTemplateId)
            if (startWorkflow["MailTemplateId"] == DBNull.Value)
            {
                return(0);
            }
            else
            {
                return((int)startWorkflow["MailTemplateId"]);
            }
        }