Beispiel #1
0
        public void RefreshEnums(ExecutionLogInterface log, List <MetaSource> sources)
        {
            int           errorCount   = 0;
            StringBuilder errorSummary = new StringBuilder("");

            try
            {
                log.Log("Starting Refresh Enumerated Lists\r\n");

                foreach (MetaSource source in sources.OrderBy(i => i.Name))
                {
                    log.Log("Processing data source '{0}'", source.Name);
                    foreach (MetaEnum item in source.MetaData.Enums.OrderBy(i => i.Name).Where(i => i.IsDynamic && (i.IsEditable || i.IsDbRefresh)))
                    {
                        if (log.IsJobCancelled())
                        {
                            return;
                        }
                        log.LogNoCR("Refreshing Enum '{0}':", item.Name);
                        item.RefreshEnum(false);
                        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");
                            _setModified = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                log.Log("\r\n[UNEXPECTED ERROR RECEIVED]\r\n{0}\r\n", ex.Message);
            }
            log.Log("Refresh Enumerated Lists 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 !");
            }
        }
Beispiel #2
0
        void exportReportsTranslations(ExecutionLogInterface log, string folder, Repository repository, StringBuilder translations, string separator, string extraSeparators, int len)
        {
            foreach (string reportPath in Directory.GetFiles(folder, "*." + Repository.SealReportFileExtension))
            {
                try
                {
                    if (log.IsJobCancelled())
                    {
                        return;
                    }
                    Report report = Report.LoadFromFile(reportPath, repository);
                    translations.AppendFormat("ReportDisplayName{0}{1}{0}{2}{3}\r\n", separator, Helper.QuoteDouble(reportPath.Substring(len)), Helper.QuoteDouble(report.ExecutionName), extraSeparators);
                    foreach (var view in report.Views)
                    {
                        exportViewsTranslations(log, view, repository, translations, reportPath, separator, extraSeparators, len);
                    }
                    foreach (var output in report.Outputs)
                    {
                        translations.AppendFormat("ReportOutputName{0}{1}{0}{2}{3}\r\n", separator, Helper.QuoteDouble(reportPath.Substring(len)), Helper.QuoteDouble(output.Name), extraSeparators);
                    }
                }
                catch (Exception ex)
                {
                    log.LogRaw("ERROR loading report {0}\r\n", reportPath);
                    log.Log(ex.Message);
                }
            }

            foreach (string subFolder in Directory.GetDirectories(folder))
            {
                if (log.IsJobCancelled())
                {
                    return;
                }
                exportReportsTranslations(log, subFolder, repository, translations, separator, extraSeparators, len);
            }
        }
Beispiel #3
0
        public void SynchronizeSchedules(ExecutionLogInterface log, bool useCurrentUser)
        {
            int           count = 0, errorCount = 0, taskDeleted = 0;
            StringBuilder errorSummary = new StringBuilder("");

            Repository repository = Repository.Instance.CreateFast();

            try
            {
                log.Log("Starting Report Schedules Synchronization\r\n");

                if (!Helper.IsMachineAdministrator() && !useCurrentUser)
                {
                    log.Log("WARNING: For this tool, we recommend to execute the 'Server Manager' application with the option 'Run as administrator'\r\n");
                }

                SynchronizeSchedules(log, repository.ReportsFolder, repository, ref count, ref errorCount, errorSummary, useCurrentUser);
                log.Log("Checking personal folders\r\n");
                SynchronizeSchedules(log, repository.PersonalFolder, repository, ref count, ref errorCount, errorSummary, useCurrentUser);

                log.Log("Checking for Orphan schedules\r\n");

                if (repository.UseWebScheduler)
                {
                    SealReportScheduler.Instance.GetSchedules();
                }
                else
                {
                    TaskService taskService = new TaskService();
                    TaskFolder  taskFolder  = taskService.RootFolder.SubFolders.FirstOrDefault(i => i.Name == repository.Configuration.TaskFolderName);
                    if (taskFolder != null)
                    {
                        foreach (Task task in taskFolder.GetTasks())
                        {
                            log.Log("Checking task '{0}'", task.Name);
                            try
                            {
                                string reportPath   = ReportSchedule.GetTaskSourceDetail(task.Definition.RegistrationInfo.Source, 0);
                                string reportGUID   = ReportSchedule.GetTaskSourceDetail(task.Definition.RegistrationInfo.Source, 1);
                                string scheduleGUID = ReportSchedule.GetTaskSourceDetail(task.Definition.RegistrationInfo.Source, 3);
                                Report report       = ReportExecution.GetScheduledReport(taskFolder, reportPath, reportGUID, scheduleGUID, repository);
                                if (report != null)
                                {
                                    ReportSchedule schedule = ReportExecution.GetReportSchedule(taskFolder, report, scheduleGUID);
                                    if (schedule == null)
                                    {
                                        taskDeleted++;
                                        log.Log("WARNING: Unable to find schedule '{0}' in report '{1}'. Task has been deleted.", scheduleGUID, report.FilePath);
                                    }
                                }
                                else
                                {
                                    taskDeleted++;
                                    log.Log("WARNING: Unable to find report '{0}' for schedule '{1}'. Report tasks have been deleted.", reportGUID, scheduleGUID);
                                }
                            }
                            catch (Exception ex)
                            {
                                errorCount++;
                                log.LogRaw("ERROR\r\n");
                                log.Log(ex.Message);
                                errorSummary.AppendFormat("\r\nTask '{0}': {1}\r\n", task.Name, ex.Message);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                log.Log("\r\n[UNEXPECTED ERROR RECEIVED]\r\n{0}\r\n", ex.Message);
            }
            log.Log("Report Schedules Synchronization terminated\r\n");

            log.Log("SUMMARY: {0} Report(s) checked, {1} Task(s) deleted, {2} Error(s) detected.\r\n{3}", count, taskDeleted, errorCount, errorSummary);
            if (errorCount == 0)
            {
                log.Log("Youpi, pas d'erreur !");
            }
        }
Beispiel #4
0
        void SynchronizeSchedules(ExecutionLogInterface log, string folder, Repository repository, ref int count, ref int errorCount, StringBuilder errorSummary, bool useCurrentUser)
        {
            log.Log("Checking folder '{0}'", folder);
            foreach (string reportPath in Directory.GetFiles(folder, "*." + Repository.SealReportFileExtension))
            {
                try
                {
                    if (log.IsJobCancelled())
                    {
                        return;
                    }
                    count++;
                    Report report = Report.LoadFromFile(reportPath, repository, false);
                    report.SchedulesWithCurrentUser = useCurrentUser;
                    if (report.Schedules.Count > 0)
                    {
                        log.Log("Synchronizing schedules for report '{0}'", reportPath);
                        foreach (ReportSchedule schedule in report.Schedules)
                        {
                            if (log.IsJobCancelled())
                            {
                                return;
                            }
                            log.Log("Checking schedule '{0}'", schedule.Name);
                            try
                            {
                                Task task = schedule.FindTask();
                                if (task != null)
                                {
                                    schedule.SynchronizeTask();
                                }
                                else
                                {
                                    log.Log("Creating task for '{0}'", schedule.Name);
                                    schedule.SynchronizeTask();
                                }
                            }
                            catch (Exception ex)
                            {
                                errorCount++;
                                log.LogRaw("ERROR\r\n");
                                log.Log(ex.Message);
                                errorSummary.AppendFormat("\r\nReport '{0}' Schedule '{1}': {2}\r\n", reportPath, schedule.Name, ex.Message);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    errorCount++;
                    log.LogRaw("ERROR\r\n");
                    log.Log(ex.Message);
                    errorSummary.AppendFormat("\r\nReport '{0}': {1}\r\n", reportPath, ex.Message);
                }
            }

            foreach (string subFolder in Directory.GetDirectories(folder))
            {
                if (log.IsJobCancelled())
                {
                    return;
                }
                SynchronizeSchedules(log, subFolder, repository, ref count, ref errorCount, errorSummary, useCurrentUser);
            }

            log.LogRaw("\r\n");
        }
Beispiel #5
0
        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 !");
            }
        }
Beispiel #6
0
        public void SynchronizeSchedules(ExecutionLogInterface log, bool useCurrentUser)
        {
            int count = 0, errorCount = 0, taskDeleted = 0;
            StringBuilder errorSummary = new StringBuilder("");

            Repository repository = Repository.Instance.CreateFast();
            try
            {
                log.Log("Starting Report Schedules Synchronization\r\n");

                if (!Helper.IsMachineAdministrator() && !useCurrentUser) log.Log("WARNING: For this tool, we recommend to execute the 'Server Manager' application with the option 'Run as administrator'\r\n");

                SynchronizeSchedules(log, repository.ReportsFolder, repository, ref count, ref errorCount, errorSummary, useCurrentUser);

                log.Log("Checking for Orphan tasks\r\n");

                TaskService taskService = new TaskService();
                TaskFolder taskFolder = taskService.RootFolder.SubFolders.FirstOrDefault(i => i.Name == repository.Configuration.TaskFolderName);
                if (taskFolder != null)
                {
                    foreach (Task task in taskFolder.GetTasks())
                    {
                        log.Log("Checking task '{0}'", task.Name);
                        try
                        {
                            string reportPath = ReportSchedule.GetTaskSourceDetail(task.Definition.RegistrationInfo.Source, 0);
                            string reportGUID = ReportSchedule.GetTaskSourceDetail(task.Definition.RegistrationInfo.Source, 1);
                            string scheduleGUID = ReportSchedule.GetTaskSourceDetail(task.Definition.RegistrationInfo.Source, 3);
                            Report report = ReportExecution.GetScheduledReport(taskFolder, reportPath, reportGUID, scheduleGUID, repository);
                            if (report != null)
                            {
                                ReportSchedule schedule = ReportExecution.GetReportSchedule(taskFolder, report, scheduleGUID);
                                if (schedule == null)
                                {
                                    taskDeleted++;
                                    log.Log("WARNING: Unable to find schedule '{0}' in report '{1}'. Task has been deleted.", scheduleGUID, report.FilePath);
                                }
                            }
                            else
                            {
                                taskDeleted++;
                                log.Log("WARNING: Unable to find report '{0}' for schedule '{1}'. Report tasks have been deleted.", reportGUID, scheduleGUID);
                            }
                        }
                        catch (Exception ex)
                        {
                            errorCount++;
                            log.LogRaw("ERROR\r\n");
                            log.Log(ex.Message);
                            errorSummary.AppendFormat("\r\nTask '{0}': {1}\r\n", task.Name, ex.Message);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                log.Log("\r\n[UNEXPECTED ERROR RECEIVED]\r\n{0}\r\n", ex.Message);
            }
            log.Log("Report Schedules Synchronization terminated\r\n");

            log.Log("SUMMARY: {0} Report(s) checked, {1} Task(s) deleted, {2} Error(s) detected.\r\n{3}", count, taskDeleted, errorCount, errorSummary);
            if (errorCount == 0) log.Log("Youpi, pas d'erreur !");

        }
Beispiel #7
0
        void checkExecutions(ExecutionLogInterface log, string folder, Repository repository, ref int count, ref int errorCount, StringBuilder errorSummary)
        {
            log.Log("Checking folder '{0}'", folder);
            foreach (string reportPath in Directory.GetFiles(folder, "*." + Repository.SealReportFileExtension))
            {
                try
                {
                    if (log.IsJobCancelled())
                    {
                        return;
                    }
                    log.Log("Checking report '{0}'", reportPath);
                    count++;
                    Report report = Report.LoadFromFile(reportPath, repository);
                    report.CheckingExecution = true;
                    if (report.Tasks.Count > 0)
                    {
                        log.Log("Warning: Report Task executions are skipped.");
                    }
                    foreach (ReportView view in report.Views)
                    {
                        if (log.IsJobCancelled())
                        {
                            return;
                        }
                        log.Log("Running report with view '{0}'", view.Name);
                        try
                        {
                            report.CurrentViewGUID = view.GUID;
                            ReportExecution reportExecution = new ReportExecution()
                            {
                                Report = report
                            };
                            reportExecution.Execute();

                            int cnt = 120;
                            while (--cnt > 0 && report.IsExecuting && !log.IsJobCancelled())
                            {
                                Thread.Sleep(1000);
                            }

                            if (report.IsExecuting)
                            {
                                if (cnt == 0)
                                {
                                    log.Log("Warning: Report is running for more than 2 minutes. Cancelling the execution...");
                                }
                                report.CancelExecution();
                            }

                            if (!string.IsNullOrEmpty(report.ExecutionErrors))
                            {
                                throw new Exception(report.ExecutionErrors);
                            }
                            if (!string.IsNullOrEmpty(report.ExecutionView.Error))
                            {
                                throw new Exception(report.ExecutionView.Error);
                            }

                            report.RenderOnly = true;
                        }
                        catch (Exception ex)
                        {
                            errorCount++;
                            log.LogRaw("ERROR\r\n");
                            log.Log(ex.Message);
                            errorSummary.AppendFormat("\r\nReport '{0}' View '{1}': {2}\r\n", reportPath, view.Name, ex.Message);
                        }
                    }
                }
                catch (Exception ex)
                {
                    errorCount++;
                    log.LogRaw("ERROR\r\n");
                    log.Log(ex.Message);
                    errorSummary.AppendFormat("\r\nReport '{0}': {1}\r\n", reportPath, ex.Message);
                }
            }
            log.LogRaw("\r\n");

            foreach (string subFolder in Directory.GetDirectories(folder))
            {
                if (log.IsJobCancelled())
                {
                    return;
                }
                checkExecutions(log, subFolder, repository, ref count, ref errorCount, errorSummary);
            }
        }
Beispiel #8
0
        void SynchronizeSchedules(ExecutionLogInterface log, string folder, Repository repository, ref int count, ref int errorCount, StringBuilder errorSummary, bool useCurrentUser)
        {
            log.Log("Checking folder '{0}'", folder);
            foreach (string reportPath in Directory.GetFiles(folder, "*." + Repository.SealReportFileExtension))
            {
                try
                {
                    if (log.IsJobCancelled()) return;
                    count++;
                    Report report = Report.LoadFromFile(reportPath, repository);
                    report.SchedulesWithCurrentUser = useCurrentUser;
                    if (report.Schedules.Count > 0)
                    {
                        log.Log("Synchronizing schedules for report '{0}'", reportPath);
                        foreach (ReportSchedule schedule in report.Schedules)
                        {
                            if (log.IsJobCancelled()) return;
                            log.Log("Checking schedule '{0}'", schedule.Name);
                            try
                            {
                                Task task = schedule.FindTask();
                                if (task != null) schedule.SynchronizeTask();
                                else
                                {
                                    log.Log("Creating task for '{0}'", schedule.Name);
                                    schedule.SynchronizeTask();
                                }
                            }
                            catch (Exception ex)
                            {
                                errorCount++;
                                log.LogRaw("ERROR\r\n");
                                log.Log(ex.Message);
                                errorSummary.AppendFormat("\r\nReport '{0}' Schedule '{1}': {2}\r\n", reportPath, schedule.Name, ex.Message);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    errorCount++;
                    log.LogRaw("ERROR\r\n");
                    log.Log(ex.Message);
                    errorSummary.AppendFormat("\r\nReport '{0}': {1}\r\n", reportPath, ex.Message);
                }
            }

            foreach (string subFolder in Directory.GetDirectories(folder))
            {
                if (log.IsJobCancelled()) return;
                SynchronizeSchedules(log, subFolder, repository, ref count, ref errorCount, errorSummary, useCurrentUser);
            }

            log.LogRaw("\r\n");
        }
Beispiel #9
0
        void exportReportsTranslations(ExecutionLogInterface log, string folder, Repository repository, StringBuilder translations, string separator, string extraSeparators, int len)
        {
            foreach (string reportPath in Directory.GetFiles(folder, "*." + Repository.SealReportFileExtension))
            {
                try
                {
                    if (log.IsJobCancelled()) return;
                    Report report = Report.LoadFromFile(reportPath, repository);
                    translations.AppendFormat("ReportDisplayName{0}{1}{0}{2}{3}\r\n", separator, Helper.QuoteDouble(reportPath.Substring(len)), Helper.QuoteDouble(report.ExecutionName), extraSeparators);
                    foreach (var view in report.Views)
                    {
                        exportViewsTranslations(log, view, repository, translations, reportPath, separator, extraSeparators, len);
                    }
                    foreach (var output in report.Outputs)
                    {
                        translations.AppendFormat("ReportOutputName{0}{1}{0}{2}{3}\r\n", separator, Helper.QuoteDouble(reportPath.Substring(len)), Helper.QuoteDouble(output.Name), extraSeparators);
                    }
                }
                catch (Exception ex)
                {
                    log.LogRaw("ERROR loading report {0}\r\n", reportPath);
                    log.Log(ex.Message);
                }
            }

            foreach (string subFolder in Directory.GetDirectories(folder))
            {
                if (log.IsJobCancelled()) return;
                exportReportsTranslations(log, subFolder, repository, translations, separator, extraSeparators, len);
            }
        }
Beispiel #10
0
        void checkExecutions(ExecutionLogInterface log, string folder, Repository repository, ref int count, ref int errorCount, StringBuilder errorSummary)
        {
            log.Log("Checking folder '{0}'", folder);
            foreach (string reportPath in Directory.GetFiles(folder, "*." + Repository.SealReportFileExtension))
            {
                try
                {
                    if (log.IsJobCancelled()) return;
                    log.Log("Checking report '{0}'", reportPath);
                    count++;
                    Report report = Report.LoadFromFile(reportPath, repository);
                    report.CheckingExecution = true;
                    if (report.Tasks.Count > 0) log.Log("Warning: Report Task executions are skipped.");
                    foreach (ReportView view in report.Views)
                    {
                        if (log.IsJobCancelled()) return;
                        log.Log("Running report with view '{0}'", view.Name);
                        try
                        {
                            report.CurrentViewGUID = view.GUID;
                            ReportExecution reportExecution = new ReportExecution() { Report = report };
                            reportExecution.Execute();

                            int cnt = 120;
                            while (--cnt > 0 && report.IsExecuting && !log.IsJobCancelled())
                            {
                                Thread.Sleep(1000);
                            }

                            if (report.IsExecuting)
                            {
                                if (cnt == 0) log.Log("Warning: Report is running for more than 2 minutes. Cancelling the execution...");
                                report.CancelExecution();
                            }

                            if (!string.IsNullOrEmpty(report.ExecutionErrors)) throw new Exception(report.ExecutionErrors);
                            if (!string.IsNullOrEmpty(report.ExecutionView.Error)) throw new Exception(report.ExecutionView.Error);

                            report.RenderOnly = true;
                        }
                        catch (Exception ex)
                        {
                            errorCount++;
                            log.LogRaw("ERROR\r\n");
                            log.Log(ex.Message);
                            errorSummary.AppendFormat("\r\nReport '{0}' View '{1}': {2}\r\n", reportPath, view.Name, ex.Message);
                        }
                    }
                }
                catch (Exception ex)
                {
                    errorCount++;
                    log.LogRaw("ERROR\r\n");
                    log.Log(ex.Message);
                    errorSummary.AppendFormat("\r\nReport '{0}': {1}\r\n", reportPath, ex.Message);
                }
            }
            log.LogRaw("\r\n");

            foreach (string subFolder in Directory.GetDirectories(folder))
            {
                if (log.IsJobCancelled()) return;
                checkExecutions(log, subFolder, repository, ref count, ref errorCount, errorSummary);
            }
        }
Beispiel #11
0
        public void RefreshEnums(ExecutionLogInterface log, List<MetaSource> sources)
        {
            int errorCount = 0;
            StringBuilder errorSummary = new StringBuilder("");
            try
            {
                log.Log("Starting Refresh Enumerated Lists\r\n");

                foreach (MetaSource source in sources.OrderBy(i => i.Name))
                {
                    log.Log("Processing data source '{0}'", source.Name);
                    foreach (MetaEnum item in source.MetaData.Enums.OrderBy(i => i.Name).Where(i => i.IsDynamic && (i.IsEditable || i.IsDbRefresh)))
                    {
                        if (log.IsJobCancelled()) return;
                        log.LogNoCR("Refreshing Enum '{0}':", item.Name);
                        item.RefreshEnum(false);
                        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");
                            _setModified = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                log.Log("\r\n[UNEXPECTED ERROR RECEIVED]\r\n{0}\r\n", ex.Message);
            }
            log.Log("Refresh Enumerated Lists 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 !");
        }
Beispiel #12
0
        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 !");
            }
        }