Exemplo n.º 1
0
 /// <summary>
 /// Definisce se fisicamente il servizio esiste
 /// </summary>
 /// <param name="filter"> </param>
 /// <param name="client"></param>
 /// <param name="logFolderPath"> </param>
 /// <returns></returns>
 public static string[] GetFiles(string logFolderPath, string filter, IFileRepositoryService client)
 {
     if (!string.IsNullOrEmpty(logFolderPath) && client != null)
     {
         var fileList = client.ListFiles(logFolderPath, filter);
         return(fileList.Select(storageFileInfo => storageFileInfo.Name).ToArray());
     }
     return(new DirectoryInfo(logFolderPath).GetFiles(filter).Select(fileInfo => fileInfo.Name).ToArray());
 }
Exemplo n.º 2
0
        public Configurator(string path, IFileRepositoryService client)
        {
            InitializeComponent();
            _liveUpdateClient = client;
            var isProtected = false;

            _currentConfiguration            = ConfigurationManagerHelper.LoadConfiguration(path, client, ref isProtected);
            _currentConfigurationIsProtected = isProtected;
        }
Exemplo n.º 3
0
 public LogMonitor(IFileRepositoryService liveUpdateClient)
 {
     _liveUpdateClient = liveUpdateClient;
     InitializeComponent();
     if (liveUpdateClient != null)
     {
         return;
     }
     LocalLogWatcher.SynchronizingObject = this;
     LocalLogWatcher.Changed            += FileWatcherChanged;
 }
Exemplo n.º 4
0
        /// <summary>
        /// Definisce se fisicamente il servizio esiste
        /// </summary>
        /// <param name="serviceName"></param>
        /// <param name="serviceFullPath"></param>
        /// <param name="client"></param>
        /// <returns></returns>
        public static bool Exists(string serviceName, string serviceFullPath, IFileRepositoryService client)
        {
            if (client != null && !string.IsNullOrEmpty(serviceFullPath))
            {
                return(client.ServiceStatus(serviceFullPath, serviceName).Exists);
            }
            var services = ServiceController.GetServices();
            var service  = services.FirstOrDefault(s => s.ServiceName == serviceName);

            return(File.Exists(serviceFullPath) && service != null);
        }
Exemplo n.º 5
0
        public static IJeepParameter ParamBuilder(IFileRepositoryService liveUpdateClient, string assembly, string classname, List <Parameter> parameters)
        {
            IJeepParameter item;

            try
            {
                Assembly myAssembly;
                if (liveUpdateClient != null)
                {
                    var assemblyStream = liveUpdateClient.GetFile(assembly);
                    using (var ms = new MemoryStream())
                    {
                        assemblyStream.CopyTo(ms);
                        myAssembly = Assembly.Load(ms.ToArray());
                    }
                }
                else
                {
                    myAssembly = Assembly.LoadFile(assembly);
                }

                if (String.IsNullOrEmpty(assembly))
                {
                    throw new FileNotFoundException("Impossibile trovare l'assembly relativo ai parametri del modulo.", assembly);
                }

                if (String.IsNullOrEmpty(classname))
                {
                    throw new ArgumentNullException("classname", "Classe dei parametri non specificata");
                }


                var instance = myAssembly.CreateInstance(classname, false, BindingFlags.CreateInstance, null, null, null, null);
                if (instance == null || !(instance is IJeepParameter))
                {
                    throw new ArgumentException("Impossibile istanziare la classe.");
                }

                item = (IJeepParameter)instance;
                if (parameters != null && parameters.Count > 0)
                {
                    item.Initialize(parameters);
                }
                else
                {
                    item.DefaultInitialization();
                }
            }
            catch (Exception exception)
            {
                item = new EmptyJeepParameter("Errore in caricamento parametri. Verificare il valore della classe del modulo e dei parametri.", exception, classname);
            }
            return(item);
        }
Exemplo n.º 6
0
 public static void SaveConfiguration(Configuration configuration, IFileRepositoryService client)
 {
     if (client != null)
     {
         client.SaveXmlConfiguration(new XmlConfigurationMessage {
             JeepConfig = configuration, JeepConfigPath = Settings.Default.JeepServiceConfig
         });
     }
     else
     {
         File.WriteAllText(Settings.Default.JeepServiceConfig, configuration.ToString());
     }
 }
        public static Configuration LoadConfiguration(string serviceFullPath, IFileRepositoryService client, ref bool isProtected)
        {
            if (client != null)
            {
                var retrievedConfig = client.LoadServiceConfiguration(serviceFullPath);
                isProtected = retrievedConfig.IsProtected;
                File.WriteAllBytes("JeepService.config", retrievedConfig.JeepServiceConfig);
                var map = new ExeConfigurationFileMap {
                    ExeConfigFilename = "JeepService.config"
                };
                return(ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None));
            }
            var currentConfiguration = ConfigurationManager.OpenExeConfiguration(serviceFullPath);

            isProtected = currentConfiguration.GetSection("appSettings").SectionInformation.IsProtected;
            return(currentConfiguration);
        }
Exemplo n.º 8
0
 public OrchestratorService(
     ILogger <OrchestratorService> logger,
     IValidationService validationService,
     IFileClassService classService,
     IFileQueryService queryService,
     IFileRepositoryService repositoryService,
     IFileServiceService serviceService,
     IFileValidatorService validatorService,
     IFileControllerService controllerService,
     IFileService fileService)
 {
     _logger            = logger ?? throw new ArgumentNullException(nameof(logger));
     _validationService = validationService ?? throw new ArgumentNullException(nameof(validationService));
     _classService      = classService ?? throw new ArgumentNullException(nameof(classService));
     _queryService      = queryService ?? throw new ArgumentNullException(nameof(queryService));
     _repositoryService = repositoryService ?? throw new ArgumentNullException(nameof(repositoryService));
     _serviceService    = serviceService ?? throw new ArgumentNullException(nameof(serviceService));
     _validatorService  = validatorService ?? throw new ArgumentNullException(nameof(validatorService));
     _controllerService = controllerService ?? throw new ArgumentNullException(nameof(controllerService));
     _fileService       = fileService ?? throw new ArgumentNullException(nameof(fileService));
 }
 public static void SaveConfiguration(Configuration configuration, IFileRepositoryService client, bool encrypt)
 {
     if (client != null)
     {
         configuration.Save(ConfigurationSaveMode.Full);
         var xmlConfiguration = File.ReadAllBytes("JeepService.config");
         File.Delete("JeepService.config");
         client.SaveServiceConfiguration(new ServiceConfigurationMessage {
             JeepServiceConfig = xmlConfiguration, JeepServicePath = Settings.Default.JeepServicePath
         }, encrypt);
     }
     else
     {
         if (encrypt)
         {
             EncryptConfigSection("appSettings", configuration);
         }
         else
         {
             DecryptConfigSection("appSettings", configuration);
         }
         configuration.Save(ConfigurationSaveMode.Full);
     }
 }
Exemplo n.º 10
0
 public CategoriesFileRepoService(IFileRepositoryService repositoryService, DatabaseContext db, IMapper mapper)
 {
     m_repositoryService = repositoryService;
     m_db     = db;
     m_mapper = mapper;
 }
Exemplo n.º 11
0
 /// <summary>
 /// Carica uno specifico file di Log
 /// </summary>
 /// <param name="logFilePath"></param>
 /// <param name="client"></param>
 /// <returns></returns>
 public static Stream GetFile(FileInfo logFilePath, IFileRepositoryService client)
 {
     return(client != null?client.GetFile(logFilePath.FullName) : File.Open(logFilePath.FullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite));
 }
Exemplo n.º 12
0
 public MIRController(IFileRepositoryService fileRepostoryService, IDropdownService dropDownService)
 {
     _fileRepositoryService = fileRepostoryService;
     _dropDownService       = dropDownService;
 }
Exemplo n.º 13
0
 public MIRController(IFileRepositoryService fileRepostoryService, IDropdownService dropDownService)
 {
     _fileRepositoryService = fileRepostoryService;
     _dropDownService = dropDownService;
 }
Exemplo n.º 14
0
 /// <summary>
 /// Definisce la versione del servizio
 /// </summary>
 /// <param name="serviceName"></param>
 /// <param name="serviceFullPath"></param>
 /// <param name="client"></param>
 /// <returns></returns>
 public static string ServiceVersion(string serviceName, string serviceFullPath, IFileRepositoryService client)
 {
     if (!string.IsNullOrEmpty(serviceFullPath) && client != null)
     {
         return(client.ServiceStatus(serviceFullPath, serviceName).Version);
     }
     if (File.Exists(serviceFullPath))
     {
         var serviceAssembly = Assembly.LoadFile(serviceFullPath);
         var serviceAssemblyFileVersioneInfo = FileVersionInfo.GetVersionInfo(serviceAssembly.Location);
         return(serviceAssemblyFileVersioneInfo.FileVersion);
     }
     return(string.Empty);
 }
Exemplo n.º 15
0
 /// <summary>
 /// Definisce lo status dello servizio
 /// </summary>
 /// <param name="serviceName"></param>
 /// <param name="serviceFullPath"></param>
 /// <param name="client"></param>
 /// <returns></returns>
 public static ServiceControllerStatus?ServiceStatus(string serviceName, string serviceFullPath, IFileRepositoryService client)
 {
     if (!string.IsNullOrEmpty(serviceFullPath) && client != null)
     {
         return(client.ServiceStatus(serviceFullPath, serviceName).Status);
     }
     if (File.Exists(serviceFullPath))
     {
         return(new ServiceController(serviceName).Status);
     }
     return(null);
 }
Exemplo n.º 16
0
        public static Configuration LoadConfiguration(string serviceConfigurationFullPath, IFileRepositoryService client)
        {
            if (client != null)
            {
                ConfigurationUtil.ModuleVersions = new Dictionary <string, string>();
                var configuration = client.LoadXmlConfiguration(serviceConfigurationFullPath).JeepConfig;
                // Per ogni modulo carico i dati relativi alla versione
                foreach (Module module in configuration.Modules)
                {
                    ConfigurationUtil.ModuleVersions.Add(module.Id, client.LoadModuleAssemblyProperties(module.FullAssemblyPath).Properties["FileVersion"]);
                }
                return(configuration);
            }

            if (!File.Exists(serviceConfigurationFullPath))
            {
                throw new FileNotFoundException("Impossibile trovare il file di configurazione JeepConfig.xml.", serviceConfigurationFullPath);
            }

            var serializer = new XmlSerializer(typeof(Configuration));

            using (Stream stream = new FileStream(serviceConfigurationFullPath, FileMode.Open))
            {
                return((Configuration)serializer.Deserialize(stream));
            }
        }