Beispiel #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string did = Request.QueryString["did"].ToString();

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

            CB.InsertIntoUserLog(int.Parse(Session[sessionNames.userID_Karbar].ToString()), DateTime.Now.ToShortTimeString(), int.Parse(Session[sessionNames.appID_Karbar].ToString()), 68, " پرینت پاسخنامه مشخصه " + did);
            this.StiWebViewer1.ResetReport();
            DataTable dt1 = new DataTable();

            dt1 = EBusiness.ExamAnswerSheetbyDid(did, int.Parse(Session[sessionNames.userID_Karbar].ToString()));
            StiWebViewer1.Visible = true;
            StiReport rpt = new StiReport();

            string targetReport = "";

            if (whichBtn == "btn_printExamSheet")
            {
                targetReport = Server.MapPath("../Reports/AnswerSheet1.mrt");
            }
            else if (whichBtn == "btn_printExamSheetByA4Format")
            {
                targetReport = Server.MapPath("../Reports/AnswerSheetA4.mrt");
            }

            //rpt.Load(Server.MapPath("../Reports/AnswerSheet1.mrt"));
            rpt.Load(targetReport);
            rpt.Dictionary.Databases.Clear();
            rpt.Dictionary.Databases.Add(new StiSqlDatabase("Supplementary", CB.ReportConnection.ToString()));
            rpt.Compile();
            rpt.CompiledReport.DataSources["[Exam].[SP_ExamAnswerSheetbyDid]"].Parameters["@did"].ParameterValue        = int.Parse(did);
            rpt.CompiledReport.DataSources["[Exam].[SP_ExamAnswerSheetbyDid]"].Parameters["@ExaminerID"].ParameterValue = int.Parse(Session[sessionNames.userID_Karbar].ToString());
            rpt.RegData(dt1);
            rpt.ReportCacheMode  = StiReportCacheMode.On;
            StiWebViewer1.Report = rpt;
        }
Beispiel #2
0
        protected void grd_Class_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
        {
            if (e.CommandName == "Filter")
            {
                return;
            }

            string did         = "0";
            var    dtdet       = new DataTable();
            var    path        = string.Empty;
            var    absPath     = string.Empty;
            var    pass        = string.Empty;
            var    hdnPassword = (HiddenField)e.Item.FindControl("hdnPassword");


            if (e.CommandName == "ShowNewHeaderForAll" || e.CommandName == "ShowNewHeader" || e.CommandName == "ShowOldHeader")
            {
                did     = e.CommandArgument.ToString();
                dtdet   = examBusiness.Get_ExamdetailbyDid(did);
                path    = $"QueizPapers/{dtdet.Rows[0]["tterm"].ToString()}/{dtdet.Rows[0]["code_ostad"].ToString()}/pdffiles/{e.CommandArgument.ToString()}";
                absPath = Server.MapPath($"~/{path}");
                var base64HashesPassword = Convert.FromBase64String(hdnPassword.Value);
                pass = EncryptionClass.DecryptRJ256(base64HashesPassword);
            }

            var QuestionId            = Convert.ToInt32(e.CommandArgument.ToString());
            var constQuestionFileInfo = new ExamStudentDTO();
            var whiteTape             = Server.MapPath("~/University/Theme/images/whitePaper.jpg");
            var questioHeaderTemplate = Server.MapPath("~/University/Theme/images/QuestionHeaderTemplate.jpg");
            var userID = Session[sessionNames.userID_Karbar].ToString();


            switch (e.CommandName)
            {
            case "ShowNewHeaderForAll":

                constQuestionFileInfo = dtdet.AsEnumerable().Select(x => new ExamStudentDTO()
                {
                    TypeNimsal        = x.Field <string>("typeNimsal"),
                    CourseTitle       = x.Field <string>("namedars"),
                    ProfossorFullName = x.Field <string>("osname"),
                    ExamDate          = x.Field <string>("dateexam"),
                    ExamTime          = x.Field <string>("saatexam"),
                    KeyCode           = x.Field <string>("keyCode"),
                    ExamDuration      = x.Field <string>("examTime"),
                    Calculator        = x.Field <string>("calculator"),
                    Note      = x.Field <string>("note"),
                    LowBook   = x.Field <string>("LowBook"),
                    ClassCode = x.Field <string>("ClassCode").ToString()
                }).FirstOrDefault();

                var dt          = examBusiness.ExamAnswerSheetbyDid(did, int.Parse(Session[sessionNames.userID_Karbar].ToString()));
                var studentList = dt.AsEnumerable().Select(x => new ExamStudentDTO()
                {
                    FirstName   = x.Field <string>("stFirstName"),
                    LastName    = x.Field <string>("stLastName"),
                    StudentCode = x.Field <string>("stcode"),
                    Grade       = x.Field <string>("magh"),
                    Major       = x.Field <string>("nameresh"),
                    SeatHeader  = x.Field <string>("SeatHeader"),
                    SeatNumber  = x.Field <int?>("SeatNumber")
                }).ToList();


                examBusiness.GeneratePdfQuestionForStudents(absPath, did.ToString(), pass, questioHeaderTemplate, whiteTape, userID, constQuestionFileInfo, studentList);
                Session["BigFile"] = true;
                ShowFiles($"{path}/{userID}/{did}_Momtahen_{userID}_2.zip", pass);
                break;

            case "ShowNewHeader":

                constQuestionFileInfo = dtdet.AsEnumerable().Select(x => new ExamStudentDTO()
                {
                    TypeNimsal        = x.Field <string>("typeNimsal"),
                    CourseTitle       = x.Field <string>("namedars"),
                    ProfossorFullName = x.Field <string>("osname"),
                    ExamDate          = x.Field <string>("dateexam"),
                    ExamTime          = x.Field <string>("saatexam"),
                    KeyCode           = x.Field <string>("keyCode"),
                    ExamDuration      = x.Field <string>("examTime"),
                    Calculator        = x.Field <string>("calculator"),
                    Note      = x.Field <string>("note"),
                    LowBook   = x.Field <string>("LowBook"),
                    ClassCode = x.Field <string>("ClassCode").ToString()
                }).FirstOrDefault();


                examBusiness.ChangeTemplateOfQuestion(absPath, e.CommandArgument.ToString(), pass, constQuestionFileInfo, questioHeaderTemplate, whiteTape, userID);
                ShowFiles($"{path}/{userID}/{did}_Momtahen_{userID}_1.zip", pass);
                break;

            case "ShowOldHeader":

                constQuestionFileInfo = dtdet.AsEnumerable().Select(x => new ExamStudentDTO()
                {
                    TypeNimsal        = x.Field <string>("typeNimsal"),
                    CourseTitle       = x.Field <string>("namedars"),
                    ProfossorFullName = x.Field <string>("osname"),
                    ExamDate          = x.Field <string>("dateexam"),
                    ExamTime          = x.Field <string>("saatexam"),
                    KeyCode           = x.Field <string>("keyCode"),
                    ExamDuration      = x.Field <string>("examTime"),
                    Calculator        = x.Field <string>("calculator"),
                    Note      = x.Field <string>("note"),
                    LowBook   = x.Field <string>("LowBook"),
                    ClassCode = x.Field <string>("ClassCode").ToString()
                }).FirstOrDefault();


                examBusiness.ChangeTemplateOfQuestion(absPath, e.CommandArgument.ToString(), pass, constQuestionFileInfo, questioHeaderTemplate, whiteTape, userID);
                ShowFiles($"{path}/{did}.zip", pass);
                break;

            case "ApproveNewHeader":
                examBusiness.SetApproveNewHeader(QuestionId, true);
                BindGrid = true;
                grd_Class.Rebind();
                break;

            case "RejectNewHeader":
                examBusiness.SetApproveNewHeader(QuestionId, false);
                BindGrid = true;
                grd_Class.Rebind();
                break;
            }
        }
        protected void grd_CourseList_ItemCommand(object sender, GridCommandEventArgs e)
        {
            string ipaddress;

            ipaddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
            if (ipaddress == "" || ipaddress == null)
            {
                ipaddress = Request.ServerVariables["REMOTE_ADDR"];
            }
            var ip = (HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != null &&
                      HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != "")
           ? HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]
           : HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];

            if (ip.Contains(","))
            {
                ip = ip.Split(',').First();
            }

            var cmdArgs  = e.CommandArgument.ToString().Split(',');
            var did      = cmdArgs[0];
            var cityIdQ2 = int.Parse(cmdArgs[1]);
            var statusQ1 = int.Parse(cmdArgs[2]);
            var statusQ2 = int.Parse(cmdArgs[3]);

            int?cityIDQ2 = null;

            if (statusQ1 == 3 && statusQ2 != -1)
            {
                cityIDQ2 = cityIdQ2;
            }



            var mainFormatClick = false;
            var examQ_Detail    = EBusiness.Get_ExamdetailbyDid(did, null, cityIDQ2);

            if (e.CommandName == "DlQuestionMainFormat")//فرمت اصلی سوالات بدون تغیرات
            {
                var relativePath = "QueizPapers/" + examQ_Detail.Rows[0]["tterm"].ToString() + "/" + examQ_Detail.Rows[0]["code_ostad"].ToString() + "/pdffiles/" + did.ToString();
                //    string path = Server.MapPath($"~/{relativePath}");
                CB.InsertIntoUserLogwithIP(int.Parse(Session[sessionNames.userID_Karbar].ToString()), DateTime.Now.ToShortTimeString(), int.Parse(Session[sessionNames.appID_Karbar].ToString()), 67, ip, " دانلود سوالات امتحان مشخصه " + did.ToString());
                DownloadZipFile(relativePath, $"{did.ToString()}.zip");
                mainFormatClick = true;
                //SendFileToUser(path + "\\" + e.CommandArgument.ToString() + ".zip");
            }
            if (e.CommandName == "DlQuestionSinglePage" && !mainFormatClick) //حاصل از فایل سوال وپیوست بدون اطلاعات دانشجو pdf فایل
            {
                var path = $"QueizPapers/{examQ_Detail.Rows[0]["tterm"].ToString()}/{examQ_Detail.Rows[0]["code_ostad"].ToString()}/pdffiles/{did.ToString()}";

                CB.InsertIntoUserLogwithIP(int.Parse(Session[sessionNames.userID_Karbar].ToString()), DateTime.Now.ToShortTimeString(), int.Parse(Session[sessionNames.appID_Karbar].ToString()), 67, ip, " دانلود سوالات امتحان مشخصه " + did.ToString());

                var constQuestionFileInfo = new ExamStudentDTO();
                constQuestionFileInfo.TypeNimsal        = examQ_Detail.Rows[0]["typeNimsal"].ToString();
                constQuestionFileInfo.CourseTitle       = examQ_Detail.Rows[0]["namedars"].ToString();
                constQuestionFileInfo.ProfossorFullName = examQ_Detail.Rows[0]["osname"].ToString();
                constQuestionFileInfo.ExamDate          = examQ_Detail.Rows[0]["dateexam"].ToString();
                constQuestionFileInfo.ExamTime          = examQ_Detail.Rows[0]["saatexam"].ToString();
                constQuestionFileInfo.KeyCode           = examQ_Detail.Rows[0]["keyCode"].ToString();
                constQuestionFileInfo.ExamDuration      = examQ_Detail.Rows[0]["examTime"].ToString();
                constQuestionFileInfo.Calculator        = examQ_Detail.Rows[0]["calculator"].ToString();
                constQuestionFileInfo.Note      = examQ_Detail.Rows[0]["note"].ToString();
                constQuestionFileInfo.LowBook   = examQ_Detail.Rows[0]["LowBook"].ToString();
                constQuestionFileInfo.ClassCode = examQ_Detail.Rows[0]["ClassCode"].ToString();
                constQuestionFileInfo.Grade     = examQ_Detail.Rows[0]["magh"].ToString();
                constQuestionFileInfo.Major     = examQ_Detail.Rows[0]["nameresh"].ToString();

                TextBox lbl_Password          = (TextBox)e.Item.FindControl("lbl_Password");
                var     pass                  = lbl_Password.Text;
                var     whiteTape             = Server.MapPath("~/University/Theme/images/whitePaper.jpg");
                var     questioHeaderTemplate = Server.MapPath("~/University/Theme/images/QuestionHeaderTemplate.jpg");

                var userID  = Session[sessionNames.userID_Karbar].ToString();
                var absPath = Server.MapPath($"/{path}");
                var res     = EBusiness.ChangeTemplateOfQuestion(absPath, did.ToString(), pass, constQuestionFileInfo, questioHeaderTemplate, whiteTape, userID, cityIDQ2);

                DownloadZipFile($"{path}/{userID}", $"{did}_Momtahen_{userID}_1.zip");
            }
            if (e.CommandName == "DlQuestionMergedFiles" && !mainFormatClick)//حاصل از فایل سوال وپیوست به همراه اطلاعات دانشجو pdf فایل
            {
                var path = $"QueizPapers/{examQ_Detail.Rows[0]["tterm"].ToString()}/{examQ_Detail.Rows[0]["code_ostad"].ToString()}/pdffiles/{did.ToString()}";

                var constQuestionFileInfo = new ExamStudentDTO();
                constQuestionFileInfo.TypeNimsal        = examQ_Detail.Rows[0]["typeNimsal"].ToString();
                constQuestionFileInfo.CourseTitle       = examQ_Detail.Rows[0]["namedars"].ToString();
                constQuestionFileInfo.ProfossorFullName = examQ_Detail.Rows[0]["osname"].ToString();
                constQuestionFileInfo.ExamDate          = examQ_Detail.Rows[0]["dateexam"].ToString();
                constQuestionFileInfo.ExamTime          = examQ_Detail.Rows[0]["saatexam"].ToString();
                constQuestionFileInfo.KeyCode           = examQ_Detail.Rows[0]["keyCode"].ToString();
                constQuestionFileInfo.ExamDuration      = examQ_Detail.Rows[0]["examTime"].ToString();
                constQuestionFileInfo.Calculator        = examQ_Detail.Rows[0]["calculator"].ToString();
                constQuestionFileInfo.Note      = examQ_Detail.Rows[0]["note"].ToString();
                constQuestionFileInfo.LowBook   = examQ_Detail.Rows[0]["LowBook"].ToString();
                constQuestionFileInfo.ClassCode = examQ_Detail.Rows[0]["ClassCode"].ToString();
                constQuestionFileInfo.Grade     = examQ_Detail.Rows[0]["magh"].ToString();
                constQuestionFileInfo.Major     = examQ_Detail.Rows[0]["nameresh"].ToString();

                var dt          = EBusiness.ExamAnswerSheetbyDid(did, int.Parse(Session[sessionNames.userID_Karbar].ToString()));
                var studentList = dt.AsEnumerable().Select(x => new ExamStudentDTO()
                {
                    FirstName   = x.Field <string>("stFirstName") ?? "",
                    LastName    = x.Field <string>("stLastName") ?? "",
                    StudentCode = x.Field <string>("stcode") ?? "",
                    Grade       = x.Field <string>("magh") ?? "",
                    Major       = x.Field <string>("nameresh") ?? "",
                    SeatHeader  = x.Field <string>("SeatHeader") ?? "",
                    SeatNumber  = x.Field <int?>("SeatNumber")
                }).ToList();

                TextBox lbl_Password          = (TextBox)e.Item.FindControl("lbl_Password");
                var     pass                  = lbl_Password.Text;
                var     whiteTape             = Server.MapPath("~/University/Theme/images/whitePaper.jpg");
                var     questioHeaderTemplate = Server.MapPath("~/University/Theme/images/QuestionHeaderTemplate.jpg");

                var userID  = Session[sessionNames.userID_Karbar].ToString();
                var absPath = Server.MapPath($"/{path}");
                var res     = EBusiness.GeneratePdfQuestionForStudents(absPath, did.ToString(), pass, questioHeaderTemplate, whiteTape, userID, constQuestionFileInfo, studentList, cityIDQ2);

                DownloadZipFile($"{path}/{userID}", $"{did}_Momtahen_{userID}_2.zip");
            }
        }
        protected void grd_CourseList_ItemCommand(object sender, GridCommandEventArgs e)
        {
            ExamBusiness EBusiness = new ExamBusiness();
            string       ipaddress;

            ipaddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
            if (ipaddress == "" || ipaddress == null)
            {
                ipaddress = Request.ServerVariables["REMOTE_ADDR"];
            }
            var ip = (HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != null &&
                      HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != "")
           ? HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]
           : HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];

            if (ip.Contains(","))
            {
                ip = ip.Split(',').First();
            }
            //DataTable dtdet = new DataTable();
            // dtdet = EBusiness.Get_ExamdetailbyDid(int.Parse(e.CommandArgument.ToString()));

            if (e.CommandName == "ExamSheet" || e.CommandName == "ExamSheetA4")
            {
                var did = e.CommandArgument.ToString();

                var whichBtn = (e.CommandSource as Button).ID;


                DataTable dt1 = new DataTable();
                dt1 = EBusiness.ExamAnswerSheetbyDid(did, int.Parse(Session[sessionNames.userID_Karbar].ToString()));

                StiReport rpt = new StiReport();

                string targetReport = "";
                if (whichBtn == "btn_printExamSheet")
                {
                    targetReport = Server.MapPath("../Reports/AnswerSheet1.mrt");
                }
                else if (whichBtn == "btn_printExamSheetByA4Format")
                {
                    targetReport = Server.MapPath("../Reports/AnswerSheetA4.mrt");
                }
                rpt.Load(targetReport);
                rpt.Dictionary.Databases.Clear();
                rpt.Dictionary.Databases.Add(new StiSqlDatabase("Supplementary", CB.ReportConnection.ToString()));


                if (whichBtn == "btn_printExamSheet")
                {
                    rpt.ReportName = $"{did}-{ddl_ExamDate.SelectedValue}-{ddl_Saate.SelectedValue}-A3";
                }
                else if (whichBtn == "btn_printExamSheetByA4Format")
                {
                    rpt.ReportName = $"{did}-{ddl_ExamDate.SelectedValue}-{ddl_Saate.SelectedValue}-A4";
                }
                rpt.ReportCacheMode = StiReportCacheMode.Off;
                rpt.Compile();
                rpt.CompiledReport.DataSources["[Exam].[SP_ExamAnswerSheetbyDid]"].Parameters["@did"].ParameterValue        = did;
                rpt.CompiledReport.DataSources["[Exam].[SP_ExamAnswerSheetbyDid]"].Parameters["@ExaminerID"].ParameterValue = int.Parse(Session[sessionNames.userID_Karbar].ToString());
                rpt.CompiledReport.DataSources["[Exam].[SP_ExamAnswerSheetbyDid]"].Parameters["@examDate"].ParameterValue   = ddl_ExamDate.SelectedValue;
                rpt.CompiledReport.DataSources["[Exam].[SP_ExamAnswerSheetbyDid]"].Parameters["@examTime"].ParameterValue   = ddl_Saate.SelectedValue;

                rpt.RegData(dt1);



                StiReportResponse.ResponseAsPdf(this.Page, rpt, true);


                CommonBusiness cmnb = new CommonBusiness();
                CB.InsertIntoUserLog(int.Parse(Session[sessionNames.userID_Karbar].ToString()), DateTime.Now.ToShortTimeString(), int.Parse(Session[sessionNames.appID_Karbar].ToString()), 68, "چاپ پاسخنامه", int.Parse(e.CommandArgument.ToString()));
            }
        }