Esempio n. 1
0
        private void InitTree(string vaultName)
        {
            MasterController mc = new MasterController(m_conn, vaultName);

            foreach (DeploymentContainerController controller in mc.ContainerControllers)
            {
                DeploymentContainer container         = controller.DetectItems();
                DeploymentContainer selectedContainer = m_deploymentModel.Containers.FirstOrDefault(
                    n => n.Key == container.Key);

                if (selectedContainer == null)
                {
                    selectedContainer = new DeploymentContainer()
                    {
                        DeploymentItems = new List <DeploymentItem>()
                    }
                }
                ;

                if (container.DeploymentItems.Any())
                {
                    TreeNode node = m_deploymentTreeView.Nodes.Add(container.DisplayName);
                    node.Tag = container;

                    foreach (DeploymentItem item in container.DeploymentItems)
                    {
                        TreeNode subNode = node.Nodes.Add(item.DisplayName);
                        subNode.Tag = item;

                        if (selectedContainer.DeploymentItems.Any(n => n.DisplayName == item.DisplayName))
                        {
                            subNode.Checked = true;
                            node.Checked    = true;
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        private void CheckForUpdates(string serverName, string vaultName, Connection conn)
        {
            if (m_restartPending)
            {
                return;
            }

            Settings settings = Settings.Load();

            // user previously indicated not to download updates and not to be prompted
            if (settings.NeverDownload)
            {
                return;
            }

            string defaultFolder = conn.WebServiceManager.KnowledgeVaultService.GetVaultOption(DEFAULT_FOLDER_OPTION);

            if (defaultFolder == null || defaultFolder.Length == 0)
            {
                return;
            }
            if (!defaultFolder.EndsWith("/"))
            {
                defaultFolder += "/";
            }

            string deploymentPath = defaultFolder + PACKAGE_NAME;

            Autodesk.Connectivity.WebServices.File [] files = conn.WebServiceManager.DocumentService.FindLatestFilesByPaths(
                deploymentPath.ToSingleArray());

            if (files == null || files.Length == 0 || files[0].Id <= 0 || files[0].Cloaked)
            {
                return; // no package found
            }
            VaultEntry entry = settings.GetOrCreateEntry(serverName, vaultName);

            if (entry != null && entry.LastUpdate >= files[0].CkInDate)
            {
                return;  // we are up to date
            }
            StringBuilder updateList = new StringBuilder();

            string          deploymentXml   = conn.WebServiceManager.KnowledgeVaultService.GetVaultOption(DEPLOYMENT_CONFIG_OPTION);
            DeploymentModel deploymentModel = DeploymentModel.Load(deploymentXml);

            if (deploymentModel == null || deploymentModel.Containers == null)
            {
                return;
            }

            foreach (DeploymentContainer container in deploymentModel.Containers)
            {
                updateList.AppendLine(container.DisplayName);

                foreach (DeploymentItem item in container.DeploymentItems)
                {
                    updateList.AppendLine("- " + item.DisplayName);
                }

                updateList.AppendLine();
            }

            AskDialog    ask    = new AskDialog(updateList.ToString());
            DialogResult result = ask.ShowDialog();

            if (result == DialogResult.OK)
            {
                if (ask.AskResult == AskDialog.AskResultEnum.No)
                {
                    return;
                }
                else if (ask.AskResult == AskDialog.AskResultEnum.Never)
                {
                    settings.NeverDownload = true;
                    settings.Save();
                    return;
                }
            }
            else
            {
                return;
            }

            // if we got here, the user cliecked yes.


            string tempPath = Path.Combine(Path.GetTempPath(), "Thunderdome");

            if (!tempPath.EndsWith("\\"))
            {
                tempPath += "\\";
            }

            if (Directory.Exists(tempPath))
            {
                Directory.Delete(tempPath, true);
            }
            DirectoryInfo dirInfo = Directory.CreateDirectory(tempPath);

            UtilSettings utilSettings = new UtilSettings();

            utilSettings.TempFolder = tempPath;

            // the first arg should be the EXE path
            utilSettings.VaultClient = Environment.GetCommandLineArgs()[0];

            string zipPath = Path.Combine(tempPath, PACKAGE_NAME);

            VDF.Vault.Currency.Entities.FileIteration vdfFile = new VDF.Vault.Currency.Entities.FileIteration(conn, files[0]);
            VDF.Currency.FilePathAbsolute             vdfPath = new VDF.Currency.FilePathAbsolute(zipPath);
            AcquireFilesSettings acquireSettings = new AcquireFilesSettings(conn, false);

            acquireSettings.AddFileToAcquire(vdfFile, AcquireFilesSettings.AcquisitionOption.Download, vdfPath);
            AcquireFilesResults acquireResults = conn.FileManager.AcquireFiles(acquireSettings);

            foreach (FileAcquisitionResult acquireResult in acquireResults.FileResults)
            {
                if (acquireResult.Exception != null)
                {
                    throw acquireResult.Exception;
                }
            }

            // clear the read-only bit
            System.IO.File.SetAttributes(zipPath, FileAttributes.Normal);

            FastZip zip = new FastZip();

            zip.ExtractZip(zipPath, tempPath, null);

            MasterController mc = new MasterController(conn, vaultName);

            mc.SetMoveOperations(tempPath, utilSettings);

            utilSettings.Save();

            MessageBox.Show("Updates downloaded. " +
                            "You need exit the Vault client to complete the update process. " + Environment.NewLine +
                            "The Vault Client will restart when the update is complete.",
                            "Exit Required");

            m_restartPending = true;

            entry.LastUpdate = files[0].CkInDate;
            settings.Save();
        }