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");
            }
        }
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;
            }
        }