In order to execute DataTransfer from your custom code your company must have an enterprise license and you have to have file access to the Master Management Console directory. Create a custom file in the Upload directory of the Master Management console or prefix the file with my_.
Download template file, unzip and move Custom folder into Centralpoint\Master\Root\Uploads directory.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using Centralpoint;
using Centralpoint.Web;
using Centralpoint.Web.Cms;
using Centralpoint.Web.UI;
using Centralpoint.Web.UI.Controls;
using Centralpoint.Web.UI.Console;
using Centralpoint.Web.Site;
using System.Security;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Linq;
public partial class Uploads_Imports_ClientName_Default : System.Web.UI.Page
{
private void ExecuteDataTransfer()
{
//Id_of_The_Website: can be retrieved from console Admin > Settings > Site Key.
WebSite webSite = WebSite.NewCached(new Guid("Id_of_The_Website"), Management.Application.SelectConnectionString);
Guid dataId = new Guid("DataId_of_the_DataTransfer_Record");
object xml = Centralpoint.Utilities.Database.ExecuteScalar(webSite.SelectConnectionString,
String.Format("SELECT TOP 1 Attributes FROM cpsys_DataCurrent WHERE DataId = '{0}'", dataId));
if (xml == null)
throw new ArgumentException(String.Format("Data Transfer does not contain a record with the DataId={0}.", dataId), "dataId");
CpCollection attributes = new CpCollection();
attributes.Load(xml.ToString());
//here you can update the Collection of attributes if required. For example, you can point your data transfer record to the new source file.
// attributes.Set("SourceCustomParameters","c:\newFile.xlsx");
Centralpoint.Master.DataTransfer dt = new Centralpoint.Master.DataTransfer(webSite, dataId, attributes);
dt.Execute(Guid.NewGuid(), "Name of the User who is running this process.");
//if you need to determine if DataTransfer was successful, you can check if dt.LastException.The message contains any values.
//if you need to see more details about the error you can get that from dt.LastException.StackTrace.
}
}
Keywords: Data Transfer, Master
Related CodeSamples Records