Ejemplo n.º 1
0
 public async static void WriteInProducerLogFile(string tenant, string product, string component, string topic, string producerName, string rowLog)
 {
     try
     {
         await File.AppendAllTextAsync(ProducerLocations.GetProducerStateWeekLogFile(tenant, product, component, topic, producerName), $"{rowLog}\n");
     }
     catch (Exception)
     {
         // TODO: handle this exception
     }
 }
Ejemplo n.º 2
0
        public static bool WriteProducerConfigFile(string tenant, string product, string component, string topic, Producer producer)
        {
            try
            {
                if (File.Exists(ProducerLocations.GetProducerConfigFile(tenant, product, component, topic, producer.Name)))
                {
                    File.Delete(ProducerLocations.GetProducerConfigFile(tenant, product, component, topic, producer.Name));
                }

                File.WriteAllText(ProducerLocations.GetProducerConfigFile(tenant, product, component, topic, producer.Name), producer.ToJsonAndEncrypt());
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Ejemplo n.º 3
0
 public bool TryCreateProducerDirectory(string tenant, string product, string component, string topic, Producer producer)
 {
     try
     {
         if (Directory.Exists(ProducerLocations.GetProducerDirectory(tenant, product, component, topic, producer.Name)) != true)
         {
             Directory.CreateDirectory(ProducerLocations.GetProducerDirectory(tenant, product, component, topic, producer.Name));
             Directory.CreateDirectory(ProducerLocations.GetProducerLogsDirectory(tenant, product, component, topic, producer.Name));
             producerLogsQueue.Enqueue(new ProducerLog()
             {
                 Tenant       = tenant,
                 Product      = product,
                 Component    = component,
                 Topic        = topic,
                 ProducerName = producer.Name,
                 Log          = $"{DateTime.Now:HH:mm:ss}|PRODUCER#|{producer.Name}|{producer.Id}|CREATED"
             });
             ProducerWriter.WriteProducerConfigFile(tenant, product, component, topic, producer);
             logger.LogInformation($"Producer '{producer.Name}' at {tenant}/{product}/{component}/{topic} is created");
         }