예제 #1
0
 /// <summary>
 /// Renders the specified ASP Session variable and appends it to the specified <see cref="StringBuilder" />.
 /// </summary>
 /// <param name="builder">The <see cref="StringBuilder"/> to append the rendered data to.</param>
 /// <param name="logEvent">Logging event.</param>
 protected internal override void Append(StringBuilder builder, LogEventInfo logEvent)
 {
     ASPHelper.ISessionObject session = ASPHelper.GetSessionObject();
     if (session != null)
     {
         if (Variable != null)
         {
             object variableValue = session.GetValue(Variable);
             builder.Append(Convert.ToString(variableValue));
         }
         Marshal.ReleaseComObject(session);
     }
 }
예제 #2
0
 /// <summary>
 /// Renders the specified ASP Application variable and appends it to the specified <see cref="StringBuilder" />.
 /// </summary>
 /// <param name="builder">The <see cref="StringBuilder"/> to append the rendered data to.</param>
 /// <param name="logEvent">Logging event.</param>
 protected internal override void Append(StringBuilder builder, LogEventInfo logEvent)
 {
     ASPHelper.IApplicationObject app = ASPHelper.GetApplicationObject();
     if (app != null)
     {
         if (Variable != null)
         {
             object variableValue = app.GetValue(Variable);
             builder.Append(Convert.ToString(variableValue));
         }
         Marshal.ReleaseComObject(app);
     }
 }
예제 #3
0
 /// <summary>
 /// Outputs the rendered logging event through the <c>OutputDebugString()</c> Win32 API.
 /// </summary>
 /// <param name="logEvent">The logging event.</param>
 public override void Write(LogEventInfo logEvent)
 {
     ASPHelper.IResponse response = ASPHelper.GetResponseObject();
     if (response != null)
     {
         if (AddComments)
         {
             response.Write("<!-- " + CompiledLayout.GetFormattedMessage(logEvent) + "-->");
         }
         else
         {
             response.Write(CompiledLayout.GetFormattedMessage(logEvent));
         }
         Marshal.ReleaseComObject(response);
     }
 }
예제 #4
0
        /// <summary>
        /// Renders the specified ASP Request variable and appends it to the specified <see cref="StringBuilder" />.
        /// </summary>
        /// <param name="builder">The <see cref="StringBuilder"/> to append the rendered data to.</param>
        /// <param name="logEvent">Logging event.</param>
        protected internal override void Append(StringBuilder builder, LogEventInfo logEvent)
        {
            ASPHelper.IRequest request = ASPHelper.GetRequestObject();
            if (request != null)
            {
                if (QueryString != null)
                {
                    builder.Append(GetItem(request.GetQueryString(), QueryString));
                }
                else if (Form != null)
                {
                    builder.Append(GetItem(request.GetForm(), Form));
                }
                else if (Cookie != null)
                {
                    object cookie = request.GetCookies().GetItem(Cookie);
                    builder.Append(Convert.ToString(ASPHelper.GetComDefaultProperty(cookie)));
                }
                else if (ServerVariable != null)
                {
                    builder.Append(GetItem(request.GetServerVariables(), ServerVariable));
                }
                else if (Item != null)
                {
                    ASPHelper.IDispatch   o  = request.GetItem(Item);
                    ASPHelper.IStringList sl = o as ASPHelper.IStringList;
                    if (sl != null)
                    {
                        if (sl.GetCount() > 0)
                        {
                            builder.Append(sl.GetItem(1));
                        }
                        Marshal.ReleaseComObject(sl);
                    }
                }

                Marshal.ReleaseComObject(request);
            }
        }
예제 #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string strlog = "";

            try
            {
                //------------------
                //Session["B_UserId"] = "d3ec3a0e-d60f-4e40-9e4f-ae7e072225bf";
                //Session["B_UserName"] = "******";

                //Session["B_UserId"] = "e6ff2ed1-133a-4ed8-a4cf-f7e39350b8b4";
                //Session["B_UserName"] = "******";

                if (Session["B_UserId"] == null)
                {
                    return;
                }
                if (Session["B_UserName"] == null)
                {
                    return;
                }
                // strlog += " 1- if (Session[\"CAM_UserExamID\"] == null) <br/>";
                // Logging(strlog);
                if (Session["CAM_UserExamID"] == null)
                {
                    return;
                }
                UserId            = Session["B_UserId"].ToString();
                Session["UserId"] = UserId;
                UserExamID        = Session["CAM_UserExamID"].ToString();
                //----------
                string sql = "SET DATEFORMAT dmy; Select * from B_UserExam_Sim where UserExamID=@UserExamID;";
                List <SqlParameter> spl = new List <SqlParameter>();
                spl.Add(new SqlParameter("UserExamID", UserExamID));
                DataTable B_UserExam_Sim = DBManager.PopulateList(sql, spl);
                sql = "";
                spl.Clear();

                // ------ Get course,Exam data (exam time, # of questions) --------
                // strlog += " 2- if (B_UserExam_Sim.Rows.Count == 1) = "+ B_UserExam_Sim.Rows.Count + "<br/>";
                // Logging(strlog);
                if (B_UserExam_Sim.Rows.Count == 1)
                {
                    CrntExamStatus = B_UserExam_Sim.Rows[0]["ExamStatus"].ToString();
                    // strlog += " 2.1- CrntExamStatus = " + CrntExamStatus + "<br/>";
                    // Logging(strlog);
                    if (CrntExamStatus == "Reserved" || CrntExamStatus == "Finished")
                    {
                        return;
                    }
                    sql = "select top(1) CaptureDateTime from B_UserExamImages_Sim where UserExamID=@UserExamID order by CaptureDateTime";
                    spl.Add(new SqlParameter("UserExamID", UserExamID));
                    DataTable tbl00 = DBManager.PopulateList(sql, spl);
                    // strlog += " 2.2- if (tbl00.Rows.Count > 0) = " + tbl00.Rows.Count + "<br/>";
                    // Logging(strlog);
                    if (tbl00.Rows.Count > 0)
                    {
                        if (Session["FirstImageTime"] == null)
                        {
                            Session["FirstImageTime"] = DateTime.Now;
                        }
                        DateTime FirstImageTime = (DateTime)Session["FirstImageTime"];
                        // strlog += " 2.3 Now= "+DateTime.Now.ToString()+ " if (DateTime.Now > FirstImageTime.AddHours(2)) " + FirstImageTime.AddHours(2).ToString() + "<br/>";
                        // Logging(strlog);

                        if (DateTime.Now > FirstImageTime.AddHours(2))
                        {
                            return;
                        }
                    }
                    // strlog += " 3- if (Request.InputStream.Length > 0) = "+ Request.InputStream.Length + "<br/>";
                    // Logging(strlog);
                    if (Request.InputStream.Length > 0)
                    {
                        using (StreamReader reader = new StreamReader(Request.InputStream))
                        {
                            // strlog += " 4- using (StreamReader reader = new StreamReader(Request.InputStream)) <br/>";
                            // Logging(strlog);
                            string hexString = Server.UrlEncode(reader.ReadToEnd());
                            string imageName = ASPHelper.GetUniqueDateTimeStamp();
                            string imagePath = string.Format("~/Exams/Captures/{0}.png", imageName);
                            File.WriteAllBytes(Server.MapPath(imagePath), ConvertHexToBytes(hexString));
                            Session["CapturedImage"] = ResolveUrl(imagePath);

                            //--- save image to table B_UserExamImages ------
                            sql = "SET DATEFORMAT dmy; insert into B_UserExamImages_Sim(UserExamID,ImageURL,CaptureDateTime,isCertificateImg) values(@UserExamID,@ImageURL,GetDate(),@isCertificateImg); SELECT SCOPE_IDENTITY() AS UExamImageId";
                            spl.Clear();
                            spl.Add(new SqlParameter("UserExamID", UserExamID));
                            spl.Add(new SqlParameter("ImageURL", imagePath));
                            spl.Add(new SqlParameter("isCertificateImg", false));

                            DataTable tbl0 = DBManager.PopulateList(sql, spl);
                            // strlog += " 5- if (tbl0.Rows.Count==1) <br/>";
                            // Logging(strlog);
                            if (tbl0.Rows.Count == 1)
                            {
                                Session["LastUExamImageId"] = tbl0.Rows[0][0].ToString();
                                Session["crntUserExamID"]   = UserExamID;
                            }
                        } // using
                    }     // if
                }
            }
            catch (Exception ex)
            {
                // strlog += " 6- "+ ex.Message+"<br/>";
                // Logging(strlog);
            }
        }
예제 #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string strlog = "";

            try
            {
                try
                {
                    ScheduleId = "0";
                    CourseId   = Session["CAM_CourseId"].ToString();
                    OrderId    = Session["CAM_OrderId"].ToString();
                    ScheduleId = Session["CAM_ScheduleId"].ToString();
                }
                catch (Exception eexx)
                {
                    strlog = " 1- eexx: " + eexx.Message + " <br/>";
                    Logging(strlog);
                }
                //------------------
                //Session["B_UserId"] = "d3ec3a0e-d60f-4e40-9e4f-ae7e072225bf";
                //Session["B_UserName"] = "******";

                //Session["B_UserId"] = "e6ff2ed1-133a-4ed8-a4cf-f7e39350b8b4";
                //Session["B_UserName"] = "******";

                strlog = " 2- if (Session[\"B_UserId\"] == null) < br/>";
                Logging(strlog);
                if (Session["B_UserId"] == null)
                {
                    return;
                }
                strlog = " 3- if (Session[\"B_UserName\"] == null) < br/>";
                Logging(strlog);
                if (Session["B_UserName"] == null)
                {
                    return;
                }
                UserId            = Session["B_UserId"].ToString();
                Session["UserId"] = UserId;
                //----------
                string sql = "SET DATEFORMAT dmy; Select * from view_UserCoursesExams where ScheduleId=@ScheduleId and OrderId=@OrderId and CourseId=@CourseId and UserId=@UserId and CONVERT(date, FromDateTime)=CONVERT(date,GETDATE());";
                List <SqlParameter> spl = new List <SqlParameter>();
                spl.Add(new SqlParameter("UserId", UserId));
                spl.Add(new SqlParameter("ScheduleId", ScheduleId));
                spl.Add(new SqlParameter("CourseId", CourseId));
                spl.Add(new SqlParameter("OrderId", OrderId));
                strlog = " 4- if (ScheduleId==0) = " + ScheduleId + "< br/>";
                Logging(strlog);
                if (ScheduleId == "0")
                {
                    sql = "SET DATEFORMAT dmy; Select * from B_UserExam where ScheduleId=0 and OrderId=@OrderId and CourseId=@CourseId and UserId=@UserId and CONVERT(date, ReservationDateTime)=CONVERT(date,GETDATE());";
                }
                DataTable tbl_UserExamSchedule = DBManager.PopulateList(sql, spl);
                sql = "";
                spl.Clear();

                // ------ Get course,Exam data (exam time, # of questions) --------
                strlog = " 5- if (tbl_UserExamSchedule.Rows.Count == 1) , " + tbl_UserExamSchedule.Rows.Count + "< br/>";
                Logging(strlog);
                if (tbl_UserExamSchedule.Rows.Count == 1)
                {
                    UserExamID     = tbl_UserExamSchedule.Rows[0]["UserExamID"].ToString();
                    CrntExamStatus = tbl_UserExamSchedule.Rows[0]["ExamStatus"].ToString();
                    strlog         = " 6- CrntExamStatus " + CrntExamStatus + "< br/>";
                    Logging(strlog);
                    if (CrntExamStatus == "Reserved" || CrntExamStatus == "FinishedMCQ" || CrntExamStatus == "Finished")
                    {
                        return;
                    }
                    strlog = " 7- if (ScheduleId != 0) " + ScheduleId + "< br/>";
                    Logging(strlog);
                    if (ScheduleId != "0")
                    {
                        DateTime FromDateTime = (DateTime)tbl_UserExamSchedule.Rows[0]["FromDateTime"];
                        DateTime ToDateTime   = (DateTime)tbl_UserExamSchedule.Rows[0]["ToDateTime"];
                        strlog = " 8- if (DateTime.Now > ToDateTime.AddMinutes(30)) " + ToDateTime.AddMinutes(30).ToString() + "< br/>";
                        Logging(strlog);
                        if (DateTime.Now > ToDateTime.AddMinutes(30))
                        {
                            return;
                        }
                    }
                    strlog = " 9- if (Request.InputStream.Length > 0) " + Request.InputStream.Length + "< br/>";
                    Logging(strlog);
                    if (Request.InputStream.Length > 0)
                    {
                        using (StreamReader reader = new StreamReader(Request.InputStream))
                        {
                            string hexString = Server.UrlEncode(reader.ReadToEnd());
                            string imageName = ASPHelper.GetUniqueDateTimeStamp();
                            string imagePath = string.Format("~/Exams/Captures/{0}.png", imageName);
                            File.WriteAllBytes(Server.MapPath(imagePath), ConvertHexToBytes(hexString));
                            Session["CapturedImage"] = ResolveUrl(imagePath);
                            strlog = " 9.1 - imagePath " + imagePath + "< br/>";
                            Logging(strlog);
                            //--- save image to table B_UserExamImages ------
                            sql = "SET DATEFORMAT dmy; insert into B_UserExamImages(UserExamID,ImageURL,CaptureDateTime,isCertificateImg) values(@UserExamID,@ImageURL,GetDate(),@isCertificateImg); SELECT SCOPE_IDENTITY() AS UExamImageId";
                            spl.Clear();
                            spl.Add(new SqlParameter("UserExamID", UserExamID));
                            spl.Add(new SqlParameter("ImageURL", imagePath));
                            spl.Add(new SqlParameter("isCertificateImg", false));

                            DataTable tbl0 = DBManager.PopulateList(sql, spl);
                            strlog = " 10- if (tbl0.Rows.Count==1)" + tbl0.Rows.Count + "< br/>";
                            Logging(strlog);
                            if (tbl0.Rows.Count == 1)
                            {
                                Session["LastUExamImageId"] = tbl0.Rows[0][0].ToString();
                                Session["crntUserExamID"]   = UserExamID;
                            }
                        } // using
                    }     // if
                }
            }
            catch (Exception ex)
            {
                strlog = " 11- ex= " + ex.Message + "< br/>";
                Logging(strlog);
            }
        }
예제 #7
0
 private string GetItem(ASPHelper.IRequestDictionary dict, string key)
 {
     object retVal = null;
     object o = dict.GetItem(key);
     ASPHelper.IStringList sl = o as ASPHelper.IStringList;
     if (sl != null)
     {
         if (sl.GetCount() > 0)
         {
             retVal = sl.GetItem(1);
         }
         Marshal.ReleaseComObject(sl);
     }
     else
         return o.GetType().ToString();
     return Convert.ToString(retVal);
 }