示例#1
0
        private void DelWorkflowComponentBtn_Click(object sender, EventArgs e)
        {
            //finds + removes the selected step
            List <Guid> ids           = this.ControlIDs;
            int         wfcId         = int.Parse(((Button)sender).CommandArgument.ToString().Split(',')[1]);
            string      id            = ((Button)sender).CommandArgument.ToString().Split(',')[0];
            Guid        guid          = Guid.Parse(id);
            Panel       panelControls = (Panel)WorkflowSteps.FindControl("stepControl" + id);

            WorkflowSteps.Controls.Remove(panelControls);
            ids.Remove(guid);
            this.ControlIDs = ids;

            WorkflowComponentUtil.DeleteWorkflowComponent(wfcId);
            ReloadCurrentPage();
        }
示例#2
0
        // ======= WORKFLOW EDITOR ======
        private void LoadWorkflowSteps(int workflowId)
        {
            List <Guid> ids = this.ControlIDs;
            List <WorkflowComponent> compList = WorkflowComponentUtil.GetWorkflowComponents(workflowId);
            int i = 0;

            foreach (WorkflowComponent item in compList)
            {
                if (ids.Count == i)
                {
                    Guid guid = Guid.NewGuid();
                    ids.Add(guid);
                    this.ControlIDs = ids;
                }
                CreateWorkflowStep(ids[i], item);
                i++;
            }
        }
示例#3
0
        private void SaveComponents(int workflowId)
        {
            User                     user     = (User)Session["User"];
            WorkflowModel            w        = WorkflowUtil.GetWorkflow(workflowId);
            List <WorkflowComponent> compList = WorkflowComponentUtil.GetWorkflowComponents(workflowId);
            int i = 0;

            foreach (Panel panelControls in WorkflowSteps.Controls.OfType <Panel>())
            {
                string       id           = panelControls.ID.Replace("stepControl", string.Empty);
                Panel        div          = (Panel)panelControls.FindControl("title" + id);
                TextBox      stepTitle    = (TextBox)div.FindControl("stepTitle" + id);
                DropDownList formSelector = (DropDownList)panelControls.FindControl("formSelector" + id);
                int          formId       = int.Parse(formSelector.SelectedValue);
                WorkflowComponentUtil.UpdateWorkflowComponent(compList[i].WFComponentID, stepTitle.Text, formId);
                Log.Info(user.Identity + " updated " + w.WorkflowName + " with component " + stepTitle.Text + " assigned to form " + FormUtil.GetFormTemplate(formId).FormName);
                i++;
            }
        }
示例#4
0
        protected void AddWorkflowComponentBtn_Click(object sender, EventArgs e)
        {
            if (WorkflowName.Text.Length > 0)
            {
                int         workflowId = 0;
                List <Guid> ids        = this.ControlIDs;
                Guid        guid       = Guid.NewGuid();
                ids.Add(guid);

                WorkflowComponent wc = null;
                if (Request.QueryString["wid"] != null)
                {
                    if (WorkflowName.Text.Length > 0)
                    {
                        workflowId = int.Parse(Request.QueryString["wid"]);
                        WorkflowUtil.UpdateWorkflow(workflowId, WorkflowName.Text);
                        SaveComponents(workflowId);
                        wc = WorkflowComponentUtil.CreateWorkflowComponent(workflowId);
                    }
                }
                else
                {
                    if (WorkflowName.Text.Length > 0)
                    {
                        WorkflowModel w    = WorkflowUtil.CreateWorkflow(WorkflowName.Text);
                        User          user = (User)Session["User"];
                        Log.Info(user.Identity + " created workflow template " + w.WorkflowName);
                        workflowId = w.WorkflowId;
                        SaveComponents(workflowId);
                        wc = WorkflowComponentUtil.CreateWorkflowComponent(workflowId);
                    }
                }
                Panel componentPanel = CreateWorkflowStep(guid, wc);
                this.ControlIDs = ids;
                Response.Redirect("Workflows.aspx?edit=1&wid=" + workflowId);
            }
            else
            {
                WorkflowError.Visible = true;
                WorkflowError.Text    = "Please name the Workflow before adding steps";
            }
        }
示例#5
0
        protected void ProjectView(Project p)
        {
            Company     c     = CompanyUtil.GetCompany(p.CompanyId);
            List <User> users = UserUtil.GetUsersByCompany(c.CompanyId);

            projectNode += "<h2><a href='Projects.aspx'>Projects</a> > " + p.Name + "</h2><div id=\"project-top-div\"><div class=\"project-info\"><div id=\"project-top\"><div class=\"project-item\">";
            projectNode += "<i class=\"huge circular building icon\"></i><h3>" + c.CompanyName + "</h3></div><div class=\"project-item\">";
            projectNode += "<i class=\"huge circular user icon\"></i><h3>" + UserUtil.GetCoach(p.CoachId).FullName + "</h3></div>";
            projectNode += "<div class=\"project-item\"><i class=\"huge circular money icon\"></i>";
            projectNode += "<h3>Funding Source</h3></div></div></div>";


            projectNode += "<div id=\"more-project-info\"><div class=\"ui accordion\"><div class=\"title\"><i class=\"dropdown icon\"></i>Company Contact";
            projectNode += "</div><div class=\"content\">";

            foreach (User i in users)
            {
                projectNode += "<p>" + i.FullName + " | " + i.Email + "</p><br>";
            }

            projectNode += "</div></div><div class=\"ui accordion\"><div class=\"title\"><i class=\"dropdown icon\"></i>Project Notes</div>";
            projectNode += "<div class=\"content\"><p class=\"transition hidden\">" + p.Notes + "</p></div></div></div></div></div>";
            projectNode += "<script>$('.ui.accordion').accordion();</script>";

            projectNode += "<div class=\"wrapper\"><ol class=\"ProgressBar\">";
            try
            {
                foreach (WorkflowComponent com in WorkflowComponentUtil.GetWorkflowComponents(p.WorkflowId))
                {
                    Form form = FormUtil.GetProjectFormByTemplate(com.FormID, p.ProjectId);
                    projectNode += "<li class=\"ProgressBar-step\" id=\"li" + com.WFComponentID + "\">";
                    projectNode += "<svg class=\"ProgressBar-icon\"></svg><a href='Forms.aspx?pfid=" + form.FormId + "'><span class=\"ProgressBar-stepLabel\">" + com.ComponentTitle + "</a></span>";
                    projectNode += "<div class=\"li-dropdown\" id=\"li-drop" + com.WFComponentID + "\">";
                    projectNode += "<div class=\"workflow-form\"><i class=\"big inbox icon\"></i><h3>" + form.FormName + "</h3></div></div></li>";
                }
            }
            catch (Exception e) { }
            projectNode += "</ol></div>";

            projectViewer.InnerHtml += projectNode;
        }
示例#6
0
        protected void ProjectFileDownloader_Click(object sender, EventArgs e)
        {
            if (Request.QueryString["pid"] != null)
            {
                int                      projId             = int.Parse(Request.QueryString["pid"]);
                Project                  p                  = ProjectUtil.GetProject(projId);
                Company                  c                  = CompanyUtil.GetCompany(p.CompanyId);
                WorkflowModel            w                  = WorkflowUtil.GetWorkflow(p.WorkflowId);
                List <WorkflowComponent> workflowComponents = WorkflowComponentUtil.GetWorkflowComponents(w.WorkflowId);
                string                   zipPath            = String.Format("{0} - {1} - {2}.zip", w.WorkflowName, p.Name, CompanyUtil.GetCompanyName(p.CompanyId));
                //delete the zip if it exists
                if (File.Exists(zipPath))
                {
                    File.Delete(zipPath);
                }

                using (ZipArchive zip = ZipFile.Open(zipPath, ZipArchiveMode.Create))
                {
                    //for each form get the file
                    foreach (WorkflowComponent wc in workflowComponents)
                    {
                        Form f = FormUtil.GetProjectFormByTemplate(wc.FormID, projId);
                        if (f.FilePath.Length > 0)
                        {
                            string fileType = f.FilePath.Split('.')[1];
                            string fileName = string.Format("{0} {1} Attachment.{2}", CompanyUtil.GetCompanyName(p.CompanyId), f.FormName, fileType);
                            zip.CreateEntryFromFile(f.FilePath, fileName);
                        }
                        string pdfName = string.Format("{0} - {1} - {2}.pdf", w.WorkflowName, f.FormName, c.CompanyName);
                        string pdfPath = string.Format("./PDFGen/{0}", pdfName);
                        zip.CreateEntryFromFile(pdfPath, pdfName);
                    }
                }

                SendFile(zipPath);
            }
        }
示例#7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //validates that the user is logged in
            if (Session["User"] != null)
            {
                User user = (User)Session["User"];
                userLbl.Text = user.FullName;
                if (user.RoleId == 4)
                {
                    AdminBtn.Visible = true;
                }

                if (user.RoleId == 1)
                {
                    CreateClientWorkflowList(user.CompanyId);
                    CreateNewWorkflowBtn.Visible = false;
                }
                else if (user.RoleId == 2)
                {
                    CreateWorkflowList(user.UserId);
                    CreateNewWorkflowBtn.Visible = false;
                }
                else if (user.RoleId == 4 || user.RoleId == 3)
                {
                    CreateAdminWorkflowList();
                }

                //loads the selected form if there is one
                if (Request.QueryString["wid"] != null)
                {
                    int           workflowId = int.Parse(Request.QueryString["wid"]);
                    WorkflowModel w          = WorkflowUtil.GetWorkflow(workflowId);

                    //admin and trying to del
                    if (Request.QueryString["del"] != null && user.RoleId == 4)
                    {
                        if (WorkflowUtil.DeleteWorkflow(w.WorkflowId))
                        {
                            Log.Info(user.Identity + " deleted a workflow template " + w.WorkflowName);
                            ReloadSection();
                        }
                        else
                        {
                            WorkflowError.Visible = true;
                            WorkflowError.Text    = "Unable to delete Workflow " + w.WorkflowName;
                        }
                    }
                    else
                    {
                        workflowListing.Visible = false;

                        //if they are trying to edit and they are admin, show workflow builder
                        if (Request.QueryString["edit"] != null && user.RoleId == 4)
                        {
                            if (WorkflowUtil.EditableWorkflow(w.WorkflowId))
                            {
                                workflowBuilder.Visible = true;
                                WorkflowName.Text       = w.WorkflowName;
                                CreateWorkflowBtn.Text  = "Update Workflow";

                                LoadWorkflowSteps(workflowId);
                            }
                            else
                            {
                                workflowListing.Visible = true;
                                WorkflowError.Visible   = true;
                                WorkflowError.Text      = "Unable to edit Workflow " + w.WorkflowName + " while projects are assigned to it";
                            }
                        }
                        //otherwise just show the workflow viewer
                        else
                        {
                            workflowViewer.Visible = true;
                            List <WorkflowComponent> comps = WorkflowComponentUtil.GetWorkflowComponents(w.WorkflowId);
                            ProjectInformation(w, comps);
                        }
                    }
                }
                //if theyre an admin and trying to make a new form
                else if (Request.QueryString["edit"] != null && Request.QueryString["wid"] == null && user.RoleId == 4)
                {
                    workflowListing.Visible = false;
                    workflowBuilder.Visible = true;
                }
            }
            else
            {
                Response.Redirect("Login.aspx");
            }
        }
示例#8
0
        private void CreateProjectPanel(List <Project> proj)
        {
            foreach (Project project in proj)
            {
                var projectNode = "";

                //Preparing Lists of the project's workflow components and their completion status
                List <WorkflowComponent> steps = WorkflowComponentUtil.GetWorkflowComponents(project.WorkflowId);

                double totalSteps     = steps.Count;
                double stepsCompleted = 0;

                List <Form> formSteps = new List <Form>();
                try
                {
                    foreach (WorkflowComponent step in steps)
                    {
                        Form f = FormUtil.GetProjectFormByTemplate(step.FormID, project.ProjectId);
                        formSteps.Add(f);
                        if (!f.Approved.Contains("0"))
                        {
                            stepsCompleted++;
                        }
                    }
                } catch (Exception e) { }

                // Calculate percentage of steps completed using total steps and number completed
                int percent = 0;
                if (stepsCompleted > 0)
                {
                    Convert.ToInt32((stepsCompleted / totalSteps));
                }

                projectNode += "<div class=\"item\"><div class=\"ui small image\">";
                projectNode += "<div class=\"ui orange progress\" data-percent=" + percent + " id=\"project" + project.ProjectId + "\">";
                projectNode += "<div class=\"bar\"><div class=\"progress\"></div></div><div class=\"label\">Completion</div></div>";

                /*id for opening project?*/
                projectNode += "<a class=\"header\" href='" + "Projects.aspx?pid=" + project.ProjectId + "'><span class=\"ui brown basic button\">View Full Project</span></a></div>";
                projectNode += "<div class=\"content\"><a class=\"header\" href='" + "Projects.aspx?pid=" + project.ProjectId + "'>" + project.Name + "</a>";
                projectNode += "<div class=\"description\">" + project.Notes + "</div>";
                projectNode += "<div class=\"table\"><table class=\"ui celled table\"><thead><tr><th>Workflow Step</th><th>Status</th></tr></thead><tbody>";

                /* 3 Cases of project status for the table; completed, not completed/unknown, and needs modification. Check status, then add appropriate class.*/
                int i = 0;
                try
                {
                    foreach (WorkflowComponent step in steps)
                    {
                        Form f = formSteps[i];
                        if (!f.Approved.Contains("0"))
                        {
                            projectNode += "<tr><td><a href='Forms.aspx?pfid=" + f.FormId + "'>" + step.ComponentTitle + "</a></td><td class=\"positive\"><i class=\"icon checkmark\"></i>Approved</td></tr>";
                        }
                        else if (f.Denied.Contains("1") && f.DenialReason.Length > 0)
                        {
                            projectNode += "<tr><td><a href='Forms.aspx?pfid=" + f.FormId + "'>" + step.ComponentTitle + "</a></td><td class=\"negative\"><i class=\"pencil alternate icon\"></i>Needs Modification</td></tr>";
                        }
                        else if (f.Denied.Contains("1"))
                        {
                            projectNode += "<tr><td><a href='Forms.aspx?pfid=" + f.FormId + "'>" + step.ComponentTitle + "</a></td><td class=\"negative\"><i class=\"close icon\"></i>Denied</td></tr>";
                        }
                        else if (f.Submission == 1)
                        {
                            projectNode += "<tr><td><a href='Forms.aspx?pfid=" + f.FormId + "'>" + step.ComponentTitle + "</a></td><td class=\"disabled\"><i class=\"battery half icon\"></i>In Progress</td></tr>";
                        }
                        else
                        {
                            projectNode += "<tr><td><a href='Forms.aspx?pfid=" + f.FormId + "'>" + step.ComponentTitle + "</a></td><td class=\"disabled\"><i class=\"close icon\"></i>Not Started</td></tr>";
                        }
                        i++;
                    }
                } catch (Exception e) { }

                // Complete table, add tab pages numbers
                projectNode += "</tbody></table></div></div></div><script>$('#project" + project.ProjectId + "').progress();</script><hr>";
                // Add to page
                projectParent.InnerHtml += projectNode;
            }
        }