MalwareSourceCode/MSIL/Virus/Win32/S/Virus.Win32.Sality.sil-906e49d7772808af1fb67511fd33b01c809079fddb77015425883ca9739cad33/MainForm.cs
2022-08-18 06:28:56 -05:00

1482 lines
72 KiB
C#

// Decompiled with JetBrains decompiler
// Type: Autodesk.AutoCAD.ADMigrator.MainForm
// Assembly: ADMigrator, Version=18.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 1EA8663B-E949-4FAD-ABC5-280393847F56
// Assembly location: C:\Users\Administrateur\Downloads\Virusshare-00001-msil\Virus.Win32.Sality.sil-906e49d7772808af1fb67511fd33b01c809079fddb77015425883ca9739cad33.exe
using Autodesk.AutoCAD.AcZipInterface;
using Autodesk.AutoCAD.ADMigrator.Properties;
using Autodesk.AutoCAD.Customization;
using Autodesk.AutoCAD.CustomMigrator;
using Autodesk.AutoCAD.MNUParser;
using Autodesk.AutoCAD.MyAutoCAD;
using Microsoft.Win32;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Windows;
using System.Windows.Forms;
using System.Xml;
namespace Autodesk.AutoCAD.ADMigrator
{
public class MainForm : Form, ILogXML
{
private const string VERTICAL_ADMIGRATOR_DLL = "VerticalAdMigrator.dll";
private const string MIGRATION_PROFILES_FILE = "AdMigrator.xml";
private const string MIGRATION_DATA_FILE = "MigrationDataFile.xml";
private bool bRun;
private Button OkBtn;
private Button CancelBtn;
private Button HelpBtn;
private Label HeaderText;
private Label ComboText;
private Label FooterText;
private ComboBox InstalledVersionsCombo;
private IContainer components;
private UTF8Encoding UTF8 = new UTF8Encoding();
private static string LogFileName = (string) null;
private static string LogFileNameXml = (string) null;
private static XmlTextWriter MainWriter = (XmlTextWriter) null;
private bool m_SkipACADCheck;
internal static bool m_isVertMigration = false;
private string m_VertDLLPath;
public static string MigrationFolder = (string) null;
public static ArrayList CUIFileMapArray;
internal Migrator _Migrator;
private static string m_CurrentSourceProfilePath = (string) null;
public static bool isTarget = false;
private static string m_CurrentTargetProfilePath = (string) null;
private bool m_isImport;
private bool m_isExport;
private bool m_includeNetworkFiles = true;
public string ProductRegistryRootKey;
private ADMigratorResources m_LocalResources = new ADMigratorResources();
private Label ItemList;
private ProductInfo m_prodInfo;
private Panel FilesCheckBoxPanel;
private CheckBox UserProfilesCheck;
private CheckBox CUIFilesCheck;
private CheckBox MNUMNSFilesCheck;
private CheckBox UserIconFilesCheck;
private CheckBox UserLineFilesCheck;
private CheckBox UserHatchFilesCheck;
private CheckBox AcadHatchFilesCheck;
private CheckBox AcadLineFilesCheck;
private CheckBox AcadPgpFilesCheck;
internal static bool isACAD = false;
internal static CustomizationHostServices customizationHostServices = new CustomizationHostServices();
internal static MainForm _theForm = (MainForm) null;
public static string CurrentSourceProfilePath => MainForm.m_CurrentSourceProfilePath;
public static string CurrentTargetProfilePath => MainForm.m_CurrentTargetProfilePath;
public bool IsImportExport => this.m_isExport || this.m_isImport;
public MainForm()
{
this.InitializeComponent();
this._Migrator = new Migrator((ILogXML) this);
CUIFileMigrator._logger = (ILogXML) this;
MNUFileMigrator._logger = (ILogXML) this;
MainForm._theForm = this;
}
public ProductInfo ProdInfo
{
get => this.m_prodInfo;
set => this.m_prodInfo = value;
}
protected override void Dispose(bool disposing)
{
if (disposing && this.components != null)
this.components.Dispose();
base.Dispose(disposing);
}
private void InitializeComponent()
{
ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof (MainForm));
this.HeaderText = new Label();
this.ComboText = new Label();
this.InstalledVersionsCombo = new ComboBox();
this.FooterText = new Label();
this.OkBtn = new Button();
this.CancelBtn = new Button();
this.HelpBtn = new Button();
this.ItemList = new Label();
this.FilesCheckBoxPanel = new Panel();
this.UserProfilesCheck = new CheckBox();
this.CUIFilesCheck = new CheckBox();
this.MNUMNSFilesCheck = new CheckBox();
this.UserIconFilesCheck = new CheckBox();
this.AcadLineFilesCheck = new CheckBox();
this.UserLineFilesCheck = new CheckBox();
this.UserHatchFilesCheck = new CheckBox();
this.AcadHatchFilesCheck = new CheckBox();
this.AcadPgpFilesCheck = new CheckBox();
this.FilesCheckBoxPanel.SuspendLayout();
this.SuspendLayout();
componentResourceManager.ApplyResources((object) this.HeaderText, "HeaderText");
this.HeaderText.Name = "HeaderText";
this.HeaderText.UseMnemonic = false;
componentResourceManager.ApplyResources((object) this.ComboText, "ComboText");
this.ComboText.Name = "ComboText";
componentResourceManager.ApplyResources((object) this.InstalledVersionsCombo, "InstalledVersionsCombo");
this.InstalledVersionsCombo.DropDownStyle = ComboBoxStyle.DropDownList;
this.InstalledVersionsCombo.Name = "InstalledVersionsCombo";
this.InstalledVersionsCombo.SelectedIndexChanged += new EventHandler(this.InstalledVersionsCombo_SelectedIndexChanged);
componentResourceManager.ApplyResources((object) this.FooterText, "FooterText");
this.FooterText.Name = "FooterText";
this.FooterText.UseMnemonic = false;
componentResourceManager.ApplyResources((object) this.OkBtn, "OkBtn");
this.OkBtn.Name = "OkBtn";
this.OkBtn.Click += new EventHandler(this.OkBtn_Click);
componentResourceManager.ApplyResources((object) this.CancelBtn, "CancelBtn");
this.CancelBtn.DialogResult = DialogResult.Cancel;
this.CancelBtn.Name = "CancelBtn";
this.CancelBtn.Click += new EventHandler(this.CancelBtn_Click);
componentResourceManager.ApplyResources((object) this.HelpBtn, "HelpBtn");
this.HelpBtn.Name = "HelpBtn";
this.HelpBtn.Click += new EventHandler(this.HelpBtn_Click);
componentResourceManager.ApplyResources((object) this.ItemList, "ItemList");
this.ItemList.Name = "ItemList";
componentResourceManager.ApplyResources((object) this.FilesCheckBoxPanel, "FilesCheckBoxPanel");
this.FilesCheckBoxPanel.BackColor = System.Drawing.SystemColors.ControlLightLight;
this.FilesCheckBoxPanel.BorderStyle = BorderStyle.Fixed3D;
this.FilesCheckBoxPanel.Controls.Add((Control) this.UserProfilesCheck);
this.FilesCheckBoxPanel.Controls.Add((Control) this.CUIFilesCheck);
this.FilesCheckBoxPanel.Controls.Add((Control) this.MNUMNSFilesCheck);
this.FilesCheckBoxPanel.Controls.Add((Control) this.UserIconFilesCheck);
this.FilesCheckBoxPanel.Controls.Add((Control) this.AcadLineFilesCheck);
this.FilesCheckBoxPanel.Controls.Add((Control) this.UserLineFilesCheck);
this.FilesCheckBoxPanel.Controls.Add((Control) this.UserHatchFilesCheck);
this.FilesCheckBoxPanel.Controls.Add((Control) this.AcadHatchFilesCheck);
this.FilesCheckBoxPanel.Controls.Add((Control) this.AcadPgpFilesCheck);
this.FilesCheckBoxPanel.Name = "FilesCheckBoxPanel";
componentResourceManager.ApplyResources((object) this.UserProfilesCheck, "UserProfilesCheck");
this.UserProfilesCheck.Name = "UserProfilesCheck";
this.UserProfilesCheck.CheckedChanged += new EventHandler(this.UserProfilesCheck_CheckedChanged);
componentResourceManager.ApplyResources((object) this.CUIFilesCheck, "CUIFilesCheck");
this.CUIFilesCheck.Name = "CUIFilesCheck";
componentResourceManager.ApplyResources((object) this.MNUMNSFilesCheck, "MNUMNSFilesCheck");
this.MNUMNSFilesCheck.Name = "MNUMNSFilesCheck";
componentResourceManager.ApplyResources((object) this.UserIconFilesCheck, "UserIconFilesCheck");
this.UserIconFilesCheck.Name = "UserIconFilesCheck";
componentResourceManager.ApplyResources((object) this.AcadLineFilesCheck, "AcadLineFilesCheck");
this.AcadLineFilesCheck.Name = "AcadLineFilesCheck";
componentResourceManager.ApplyResources((object) this.UserLineFilesCheck, "UserLineFilesCheck");
this.UserLineFilesCheck.Name = "UserLineFilesCheck";
componentResourceManager.ApplyResources((object) this.UserHatchFilesCheck, "UserHatchFilesCheck");
this.UserHatchFilesCheck.Name = "UserHatchFilesCheck";
componentResourceManager.ApplyResources((object) this.AcadHatchFilesCheck, "AcadHatchFilesCheck");
this.AcadHatchFilesCheck.Name = "AcadHatchFilesCheck";
componentResourceManager.ApplyResources((object) this.AcadPgpFilesCheck, "AcadPgpFilesCheck");
this.AcadPgpFilesCheck.Name = "AcadPgpFilesCheck";
this.AcceptButton = (IButtonControl) this.OkBtn;
componentResourceManager.ApplyResources((object) this, "$this");
this.CancelButton = (IButtonControl) this.CancelBtn;
this.Controls.Add((Control) this.FilesCheckBoxPanel);
this.Controls.Add((Control) this.ItemList);
this.Controls.Add((Control) this.HelpBtn);
this.Controls.Add((Control) this.CancelBtn);
this.Controls.Add((Control) this.OkBtn);
this.Controls.Add((Control) this.FooterText);
this.Controls.Add((Control) this.InstalledVersionsCombo);
this.Controls.Add((Control) this.ComboText);
this.Controls.Add((Control) this.HeaderText);
this.FormBorderStyle = FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = nameof (MainForm);
this.SizeGripStyle = SizeGripStyle.Hide;
this.Closed += new EventHandler(this.MainForm_Closed);
this.Load += new EventHandler(this.MainForm_Load);
this.FilesCheckBoxPanel.ResumeLayout(false);
this.ResumeLayout(false);
}
[STAThread]
private static int Main(string[] args)
{
if (args.Length > 0)
{
for (int index = 0; index < args.Length; ++index)
{
if (args[index].ToLower().Equals("/myautocad"))
return MainForm.IsMyAutoCADInstalled() ? MainForm.CallMyAutoCAD() : 0;
}
}
return MainForm.RunMigrator(args);
}
private static int RunMigrator(string[] args)
{
System.Windows.Forms.Application.EnableVisualStyles();
Mutex mutex = (Mutex) null;
ProductInfo productInfo = (ProductInfo) null;
CustomizationSection.HostServices = (IHostServices) MainForm.customizationHostServices;
try
{
mutex = new Mutex(true, "Local\\" + Assembly.GetEntryAssembly().GetName().Name);
}
catch (Exception ex)
{
}
if (mutex != null && !mutex.WaitOne(10, true))
return 1;
string str = (string) null;
try
{
str = Migrator.GetVerifiedRootKeyFromIni();
productInfo = new ProductInfo();
Migrator.getProductInfoFromRegistryString(str, productInfo);
if (productInfo.m_languageTag.Length > 3)
throw new INIException(3);
Thread.CurrentThread.CurrentUICulture = new CultureInfo(int.Parse(productInfo.m_languageTag, NumberStyles.HexNumber, (IFormatProvider) CultureInfo.InvariantCulture), true);
}
catch (INIException ex)
{
bool flag = true;
MainForm mainForm = new MainForm();
switch (ex.nProblem)
{
case 1:
int num1 = (int) System.Windows.Forms.MessageBox.Show(mainForm.m_LocalResources.GetString("ERROR_RK_NF"), mainForm.m_LocalResources.GetString("UI_TITLE"), MessageBoxButtons.OK, MessageBoxIcon.Hand);
break;
case 2:
int num2 = (int) System.Windows.Forms.MessageBox.Show(mainForm.m_LocalResources.GetString("ERROR_INI_INVALID"), mainForm.m_LocalResources.GetString("UI_TITLE"), MessageBoxButtons.OK, MessageBoxIcon.Hand);
break;
case 3:
flag = false;
if (productInfo.m_languageTag != "24242424")
{
int num3 = (int) System.Windows.Forms.MessageBox.Show(string.Format(mainForm.m_LocalResources.GetString("ERROR_RK_INVALID"), (object) str), mainForm.m_LocalResources.GetString("UI_TITLE"), MessageBoxButtons.OK, MessageBoxIcon.Hand);
break;
}
break;
}
if (flag)
return 1;
}
MainForm mainForm1 = new MainForm();
mainForm1.ProductRegistryRootKey = str;
MainForm.customizationHostServices.RegProdRootKey = str;
mainForm1.ProdInfo = productInfo;
if (args.Length > 0)
{
for (int index = 0; index < args.Length; ++index)
{
if (args[index].ToLower().Equals("/a"))
mainForm1.m_SkipACADCheck = true;
if (args[index].ToLower().Equals("/i"))
mainForm1.m_isImport = true;
if (args[index].ToLower().Equals("/e"))
mainForm1.m_isExport = true;
}
}
if (!mainForm1.m_SkipACADCheck && Process.GetProcessesByName(productInfo.m_productId).Length > 0)
{
if (mainForm1.m_isImport || mainForm1.m_isExport)
{
int num4 = (int) System.Windows.Forms.MessageBox.Show(string.Format(mainForm1.m_LocalResources.GetString("NOTICE_ISRUNNING_IMPORTEXPORT"), (object) mainForm1.ProdInfo.m_productName, (object) mainForm1.ProdInfo.m_productName), mainForm1.ProdInfo.m_productName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
}
else
{
int num5 = (int) System.Windows.Forms.MessageBox.Show(string.Format(mainForm1.m_LocalResources.GetString("NOTICE_ISRUNNING"), (object) mainForm1.ProdInfo.m_productName), mainForm1.m_LocalResources.GetString("UI_TITLE"), MessageBoxButtons.OK, MessageBoxIcon.Hand);
}
return 1;
}
if (Registry.CurrentUser.OpenSubKey(Migrator.StripWOWFromCURegKey(mainForm1.ProductRegistryRootKey)) == null)
{
if (mainForm1.m_isImport)
mainForm1.LaunchProductFirst(Migrator.GetAppInstallDir(mainForm1.ProductRegistryRootKey), false);
else if (mainForm1.m_isExport)
{
mainForm1.LaunchProductFirst(Migrator.GetAppInstallDir(mainForm1.ProductRegistryRootKey), true);
}
else
{
int num = (int) System.Windows.Forms.MessageBox.Show(string.Format(mainForm1.m_LocalResources.GetString("NOTICE_PRODUCT_MUST_BE_RUN"), (object) mainForm1.ProdInfo.m_productName), mainForm1.m_LocalResources.GetString("UI_TITLE"), MessageBoxButtons.OK, MessageBoxIcon.Hand);
}
return 1;
}
if (!mainForm1.m_isExport && !mainForm1.m_isImport && Migrator.HasMigrated(mainForm1.ProductRegistryRootKey) && MigratorMessageBox.Show(string.Format(mainForm1.m_LocalResources.GetString("NOTICE_ALREADYRUN"), (object) productInfo.m_productName), mainForm1.m_LocalResources.GetString("NOTICE_WARNING"), mainForm1.m_LocalResources.GetString("UI_TITLE")) != DialogResult.OK)
return 0;
Parser.Initialize();
try
{
mainForm1.m_VertDLLPath = System.Windows.Forms.Application.ExecutablePath;
mainForm1.m_VertDLLPath = Path.GetDirectoryName(mainForm1.m_VertDLLPath);
mainForm1.m_VertDLLPath += "\\VerticalAdMigrator.dll";
if (File.Exists(mainForm1.m_VertDLLPath))
MainForm.m_isVertMigration = true;
if (mainForm1.m_isExport)
mainForm1.ExportCustomizations();
else if (mainForm1.m_isImport)
mainForm1.ImportCustomizations();
else
System.Windows.Forms.Application.Run((Form) mainForm1);
Settings.Default.Save();
}
catch (Exception ex)
{
return 1;
}
Parser.Terminate();
return 0;
}
public void LaunchProductFirst(string AppInstallDir, bool ExportMsg)
{
string str = AppInstallDir + (this.m_prodInfo.isAcad ? "acad" : "acadlt") + ".exe";
if (((Form) new LaunchDialog()
{
dlgName = this.m_prodInfo.m_productName,
messageBody = (!ExportMsg ? string.Format(LocalResources.GetString("Import_Launch_Message"), (object) this.m_prodInfo.m_productName) : string.Format(LocalResources.GetString("Export_Launch_Message"), (object) this.m_prodInfo.m_productName))
}).ShowDialog() != DialogResult.OK || !File.Exists(str))
return;
Process.Start(str);
}
private void SetUIText(Control thing) => thing.Text = this.m_LocalResources.GetString(thing.Text);
private void InitProductInfo()
{
RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(this.ProductRegistryRootKey);
if (registryKey == null)
return;
Migrator.getProductInfoFromRegistryString(this.ProductRegistryRootKey, this.m_prodInfo);
MainForm.isACAD = this.m_prodInfo.isAcad;
registryKey.Close();
MainForm.MigrationFolder = Migrator.GetRoamableRootFolder(this.ProductRegistryRootKey) + this.m_LocalResources.GetString("LOG_FOLDER");
if (Directory.Exists(MainForm.MigrationFolder))
return;
Directory.CreateDirectory(MainForm.MigrationFolder);
}
private void MainForm_Load(object sender, EventArgs e)
{
this.InitProductInfo();
this.AcadLineFilesCheck.Text = string.Format(this.AcadLineFilesCheck.Text, (object) this.m_prodInfo.m_product);
this.AcadHatchFilesCheck.Text = string.Format(this.AcadHatchFilesCheck.Text, (object) this.m_prodInfo.m_product);
this.AcadPgpFilesCheck.Text = string.Format(this.AcadPgpFilesCheck.Text, (object) this.m_prodInfo.m_productId.ToLower());
this.HeaderText.Text = string.Format(this.HeaderText.Text, (object) this.m_prodInfo.m_product, (object) this.m_prodInfo.m_productName);
if (MainForm.m_isVertMigration)
{
object[] parameters = new object[2]
{
(object) this._Migrator.MinProductVersion,
(object) this._Migrator.MinCUIVersion
};
this.CallVerticalMigration("LatestSupportedVersions", parameters);
if ((double) parameters[0] > this._Migrator.MinProductVersion)
this._Migrator.MinProductVersion = (double) parameters[0];
if ((double) parameters[1] > this._Migrator.MinCUIVersion)
this._Migrator.MinCUIVersion = (double) parameters[1];
}
ArrayList installedAppList = this._Migrator.GetInstalledAppList(this.ProductRegistryRootKey);
if (installedAppList.Count == 0)
{
if (!this.m_SkipACADCheck)
{
int num = (int) System.Windows.Forms.MessageBox.Show(string.Format(this.m_LocalResources.GetString("ERROR_NO_PREVIOUS"), (object) this.m_prodInfo.m_product), this.m_LocalResources.GetString("UI_TITLE"), MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
}
this.Close();
}
else
{
foreach (ProductInfo productInfo in installedAppList)
this.InstalledVersionsCombo.Items.Add((object) productInfo);
this.InstalledVersionsCombo.SelectedIndex = this.InstalledVersionsCombo.Items.Count - 1;
for (int index = 0; index < this.FilesCheckBoxPanel.Controls.Count; ++index)
{
if (this.FilesCheckBoxPanel.Controls[index] is CheckBox control)
control.Checked = true;
}
this.UpdateCheckBoxes(this.InstalledVersionsCombo);
}
}
private static bool IsMyAutoCADInstalled()
{
try
{
string name = Migrator.StripWOWFromCURegKey(Migrator.GetVerifiedRootKeyFromIni());
using (RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(name))
{
object obj = registryKey != null ? registryKey.GetValue("InitialSetup") : throw new INIException(4);
if (obj == null || !(obj is int num))
throw new INIException(4);
if (num < 1)
throw new INIException(4);
}
string location = Assembly.GetCallingAssembly().Location;
if (!File.Exists(location.Substring(0, location.LastIndexOf("\\") + 1) + "MyAutoCAD.dll"))
throw new INIException(4);
return true;
}
catch (INIException ex)
{
ADMigratorResources migratorResources = new ADMigratorResources();
int num = (int) System.Windows.Forms.MessageBox.Show(migratorResources.GetString("INITIALSETUP_ERROR_NOT_INSTALLED"), migratorResources.GetString("INITIALSETUP_DIALOG_TITLE"), MessageBoxButtons.OK, MessageBoxIcon.Hand);
}
return false;
}
private static int CallMyAutoCAD()
{
try
{
ProductInfo productInfo = new ProductInfo();
if (Migrator.getProductInfoFromRegistryString(Migrator.GetVerifiedRootKeyFromIni(), productInfo))
{
if (productInfo.m_languageTag.Length <= 3)
Thread.CurrentThread.CurrentUICulture = new CultureInfo(int.Parse(productInfo.m_languageTag, NumberStyles.HexNumber, (IFormatProvider) CultureInfo.InvariantCulture), true);
}
}
catch (INIException ex)
{
}
((Window) new MainWindow())?.ShowDialog();
return 0;
}
private void CancelBtn_Click(object sender, EventArgs e) => this.Close();
private void OkBtn_Click(object sender, EventArgs e)
{
if (!(this.InstalledVersionsCombo.Items[this.InstalledVersionsCombo.SelectedIndex] is ProductInfo srcInfo))
return;
this._Migrator.SourceProdInfo = srcInfo;
MainForm.CUIFileMapArray = new ArrayList();
if (MainForm.m_isVertMigration)
{
try
{
this.CallVerticalMigration("PreProcess", new object[2]
{
(object) srcInfo.m_regRootKey,
(object) MainForm.CUIFileMapArray
});
}
catch (Exception ex)
{
MainForm.Log2File(string.Format(this.m_LocalResources.GetString("ERROR_ACAD_VERTICAL"), (object) this.m_prodInfo.m_productId.ToLower(), (object) ex.Message));
Migrator.m_bErrors = true;
}
}
else if (srcInfo.isLT && srcInfo.IsBeforeSpago())
{
CUIFileMap cuiFileMap = new CUIFileMap("aclt.cui", "ACLT", "ACLTMacros", "acadlt.cui", "ACADLT", "ACADLTMacros");
MainForm.CUIFileMapArray.Add((object) cuiFileMap);
}
else if (srcInfo.IsBeforeGator())
{
CUIFileMap cuiFileMap = new CUIFileMap("contentsearch", "CONTENTSEARCH", "CONTENTSEARCHMacros", "AutodeskSeek", "CONTENTSEARCH", "CONTENTSEARCHMacros");
MainForm.CUIFileMapArray.Add((object) cuiFileMap);
}
bool flag1 = false;
for (int index = 0; index < this.FilesCheckBoxPanel.Controls.Count; ++index)
{
if (this.FilesCheckBoxPanel.Controls[index] is CheckBox control && control.Checked)
{
flag1 = true;
break;
}
}
try
{
if (flag1)
{
this.Cursor = Cursors.WaitCursor;
this.bRun = true;
this.LogXMLInitialize();
string[] profiles = Migrator.GetProfiles(srcInfo.m_regRootKey);
if (this.UserProfilesCheck.Checked && profiles != null)
{
if (MainForm.m_isVertMigration)
{
StringDictionary stringDictionary = new StringDictionary();
this.CallVerticalMigration("GetMigrationEnvironmentVariables", new object[2]
{
(object) srcInfo.m_regRootKey,
(object) stringDictionary
});
if (stringDictionary.Count > 0)
{
foreach (string key in (IEnumerable) stringDictionary.Keys)
srcInfo.EnvVars.Add(key, stringDictionary[key], true);
}
stringDictionary.Clear();
this.CallVerticalMigration("GetMigrationEnvironmentVariables", new object[2]
{
(object) this._Migrator.destProductInfo().m_regRootKey,
(object) stringDictionary
});
if (stringDictionary.Count > 0)
{
foreach (string key in (IEnumerable) stringDictionary.Keys)
this._Migrator.destProductInfo().EnvVars.Add(key, stringDictionary[key], true);
}
}
ProfileMigrator pm = (ProfileMigrator) null;
try
{
this.LogXMLStartSection((LogSection) 0);
string location = Assembly.GetEntryAssembly().Location;
pm = new ProfileMigrator(location.Substring(0, location.LastIndexOf("\\") + 1) + "AdMigrator.xml");
// ISSUE: method pointer
pm.Migrate(srcInfo, this._Migrator.destProductInfo(), this.ProductRegistryRootKey, new ProfileMigrator.Log((object) null, __methodptr(Log2File)));
}
catch (FileNotFoundException ex)
{
string str = string.Format(this.m_LocalResources.GetString("ERROR_FNF"), (object) "AdMigrator.xml", (object) ex.Message);
MainForm.Log2File(str);
this.LogXMLElement((LogOperation) 0, (LogCategory) 0, str);
Migrator.m_bErrors = true;
}
catch (Exception ex)
{
string str = string.Format(this.m_LocalResources.GetString("ERROR_PROFILE"), (object) ex.Message);
this.LogXMLElement((LogOperation) 0, (LogCategory) 0, str);
MainForm.Log2File(str);
Migrator.m_bErrors = true;
}
finally
{
this.LogXMLEndSection();
}
StringCollection stringCollection1 = new StringCollection();
StringCollection stringCollection2 = new StringCollection();
foreach (string str1 in profiles)
{
StringCollection a1 = new StringCollection();
MainForm.m_CurrentSourceProfilePath = srcInfo.m_regRootKey + "\\Profiles\\" + str1;
MainForm.m_CurrentTargetProfilePath = this.ProductRegistryRootKey + "\\Profiles\\" + str1;
RegistryKey registryKey1 = Registry.CurrentUser.OpenSubKey(Migrator.StripWOWFromCURegKey(MainForm.m_CurrentSourceProfilePath) + "\\General Configuration");
if (registryKey1 != null)
{
string b1 = (string) registryKey1.GetValue("MenuFile");
if (b1 != null && b1.Length > 1 && !MainForm.StringCollectionContains(a1, b1, true))
a1.Add(b1);
string b2 = (string) registryKey1.GetValue("EnterpriseMenuFile");
if (b2 != null && b2.Length > 1 && !MainForm.StringCollectionContains(a1, b2, true))
a1.Add(b2);
if (this.CUIFilesCheck.Checked && !pm.SrcProdInfo.IsBeforeRio())
{
DisposableContainer disposableContainer = new DisposableContainer();
try
{
this.LogXMLStartSection((LogSection) 1);
StringCollection a2 = new StringCollection();
CUIFileMigrator.FindTargetCUIFiles(this.ProductRegistryRootKey);
Hashtable hashtable1 = new Hashtable();
Hashtable hashtable2 = new Hashtable();
foreach (string source in a1)
{
if (!stringCollection1.Contains(source.ToLower()))
{
stringCollection1.Add(source.ToLower());
CUIFileMigrator key = new CUIFileMigrator(source, (ILogXML) this, srcInfo, this._Migrator.destProductInfo());
disposableContainer.AddDisposableObject((IDisposable) key);
if (key.SourceFile != null)
{
key.FindInitialTarget();
if (key.SetFinalTarget(pm, this.ProductRegistryRootKey))
{
if (key.MergeFiles())
{
if (source == b1)
{
RegistryKey registryKey2 = Registry.CurrentUser.OpenSubKey(Migrator.StripWOWFromCURegKey(MainForm.m_CurrentTargetProfilePath) + "\\General Configuration", true);
registryKey2.SetValue("MenuFile", (object) key.TargetFile);
registryKey2.Close();
this.LogXMLElement((LogOperation) 0, (LogCategory) 5, string.Format(LocalResources.GetString("LOG_MENU_FILE_CHANGE"), (object) key.TargetFile));
}
if (source == b2)
{
RegistryKey registryKey3 = Registry.CurrentUser.OpenSubKey(Migrator.StripWOWFromCURegKey(MainForm.m_CurrentTargetProfilePath) + "\\General Configuration", true);
registryKey3.SetValue("EnterpriseMenuFile", (object) key.TargetFile);
registryKey3.Close();
this.LogXMLElement((LogOperation) 0, (LogCategory) 5, string.Format(LocalResources.GetString("LOG_ENTERPRISE_FILE_CHANGE"), (object) key.TargetFile));
}
}
key.CopyImagesDll();
key.CopySldAndSlbFiles();
hashtable2.Add((object) key, (object) new List<CUIFileMigrator>());
foreach (string str2 in key.GetPartialsFromSource())
{
if (str2.Length > 1 && !MainForm.StringCollectionContains(a2, str2, true))
{
a2.Add(str2);
if (!hashtable1.Contains((object) str2))
hashtable1.Add((object) str2, (object) key);
}
}
}
}
}
}
foreach (string str3 in a2)
{
if (!stringCollection1.Contains(str3.ToLower()))
{
stringCollection1.Add(str3.ToLower());
CUIFileMigrator cuiFileMigrator1 = new CUIFileMigrator(str3, (ILogXML) this, srcInfo, this._Migrator.destProductInfo());
disposableContainer.AddDisposableObject((IDisposable) cuiFileMigrator1);
if (cuiFileMigrator1.SourceFile != null)
{
cuiFileMigrator1.FindInitialTarget();
if (cuiFileMigrator1.SetFinalTarget(pm, this.ProductRegistryRootKey))
{
CUIFileMigrator cuiFileMigrator2 = (CUIFileMigrator) null;
if (hashtable1.Contains((object) str3))
cuiFileMigrator2 = hashtable1[(object) str3] as CUIFileMigrator;
cuiFileMigrator1.setParentCUIFile(cuiFileMigrator2);
cuiFileMigrator1.MergeFiles();
cuiFileMigrator1.CopyImagesDll();
cuiFileMigrator1.CopySldAndSlbFiles();
if (hashtable2[(object) cuiFileMigrator2] is IList<CUIFileMigrator> cuiFileMigratorList)
cuiFileMigratorList.Add(cuiFileMigrator1);
this.LogXMLElement((LogOperation) 1, (LogCategory) 5, !cuiFileMigrator1.AutodeskSourceFile ? string.Format(LocalResources.GetString("LOG_FILE_COPY"), (object) cuiFileMigrator1.SourceFile, (object) cuiFileMigrator1.TargetFile) : string.Format(LocalResources.GetString("LOG_FILE_MERGE"), (object) cuiFileMigrator1.SourceFile, (object) cuiFileMigrator1.TargetFile));
}
}
}
}
foreach (CUIFileMigrator key in (IEnumerable) hashtable2.Keys)
CUIFileMigrator.RemoveUnresolvedReferences(key, hashtable2[(object) key] as IList<CUIFileMigrator>);
if (srcInfo.IsBeforeGator())
{
using (RegistryKey profileGeneralRegKey = Migrator.GetProfileGeneralRegKey(this._Migrator.destProductInfo().m_regRootKey, (string) null, true))
{
if (profileGeneralRegKey != null)
{
profileGeneralRegKey.DeleteValue("ContentSearchInit", false);
profileGeneralRegKey.DeleteValue("ImpressionInit", false);
}
}
using (RegistryKey profileGeneralRegKey = Migrator.GetProfileGeneralRegKey(this._Migrator.destProductInfo().m_regRootKey, str1, true))
profileGeneralRegKey?.DeleteValue("ACET-ACETMAIN-MENULOADED", false);
}
}
finally
{
disposableContainer.Dispose();
this.LogXMLEndSection();
}
}
else if (this.MNUMNSFilesCheck.Checked)
{
if (pm.SrcProdInfo.IsBeforeRio())
{
try
{
this.LogXMLStartSection((LogSection) 2);
if (a1.Count > 0)
{
MNUFileMigrator mnuFileMigrator = new MNUFileMigrator(a1[0], (ILogXML) this);
if (mnuFileMigrator.OriginalSource != null)
{
mnuFileMigrator.ConvertToCUIx(pm, this.ProductRegistryRootKey, true);
stringCollection1.Add(mnuFileMigrator.TargetCUIPath);
}
a1.Clear();
}
RegistryKey registryKey4 = Registry.CurrentUser.OpenSubKey(Migrator.StripWOWFromCURegKey(MainForm.m_CurrentSourceProfilePath) + "\\Menus");
if (registryKey4 != null)
{
string[] valueNames = registryKey4.GetValueNames();
if (valueNames != null && valueNames.Length > 0)
{
foreach (string name in valueNames)
{
if (name.StartsWith("Group"))
{
string b3 = (string) registryKey4.GetValue(name);
if (b3 != null)
{
if (b3.IndexOf(" ") > 0)
b3 = b3.Substring(b3.IndexOf(" ") + 1);
if (b3.Length > 1 && !MainForm.StringCollectionContains(a1, b3, true))
a1.Add(b3);
}
}
}
}
RegistryKey registryKey5 = Registry.CurrentUser.OpenSubKey(Migrator.StripWOWFromCURegKey(MainForm.CurrentTargetProfilePath) + "\\General Configuration");
if (registryKey5 != null)
{
string defaultSupportFile = (string) registryKey5.GetValue("MenuFile");
CustomizationSection customizationSection = (CustomizationSection) null;
if (defaultSupportFile == null || defaultSupportFile.Length < 1)
{
string str4 = pm.DestProdInfo.m_productId + CustomizationSection.EXTENSION_OPC;
defaultSupportFile = Migrator.FindFirstDefaultSupportFile(MainForm.isACAD, str4, this.ProductRegistryRootKey);
}
if (defaultSupportFile != null && defaultSupportFile.Length > 1)
customizationSection = new CustomizationSection(defaultSupportFile);
foreach (string source in a1)
{
MNUFileMigrator mnuFileMigrator = new MNUFileMigrator(source, (ILogXML) this);
if (mnuFileMigrator.OriginalSource != null)
{
mnuFileMigrator.ConvertToCUIx(pm, this.ProductRegistryRootKey, false);
if (mnuFileMigrator.LoadTarget)
{
if (customizationSection != null)
{
bool flag2 = false;
foreach (string partialCuiFile in (StringCollection) customizationSection.PartialCuiFiles)
{
if (string.Compare(Path.GetFileName(partialCuiFile), Path.GetFileName(mnuFileMigrator.TargetCUIPath), true) == 0)
{
flag2 = true;
break;
}
}
if (!flag2)
{
((CuiFileCollectionBase) customizationSection.PartialCuiFiles).Add(mnuFileMigrator.TargetCUIPath);
customizationSection.Save();
}
}
stringCollection1.Add(mnuFileMigrator.TargetCUIPath);
}
}
}
}
else
continue;
}
}
finally
{
this.LogXMLEndSection();
}
}
}
if (this.UserIconFilesCheck.Checked)
{
try
{
this.LogXMLStartSection((LogSection) 3);
string path1 = Migrator.GetRoamableRootFolder(this.ProductRegistryRootKey) + "support\\icons";
if (!Directory.Exists(path1))
Directory.CreateDirectory(path1);
this.LogXMLElement((LogOperation) 1, (LogCategory) 3, string.Format(LocalResources.GetString("LOG_ICON_FILE_LOCATION"), (object) path1));
foreach (string path2 in stringCollection1)
{
if (!stringCollection2.Contains(path2.ToLower()))
{
stringCollection2.Add(path2.ToLower());
try
{
CustomizationSection customizationSection = new CustomizationSection(path2);
if (customizationSection != null)
{
int num = 0;
foreach (string image in customizationSection.FindImages())
{
try
{
string str5 = (string) null;
if (File.Exists(image))
str5 = image;
else if (File.Exists(Path.GetDirectoryName(path2) + (object) Path.DirectorySeparatorChar + Path.GetFileName(image)))
str5 = image;
if (str5 == null)
{
string fileName = Path.GetFileName(image);
str5 = Migrator.FindFirstProfileSupportFile(MainForm.isACAD, fileName, MainForm.m_CurrentSourceProfilePath);
}
if (str5 != null)
{
if (File.Exists(str5))
{
string str6 = path1 + (object) Path.DirectorySeparatorChar + Path.GetFileName(image);
if (!File.Exists(str6))
File.Copy(str5, str6, false);
++num;
}
}
}
catch (IOException ex)
{
}
}
this.LogXMLElement((LogOperation) 1, (LogCategory) 3, string.Format(LocalResources.GetString("LOG_ICON_FILES_COPIED"), (object) num, (object) customizationSection.CUIFileBaseName));
}
}
catch (IOException ex)
{
}
}
}
}
finally
{
this.LogXMLEndSection();
}
MainForm.m_CurrentSourceProfilePath = (string) null;
MainForm.m_CurrentTargetProfilePath = (string) null;
}
}
}
}
if (this.AcadLineFilesCheck.Checked)
{
MainForm.Log2File(this.m_LocalResources.GetString("LOG_LINE"));
try
{
this.LogXMLStartSection((LogSection) 4);
string str7 = srcInfo.m_productId.ToLower() + ".lin";
string str8 = this.m_prodInfo.m_productId.ToLower() + ".lin";
string defaultSupportFile1 = Migrator.FindFirstDefaultSupportFile(MainForm.isACAD, str7, srcInfo.m_regRootKey);
string defaultSupportFile2 = Migrator.FindFirstDefaultSupportFile(MainForm.isACAD, str8, this.ProductRegistryRootKey);
LINFileMigrator linFileMigrator = new LINFileMigrator();
StringCollection stringCollection3 = ((FileMigrator) linFileMigrator).MigrateFile(defaultSupportFile1, defaultSupportFile2);
string str9 = string.Format(this.m_LocalResources.GetString("LOG_ITEMS_MIGRATED"), (object) stringCollection3.Count, (object) (str8 + this.m_LocalResources.GetString("LOG_LINE_PATTERNS")), (object) defaultSupportFile1, (object) defaultSupportFile2);
MainForm.Log2File(str9);
this.LogXMLElement((LogOperation) 1, (LogCategory) 4, str9);
string str10 = srcInfo.m_productId.ToLower() + "iso.lin";
string str11 = this.m_prodInfo.m_productId.ToLower() + "iso.lin";
string defaultSupportFile3 = Migrator.FindFirstDefaultSupportFile(MainForm.isACAD, str10, srcInfo.m_regRootKey);
string defaultSupportFile4 = Migrator.FindFirstDefaultSupportFile(MainForm.isACAD, str11, this.ProductRegistryRootKey);
StringCollection stringCollection4 = ((FileMigrator) linFileMigrator).MigrateFile(defaultSupportFile3, defaultSupportFile4);
string str12 = string.Format(this.m_LocalResources.GetString("LOG_ITEMS_MIGRATED"), (object) stringCollection4.Count, (object) (str11 + this.m_LocalResources.GetString("LOG_LINE_PATTERNS")), (object) defaultSupportFile3, (object) defaultSupportFile4);
MainForm.Log2File(str12);
this.LogXMLElement((LogOperation) 1, (LogCategory) 4, str12);
}
catch (Exception ex)
{
string str = string.Format(this.m_LocalResources.GetString("ERROR_ACAD_LINE"), (object) this.m_prodInfo.m_product, (object) ex.Message);
MainForm.Log2File(str);
this.LogXMLElement((LogOperation) 1, (LogCategory) 0, str);
Migrator.m_bErrors = true;
}
finally
{
this.LogXMLEndSection();
}
}
if (this.UserLineFilesCheck.Checked)
{
MainForm.Log2File(this.m_LocalResources.GetString("LOG_LINE"));
try
{
this.LogXMLStartSection((LogSection) 5);
string str13 = this.m_prodInfo.m_productId.ToLower() + ".lin";
string defaultSupportFileDir1 = Migrator.FindDefaultSupportFileDir(MainForm.isACAD, str13, srcInfo.m_regRootKey);
string defaultSupportFileDir2 = Migrator.FindDefaultSupportFileDir(MainForm.isACAD, str13, this.ProductRegistryRootKey);
StringCollection newDir = FileMigrator.CopyFilesToNewDir(defaultSupportFileDir1, defaultSupportFileDir2, "*.lin", false);
string str14 = string.Format(this.m_LocalResources.GetString("LOG_ITEMS_MIGRATED"), (object) newDir.Count, (object) this.m_LocalResources.GetString("LOG_USER_LIN_FILES"), (object) defaultSupportFileDir1, (object) defaultSupportFileDir2);
MainForm.Log2File(str14);
this.LogXMLElement((LogOperation) 1, (LogCategory) 3, str14);
}
catch (Exception ex)
{
string str = string.Format(this.m_LocalResources.GetString("ERROR_USER_LINE"), (object) ex.Message);
MainForm.Log2File(str);
this.LogXMLElement((LogOperation) 1, (LogCategory) 0, str);
Migrator.m_bErrors = true;
}
finally
{
this.LogXMLEndSection();
}
}
if (this.AcadHatchFilesCheck.Checked)
{
MainForm.Log2File(this.m_LocalResources.GetString("LOG_LINE"));
try
{
this.LogXMLStartSection((LogSection) 6);
string str15 = srcInfo.m_productId.ToLower() + ".pat";
string str16 = this.m_prodInfo.m_productId.ToLower() + ".pat";
string defaultSupportFile5 = Migrator.FindFirstDefaultSupportFile(MainForm.isACAD, str15, srcInfo.m_regRootKey);
string defaultSupportFile6 = Migrator.FindFirstDefaultSupportFile(MainForm.isACAD, str16, this.ProductRegistryRootKey);
PATFileMigrator patFileMigrator = new PATFileMigrator();
StringCollection stringCollection5 = ((FileMigrator) patFileMigrator).MigrateFile(defaultSupportFile5, defaultSupportFile6);
string str17 = string.Format(this.m_LocalResources.GetString("LOG_ITEMS_MIGRATED"), (object) stringCollection5.Count, (object) (str16 + string.Format(this.m_LocalResources.GetString("LOG_HATCH_PATTERNS"))), (object) defaultSupportFile5, (object) defaultSupportFile6);
MainForm.Log2File(str17);
this.LogXMLElement((LogOperation) 1, (LogCategory) 4, str17);
string str18 = srcInfo.m_productId.ToLower() + "iso.pat";
string str19 = this.m_prodInfo.m_productId.ToLower() + "iso.pat";
string defaultSupportFile7 = Migrator.FindFirstDefaultSupportFile(MainForm.isACAD, str18, srcInfo.m_regRootKey);
string defaultSupportFile8 = Migrator.FindFirstDefaultSupportFile(MainForm.isACAD, str19, this.ProductRegistryRootKey);
StringCollection stringCollection6 = ((FileMigrator) patFileMigrator).MigrateFile(defaultSupportFile7, defaultSupportFile8);
string str20 = string.Format(this.m_LocalResources.GetString("LOG_ITEMS_MIGRATED"), (object) stringCollection6.Count, (object) (str19 + string.Format(this.m_LocalResources.GetString("LOG_HATCH_PATTERNS"))), (object) defaultSupportFile7, (object) defaultSupportFile8);
MainForm.Log2File(str20);
this.LogXMLElement((LogOperation) 1, (LogCategory) 4, str20);
}
catch (Exception ex)
{
string str = string.Format(this.m_LocalResources.GetString("ERROR_ACAD_PATTERN"), (object) this.m_prodInfo.m_product, (object) ex.Message);
MainForm.Log2File(str);
this.LogXMLElement((LogOperation) 1, (LogCategory) 0, str);
Migrator.m_bErrors = true;
}
finally
{
this.LogXMLEndSection();
}
}
if (this.UserHatchFilesCheck.Checked)
{
MainForm.Log2File(this.m_LocalResources.GetString("LOG_LINE"));
try
{
this.LogXMLStartSection((LogSection) 7);
string str21 = this.m_prodInfo.m_productId.ToLower() + ".pat";
string defaultSupportFileDir3 = Migrator.FindDefaultSupportFileDir(MainForm.isACAD, str21, srcInfo.m_regRootKey);
string defaultSupportFileDir4 = Migrator.FindDefaultSupportFileDir(MainForm.isACAD, str21, this.ProductRegistryRootKey);
StringCollection newDir = FileMigrator.CopyFilesToNewDir(defaultSupportFileDir3, defaultSupportFileDir4, "*.pat", false);
string str22 = string.Format(this.m_LocalResources.GetString("LOG_ITEMS_MIGRATED"), (object) newDir.Count, (object) this.m_LocalResources.GetString("LOG_HATCH_USER_PAT"), (object) defaultSupportFileDir3, (object) defaultSupportFileDir4);
MainForm.Log2File(str22);
this.LogXMLElement((LogOperation) 1, (LogCategory) 3, str22);
}
catch (Exception ex)
{
string str = string.Format(this.m_LocalResources.GetString("ERROR_USER_PATTERN"), (object) ex.Message);
MainForm.Log2File(str);
this.LogXMLElement((LogOperation) 1, (LogCategory) 0, str);
Migrator.m_bErrors = true;
}
finally
{
this.LogXMLEndSection();
}
}
if (this.AcadPgpFilesCheck.Checked)
{
MainForm.Log2File(this.m_LocalResources.GetString("LOG_LINE"));
try
{
this.LogXMLStartSection((LogSection) 8);
string str23 = srcInfo.m_productId.ToLower() + ".pgp";
string str24 = this.m_prodInfo.m_productId.ToLower() + ".pgp";
StringCollection stringCollection = ((FileMigrator) new PGPFileMigrator()).MigrateFile(Migrator.FindFirstDefaultSupportFile(MainForm.isACAD, str23, srcInfo.m_regRootKey), Migrator.FindFirstDefaultSupportFile(MainForm.isACAD, str24, this.ProductRegistryRootKey));
string str25 = string.Format(this.m_LocalResources.GetString("PGP_MIGRATED"), (object) stringCollection.Count);
MainForm.Log2File(str25);
this.LogXMLElement((LogOperation) 1, (LogCategory) 4, str25);
}
catch (Exception ex)
{
string str = string.Format(this.m_LocalResources.GetString("ERROR_ACAD_PGP"), (object) this.m_prodInfo.m_productId.ToLower(), (object) ex.Message);
MainForm.Log2File(str);
this.LogXMLElement((LogOperation) 1, (LogCategory) 0, str);
Migrator.m_bErrors = true;
}
finally
{
this.LogXMLEndSection();
}
}
this.Hide();
if (MainForm.m_isVertMigration)
{
try
{
this.CallVerticalMigration("Start", (object[]) null);
}
catch (Exception ex)
{
string str = string.Format(this.m_LocalResources.GetString("ERROR_ACAD_VERTICAL"), (object) this.m_prodInfo.m_productId.ToLower(), (object) ex.Message);
MainForm.Log2File(str);
this.LogXMLElement((LogOperation) 2, (LogCategory) 0, str);
Migrator.m_bErrors = true;
}
}
string text;
if (Migrator.m_bErrors)
{
string str = string.Format(this.m_LocalResources.GetString("LOG_FINISHED_ERRORS"), (object) DateTime.Now);
MainForm.Log2File(str);
this.LogXMLStartSection((LogSection) 9);
this.LogXMLElement((LogOperation) 2, (LogCategory) 2, str);
text = this.m_LocalResources.GetString("ERROR_VIEW");
}
else
{
string str = string.Format(this.m_LocalResources.GetString("LOG_FINISHED_OK"), (object) DateTime.Now);
MainForm.Log2File(str);
this.LogXMLElement((LogOperation) 2, (LogCategory) 2, str);
text = this.m_LocalResources.GetString("SUCCESS_VIEW");
}
this.Cursor = Cursors.Default;
if (System.Windows.Forms.MessageBox.Show(text, this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.Yes)
{
try
{
Process.Start("IExplore.exe", MainForm.LogFileNameXml);
}
catch
{
int num = (int) System.Windows.Forms.MessageBox.Show(this.m_LocalResources.GetString("NO_LOG"), this.Text);
}
}
}
}
finally
{
this.LogXMLFinalize();
}
this.Close();
}
internal void CallVerticalMigration(string methodName, object[] parameters)
{
try
{
foreach (System.Type type in Assembly.LoadFrom(this.m_VertDLLPath).GetTypes())
{
if (type.FullName == "VerticalAdMigrator.VertAdMigrator")
{
Activator.CreateInstance(type);
foreach (MethodInfo method in type.GetMethods())
{
if (method.Name == methodName)
{
method.Invoke((object) null, parameters);
break;
}
}
}
}
}
catch (SystemException ex)
{
MainForm.m_isVertMigration = false;
}
}
public static void Log2File(string sLine)
{
FileStream fileStream = new FileStream(MainForm.LogFileName, FileMode.Append, FileAccess.Write, FileShare.None);
fileStream.Seek(0L, SeekOrigin.End);
sLine += "\r\n\r\n";
StreamWriter streamWriter = new StreamWriter((Stream) fileStream, Encoding.Default);
streamWriter.Write(sLine);
streamWriter.Flush();
streamWriter.Close();
fileStream.Close();
}
public void LogXMLInitialize()
{
MainForm.LogFileName = MainForm.MigrationFolder + "\\" + this.m_LocalResources.GetString("LOG_FILE");
MainForm.LogFileNameXml = Path.GetFileNameWithoutExtension(MainForm.LogFileName);
MainForm.LogFileNameXml = MainForm.MigrationFolder + "\\" + MainForm.LogFileNameXml + ".xml";
string str1 = MainForm.MigrationFolder + "\\migration.xsl";
string location = Assembly.GetEntryAssembly().Location;
string str2 = location.Substring(0, location.LastIndexOf("\\") + 1) + "migration.xsl";
if (!File.Exists(str1) && File.Exists(str2))
File.Copy(str2, str1, false);
File.Delete(MainForm.LogFileName);
File.Delete(MainForm.LogFileNameXml);
FileStream w = new FileStream(MainForm.LogFileNameXml, FileMode.Append, FileAccess.Write, FileShare.None);
w.Seek(0L, SeekOrigin.End);
MainForm.MainWriter = new XmlTextWriter((Stream) w, (Encoding) null);
MainForm.MainWriter.Formatting = Formatting.Indented;
MainForm.MainWriter.WriteStartDocument();
string text = "type='text/xsl' href='migration.xsl'";
MainForm.MainWriter.WriteProcessingInstruction("xml-stylesheet", text);
MainForm.MainWriter.WriteStartElement("Log");
MainForm.MainWriter.Flush();
}
public void LogXMLFinalize()
{
if (MainForm.MainWriter == null)
return;
MainForm.MainWriter.Formatting = Formatting.Indented;
MainForm.MainWriter.WriteEndElement();
MainForm.MainWriter.WriteEndDocument();
MainForm.MainWriter.Flush();
MainForm.MainWriter.Close();
}
public void LogXMLStartSection(LogSection section)
{
MainForm.MainWriter.Formatting = Formatting.Indented;
string enumDescription = Migrator.GetEnumDescription(typeof (LogSection), (Enum) (object) section);
MainForm.MainWriter.WriteStartElement("Section");
MainForm.MainWriter.WriteStartAttribute((string) null, "Name", (string) null);
MainForm.MainWriter.WriteString(enumDescription);
MainForm.MainWriter.WriteEndAttribute();
MainForm.MainWriter.Flush();
}
public void LogXMLElement(LogOperation operation, LogCategory category, string message)
{
MainForm.MainWriter.Formatting = Formatting.Indented;
string enumDescription1 = Migrator.GetEnumDescription(typeof (LogOperation), (Enum) (object) operation);
string enumDescription2 = Migrator.GetEnumDescription(typeof (LogCategory), (Enum) (object) category);
MainForm.MainWriter.WriteStartElement(enumDescription1);
MainForm.MainWriter.WriteStartAttribute((string) null, "Category", (string) null);
MainForm.MainWriter.WriteString(enumDescription2);
MainForm.MainWriter.WriteEndAttribute();
MainForm.MainWriter.WriteString(message);
MainForm.MainWriter.WriteEndElement();
MainForm.MainWriter.Flush();
}
public void LogXMLEndSection()
{
MainForm.MainWriter.Formatting = Formatting.Indented;
MainForm.MainWriter.WriteEndElement();
MainForm.MainWriter.Flush();
}
private void HelpBtn_Click(object sender, EventArgs e)
{
string location = Assembly.GetEntryAssembly().Location;
string url = location.Substring(0, location.LastIndexOf("\\") + 1) + "help\\" + this.m_prodInfo.m_productId + "_sig.chm";
string parameter = "admigrate.htm";
if (MainForm.m_isVertMigration)
this.CallVerticalMigration("VerticalHelp", new object[3]
{
(object) this,
(object) url,
(object) parameter
});
else
Help.ShowHelp((Control) this, url, HelpNavigator.Topic, (object) parameter);
}
private void MainForm_Closed(object sender, EventArgs e)
{
if (Migrator.HasMigrated(this.ProductRegistryRootKey))
return;
if (this.bRun)
Migrator.SetHasMigrated(this._Migrator, 0);
else
Migrator.SetHasMigrated(this._Migrator, 2);
}
private void UserProfilesCheck_CheckedChanged(object sender, EventArgs e)
{
if (!this.UserProfilesCheck.Checked)
{
this.CUIFilesCheck.Enabled = false;
this.MNUMNSFilesCheck.Enabled = false;
this.UserIconFilesCheck.Enabled = false;
}
else
{
this.UserIconFilesCheck.Enabled = true;
this.UpdateCheckBoxes(this.InstalledVersionsCombo);
}
}
internal static bool StringCollectionContains(StringCollection a, string b, bool ignoreCase)
{
if (a == null)
return false;
for (int index = 0; index < a.Count; ++index)
{
if (string.Compare(a[index], b, ignoreCase, CultureInfo.InvariantCulture) == 0)
return true;
}
return false;
}
private void InstalledVersionsCombo_SelectedIndexChanged(object sender, EventArgs e)
{
if (!(sender is ComboBox versionsCombo))
return;
this.UpdateCheckBoxes(versionsCombo);
}
private void UpdateCheckBoxes(ComboBox versionsCombo)
{
ProductInfo selectedItem = versionsCombo.SelectedItem as ProductInfo;
if (!this.UserProfilesCheck.Checked)
return;
if (selectedItem.m_dVersion >= this._Migrator.MinCUIVersion)
{
this.MNUMNSFilesCheck.Enabled = false;
this.MNUMNSFilesCheck.Checked = false;
this.CUIFilesCheck.Enabled = true;
this.CUIFilesCheck.Checked = true;
}
else if (selectedItem.IsBeforeRio())
{
this.MNUMNSFilesCheck.Enabled = true;
this.MNUMNSFilesCheck.Checked = true;
this.CUIFilesCheck.Enabled = false;
this.CUIFilesCheck.Checked = false;
}
else
{
this.MNUMNSFilesCheck.Enabled = false;
this.MNUMNSFilesCheck.Checked = false;
this.CUIFilesCheck.Enabled = false;
this.CUIFilesCheck.Checked = false;
}
}
private void ExportCustomizations()
{
try
{
this.InitProductInfo();
this.LogXMLInitialize();
this._Migrator.GetInstalledAppList(this.ProductRegistryRootKey);
this.m_prodInfo.m_migrationType = (ProductInfo.MigrationType) 1;
this.m_prodInfo.dataFile = new DataFile(MainForm.MigrationFolder + "\\MigrationDataFile.xml");
this.m_prodInfo.dataFile.SetProductInfo(this.m_prodInfo);
ExportDialog exportDialog = new ExportDialog(this);
exportDialog.BodyMessage.Text = string.Format(LocalResources.GetString("EXPORT_SETTINGS_BODY"), (object) this.m_prodInfo.m_productName);
if (exportDialog.ShowDialog((IWin32Window) this) != DialogResult.OK)
return;
this.m_includeNetworkFiles = exportDialog.IncludeNetworkedFiles;
System.Windows.Forms.SaveFileDialog saveFileDialog = new System.Windows.Forms.SaveFileDialog();
if (Settings.Default.ExportInitialDirectory != null && Settings.Default.ExportInitialDirectory.Length > 0)
saveFileDialog.InitialDirectory = Settings.Default.ExportInitialDirectory;
else
saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
saveFileDialog.CheckFileExists = false;
saveFileDialog.Title = LocalResources.GetString("EXPORT_TITLE");
saveFileDialog.Filter = LocalResources.GetString("ZIP_FILEDIALOG_FILTERS");
saveFileDialog.FileName = this.m_prodInfo.m_productName + LocalResources.GetString("DEFAULT_EXPORT_FILENAME_BODY") + ".zip";
if (saveFileDialog.ShowDialog() != DialogResult.OK || Autodesk.AutoCAD.Customization.Util.IsEmpty(saveFileDialog.FileName))
return;
using (ProgressForm progressForm = new ProgressForm())
{
progressForm.Show();
System.Windows.Forms.Application.DoEvents();
Settings.Default.ExportInitialDirectory = Path.GetDirectoryName(saveFileDialog.FileName);
this.m_prodInfo.zipInt = new ZipInterface();
this.m_prodInfo.zipInt.createZipFile(saveFileDialog.FileName);
this.m_prodInfo.m_zipFileName = saveFileDialog.FileName;
System.Windows.Forms.Application.DoEvents();
if (MainForm.m_isVertMigration)
{
this.CallVerticalMigration("ZipPreProcess", new object[2]
{
(object) saveFileDialog.FileName,
(object) this.m_prodInfo.m_regRootKey
});
StringDictionary stringDictionary = new StringDictionary();
this.CallVerticalMigration("VerticalEnvironmentVariables", new object[1]
{
(object) stringDictionary
});
if (stringDictionary.Count > 0)
{
foreach (string key in (IEnumerable) stringDictionary.Keys)
this.m_prodInfo.EnvVars.Add(key, stringDictionary[key], true);
}
}
System.Windows.Forms.Application.DoEvents();
string location = Assembly.GetEntryAssembly().Location;
// ISSUE: method pointer
new ProfileMigrator(location.Substring(0, location.LastIndexOf("\\") + 1) + "AdMigrator.xml")
{
IncludeNetworkedFiles = exportDialog.IncludeNetworkedFiles
}.Migrate(this._Migrator.destProductInfo(), this.m_prodInfo, this.ProductRegistryRootKey, new ProfileMigrator.Log((object) null, __methodptr(Log2File)));
System.Windows.Forms.Application.DoEvents();
this.m_prodInfo.dataFile.SetSourceVariables(this.m_prodInfo.EnvVars);
System.Windows.Forms.Application.DoEvents();
if (MainForm.m_isVertMigration)
this.CallVerticalMigration("ZipPostProcess", (object[]) null);
System.Windows.Forms.Application.DoEvents();
this.m_prodInfo.dataFile.Save();
this.m_prodInfo.zipInt.addFileToZip(this.m_prodInfo.dataFile.FileName);
File.Delete(this.m_prodInfo.dataFile.FileName);
}
int num = (int) System.Windows.Forms.MessageBox.Show(string.Format(LocalResources.GetString("EXPORT_SUCCESS"), (object) saveFileDialog.FileName), this.m_prodInfo.m_productName);
}
catch (SystemException ex)
{
int num = (int) System.Windows.Forms.MessageBox.Show(string.Format(LocalResources.GetString("EXPORT_FAILURE"), (object) ex.Message), this.m_prodInfo.m_productName);
}
finally
{
this.LogXMLFinalize();
if (this.m_prodInfo.zipInt != null)
this.m_prodInfo.zipInt.closeZipFile();
}
}
private void ImportCustomizations()
{
string text = "";
bool flag1 = false;
this.InitProductInfo();
this.LogXMLInitialize();
this._Migrator.GetInstalledAppList(this.ProductRegistryRootKey);
System.Windows.Forms.OpenFileDialog openFileDialog = new System.Windows.Forms.OpenFileDialog();
if (Settings.Default.ImportInitialDirectory != null && Settings.Default.ImportInitialDirectory.Length > 0)
openFileDialog.InitialDirectory = Settings.Default.ImportInitialDirectory;
else
openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
openFileDialog.Title = LocalResources.GetString("IMPORT_TITLE");
openFileDialog.Filter = LocalResources.GetString("ZIP_FILEDIALOG_FILTERS");
if (openFileDialog.ShowDialog() != DialogResult.OK || Autodesk.AutoCAD.Customization.Util.IsEmpty(openFileDialog.FileName))
return;
Settings.Default.ImportInitialDirectory = Path.GetDirectoryName(openFileDialog.FileName);
this.m_prodInfo.zipInt = new ZipInterface();
int num1 = this.m_prodInfo.zipInt.initZipExtraction(openFileDialog.FileName, MainForm.MigrationFolder);
if (num1 < 0)
{
if (num1 == -2)
text = string.Format(LocalResources.GetString("ERROR_NOT_EXPORT_PACKAGE"), (object) this.m_prodInfo.m_productName);
if (num1 == -1)
text = LocalResources.GetString("ERROR_UNZIPPING_FILE");
int num2 = (int) System.Windows.Forms.MessageBox.Show(text, LocalResources.GetString("IMPORT_TITLE"));
}
else
{
this.m_prodInfo.m_migrationType = (ProductInfo.MigrationType) 1;
this.m_prodInfo.dataFile = new DataFile(MainForm.MigrationFolder + "\\MigrationDataFile.xml");
this.m_prodInfo.PostProcessDataFile();
bool flag2 = true;
if (string.Compare(this.m_prodInfo.m_productId, this._Migrator.destProductInfo().m_productId, true, CultureInfo.InvariantCulture) != 0)
flag2 = false;
if (string.Compare(this.m_prodInfo.m_productTag, this._Migrator.destProductInfo().m_productTag, true, CultureInfo.InvariantCulture) != 0)
flag2 = false;
if (string.Compare(this.m_prodInfo.m_version, this._Migrator.destProductInfo().m_version, true, CultureInfo.InvariantCulture) != 0)
flag2 = false;
if (string.Compare(this.m_prodInfo.m_languageTag, this._Migrator.destProductInfo().m_languageTag, true, CultureInfo.InvariantCulture) != 0)
flag2 = false;
if (!flag2)
{
int num3 = (int) System.Windows.Forms.MessageBox.Show(string.Format(LocalResources.GetString("ERROR_IMPORT_TYPE"), (object) this.m_prodInfo.m_productName, (object) this.m_prodInfo.m_version, (object) this.m_prodInfo.m_languageTag), LocalResources.GetString("IMPORT_TITLE"));
}
else
{
if (string.Compare(this.m_prodInfo.dataFile.Culture, CultureInfo.CurrentCulture.Name, true, CultureInfo.InvariantCulture) != 0)
{
int num4 = (int) System.Windows.Forms.MessageBox.Show(LocalResources.GetString("WARNING_DIFFERENTCODEPAGE"), LocalResources.GetString("IMPORT_TITLE"));
}
DirectoryInfo directory = Directory.CreateDirectory(Path.GetTempPath() + "\\AdMigExtraction");
this.m_prodInfo.m_zipExtractDir = directory.FullName;
try
{
using (ProgressForm progressForm = new ProgressForm())
{
progressForm.Show();
System.Windows.Forms.Application.DoEvents();
this.LogXMLStartSection((LogSection) 10);
this.LogXMLElement((LogOperation) 2, (LogCategory) 1, string.Format(this.m_LocalResources.GetString("IMPORT_FILE"), (object) openFileDialog.FileName));
string location = Assembly.GetEntryAssembly().Location;
ProfileMigrator profileMigrator = new ProfileMigrator(location.Substring(0, location.LastIndexOf("\\") + 1) + "AdMigrator.xml");
System.Windows.Forms.Application.DoEvents();
if (MainForm.m_isVertMigration)
{
this.CallVerticalMigration("UnZipPreProcess", new object[2]
{
(object) directory.FullName,
(object) this.ProductRegistryRootKey
});
StringDictionary stringDictionary = new StringDictionary();
this.CallVerticalMigration("VerticalEnvironmentVariables", new object[1]
{
(object) stringDictionary
});
if (stringDictionary.Count > 0)
{
foreach (string key in (IEnumerable) stringDictionary.Keys)
this._Migrator.destProductInfo().EnvVars.Add(key, stringDictionary[key], true);
}
}
System.Windows.Forms.Application.DoEvents();
// ISSUE: method pointer
flag1 = profileMigrator.Migrate(this.m_prodInfo, this._Migrator.destProductInfo(), this.ProductRegistryRootKey, new ProfileMigrator.Log((object) null, __methodptr(Log2File)));
System.Windows.Forms.Application.DoEvents();
if (MainForm.m_isVertMigration)
this.CallVerticalMigration("UnZipPostProcess", (object[]) null);
System.Windows.Forms.Application.DoEvents();
}
}
catch (Exception ex)
{
string str = string.Format(this.m_LocalResources.GetString("ERROR_UNKNOWN"), (object) ex.Message);
this.LogXMLElement((LogOperation) 0, (LogCategory) 0, str);
MainForm.Log2File(str);
Migrator.m_bErrors = true;
}
finally
{
this.LogXMLEndSection();
if (this.m_prodInfo.zipInt != null)
this.m_prodInfo.zipInt.closeUnzip();
if (Directory.Exists(this.m_prodInfo.m_zipExtractDir))
Directory.Delete(this.m_prodInfo.m_zipExtractDir, true);
if (File.Exists(this.m_prodInfo.dataFile.FileName))
File.Delete(this.m_prodInfo.dataFile.FileName);
}
this.LogXMLFinalize();
ImportDialog importDialog = new ImportDialog();
if (flag1)
{
string str = string.Format(this.m_LocalResources.GetString("IMPORT_LOG_LOCATION"), (object) MainForm.LogFileNameXml);
importDialog.labelLogText = str;
}
else
{
string str = this.m_LocalResources.GetString("IMPORT_FAILURE");
importDialog.successMsg = str;
}
int num5 = (int) importDialog.ShowDialog();
if (!importDialog.displayLog)
return;
try
{
Process.Start("IExplore.exe", MainForm.LogFileNameXml);
}
catch
{
int num6 = (int) System.Windows.Forms.MessageBox.Show(this.m_LocalResources.GetString("NO_LOG"), this.Text);
}
}
}
}
public static CUIFileMap GetFileMapFromMenuGroup(string menuGroupName)
{
foreach (CUIFileMap cuiFileMap in MainForm.CUIFileMapArray)
{
if (menuGroupName.Equals(cuiFileMap.SourceMenuGroupName, StringComparison.InvariantCultureIgnoreCase))
return cuiFileMap;
}
return (CUIFileMap) null;
}
public static CUIFileMap GetFileMapFromMacroGroup(string macroGroupName)
{
foreach (CUIFileMap cuiFileMap in MainForm.CUIFileMapArray)
{
if (macroGroupName.Equals(cuiFileMap.SourceMacroGroupName, StringComparison.InvariantCultureIgnoreCase))
return cuiFileMap;
}
return (CUIFileMap) null;
}
public static CUIFileMap GetFileMapFromFileName(string fileName)
{
string withoutExtension1 = Path.GetFileNameWithoutExtension(fileName);
foreach (CUIFileMap cuiFileMap in MainForm.CUIFileMapArray)
{
string withoutExtension2 = Path.GetFileNameWithoutExtension(cuiFileMap.SourceFileName);
if (withoutExtension1.Equals(withoutExtension2, StringComparison.InvariantCultureIgnoreCase))
return cuiFileMap;
}
return (CUIFileMap) null;
}
}
}