/// <summary>
        /// Called When the package is initialized.
        /// </summary>
        public override void InitializeCustomExtension()
        {
            if (RuntimeSettings != null)
            {
                PackageLog.Log(string.Format("Runtime Settings populated.  Count = {0}", RuntimeSettings.Count));
                foreach (var setting in RuntimeSettings)
                {
                    PackageLog.Log(string.Format("Key={0} | Value={1}", setting.Key, setting.Value.ToString()));
                }

                if (RuntimeSettings.ContainsKey("SkipSampleData"))
                {
                    bool sample = false;
                    if (bool.TryParse((string)RuntimeSettings["SkipSampleData"], out sample))
                    {
                        DataImportBypass = sample;
                    }
                }
            }
            else
            {
                // Skip sample data by default
                DataImportBypass = true;
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Checks if a selected runtime setting is true or falss.
 /// </summary>
 private bool?GetRuntimeSetting(string runtimeKey)
 {
     if (RuntimeSettings != null && RuntimeSettings.ContainsKey(runtimeKey))
     {
         bool install = false;
         if (bool.TryParse((string)RuntimeSettings[runtimeKey], out install))
         {
             return(install);
         }
         else
         {
             return(null);
         }
     }
     else
     {
         return(null);
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Called When the package is initialized.
        /// </summary>
        public override void InitializeCustomExtension()
        {
            if (RuntimeSettings != null)
            {
                //RuntimeSettings.Add("CommonDataModelNonprofitSampleAppsBase", "true");
                PackageLog.Log(string.Format("Runtime Settings populated.  Count = {0}", RuntimeSettings.Count));

                foreach (var setting in RuntimeSettings)
                {
                    PackageLog.Log(string.Format("Key={0} | Value={1}", setting.Key, setting.Value.ToString()));
                }

                int[] version     = GetSolutionVersion("NonprofitCore");
                bool? installCore = GetRuntimeSetting("NonprofitCore");
                if (installCore == true && version != null && version[0] < 3 && version[1] < 3)
                {
                    PackageLog.Log("Older version of the Core found adding sample app base solution.");
                    RuntimeSettings.Add("CommonDataModelNonprofitSampleAppsBase", "true");
                }
                else
                {
                    PackageLog.Log("New install detected no sample app base install required.");
                    RuntimeSettings.Add("CommonDataModelNonprofitSampleAppsBase", "false");
                }

                if (RuntimeSettings.ContainsKey("SkipSampleData"))
                {
                    bool sample = false;
                    if (bool.TryParse((string)RuntimeSettings["SkipSampleData"], out sample))
                    {
                        DataImportBypass = sample;
                    }
                }
            }
            else
            {
                // Skip sample data by default
                DataImportBypass = true;
            }
        }
        /// <summary>
        /// Override default decision made by PD.
        /// </summary>
        public override UserRequestedImportAction OverrideSolutionImportDecision(string solutionUniqueName, Version organizationVersion, Version packageSolutionVersion, Version inboundSolutionVersion, Version deployedSolutionVersion, ImportAction systemSelectedImportAction)
        {
            // Solution appears in settings if the request came from the SPA. Follow that request if it exists.
            if (RuntimeSettings != null && RuntimeSettings.ContainsKey(solutionUniqueName))
            {
                bool install = false;
                if (bool.TryParse((string)RuntimeSettings[solutionUniqueName], out install) && !install)
                {
                    PackageLog.Log("Skipping package: " + solutionUniqueName);
                    return(UserRequestedImportAction.Skip);
                }
            }
            // If this request didn't come from the SPA, then this is an upgrade, but default to allow the anchor solution. We don't want to install new solutions,
            // so only import the ones that already exist on the instance
            else if (solutionUniqueName?.Equals(ANCHOR_SOLUTION_UNIQUE_NAME) == false && deployedSolutionVersion.Equals(new Version(0, 0, 0, 0)))
            {
                return(UserRequestedImportAction.Skip);
            }

            PackageLog.Log("Not skipping package: " + solutionUniqueName);
            return(base.OverrideSolutionImportDecision(solutionUniqueName, organizationVersion, packageSolutionVersion, inboundSolutionVersion, deployedSolutionVersion, systemSelectedImportAction));
        }