public static bool IsBadImageFormatException(Exception ex) { #if !NETCORE return(GXUtil.IsBadImageFormatException(ex)); #else return(false); #endif }
private static GXReorganization GetReorgProgram() { GXReorganization rg = null; try { string ns; string assmblyName; string nme; if (Config.GetValueOf("ReorgAssemblyName", out nme)) { assmblyName = nme; } else { assmblyName = ""; } if (Config.GetValueOf("AppMainNamespace", out nme)) { ns = nme; } else { ns = "GeneXus.Programs"; } if (assmblyName.Length == 0) { rg = (GXReorganization)GeneXus.Metadata.ClassLoader.GetInstance("Reorganization", ns + ".reorganization", null); } else { rg = (GXReorganization)GeneXus.Metadata.ClassLoader.GetInstance(assmblyName, ns + ".reorganization", null); } } catch (Exception ex) { if (GXUtil.IsBadImageFormatException(ex)) { throw ex; } else { rg = (GXReorganization)GeneXus.Metadata.ClassLoader.GetInstance("Reorganization", "GeneXus.Programs.reorganization", null); } } return(rg); }
public static int Main(string[] args) { #if NETCORE var configFilePath = Path.Combine(FileUtil.GetStartupDirectory(), CLIENT_EXE_CONFIG); if (File.Exists(configFilePath)) { GeneXus.Configuration.Config.ConfigFileName = configFilePath; } #else string parentConfigFile = Path.Combine("..", CLIENT_EXE_CONFIG); if (File.Exists(CLIENT_EXE_CONFIG)) { GeneXus.Configuration.Config.ConfigFileName = CLIENT_EXE_CONFIG; } else if (File.Exists(parentConfigFile)) { GeneXus.Configuration.Config.ConfigFileName = parentConfigFile; } else { string configPath = Path.Combine(GxContext.StaticPhysicalPath(), CLIENT_EXE_CONFIG); if (File.Exists(configPath)) { GeneXus.Configuration.Config.ConfigFileName = configPath; } } bool nogui = false; #endif bool notexecute = false; foreach (string sw in args) { if (sw.ToLower().StartsWith("\\config:") || sw.ToLower().StartsWith("-config:")) { string configFile = sw.Substring(8); GeneXus.Configuration.Config.ConfigFileName = configFile; REORG_FILE_3 = Path.Combine(Path.GetDirectoryName(configFile), REORGPGM_GEN); } #if !NETCORE else if (sw.ToLower().Trim() == "-nogui") { nogui = true; } #endif else if (sw.ToLower().Trim() == "-force") { force = true; } else if (sw.ToLower().Trim() == "-recordcount") { onlyRecordCount = true; } else if (sw.ToLower().Trim() == "-ignoreresume") { ignoreresume = true; } else if (sw.ToLower().Trim() == "-noverifydatabaseschema") { noprecheck = true; } else if (sw.ToLower().Trim() == "-donotexecute") { notexecute = true; } } if (notexecute) { SetStatus(GXResourceManager.GetMessage("GXM_dbnotreorg")); errorCode = 0; } else { try { GxContext.isReorganization = true; gxReorganization = GetReorgProgram(); #if !NETCORE if (nogui) { try { Console.OutputEncoding = Encoding.Default; } catch (IOException) //Docker: System.IO.IOException: The parameter is incorrect. { try { Console.OutputEncoding = Encoding.UTF8; } catch (IOException) { } } #endif GXReorganization._ReorgReader = new NoGuiReorg(); GXReorganization.printOnlyRecordCount = onlyRecordCount; GXReorganization.ignoreResume = ignoreresume; GXReorganization.noPreCheck = noprecheck; if (gxReorganization.GetCreateDataBase()) { GXReorganization.SetCreateDataBase(); } if (ReorgStartup.reorgPending()) { if (gxReorganization.BeginResume()) { gxReorganization.ExecForm(); } if (GXReorganization.Error) { SetStatus(GXResourceManager.GetMessage("GXM_reorgnotsuccess")); if (GXReorganization.ReorgLog != null && GXReorganization.ReorgLog.Count > 0) { SetStatus((string)GXReorganization.ReorgLog[GXReorganization.ReorgLog.Count - 1]); } errorCode = -1; } else { SetStatus(GXResourceManager.GetMessage("GXM_reorgsuccess")); errorCode = 0; } } else { SetStatus(GXResourceManager.GetMessage("GXM_ids_noneeded")); errorCode = 0; } #if !NETCORE } else { FreeConsole(); System.Windows.Forms.Application.Run(new GuiReorg()); } #endif } catch (Exception ex) { #if !NETCORE if (GXUtil.IsBadImageFormatException(ex) && !GXUtil.ExecutingRunX86()) { GXReorganization.CloseResumeFile(); int exitCode; if (GXUtil.RunAsX86(GXUtil.REOR, args, DataReceived, out exitCode)) { return(exitCode); } else { SetStatus(GXResourceManager.GetMessage("GXM_reorgnotsuccess")); SetStatus(GXResourceManager.GetMessage("GXM_callerr", GXUtil.RUN_X86)); errorCode = -1; } } else #endif { SetStatus(GXResourceManager.GetMessage("GXM_reorgnotsuccess")); SetStatus(ex.Message); errorCode = -1; } } } return(errorCode); }