Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents

Goal

In this article, you will find information about working with the Exporter, detailed information about the Exporter API.

Prerequisite

Info

Installed Sitefinity connector - Installing the Connector

How is Export made behind the scenes?

What happens in the Hawksearch project?

In the Hawksearch Admin Panel (your-website-url/Sitefinity/Administration/hawksearchconfig), there are 2 buttons: “Run Full Export Now“ and “Run Delta Export Now“.

...

In the ExportModel there is also the GetExportDetails() method, where the information about the Full and Delta export is being resolved. After the Export, an object ExportResult is being returned to the ExportModel and this object provides the whole details about the export.

What happens in the Hawksearch.SDK project?

The further steps that are related to the export are part of the SDK project that is CMS independent, but still a .NET SDK.

...

You can find your files with the exported items in the folder that you’ve set in the Configurations.

Setting a Schedule Export

Setting a Schedule for Export is an important part of Export functionalities.
When Scheduling an export a HttpPost request is made.

...

Code Block
languagec#
public override void ExecuteTask()
        {
            var hawksearchConfig = Config.Get<HawkSearchConfig>();
            try
            {
                if (hawksearchConfig.RunExportTaskOnSpecifiedDomainOnly)
                {
                    this.CallFullExportApi(hawksearchConfig);
                }
                else
                {
                    var exporter = IocKernel.Get<IExporter>();

                    var exportInfo = new ExportInfo();
                    List<string> contentTypes = ContentTypeData.GetContentTypes();
                    exportInfo.ContentTypes = contentTypes;
                    exportInfo.ExportType = ExportType.Full;
                    ExportModel.GetConfig(exportInfo);

                    exporter.Export(exportInfo);
                }
            }
            catch (Exception ex)
            {
                Log.Write(ex, ConfigurationPolicy.ErrorLog);
            }

            //Schedule next run if not a "One Time Execution" instance.
            if (!this.OneTimeExecution)
            {
                SchedulingManager schedulingManager = SchedulingManager.GetManager();
                var taskKey = hawksearchConfig.ExportTaskKey;
                var hawkManager = HawkManager.GetManager();
                var exportRecord = ExportModel.GetExportInfo(hawkManager);
                var exportScheduleTime = exportRecord.ExportScheduleTime;
                var exportScheduleType = exportRecord.ExportScheduleType;
                var newTask = new FullExportTask() { Key = taskKey, ExecuteTime = SDK.Export.ExportScheduler.GetNextOccurrence(exportScheduleType, exportScheduleTime).ToUniversalTime() };
                
                schedulingManager.AddTask(newTask);
                schedulingManager.SaveChanges();
            }
        }

How to integrate the Hawksearch.SDK with any CMS?

The power of the Export now is that it can be used with all kind of CMS. The Export functionality is part of the SDK and does not depend on Sitefinity.

...

Code Block
protected virtual List<SubmitDocument> GetPageNodes(ISite site, DateTime? lastModified = null)
        {
            var pageList = new List<IDataItem>();
            var pageManager = PageManager.GetManager();

            pageList = pageManager
                   .GetPageDataList()
                   .ToList()
                   .Where(pData => pData.Status == ContentLifecycleStatus.Live)
                   .Select(pData => pData.NavigationNode)
                   .Where(pNode => !pNode.IsBackend && !pNode.IsDeleted && pNode.RootNodeId == site.SiteMapRootNodeId)
                   .Cast<IDataItem>()
                   .ToList();

            if (lastModified != null)
            {
                pageList = pageList.Where(p => p.LastModified >= lastModified).ToList();
                var deletedItems = this.hawkManager.GetRemovedDataItems().Where(di => di.LastModified >= lastModified).ToList();
                pageList.AddRange(deletedItems);
            }

            var submitDocuments = this.Convert(pageList, SDK.Export.Constants.ExportConstants.FullExport);

            return submitDocuments;
        }

Creating SubmitDocument

The SubmitDocuments are the items that the Exporter expects and can process. These Documents contain the base information about an record. A document can be initialized with an empty constructor and different Fields can be added. An SubmitDocument can have IdentityFields and List<SubmitFields>.

...