public override void Install(IDictionary stateSaver)
        {
            string[] nonpublicCachedDataMembers = null;

            Uri deploymentManifestLocation = null;

            if (Uri.TryCreate(
                    Context.Parameters["deploymentManifestLocation"],
                    UriKind.RelativeOrAbsolute,
                    out deploymentManifestLocation) == false)
            {
                throw new InstallException(
                          "The location of the deployment manifest " +
                          "is missing or invalid.");
            }
            string documentLocation =
                Context.Parameters["documentLocation"];

            if (String.IsNullOrEmpty(documentLocation))
            {
                throw new InstallException(
                          "The location of the document is missing.");
            }
            string assemblyLocation =
                Context.Parameters["assemblyLocation"];

            if (String.IsNullOrEmpty(assemblyLocation))
            {
                throw new InstallException(
                          "The location of the assembly is missing.");
            }

            string targetLocation = CreateTargetLocation(documentLocation);

            File.Copy(documentLocation, targetLocation);
            if (ServerDocument.IsCustomized(targetLocation))
            {
                ServerDocument.RemoveCustomization(targetLocation);
            }
            ServerDocument.AddCustomization(
                targetLocation,
                assemblyLocation,
                SolutionID,
                deploymentManifestLocation,
                true,
                out nonpublicCachedDataMembers);
            stateSaver.Add("targetLocation", targetLocation);
            base.Install(stateSaver);
        }
Beispiel #2
0
        FileIsNodeXLWorkbook
        (
            String filePath
        )
        {
            Debug.Assert(!String.IsNullOrEmpty(filePath));

            if (ServerDocument.IsCustomized(filePath))
            {
                Guid oSolutionID = new Guid(ApplicationUtil.SolutionID);

                using (ServerDocument oServerDocument =
                           new ServerDocument(filePath))
                {
                    if (oServerDocument.SolutionId == oSolutionID)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Beispiel #3
0
        public void Execute(AddInPostDeploymentActionArgs args)
        {
            XElement parameters = XElement.Parse(args.PostActionManifestXml);

            //configurabili
            string dataDirectory = @"Data\";
            string file          = parameters.Attribute("filename").Value;

            //statici
            string sourcePath            = args.AddInPath;
            string destPath              = Environment.ExpandEnvironmentVariables(Base.Simboli.LocalBasePath);
            Uri    deploymentManifestUri = args.ManifestLocation;
            string sourceFile            = Path.Combine(sourcePath, dataDirectory, file);
            string destFile              = Path.Combine(destPath, file);

            switch (args.InstallationStatus)
            {
            case AddInInstallationStatus.InitialInstall:
                if (!Directory.Exists(destPath))
                {
                    Directory.CreateDirectory(destPath);
                }

                System.IO.File.Copy(sourceFile, destFile, true);

                if (ServerDocument.IsCustomized(destFile))
                {
                    ServerDocument.RemoveCustomization(destFile);
                }

                ServerDocument.AddCustomization(destFile, deploymentManifestUri);

                break;

            case AddInInstallationStatus.Update:
                string dirUPDATE  = Path.Combine(destPath, "UPDATE");
                string fileUPDATE = Path.Combine(dirUPDATE, file);
                if (!Directory.Exists(dirUPDATE))
                {
                    Directory.CreateDirectory(dirUPDATE);
                }

                System.IO.File.Copy(sourceFile, fileUPDATE, true);

                if (ServerDocument.IsCustomized(fileUPDATE))
                {
                    ServerDocument.RemoveCustomization(fileUPDATE);
                }

                ServerDocument.AddCustomization(fileUPDATE, deploymentManifestUri);

                break;

            case AddInInstallationStatus.Uninstall:
                if (System.IO.File.Exists(destFile))
                {
                    //rimuovo file di installazione
                    System.IO.File.Delete(destFile);

                    //rimuovo directory di update
                    string update = Path.Combine(destPath, "UPDATE");
                    if (Directory.Exists(update) && !Directory.EnumerateFileSystemEntries(update).Any())
                    {
                        Directory.Delete(update);
                    }

                    //rimuovo directory PSO
                    if (!Directory.EnumerateFileSystemEntries(destPath).Any())
                    {
                        Directory.Delete(destPath);
                    }
                }
                break;
            }
        }
Beispiel #4
0
        public override void Install(IDictionary stateSaver)
        {
            string[] nonpublicCachedDataMembers = null;


            // Use the following for debugging during the install
            //string parameters = "Parameters in Context.Paramters:";
            //foreach (DictionaryEntry parameter in Context.Parameters)
            //{
            //    parameters = parameters + "\n" + parameter.Key + ":" + parameter.Value;
            //}

            //MessageBox.Show(parameters);

            //MessageBox.Show("total items in parameters: " + Context.Parameters.Count);
            //MessageBox.Show("Document Manifest Location:" + Context.Parameters["deploymentManifestLocation"]);

            Uri deploymentManifestLocation = null;

            if (Uri.TryCreate(
                    Context.Parameters["deploymentManifestLocation"],
                    UriKind.RelativeOrAbsolute,
                    out deploymentManifestLocation) == false)
            {
                throw new InstallException(
                          "The location of the deployment manifest " +
                          "is missing or invalid.");
            }
            string documentLocation =
                Context.Parameters["documentLocation"];

            if (String.IsNullOrEmpty(documentLocation))
            {
                throw new InstallException(
                          "The location of the document is missing.");
            }
            string assemblyLocation =
                Context.Parameters["assemblyLocation"];

            if (String.IsNullOrEmpty(assemblyLocation))
            {
                throw new InstallException(
                          "The location of the assembly is missing.");
            }

            // use the following for debugging
            MessageBox.Show(documentLocation);

            if (ServerDocument.IsCustomized(documentLocation))
            {
                ServerDocument.RemoveCustomization(documentLocation);
            }
            ServerDocument.AddCustomization(
                documentLocation,
                assemblyLocation,
                SolutionID,
                deploymentManifestLocation,
                false,
                out nonpublicCachedDataMembers);
            stateSaver.Add("documentlocation", documentLocation);
            base.Install(stateSaver);
        }
Beispiel #5
0
        ConvertNodeXLWorkbook
        (
            String otherWorkbookFile,
            String convertedWorkbookFile
        )
        {
            Debug.Assert(!String.IsNullOrEmpty(otherWorkbookFile));
            Debug.Assert(File.Exists(otherWorkbookFile));
            Debug.Assert(!String.IsNullOrEmpty(convertedWorkbookFile));

            // The application's template is needed to get the customization
            // information.

            String sTemplatePath;

            if (!ApplicationUtil.TryGetTemplatePath(out sTemplatePath))
            {
                throw new NodeXLWorkbookConversionException(
                          ApplicationUtil.GetMissingTemplateMessage());
            }

        #if false  // For testing.
            sTemplatePath = @"E:\NodeXL\ExcelTemplateSetup\"
                            + "TemplateModifiedForClickOnce\NodeXLGraph.xltx";
        #endif

            try
            {
                File.Copy(otherWorkbookFile, convertedWorkbookFile, true);
            }
            catch (UnauthorizedAccessException)
            {
                throw new NodeXLWorkbookConversionException(
                          "The converted copy already exists and is read-only.  It can't"
                          + " be overwritten."
                          );
            }
            catch (IOException oIOException)
            {
                if (oIOException.Message.Contains(
                        "it is being used by another process"))
                {
                    throw new NodeXLWorkbookConversionException(
                              "The converted copy already exists and is open in Excel."
                              + "  It can't be overwritten."
                              );
                }

                throw (oIOException);
            }

            // Remove the other customization.

            try
            {
                if (ServerDocument.IsCustomized(convertedWorkbookFile))
                {
                    ServerDocument.RemoveCustomization(convertedWorkbookFile);
                }
            }
            catch (Microsoft.VisualStudio.Tools.Applications.Runtime.
                   UnknownCustomizationFileException)
            {
                throw new NodeXLWorkbookConversionException(
                          "The file doesn't appear to be an Excel workbook."
                          );
            }

            // Create a ServerDocument from the application's template.  The
            // solution ID and deployment manifest name will be obtained from this.

            using (ServerDocument oTemplateServerDocument =
                       new ServerDocument(sTemplatePath, FileAccess.Read))
            {
                // For some reason, ServerDocument.AddCustomization() also requires
                // a path to the NodeXL assembly file, even though it doesn't get
                // embedded in the document.

                String sAssemblyFile = new Uri(
                    Assembly.GetExecutingAssembly().CodeBase).LocalPath;

                String [] asNonPublicCachedDataMembers;

                ServerDocument.AddCustomization(convertedWorkbookFile,
                                                sAssemblyFile, oTemplateServerDocument.SolutionId,
                                                oTemplateServerDocument.DeploymentManifestUrl, false,
                                                out asNonPublicCachedDataMembers);
            }
        }