Ejemplo n.º 1
0
        CreateEnvJson()
        {
            // collecet search paths
            var searchPaths = new List <string>()
            {
                PyRevitConsts.DefaultExtensionsPath
            };

            searchPaths.AddRange(PyRevitExtensions.GetRegisteredExtensionSearchPaths());

            // collect list of lookup sources
            var lookupSrc = new List <string>()
            {
                PyRevitExtensions.GetDefaultExtensionLookupSource()
            };

            lookupSrc.AddRange(PyRevitExtensions.GetRegisteredExtensionLookupSources());

            // create json data object
            var jsonData = new Dictionary <string, object>()
            {
                { "meta", new Dictionary <string, object>()
                  {
                      { "version", "0.1.0" }
                  } },
                { "clones", PyRevitClones.GetRegisteredClones() },
                { "attachments", PyRevitAttachments.GetAttachments() },
                { "extensions", PyRevitExtensions.GetInstalledExtensions() },
                { "searchPaths", searchPaths },
                { "lookupSources", lookupSrc },
                { "installed", RevitProduct.ListInstalledProducts() },
                { "running", RevitController.ListRunningRevits() },
                { "pyrevitDataDir", PyRevitLabsConsts.PyRevitPath },
                { "userEnv", new Dictionary <string, object>()
                  {
                      { "osVersion", UserEnv.GetWindowsVersion() },
                      { "execUser", string.Format("{0}\\{1}", Environment.UserDomainName, Environment.UserName) },
                      { "activeUser", UserEnv.GetLoggedInUserName() },
                      { "isAdmin", UserEnv.IsRunAsAdmin() },
                      { "userAppdata", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) },
                      { "latestFramework", UserEnv.GetInstalledDotNetVersion() },
                      { "targetPacks", UserEnv.GetInstalledDotnetTargetPacks() },
                      { "targetPacksCore", UserEnv.GetInstalledDotnetCoreTargetPacks() },
                      { "cliVersion", PyRevitCLI.CLIVersion },
                  } },
            };

            var jsonExportCfg = new JsonSerializerSettings {
                Error = delegate(object sender, pyRevitLabs.Json.Serialization.ErrorEventArgs args) {
                    args.ErrorContext.Handled = true;
                },
                ContractResolver = new CamelCasePropertyNamesContractResolver()
            };

            jsonExportCfg.Converters.Add(new JsonVersionConverter());

            return(JsonConvert.SerializeObject(jsonData, jsonExportCfg));
        }
Ejemplo n.º 2
0
        PrinUserEnv()
        {
            PrintHeader("User Environment");
            Console.WriteLine(UserEnv.GetWindowsVersion());
            Console.WriteLine(string.Format("Executing User: {0}\\{1}",
                                            Environment.UserDomainName, Environment.UserName));
            Console.WriteLine(string.Format("Active User: {0}", UserEnv.GetLoggedInUserName()));
            Console.WriteLine(string.Format("Admin Access: {0}", UserEnv.IsRunAsAdmin() ? "Yes" : "No"));
            Console.WriteLine(string.Format("%APPDATA%: \"{0}\"",
                                            Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)));
            Console.WriteLine(string.Format("Latest Installed .Net Framework: {0}",
                                            UserEnv.GetInstalledDotNetVersion()));
            try {
                string targetPacks = "";
                foreach (string targetPackagePath in UserEnv.GetInstalledDotnetTargetPacks())
                {
                    targetPacks += string.Format("{0} ", Path.GetFileName(targetPackagePath));
                }
                Console.WriteLine(string.Format("Installed .Net Target Packs: {0}", targetPacks));
            }
            catch {
                Console.WriteLine("No .Net Target Packs are installed.");
            }

            try {
                string targetPacks = "";
                foreach (string targetPackagePath in UserEnv.GetInstalledDotnetCoreTargetPacks())
                {
                    targetPacks += string.Format("v{0} ", Path.GetFileName(targetPackagePath));
                }
                Console.WriteLine(string.Format("Installed .Net-Core Target Packs: {0}", targetPacks));
            }
            catch {
                Console.WriteLine("No .Ne-Core Target Packs are installed.");
            }

            Console.WriteLine(string.Format("pyRevit CLI {0}", PyRevitCLI.CLIVersion.ToString()));
        }