Esempio n. 1
0
        public void ExportReportsTranslations(ExecutionLogInterface log)
        {
            Repository    repository   = Repository.Instance.CreateFast();
            StringBuilder translations = new StringBuilder();

            try
            {
                log.Log("Starting the export of the Folders and Reports translations\r\n");
                string separator       = System.Globalization.CultureInfo.CurrentCulture.TextInfo.ListSeparator;
                string extraSeparators = initTranslationFile(translations, separator, repository);

                log.Log("Adding folder names in context: FolderName, FolderPath\r\n");
                exportFolderNamesTranslations(repository.ReportsFolder, translations, separator, extraSeparators, repository.ReportsFolder.Length);

                log.Log("Adding file names in context: FileName\r\n");
                exportReportNamesTranslations(repository.ReportsFolder, translations, separator, extraSeparators, repository.ReportsFolder.Length);

                log.Log("Adding report names in context: ReportExecutionName, ReportViewName, ReportOutputName\r\n");
                exportReportsTranslations(log, repository.ReportsFolder, repository, translations, separator, extraSeparators, repository.ReportsFolder.Length);

                string fileName = FileHelper.GetUniqueFileName(Path.Combine(repository.SettingsFolder, "FoldersReportsTranslations_WORK.csv"));
                File.WriteAllText(fileName, translations.ToString(), Encoding.UTF8);

                log.Log("\r\nExport of the Folders and Reports translations terminated.\r\n\r\nThe file has been saved to '{0}' and can be re-worked and merged with the repository translations file.\r\n\r\nNote that the effective repository translations file is 'RepositoryTranslations.csv' in the Repository Sub-Folder 'Settings'.", fileName);

                Process.Start(fileName);
            }
            catch (Exception ex)
            {
                log.Log("\r\n[UNEXPECTED ERROR RECEIVED]\r\n{0}\r\n", ex.Message);
            }
        }
Esempio n. 2
0
        public void CheckExecutions(ExecutionLogInterface log)
        {
            int           count = 0, errorCount = 0;
            StringBuilder errorSummary = new StringBuilder("");

            Repository repository = Repository.Instance.CreateFast();

            try
            {
                log.Log("Starting Check Report Executions\r\n");
                checkExecutions(log, repository.ReportsFolder, repository, ref count, ref errorCount, errorSummary);
                log.Log("Checking personal folders\r\n");
                checkExecutions(log, repository.PersonalFolder, repository, ref count, ref errorCount, errorSummary);
            }
            catch (Exception ex)
            {
                log.Log("\r\n[UNEXPECTED ERROR RECEIVED]\r\n{0}\r\n", ex.Message);
            }
            log.Log("Check Report Executions terminated\r\n");

            log.Log("SUMMARY: {0} Report(s) checked, {1} Error(s) detected.\r\n{2}", count, errorCount, errorSummary);
            if (errorCount == 0)
            {
                log.Log("Youpi, pas d'erreur !");
            }
        }
Esempio n. 3
0
 void exportViewsTranslations(ExecutionLogInterface log, ReportView view, Repository repository, StringBuilder translations, string reportPath, string separator, string extraSeparators, int len)
 {
     translations.AppendFormat("ReportViewName{0}{1}{0}{2}{3}\r\n", separator, Helper.QuoteDouble(reportPath.Substring(len)), Helper.QuoteDouble(view.Name), extraSeparators);
     foreach (var child in view.Views)
     {
         exportViewsTranslations(log, child, repository, translations, reportPath, separator, extraSeparators, len);
     }
 }
Esempio n. 4
0
        public void ExportSourceTranslations(ExecutionLogInterface log)
        {
            Repository    repository   = Repository.Instance.CreateFast();
            StringBuilder translations = new StringBuilder();

            try
            {
                log.Log("Starting the export of the Data Source translations for '{0}'\r\n", Source.Name);
                string separator       = System.Globalization.CultureInfo.CurrentCulture.TextInfo.ListSeparator;
                string extraSeparators = initTranslationFile(translations, separator, repository);

                log.Log("Adding elements names in context: Element\r\n");
                foreach (var table in Source.MetaData.Tables)
                {
                    foreach (var element in table.Columns)
                    {
                        translations.AppendFormat("Element{0}{1}{0}{2}{3}\r\n", separator, Helper.QuoteDouble(element.Category + '.' + element.DisplayName), Helper.QuoteDouble(element.DisplayName), extraSeparators);
                    }
                }

                log.Log("Adding enum values in context: Enum\r\n");
                foreach (var enumList in Source.MetaData.Enums.Where(i => i.Translate))
                {
                    foreach (var enumVal in enumList.Values)
                    {
                        translations.AppendFormat("Enum{0}{1}{0}{2}{3}\r\n", separator, Helper.QuoteDouble(enumList.Name), Helper.QuoteDouble(enumVal.DisplayValue), extraSeparators);
                        if (enumVal.DisplayValue != enumVal.DisplayRestriction)
                        {
                            translations.AppendFormat("Enum{0}{1}{0}{2}{3}\r\n", separator, Helper.QuoteDouble(enumList.Name), Helper.QuoteDouble(enumVal.DisplayRestriction), extraSeparators);
                        }
                    }
                }

                log.Log("Adding Sub-Report names in context: SubReport\r\n");
                foreach (var table in Source.MetaData.Tables)
                {
                    foreach (var element in table.Columns)
                    {
                        foreach (var subReport in element.SubReports)
                        {
                            translations.AppendFormat("SubReport{0}{1}{0}{2}{3}\r\n", separator, Helper.QuoteDouble(element.Category + '.' + element.DisplayName), subReport.Name, extraSeparators);
                        }
                    }
                }

                string fileName = FileHelper.GetUniqueFileName(Path.Combine(repository.SettingsFolder, Helper.CleanFileName(string.Format("RepositoryTranslations_{0}_WORK.csv", Source.Name))));
                File.WriteAllText(fileName, translations.ToString(), Encoding.UTF8);

                log.Log("\r\nExport of the Data Source translations terminated.\r\n\r\nThe file has been saved to '{0}' and can be re-worked and merged with the repository translations file.\r\n\r\nNote that the effective repository translations file is 'RepositoryTranslations.csv' in the Repository Sub-Folder 'Settings'.", fileName);

                Process.Start(fileName);
            }
            catch (Exception ex)
            {
                log.Log("\r\n[UNEXPECTED ERROR RECEIVED]\r\n{0}\r\n", ex.Message);
            }
        }
Esempio n. 5
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 !");
            }
        }
Esempio n. 6
0
        public void ExportReportsTranslations(ExecutionLogInterface log)
        {
            Repository    repository   = Repository.Instance.CreateFast();
            StringBuilder translations = new StringBuilder();

            try
            {
                log.Log("Starting the export of the Folders and Reports translations\r\n");
                string separator       = System.Globalization.CultureInfo.CurrentCulture.TextInfo.ListSeparator;
                string extraSeparators = initTranslationFile(translations, separator, repository);

                log.Log("Adding folder names in context: FolderName, FolderPath\r\n");
                exportFolderNamesTranslations(repository.ReportsFolder, translations, separator, extraSeparators, repository.ReportsFolder.Length);

                log.Log("Adding file names in context: FileName\r\n");
                exportReportNamesTranslations(repository.ReportsFolder, translations, separator, extraSeparators, repository.ReportsFolder.Length);

                log.Log("Adding report names in context: ReportExecutionName, ReportViewName, ReportOutputName, WidgetName, WidgetDescription\r\n");
                exportReportsTranslations(log, repository.ReportsFolder, repository, translations, separator, extraSeparators, repository.ReportsFolder.Length);

                log.Log("Adding dashboard folders in context: DashboardFolder\r\n");
                foreach (var folder in Directory.GetDirectories(repository.DashboardPublicFolder))
                {
                    translations.AppendFormat("DashboardFolder{0}{1}{0}{2}{3}\r\n", separator, Helper.QuoteDouble(folder.Substring(repository.DashboardPublicFolder.Length)), Helper.QuoteDouble(Path.GetFileName(folder)), extraSeparators);
                }

                log.Log("Adding dashboard names in context: DashboardName\r\n");
                foreach (var folder in Directory.GetDirectories(repository.DashboardPublicFolder))
                {
                    foreach (var p in Directory.GetFiles(folder, "*." + Repository.SealDashboardExtension))
                    {
                        var dashboard = Dashboard.LoadFromFile(p);
                        translations.AppendFormat("DashboardName{0}{1}{0}{2}{3}\r\n", separator, Helper.QuoteDouble(p.Substring(repository.DashboardPublicFolder.Length)), Helper.QuoteDouble(dashboard.Name), extraSeparators);
                    }
                }

                string fileName = FileHelper.GetUniqueFileName(Path.Combine(repository.SettingsFolder, "FoldersReportsTranslations_WORK.csv"));
                File.WriteAllText(fileName, translations.ToString(), Encoding.UTF8);

                log.Log("\r\nExport of the Folders and Reports translations terminated.\r\n\r\nThe file has been saved to '{0}' and can be re-worked and merged with the repository translations file.\r\n\r\nNote that the effective repository translations file is 'RepositoryTranslations.csv' in the Repository Sub-Folder 'Settings'.", fileName);

                Process.Start(fileName);
            }
            catch (Exception ex)
            {
                log.Log("\r\n[UNEXPECTED ERROR RECEIVED]\r\n{0}\r\n", ex.Message);
            }
        }
Esempio n. 7
0
 void exportViewsTranslations(ExecutionLogInterface log, ReportView view, Repository repository, StringBuilder translations, string reportPath, string separator, string extraSeparators, int len)
 {
     translations.AppendFormat("ReportViewName{0}{1}{0}{2}{3}\r\n", separator, Helper.QuoteDouble(reportPath.Substring(len)), Helper.QuoteDouble(view.Name), extraSeparators);
     if (view.WidgetDefinition.IsPublished)
     {
         translations.AppendFormat("WidgetName{0}{1}{0}{2}{3}\r\n", separator, Helper.QuoteDouble(reportPath.Substring(len)), Helper.QuoteDouble(view.WidgetDefinition.Name), extraSeparators);
         if (!string.IsNullOrEmpty(view.WidgetDefinition.Description))
         {
             translations.AppendFormat("WidgetDescription{0}{1}{0}{2}{3}\r\n", separator, Helper.QuoteDouble(reportPath.Substring(len)), Helper.QuoteDouble(view.WidgetDefinition.Description), extraSeparators);
         }
     }
     foreach (var child in view.Views)
     {
         exportViewsTranslations(log, child, repository, translations, reportPath, separator, extraSeparators, len);
     }
 }
Esempio n. 8
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);
            }
        }
Esempio n. 9
0
        public void ViewWidgetsList(ExecutionLogInterface log)
        {
            Repository    repository   = Repository.Instance.CreateFast();
            StringBuilder translations = new StringBuilder();

            try
            {
                DashboardWidgetsPool.ForceReload();

                log.Log("Building the list of Published Widgets in the repository...\r\n");
                foreach (var path in (from w in DashboardWidgetsPool.Widgets.Values select w.ReportPath).Distinct().OrderBy(i => i))
                {
                    if (log.IsJobCancelled())
                    {
                        return;
                    }

                    Report        report  = Report.LoadFromFile(repository.ReportsFolder + path, repository, false);
                    StringBuilder summary = new StringBuilder();
                    foreach (var view in report.GetWidgetViews())
                    {
                        summary.AppendFormat("Widget '{0}' in View '{1}' of Type '{2}'\r\n", view.WidgetDefinition.Name, view.Name, view.TemplateName);
                    }
                    log.Log("Report: '{0}' ({1}):\r\n{2}", report.ExecutionName, path, summary);
                }

                if (DashboardWidgetsPool.Widgets.Count == 0)
                {
                    log.Log("No Widget published in this repository.\r\n");
                }
            }
            catch (Exception ex)
            {
                log.Log("\r\n[UNEXPECTED ERROR RECEIVED]\r\n{0}\r\n", ex.Message);
            }
        }
Esempio n. 10
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);
            }
        }
Esempio n. 11
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");
        }
Esempio n. 12
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 !");
        }
Esempio n. 13
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 !");
            }
        }
Esempio n. 14
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);
            }
        }
Esempio n. 15
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 !");
            }
        }
Esempio n. 16
0
 void exportViewsTranslations(ExecutionLogInterface log, ReportView view, Repository repository, StringBuilder translations, string reportPath, string separator, string extraSeparators, int len)
 {
     translations.AppendFormat("ReportViewName{0}{1}{0}{2}{3}\r\n", separator, Helper.QuoteDouble(reportPath.Substring(len)), Helper.QuoteDouble(view.Name), extraSeparators);
     foreach (var child in view.Views)
     {
         exportViewsTranslations(log, child, repository, translations, reportPath, separator, extraSeparators, len);
     }
 }
Esempio n. 17
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);
            }
        }
Esempio n. 18
0
        public void CheckExecutions(ExecutionLogInterface log)
        {
            int count = 0, errorCount = 0;
            StringBuilder errorSummary = new StringBuilder("");

            Repository repository = Repository.Instance.CreateFast();
            try
            {
                log.Log("Starting Check Report Executions\r\n");
                checkExecutions(log, repository.ReportsFolder, repository, ref count, ref errorCount, errorSummary);
            }
            catch (Exception ex)
            {
                log.Log("\r\n[UNEXPECTED ERROR RECEIVED]\r\n{0}\r\n", ex.Message);
            }
            log.Log("Check Report Executions terminated\r\n");

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

        }
Esempio n. 19
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 !");
            }
        }
        void publish(ExecutionLogInterface log, bool filesOnly)
        {
            log.Log("Starting Web Site Publishing...");
            _publicationInError = false;
            try
            {
                string publicationDirectory = _configuration.WebPublicationDirectory;
                string sourceDirectory      = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), _configuration.WebNETCore ? "NETCore" : "Web.Net");
#if DEBUG
                sourceDirectory = Path.GetDirectoryName(Application.ExecutablePath) + @"\..\..\..\..\SealWebServer\";
                if (_configuration.WebNETCore)
                {
                    sourceDirectory = Path.GetDirectoryName(Application.ExecutablePath) + @"\..\..\..\..\..\Projects.NETCore\SealWebServer\bin\Release\netcoreapp3.1\publish\";
                }
#endif

                //Copy installation directory
                log.Log("Copying files from '{0}' to '{1}'", sourceDirectory, publicationDirectory);
                FileHelper.CopyDirectory(sourceDirectory, publicationDirectory, true);

                //Check config...
                var currentConfig = Path.Combine(publicationDirectory, _configuration.WebNETCore ? "appsettings.json" : "web.config");
                var releaseConfig = Path.Combine(publicationDirectory, _configuration.WebNETCore ? "appsettings.Release.json" : "web.release.config");
                if (!File.Exists(currentConfig) && File.Exists(releaseConfig))
                {
                    log.Log("Creating Config file from '{0}'", releaseConfig);
                    //Replace repository path
                    var configText = File.ReadAllText(releaseConfig);
                    if (_configuration.WebNETCore)
                    {
                        configText = configText.Replace("\"RepositoryPath\": \"\",", string.Format("\"RepositoryPath\": \"{0}\",", _configuration.Repository.RepositoryPath.Replace("\\", "\\\\")));
                    }
                    else
                    {
                        configText = configText.Replace(@"C:\ProgramData\Seal Report Repository", _configuration.Repository.RepositoryPath);
                    }
                    File.WriteAllText(currentConfig, configText);
                }

                if (!filesOnly && !log.IsJobCancelled())
                {
                    log.Log("Publishing Site on IIS...");

                    Microsoft.Web.Administration.ServerManager serverMgr = new Microsoft.Web.Administration.ServerManager();
                    Microsoft.Web.Administration.Site          site      = null;
                    if (serverMgr.Sites.Count == 0)
                    {
                        log.Log("Creating Default Web Site");
                        site = serverMgr.Sites.Add("Default Web Site", "C:\\inetpub\\wwwroot", 80);
                    }
                    else
                    {
                        site = serverMgr.Sites[0];
                    }

                    Microsoft.Web.Administration.ApplicationPool pool = serverMgr.ApplicationPools.FirstOrDefault(i => i.Name == _configuration.WebApplicationPoolName);
                    if (pool == null)
                    {
                        log.Log("Creating Application Pool");
                        pool = serverMgr.ApplicationPools.Add(_configuration.WebApplicationPoolName);
                    }
                    pool.ManagedRuntimeVersion = _configuration.WebNETCore ?  "" : "v4.0";
                    if (Marshal.SizeOf(typeof(IntPtr)) != 8)
                    {
                        pool.Enable32BitAppOnWin64 = true;                                      //Test if 32bit
                    }
                    pool.ProcessModel.IdentityType = Microsoft.Web.Administration.ProcessModelIdentityType.LocalSystem;

                    if (string.IsNullOrEmpty(_configuration.WebApplicationName))
                    {
                        _configuration.WebApplicationName = "/";
                    }
                    var application = site.Applications.FirstOrDefault(i => i.Path == _configuration.WebApplicationName);
                    if (application == null)
                    {
                        log.Log("Creating Application");
                        application = site.Applications.Add(_configuration.WebApplicationName, _configuration.WebPublicationDirectory);
                    }
                    if (_configuration.WebApplicationName == "/")
                    {
                        Microsoft.Web.Administration.VirtualDirectory vDir = application.VirtualDirectories[0];
                        vDir.Path         = _configuration.WebApplicationName;
                        vDir.PhysicalPath = _configuration.WebPublicationDirectory;
                    }
                    application.ApplicationPoolName = _configuration.WebApplicationPoolName;
                    if (!log.IsJobCancelled())
                    {
                        serverMgr.CommitChanges();
                    }
                    log.Log("Web Site has been published successfully.");
                }
            }
            catch (Exception ex)
            {
                _publicationInError = true;
                log.Log("\r\n[UNEXPECTED ERROR RECEIVED]\r\n{0}\r\n", ex.Message);
                if (ex.InnerException != null)
                {
                    log.Log("{0}\r\n", ex.InnerException.Message);
                }
            }
            log.Log("Web Site Publishing terminated.");
            if (log.IsJobCancelled())
            {
                log.Log("Publication has been cancelled.");
            }
        }
        void publish(ExecutionLogInterface log, bool filesOnly)
        {
            log.Log("Starting Web Site Publishing...");
            _publicationInError = false;
            try
            {
                string publicationDirectory = _configuration.WebPublicationDirectory;
                string sourceDirectory = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "Web");
            #if DEBUG
                sourceDirectory = Path.GetDirectoryName(Application.ExecutablePath) + @"\..\..\..\SealWebServer\";
            #endif

                //Copy installation directory
                log.Log("Copying files from '{0}' to '{1}'", sourceDirectory, publicationDirectory);
                FileHelper.CopyDirectory(sourceDirectory, publicationDirectory, true);

                //Check web config...
                if (!File.Exists(Path.Combine(publicationDirectory, "web.config")) && File.Exists(Path.Combine(publicationDirectory, "web.release.config")))
                {
                    log.Log("Creating web.config file");
                    File.Copy(Path.Combine(publicationDirectory, "web.release.config"), Path.Combine(publicationDirectory, "web.config"));
                }

                if (!filesOnly && !log.IsJobCancelled())
                {
                    log.Log("Publishing Site on IIS...");

                    Microsoft.Web.Administration.ServerManager serverMgr = new Microsoft.Web.Administration.ServerManager();
                    Microsoft.Web.Administration.Site site = null;
                    if (serverMgr.Sites.Count == 0)
                    {
                        log.Log("Creating Default Web Site");
                        site = serverMgr.Sites.Add("Default Web Site", "C:\\inetpub\\wwwroot", 80);
                    }
                    else site = serverMgr.Sites[0];

                    Microsoft.Web.Administration.ApplicationPool pool = serverMgr.ApplicationPools.FirstOrDefault(i => i.Name == _configuration.WebApplicationPoolName);
                    if (pool == null)
                    {
                        log.Log("Creating Application Pool");
                        pool = serverMgr.ApplicationPools.Add(_configuration.WebApplicationPoolName);
                    }
                    pool.ManagedRuntimeVersion = "v4.0";
                    pool.Enable32BitAppOnWin64 = true;
                    pool.ProcessModel.IdentityType = Microsoft.Web.Administration.ProcessModelIdentityType.LocalSystem;

                    Microsoft.Web.Administration.Application application = site.Applications.FirstOrDefault(i => i.Path == _configuration.WebApplicationName);
                    if (application == null)
                    {
                        log.Log("Creating Application");
                        application = site.Applications.Add(_configuration.WebApplicationName, _configuration.WebPublicationDirectory);
                    }
                    application.ApplicationPoolName = _configuration.WebApplicationPoolName;
                    if (!log.IsJobCancelled())
                    {
                        serverMgr.CommitChanges();
                    }
                    log.Log("Web Site has been published successfully.");
                }
            }
            catch (Exception ex)
            {
                _publicationInError = true;
                log.Log("\r\n[UNEXPECTED ERROR RECEIVED]\r\n{0}\r\n", ex.Message);
                if (ex.InnerException != null) log.Log("{0}\r\n", ex.InnerException.Message);
            }
            log.Log("Web Site Publishing terminated.");
            if (log.IsJobCancelled()) log.Log("Publication has been cancelled.");
        }
Esempio n. 22
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 !");

        }
Esempio n. 23
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");
        }
Esempio n. 24
0
        public void ExportReportsTranslations(ExecutionLogInterface log)
        {
            Repository repository = Repository.Instance.CreateFast();
            StringBuilder translations = new StringBuilder();
            try
            {
                log.Log("Starting the export of the Folders and Reports translations\r\n");
                string separator = System.Globalization.CultureInfo.CurrentCulture.TextInfo.ListSeparator;
                string extraSeparators = initTranslationFile(translations, separator, repository);

                log.Log("Adding folder names in context: FolderName, FolderPath\r\n");
                exportFolderNamesTranslations(repository.ReportsFolder, translations, separator, extraSeparators, repository.ReportsFolder.Length);

                log.Log("Adding file names in context: FileName\r\n");
                exportReportNamesTranslations(repository.ReportsFolder, translations, separator, extraSeparators, repository.ReportsFolder.Length);

                log.Log("Adding report names in context: ReportExecutionName, ReportViewName, ReportOutputName\r\n");
                exportReportsTranslations(log, repository.ReportsFolder, repository, translations, separator, extraSeparators, repository.ReportsFolder.Length);

                string fileName = FileHelper.GetUniqueFileName(Path.Combine(repository.SettingsFolder, "FoldersReportsTranslations_WORK.csv"));
                File.WriteAllText(fileName, translations.ToString(), Encoding.UTF8);

                log.Log("\r\nExport of the Folders and Reports translations terminated.\r\n\r\nThe file has been saved to '{0}' and can be re-worked and merged with the repository translations file.\r\n\r\nNote that the effective repository translations file is 'RepositoryTranslations.csv' in the Repository Sub-Folder 'Settings'.", fileName);

                Process.Start(fileName);
            }
            catch (Exception ex)
            {
                log.Log("\r\n[UNEXPECTED ERROR RECEIVED]\r\n{0}\r\n", ex.Message);
            }
        }
Esempio n. 25
0
        void publish(ExecutionLogInterface log, bool filesOnly)
        {
            log.Log("Starting Web Site Publishing...");
            _publicationInError = false;
            try
            {
                string publicationDirectory = _configuration.WebPublicationDirectory;
                string sourceDirectory      = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "Web");
#if DEBUG
                sourceDirectory = Path.GetDirectoryName(Application.ExecutablePath) + @"\..\..\..\SealWebServer\";
#endif

                //Copy installation directory
                log.Log("Copying files from '{0}' to '{1}'", sourceDirectory, publicationDirectory);
                FileHelper.CopyDirectory(sourceDirectory, publicationDirectory, true);

                //Copy license files if any
                foreach (var path in Directory.GetFiles(Path.GetDirectoryName(Application.ExecutablePath), "*.slc"))
                {
                    File.Copy(path, Path.Combine(Path.Combine(publicationDirectory, "bin"), Path.GetFileName(path)), true);
                }

                //Check web config...
                if (!filesOnly || (!File.Exists(Path.Combine(publicationDirectory, "web.config")) && File.Exists(Path.Combine(publicationDirectory, "web.release.config"))))
                {
                    log.Log("Creating web.config file");
                    File.Copy(Path.Combine(publicationDirectory, "web.release.config"), Path.Combine(publicationDirectory, "web.config"), true);
                }

                if (!filesOnly && !log.IsJobCancelled())
                {
                    log.Log("Publishing Site on IIS...");

                    Microsoft.Web.Administration.ServerManager serverMgr = new Microsoft.Web.Administration.ServerManager();
                    Microsoft.Web.Administration.Site          site      = null;
                    if (serverMgr.Sites.Count == 0)
                    {
                        log.Log("Creating Default Web Site");
                        site = serverMgr.Sites.Add("Default Web Site", "C:\\inetpub\\wwwroot", 80);
                    }
                    else
                    {
                        site = serverMgr.Sites[0];
                    }

                    Microsoft.Web.Administration.ApplicationPool pool = serverMgr.ApplicationPools.FirstOrDefault(i => i.Name == _configuration.WebApplicationPoolName);
                    if (pool == null)
                    {
                        log.Log("Creating Application Pool");
                        pool = serverMgr.ApplicationPools.Add(_configuration.WebApplicationPoolName);
                    }
                    pool.ManagedRuntimeVersion = "v4.0";
                    if (Marshal.SizeOf(typeof(IntPtr)) != 8)
                    {
                        pool.Enable32BitAppOnWin64 = true;                                      //Test if 32bit
                    }
                    pool.ProcessModel.IdentityType = Microsoft.Web.Administration.ProcessModelIdentityType.LocalSystem;

                    if (string.IsNullOrEmpty(_configuration.WebApplicationName))
                    {
                        _configuration.WebApplicationName = "/";
                    }
                    var application = site.Applications.FirstOrDefault(i => i.Path == _configuration.WebApplicationName);
                    if (application == null)
                    {
                        log.Log("Creating Application");
                        application = site.Applications.Add(_configuration.WebApplicationName, _configuration.WebPublicationDirectory);
                    }
                    if (_configuration.WebApplicationName == "/")
                    {
                        Microsoft.Web.Administration.VirtualDirectory vDir = application.VirtualDirectories[0];
                        vDir.Path         = _configuration.WebApplicationName;
                        vDir.PhysicalPath = _configuration.WebPublicationDirectory;
                    }
                    application.ApplicationPoolName = _configuration.WebApplicationPoolName;
                    if (!log.IsJobCancelled())
                    {
                        serverMgr.CommitChanges();
                    }
                    log.Log("Web Site has been published successfully.");
                }
            }
            catch (Exception ex)
            {
                _publicationInError = true;
                log.Log("\r\n[UNEXPECTED ERROR RECEIVED]\r\n{0}\r\n", ex.Message);
                if (ex.InnerException != null)
                {
                    log.Log("{0}\r\n", ex.InnerException.Message);
                }
            }
            log.Log("Web Site Publishing terminated.");
            if (log.IsJobCancelled())
            {
                log.Log("Publication has been cancelled.");
            }
        }
Esempio n. 26
0
        public void ExportSourceTranslations(ExecutionLogInterface log)
        {
            Repository repository = Repository.Instance.CreateFast();
            StringBuilder translations = new StringBuilder();
            try
            {
                log.Log("Starting the export of the Data Source translations for '{0}'\r\n", Source.Name);
                string separator = System.Globalization.CultureInfo.CurrentCulture.TextInfo.ListSeparator;
                string extraSeparators = initTranslationFile(translations, separator, repository);

                log.Log("Adding elements names in context: Element\r\n");
                foreach (var table in Source.MetaData.Tables)
                {
                    foreach (var element in table.Columns)
                    {
                        translations.AppendFormat("Element{0}{1}{0}{2}{3}\r\n", separator, Helper.QuoteDouble(element.Category + '.' + element.DisplayName), Helper.QuoteDouble(element.DisplayName), extraSeparators);
                    }
                }

                log.Log("Adding enum values in context: Enum\r\n");
                foreach (var enumList in Source.MetaData.Enums.Where(i => i.Translate))
                {
                    foreach (var enumVal in enumList.Values)
                    {
                        translations.AppendFormat("Enum{0}{1}{0}{2}{3}\r\n", separator, Helper.QuoteDouble(enumList.Name), Helper.QuoteDouble(enumVal.Val), extraSeparators);
                    }
                }

                log.Log("Adding Sub-Report names in context: SubReport\r\n");
                foreach (var table in Source.MetaData.Tables)
                {
                    foreach (var element in table.Columns)
                    {
                        foreach (var subReport in element.SubReports)
                        {
                            translations.AppendFormat("SubReport{0}{1}{0}{2}{3}\r\n", separator, Helper.QuoteDouble(element.Category + '.' + element.DisplayName), subReport.Name, extraSeparators);
                        }
                    }
                }

                string fileName = FileHelper.GetUniqueFileName(Path.Combine(repository.SettingsFolder, Helper.CleanFileName(string.Format("RepositoryTranslations_{0}_WORK.csv", Source.Name))));
                File.WriteAllText(fileName, translations.ToString(), Encoding.UTF8);

                log.Log("\r\nExport of the Data Source translations terminated.\r\n\r\nThe file has been saved to '{0}' and can be re-worked and merged with the repository translations file.\r\n\r\nNote that the effective repository translations file is 'RepositoryTranslations.csv' in the Repository Sub-Folder 'Settings'.", fileName);

                Process.Start(fileName);
            }
            catch (Exception ex)
            {
                log.Log("\r\n[UNEXPECTED ERROR RECEIVED]\r\n{0}\r\n", ex.Message);
            }
        }