Beispiel #1
0
        public override void After(AspectExecutedContext context)
        {
            base.After(context);
            _stopwatch.Stop();

            string methodName = string.Format("{0}.{1}.{2}",
                                              context.Method.ReflectedType.Namespace,
                                              context.InvokeObject.GetType().Name, context.Method.Name
                                              );

            double time = _stopwatch.Elapsed.TotalMilliseconds;

            if (time > _limitTime)
            {
                try
                {
                    string message = $"{methodName} worked {time} ms (time)";
                    _logManager.Write(message, "performance info");
                }
                catch (Exception e)
                {
                    _exceptionManager.Handle(e);
                }
            }
        }
        public async Task <ActionResult <OutputEpic> > Post(Guid projectId, [FromBody] CreateEpic createEpic)
        {
            try
            {
                logger.LogInformation($"Beginning request: /api/projects/{projectId}/epics POST");
                Epic createdEpic = await epicManager.CreateEpicAsync(projectId,
                                                                     createEpic.Name,
                                                                     createEpic.Description);

                string     createdProjectUrl = $"{Utilities.Web.GetBaseUrl(HttpContext)}/api/projects/{projectId}/epics{createdEpic.PublicEpicId}";
                OutputEpic output            = epicMapper.MapOutputEpic(createdEpic);
                logger.LogInformation("Request complete: /api/projects/{projectId}/epics POST");
                return(Created(createdProjectUrl, output));
            }
            catch (Exception ex)
            {
                return(exceptionManager.Handle(ex));
            }
        }
Beispiel #3
0
        public async Task Invoke(HttpContext context /* other dependencies */)
        {
            try
            {
                await next(context);
            }
            catch (Exception ex)
            {
                await HandleExceptionAsync(context, ex);

                _exceptionManager.Handle(ex);
            }
        }
        public async Task <ActionResult <OutputProject> > Post([FromBody] CreateProject createProject)
        {
            try
            {
                logger.LogInformation("Beginning request: /api/projects POST");
                Project createdProject = await projectManager.CreateProjectAsync(createProject.Name,
                                                                                 createProject.Description);

                string        createdProjectUrl = $"{Utilities.Web.GetBaseUrl(HttpContext)}/api/projects/{createdProject.PublicProjectId}";
                OutputProject output            = projectMapper.MapOutputProject(createdProject);
                logger.LogInformation("Request complete: /api/projects POST");
                return(Created(createdProjectUrl, output));
            }
            catch (Exception ex)
            {
                return(exceptionManager.Handle(ex));
            }
        }
Beispiel #5
0
        /// <summary>
        /// Calculates 2 digit ohm value based on 4 color band resistor values. A 5-6 band resistor would require 5-6 colors.
        /// </summary>
        /// <param name="bandAColor">The color of the first figure of component value band.</param>
        /// <param name="bandBColor">The color of the second significant figure band.</param>
        /// <param name="bandCColor">The color of the decimal multiplier band.</param>
        /// <param name="bandDColor">The color of the tolerance value band.</param>
        /// <returns>Two digit ohm value referencing significant band colors only.</returns>
        public int CalculateOhmValue(string bandAColor, string bandBColor, string bandCColor, string bandDColor)
        {
            try
            {
                List <Domain.Entity.Resistor> lstresistor = Domain.Entity.Resistor.LoadResistorData();
                Domain.Entity.Resistor        banda       = lstresistor.Where(p => p.Name.ToLower() == bandAColor.ToLower()).SingleOrDefault();
                Domain.Entity.Resistor        bandb       = lstresistor.Where(p => p.Name.ToLower() == bandBColor.ToLower()).SingleOrDefault();
                int ohmValue = 0;



                ohmValue = Convert.ToInt32(banda.Digit.ToString() + bandb.Digit.ToString());


                return(ohmValue);
            }
            catch (Exception ex)
            {
                logger.Handle(ex);

                return(-33);
            }
        }
        public async Task <ActionResult <OutputIssue> > Post(Guid projectId, [FromBody] CreateIssue createIssue)
        {
            try
            {
                logger.LogInformation($"Beginning request: /api/projects/{projectId}/issues POST");
                Issue createdIssue = await issueManager.CreateIssueAsync(projectId,
                                                                         createIssue.EpicId,
                                                                         createIssue.IssueType,
                                                                         createIssue.Name,
                                                                         createIssue.Description,
                                                                         createIssue.Status,
                                                                         createIssue.Estimate);

                string      createdProjectUrl = $"{Utilities.Web.GetBaseUrl(HttpContext)}/api/projects/{projectId}/issues{createdIssue.PublicIssueId}";
                OutputIssue output            = issueMapper.MapOutputIssue(createdIssue);
                logger.LogInformation("Request complete: /api/projects/{projectId}/issues POST");
                return(Created(createdProjectUrl, output));
            }
            catch (Exception ex)
            {
                return(exceptionManager.Handle(ex));
            }
        }