コード例 #1
0
        private bool UninstallTool(ToolInfo info)
        {
            bool removed = false;

            try
            {
                if (info.ToolTypeEnum == ToolType.REVIT)
                {
                    foreach (string file in info.Files)
                    {
                        string installPath = info.InstallDirectory + info.Version + file;
                        File.Delete(installPath);
                    }

                    string addInDirectory = info.InstallDirectory + info.Version + @"\Arup.IssueTracker.Revit";
                    if (Directory.Exists(addInDirectory))
                    {
                        Directory.Delete(addInDirectory, true);
                    }

                    string dllPath = info.InstallDirectory + info.Version + info.DllPath;
                    if (!File.Exists(dllPath))
                    {
                        removed = true;
                    }
                }
                else if (info.ToolTypeEnum == ToolType.NAVISWORKS)
                {
                    foreach (string file in info.Files)
                    {
                        string installPath = info.InstallDirectory + file;
                        File.Delete(installPath);
                    }

                    string pluginDirectory = info.InstallDirectory + @"\ARUP.IssueTracker.Navisworks";
                    if (Directory.Exists(pluginDirectory))
                    {
                        Directory.Delete(pluginDirectory, true);
                    }

                    string dllPath = info.InstallDirectory + info.DllPath;
                    if (!File.Exists(dllPath))
                    {
                        removed = true;
                    }
                }
                else if (info.ToolTypeEnum == ToolType.DESKTOP)
                {
                    string uninstallString = toolManager.GetUninstallString(info.ToolName);

                    ProcessStartInfo psi = new ProcessStartInfo();
                    psi.UseShellExecute  = true;
                    psi.WorkingDirectory = @"C:\Windows\System32";
                    psi.FileName         = @"C:\Windows\System32\cmd.exe";
                    psi.Arguments        = "/c " + uninstallString;
                    psi.WindowStyle      = ProcessWindowStyle.Hidden;
                    Process.Start(psi);
                    removed = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(info.ToolName + "\nFailed to remove the tool.\n" + ex.Message, "Uninstall Tool", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            return(removed);
        }
コード例 #2
0
        private bool InstallTool(ToolInfo info)
        {
            bool installed = false;

            try
            {
                if (info.ToolTypeEnum == ToolType.REVIT)
                {
                    if (!Directory.Exists(info.InstallDirectory + info.Version))
                    {
                        return(false);
                    }
                    string addInDirectory = info.InstallDirectory + info.Version + @"\Arup.IssueTracker.Revit";
                    if (!Directory.Exists(addInDirectory))
                    {
                        Directory.CreateDirectory(addInDirectory);
                    }

                    if (ApplicationDeployment.IsNetworkDeployed)
                    {
                        foreach (string file in info.Files)
                        {
                            string sourceFile  = info.SourceDirectory + @"\Revit\" + info.Version + file;
                            string installPath = info.InstallDirectory + info.Version + file;
                            File.Copy(sourceFile, installPath, true);
                        }
                    }

                    string dllPath = info.InstallDirectory + info.Version + info.DllPath;
                    if (File.Exists(dllPath))
                    {
                        installed = true;
                    }
                }
                else if (info.ToolTypeEnum == ToolType.NAVISWORKS)
                {
                    if (!Directory.Exists(info.InstallDirectory))
                    {
                        return(false);
                    }
                    string pluginDirectory = info.InstallDirectory + @"\ARUP.IssueTracker.Navisworks";
                    if (!Directory.Exists(pluginDirectory))
                    {
                        Directory.CreateDirectory(pluginDirectory);

                        string langDirectory = System.IO.Path.Combine(pluginDirectory, "en-US");
                        Directory.CreateDirectory(langDirectory);
                        string imageDirectory = System.IO.Path.Combine(pluginDirectory, "Images");
                        Directory.CreateDirectory(imageDirectory);
                    }

                    if (ApplicationDeployment.IsNetworkDeployed)
                    {
                        foreach (string file in info.Files)
                        {
                            string sourceFile  = info.SourceDirectory + @"\Navisworks\" + info.Version + file;
                            string installPath = info.InstallDirectory + file;
                            File.Copy(sourceFile, installPath, true);
                        }
                    }

                    string dllPath = info.InstallDirectory + info.DllPath;
                    if (File.Exists(dllPath))
                    {
                        installed = true;
                    }
                }
                else if (info.ToolTypeEnum == ToolType.DESKTOP)
                {
                    MessageBoxResult result = MessageBox.Show("The desktop version of " + info.ToolName + " will be installed.\nPlease follow the on-screen instructions to complete the process.", "ClickOnce Installeation", MessageBoxButton.OKCancel, MessageBoxImage.Question);
                    if (result == MessageBoxResult.OK)
                    {
                        Process.Start(info.ExePath);
                        installed = true;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(info.ToolName + "\nFailed to install tool.\n" + ex.Message, "Install Tool", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            return(installed);
        }
コード例 #3
0
        public void GetToolInfo()
        {
            try
            {
                //desktop
                ToolInfo rvt2014Info = new ToolInfo()
                {
                    ToolName         = "Arup Issue Tracker for Revit 2014",
                    ToolTypeEnum     = ToolType.REVIT,
                    IsSelected       = true,
                    Version          = "2014",
                    InstallDirectory = addInDirectory,
                    SourceDirectory  = dataDirectory,
                    DllPath          = rvtDllFile,
                    Files            = rvtFiles
                };
                tools.Add(rvt2014Info);

                ToolInfo rvt2015Info = new ToolInfo()
                {
                    ToolName         = "Arup Issue Tracker for Revit 2015",
                    ToolTypeEnum     = ToolType.REVIT,
                    IsSelected       = true,
                    Version          = "2015",
                    InstallDirectory = addInDirectory,
                    SourceDirectory  = dataDirectory,
                    DllPath          = rvtDllFile,
                    Files            = rvtFiles
                };
                tools.Add(rvt2015Info);

                ToolInfo rvt2016Info = new ToolInfo()
                {
                    ToolName         = "Arup Issue Tracker for Revit 2016",
                    ToolTypeEnum     = ToolType.REVIT,
                    IsSelected       = true,
                    Version          = "2016",
                    InstallDirectory = addInDirectory,
                    SourceDirectory  = dataDirectory,
                    DllPath          = rvtDllFile,
                    Files            = rvtFiles
                };
                tools.Add(rvt2016Info);

                ToolInfo nav2014Info = new ToolInfo()
                {
                    ToolName         = "Arup Issue Tracker for Navisworks 2014",
                    ToolTypeEnum     = ToolType.NAVISWORKS,
                    IsSelected       = true,
                    Version          = "2014",
                    InstallDirectory = appDataDirectory + @"\Autodesk Navisworks Manage 2014\Plugins",
                    SourceDirectory  = dataDirectory,
                    DllPath          = navDllFile,
                    Files            = navFiles
                };
                tools.Add(nav2014Info);

                ToolInfo nav2015Info = new ToolInfo()
                {
                    ToolName         = "Arup Issue Tracker for Navisworks 2015",
                    ToolTypeEnum     = ToolType.NAVISWORKS,
                    IsSelected       = true,
                    Version          = "2015",
                    InstallDirectory = appDataDirectory + @"\Autodesk Navisworks Manage 2015\Plugins",
                    SourceDirectory  = dataDirectory,
                    DllPath          = navDllFile,
                    Files            = navFiles
                };
                tools.Add(nav2015Info);

                ToolInfo nav2016Info = new ToolInfo()
                {
                    ToolName         = "Arup Issue Tracker for Navisworks 2016",
                    ToolTypeEnum     = ToolType.NAVISWORKS,
                    IsSelected       = true,
                    Version          = "2016",
                    InstallDirectory = appDataDirectory + @"\Autodesk Navisworks Manage 2016\Plugins",
                    SourceDirectory  = dataDirectory,
                    DllPath          = navDllFile,
                    Files            = navFiles
                };
                tools.Add(nav2016Info);

                ToolInfo desktopInfo = new ToolInfo()
                {
                    ToolName     = "Arup Issue Tracker Desktop",
                    ToolTypeEnum = ToolType.DESKTOP,
                    IsSelected   = true,
                    ExePath      = "http://assets.hok.com/app/buildingsmart/ArupIssueTracker/Win/ARUP.IssueTracker.Win.application"
                };
                tools.Add(desktopInfo);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to get tool's information.\n" + ex.Message, "Get Tool Info", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }