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 !"); } }
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); } }
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); } }
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."); } }
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"); }
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 !"); } }
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); } }
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"); }
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."); }
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); } }
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); } }
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 !"); }
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 !"); } }
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."); } }