Example #1
0
 protected void Page_Load(object sender, System.EventArgs e)
 {
     try
     {
         //Response.AddHeader("Refresh", Convert.ToString((Session.Timeout*60)-10));
         pagTitle.Text = ResourceManager.GetString("pagTitle");
         if (!Page.IsPostBack)
         {
             BusinessServices.Organisation objOrganisation = new BusinessServices.Organisation();
             if (objOrganisation.GetOrganisationCPDEventAccess(UserContext.UserData.OrgID))
             {
                 CPDBindGrid();
             }
             else// dosnt have access to CPD
             {
                 panCPD.Visible = false;
                 this.btnCreateEvent.Visible = false;
                 lblMessage.Text             = ResourceManager.GetString("NoAccess");
                 lblMessage.CssClass         = "WarningMessage";
             }
         }
     }
     catch (Exception Ex)
     {
         ErrorHandler.ErrorLog Error = new ErrorHandler.ErrorLog(Ex, ErrorLevel.Medium, "cpdevent.aspx.cs", "Page_Load", "GetFilename");
         throw (Ex);
     }
 }
Example #2
0
        /// <summary>
        /// Get Pagination Data
        /// </summary>
        /// <returns></returns>
        private DataTable GetPaginationData()
        {
            // Customize, and return DataView
            // conduct search based on criteria
            Report    objReport = new Report();
            DataTable odtReport = new DataTable();


            try
            {
                //odtReport = objReport.GetIndividualReport(UserContext.UserID);   // report data
                odtReport = objReport.GetIndividualReport(UserId);   // report data
                if (odtReport.Rows.Count == 0)
                {
                    this.lblError.Text    += "No results found.";
                    this.lblError.CssClass = "FeedbackMessage";
                }
            }

            catch (Exception Ex)
            {
                ErrorHandler.ErrorLog Error = new ErrorHandler.ErrorLog(Ex, ErrorLevel.Medium, "IndividualReport.aspx.cs", "GetPaginationData()", "Binding Data to Datagrid");
                throw (Ex);
            }


            return(odtReport);
        }
Example #3
0
        /// <summary>
        /// Show Paging Data.
        /// </summary>
        /// <param name="currentPageIndex"></param>
        private void ShowPagination(int currentPageIndex)
        {
            try
            {
                //1. Get data
                DataTable dtbIndividual = this.GetPaginationData();
                DataView  dvwPagination = dtbIndividual.DefaultView;

                if (dvwPagination.Table.Rows.Count == 0)
                {
                    this.lblError.Text     = ResourceManager.GetString("lblError.NoUsers");//"No users found.";
                    this.lblError.CssClass = "FeedbackMessage";
                }
                if (dvwPagination.Count <= ApplicationSettings.PageSize)
                {
                    this.trPagination.Visible = false;
                }
                else
                {
                    this.trPagination.Visible = true;
                }

                if (dvwPagination.Count == 0)
                {
                    this.tblPagination.Visible = false;
                }

                //3. Set pagination panel
                int intPageSize;
                intPageSize = ApplicationSettings.PageSize;
                this.SetPaginationPanel(intPageSize, dvwPagination.Count, currentPageIndex);

                //4. Bind Data
                // add columns as required for the profiles & points

                int colCount = dtbIndividual.Columns.Count;


                for (int i = 11; i < colCount; i++)// 0index //11th column of the data set not of the grid!!!
                {
                    dgrResults.Columns.Add(CreateBoundColumn(dtbIndividual.Columns[i]));
                }

                //5. Set the Key field for the DataGrid
                dgrResults.DataKeyField = "UserID";
                dgrResults.DataSource   = dvwPagination;
                //dgrResults.PageSize = intPageSize;
                //dgrResults.CurrentPageIndex = currentPageIndex;
                dgrResults.DataBind();
                // do this for all the new columns we just added
                dgrResults.ItemStyle.CssClass = dgrResults.Columns[5].ItemStyle.CssClass;
            }
            catch (Exception Ex)
            {
                ErrorHandler.ErrorLog Error = new ErrorHandler.ErrorLog(Ex, ErrorLevel.Medium, "ExportCPDProfileReport.aspx.cs", "ShowPagination()", "Binding Data to Datagrid");
                throw (Ex);
            }
        }
Example #4
0
        private void ShowEventPagination(int currentEventPageIndex)
        {
            try
            {
                HtmlTableRow trEventPagination = FindControl("trEventPagination") as HtmlTableRow;

                //1. Get data
                DataSet  dtbEventIndividual = this.GetEventPaginationData();
                DataView dvwEventPagination = dtbEventIndividual.Tables[0].DefaultView;

                if (dvwEventPagination.Table.Rows.Count == 0)
                {
                    this.lblError.Text     = ResourceManager.GetString("lblError.NoUsers");//"No users found.";
                    this.lblError.CssClass = "FeedbackMessage";
                }

                //2. Set pagination panel
                int intEventPageSize;
                intEventPageSize = ApplicationSettings.PageSize;
                this.SetEventPaginationPanel(intEventPageSize, dvwEventPagination.Count, currentEventPageIndex);

                //3. Bind Data
                // add columns as required for the profiles & points

                int colCount = dtbEventIndividual.Tables[0].Columns.Count;

                for (int i = 11; i < colCount; i++)
                {
                    //string strUserID = UserContext.UserID.ToString();
                    string strUserID = UserId.ToString();
                    //string strUserID = "1381";
                    string strColName = dtbEventIndividual.Tables[0].Columns[i].ToString();

                    BoundColumn test = new BoundColumn();
                    test.DataField  = strColName;
                    test.HeaderText = strColName;

                    if (strColName.Substring(strColName.Length - 3, 3) == "ID~")
                    {
                        test.Visible = false;
                    }
                    test.ItemStyle.CssClass = "tablerow2";
                    dgrEvent.Columns.Add(test);
                }

                dgrEvent.DataKeyField = "EventPeriodID";
                dgrEvent.DataSource   = dvwEventPagination;
                //dgrEvent.PageSize = intEventPageSize;
                //dgrEvent.CurrentPageIndex = currentEventPageIndex;
                dgrEvent.DataBind();
            }
            catch (Exception Ex)
            {
                ErrorHandler.ErrorLog Error = new ErrorHandler.ErrorLog(Ex, ErrorLevel.Medium, "ExportCPDEventReport.aspx.cs", "ShowEventPagination()", "Binding Data to Datagrid");
                throw (Ex);
            }
        }
Example #5
0
        /// <summary>
        /// Application Error event. An error has occurred within the application and this
        /// method must handle it and attempt to log it to the database
        /// </summary>
        /// <param name="sender">Object</param>
        /// <param name="e">EventArgs</param>
        protected void Application_Error(Object sender, EventArgs e)
        {
            // Try and log error.
            try
            {
                Exception ex = HttpContext.Current.Error.GetBaseException();
                if (VerifyAppConnectionsAvailability() == false ||
                    VerifyRepConnectionsAvailability() == false)
                {
                    //string strMessage = "SQL Connection Error";
                    //ApplicationException SqlConnectionException = new ApplicationException(strMessage);
                    //ErrorHandler.ErrorLog SecurityErrorLog = new ErrorHandler.ErrorLog(SqlConnectionException,ErrorLevel.High,"Global.asas","Application_Error","See previous exception");
#if !debugMode
                    if (Request.Url.Host.ToLower().Equals("127.0.0.2"))
                    {
                        Response.Redirect("https://" + Request.Url.Host + "/general/errors/SqlConnectionException.aspx");
                    }
                    else
                    {
                        Response.Redirect("http://" + Request.Url.Host + "/general/errors/SqlConnectionException.aspx");
                    }
#endif
                }
                else
                {
                    if (ex.GetBaseException() is System.Web.HttpRequestValidationException)
                    {
                        // Log it as a regular errors
                        ErrorHandler.ErrorLog ErrorLog = new ErrorHandler.ErrorLog(ex, ErrorLevel.High);

                        // Log security Errors differently
                        string strMessage = "Security Error";
                        strMessage += " User Host Address:" + Request.UserHostAddress.ToString();
                        strMessage += " User Host Name:" + Request.UserHostName.ToString();
                        strMessage += " User Agent:" + Request.UserAgent.ToString();
                        strMessage += " User Request Type:" + Request.RequestType.ToString();
                        strMessage += " User QueryString:" + Request.QueryString.ToString();

                        ApplicationException SecurityException = new ApplicationException(strMessage);

                        ErrorHandler.ErrorLog SecurityErrorLog = new ErrorHandler.ErrorLog(SecurityException, ErrorLevel.High, "Global.asas", "Application_Error", "See previous exception");

                        Server.Transfer("/general/errors/ValidationException.aspx");
                    }
                    else
                    {
                        // Log all regular errors
                        new ErrorHandler.ErrorLog(ex, Bdw.Application.Salt.Data.ErrorLevel.Medium, "Global.asax.cs", "Application_Error", "Global.asax.cs");
                    }
                }
            }
            // Logging error failed
            catch (Exception ex)
            {
                string s = ex.Message;
            }
        }
Example #6
0
        private void LoadEvent(int EventID, int EventPeriodID)
        {
            try
            {
                BusinessServices.Event objEvent = new BusinessServices.Event();
                DataTable dtEvent = objEvent.GetEvent(EventID, EventPeriodID, UserContext.UserData.OrgID);
                if (dtEvent.Rows.Count > 0)
                {
                    this.txtEventName.Text          = dtEvent.Rows[0]["EventName"].ToString();
                    EventNameCheck                  = dtEvent.Rows[0]["EventName"].ToString();
                    this.txtEventItem.Text          = dtEvent.Rows[0]["EventItem"].ToString();
                    this.txtEventLocation.Text      = dtEvent.Rows[0]["EventLocation"].ToString();
                    this.txtEventProvider.Text      = dtEvent.Rows[0]["EventProvider"].ToString();
                    this.ddlEventType.SelectedValue = dtEvent.Rows[0]["EventType"].ToString();
                    // this.chkstatus.Checked = Boolean.Parse(dtEvent.Rows[0]["RegisterPoint"].ToString());
                    //this.chkallowuser.Checked = Boolean.Parse(dtEvent.Rows[0]["AllowUser"].ToString());
                    this.ddlCPDProfile.SelectedValue = dtEvent.Rows[0]["ProfileID"].ToString();
                    ViewState["EventID"]             = EventID;
                    ViewState["EventPeriodID"]       = EventPeriodID;
                    ViewState["CurrentEventPoints"]  = dtEvent.Rows[0]["Points"].ToString();;
                    // if (Session["Action"] == "Edit")
                    EventFileList();

                    if (this.panPeriod.Visible == true)
                    {
                        if (!dtEvent.Rows[0]["datestart"].Equals(System.DBNull.Value))
                        {
                            DateTime dtStart = (DateTime)dtEvent.Rows[0]["datestart"];
                            this.ddlCurrentDateStartDay.SelectedValue    = dtStart.Day.ToString();
                            this.ddlCurrentDateStartMonth.SelectedValue  = dtStart.Month.ToString();
                            this.ddlCurrentDateStartYear.SelectedValue   = dtStart.Year.ToString();
                            this.ddlCurrentDateStartHour.SelectedValue   = dtStart.Hour.ToString();
                            this.ddlCurrentDateStartMinute.SelectedValue = dtStart.Minute.ToString();
                        }
                        if (!dtEvent.Rows[0]["dateend"].Equals(System.DBNull.Value))
                        {
                            DateTime dtStart = (DateTime)dtEvent.Rows[0]["dateend"];
                            this.ddlCurrentDateEndDay.SelectedValue    = dtStart.Day.ToString();
                            this.ddlCurrentDateEndMonth.SelectedValue  = dtStart.Month.ToString();
                            this.ddlCurrentDateEndYear.SelectedValue   = dtStart.Year.ToString();
                            this.ddlCurrentDateEndHour.SelectedValue   = dtStart.Hour.ToString();
                            this.ddlCurrentDateEndMinute.SelectedValue = dtStart.Minute.ToString();
                        }
                        if (!dtEvent.Rows[0]["Points"].Equals(System.DBNull.Value))
                        {
                            this.txtCurrentPoints.Text = dtEvent.Rows[0]["Points"].ToString();
                        }

                        string strEndOfPeriodAction = dtEvent.Rows[0]["EndOfPeriodAction"].ToString();
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorHandler.ErrorLog el = new ErrorHandler.ErrorLog(ex, ErrorLevel.High, "Usercpdevent.aspx.cs", "LoadEvent", ex.Message);
            }
        }
Example #7
0
        private bool UploadEventFile(int EventPeriodID, bool checkFile)
        {
            int  FileId;
            bool UploadStatus = false;

            if ((UploadFile.PostedFile != null) && (UploadFile.PostedFile.ContentLength > 0))
            {
                BusinessServices.Event objEvent = new BusinessServices.Event();

                int    OrganisationID = UserContext.UserData.OrgID;
                string SaveDir        = Server.MapPath(@"\General") + @"\CPDEvent\" + UserContext.UserData.OrgID.ToString();


                //Check that the directory exists - if it doesn't then create it
                if (!Directory.Exists(SaveDir))
                {
                    Directory.CreateDirectory(SaveDir);
                }

                try
                {
                    HttpFileCollection hfc = Request.Files;
                    for (int i = 0; i < hfc.Count; i++)
                    {
                        HttpPostedFile hpf = hfc[i];
                        if (hpf.ContentLength > 0)
                        {
                            System.IO.FileInfo file  = new System.IO.FileInfo(hpf.FileName);
                            string             fname = file.Name.Remove((file.Name.Length - file.Extension.Length));

                            fname = fname + "~" + DateTime.Now.ToString("ddMMyyyyhhmmss") + file.Extension;
                            hpf.SaveAs(SaveDir + @"\" + fname);
                            objEvent.EventPeriodID = EventPeriodID;
                            objEvent.FileName      = fname;
                            FileId = objEvent.AddEventFile(objEvent);
                        }
                    }
                }
                catch (Exception ex)
                {
                    //log exception to event log
                    ErrorHandler.ErrorLog el = new ErrorHandler.ErrorLog(ex, ErrorLevel.High, "Usercpdevent.aspx.cs", "UploadEventFile", ex.Message);

                    //display friendly message to user
                    lblMessage.Text     = ResourceManager.GetString("UploadFail");
                    lblMessage.CssClass = "WarningMessage";
                }
            }
            else
            {
                lblMessage.Text     = ResourceManager.GetString("NoUploadFile");
                lblMessage.CssClass = "WarningMessage";
            }
            return(UploadStatus);
        }
Example #8
0
 private void StartPagination()
 {
     try
     {
         this.ShowEventPagination(0);
     }
     catch (Exception Ex)
     {
         ErrorHandler.ErrorLog Error = new ErrorHandler.ErrorLog(Ex, ErrorLevel.Medium, "ExportCPDEventReport.aspx.cs", "StartPagination()", "Binding Data to Datagrid");
         throw (Ex);
     }
 }
Example #9
0
        }        //Lesson_OnLoad

        /// <summary>
        /// LessonPage_OnLoad
        /// </summary>
        /// <param name="sessionID">This is the session id that maps to the lesson that is currently loading</param>
        /// <param name="postData">This is the collection of http post data variables</param>
        private void LessonPage_OnLoad(SqlString sessionID, NameValueCollection postData)
        {
            string strToolbookPageID;

            // Verify the necessary post parameters have been supplied
            strToolbookPageID = postData.Get("TBPageID");
            if (strToolbookPageID.Length == 0)
            {
                OutputToToolBook(
                    cm_strReturnCodeCriticalError                                                  // paramater 1 - ReturnCode
                    + cm_strDelimiter + "TBListener Error 1. Missing required parameter: TBPageID" // paramater 2 - Error Message
                    );
                return;
            }

            try
            {
                BusinessServices.Toolbook objToolBook = new BusinessServices.Toolbook();
                if (objToolBook.RecordPageVisited(sessionID, strToolbookPageID))
                {
                    // Normal condition -> tell TB "c_strReturnCodeOK", i.e. it can continue
                    OutputToToolBook(
                        cm_strReturnCodeOK                                              // paramater 1 - ReturnCode
                        + cm_strDelimiter + ""                                          // paramater 2 - Error Message
                        );
                    return;
                }
                else
                {
                    // Error condition
                    OutputToToolBook(
                        cm_strReturnCodeCriticalError                                                     // paramater 1 - ReturnCode
                        + cm_strDelimiter + "TBListener Error 15. " + ResourceManager.GetString("Error2") //"	// paramater 2 - Error Message
                        );
                    return;
                }
            }
            catch (Exception ex)
            {
                // log the error
                ErrorHandler.ErrorLog Error = new ErrorHandler.ErrorLog(ex);

                OutputToToolBook(
                    cm_strReturnCodeCriticalError                               // paramater 1 - ReturnCode
                    + cm_strDelimiter + "TBListener Error 16. Unknown Error"    // paramater 2 - Error Message
                    );
                return;
            }
        }         // LessonPage_OnLoad
Example #10
0
 /// <summary>
 /// Entry point for the Toolbook Listener functionality
 /// No output should be sent to the toolbook except by the appropriate
 /// event handlers for LessonOnLoad etc.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void Page_Load(object sender, System.EventArgs e)
 {
     try
     {
         ProcessEvent();
     }
     catch (Exception Ex)
     {
         // Log The error but dont let it bubble up ( so that html error messages are not displayed in toolbook
         ErrorHandler.ErrorLog Error = new ErrorHandler.ErrorLog(Ex, ErrorLevel.Medium, "ToolBookListener.aspx.cs", "Page_Load", "TBListener Error 0. Unknown Error. Caught");
         OutputToToolBook(
             cm_strReturnCodeCriticalError               // paramater 1 - ReturnCode
             + cm_strDelimiter + "TBListener Error 0."   // paramater 2 - Error Message
             );
         return;
     }
 }
 private void restartService(ServiceController sc)
 {
     try
     {
         if (sc.Status != ServiceControllerStatus.Stopped)
         {
             sc.Stop();
             sc.WaitForStatus(ServiceControllerStatus.Stopped, new TimeSpan(0, 0, 10));
         }
         sc.Start();
         sc.WaitForStatus(ServiceControllerStatus.Running, new TimeSpan(0, 0, 10));
         sc.Refresh();
     }
     catch (Exception ex)
     {
         ErrorHandler.ErrorLog el = new ErrorHandler.ErrorLog(ex, ErrorLevel.High, "Service Control", "Panic button pressed", ex.Message);
     }
 }
        private void setButtonLabel()
        {
            try
            {
                String[]          strArr;
                ServiceController scSendMail = null;

                BusinessServices.AppConfig ac = new BusinessServices.AppConfig();

                DataTable dt = ac.getMailServices();


                foreach (DataRow dr in dt.Rows)
                {
                    strArr = dr.ItemArray[1].ToString().Split(';');

                    if (dr.ItemArray[0].Equals("MailService_SendMail"))
                    {
                        try
                        {
                            scSendMail = new ServiceController(strArr[1], strArr[0]);
                        }
                        catch (Exception e)
                        {
                            btnServiceToggle.Text = "- No Service Permissions -";
                        }
                    }
                }

                if (scSendMail.Status != ServiceControllerStatus.Stopped)
                {
                    btnServiceToggle.Text = ResourceManager.GetString("btnStopServices");
                }
                else
                {
                    btnServiceToggle.Text = ResourceManager.GetString("btnStartServices");
                }
            }
            catch (Exception e)
            {
                ErrorHandler.ErrorLog el = new ErrorHandler.ErrorLog(e, ErrorLevel.High, "Service Control", "No Permissions to access", "Please use subinacl.exe to grant permissions");
            }
        }
Example #13
0
        private void DisplayEvents(DataTable dtEvents)
        {
            try
            {
                lblMessage.Text = String.Empty;
                panCPD.Visible  = (dtEvents.Rows.Count > 0);

                if (dtEvents.Rows.Count == 0)
                {
                    lblMessage.Text     = ResourceManager.GetString("NoProfiles");
                    lblMessage.CssClass = "WarningMessage";
                }
            }
            catch (Exception Ex)
            {
                ErrorHandler.ErrorLog Error = new ErrorHandler.ErrorLog(Ex, ErrorLevel.Medium, "cpdevent.aspx.cs", "DisplayEvents", "GetFilename");
                throw (Ex);
            }
        }
Example #14
0
        private DataGridColumn CreateBoundColumn(DataColumn c)
        {
            try
            {
                //string strUserID = UserContext.UserID.ToString();
                string strUserID  = UserId.ToString();
                string strColName = c.ColumnName;



                BoundColumn col = new BoundColumn();

                col.DataField  = strColName;
                col.HeaderText = strColName;
                //col.FooterText ="test<BR>test" ;

                ///*
                //if (strColName.Length < 3) // Need to perform this check because if the column name happens to be 2 characters then will cause a system error - if < 2 char then can assume that not an "ID~" column
                //{
                //    col.DataNavigateUrlField = c.ColumnName + "ID~";
                //    col.DataNavigateUrlFormatString = "/Reporting/Individual/CPDHistory.aspx?ProfileID={0}&ModuleID=";
                //}
                //else if (strColName.Substring(strColName.Length - 3, 3) != "ID~")
                //{
                //    // if it is the id column (determined by the last 3 idiotic characters) then hideit and also dont set the url stuff
                //    col.DataNavigateUrlField = c.ColumnName + "ID~";
                //    col.DataNavigateUrlFormatString = "/Reporting/Individual/CPDHistory.aspx?ProfileID={0}&ModuleID=";
                //}
                //else
                ////
                if (strColName.Contains("ID~"))
                {
                    col.Visible = false;
                }
                return(col);
            }
            catch (Exception Ex)
            {
                ErrorHandler.ErrorLog Error = new ErrorHandler.ErrorLog(Ex, ErrorLevel.Medium, "ExportCPDProfileReport.aspx.cs", "CreateBoundColumn()", "Binding Data to Datagrid");
                throw (Ex);
            }
        }
Example #15
0
        private void SetEventPaginationPanel(int pageSize, int totalRecordCount, int currentPageIndex)
        {
            try
            {
                //1. Get pagination info
                int      intPageSize;
                int      intTotalRecordCount;
                int      intPageCount;
                int      intCurrentPageStart;
                int      intCurrentPageEnd;
                ListItem objItem;

                intPageSize         = pageSize;
                intTotalRecordCount = totalRecordCount;
                intPageCount        = ((int)(intTotalRecordCount - 1) / intPageSize) + 1;

                //Page start record number
                if (intTotalRecordCount != 0)
                {
                    intCurrentPageStart = intPageSize * currentPageIndex + 1;
                }
                else
                {
                    intCurrentPageStart = 0;
                }
                //Page end record number
                if (currentPageIndex < intPageCount - 1)
                {
                    intCurrentPageEnd = intPageSize * (currentPageIndex + 1);
                }
                //Last page, the page record count is the remaining records
                else
                {
                    intCurrentPageEnd = intTotalRecordCount;
                }
            }
            catch (Exception Ex)
            {
                ErrorHandler.ErrorLog Error = new ErrorHandler.ErrorLog(Ex, ErrorLevel.Medium, "ExportCPDEventReport.aspx.cs", "SetEventPaginationPanel()", "Binding Data to Datagrid");
                throw (Ex);
            }
        }
Example #16
0
        //delete event
        protected void gvFile_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            try
            {
                GridViewRow row                = (GridViewRow)gvFile.Rows[e.RowIndex];
                Label       lbldeleteid        = (Label)row.FindControl("lblImgId");
                Label       lblDeleteImageName = (Label)row.FindControl("lblImageName");


                BusinessServices.Event objProfile = new BusinessServices.Event();
                objProfile.FileID = int.Parse(lbldeleteid.Text);
                objProfile.DeleteEventFile(objProfile);

                FileDeleteFromFolder(lblDeleteImageName.Text);
                EventFileList();
            }
            catch (Exception ex)
            {
                ErrorHandler.ErrorLog el = new ErrorHandler.ErrorLog(ex, ErrorLevel.High, "Usercpdevent.aspx.cs", "gvFile_RowDeleting", ex.Message);
            }
        }
Example #17
0
        private void CPDBindGrid()
        {
            try
            {
                DataTable dtEvents = GetEvent();


                int PageSize = ApplicationSettings.PageSize;
                this.dgrCPD.PageSize = PageSize;
                if (dtEvents.Rows.Count > 0)
                {
                    dgrCPD.DataSource = dtEvents;
                    dgrCPD.DataBind();
                    DisplayEvents(dtEvents);
                }
            }
            catch (Exception Ex)
            {
                ErrorHandler.ErrorLog Error = new ErrorHandler.ErrorLog(Ex, ErrorLevel.Medium, "cpdevent.aspx.cs", "CPDBindGrid", "GetFilename");
                throw (Ex);
            }
        }
Example #18
0
        private DataSet GetEventPaginationData()
        {
            try
            {
                Event   objEvent  = new Event();
                DataSet odtReport = new DataSet();

                odtReport = objEvent.GetUserEventReportNew(UserContext.UserID, UserContext.UserData.OrgID);
                if (odtReport.Tables[0].Rows.Count == 0)
                {
                    this.lblEventError.Text    += "No results found.";
                    this.lblEventError.CssClass = "FeedbackMessage";
                }
                return(odtReport);
            }

            catch (Exception Ex)
            {
                ErrorHandler.ErrorLog Error = new ErrorHandler.ErrorLog(Ex, ErrorLevel.Medium, "IndividualReport.aspx.cs", "GetEventPaginationData()", "Binding Data to Datagrid");
                throw (Ex);
            }
        }
Example #19
0
        // update event
        protected void gvFile_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            try
            {
                BusinessServices.Event objProfile  = new BusinessServices.Event();
                FileUpload             FileUpload1 = (FileUpload)gvFile.Rows[e.RowIndex].FindControl("FileUpload1");
                string path = Server.MapPath(@"\General") + @"\CPDEvent\" + UserContext.UserData.OrgID.ToString() + @"\";

                int       OrganisationID = UserContext.UserData.OrgID;
                DataTable dt             = objProfile.CheckFileName(OrganisationID, FileUpload1.FileName);
                int       CheckRowCount  = dt.Rows.Count;

                if (CheckRowCount != 0)
                {
                    lblMessage.Text     = ResourceManager.GetString("FileExists");
                    lblMessage.CssClass = "WarningMessage";
                    return;
                }
                string FileID = gvFile.DataKeys[e.RowIndex].Value.ToString();

                if (FileUpload1.HasFile)
                {
                    FileUpload1.SaveAs(path + FileUpload1.FileName);
                }

                objProfile.FileID   = int.Parse(FileID);
                objProfile.FileName = FileUpload1.FileName;
                objProfile.UpdateEventFile(objProfile);

                gvFile.EditIndex = -1;
                EventFileList();
            }
            catch (Exception ex)
            {
                ErrorHandler.ErrorLog el = new ErrorHandler.ErrorLog(ex, ErrorLevel.High, "Usercpdevent.aspx.cs", "gvFile_RowUpdating", ex.Message);
            }
        }
Example #20
0
        /// <summary>
        /// This handles the bulk of the logic associated with a toolbook event being fired
        /// </summary>
        private void ProcessEvent()
        {
            // TODO: SQL Injection and all other attacks must be dealt with

            // Make sure nothing is sent to the browser
            // Assumption: Buffering is on (it should be on as the default in asp.net)

            // Get the Action ID and convert it into an int
            int    intActionID = 0;
            string strActionID = "";

            if (Request.Form["ActionID"] != null)
            {
                strActionID = Request.Form["ActionID"].Trim();
            }
            else
            {
                // There is no Action ID !!! -> toolbook should imediatly close
                // Log the error and then send toolbook a message to close
                Exception             ex    = new Exception("TBListener Error 1. The action id was missing. 'ActionID' is a manditory field and must be one of the agreed constant");
                ErrorHandler.ErrorLog Error = new ErrorHandler.ErrorLog(ex, ErrorLevel.Medium, "ToolBookListener.aspx.cs", "Page_Load", "Check ActionID isn't missing");

                // Send toolbook a message to close
                OutputToToolBook(
                    cm_strReturnCodeCriticalError
                    + cm_strDelimiter
                    + "TBListener Error 1. The action id was missing. 'ActionID' is a manditory field and must be one of the agreaded constant"
                    + cm_strDelimiter
                    + m_strRootURL + cm_strErrorLocation
                    + "?errnum=1"
                    );
                return;
            }

            // Check that Action ID is numeric
            if (IsInteger(strActionID))
            {
                // Convert the Action ID to an integer
                intActionID = Convert.ToInt32(strActionID);
            }
            else
            {
                // The action id must be an integer -> toolbook should close.
                // Log the error then send toolbook a message to close
                Exception             ex    = new Exception("TBListener Error 2. The action id was malformed. 'ActionID' is a manditory field");
                ErrorHandler.ErrorLog Error = new ErrorHandler.ErrorLog(ex, ErrorLevel.Medium, "ToolBookListener.aspx.cs", "Page_Load", "Checking ActionID Is Numeric");

                // Send toolbook a message to close
                OutputToToolBook(
                    cm_strReturnCodeCriticalError
                    + cm_strDelimiter
                    + "TBListener Error 2. The action id must be a numeric value."
                    + cm_strDelimiter
                    + m_strRootURL + cm_strErrorLocation
                    + "?errnum=2"
                    );
                return;
            }

            // Get the session ID from the form object
            if (Request.Form["SessionData"] != null)
            {
                strSessionID = Request.Form["SessionData"].Trim();
            }
            else
            {
                // There is no Session Data !!! -> toolbook should imediatly close
                // Log the error and then send toolbook a message to close
                Exception             ex    = new Exception("TBListener Error 3. The Session Data was missing. 'SessionData' is a manditory field");
                ErrorHandler.ErrorLog Error = new ErrorHandler.ErrorLog(ex, ErrorLevel.Medium, "ToolBookListener.aspx.cs", "Page_Load", "Checking SessionData isn't missing");
                OutputToToolBook(
                    cm_strReturnCodeCriticalError
                    + cm_strDelimiter
                    + "TBListener Error 3. The Session Data was missing. 'SessionData' is a manditory field"
                    + cm_strDelimiter
                    + m_strRootURL + cm_strErrorLocation
                    + "?errnum=3"
                    );
                return;
            }

            // Act on the action id
            switch (intActionID)
            {
            case cm_intEventLessonOnLoad:
                Lesson_OnLoad(strSessionID, Request.Form);
                break;

            case cm_intEventLessonPageOnLoad:
                LessonPage_OnLoad(strSessionID, Request.Form);
                break;

            case cm_intEventLessonOnExit:
                Lesson_OnExit(strSessionID, Request.Form);
                break;

            case cm_intEventQuizOnLoad:
                Quiz_OnLoad(strSessionID, Request.Form);
                break;

            case cm_intEventQuizOnScore:
                Quiz_OnScore(strSessionID, Request.Form);
                break;

            default:
                // The ActionID supplied by toolbook does not corespond to a known event
                // Log this as an error and instruct toolbook to quit
                Exception             Ex    = new Exception("TBListener Error 4. Unknown ActionID");
                ErrorHandler.ErrorLog Error = new ErrorHandler.ErrorLog(Ex, ErrorLevel.Medium, "ToolBookListener.aspx.cs", "Page_Load", "Act on the action id");

                OutputToToolBook(
                    cm_strReturnCodeCriticalError                                                               // paramater 1 - ReturnCode
                    + cm_strDelimiter + "TBListener Error 4. Unknown ActionID"                                  // paramater 2 - Error Message
                    );
                break;
            }            //switch
        }
Example #21
0
        /// <summary>
        /// This even is trigged as the grid renders each row.
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        private void dgrResults_ItemDataBound(object source, DataGridItemEventArgs e)
        {
            // Columns holding various fields.
            //int c_intColumnCourse = 0;
            int c_intColumnUnit   = 0;
            int c_intColumnModule = 1;

            int c_intColumnPassMark = 3;
            int c_intColumnAvgMark  = 4;

            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.SelectedItem || e.Item.ItemType == ListItemType.EditItem)
            {
                Table tblPassMark;                              // Table containing the Graphical Mark
                Table tblAvgMark;                               // Table containing the Graphical Mark
                Label lblPassMark;                              // Label containing the Textual Pass Mark
                Label lblAvgMark;                               // Label containing the Textual Mark

                int intQuizPassMark;
                int intQuizAvgScore;

                TableCellCollection tclCells = e.Item.Cells;

                // Show and hide the Module name
                if (tclCells[c_intColumnModule].Text != strModule)
                {
                    // Capture the new Module name
                    strModule = tclCells[c_intColumnModule].Text;
                    tclCells[c_intColumnModule].CssClass = "TableRow2";
                }
                else
                {
                    // Hide the existing Module name
                    tclCells[c_intColumnModule].Text     = "";
                    tclCells[c_intColumnModule].CssClass = "TableRow1";
                }


                // Show and hide the Unit name
                if (tclCells[c_intColumnUnit].Text != strUnit)
                {
                    // Capture the new Unit name
                    strUnit = tclCells[c_intColumnUnit].Text;
                    tclCells[c_intColumnUnit].CssClass = "TableRow2";
                    // Reshow the module name because we have just redraw the unit name
                    tclCells[c_intColumnModule].CssClass = "TableRow2";
                    tclCells[c_intColumnModule].Text     = strModule;
                }
                else
                {
                    // Hide the existing Unit name
                    tclCells[c_intColumnUnit].Text     = "";
                    tclCells[c_intColumnUnit].CssClass = "TableRow1";
                }


                try
                {
                    //Get the table which is in the fourth cell
                    tblPassMark = (Table)e.Item.Cells[c_intColumnPassMark].Controls[1];
                    tblAvgMark  = (Table)e.Item.Cells[c_intColumnAvgMark].Controls[1];

                    // Get the label that resides in it
                    lblPassMark = (Label)tblPassMark.Rows[0].Cells[0].Controls[0];
                    lblAvgMark  = (Label)tblAvgMark.Rows[0].Cells[0].Controls[0];
                    // Get the current DataRow from e
                    DataRowView drwQuizAttempt = (DataRowView)e.Item.DataItem;


                    // Draw the passmark graphically
                    if (drwQuizAttempt["QuizPassMark"] == DBNull.Value)
                    {
                        intQuizAvgScore = 0;
                        lblAvgMark.Text = "N/A";
                        tblAvgMark.Rows[0].Cells[0].Attributes.Add("class", "BarChartNA");
                        tblAvgMark.Rows[0].Cells[1].Visible = false;
                        //tblPassMark.Visible=false;
                    }
                    else
                    {
                        // Get the Quiz pass mark from the QuizPassMark column
                        intQuizPassMark = Int32.Parse(drwQuizAttempt["QuizPassMark"].ToString());

                        // If the passmark is to be displayed as an expanding column use this line and add a colour style.
                        //tblPassMark.Rows[0].Cells[0].Attributes.Add ("Width",intQuizPassMark.ToString() +"%");
                        // If the passmark is to be displayed as a static field set the width to a fixed % - 5% is good
                        tblPassMark.Rows[0].Cells[0].Attributes.Add("Width", "5%");

                        // Column one is the barchar background
                        lblPassMark.Text = intQuizPassMark.ToString() + "%";
                    }

                    // Draw the average score graphically
                    if (drwQuizAttempt["AvgScore"] == DBNull.Value)
                    {
                        intQuizAvgScore = 0;
                        lblAvgMark.Text = "N/A";
                        tblAvgMark.Rows[0].Cells[0].Attributes.Add("class", "BarChartNA");
                        tblAvgMark.Rows[0].Cells[1].Visible = false;
                        //tblAvgMark.Visible=false;
                    }
                    else
                    {
                        // Get the Average Quiz Pass Mark from the QuizScore column
                        intQuizPassMark = Int32.Parse(drwQuizAttempt["QuizPassMark"].ToString());
                        // Get the Average Quiz Score from the QuizScore column
                        intQuizAvgScore = Int32.Parse(drwQuizAttempt["AvgScore"].ToString());

                        if (intQuizAvgScore < 5)
                        {
                            tblAvgMark.Rows[0].Cells[0].Attributes.Add("Width", "5%");
                        }
                        else
                        {
                            // Get the Quiz Score from the QuizScore column
                            intQuizAvgScore = Int32.Parse(drwQuizAttempt["AvgScore"].ToString());
                            // The width of the TD is what gives the barchart like effect.
                            tblAvgMark.Rows[0].Cells[0].Attributes.Add("Width", intQuizAvgScore.ToString() + "%");
                            if (intQuizAvgScore >= intQuizPassMark)
                            {
                                // green for pass
                                tblAvgMark.Rows[0].Cells[0].Attributes.Add("class", "BarChartPass");
                            }
                            else
                            {
                                // red for fail
                                tblAvgMark.Rows[0].Cells[0].Attributes.Add("class", "BarChartFail");
                            }
                            // if the score was 100% then there is no need to have a spacer filling out the rest of the column
                            if (intQuizAvgScore == 100)
                            {
                                tblAvgMark.Rows[0].Cells[1].Visible = false;
                            }
                            // Column one is the barchar background
                            lblAvgMark.Text = intQuizAvgScore.ToString() + "%";
                        }
                    }
                }
                catch (Exception Ex)
                {
                    ErrorLog Error = new ErrorHandler.ErrorLog(Ex, ErrorLevel.Medium, "TrendReport.aspx", "dgrQuizHistory_ItemDataBound", "Displaying Quiz Score");
                    throw (Ex);
                }
            }
        }
Example #22
0
        void dgrEvent_ItemDataBound(object sender, DataGridItemEventArgs e)
        {
            try
            {
                Label hl = new Label();
                // Colmns in the datagrid for specific values

                //int c_intColumnCourse = 0;
                if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
                {
                    TableCellCollection tclCells = e.Item.Cells;

                    if (tclCells[0].Text != strCourse)
                    {
                        // Capture the new Course name
                        strCourse            = tclCells[0].Text;
                        tclCells[0].CssClass = "tablerow2Selected";
                    }
                    else
                    {
                        // Hide the existing Course name
                        tclCells[0].Text = "";
                    }
                }
                if (e.Item.ItemType == ListItemType.Footer)
                {
                    Profile pf       = new Profile();
                    DataSet ds       = new DataSet();
                    Event   objEvent = new Event();

                    //ds = objEvent.GetUserEventReportNew(UserContext.UserID, UserContext.UserData.OrgID);   // report data
                    ds = objEvent.GetUserEventReportNew(UserId, OrganisationId);   // report data
                    //ds = objEvent.GetUserEventReportNew(1381, 2);
                    DataRow dr1 = ds.Tables[1].Rows[0];

                    e.Item.Cells[3].Text = ResourceManager.GetString("totals") + ":<BR><B>" + ResourceManager.GetString("shortfall") + ":</B>";

                    // add columns as required for the profiles & points
                    int    colCount = ds.Tables[1].Columns.Count;
                    string strColName;

                    if (colCount > 1)// user has cpd access?
                    {
                        int j = 6;

                        for (int i = 1; i < colCount - 1; i += 3)// 0index
                        {
                            bool addHl = false;
                            strColName = ds.Tables[1].Columns[i].ColumnName;
                            if (strColName.Length < 3)
                            {
                                addHl = true;
                            }
                            else if (strColName.Substring(strColName.Length - 3, 3) != "ID~")
                            {
                                addHl = true;
                            }

                            if (addHl)
                            {
                                hl      = new Label();
                                hl.Text = dr1[i] + "<BR><B>" + dr1[i + 2] + "</B>";
                                e.Item.Cells[j].Controls.Add(hl);
                                j += 2;
                            }
                        }
                    }// end if
                }
            }
            catch (Exception Ex)
            {
                ErrorHandler.ErrorLog Error = new ErrorHandler.ErrorLog(Ex, ErrorLevel.Medium, "ExportCPDEventReport.aspx.cs", "dgrEvent_ItemDataBound", "Binding Data to Datagrid");
                throw (Ex);
            }
        }
Example #23
0
        protected void btnSaveEvent_Click(object sender, System.EventArgs e)
        {
            try
            {
                //this.cvCurrentPoints.Validate();
                this.cvCurrentDate.Validate();


                int EventID;

                int EventPeriodID;
                try
                {
                    EventID = int.Parse(Session["EventID"].ToString());
                }
                catch
                {
                    EventID = -1;
                }
                try
                {
                    EventPeriodID = int.Parse(Session["EventPeriodID"].ToString());
                }
                catch
                {
                    EventPeriodID = -1;
                }
                if (Session["Action"].ToString() == "Add")
                {
                    EventID       = -1;
                    EventPeriodID = -1;
                }
                if (!this.IsValid && (EventID < 0))
                {
                    return;
                }
                else if (!this.IsValid)
                {
                    return;
                }

                this.lblNoPeriod.Text = String.Empty;
                BusinessServices.Event objEvent = new BusinessServices.Event();
                objEvent = GetEventValues();

                int    OrganisationID = UserContext.UserData.OrgID;
                string ProfileName    = this.txtEventName.Text;

                DataTable dtEventName = objEvent.CheckUserEventName(objEvent.EventName, OrganisationID, int.Parse(ddlCPDProfile.SelectedValue), EventPeriodID, UserContext.UserID);
                //if (dtProfileName.Rows.Count > 0 && (ProfileNameCheck != ProfileName))
                if (dtEventName.Rows.Count > 0)
                {
                    this.lblMessage.Text    += ResourceManager.GetString("EventExists");
                    this.lblMessage.CssClass = "WarningMessage";
                    return;
                }

                int  CheckRowCount     = 0;
                bool flagCanUpload     = true;
                HttpFileCollection hfc = Request.Files;



                //for (int i = 0; i < hfc.Count; i++)
                //{
                //    HttpPostedFile hpf = hfc[i];
                //    if (hpf.FileName != "")
                //    {
                //        System.IO.FileInfo file = new System.IO.FileInfo(hpf.FileName);
                //        string fname = file.Name.Remove((file.Name.Length - file.Extension.Length));
                //        fname = fname + "_" + DateTime.Now.ToString("dd-MM-yyyy-hh:mm:ss") + file.Extension;


                //        if (hpf.ContentLength > 0)
                //        {
                //            DataTable dt = objEvent.CheckFileName(OrganisationID, fname);
                //            CheckRowCount = dt.Rows.Count;
                //            if (CheckRowCount != 0)
                //            {
                //                // File with this name already exists for this organisation
                //                flagCanUpload = false;

                //                lblMessage.Text = ResourceManager.GetString("FileExists");
                //                lblMessage.CssClass = "WarningMessage";
                //                return;
                //            }
                //        }
                //    }
                //}

                if (EventID > 0) //Existing Event - update
                {
                    if (flagCanUpload)
                    {
                        objEvent.UpdateUserEvent(objEvent);
                        // EventPeriodID = objProfile.GetEventPeriodID(EventID);
                        Session["EventPeriodID"] = EventPeriodID;
                        UploadEventFile(EventPeriodID, true);
                        // objEvent.UpdateEventPeriodAccess(OrganisationID, EventPeriodID, objEvent.EventID);
                        panPeriod.Visible = true;
                        InitialisePage(EventID, EventPeriodID);
                        LoadEvent(EventID, EventPeriodID);
                        this.lblMessage.Text    += ResourceManager.GetString("SaveSuccess");
                        this.lblMessage.CssClass = "SuccessMessage";
                    }
                }
                else // New Event - Add
                {
                    if (flagCanUpload)
                    {
                        EventID       = objEvent.AddEvent(objEvent);
                        EventPeriodID = objEvent.EventPeriodID;

                        UploadEventFile(EventPeriodID, true);

                        // Assign the new values to session variables
                        Session["EventPeriodID"] = EventPeriodID;
                        Session["EventID"]       = EventID;

                        // Initialize all units and users granted access to 0
                        //objEvent.InitialiseEventPeriodAccess(OrganisationID, objEvent.EventID, EventPeriodID);

                        panPeriod.Visible = true;
                        InitialisePage(EventID, EventPeriodID);
                        LoadEvent(EventID, EventPeriodID);

                        this.lblMessage.Text    += ResourceManager.GetString("SaveSuccess");
                        this.lblMessage.CssClass = "SuccessMessage";
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorHandler.ErrorLog el = new ErrorHandler.ErrorLog(ex, ErrorLevel.High, "Usercpdevent.aspx.cs", "btnSaveEvent_Click", ex.Message);
            }
        }
Example #24
0
        } //Page_Load

        private void dgrResults_ItemDataBound(object sender, DataGridItemEventArgs e)
        {
            try
            {
                // Colmns in the datagrid for specific values
                int   c_intColumnCourse     = 0;
                int   c_intColumnHyperlink  = 1;
                int   c_intColumnQuizStatus = 3;
                int   c_intColumnModule     = 6;
                Label hl = new Label();

                if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
                {
                    // Table cell collection of all cells
                    TableCellCollection tclCells = e.Item.Cells;

                    // Show and hide the Course name
                    if (tclCells[c_intColumnCourse].Text != strCourse)
                    {
                        // Capture the new Course name
                        strCourse = tclCells[c_intColumnCourse].Text;
                        tclCells[c_intColumnCourse].CssClass = "tablerow2Selected";
                    }
                    else
                    {
                        // Hide the existing Course name
                        tclCells[c_intColumnCourse].Text     = "";
                        tclCells[c_intColumnCourse].CssClass = "tablerow1";
                    }

                    // Adjust the Hyperlink for rows that dont have a mark.
                    if (tclCells[c_intColumnQuizStatus].Text == "Not Started")
                    {
                        tclCells[c_intColumnHyperlink].Text = tclCells[c_intColumnModule].Text;
                    }


                    //for (int i = 8; i < tclCells.Count; i++)// 8 onwards are the auto generated columns in the grid
                    //{
                    //    hl = (Label)tclCells[i].Controls[0];// get the hyperlink
                    //    tclCells[i].Controls.Remove(tclCells[i].Controls[0]);

                    //    // if its a hyperlink colum or if there is history for the module
                    //    if (hl.Text != "" && hl.Text != "0")
                    //    {
                    //        if (hl.Text == "-1")
                    //        {
                    //            //tclCells[i].Text="0";
                    //            hl.Text = "0";

                    //        }

                    //        hl.NavigateUrl += tclCells[c_intColumnModule + 1].Text;
                    //        tclCells[i].Controls.Add(hl);
                    //    }
                    //    else // id column or no points  & no history
                    //    {
                    //        tclCells[i].Text = "0";
                    //    }
                    //}
                }
                if (e.Item.ItemType == ListItemType.Footer)
                {
                    Profile  pf = new Profile();
                    DataView dt = new DataView();

                    //dt = pf.GetTotalCurrentPointsForProfile(UserContext.UserID);
                    dt = pf.GetTotalCurrentPointsForProfile(UserId);
                    DataRow dr1 = dt.Table.Rows[0];

                    // add columns as required for the profiles & points
                    int    colCount = dt.Table.Columns.Count;
                    string strColName;

                    if (colCount > 1)// user has cpd access?
                    {
                        e.Item.Cells[5].Text = ResourceManager.GetString("totals") + ":<BR><B>" + ResourceManager.GetString("shortfall") + ":</B>";
                        int j = 8;

                        for (int i = 1; i < colCount - 1; i += 3)// 0index
                        {
                            bool addHl = false;
                            strColName = dt.Table.Columns[i].ColumnName;
                            if (strColName.Length < 3)
                            {
                                addHl = true;
                            }
                            else if (strColName.Substring(strColName.Length - 3, 3) != "ID~")
                            {
                                addHl = true;
                            }

                            if (addHl)
                            {
                                Label Ll = new Label();
                                //hl.NavigateUrl = "/Reporting/Individual/CPDHistory.aspx?ProfileID=" + dr1[i + 1];
                                Ll.Text = dr1[i] + "<BR><B>" + dr1[i + 2] + "</B>";
                                e.Item.Cells[j].Controls.Add(Ll);
                                j += 2;
                            }
                        }
                    }// end if
                }
            }
            catch (Exception Ex)
            {
                ErrorHandler.ErrorLog Error = new ErrorHandler.ErrorLog(Ex, ErrorLevel.Medium, "ExportCPDProfileReport.aspx.cs", "dgrResults_ItemDataBound", "Binding Data to Datagrid");
                throw (Ex);
            }
        } // dgrResults_ItemDataBound
Example #25
0
        /// <summary>
        /// Sets the pagination panel.
        /// </summary>
        /// <param name="pageSize"></param>
        /// <param name="totalRecordCount"></param>
        /// <param name="currentPageIndex"></param>
        private void SetPaginationPanel(int pageSize, int totalRecordCount, int currentPageIndex)
        {
            try
            {
                //1. Get pagination info
                int      intPageSize;
                int      intTotalRecordCount;
                int      intPageCount;
                int      intCurrentPageStart;
                int      intCurrentPageEnd;
                ListItem objItem;

                intPageSize         = pageSize;
                intTotalRecordCount = totalRecordCount;
                intPageCount        = ((int)(intTotalRecordCount - 1) / intPageSize) + 1;

                //Page start record number
                if (intTotalRecordCount != 0)
                {
                    intCurrentPageStart = intPageSize * currentPageIndex + 1;
                }
                else
                {
                    intCurrentPageStart = 0;
                }
                //Page end record number
                if (currentPageIndex < intPageCount - 1)
                {
                    intCurrentPageEnd = intPageSize * (currentPageIndex + 1);
                }
                //Last page, the page record count is the remaining records
                else
                {
                    intCurrentPageEnd = intTotalRecordCount;
                }
                //2. Set  pagination
                //2.1 Set dropdown page selector
                this.cboPage.Items.Clear();
                for (int i = 1; i <= intPageCount; i++)
                {
                    objItem = new ListItem(i.ToString());
                    if (i == currentPageIndex + 1)
                    {
                        objItem.Selected = true;
                    }
                    this.cboPage.Items.Add(objItem);
                }

                //2.2 Set Page numbers
                this.lblPageCount.Text = intPageCount.ToString();
                this.lblCurrentPageRecordCount.Text = intCurrentPageStart.ToString() + " - " + intCurrentPageEnd.ToString();
                this.lblTotalRecordCount.Text       = intTotalRecordCount.ToString();

                //2.3 Disable prev, next buttons
                this.btnPrev.Enabled = true;
                this.btnNext.Enabled = true;
                //First Page
                if (currentPageIndex == 0)
                {
                    this.btnPrev.Enabled = false;
                }
                //Last Page
                if (currentPageIndex == intPageCount - 1)
                {
                    this.btnNext.Enabled = false;
                }
            }
            catch (Exception Ex)
            {
                ErrorHandler.ErrorLog Error = new ErrorHandler.ErrorLog(Ex, ErrorLevel.Medium, "ExportCPDProfileReport.aspx.cs", "SetPaginationPanel()", "Binding Data to Datagrid");
                throw (Ex);
            }
        }
Example #26
0
        //override protected void OnInit(EventArgs e)
        //{
        //    //
        //    // CODEGEN: This call is required by the ASP.NET Web Form Designer.
        //    //
        //    InitializeComponent();
        //    base.OnInit(e);

        //}
        //private void InitializeComponent()
        //{
        //    this.txtCurrentPoints.TextChanged +=new EventHandler(txtCurrentPoints_TextChanged);
        //}

        //void txtCurrentPoints_TextChanged(object sender, EventArgs e)
        //{
        //    if (int.Parse(txtCurrentPoints.Text) <= int.Parse(lblavailablepoint.Text))
        //    {

        //    }
        //    else
        //    {
        //        txtCurrentPoints.Text = "0";
        //    }

        //}
        protected void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                BusinessServices.Organisation objOrganisation = new BusinessServices.Organisation();
                if (objOrganisation.GetOrganisationCPDAccess(UserContext.UserData.OrgID))
                {
                    pagTitle.InnerText = ResourceManager.GetString("pagTitle");

                    int EventID;
                    int EventPeriodID;
                    //int ProfileID;
                    //string EventName;
                    //int EventType;

                    try
                    {
                        EventID = int.Parse(Session["EventID"].ToString());
                    }
                    catch
                    {
                        EventID = -1;
                    }
                    try
                    {
                        EventPeriodID = int.Parse(Session["EventPeriodID"].ToString());
                    }
                    catch
                    {
                        EventPeriodID = -1;
                    }

                    this.InitialisePage(EventID, EventPeriodID);

                    if (!Page.IsPostBack)
                    {
                        Session["PageIndex"] = 0;
                        PopulateDropdown(this.ddlCurrentDateStartDay, this.ddlCurrentDateStartMonth, this.ddlCurrentDateStartYear);
                        PopulateDropdown(this.ddlCurrentDateEndDay, this.ddlCurrentDateEndMonth, this.ddlCurrentDateEndYear);

                        this.ddlCurrentDateStartDay.SelectedValue   = System.DateTime.Today.Day.ToString();
                        this.ddlCurrentDateStartMonth.SelectedValue = System.DateTime.Today.Month.ToString();
                        this.ddlCurrentDateStartYear.SelectedValue  = System.DateTime.Today.Year.ToString();


                        this.ddlCurrentDateEndDay.SelectedValue   = System.DateTime.Today.Day.ToString();
                        this.ddlCurrentDateEndMonth.SelectedValue = System.DateTime.Today.Month.ToString();
                        this.ddlCurrentDateEndYear.SelectedValue  = System.DateTime.Today.Year.ToString();


                        SetSortOrder("LastName");
                        BindCPDProfile();
                        BindEventType();

                        if (Session["Action"].ToString() == "Add")
                        {
                            EventID       = -1;
                            EventPeriodID = -1;
                        }
                        //By default "No Action" radiobutton checked if a new Event
                        if (EventID > 0) //Existing Event
                        {
                            LoadEvent(EventID, EventPeriodID);
                        }

                        var hours   = Enumerable.Range(0, 24).Select(i => i.ToString());
                        var minutes = Enumerable.Range(0, 60).Select(i => i.ToString());
                        ddlCurrentDateStartHour.DataSource = hours;
                        ddlCurrentDateStartHour.DataBind();
                        ddlCurrentDateStartMinute.DataSource = minutes;
                        ddlCurrentDateStartMinute.DataBind();

                        ddlCurrentDateEndHour.DataSource = hours;
                        ddlCurrentDateEndHour.DataBind();
                        ddlCurrentDateEndMinute.DataSource = minutes;
                        ddlCurrentDateEndMinute.DataBind();
                    }
                }
                else// dosnt have access to CPD
                {
                    pagTitle.InnerText     = ResourceManager.GetString("pagTitle");
                    this.lblPageTitle.Text = ResourceManager.GetString("lblPageTitle");
                    panCPD.Visible         = false;
                    lblMessage.Text        = ResourceManager.GetString("NoAccess");
                    lblMessage.CssClass    = "WarningMessage";
                }
            }
            catch (Exception ex)
            {
                //log exception to event log
                ErrorHandler.ErrorLog el = new ErrorHandler.ErrorLog(ex, ErrorLevel.High, "Usercpdevent.aspx.cs", "Page_Load", ex.Message);
            }
        }
Example #27
0
        /// <summary>
        /// Quiz End event
        /// </summary>
        /// <remarks>
        /// This event fires when a student clicks the “Submit answers” button on the last page. The event will
        ///		.Score: Calculate the score (Question number with correct answer/Total question number * 100)
        ///		.Duration: Calculate the duration of the testing.
        ///		.QuizQuestionAudit: Record quiz question audit.
        ///		.QuizAnswerAudit: Record quiz answer audit
        /// </remarks>
        public void Quiz_End()
        {
            //certemail(956, 42, 0);
            if (!PageContext.Current.IsPreviewMode)
            {
                try
                {
                    BusinessServices.Toolbook objToolbook = new BusinessServices.Toolbook();
                    NameValueCollection       nvcAnswers  = CurrentQuizContext.Answers;
                    DataTable endQuizInfo;
                    int       intUserID;
                    int       intQuizID;
                    int       intPassMark;
                    int       intUnitID;
                    int       intModuleID;
                    int       intQuizFrequency;
                    int       intOldCourseStatus;
                    int       intNewCourseStatus;
                    int       intNewQuizStatus;
                    int       intCourseID;
                    DateTime  dtmQuizCompletionDate;

                    foreach (string strKey in nvcAnswers.AllKeys)
                    {
                        objToolbook.CreateQuizQuestionAudit(PageContext.Current.SessionID, strKey);
                        objToolbook.CreateQuizAnswerAudit(PageContext.Current.SessionID, strKey, Convert.ToInt32(nvcAnswers[strKey]));
                    }

                    int      intScore    = objToolbook.GetQuizScore(PageContext.Current.SessionID);
                    TimeSpan objTimeSpan = DateTime.Now.Subtract(PageContext.Current.StartTime);

                    //objToolbook.EndQuizSession(PageContext.Current.SessionID,objTimeSpan.Seconds,intScore);

                    endQuizInfo = objToolbook.BeforeQuizEnd(PageContext.Current.SessionID, objTimeSpan.Seconds, intScore);

                    DataRow tmpRow = endQuizInfo.Rows[0];
                    intUserID        = Int32.Parse(tmpRow["UserID"].ToString());
                    intQuizID        = Int32.Parse(tmpRow["QuizID"].ToString());
                    intPassMark      = Int32.Parse(tmpRow["PassMark"].ToString());
                    intUnitID        = Int32.Parse(tmpRow["UnitID"].ToString());
                    intModuleID      = Int32.Parse(tmpRow["ModuleID"].ToString());
                    intQuizFrequency = tmpRow["QuizFrequency"] == null?Int32.Parse(tmpRow["QuizFrequency"].ToString()) : 0;

                    intOldCourseStatus = Int32.Parse(tmpRow["OldCourseStatus"].ToString());
                    intNewCourseStatus = Int32.Parse(tmpRow["NewCourseStatus"].ToString());
                    intNewQuizStatus   = Int32.Parse(tmpRow["NewQuizStatus"].ToString());
                    intCourseID        = Int32.Parse(tmpRow["CourseID"].ToString());
                    int intProfileID = Int32.Parse(Request.QueryString["ProfileID"].ToString());
                    dtmQuizCompletionDate = (tmpRow["QuizCompletionDate"] == System.DBNull.Value ? DateTime.Parse("1/1/1900"): (DateTime)tmpRow["QuizCompletionDate"]);

                    endQuizInfo = objToolbook.EndQuizSession_UpdateTables(PageContext.Current.SessionID, objTimeSpan.Seconds, intScore, intUserID, intQuizID, intPassMark, intUnitID, intModuleID, intCourseID, intOldCourseStatus, intNewQuizStatus, intNewCourseStatus, intQuizFrequency, dtmQuizCompletionDate);
                    tmpRow      = endQuizInfo.Rows[0];
                    Boolean blnSendCert = (bool)tmpRow["sendcert"];
                    if (blnSendCert)
                    {
                        certemail(intUserID, intCourseID, intProfileID);
                    }


                    //obtain profileIDs for all profiles that have access to module and apply points
                    BusinessServices.Profile objProfile = new BusinessServices.Profile();
                    DataTable dtProfiles = objProfile.ProfilesWithModuleAccess(intUserID, intModuleID);
                    foreach (DataRow dr in dtProfiles.Rows)
                    {
                        int ProfileID = int.Parse(dr["ProfileID"].ToString());
                        ApplyProfilePoints(ProfileID, intNewQuizStatus, intModuleID, intUserID);
                    }
                    Session["CourseID"]           = intCourseID.ToString();
                    Session["CourseID_ProfileID"] = "CourseID=" + intCourseID.ToString() + "&ProfileID=" + intProfileID.ToString();
                }
                catch (Exception ex)
                {
                    if (ex.Message.ToLower().StartsWith("violation of primary key"))
                    {
                        Response.Write(ResourceManager.GetString("QuizLesson_Error"));
                        Response.End();
                    }
                    else
                    {
                        //throw ex;
                        ErrorHandler.ErrorLog el = new ErrorHandler.ErrorLog(ex);
                    }
                }

                Response.Redirect("/Reporting/QuizResult.aspx?QuizSessionID=" + PageContext.Current.SessionID);
            }
        }
Example #28
0
        }         // Quiz_OnLoad

        /// <summary>
        /// This event is called when a quiz is completed.
        /// It updates the QuizSession table in Salt with information
        /// provided by the Toolbook application. This information is supplied
        /// via form elements that are posted to this page.
        /// </summary>
        /// <param name="sessionID">This is the session id that maps to the lesson that is currently loading</param>
        /// <param name="postData">This is the collection of http post data variables</param>
        private void Quiz_OnScore(string sessionID, NameValueCollection postData)
        {
            string strDuration;         // This isnt currently implemented in toolbook
            string strResponses;        // The responses given by the user
            string strScore;            // The score of the user
            int    intScore;            // The score of the user answering the quiz
            int    intDuration;         // The uration the user spent doing the quiz

            // Verify the necessary post parameters have been supplied
            strResponses = postData.Get("Responses");
            if (strResponses.Length == 0)
            {
                OutputToToolBook(
                    cm_strReturnCodeCriticalError                                                   // paramater 1 - ReturnCode
                    + cm_strDelimiter + "TBListener Error 1. Missing required parameter: Responses" // paramater 2 - Error Message
                    );
                return;
            }

            // Get the duration
            strDuration = postData.Get("Duration");
            if (strDuration.Length == 0)
            {
                OutputToToolBook(
                    cm_strReturnCodeCriticalError                                                  // paramater 1 - ReturnCode
                    + cm_strDelimiter + "TBListener Error 1. Missing required parameter: Duration" // paramater 2 - Error Message
                    );
                return;
            }

            // Get the score
            strScore = postData.Get("Score");
            if (strDuration.Length == 0)
            {
                OutputToToolBook(
                    cm_strReturnCodeCriticalError                                                  // paramater 1 - ReturnCode
                    + cm_strDelimiter + "TBListener Error 1. Missing required parameter: Duration" // paramater 2 - Error Message
                    );
                return;
            }

            // Check that Duration and Score contain numeric values
            if (IsInteger(strDuration) && IsInteger(strScore))
            {
                intDuration = Convert.ToInt32(strDuration);
                intScore    = Convert.ToInt32(strScore);
            }
            else
            {
                OutputToToolBook(
                    cm_strReturnCodeCriticalError                                                       // paramater 1 - ReturnCode
                    + cm_strDelimiter + "TBListener Error 1. Invalid parameter type: Duration or Score" // paramater 2 - Error Message
                    );
                return;
            }

            try
            {
                // All Answers To All Questions
                string[] aAnswersAllQuestions;

                // Answers to one particular question
                string[] aAnswersOneQuestions;

                // QuizQuestionID
                string strQuestionToolbookPageID;

                int intFirstMarker;
                int intSecondMarker;
                BusinessServices.Toolbook objToolboook = new Toolbook();

                // Remove one of the ['s
                strResponses = strResponses.Replace("[", "");

                // Use the other ] as a delimiter to split the string to an array.
                strResponses = strResponses.Substring(0, strResponses.Length - 1);

                aAnswersAllQuestions = strResponses.Split(']');
                foreach (string strAnswer in aAnswersAllQuestions)
                {
                    // Find first opening square bracket
                    intFirstMarker = strAnswer.IndexOf("{");

                    // Find the matching closing bracket.
                    intSecondMarker = strAnswer.IndexOf("}");

                    // This turns the string "Q1{1,2,3}" into an array containing '1' '2' and '3'
                    aAnswersOneQuestions = strAnswer.Substring(intFirstMarker + 1, intSecondMarker - intFirstMarker - 1).Split(',');

                    // Get the Question ID from the start of the string, ignore the Q at the start.
                    strQuestionToolbookPageID = strAnswer.Substring(0, intFirstMarker);
                    objToolboook.CreateQuizQuestionAudit(sessionID, strQuestionToolbookPageID);

                    // Iterate through each Answer for this question and add it to the salt database.
                    foreach (string strQuizAnswer in aAnswersOneQuestions)
                    {
                        // Only add the answer if there is a value provided
                        if (strQuizAnswer.Length > 0)
                        {
                            objToolboook.CreateQuizAnswerAudit(sessionID, strQuestionToolbookPageID, Convert.ToInt32(strQuizAnswer));
                        }
                    }
                }

                // Record that the Quiz has finished
                try
                {
                    DataTable endQuizInfo;
                    int       intUserID;
                    int       intQuizID;
                    int       intPassMark;
                    int       intUnitID;
                    int       intModuleID;
                    int       intQuizFrequency;
                    int       intOldCourseStatus;
                    int       intNewCourseStatus;
                    int       intNewQuizStatus;
                    int       intCourseID;
                    DateTime  dtmQuizCompletionDate;

                    //objToolboook.EndQuizSession(sessionID, intDuration, intScore);
                    endQuizInfo = objToolboook.BeforeQuizEnd(sessionID, intDuration, intScore);

                    DataRow tmpRow = endQuizInfo.Rows[0];
                    intUserID             = Int32.Parse(tmpRow["UserID"].ToString());
                    intQuizID             = Int32.Parse(tmpRow["QuizID"].ToString());
                    intPassMark           = Int32.Parse(tmpRow["PassMark"].ToString());
                    intUnitID             = Int32.Parse(tmpRow["UnitID"].ToString());
                    intModuleID           = Int32.Parse(tmpRow["ModuleID"].ToString());
                    intQuizFrequency      = Int32.Parse(tmpRow["QuizFrequency"].ToString());
                    intOldCourseStatus    = Int32.Parse(tmpRow["OldCourseStatus"].ToString());
                    intNewCourseStatus    = Int32.Parse(tmpRow["NewCourseStatus"].ToString());
                    intNewQuizStatus      = Int32.Parse(tmpRow["NewQuizStatus"].ToString());
                    intCourseID           = Int32.Parse(tmpRow["CourseID"].ToString());
                    dtmQuizCompletionDate = tmpRow["QuizCompletionDate"] == null?DateTime.Parse("1/1/1900") : (DateTime)tmpRow["QuizCompletionDate"];


                    objToolboook.EndQuizSession_UpdateTables(sessionID, intDuration, intScore, intUserID, intQuizID, intPassMark, intUnitID, intModuleID, intCourseID, intOldCourseStatus, intNewQuizStatus, intNewCourseStatus, intQuizFrequency, dtmQuizCompletionDate);
                }
                catch (Exception ex)
                {
                    ErrorHandler.ErrorLog Error = new ErrorHandler.ErrorLog(ex, ErrorLevel.Medium, "ToolBookListener.aspx.cs", "Quiz_OnScore", "Failed in objToolboook.EndQuizSession");
                    throw (ex);
                }

                // Everything has been saved to Salt successfully.
                // Send OK Return code to Toolbook to indicate completion
                OutputToToolBook(
                    cm_strReturnCodeOK                                          // paramater 1 - ReturnCode
                    + cm_strDelimiter + ""                                      // paramater 2 - Error Message
                    );
            }
            catch (Exception ex)
            {
                ErrorHandler.ErrorLog objError = new ErrorHandler.ErrorLog(ex, ErrorLevel.Medium, "ToolBookListener.aspx.cs", "Quiz_OnScore", "");
            }
        }         // Quiz_OnScore
Example #29
0
        }         // LessonPage_OnLoad

        /// <summary>
        /// Lesson_OnExit
        /// </summary>
        /// <param name="sessionID">This is the session id that maps to the lesson that is currently loading</param>
        /// <param name="postData">This is the collection of http post data variables</param>
        private void Lesson_OnExit(SqlString sessionID, NameValueCollection postData)
        {
            int    iDuration;
            string strDuration, strBookmark;

            // Verify the necessary post parameters have been supplied
            strDuration = postData.Get("Duration");
            if (strDuration.Length == 0)
            {
                OutputToToolBook(
                    cm_strReturnCodeCriticalError                                                  // paramater 1 - ReturnCode
                    + cm_strDelimiter + "TBListener Error 1. Missing required parameter: Duration" // paramater 2 - Error Message
                    );
                return;
            }

            // Check that Duration contains a numeric value
            if (IsInteger(strDuration))
            {
                iDuration = Convert.ToInt32(strDuration);
            }
            else
            {
                OutputToToolBook(
                    cm_strReturnCodeCriticalError                                              // paramater 1 - ReturnCode
                    + cm_strDelimiter + "TBListener Error 1. Invalid parameter type: Duration" // paramater 2 - Error Message
                    );
                return;
            }

            // Bookmark is optionial
            strBookmark = postData.Get("Bookmark");

            try
            {
                BusinessServices.Toolbook objToolBook = new BusinessServices.Toolbook();
                if (objToolBook.EndLessonSession(sessionID, iDuration, strBookmark))
                {
                    // Normal condition -> tell TB "cm_strReturnCodeOK", i.e. it can continue
                    OutputToToolBook(
                        cm_strReturnCodeOK                                      // paramater 1 - ReturnCode
                        + cm_strDelimiter + ""                                  // paramater 2 - Error Message
                        );
                    return;
                }
                else
                {
                    // log the error
                    Exception             Ex    = new Exception("TBListener Error 17.  The lesson_OnExit event for session '" + (string)sessionID + "' has failed. One reason for this may be that the lesson has already ended and toolbook has firing the event twice. Except for this.");
                    ErrorHandler.ErrorLog Error = new ErrorHandler.ErrorLog(Ex, ErrorLevel.Medium, "ToolBookListener.aspx.cs", "lesson_OnExit", "TBListener Error 17. The Stored proc prcLessonSession_EndLesson returned false - indicating that it could not or has already finished this lesson");


                    // error condition -> TB is closing any way so no need to send a critical error, just advise user that there is a problem

                    OutputToToolBook(
                        cm_strReturnCodeNonCriticalError                                                  // paramater 1 - ReturnCode
                        + cm_strDelimiter + "TBListener Error 17. " + ResourceManager.GetString("Error3") //There was a problem recording the finishing of your lesson, details may not have been saved :-("	// paramater 2 - Error Message
                        );
                    return;
                }
            }
            catch (Exception ex)
            {
                // log the error
                ErrorHandler.ErrorLog Error = new ErrorHandler.ErrorLog(ex);
                OutputToToolBook(
                    cm_strReturnCodeCriticalError                            // paramater 1 - ReturnCode
                    + cm_strDelimiter + "TBListener Error 18. Unknown Error" // paramater 2 - Error Message
                    );
                return;
            }
        }        //Lesson_OnExit
        protected void btnServiceToggle_Click(object sender, EventArgs e)
        {
            try
            {
                BusinessServices.AppConfig ac = new BusinessServices.AppConfig();
                BusinessServices.Email     em = new BusinessServices.Email();

                DataTable dt = ac.getMailServices();

                String[] strArr;

                ServiceController scQueueMail    = null;
                ServiceController scQueueReports = null;
                ServiceController scSendMail     = null;


                foreach (DataRow dr in dt.Rows)
                {
                    strArr = dr.ItemArray[1].ToString().Split(';');

                    if (dr.ItemArray[0].Equals("MailService_QueueMail"))
                    {
                        scQueueMail = new ServiceController(strArr[1], strArr[0]);
                    }
                    else if (dr.ItemArray[0].Equals("MailService_QueueReports"))
                    {
                        scQueueReports = new ServiceController(strArr[1], strArr[0]);
                    }
                    else if (dr.ItemArray[0].Equals("MailService_SendMail"))
                    {
                        scSendMail = new ServiceController(strArr[1], strArr[0]);
                    }
                }

                //String username = System.Security.Principal.WindowsIdentity.GetCurrent().Name;// used for debugging

                // if its stopped then start it
                if (scSendMail.Status == ServiceControllerStatus.Stopped)
                {
                    em.purgeAutoEmails();

                    // set the send mail flag to allow emails to be sent
                    ac.Update("SEND_AUTO_EMAILS", "YES");

                    scSendMail.Start();
                    scSendMail.WaitForStatus(ServiceControllerStatus.Running, new TimeSpan(0, 0, 10));
                    scSendMail.Refresh();
                }
                // if its started then stop it
                else if (scSendMail.Status == ServiceControllerStatus.Running)
                {
                    em.purgeAutoEmails();

                    // set the send mail flag to stop emails from being sent
                    ac.Update("SEND_AUTO_EMAILS", "NO");

                    // restart report queuing
                    restartService(scQueueReports);

                    scSendMail.Stop();
                    scSendMail.WaitForStatus(ServiceControllerStatus.Stopped, new TimeSpan(0, 0, 10));
                    scSendMail.Refresh();

                    // restart mail queuing service
                    restartService(scQueueMail);
                }

                //username = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
                setButtonLabel();
            }
            catch (Exception ex)
            {
                ErrorHandler.ErrorLog el = new ErrorHandler.ErrorLog(ex, ErrorLevel.High, "Service Control", "Panic button pressed", ex.Message);
            }
        }