Ejemplo n.º 1
0
        private void delete_Clicked(object sender, EventArgs e)
        {
            Button clickedButton = (Button)sender;
            CNTR_Resource_Schedule_Facade resource_Schedule_Facade = new CNTR_Resource_Schedule_Facade();

            string deleteLogMessage = PortalUser.Current.FirstName + " " + PortalUser.Current.LastName + " has deleted a Submission." + "\n";

            int       row     = Int32.Parse(clickedButton.ID.Substring(7));
            List_able listObj = current_Viewable.returnListable();

            switch (listObj.getType())
            {
            case "ICS_NHibernate.JCF_Submission":
                JCF_Submission        obj = (JCF_Submission)listObj.get_iterable_List()[row];
                JCF_Submission_Facade submission_Facade = new JCF_Submission_Facade();
                JCF_Answer_Facade     answer_Facade     = new JCF_Answer_Facade();
                Flow_Rec_Facade       flow_Rec_Facade   = new Flow_Rec_Facade();
                submission_Facade.Remove(obj);
                deleteLogMessage += "SubmissionID: " + obj.SubmissionID.ToString() + "\n";
                deleteLogMessage += "SubmissionUser: "******"\n";
                deleteLogMessage += "SubmissionFormID: " + obj.FormID.ToString() + "\n";
                deleteLogMessage += "SubmissionSubmittedDate: " + obj.SubmittedDate.ToString() + "\n";

                try
                {
                    List <CNTR_Resource_Schedule> resourceList = resource_Schedule_Facade.GetByIdWhere(obj.SubmissionID, "Submission_ID").Cast <CNTR_Resource_Schedule>().ToList();
                    foreach (CNTR_Resource_Schedule schedule in resourceList)
                    {
                        resource_Schedule_Facade.Remove(schedule);
                        deleteLogMessage += "ResourceID: " + schedule.Schedule_ID.ToString() + "\n";
                        deleteLogMessage += "ResourceStartTime: " + schedule.Start_Date.ToString() + "\n";
                        deleteLogMessage += "ResourceEndTime: " + schedule.End_Date.ToString() + "\n";
                        deleteLogMessage += "ResourceUser: "******"\n";
                    }
                }
                catch
                {
                    EventLog.WriteEntry("ICSNET", "Error while clearing resource scheduled when deleting submission.");
                }

                List <Flow_Rec> flow_List = flow_Rec_Facade.GetByIdWhere(obj.SubmissionID, "Submission_ID").Cast <Flow_Rec>().ToList();
                if (flow_List.Any())
                {
                    Flow_Rec parent_Flow;
                    if (flow_List[0].Parrent_Flow == new Guid())
                    {
                        parent_Flow = flow_List[0];
                    }
                    else
                    {
                        flow_List = flow_Rec_Facade.GetByIdWhere(flow_List[0].Parrent_Flow, "ID").Cast <Flow_Rec>().ToList();
                        if (flow_List.Any())
                        {
                            parent_Flow = flow_List[0];
                        }
                        else
                        {
                            parent_Flow = null;
                        }
                    }
                    if (parent_Flow != null)
                    {
                        flow_List = flow_Rec_Facade.GetByIdWhere(parent_Flow.ID, "Parrent_Flow").Cast <Flow_Rec>().ToList();
                        List <JCF_Submission> submission_List = new List <JCF_Submission>();
                        foreach (Flow_Rec flow in flow_List)
                        {
                            List <JCF_Submission> submissions = submission_Facade.GetByIdWhere(flow.Submission_ID, "SubmissionID").Cast <JCF_Submission>().ToList();
                            if (submissions.Any())
                            {
                                submission_List.Add(submissions[0]);
                                submission_Facade.Remove(submissions[0]);
                            }
                            flow_Rec_Facade.Remove(flow);
                        }
                        foreach (JCF_Submission sub in submission_List)
                        {
                            List <Abstract_Iter_able> answer_List = answer_Facade.GetByIdWhere(sub.SubmissionID, "SubmissionID");
                            foreach (JCF_Answer answer in answer_List)
                            {
                                answer_Facade.Remove(answer);
                            }
                        }

                        flow_Rec_Facade.Remove(parent_Flow);
                    }
                }

                List <Abstract_Iter_able> answers_List = answer_Facade.GetByIdWhere(obj.SubmissionID, "SubmissionID");
                foreach (JCF_Answer x in answers_List)
                {
                    answer_Facade.Remove(x);
                }
                break;

            default:

                break;
            }
            var flow_Object = master_Forms_List[Convert.ToInt32(hf_Selected_Object.Value)] as Flow_Form_able;

            if (flow_Object != null)
            {
                LoadFlow(master_Forms_List[Convert.ToInt32(hf_Selected_Object.Value)], master_Forms_List[Convert.ToInt32(hf_Selected_Object.Value)].Index_Value, master_Forms_List[Convert.ToInt32(hf_Selected_Object.Value)].Index);
            }
            else
            {
                LoadForm(master_Forms_List[Convert.ToInt32(hf_Selected_Object.Value)].facade, master_Forms_List[Convert.ToInt32(hf_Selected_Object.Value)].Index_Value, master_Forms_List[Convert.ToInt32(hf_Selected_Object.Value)].Index, master_Forms_List[Convert.ToInt32(hf_Selected_Object.Value)]);
            }
            EventLog.WriteEntry("ICSNET", deleteLogMessage, EventLogEntryType.Warning);
            return;
        }
Ejemplo n.º 2
0
        private void print_Form(JCF_Submission submission)
        {
            string   filename = string.Empty;
            Document document = new Document();
            Section  section;

            JCF_Submission_Facade submission_Facade = new JCF_Submission_Facade();
            Flow_Rec_Facade       flow_Rec_Facade   = new Flow_Rec_Facade();
            Flow_Rec parent_Flow;

            List <Abstract_Iter_able> form_List = new List <Abstract_Iter_able>();

            List <Abstract_Iter_able> flow_List = flow_Rec_Facade.GetByIdWhere(submission.SubmissionID, "Submission_ID");

            if (flow_List.Count > 0)
            {
                parent_Flow = (Flow_Rec)flow_Rec_Facade.GetByIdWhere(submission.SubmissionID, "Submission_ID")[0];
                List <Abstract_Iter_able> flow_objs = flow_Rec_Facade.GetByIdWhere(parent_Flow.ID, "Parrent_Flow");
                List <Abstract_Iter_able> submissions;

                form_List.Add(submission);
                foreach (Flow_Rec flow_obj in flow_objs)
                {
                    submissions = submission_Facade.GetByIdWhere(flow_obj.Submission_ID, "SubmissionID");
                    if (submissions.Count > 0)
                    {
                        form_List.Add(submissions[0]);
                    }
                }
            }
            else
            {
                form_List.Add(submission);
            }
            Paragraph    answer_Paragraph  = new Paragraph();
            Paragraph    question_Pragraph = new Paragraph();
            Paragraph    header_Paragaraph = new Paragraph();
            List <Color> color_List        = new List <Color>()
            {
                Colors.Red, Colors.Orange, Colors.Yellow, Colors.Green, Colors.Blue, Colors.Indigo, Colors.Violet
            };
            int i = 0;

            foreach (JCF_Submission submissionForm in form_List)
            {
                section           = document.AddSection();
                header_Paragaraph = section.AddParagraph(GetFormHeader(submissionForm));
                header_Paragaraph.Format.Alignment        = ParagraphAlignment.Left;
                header_Paragaraph.Format.Font.Name        = "Times New Roman";
                header_Paragaraph.Format.Font.Color       = Colors.Black;
                header_Paragaraph.Format.Borders.Distance = "5pt";
                header_Paragaraph.Format.Borders.Color    = color_List[i % 7];
                header_Paragaraph.Format.Font.Size        = 16;
                List <JCF_FormItem> questions = new JICSBaseFacade <JCF_FormItem>().GetQuery().Where(x => x.FormID == submissionForm.FormID).OrderBy(x => x.QuestionNum).ThenBy(x => x.RowNum).ToList();
                foreach (JCF_FormItem question in questions)
                {
                    question_Pragraph = section.AddParagraph(StripHTML(current_Viewable.nullCheck(question.Text).ToString()));
                    question_Pragraph.Format.Alignment        = ParagraphAlignment.Left;
                    question_Pragraph.Format.Font.Name        = "Times New Roman";
                    question_Pragraph.Format.Font.Color       = Colors.Black;
                    question_Pragraph.Format.Font.Size        = 12;
                    question_Pragraph.Format.Borders.Distance = "5pt";
                    question_Pragraph.Format.Borders.Color    = color_List[i % 7];

                    List <JCF_Answer> answers = new JICSBaseFacade <JCF_Answer>().GetQuery().Where(x => x.ItemID == question.ID && x.SubmissionID == submissionForm.SubmissionID).ToList();
                    if (answers.Count > 0)
                    {
                        foreach (JCF_Answer answer in answers)
                        {
                            answer_Paragraph = section.AddParagraph(StripHTML(current_Viewable.nullCheck(answer.AnswerValue).ToString()));
                            answer_Paragraph.Format.Alignment  = ParagraphAlignment.Justify;
                            answer_Paragraph.Format.Font.Name  = "Times New Roman";
                            answer_Paragraph.Format.Font.Color = Colors.DarkGray;
                            answer_Paragraph.Format.Font.Size  = 12;
                        }
                    }
                    else
                    {
                        answer_Paragraph = section.AddParagraph(" ");
                        answer_Paragraph.Format.Alignment = ParagraphAlignment.Justify;
                        answer_Paragraph.Format.Font.Size = 12;
                    }
                }
                i++;
            }

            PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(false);

            pdfRenderer.Document = document;
            pdfRenderer.RenderDocument();
            filename = GetSubmissionFileName(submission);
            EventLog.WriteEntry("ICSNET", "FILENAME:" + filename, EventLogEntryType.Information);
            Response.Clear();
            Response.ContentType = "application/pdf";
            MemoryStream stream = new MemoryStream();

            pdfRenderer.PdfDocument.Save(stream, false);
            Response.AddHeader("Content-Disposition", "attachment; filename=" + filename);
            Response.AddHeader("content-length", stream.Length.ToString());
            Response.BinaryWrite(stream.ToArray());
            Response.Flush();
            stream.Close();
            Response.End();
        }
Ejemplo n.º 3
0
        private void review_Clicked(object sender, EventArgs e)
        {
            Button                    clickedButton     = (Button)sender;
            int                       row               = Int32.Parse(clickedButton.ID.Substring(7));
            int                       data              = Convert.ToInt32(hf_Selected_Object.Value);
            List_able                 listable          = current_Viewable.returnListable();
            Abstract_Iter_able        form_obj          = listable.get_iterable_List()[row];
            JCF_Submission_Facade     submission_Facade = new JCF_Submission_Facade();
            Flow_Rec_Facade           flow_Rec_Facade   = new Flow_Rec_Facade();
            Flow_Rec                  parent_Flow;
            JCF_Submission            submission;
            List <Abstract_Iter_able> form_List = new List <Abstract_Iter_able>();

            if (form_obj.GetType().Equals(typeof(JCF_Submission)))
            {
                List <Abstract_Iter_able> flow_List = flow_Rec_Facade.GetByIdWhere(((JCF_Submission)form_obj).SubmissionID, "Submission_ID");
                if (flow_List.Count > 0)
                {
                    parent_Flow = (Flow_Rec)flow_Rec_Facade.GetByIdWhere(((JCF_Submission)form_obj).SubmissionID, "Submission_ID")[0];
                    List <Abstract_Iter_able> flow_objs = flow_Rec_Facade.GetByIdWhere(parent_Flow.ID, "Parrent_Flow");
                    List <Abstract_Iter_able> submissions;
                    submission = (JCF_Submission)submission_Facade.GetByIdWhere(((JCF_Submission)form_obj).SubmissionID, "SubmissionID")[0];
                    form_List.Add(submission);
                    foreach (Flow_Rec flow_obj in flow_objs)
                    {
                        submissions = submission_Facade.GetByIdWhere(flow_obj.Submission_ID, "SubmissionID");
                        if (submissions.Count > 0)
                        {
                            form_List.Add(submissions[0]);
                        }
                    }
                }
                else
                {
                    submission = (JCF_Submission)submission_Facade.GetByIdWhere(((JCF_Submission)form_obj).SubmissionID, "SubmissionID")[0];
                    form_List.Add(submission);
                }


                Session["form_Obj"]    = form_List;
                Session["viewDesired"] = "Edit";
            }
            else
            {
                parent_Flow = (Flow_Rec)flow_Rec_Facade.GetByIdWhere(((Flow_Rec)form_obj).Submission_ID, "Submission_ID")[0];
                Flow_Rec flow_obj = (Flow_Rec)flow_Rec_Facade.GetByIdWhere(parent_Flow.ID, "Parrent_Flow")[0];
                submission             = (JCF_Submission)submission_Facade.GetByIdWhere(flow_obj.Submission_ID, "SubmissionID")[0];
                Session["viewDesired"] = "Evaluation";
                while (parent_Flow.Parrent_Flow != new Guid())
                {
                    form_List.Add((Abstract_Iter_able)submission_Facade.GetByIdWhere(parent_Flow.Submission_ID, "SubmissionID")[0]);
                    parent_Flow = (Flow_Rec)flow_Rec_Facade.GetByIdWhere(parent_Flow.Parrent_Flow, "ID")[0];
                }
                if (parent_Flow.Parrent_Flow == new Guid())
                {
                    form_List.Add((Abstract_Iter_able)submission_Facade.GetByIdWhere(parent_Flow.Submission_ID, "SubmissionID")[0]);
                }
                Session["form_Obj"] = form_List;
            }
            Session["formable"]     = master_Forms_List[data];
            Session["eval_Obj"]     = submission;
            Session["viewableType"] = master_Forms_List[data].Name;

            Session["eval_Obj"] = submission;
            ParentPortlet.NextScreen("Objectable_View");
        }