Esempio n. 1
0
        public static string CreateSupportPackage()
        {
            string path2 = Guid.NewGuid().ToString();
            string str1  = Path.Combine(Path.GetTempPath(), path2);

            Trace.TraceInformation("Creating support package...");
            Directory.CreateDirectory(str1);
            try
            {
                File.Copy(VmcStudioUtil.LogFilePath, Path.Combine(str1, Path.GetFileName(VmcStudioUtil.LogFilePath)));
                string path1 = Path.Combine(VmcStudioUtil.ApplicationDataPath, "Logs");
                if (Directory.Exists(path1))
                {
                    FileUtil.CopyTo(new DirectoryInfo(path1), Path.Combine(str1, "Logs"), true);
                }
                using (StreamWriter text = File.CreateText(Path.Combine(str1, "info.txt")))
                {
                    text.WriteLine("Support package ID: {0}", (object)path2);
                    text.WriteLine("{1} Version: {0}", (object)Assembly.GetEntryAssembly().GetName().Version, (object)VmcStudioUtil.ApplicationName);
                    FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(Path.Combine(MediaCenterUtil.MediaCenterPath, "ehshell.exe"));
                    text.WriteLine("Media Center Version: {0}", (object)versionInfo.ProductVersion);
                    text.WriteLine("Date/Time: {0}", (object)DateTime.Now);
                    text.WriteLine("User preferred language: {0}", (object)LanguageUtils.GetUserDefaultUILanguage());
                    text.WriteLine("System default language: {0}", (object)LanguageUtils.GetSystemDefaultUILanguage());
                    text.WriteLine();
                    try
                    {
                        text.WriteLine("Dumping registry...");
                        string str2 = Path.Combine(str1, "Registry");
                        Directory.CreateDirectory(str2);
                        using (RegistryKey key1 = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Media Center\\Extensibility"))
                        {
                            using (RegistryKey key2 = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Media Center\\Extensibility"))
                            {
                                using (RegistryKey key3 = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Media Center\\Start Menu"))
                                {
                                    using (RegistryKey key4 = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Media Center\\Start Menu"))
                                    {
                                        VmcStudioUtil.DumpRegistry(key1, Path.Combine(str2, "HKEY_LOCAL_MACHINE Extensibility.txt"));
                                        VmcStudioUtil.DumpRegistry(key2, Path.Combine(str2, "HKEY_CURRENT_USER Extensibility.txt"));
                                        VmcStudioUtil.DumpRegistry(key3, Path.Combine(str2, "HKEY_LOCAL_MACHINE Start Menu.txt"));
                                        VmcStudioUtil.DumpRegistry(key4, Path.Combine(str2, "HKEY_CURRENT_USER Start Menu.txt"));
                                    }
                                }
                            }
                        }
                        text.WriteLine("Success!");
                    }
                    catch (Exception ex)
                    {
                        text.WriteLine(((object)ex).ToString());
                    }
                    text.WriteLine();
                    try
                    {
                        text.WriteLine("Dumping resources...");
                        string path3 = Path.Combine(str1, "Resources");
                        Directory.CreateDirectory(path3);
                        using (MediaCenterLibraryCache centerLibraryCache = new MediaCenterLibraryCache(MediaCenterUtil.MediaCenterPath))
                        {
                            IResourceLibrary lib = centerLibraryCache["ehres.dll"];
                            VmcStudioUtil.DumpHtmlResource(lib, "STARTMENU.XML", path3);
                            VmcStudioUtil.DumpHtmlResource(lib, "SM.ACTIVITIES.XML", path3);
                            VmcStudioUtil.DumpHtmlResource(lib, "SM.MUSIC.XML", path3);
                            VmcStudioUtil.DumpHtmlResource(lib, "SM.PICTURES.XML", path3);
                            VmcStudioUtil.DumpHtmlResource(lib, "SM.SPORTS.XML", path3);
                            VmcStudioUtil.DumpHtmlResource(lib, "SM.TV.XML", path3);
                            UnmanagedLibrary unmanagedLibrary = lib as UnmanagedLibrary;
                            if (unmanagedLibrary != null)
                            {
                                text.WriteLine("ehres.dll MUI languages: {0}", (object)VmcStudioUtil.ArrayToString(unmanagedLibrary.GetMUI().Languages));
                            }
                            text.WriteLine("STARTMENU.XML languages: {0}", (object)VmcStudioUtil.ArrayToString(lib.GetResource("STARTMENU.XML", (object)23).Languages));
                        }
                        text.WriteLine("Success!");
                    }
                    catch (Exception ex)
                    {
                        text.WriteLine(((object)ex).ToString());
                    }
                }
                string str3 = Path.Combine(VmcStudioUtil.UserPath, "Support Packages");
                if (!Directory.Exists(str3))
                {
                    Directory.CreateDirectory(str3);
                }
                string str4 = Path.Combine(str3, string.Format("Media Center Studio Support {0}.zip", (object)path2));
                new FastZip().CreateZip(str4, str1, true, (string)null);
                Trace.WriteLine("Support package successfully created at {0}", str4);
                return(str4);
            }
            finally
            {
                Directory.Delete(str1, true);
            }
        }