コード例 #1
0
        public async Task <IEnumerable <HealthIssue> > GetHealthIssuesAsync()
        {
            try
            {
                var dcrdIssues = await GetDcrdHealthIssues();

                if (dcrdIssues.Any())
                {
                    return(dcrdIssues);
                }

                var dcrdataIssues = await GetDcrdataHealthIssues();

                if (dcrdataIssues.Any())
                {
                    return(dcrdataIssues);
                }
            }
            catch (Exception e)
            {
                await _log.WriteErrorAsync(nameof(HealthService), nameof(GetDcrdataHealthIssues), "", e);

                return(new[]
                {
                    HealthIssue.Create("UnknownHealthIssue", e.Message),
                });
            }

            return(Enumerable.Empty <HealthIssue>());
        }
コード例 #2
0
        public async Task UpdateHealthStatus()
        {
            var result = new List <HealthIssue>();

            try
            {
                result.AddRange(await GetDcrdHealthIssues());
                result.AddRange(await GetDcrdataHealthIssues());
            }
            catch (Exception e)
            {
                _log.Error(e);

                result.Add(HealthIssue.Create("UnknownHealthIssue", e.Message));
            }

            await _healthStatusRepo.InsertAsync(new HealthStatusEntity
            {
                HealthIssues = result.Select(p => new HealthStatusEntity.HealthIssue
                {
                    Type  = p.Type,
                    Value = p.Value
                }).ToArray()
            });
        }
        public async Task InsertAsync(HealthIssue healthIssue)
        {
            var id     = Guid.NewGuid();
            var entity = new HealthIssueEntity(GetPartitionKey(healthIssue.Time), GetRowKey(id));

            Mapper.Map(healthIssue, entity);

            await _storage.InsertOrReplaceAsync(entity);
        }
コード例 #4
0
        public IEnumerable <HealthIssue> GetHealthIssues()
        {
            var issues  = new List <HealthIssue>();
            var message = GetHealthViolationMessage();

            if (message != null)
            {
                issues.Add(HealthIssue.Create(string.Empty, message));
            }
            return(issues);
        }
コード例 #5
0
 private async Task ProcessMessageAsync(HealthIssue message)
 {
     try
     {
         var model = Mapper.Map <Core.Domain.Health.HealthIssue>(message);
         await _healthMonitorService.HandleAsync(model);
     }
     catch (Exception exception)
     {
         _log.Error(exception, "An error occurred during processing health issue message", message);
     }
 }
コード例 #6
0
        private async Task <HealthIssue[]> GetDcrdHealthIssues()
        {
            try
            {
                await _dcrdClient.PingAsync();

                return(new HealthIssue[0]);
            }
            catch (Exception e)
            {
                _log.Error(e);
                return(new[]
                {
                    HealthIssue.Create("DcrdPingFailure",
                                       $"Failed to ping dcrd.  {e}".Trim())
                });
            }
        }
コード例 #7
0
        private async Task <HealthIssue[]> GetDcrdHealthIssues()
        {
            try
            {
                await _dcrdClient.PingAsync();

                return(new HealthIssue[0]);
            }
            catch (Exception e)
            {
                await _log.WriteErrorAsync(nameof(HealthService), nameof(GetDcrdHealthIssues), "", e);

                return(new[]
                {
                    HealthIssue.Create("DcrdPingFailure",
                                       $"Failed to ping dcrd.  {e.Message}".Trim())
                });
            }
        }
コード例 #8
0
        /// <summary>
        /// Adds the rendering issue to the list of issues and updates the totals
        /// depending on the issue's severity.
        /// </summary>
        /// <param name="issue">The issue to add to the list</param>
        private void AddRenderingIssue(HealthIssue issue)
        {
            if (issue.Severity == HealthIssueSeverity.Error)
            {
                result.Totals.NumErrors++;
                result.Renderings.Totals.NumErrors++;
            }
            else if (issue.Severity == HealthIssueSeverity.Warning)
            {
                result.Totals.NumWarnings++;
                result.Renderings.Totals.NumWarnings++;
            }
            else if (issue.Severity == HealthIssueSeverity.Info)
            {
                result.Totals.NumInfo++;
                result.Renderings.Totals.NumInfo++;
            }

            result.Renderings.Issues.Add(issue);
        }
コード例 #9
0
        private async Task <HealthIssue[]> GetDcrdataHealthIssues()
        {
            var dcrdataTopBlock = await _blockRepository.GetHighestBlock();

            if (dcrdataTopBlock == null)
            {
                return(new []
                {
                    HealthIssue.Create("NoDcrdataBestBlock",
                                       "No blocks found in dcrdata database"),
                });
            }

            // Get dcrd block height.  If dcrdata out of sync, raise failure.
            var dcrdTopBlock = await _dcrdClient.GetBestBlockAsync();

            if (dcrdTopBlock == null)
            {
                return(new []
                {
                    HealthIssue.Create("NoDcrdBestBlock",
                                       "No blocks found with dcrd getbestblock"),
                });
            }

            // If the difference in block height
            const int unsyncedThreshold = 3;
            var       isUnsynced        = Math.Abs(dcrdTopBlock.Height - dcrdataTopBlock.Height) > unsyncedThreshold;

            if (isUnsynced)
            {
                return(new []
                {
                    HealthIssue.Create("BlockHeightOutOfSync",
                                       $"dcrd at blockheight {dcrdTopBlock.Height} while dcrdata at blockheight {dcrdataTopBlock.Height}"),
                });
            }

            return(new HealthIssue[0]);
        }
コード例 #10
0
        public async Task <(DateTime updated, IEnumerable <HealthIssue> issues)> GetHealthStatusAsync()
        {
            var result = (await _healthStatusRepo.GetAsync(HealthStatusEntity.RowKeyDefaultValue));

            if (result != null)
            {
                return(updated : result.Timestamp.UtcDateTime, result.HealthIssues.Select(p => HealthIssue.Create(p.Type, p.Value)));
            }

            return(DateTime.MinValue, Enumerable.Empty <HealthIssue>());
        }
コード例 #11
0
 public Task HandleAsync(HealthIssue healthIssue)
 {
     return(_healthIssueRepository.InsertAsync(healthIssue));
 }
コード例 #12
0
        public HttpResponseMessage AddRegistration(RegistrationDTO DTO)
        {
            try
            {
                var payment = new Payment()
                {
                    Amount         = DTO.R_Payment.P_Amount,
                    DataDescriptor = DTO.R_Payment.P_DataDescriptor,
                    DataValue      = DTO.R_Payment.P_DataValue
                };

                var address = new Address()
                {
                    Address1 = DTO.R_Address.A_Address1,
                    Address2 = DTO.R_Address.A_Address2,
                    City     = DTO.R_Address.A_City,
                    State    = DTO.R_Address.A_State,
                    Zip      = DTO.R_Address.A_Zip
                };

                var contactInfo = new ContactInformation()
                {
                    CellPhone = DTO.R_ContactInfo.CI_CellPhone,
                    HomePhone = DTO.R_ContactInfo.CI_HomePhone,
                    Email     = DTO.R_ContactInfo.CI_Email
                };

                var emergencyContactInfo = new EmergencyContact()
                {
                    Name  = DTO.R_EmergencyContactInfo.EC_Name,
                    Phone = DTO.R_EmergencyContactInfo.EC_Phone
                };

                List <HealthIssue> healthIssues = new List <HealthIssue>();
                foreach (HealthIssueDTO issue in DTO.R_HealthIssues)
                {
                    HealthIssue newIssue = new HealthIssue()
                    {
                        Issue = issue.HI_Issue
                    };

                    healthIssues.Add(newIssue);
                }

                DateTime?regDate    = null;
                string   isMinor    = "N";
                string   isMerchant = "N";
                if (DTO.R_RegText.Contains("Saturday"))
                {
                    regDate = new DateTime(2017, 06, 17);
                }
                else if (DTO.R_RegText.Contains("Sunday"))
                {
                    regDate = new DateTime(2017, 06, 18);
                }

                if (DTO.R_RegText.Contains("Child"))
                {
                    isMinor = "Y";
                }
                else if (DTO.R_RegText.Contains("Merchant"))
                {
                    isMerchant = "Y";
                }

                var participant = new Participant()
                {
                    CampId             = DTO.R_CampId,
                    FirstName          = DTO.R_FirstName,
                    LastName           = DTO.R_LastName,
                    DateOfBirth        = DTO.R_DateOfBirth,
                    CharacterName      = DTO.R_CharacterName,
                    ChapterName        = DTO.R_ChapterName,
                    UnitName           = DTO.R_UnitName,
                    Payment            = payment,
                    Address            = address,
                    ContactInformation = contactInfo,
                    EmergencyContact   = emergencyContactInfo,
                    HealthIssues       = healthIssues,
                    Signature          = DTO.R_Signature,
                    RegistrationDate   = regDate,
                    IsMinor            = isMinor,
                    IsMerchant         = isMerchant
                };

                var registration = new Registration()
                {
                    Participant = participant
                };

                CampController cc = new CampController();
                cc.AddRegistration(registration);

                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            catch (Exception e)
            {
                CampController cc = new CampController();
                cc.AddError(e.ToString());

                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e.Message, e));
            }
        }