コード例 #1
0
        ProcessExtensionOpenCommand(string cloneName, string extName)
        {
            if (extName != null)
            {
                PyRevitClone clone = null;
                if (cloneName != null)
                {
                    clone = PyRevitClones.GetRegisteredClone(cloneName);
                }

                PyRevitExtension ext;
                if (clone != null)
                {
                    ext = PyRevitExtensions.GetShippedExtension(clone, extName);
                }
                else
                {
                    ext = PyRevitExtensions.GetInstalledExtension(extName);
                }

                if (ext != null)
                {
                    CommonUtils.OpenInExplorer(ext.InstallPath);
                }
            }
        }
コード例 #2
0
        ToggleExtension(bool enable, string cloneName, string extName)
        {
            if (extName != null)
            {
                PyRevitClone clone = null;
                if (cloneName != null)
                {
                    clone = PyRevitClones.GetRegisteredClone(cloneName);
                }

                if (enable)
                {
                    if (clone != null)
                    {
                        PyRevitExtensions.EnableShippedExtension(clone, extName);
                    }
                    else
                    {
                        PyRevitExtensions.EnableInstalledExtension(extName);
                    }
                }
                else
                {
                    if (clone != null)
                    {
                        PyRevitExtensions.DisableShippedExtension(clone, extName);
                    }
                    else
                    {
                        PyRevitExtensions.DisableInstalledExtension(extName);
                    }
                }
            }
        }
コード例 #3
0
        AttachClone(PyRevitClone clone, PyRevitEngineVersion engineVersion,
                    string revitYear, bool installed, bool attached,
                    bool allUsers)
        {
            // decide targets revits to attach to
            int revitYearNumber = 0;

            if (installed)
            {
                foreach (var revit in RevitProduct.ListInstalledProducts())
                {
                    PyRevitAttachments.Attach(revit.ProductYear, clone, engineVer: engineVersion, allUsers: allUsers);
                }
            }
            else if (attached)
            {
                foreach (var attachment in PyRevitAttachments.GetAttachments())
                {
                    PyRevitAttachments.Attach(attachment.Product.ProductYear, clone, engineVer: engineVersion, allUsers: allUsers);
                }
            }
            else if (int.TryParse(revitYear, out revitYearNumber))
            {
                PyRevitAttachments.Attach(revitYearNumber, clone, engineVer: engineVersion, allUsers: allUsers);
            }
        }
コード例 #4
0
        internal static void UpdateFromOutsideAndClose(PyRevitClone clone)
        {
            logger.Debug("Updating clone \"{0}\" using outside process", clone.Name);

            // prepare outside updater
            var updaterTempBinary = updaterBinaryName + ".exe";
            var updaterBinaryPath = Path.Combine(GetProcessPath(), updaterBinaryName);
            var updaterTempPath   = Path.Combine(UserEnv.UserTemp, updaterTempBinary);

            logger.Debug("Setting up \"{0}\" to \"{1}\"", updaterBinaryPath, updaterTempPath);
            File.Copy(updaterBinaryPath, updaterTempPath, overwrite: true);

            // make a updater bat file
            var updaterBATFile = Path.Combine(UserEnv.UserTemp, updaterBinaryName + ".bat");

            using (var batFile = new StreamWriter(File.Create(updaterBATFile))) {
                batFile.WriteLine("@ECHO OFF");
                batFile.WriteLine("TIMEOUT /t 1 /nobreak >NUL  2>NUL");
                batFile.WriteLine("TASKKILL /IM \"{0}\" >NUL  2>NUL", Path.GetFileName(Process.GetCurrentProcess().MainModule.FileName));
                batFile.WriteLine("START \"\" /B \"{0}\" \"{1}\"", updaterTempPath, clone.ClonePath);
            }

            // launch update
            ProcessStartInfo updaterProcessInfo = new ProcessStartInfo(updaterBATFile);

            updaterProcessInfo.WorkingDirectory = Path.GetDirectoryName(updaterTempPath);
            updaterProcessInfo.UseShellExecute  = false;
            updaterProcessInfo.CreateNoWindow   = true;
            logger.Debug("Calling outside update and exiting...");
            Process.Start(updaterProcessInfo);
            // and exit self
            Environment.Exit(0);
        }
コード例 #5
0
        AttachClone(PyRevitClone clone, string engineId,
                    string revitYear, bool installed, bool attached,
                    bool allUsers)
        {
            var engine = clone.GetConfiguredEngine(engineId);

            AttachClone(clone, engine.Version, revitYear, installed, attached, allUsers);
        }
コード例 #6
0
        UpdateClone(bool allClones, string cloneName, GitInstallerCredentials credentials)
        {
            // TODO: ask for closing running Revits

            // prepare a list of clones to be updated
            var targetClones = new List <PyRevitClone>();
            // separate the clone that this process might be running from
            // this is used to update this clone from outside since the dlls will be locked
            PyRevitClone myClone = null;

            // all clones
            if (allClones)
            {
                foreach (var clone in PyRevitClones.GetRegisteredClones())
                {
                    if (PyRevitCLIAppCmds.IsRunningInsideClone(clone))
                    {
                        myClone = clone;
                    }
                    else
                    {
                        targetClones.Add(clone);
                    }
                }
            }
            // or single clone
            else
            {
                if (cloneName != null)
                {
                    var clone = PyRevitClones.GetRegisteredClone(cloneName);
                    if (PyRevitCLIAppCmds.IsRunningInsideClone(clone))
                    {
                        myClone = clone;
                    }
                    else
                    {
                        targetClones.Add(clone);
                    }
                }
            }

            // update clones that do not include this process
            foreach (var clone in targetClones)
            {
                logger.Debug("Updating clone \"{0}\"", clone.Name);
                PyRevitClones.Update(clone, credentials);
            }

            // now update myClone if any, as last step
            if (myClone != null)
            {
                throw new PyRevitException("Can not update clone that contains this command line utility. "
                                           + "Use installer to update.");
            }
        }
コード例 #7
0
        UpdateClone(bool allClones, string cloneName)
        {
            // TODO: ask for closing running Revits

            // prepare a list of clones to be updated
            var targetClones = new List <PyRevitClone>();
            // separate the clone that this process might be running from
            // this is used to update this clone from outside since the dlls will be locked
            PyRevitClone myClone = null;

            // all clones
            if (allClones)
            {
                foreach (var clone in PyRevit.GetRegisteredClones())
                {
                    if (PyRevitCLIAppCmds.IsRunningInsideClone(clone))
                    {
                        myClone = clone;
                    }
                    else
                    {
                        targetClones.Add(clone);
                    }
                }
            }
            // or single clone
            else
            {
                if (cloneName != null)
                {
                    var clone = PyRevit.GetRegisteredClone(cloneName);
                    if (PyRevitCLIAppCmds.IsRunningInsideClone(clone))
                    {
                        myClone = clone;
                    }
                    else
                    {
                        targetClones.Add(clone);
                    }
                }
            }

            // update clones that do not include this process
            foreach (var clone in targetClones)
            {
                logger.Debug("Updating clone \"{0}\"", clone.Name);
                PyRevit.Update(clone);
            }

            // now update myClone if any, as last step
            if (myClone != null)
            {
                PyRevitCLIAppCmds.UpdateFromOutsideAndClose(myClone);
            }
        }
コード例 #8
0
 internal static bool IsRunningInsideClone(PyRevitClone clone) =>
 GetProcessPath().NormalizeAsPath().Contains(clone.ClonePath.NormalizeAsPath());
コード例 #9
0
 internal static void ReportCloneAsNoGit(PyRevitClone clone) =>
 Console.WriteLine(
     string.Format("Clone \"{0}\" is a deployment and is not a git repo.",
                   clone.Name)
     );