public void LogRequest(ConnectionTypeIdentifier connection, object payload, DataProviderNoRecordState billNoRecords)
        {
            SendRequestAsync(
                new DataProviderIdentifier(_dataProviderName, DataProviderAction.Request, DataProviderResponseState.Successful,billNoRecords)
                    .SetPrice(_dataProvider), connection, payload, _requestWatch);

        }
 public void CreateTransaction(Guid packageId, long packageVersion, Guid userId, Guid requestId,
     Guid contractId, string system, long contractVersion, DataProviderResponseState state, string accountNumber, double packageCostPrice, double packageRecommendedPrice, DataProviderNoRecordState billNoRecords)
 {
     new CreateTransactionCommand(Guid.NewGuid(), packageId, packageVersion, DateTime.UtcNow, userId, requestId,
         contractId,
         system, contractVersion, state, accountNumber, packageCostPrice, packageRecommendedPrice, billNoRecords)
         .SendToBus(_publisher, _log);
 }
 public void End(object payload, DataProviderStopWatch stopWatch, DataProviderCommandSource dataProvider,DataProviderNoRecordState billNoRecords)
 {
     stopWatch.Stop();
     new EndingCallCommand(Guid.NewGuid(), _requestId, CommandDescriptions.EndExecutionDescription(dataProvider),
         payload.ObjectToJson(), dataProvider, DateTime.UtcNow,
         new PerformanceMetadata(stopWatch.ToObject()).ObjectToJson(), Category.Performance,billNoRecords).SendToBus(
             _publisher, _log);
 }
 public DataProviderIdentifier(DataProviderCommandSource dataProvider,
     DataProviderAction action, DataProviderResponseState state, DataProviderNoRecordState billNoRecords)
 {
     Id = (int) dataProvider;
     Name = dataProvider.ToString();
     Action = action;
     State = state;
     BillNoRecords = billNoRecords;
 }
 private LogCommandTypes(ISendCommandToBus commands, DataProviderCommandSource dataProviderName,DataProviderNoRecordState billNoRecords)
 {
     _commands = commands;
     _dataProviderName = dataProviderName;
     _log = LogManager.GetLogger(GetType());
     _executeWatch = new StopWatchFactory().StopWatchForDataProvider(_dataProviderName);
     _requestWatch = new StopWatchFactory().StopWatchForDataProvider(_dataProviderName);
     _billNoRecords = billNoRecords;
 }
 public DataProviderIdentifier(int id, string name, decimal costPrice, decimal recommendedPrice,
     DataProviderAction action, DataProviderResponseState state, DataProviderNoRecordState billNoRecords)
 {
     Id = id;
     Name = name;
     CostPrice = costPrice;
     RecommendedPrice = recommendedPrice;
     Action = action;
     State = state;
     BillNoRecords = billNoRecords;
 }
 public Request RaiseSecurityFlag(Guid id, DataProviderCommandSource dataProvider,
     DateTime date, CommandType commandType, string metaData, string payload, string message, DataProviderNoRecordState billNoRecords)
 {
     DataProvider = new DataProviderIdentifier(dataProvider, DataProviderAction.Response,
         DataProviderResponseState.Successful, billNoRecords);
     Date = date;
     Connection = new ConnectionTypeIdentifier();
     Payload = new PayloadIdentifier(metaData, payload, message);
     CommandType = commandType;
     State = new StateIdentifier();
     RequestContext = new SearchRequestIndentifier();
     return this;
 }
 public RaisingSecurityFlagCommand(Guid id, Guid requestId, string message, string payload,
     DataProviderCommandSource dataProvider, DateTime date, string metaData, Category category, DataProviderNoRecordState billNoRecords)
 {
     Id = id;
     RequestId = requestId;
     Message = message;
     Payload = payload;
     DataProvider = dataProvider;
     Date = date;
     MetaData = metaData;
     Category = category;
     BillNoRecords = billNoRecords;
 }
 public CreateTransactionCommand(Guid id, Guid packageId, long packageVersion, DateTime date, Guid userId, Guid requestId, Guid contractId,
     string system, long contractVersion, DataProviderResponseState state, string accountNumber, double packageCostPrice, double packageRecommendedPrice,DataProviderNoRecordState noRecordState)
 {
     Id = id;
     PackageId = packageId;
     PackageVersion = packageVersion;
     PackageCostPrice = packageCostPrice;
     PackageRecommendedPrice = packageRecommendedPrice;
     Date = date;
     UserId = userId;
     RequestId = requestId;
     ContractId = contractId;
     System = system;
     State = state;
     ContractVersion = contractVersion;
     AccountNumber = accountNumber;
     NoRecordState = noRecordState;
 }
 private void SendEntryPointResponseAsync(object payload, DataProviderResponseState state,
     ICollection<IPointToLaceRequest> request, DataProviderNoRecordState billNoRecords)
 {
     try
     {
         Task.Run(() =>
         {
             try
             {
                 _commands.Workflow.EntryPointResponse(payload, _requestWatch, state, request,billNoRecords);
             }
             catch (Exception ex)
             {
                 _log.ErrorFormat("An error occured sending entry point request to the bus because of {0}",ex, ex.Message);
             }
         });
     }
     catch (Exception ex)
     {
         _log.ErrorFormat("An error occured sending entry point request to the bus because of {0}",ex, ex.Message);
     }
 }
 public static LogCommandTypes ForEntryPoint(ISendCommandToBus commands, DataProviderNoRecordState billNoRecords)
 {
     return new LogCommandTypes(commands, DataProviderCommandSource.EntryPoint,billNoRecords);
 }
 public static LogCommandTypes ForDataProvider(ISendCommandToBus commands, DataProviderCommandSource dataProviderName,
     IAmDataProvider dataProvider,DataProviderNoRecordState billNoRecords)
 {
     return new LogCommandTypes(commands,dataProviderName,dataProvider,billNoRecords);
 }
 public void LogEntryPointResponse(object payload, DataProviderResponseState state, ICollection<IPointToLaceRequest> request, DataProviderNoRecordState billNoRecords)
 {
     SendEntryPointResponseAsync(payload, state, request,billNoRecords);
 }
 public void LogEntryPointRequest(ICollection<IPointToLaceRequest> request,DataProviderNoRecordState billNoRecords)
 {
     SendEntryPointRequestAsync(request,billNoRecords);
 }
 public BillableState(DataProviderNoRecordState state)
 {
     NoRecordState = state;
 }
 public Request CreateTransaction(Guid packageId, long packageVersion, DateTime date, Guid userId,
     Guid contractId,
     string system, long contractVersion, DataProviderResponseState state, string accountNumber, double packageCostPrice, double packageRecommendedPrice, DataProviderNoRecordState billNoRecords)
 {
     DataProvider = new DataProviderIdentifier(DataProviderCommandSource.EntryPoint, DataProviderAction.Response, state, billNoRecords);
     Date = date;
     Connection = new ConnectionTypeIdentifier();
     Payload = new PayloadIdentifier();
     CommandType = CommandType.Accounting;
     State = new StateIdentifier((int) state, state.ToString());
     RequestContext = new SearchRequestIndentifier();
     Package = new PackageIdentifier(packageId, new VersionIdentifier(packageVersion), packageCostPrice, packageRecommendedPrice);
     return this;
 }
        public void EntryPointResponse(object payload, DataProviderStopWatch stopWatch, DataProviderResponseState state, ICollection<IPointToLaceRequest> request, DataProviderNoRecordState billNoRecords)
        {
            stopWatch.Stop();
            new ReturnEntryPointResponse(Guid.NewGuid(), _requestId, DateTime.UtcNow,
                new StateIdentifier((int) state, state.ToString()),
                new PayloadIdentifier(new PerformanceMetadata(stopWatch.ToObject()).ObjectToJson(),
                    payload.ObjectToJson(),
                    CommandDescriptions.ReturnEntryPointResponseDescription()),SearchRequestIndentifier.Determine(request),new NoRecordBillableIdentifier((int)billNoRecords,billNoRecords.ToString()))
                .SendToBus(_publisher, _log);

        }
 public DataProviderBillState(DataProviderNoRecordState noRecordState)
 {
     NoRecordState = noRecordState;
 }
 public void EntryPointRequest(ICollection<IPointToLaceRequest> request, DataProviderStopWatch stopWatch, DataProviderNoRecordState billNoRecords)
 {
     new ReceiveEntryPointRequest(Guid.NewGuid(), _requestId, DateTime.UtcNow,
         SearchRequestIndentifier.Determine(request),
         new PayloadIdentifier(new PerformanceMetadata(stopWatch.ToObject()).ObjectToJson(), request.ObjectToJson(),
             CommandDescriptions.ReceiveEntryPointRequestDescription()),new NoRecordBillableIdentifier((int)billNoRecords,billNoRecords.ToString()))
         .SendToBus(_publisher, _log);
     stopWatch.Start();
 }
 public MonitoirngQueueSender(DataProviderCommandSource dataProvider, Guid aggregateId, DataProviderNoRecordState billNoRecords)
 {
     _dataProvider = dataProvider;
     _aggregateId = aggregateId;
     _billNoRecords = billNoRecords;
 }
 public void Send(CommandType commandType, object payload, object metadata,
     DataProviderCommandSource dataProvider, DataProviderNoRecordState billNoRecords)
 {
     //Task.Run(() =>
     //{
         switch (commandType)
         {
             case CommandType.Error:
                 Error(payload, new MetadataContainer(metadata), dataProvider, billNoRecords);
                 break;
             case CommandType.Configuration:
                 Configuring(payload, new MetadataContainer(metadata), dataProvider, billNoRecords);
                 break;
             case CommandType.Security:
                 Security(payload, new MetadataContainer(metadata), dataProvider, billNoRecords);
                 break;
             case CommandType.Transformation:
                 Transforming(payload, new MetadataContainer(metadata), dataProvider, billNoRecords);
                 break;
         }
     //});
 }
 private void Security(object payload, MetadataContainer metadata, DataProviderCommandSource dataProvider, DataProviderNoRecordState billNoRecords)
 {
     new RaisingSecurityFlagCommand(Guid.NewGuid(), _requestId,
         CommandDescriptions.SecurityDescription(dataProvider), payload.ObjectToJson(), dataProvider,
         DateTime.UtcNow, metadata.ObjectToJson(), Category.Security,billNoRecords)
         .SendToBus(_publisher, _log);
 }
 private void Configuring(object payload, MetadataContainer metadata, DataProviderCommandSource dataProvider, DataProviderNoRecordState billNoRecords)
 {
     new ConfiguringDataProviderCommand(Guid.NewGuid(), _requestId,
         CommandDescriptions.ConfigurationDescription(dataProvider), payload.ObjectToJson(), dataProvider,
         DateTime.UtcNow, metadata.ObjectToJson(), Category.Configuration,billNoRecords)
         .SendToBus(_publisher, _log);
 }