Seal.Forms.ToolsHelper.CheckDataSources C# (CSharp) Méthode

CheckDataSources() public méthode

public CheckDataSources ( ExecutionLogInterface log, List sources ) : void
log ExecutionLogInterface
sources List
Résultat void
        public void CheckDataSources(ExecutionLogInterface log, List<MetaSource> sources)
        {
            int errorCount = 0;
            StringBuilder errorSummary = new StringBuilder("");
            try
            {
                log.Log("Starting check Data Sources\r\n");

                foreach (MetaSource source in sources.OrderBy(i => i.Name))
                {
                    if (log.IsJobCancelled()) return;
                    log.Log("Checking data source '{0}'", source.Name);

                    log.Log("Checking Connections...");
                    int cnt = 0;
                    foreach (MetaConnection item in source.Connections.OrderBy(i => i.Name))
                    {
                        if (source.IsNoSQL && !item.ConnectionString.ToLower().Contains("provider=")) continue;

                        if (log.IsJobCancelled()) return;
                        log.LogNoCR("Checking connection '{0}':", item.Name);
                        item.CheckConnection();
                        cnt++;
                        if (!string.IsNullOrEmpty(item.Error))
                        {
                            errorCount++;
                            log.LogRaw("ERROR\r\n");
                            log.Log(item.Error);
                            errorSummary.AppendFormat("\r\n[{2}] Connection '{0}': {1}\r\n", item.Name, item.Error, source.Name);
                        }
                        else log.LogRaw("OK\r\n");
                    }
                    log.Log("Connections: {0} Connection(s) checked\r\n", cnt);

                    log.Log("Checking Tables...");
                    foreach (MetaTable item in source.MetaData.Tables.OrderBy(i => i.Name))
                    {
                        if (log.IsJobCancelled()) return;
                        log.LogNoCR("Checking table '{0}':", item.DisplayName);
                        item.CheckTable(null);
                        if (!string.IsNullOrEmpty(item.Error))
                        {
                            errorCount++;
                            log.LogRaw("ERROR\r\n");
                            log.Log(item.Error);
                            errorSummary.AppendFormat("\r\n[{2}] Table '{0}': {1}\r\n", item.DisplayName, item.Error, source.Name);
                        }
                        else log.LogRaw("OK\r\n");
                    }
                    log.Log("Tables: {0} Table(s) checked\r\n", source.MetaData.Tables.Count);

                    log.Log("Checking Joins...");
                    foreach (MetaJoin item in source.MetaData.Joins.OrderBy(i => i.Name))
                    {
                        if (log.IsJobCancelled()) return;
                        log.LogNoCR("Checking Join '{0}':", item.Name);
                        item.CheckJoin();
                        if (!string.IsNullOrEmpty(item.Error))
                        {
                            errorCount++;
                            log.LogRaw("ERROR\r\n");
                            log.Log(item.Error);
                            errorSummary.AppendFormat("\r\n[{2}] Join '{0}': {1}\r\n", item.Name, item.Error, source.Name);
                        }
                        else log.LogRaw("OK\r\n");
                    }
                    log.Log("Joins: {0} Join(s) checked\r\n", source.MetaData.Joins.Count);

                    log.Log("Checking Enums...");
                    foreach (MetaEnum item in source.MetaData.Enums.OrderBy(i => i.Name))
                    {
                        if (log.IsJobCancelled()) return;
                        log.LogNoCR("Checking Enum '{0}':", item.Name);
                        item.RefreshEnum(true);
                        if (!string.IsNullOrEmpty(item.Error))
                        {
                            errorCount++;
                            log.LogRaw("ERROR\r\n");
                            log.Log(item.Error);
                            errorSummary.AppendFormat("\r\n[{2}] Enum '{0}': {1}\r\n", item.Name, item.Error, source.Name);
                        }
                        else log.LogRaw("OK\r\n");
                    }
                    log.Log("Enums: {0} Enum(s) checked\r\n", source.MetaData.Enums.Count);
                }

                log.Log("{0} Data Source(s) checked\r\n", sources.Count);

            }
            catch (Exception ex)
            {
                log.Log("\r\n[UNEXPECTED ERROR RECEIVED]\r\n{0}\r\n", ex.Message);
            }
            log.Log("Check Data Sources terminated\r\n");

            if (errorCount > 0)
            {
                log.Log("SUMMARY: {0} Error(s) detected.\r\n{1}", errorCount, errorSummary);
            }
            else
            {
                log.Log("Youpi, pas d'erreur !");
            }
        }