Exemplo n.º 1
0
        public GitHelper()
        {
            if (LOG.IsTraceEnabled)
            {
                LOG.InitTrace(nameof(GitHelper));
            }

            caminhoGit = ConfigurationManager.AppSettings[APP_SETTING_COMANDO_GIT];
            if (!string.IsNullOrEmpty(caminhoGit))
            {
                caminhoGit = $"\"{caminhoGit}\"";
            }

            if (LOG.IsDebugEnabled)
            {
                LOG.Debug($"{nameof(caminhoGit)}={caminhoGit}");
            }

            repositorio = ConfigurationManager.AppSettings[APP_SETTING_REPOSITORIO_GIT];
            if (!string.IsNullOrEmpty(repositorio))
            {
                repositorio = $"-C \"{repositorio}\"";
            }

            if (LOG.IsDebugEnabled)
            {
                LOG.Debug($"{nameof(repositorio)}={repositorio}");
            }

            if (LOG.IsTraceEnabled)
            {
                LOG.EndTrace(nameof(GitHelper));
            }
        }
Exemplo n.º 2
0
        public void CriarDiretorioQuandoNaoExistir(string caminho)
        {
            if (LOG.IsTraceEnabled)
            {
                LOG.InitTrace(nameof(CriarDiretorioQuandoNaoExistir), nameof(caminho), caminho);
            }

            bool ehCaminhoRede = caminho.StartsWith(INDICADOR_REDE);

            if (ehCaminhoRede)
            {
                caminho = caminho.Substring(INDICADOR_REDE.Length);
            }

            var partes = caminho.Split(SEPARADOR_DIRETORIO.ToCharArray());

            if (partes.Length == 0)
            {
                return; // sem separador
            }
            if (partes.Length == 1)
            {
                return; //diretório atual ou raiz
            }
            if (partes.Length == 2)
            {
                return; //diretório raiz e arquivo apenas
            }
            string parte  = (ehCaminhoRede ? $"{INDICADOR_REDE}{partes[0]}" : partes[0]);
            int    limite = partes.Length - 1;

            for (int i = 1; i < limite; i++)
            {
                if (partes[i].Contains(INDICADOR_BLOQUEIO_VALIDACAO))
                {
                    break;
                }

                parte = $"{parte}{SEPARADOR_DIRETORIO}{partes[i]}";
                if (!Directory.Exists(parte))
                {
                    Directory.CreateDirectory(parte);

                    if (LOG.IsDebugEnabled)
                    {
                        LOG.Debug($"Diretório criado: {parte}");
                    }
                }
            }

            if (LOG.IsTraceEnabled)
            {
                LOG.EndTrace(nameof(CriarDiretorioQuandoNaoExistir));
            }
        }
Exemplo n.º 3
0
        public DefaultSqlExporter()
        {
            if (LOG.IsTraceEnabled)
            {
                LOG.InitTrace(nameof(DefaultSqlExporter));
            }

            InterromperProcesso = false;

            helper       = SqlSettingHelper.GetInstance();
            fileUtils    = new FileUtils();
            tiposObjetos = new SqlTiposFabrica().ListarTipos();

            if (LOG.IsTraceEnabled)
            {
                LOG.EndTrace(nameof(DefaultSqlExporter));
            }
        }
        public void OnStart(string[] args)
        {
            if (LOG.IsTraceEnabled)
            {
                LOG.InitTrace(nameof(OnStart), nameof(args), args);
            }

            ExportacaoRealizada = false;

            temporizador           = new Timer();
            temporizador.Elapsed  += new ElapsedEventHandler(Processar);
            temporizador.AutoReset = true;
            temporizador.Interval  = PING_TIME;
            temporizador.Start();

            if (LOG.IsTraceEnabled)
            {
                LOG.EndTrace(nameof(OnStart));
            }
        }
Exemplo n.º 5
0
        private SqlSettingHelper()
        {
            if (LOG.IsTraceEnabled)
            {
                LOG.InitTrace(nameof(SqlExporterCore));
            }

            this.connectionString = ConfigurationManager.AppSettings[APP_SETTING_CONNECTION_STRING_BASE];
            this.localScriptBase  = ConfigurationManager.AppSettings[APP_SETTING_LOCAL_GERACAO_SCRIPT];

            string servidores = ConfigurationManager.AppSettings[APP_SETTING_NOME_SERVIDORES];

            this.servidores = this.StringToList(servidores);
            ConverterNomeServidores();

            string bancos = ConfigurationManager.AppSettings[APP_SETTING_NOME_BANCOS_DE_DADOS];

            this.bancos = this.StringToList(bancos);
            DescobrirLocaisScripts();

            try
            {
                var settingDias = int.Parse(ConfigurationManager.AppSettings[APP_SETTING_DIAS_ATUALIZACAO]);
                if (settingDias <= 0)
                {
                    diasAtualizacao = DEFAULT_DIAS_ATUALIZACAO;
                }
                else
                {
                    diasAtualizacao = -1 * settingDias;
                }
            }
            catch (Exception)
            {
                if (LOG.IsDebugEnabled)
                {
                    if (string.IsNullOrEmpty(ConfigurationManager.AppSettings[APP_SETTING_DIAS_ATUALIZACAO]))
                    {
                        LOG.Debug($"Configuração de número de dias ({APP_SETTING_DIAS_ATUALIZACAO}) com valor inválido: {ConfigurationManager.AppSettings[APP_SETTING_DIAS_ATUALIZACAO]}");
                    }
                }

                diasAtualizacao = DEFAULT_DIAS_ATUALIZACAO;
            }

            if (LOG.IsTraceEnabled)
            {
                LOG.EndTrace(nameof(SqlExporterCore));
            }
        }