Beispiel #1
0
        public VaultEntry GetOrCreateEntry(string serverName, string vaultName)
        {
            VaultEntry entry = VaultEntries.FirstOrDefault(n =>
                                                           string.Equals(n.ServerName, serverName, StringComparison.InvariantCultureIgnoreCase) &&
                                                           string.Equals(n.VaultName, vaultName, StringComparison.InvariantCultureIgnoreCase));

            if (entry == null)
            {
                entry = new VaultEntry()
                {
                    ServerName = serverName,
                    VaultName  = vaultName,
                    LastUpdate = DateTime.MinValue
                };
                VaultEntries.Add(entry);
            }

            return(entry);
        }
Beispiel #2
0
        private void ConfigureThunderdome(string serverName, string vaultName, CommandItemEventArgs e)
        {
            Connection conn = e.Context.Application.Connection;

            if (!Util.IsAdmin(conn))
            {
                MessageBox.Show("Only administrators can use this function");
                return;
            }

            //string userFolder = m_mgr.KnowledgeVaultService.GetVaultOption(USER_FOLDER_OPTION);
            string          deployFolderPath = conn.WebServiceManager.KnowledgeVaultService.GetVaultOption(DEFAULT_FOLDER_OPTION);
            string          deploymentXml    = conn.WebServiceManager.KnowledgeVaultService.GetVaultOption(DEPLOYMENT_CONFIG_OPTION);
            DeploymentModel deploymentModel  = DeploymentModel.Load(deploymentXml);

            Configure    cfgDialog = new Configure(deployFolderPath, deploymentModel, vaultName, conn);
            DialogResult result    = cfgDialog.ShowDialog();

            if (result != DialogResult.OK)
            {
                return;
            }

            DeploymentModel deploymentModel2 = cfgDialog.GetSelectedDataModel();

            if (!deploymentModel2.Containers.Any())
            {
                return;
            }

            // zip up the files and upload to Vault
            string  tempFile = System.IO.Path.GetTempFileName();
            ZipFile zip      = ZipFile.Create(tempFile);

            zip.BeginUpdate();


            foreach (DeploymentContainer container in deploymentModel2.Containers)
            {
                foreach (DeploymentItem item in container.DeploymentItems)
                {
                    item.Zip(zip, container);
                }
            }

            zip.CommitUpdate();
            zip.Close();

            Folder deployFolder = cfgDialog.DeploymentFolder;

            conn.WebServiceManager.KnowledgeVaultService.SetVaultOption(DEFAULT_FOLDER_OPTION, deployFolder.FullName);

            Autodesk.Connectivity.WebServices.File vaultPackage = Util.AddOrUpdateFile(
                tempFile, PACKAGE_NAME, deployFolder, conn);

            System.IO.File.Delete(tempFile);

            // we just updated the package, so we are definately up to date.
            Settings   settings = Settings.Load();
            VaultEntry entry    = settings.GetOrCreateEntry(serverName, vaultName);

            entry.LastUpdate = vaultPackage.CkInDate;
            settings.Save();

            deploymentXml = deploymentModel2.ToXml();
            conn.WebServiceManager.KnowledgeVaultService.SetVaultOption(DEPLOYMENT_CONFIG_OPTION, deploymentXml);

            MessageBox.Show("Deployment Created");
            e.Context.ForceRefresh = true;
            e.Context.GoToLocation = new LocationContext(SelectionTypeId.File, deployFolder.FullName + "/" + PACKAGE_NAME);
            return;
        }
Beispiel #3
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();
        }