Inheritance: DataObject, ICloneable
Esempio n. 1
0
        private static Base.Profiles.Profile DetectProfile()
        {
            var profile = new Base.Profiles.Profile();

            Action action = delegate
            {
                try
                {
                    InstanceManager.Default.Initialize();
                    var instances = InstanceManager.Default.Instances.ToArray();
                    if (!instances.Any())
                    {
                        return;
                    }

                    var database = instances
                                   .Select(x =>
                                           Safe(() =>
                                                x.AttachedDatabases.FirstOrDefault(y => y.Name.EqualsIgnoreCase("core")), x.ToString()))
                                   .FirstOrDefault(x => x != null);

                    var cstr     = SqlServerManager.Instance.GetManagementConnectionString(database.ConnectionString).ToString();
                    var instance = instances.FirstOrDefault();
                    var root     = instance.RootPath.EmptyToNull().With(x => Path.GetDirectoryName(x)) ?? "C:\\inetpub\\wwwroot";
                    var rep      = GetRepositoryPath();
                    var lic      = GetLicensePath();
                    if (!SIM.FileSystem.FileSystem.Local.File.Exists(lic))
                    {
                        SIM.FileSystem.FileSystem.Local.File.Copy(instance.LicencePath, lic);
                    }

                    profile = new Base.Profiles.Profile
                    {
                        ConnectionString = cstr,
                        InstancesFolder  = root,
                        LocalRepository  = rep,
                        License          = lic
                    };
                }
                catch (Exception ex)
                {
                    Log.Error(ex, "Error during detecting profile defaults");
                }
            };

            // max timeout 5 seconds
            var thread = new Thread(new ThreadStart(action));

            thread.Start();

            Thread.Sleep(5000);
            if (thread.IsAlive)
            {
                thread.Abort();
            }

            return(profile);
        }
        public static void Initialize()
        {
            if (FileExists)
              {
            var profileFilePath = ProfileFilePath;
            var profile = ReadProfile(profileFilePath);

            Assert.IsNotNull(profile, "profile");
            Profile = profile;
              }
        }
    public SetupWizardArgs(Profile profile)
    {
      if (profile == null)
      {
        return;
      }

      this.InstancesRootFolderPath = profile.InstancesFolder;
      this.LicenseFilePath = profile.License;
      this.ConnectionString = profile.ConnectionString;
      this.LocalRepositoryFolderPath = profile.LocalRepository;
    }
    public static IEnumerable<Plugin> GetEnabledPlugins(Profile profile)
    {
      char[] separator = new[]
      {
        '|', ';', ','
      };
      var workaround = "Plugins\\Support Workaround";
      var plugins = profile.Plugins.Replace(workaround, string.Empty);
      if (EnvironmentHelper.IsSitecoreMachine)
      {
        plugins += "|" + workaround;
      }

      var selected = plugins.Replace("||", "|").Trim(separator).Split(separator);
      return Plugins.Where(plugin => selected.Contains(plugin.PluginFolder));
    }
 public Item(Plugin path, Profile profile)
 {
   this.profile = profile;
   this.Plugin = path;
 }
        public static void SaveChanges([CanBeNull] Profile profile = null)
        {
            if (profile != null)
              {
            Profile = profile;
              }

              XmlSerializer serializer = new XmlSerializer(typeof(Profile));
              using (TextWriter textWriter = new StreamWriter(ProfileFilePath))
              {
            serializer.Serialize(textWriter, Profile);
              }
        }