Example #1
0
        static void Main(string[] args)
        {
            IAppErrors     errors  = new AppErrors();
            IExamService   service = new ExamService(errors, new ExamRepository());
            ExaminationDTO ex      = new ExaminationDTO();

            ex.Description = "Data By EF";
            ex.CutOffMark  = 24;
            ex.CourseID    = 1;
            service.AddNewExam(ex);

            if (errors.IsValid)
            {
                Console.WriteLine("Success");
            }
            else
            {
                foreach (Error er in errors.GetErrors())
                {
                    Console.WriteLine(er.Value);
                }
            }

            IEnumerable <ExaminationDTO> exams = service.GetExams();

            foreach (var x in exams)
            {
                Console.WriteLine(x.CourseID + "|" + x.Description + "|" + x.CutOffMark);
            }
            Console.ReadLine();
        }
Example #2
0
        public static void LogError(Exception ex, HttpContext httpContext, ExpenseConnection _conn)
        {
            var appErrors = new AppErrors();

            try
            {
                appErrors.Host = httpContext.Request.Host.HasValue ? httpContext.Request.Host.ToString() : "";

                appErrors.IpAddress = httpContext.Request.HttpContext.Connection.RemoteIpAddress.ToString();

                appErrors.Url = httpContext.Request.Path;

                appErrors.HttpMethod = httpContext.Request.Method;

                var userId = httpContext.User.Claims.Where(c => c.Type == ClaimTypes.PrimarySid).FirstOrDefault()?.Value;

                if (!string.IsNullOrEmpty(userId))
                {
                    appErrors.UserId = Convert.ToInt32(userId);
                }

                appErrors.Username = httpContext.User.Claims.Where(c => c.Type == ClaimTypes.Name).FirstOrDefault()?.Value;

                appErrors.StackTrace = ex.StackTrace;

                appErrors.InnerException = ex.InnerException.Message;

                appErrors.TimeStamp = DateTime.Now;

                _conn.BeginTransaction();
                _conn.Insert(appErrors);
                _conn.Commit();
            }
            catch (Exception ex1)
            {
                if (_conn.InTransaction)
                {
                    _conn.RollBack();
                }
                var x = ex1.Message.ToString();
            }
        }
Example #3
0
        /// <summary>
        /// Constructor for the Application object.
        /// </summary>
        public App()
        {
            // Global handler for uncaught exceptions.
            UnhandledException += Application_UnhandledException;

            // Standard XAML initialization
            InitializeComponent();

            // Phone-specific initialization
            InitializePhoneApplication();

            // Language display initialization
            InitializeLanguage();

            // Show graphics profiling information while debugging.
            if (Debugger.IsAttached)
            {
                // Display the current frame rate counters.
                Application.Current.Host.Settings.EnableFrameRateCounter = true;

                // Show the areas of the app that are being redrawn in each frame.
                //Application.Current.Host.Settings.EnableRedrawRegions = true;

                // Enable non-production analysis visualization mode,
                // which shows areas of a page that are handed off GPU with a colored overlay.
                //Application.Current.Host.Settings.EnableCacheVisualization = true;

                // Prevent the screen from turning off while under the debugger by disabling
                // the application's idle detection.
                // Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run
                // and consume battery power when the user is not using the phone.
                PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
            }

            //my classes
            Setting = new AppSettings();
            Error   = new AppErrors();
        }
Example #4
0
        static void Main(string[] args)
        {
            IAppErrors   errors  = new AppErrors();
            IExamService service = new ExamService(errors, new ExamRepository());
            Examination  ex      = new Examination();

            ex.Description = "Data By ADO.NET";
            ex.CutOffMark  = 24;
            ex.CourseID    = 1;
            service.AddNewExam(ex);

            if (errors.IsValid)
            {
                Console.WriteLine("Success");
            }
            else
            {
                foreach (Error er in errors.GetErrors())
                {
                    Console.WriteLine(er.Value);
                }
            }
            Console.ReadLine();
        }
 public void InsertException(AppErrors appError)
 {
     _connection.Insert(appError);
 }