public static void Run() { // ExStart:ImportProjectDataFromDatabase try { SqlConnectionStringBuilder sqlConnectionString = new SqlConnectionStringBuilder(); sqlConnectionString.DataSource = "192.168.56.2,1433"; sqlConnectionString.Encrypt = true; sqlConnectionString.TrustServerCertificate = true; sqlConnectionString.InitialCatalog = "ProjectServer_Published"; sqlConnectionString.NetworkLibrary = "DBMSSOCN"; sqlConnectionString.UserID = "sa"; sqlConnectionString.Password = "******"; // Use Aspose.Tasks.Connectivity namespace MspDbSettings settings = new MspDbSettings(sqlConnectionString.ConnectionString, new Guid("E6426C44-D6CB-4B9C-AF16-48910ACE0F54")); Project project = new Project(settings); } catch (Exception ex) { Console.WriteLine(ex.Message + "\nPlease setup proper datasource (DataSource, InitialCatalog etc)"); } // ExEnd:ImportProjectDataFromDatabase }
public static void Run() { // ExStart:ImportProjectDataFromDatabase try { // Create connection string SqlConnectionStringBuilder sqlConnectionString = new SqlConnectionStringBuilder(); sqlConnectionString.DataSource = "192.168.56.2,1433"; sqlConnectionString.Encrypt = true; sqlConnectionString.TrustServerCertificate = true; sqlConnectionString.InitialCatalog = "ProjectServer_Published"; sqlConnectionString.NetworkLibrary = "DBMSSOCN"; sqlConnectionString.UserID = "sa"; sqlConnectionString.Password = "******"; // Use Aspose.Tasks.Connectivity namespace MspDbSettings settings = new MspDbSettings(sqlConnectionString.ConnectionString, new Guid("E6426C44-D6CB-4B9C-AF16-48910ACE0F54")); Project project = new Project(settings); } catch (Exception ex) { Console.WriteLine(ex.Message + "\nPlease setup proper datasource (DataSource, InitialCatalog etc)"); } // ExEnd:ImportProjectDataFromDatabase }
public void ImportProjectDataFromDatabase() { // ExStart:ImportProjectDataFromDatabase // ExFor: MspDbSettings // ExFor: MspDbSettings.#ctor(String, Guid) // ExFor: MspDbSettings.Schema // ExFor: MspDbSettings.ProjectGuid // ExSummary: Shows how to import a project from a database. try { // Create connection string var connectionString = new SqlConnectionStringBuilder(); connectionString.DataSource = "192.168.56.2,1433"; connectionString.Encrypt = true; connectionString.TrustServerCertificate = true; connectionString.InitialCatalog = "ProjectServer_Published"; connectionString.NetworkLibrary = "DBMSSOCN"; connectionString.UserID = "sa"; connectionString.Password = "******"; connectionString.ConnectTimeout = 2; // ExSkip // create settings to load from MS database var settings = new MspDbSettings(connectionString.ConnectionString, new Guid("E6426C44-D6CB-4B9C-AF16-48910ACE0F54")); settings.Schema = "dbo"; Console.WriteLine("Project GUID to load: " + settings.ProjectGuid); var project = new Project(settings); project.Save(OutDir + "ImportProjectDataFromDatabase_out.mpp", SaveFileFormat.MPP); } catch (Exception ex) { Console.WriteLine(ex.Message + " Please setup proper data source (DataSource, InitialCatalog etc)"); } // ExEnd:ImportProjectDataFromDatabase }