Esempio n. 1
0
        public static List <Form> GetProjectForms(int projectId)
        {
            List <Form> formList = new List <Form>();
            Project     p        = ProjectUtil.GetProject(projectId);
            List <WorkflowComponent> workflowComponents = WorkflowComponentUtil.GetWorkflowComponents(p.WorkflowId);

            foreach (WorkflowComponent wc in workflowComponents)
            {
                if (wc.FormID != -1)
                {
                    formList.Add(GetProjectFormByTemplate(wc.FormID, projectId));
                }
            }
            return(formList);
        }
Esempio n. 2
0
        public static Project CreateProject(string name, int workflowId, int companyId, int coachId, string notes)
        {
            Project      p   = new Project(workflowId, companyId, 0, coachId, name, notes);
            MySqlCommand cmd = new MySqlCommand("INSERT INTO Project (WorkflowID, CompanyID, StatusID, CoachID, ProjectName, ProjectNotes) VALUES (@workflowId, @companyId, @statusId, @coachId, @name, @notes)");

            cmd.Parameters.AddWithValue("@workflowId", workflowId);
            cmd.Parameters.AddWithValue("@companyId", companyId);
            cmd.Parameters.AddWithValue("@statusId", 0);
            cmd.Parameters.AddWithValue("@coachId", coachId);
            cmd.Parameters.AddWithValue("@name", name);
            cmd.Parameters.AddWithValue("@notes", notes);
            DBConn conn = new DBConn();

            p.ProjectId = conn.ExecuteInsertCommand(cmd);

            //creates notification for the coach
            FeedUtil.CreateProjectFeedItem("Added as a coach for " + name, coachId, p.ProjectId);

            List <WorkflowComponent> workflowComponents = WorkflowComponentUtil.GetWorkflowComponents(workflowId);

            foreach (WorkflowComponent wc in workflowComponents)
            {
                //create completion status and forms for the project
                if (wc.FormID != -1)
                {
                    Form f = FormUtil.CreateForm(wc.FormID, p.ProjectId);

                    //creates notifications for each member of the company and each form
                    List <User> clients = UserUtil.GetClients(companyId);
                    foreach (User client in clients)
                    {
                        FeedUtil.CreateProjectFormFeedItem("Form " + f.FormName + " needs completion for " + name, client.UserId, p.ProjectId, f.FormId);
                    }
                }
            }

            conn.CloseConnection();
            return(p);
        }
Esempio n. 3
0
        public static bool DeleteWorkflow(int workflowId)
        {
            List <Project> projects = ProjectUtil.GetWorkflowProjects(workflowId);

            if (projects.Count == 0)
            {
                List <WorkflowComponent> comps = WorkflowComponentUtil.GetWorkflowComponents(workflowId);
                foreach (WorkflowComponent item in comps)
                {
                    WorkflowComponentUtil.DeleteWorkflowComponent(item.WFComponentID);
                }
                string       query = "DELETE FROM Workflows WHERE WorkflowID=@workflowId";
                MySqlCommand cmd   = new MySqlCommand(query);
                cmd.Parameters.AddWithValue("@workflowId", workflowId);
                DBConn conn = new DBConn();
                conn.ExecuteInsertCommand(cmd);
                conn.CloseConnection();
                return(true);
            }
            else
            {
                return(false);
            }
        }