Пример #1
0
        internal void Run(string schemaPath, string asmPath, string fsPath, string repositoryPath, bool validate)
        {
            string ctdPath     = null;
            string aspectsPath = null;

            if (schemaPath != null)
            {
                ctdPath     = Directory.GetDirectories(schemaPath, "ContentTypes").FirstOrDefault();
                aspectsPath = Directory.GetDirectories(schemaPath, "Aspects").FirstOrDefault();
            }

            if (ctdPath == null && aspectsPath == null && String.IsNullOrEmpty(fsPath) && String.IsNullOrEmpty(SourceFile))
            {
                LogWriteLine("No changes");
                return;
            }

            var startSettings = new RepositoryStartSettings
            {
                Console            = Console.Out,
                StartLuceneManager = StorageContext.Search.IsOuterEngineEnabled,
                PluginsPath        = asmPath
            };

            using (Repository.Start(startSettings))
            {
                var installationMode = false;
                try
                {
                    installationMode = IsInstallationMode();
                }
                catch (Exception e)
                {
                    PrintException(e, null);
                    return;
                }

                ApplicationInfo.CreateInitialSenseNetVersion("Sense/Net ECM", "Unofficial", new Version(6, 3, 1),
                                                             "This edition can only be used for development and testing purposes.");

                // Elevation: there can be folders where even admins
                // do not have any permissions. This is why we need to
                // use system account for the whole import process.
                using (new SystemAccount())
                {
                    //-- Install ContentTypes
                    if (ctdPath == null && aspectsPath == null)
                    {
                        LogWriteLine("Schema is not changed");
                    }
                    else
                    {
                        if (installationMode)
                        {
                            StorageContext.Search.DisableOuterEngine();
                            LogWriteLine("Indexing is temporarily switched off." + CR);
                        }

                        InstallContentTypeDefinitionsAndAspects(ctdPath, aspectsPath);

                        if (installationMode)
                        {
                            StorageContext.Search.EnableOuterEngine();
                            CreateInitialIndex();
                            LogWriteLine("Indexing is switched on." + CR);
                        }
                    }

                    //-- Create missing index documents
                    var firstImport = SaveInitialIndexDocuments();
                    if (firstImport)
                    {
                        var admin     = Node.Load <User>(User.Administrator.Id);
                        var admins    = Node.Load <Group>(Group.Administrators.Id);
                        var operators = Node.Load <Group>(RepositoryConfiguration.OperatorsGroupPath);

                        admins.AddMember(admin);
                        admins.Save();

                        operators.AddMember(admins);
                        operators.Save();
                    }

                    //-- Import Contents
                    if (!String.IsNullOrEmpty(fsPath) || !String.IsNullOrEmpty(SourceFile))
                    {
                        ImportContents(fsPath, repositoryPath, validate, false);
                    }
                    else
                    {
                        LogWriteLine("Contents are not changed");
                    }
                }
            }
        }