コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            QueryStringEncryption Decryptor = new QueryStringEncryption();

            //Decryptor.decryptQueryString(Request.QueryString["QuestionID"].ToString());

            string serialsList = Request.QueryString["sl"].ToString();

            string PaperPNR = Decryptor.decryptQueryString(Request.QueryString["p"].ToString());

            if (serialsList != "NULL")
            {
                string[] SerialsList = serialsList.Split(new char[] { 's' });

                foreach (string PNR in givePNRs(SerialsList))
                {
                    HyperLink ViewPaperLink = new HyperLink();
                    ViewPaperLink.Text        = new QuestionsPDF().getQuestionSourcePaper(PNR);
                    ViewPaperLink.NavigateUrl = "ViewQuestionPaper.aspx?p=" + Decryptor.encryptQueryString(PNR);
                    ViewPaperLink.CssClass    = "DynamicLinks";
                    if (PaperPNR == PNR)
                    {
                        ViewPaperLink.CssClass = "DynamicLinks SamePaperLink";
                    }
                    else
                    {
                        ViewPaperLink.CssClass = "DynamicLinks";
                    }

                    pnl_LinksHolder.Controls.Add(ViewPaperLink);
                }
            }
        }
コード例 #2
0
        protected void btn_UnlockForNewUser_Click(object sender, EventArgs e)
        {
            TimeZoneInfo IST  = TimeZoneInfo.FindSystemTimeZoneById("India Standard Time");
            DateTime     taim = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, IST);

            QueryStringEncryption Encryptor = new QueryStringEncryption();


            using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConStr"].ConnectionString))
            {
                SqlCommand cmd = new SqlCommand("insert into Users values('" + tb_NewUserName.Text.Trim() + "','" + Encryptor.encryptQueryString(tb_NewUserName.Text.Trim()) + "'," + ddl_permissionsList.SelectedItem.Text + ",'" + taim.ToShortDateString() + " " + taim.ToShortTimeString() + "')", con);
                con.Open();
                cmd.ExecuteNonQuery();
            }
            Button2_Click(new Object(), new EventArgs());
        }
コード例 #3
0
        protected void displayAlreadyEnteredPapers(string CourseCode)
        {
            DataTable papers = getAlreadyEnteredPNRlesses(CourseCode);

            System.Diagnostics.Debug.WriteLine(papers.Rows.Count + "------ROW COUNT------");
            if (papers.Rows.Count > 0)
            {
                PNRgenerator.Visible    = false;
                pnl_LinksHolder.Visible = true;
                pnl_msgholder.Visible   = true;
                QueryStringEncryption Encryptor = new QueryStringEncryption();
                foreach (DataRow paper in papers.Rows)
                {
                    HyperLink paperlink = new HyperLink();
                    paperlink.CssClass = "DynamicPaperLinks";

                    if (paper["FilePath"].ToString().Contains(".pdf"))
                    {
                        //System.Diagnostics.Debug.WriteLine("IN IN I NI IN ININI INI NININI");
                        //is HardTypedPaper
                        paperlink.NavigateUrl = paper["FilePath"].ToString().Substring(paper["FilePath"].ToString().IndexOf("Hard Typed"));
                        paperlink.Text        = CourseCode.ToUpper() + " - " + paper["MaxMarks"].ToString();
                        pnl_LinksHolder.Controls.Add(paperlink);
                    }
                    else
                    {
                        //is not HardTypedPaper
                        paperlink.NavigateUrl = "ViewQuestionPaper.aspx?p=" + Encryptor.encryptQueryString(paper["PNR"].ToString());
                        paperlink.Text        = CourseCode.ToUpper() + " - " + paper["MaxMarks"].ToString() + " - Not hard";
                        pnl_LinksHolder.Controls.Add(paperlink);
                    }
                    Literal newLine = new Literal();
                    newLine.Text = "<br>";
                    pnl_LinksHolder.Controls.Add(newLine);
                }
                btn_ConfirmNew.Visible = true;
            }
            else
            {
                pnl_LinksHolder.Visible = false;
                pnl_msgholder.Visible   = false;
                confirmNewPNRlessEntry();
            }
        }
コード例 #4
0
        protected void generateQuestionsPDF()
        {
            DataTable WorkTable = getDataTableForQuestions(QuestionsType, CourseCode, IncludeCA);

            int RepetitionsCount = getRepetitionsCount(WorkTable);

            string strQtype = string.Empty;

            switch (QuestionsType)
            {
            case 1:
                strQtype = "Very short/MCQ Qestions [1 Mark]";
                break;

            case 2:
                strQtype = "Short Questions [2-2.5 Marks]";
                break;

            case 5:
                strQtype = "Short Questions [5 Marks]";
                break;

            case 10:
                strQtype = "Long Questions [10 Marks]";
                break;

            case 15:
                strQtype = "Long Questions [15 Marks]";
                break;

            default:
                break;
            }

            var    ExtractedQuestionsPDF = new Document(PageSize.A4, 30, 20, 50, 50);
            string SavePath = Server.MapPath("PDFs");

            PdfWriter.GetInstance(ExtractedQuestionsPDF, new FileStream(SavePath + "/Questions.pdf", FileMode.Create));

            ExtractedQuestionsPDF.Open();
            //addding header
            Paragraph header = new Paragraph(strQtype, TopHeader);

            header.Alignment = Element.ALIGN_CENTER;

            ExtractedQuestionsPDF.Add(header);
            //END//addding header

            if (CourseCode != "N")
            {
                Paragraph CCode = new Paragraph(CourseCode, TopHeader);
                CCode.Alignment = Element.ALIGN_CENTER;
                ExtractedQuestionsPDF.Add(CCode);
            }
            ///data set stats
            DataView view   = new DataView(WorkTable);
            int      qCount = view.ToTable(true, new string[] { "Statement" }).Rows.Count;
            //int qCount = WorkTable.Rows.Count;///200 questions found from 33 papers

            DataView dv = new DataView(WorkTable);

            int pCount = dv.ToTable(true, "PNR").Rows.Count;

            string QuestionsGrammarCorrector = qCount > 1 ? "questions" : "question";
            string PapersGrammarCorrector    = pCount > 1 ? "papers" : "paper";

            //int repcount = getRepetitionsCount(WorkTable);

            string RepsJoiner = string.Empty;

            if (RepetitionsCount > 1)
            {
                RepsJoiner = " with " + RepetitionsCount.ToString() + " repeated questions";
            }
            else if (RepetitionsCount == 1)
            {
                RepsJoiner = " with " + RepetitionsCount.ToString() + " repeated question";
            }

            Paragraph DataSetstats = new Paragraph("Showing " + qCount + " " + QuestionsGrammarCorrector + " from " + pCount + " " + PapersGrammarCorrector + RepsJoiner, Topsmall);

            DataSetstats.Alignment = Element.ALIGN_CENTER;

            ExtractedQuestionsPDF.Add(DataSetstats);
            //END/data set stats

            //// adding "Questions" header
            Paragraph QuestionsHeader = new Paragraph("Questions", TopHeader17);

            QuestionsHeader.Alignment = Element.ALIGN_CENTER;

            ExtractedQuestionsPDF.Add(new Paragraph("\n"));

            ExtractedQuestionsPDF.Add(QuestionsHeader);
            ExtractedQuestionsPDF.Add(new Paragraph("\n", small));
            //ExtractedQuestionsPDF.Add(new Paragraph("\n"));//spacemaker

            //END// adding "Questions" header

            /*
             * ////CA indicator
             * PdfPCell CAindicator = new PdfPCell(new Phrase("CA", Topsmall));
             * CAindicator.HorizontalAlignment = Element.ALIGN_CENTER;
             * //END//CA indicator
             */
            ////Real-time Question Table
            PdfPTable QuestionTable = new PdfPTable(4);//Numbering &Statement + Weightage + CA/MTE/ETE + RepetedSTAR

            QuestionTable.WidthPercentage = 100;
            QuestionTable.SetWidths(new float[] { .79f, .06f, .12f, .03f });

            PdfPCell cell_QuestionHolder = new PdfPCell();

            PDFtester PDFfuncs = new PDFtester();//getting custom PDF functions class

            int QuestionNumber = 1;

            for (int c = 0; c < qCount; c++)//rendering questions from Datatable to PDF///CAN BE OPTIMIZED MORE
            {
                DataRow question = WorkTable.Rows[c];

                QuestionTable.FlushContent();
                ////Adding question statement
                if (question["Option1"].ToString() == "")//is not MCQ
                {
                    cell_QuestionHolder = PDFfuncs.convertTableToCell(renderNonMCQQuestion(question, QuestionNumber++));
                }
                else
                {
                    cell_QuestionHolder = PDFfuncs.convertTableToCell(PDFfuncs.renderMCQQuestion(question, PDFfuncs.detectQuestionPattern(question), QuestionNumber++));
                }

                //QuestionTable.AddCell(cell_QuestionHolder);////PICKUP////
                //END//Adding question statement

                ////Adding Weightage
                //QuestionTable.AddCell(PDFfuncs.removeBorders(new PdfPCell(new Phrase("[" + PDFfuncs.formatMarks(question["Weightage"].ToString()) + "]", questionfont))));////PICKUP////
                //END//Adding Weightage

                ////Adding QuestionPaper type
                Anchor PaperLinker = new Anchor(new Phrase(getQuestionSourcePaper(question["PNR"].ToString()), boldquestionfontLINK));
                //PaperLinker.Reference = "http://localhost:50876/ViewQuestionPaper.aspx?p=" + new QueryStringEncryption().encryptQueryString(question["PNR"].ToString());//for TEST environment only
                PaperLinker.Reference = "http://blackchair.manhardeep.com/ViewQuestionPaper.aspx?p=" + new QueryStringEncryption().encryptQueryString(question["PNR"].ToString());//for PRODUCTION environment only
                //QuestionTable.AddCell(PDFfuncs.removeBorders(new PdfPCell(PaperLinker)));////PICKUP////
                //END//Adding QuestionPaper type

                ////Adding Repetitions thingy
                if (isRepeatedQuestion(question["QuestionID"].ToString()))
                {
                    if (!RepeatedQuestionOnceEntered.Contains(question["Statement"].ToString()))//Add to PDF only if not in pdf already
                    {
                        RepeatedQuestionOnceEntered.Add(question["Statement"].ToString());

                        iTextSharp.text.Image repIcon = iTextSharp.text.Image.GetInstance(Server.MapPath("Icons") + "/repIcon.png");

                        Chunk  chnk_RepeatedIcon       = new Chunk(repIcon, 0, 0, false);
                        Anchor repImage                = new Anchor(chnk_RepeatedIcon);
                        QueryStringEncryption Ecryptor = new QueryStringEncryption();
                        //repImage.Reference = "http://localhost:50876/RepetitionsShower.aspx?QuestionID=" + Ecryptor.encryptQueryString(question["QuestionID"].ToString()) + "&sl=" + giveRepetitionsHyperlinkURL(question["Statement"].ToString()) + "&p=" + Ecryptor.encryptQueryString(question["PNR"].ToString());
                        repImage.Reference = "http://blackchair.manhardeep.com/RepetitionsShower.aspx?QuestionID=" + Ecryptor.encryptQueryString(question["QuestionID"].ToString()) + "&sl=" + giveRepetitionsHyperlinkURL(question["Statement"].ToString()) + "&p=" + Ecryptor.encryptQueryString(question["PNR"].ToString());

                        PdfPCell cell_ImgREP = new PdfPCell(repImage);
                        cell_ImgREP.VerticalAlignment = Element.ALIGN_BOTTOM;
                        repIcon.ScaleAbsolute(30f, 30f);

                        QuestionTable.AddCell(cell_QuestionHolder);                                                                                                                ////PICKUP////
                        QuestionTable.AddCell(PDFfuncs.removeBorders(new PdfPCell(new Phrase("[" + PDFfuncs.formatMarks(question["Weightage"].ToString()) + "]", questionfont)))); ////PICKUP////
                        QuestionTable.AddCell(PDFfuncs.removeBorders(new PdfPCell(PaperLinker)));                                                                                  ////PICKUP////
                        QuestionTable.AddCell(PDFfuncs.removeBorders(new PdfPCell(cell_ImgREP)));

                        ExtractedQuestionsPDF.Add(QuestionTable);
                    }
                    else
                    {
                        QuestionNumber--;
                        qCount++;
                        System.Diagnostics.Debug.WriteLine("in already in reps");
                        //QuestionTable.FlushContent();
                    }
                }
                else//if not repeated question
                {
                    QuestionTable.AddCell(cell_QuestionHolder);////PICKUP////
                    QuestionTable.AddCell(PDFfuncs.removeBorders(new PdfPCell(new Phrase("[" + PDFfuncs.formatMarks(question["Weightage"].ToString()) + "]", questionfont)))); ////PICKUP////
                    QuestionTable.AddCell(PDFfuncs.removeBorders(new PdfPCell(PaperLinker)));                                                                                  ////PICKUP////
                    QuestionTable.AddCell(PDFfuncs.removeBorders(new PdfPCell()));
                    ExtractedQuestionsPDF.Add(QuestionTable);
                }
                //END//Adding Repetitions thingy

                ExtractedQuestionsPDF.Add(new Paragraph("\n"));
            }

            ExtractedQuestionsPDF.Close();
            PDFfuncs.AddPageNumber(Server.MapPath("PDFs") + "/Questions.pdf");
        }