示例#1
0
        public async Task <bool> AddScoreToCall(MonitoringEntity monitoring)
        {
            if (monitoring == null)
            {
                return(false);
            }
            _dataContext.Add(monitoring);
            await _dataContext.SaveChangesAsync();

            return(true);
        }
        public async Task <PingReply> SendAsync(MonitoringEntity entity)
        {
            var pingSender = new Ping();
            var options    = new PingOptions
            {
                DontFragment = true
            };

            var buffer = Encoding.ASCII.GetBytes(BufferString);

            return(await pingSender.SendPingAsync(entity.Address, Timeout, buffer, options));
        }
示例#3
0
        public async Task StartAsync(MonitoringEntity entity)
        {
            var result = new MonitoringResult
            {
                CreatedDate        = _dateTimeProvider.Now,
                MonitoringEntityId = entity.Id
            };

            result.SetData(new PingMonitoringResultData(await GetIpStatus(entity)));

            _monitoringResultRepository.Create(result);
            await _monitoringResultRepository.SaveChangesAsync();
        }
示例#4
0
        /// <summary>
        /// Updates the heartBeatEntity.
        /// </summary>
        /// <param name="monitoringEntity">The health heartBeatEntity.</param>
        /// <param name="serviceInfo">The service info.</param>
        /// <param name="updateValues">The update values.</param>
        private static void UpdateEntity(ServiceInfoEntity serviceInfo, MonitoringEntity monitoringEntity, Action <ServiceInfoEntity> updateValues)
        {
            if (serviceInfo == null)
            {
                return;
            }

            updateValues(serviceInfo);
            serviceInfo.UtcTimeTakenSample = monitoringEntity.UtcTimeTakenSample;
            serviceInfo.BusIdentification  = monitoringEntity.BusIdentification;
            serviceInfo.Identification     = monitoringEntity.Identification;
            serviceInfo.Type = monitoringEntity.Type;
        }
示例#5
0
        private async Task <IPStatus> GetIpStatus(MonitoringEntity entity)
        {
            try
            {
                var reply = await _pingMonitoringRequest.SendAsync(entity);

                return(reply.Status);
            }
            catch (PingException e)
            {
                _logger.LogWarning(e, $"Unable to retrieve ip status for '{entity.Address}'");
                return(IPStatus.Unknown);
            }
        }
示例#6
0
 /// <summary>
 /// Gets the reopsitory.
 /// </summary>
 /// <param name="entity">The heartBeatEntity.</param>
 /// <returns></returns>
 private IServiceInfoRepository GetReopsitory(MonitoringEntity entity)
 {
     return IsBus(entity) ? _busRepository : _serviceRepository;
 }
示例#7
0
        /// <summary>
        /// Updates the heartBeatEntity.
        /// </summary>
        /// <param name="monitoringEntity">The health heartBeatEntity.</param>
        /// <param name="serviceInfo">The service info.</param>
        /// <param name="updateValues">The update values.</param>
        private static void UpdateEntity(ServiceInfoEntity serviceInfo,MonitoringEntity monitoringEntity, Action<ServiceInfoEntity> updateValues)
        {
            if (serviceInfo == null) return;

            updateValues(serviceInfo);
            serviceInfo.UtcTimeTakenSample = monitoringEntity.UtcTimeTakenSample;
            serviceInfo.BusIdentification = monitoringEntity.BusIdentification;
            serviceInfo.Identification = monitoringEntity.Identification;
            serviceInfo.Type = monitoringEntity.Type;
        }
示例#8
0
 /// <summary>
 /// Determines whether the specified service info heartBeatEntity is bus.
 /// </summary>
 /// <param name="serviceInfoEntity">The service info heartBeatEntity.</param>
 /// <returns>
 /// 	<c>true</c> if the specified service info heartBeatEntity is bus; otherwise, <c>false</c>.
 /// </returns>
 private static bool IsBus(MonitoringEntity serviceInfoEntity)
 {
     return IdentitySpec.Instance.IsSatisfiedBy(serviceInfoEntity.Identification) &&
            BusTypeSpec.Instance.IsSatisfiedBy(serviceInfoEntity.Type);
 }
        public bool InsertMonitoring(MonitoringEntity monitoring)
        {
            bool success = false;

            try
            {
                oCompService = oCompany.GetCompanyService();
                oCompany.StartTransaction();
                oGeneralService = oCompService.GetGeneralService("UD_INT_MONITORING");

                oGeneralData = (SAPbobsCOM.GeneralData)oGeneralService.GetDataInterface(GeneralServiceDataInterfaces.gsGeneralData);

                oGeneralData.SetProperty("Code", monitoring.DocCode);

                oGeneralData.SetProperty("U_SketchInv", monitoring.Sketch_Invoice);

                oGeneralData.SetProperty("U_DocDate", DateTime.Now.ToString("yyyyMMdd"));

                oGeneralData.SetProperty("U_DocTotal", monitoring.DocTot);

                if (monitoring.BL != null)
                {
                    oGeneralData.SetProperty("U_Bl", monitoring.BL);
                }

                if (monitoring.BLId != null)
                {
                    oGeneralData.SetProperty("U_BlId", monitoring.BLId);
                }

                if (monitoring.Draft != null)
                {
                    oGeneralData.SetProperty("U_Draft", monitoring.Draft);
                }

                if (monitoring.Branch != null)
                {
                    oGeneralData.SetProperty("U_Branch", monitoring.Branch);
                }

                if (monitoring.BranchId != null)
                {
                    oGeneralData.SetProperty("U_BranchId", monitoring.BranchId);
                }

                oGeneralData.SetProperty("U_StatusId", monitoring.StatusId);
                oGeneralData.SetProperty("U_Status", monitoring.Status);

                oGeneralData.SetProperty("U_XMLPath", monitoring.XMLPath);
                oGeneralData.SetProperty("U_Message", monitoring.Message);

                oGeneralService.Add(oGeneralData);
            }
            catch (Exception e)
            {
                if (oCompany.InTransaction)
                {
                    oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack);
                }

                LogDAL _log = new LogDAL();
                _log.WriteEntry("InsertMonitoring error: " + e.Message);

                throw e;
            }
            if (oCompany.InTransaction)
            {
                oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit);
            }
            return(success);
        }
示例#10
0
 /// <summary>
 /// Determines whether the specified service info heartBeatEntity is bus.
 /// </summary>
 /// <param name="serviceInfoEntity">The service info heartBeatEntity.</param>
 /// <returns>
 ///     <c>true</c> if the specified service info heartBeatEntity is bus; otherwise, <c>false</c>.
 /// </returns>
 private static bool IsBus(MonitoringEntity serviceInfoEntity)
 {
     return(IdentitySpec.Instance.IsSatisfiedBy(serviceInfoEntity.Identification) &&
            BusTypeSpec.Instance.IsSatisfiedBy(serviceInfoEntity.Type));
 }
示例#11
0
 /// <summary>
 /// Gets the reopsitory.
 /// </summary>
 /// <param name="entity">The heartBeatEntity.</param>
 /// <returns></returns>
 private IServiceInfoRepository GetReopsitory(MonitoringEntity entity)
 {
     return(IsBus(entity) ? _busRepository : _serviceRepository);
 }