//TO EDIT

        public List <WorkflowApprover> getSortedWorkflowApprovers(string workflowID, string workflow_subID)
        {
            List <WorkflowApprover> toReturn = new List <WorkflowApprover>();
            SqlConnection           conn     = new SqlConnection();
            WorkflowApprover        approver = null;
            UserDAO userDAO = new UserDAO();

            try
            {
                conn = new SqlConnection();
                string connstr = ConfigurationManager.ConnectionStrings["DBConnectionString"].ToString();
                conn.ConnectionString = connstr;
                conn.Open();
                SqlCommand comm = new SqlCommand();
                comm.Connection  = conn;
                comm.CommandText = "select * from [Workflow_approvers] where wfid=@wfid and wfsid=@wfsid order by level asc";
                comm.Parameters.AddWithValue("@wfid", workflowID);
                comm.Parameters.AddWithValue("@wfsid", workflow_subID);
                SqlDataReader dr = comm.ExecuteReader();
                while (dr.Read())
                {
                    approver = new WorkflowApprover();
                    string   wfid = (string)dr["wfid"];
                    Workflow wf   = wfDAO.getWorkflowByID(wfid);
                    approver.setMainWF(wf);

                    string      wfsid = (string)dr["wf_sub_id"];
                    WorkflowSub wfs   = wfsDAO.getWorkflowSubByID(wfsid);
                    approver.setMainWFS(wfs);

                    string userID = (string)dr["userID"];
                    User   user   = userDAO.getUserByID(userID);
                    approver.setApprover(user);
                    approver.setLevel((int)dr["levels"]);

                    toReturn.Add(approver);
                }
                dr.Close();
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                conn.Close();
            }
            return(toReturn);
        }
Exemplo n.º 2
0
        public WorkflowApprover getWorkflowApproverByJobCategory(string jobCategory, int wfid, int wf_sub_id)
        {
            WorkflowApprover toReturn = new WorkflowApprover();
            SqlConnection    conn     = new SqlConnection();
            UserDAO          userDAO  = new UserDAO();

            try
            {
                conn = new SqlConnection();
                string connstr = ConfigurationManager.ConnectionStrings["DBConnectionString"].ToString();
                conn.ConnectionString = connstr;
                conn.Open();
                SqlCommand comm = new SqlCommand();
                comm.Connection  = conn;
                comm.CommandText = "select * from [Workflow_approvers] where job_category=@job_category and wfid=@wfid and wf_sub_id=@wf_sub_id";
                comm.Parameters.AddWithValue("@job_category", jobCategory);
                comm.Parameters.AddWithValue("@wfid", wfid);
                comm.Parameters.AddWithValue("@wf_sub_id", wf_sub_id);
                SqlDataReader dr = comm.ExecuteReader();
                while (dr.Read())
                {
                    int      wf_id = (int)dr["wfid"];
                    Workflow wf    = wfDAO.getWorkflowByID(wf_id);
                    toReturn.setMainWF(wf);

                    int         wfsid = (int)dr["wf_sub_id"];
                    WorkflowSub wfs   = wfsDAO.getWorkflowSubByID(wfsid);
                    toReturn.setMainWFS(wfs);

                    toReturn.setJobCategory((string)dr["job_category"]);
                    toReturn.setLevel((int)dr["levels"]);
                }
                dr.Close();
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                conn.Close();
            }
            return(toReturn);
        }