示例#1
0
        public IActionResult SendReport(SendReportRequest input)
        {
            if (_logger.IsEnabled(LogLevel.Trace))
            {
                _logger.LogTrace($"{nameof(SendReport)}:  {SendReportRequest.VERB}");
            }

            if (ModelState.IsValid)
            {
                // This validation of the date elements will throw a FormatException
                // and result in a 500 error if the dates are invalid which matches
                // the observed and tested behavior of the Classic DSC Pull Server
                if (!string.IsNullOrEmpty(input.Body.StartTime))
                {
                    DateTime.Parse(input.Body.StartTime);
                }
                if (!string.IsNullOrEmpty(input.Body.EndTime))
                {
                    DateTime.Parse(input.Body.EndTime);
                }

                _logger.LogDebug($"AgentId=[{input.AgentId}]");
                _dscHandler.SendReport(input.AgentId.Value, input.Body);
                return(Ok());
            }

            return(BadRequest(ModelState));
        }
示例#2
0
        /// <summary>
        /// Submits a <c>SendReport</c> message request which the body payload
        /// of the request defined as the JSON-serialized form of the argument.
        /// </summary>
        /// <param name="body"></param>
        public async Task SendReport(SendReportBody body)
        {
            if (LOG.IsEnabled(LogLevel.Trace))
            {
                LOG.LogTrace(nameof(SendReport));
            }

            AssertInit();

            var serverConfig = Configuration.ReportServer;

            AssertServerConfig(serverConfig);

            if (body != null)
            {
                var now   = DateTime.Now.ToString(SendReportBody.REPORT_DATE_FORMAT);
                var jobId = Guid.NewGuid();

                if (Guid.Empty == body.JobId)
                {
                    body.JobId = jobId;
                }

                if (DscPullConfig.SendReportConfig.DATETIME_NOW_TOKEN == body.StartTime)
                {
                    body.StartTime = now;
                }

                if (DscPullConfig.SendReportConfig.DATETIME_NOW_TOKEN == body.EndTime)
                {
                    body.EndTime = now;
                }

                if (DisableReportAdditionalData)
                {
                    body.AdditionalData = null;
                }
            }

            var dscRequ = new SendReportRequest
            {
                AgentId           = Configuration.AgentId,
                AcceptHeader      = DscContentTypes.JSON,
                Body              = body,
                ContentTypeHeader = DscContentTypes.JSON,
            };

            await SendDscAsync(serverConfig, SendReportRequest.VERB,
                               SendReportRequest.ROUTE, dscRequ);
        }
示例#3
0
        public override void CallServerMethod(uint token, uint methodId, CodedInputStream stream)
        {
            switch (methodId)
            {
            case 1:
            {
                SendReportRequest request = new SendReportRequest();
                request.MergeFrom(stream);


                NoData response = new NoData();
                BattlenetRpcErrorCode status = HandleSendReport(request, response);
                Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ReportService.SendReport(bgs.protocol.report.v1.SendReportRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
                             GetCallerInfo(), request.ToString(), response.ToString(), status);
                if (status == 0)
                {
                    SendResponse(token, response);
                }
                else
                {
                    SendResponse(token, status);
                }
                break;
            }

            /*case 2:
             *  {
             *      SubmitReportRequest request = new SubmitReportRequest();
             *      request.MergeFrom(stream);
             *
             *
             *      NoData response = new NoData();
             *      BattlenetRpcErrorCode status = HandleSubmitReport(request, response);
             *      Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ReportService.SubmitReport(bgs.protocol.report.v1.SubmitReportRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
             *        GetCallerInfo(), request.ToString(), response.ToString(), status);
             *      if (status == 0)
             *          SendResponse(token, response);
             *      else
             *          SendResponse(token, status);
             *      break;
             *  }*/
            default:
                Log.outError(LogFilter.ServiceProtobuf, "Bad method id {0}.", methodId);
                SendResponse(token, BattlenetRpcErrorCode.RpcInvalidMethod);
                break;
            }
        }
示例#4
0
 BattlenetRpcErrorCode HandleSendReport(SendReportRequest request, NoData response)
 {
     Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method ReportService.SendReport: {1}",
                  GetCallerInfo(), request.ToString());
     return(BattlenetRpcErrorCode.RpcNotImplemented);
 }