Red Gate forums :: View topic - Load project options using API library
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
SQL Toolkit Previous Versions
SQL Toolkit Previous Versions forum

Load project options using API library

Search in SQL Toolkit Previous Versions forum
Post new topic   Reply to topic
Jump to:  
Author Message
kkchan



Joined: 01 Dec 2007
Posts: 23

PostPosted: Sat Dec 01, 2007 11:06 am    Post subject: Load project options using API library Reply with quote

Hi,

Just to double confirm that, If I have set all the replication option and save it. Can I use SQL toolkit C# library to load the settings from project file so that I don't have to hardcode inside my application?
Back to top
View user's profile Send private message
richardjm



Joined: 20 May 2005
Posts: 383
Location: Red Gate Software Ltd

PostPosted: Mon Dec 03, 2007 9:37 am    Post subject: Reply with quote

If you are talking about SQL Data Compare version 6 then yes. You will have to call the function Project.ReplayUserActions() for your SchemaMappings.

HTH
_________________
Richard Mitchell
Project Manager
Red Gate Software Ltd
Back to top
View user's profile Send private message Send e-mail
jimboh



Joined: 29 Jan 2007
Posts: 17
Location: Melbourne Australia

PostPosted: Fri Mar 28, 2008 2:11 pm    Post subject: Reply with quote

Please provide more DETAIL information as to how this is used .
When I suck in a project file, the resulting comparison does not have any regard for the tables and and views and column filters that i have set in the project configuration - whether the project.RepayUserActions is used or not.
Back to top
View user's profile Send private message
richardjm



Joined: 20 May 2005
Posts: 383
Location: Red Gate Software Ltd

PostPosted: Fri Mar 28, 2008 3:14 pm    Post subject: Reply with quote

No need to SHOUT.

Please see a related article...

http://www.red-gate.com/MessageBoard/viewtopic.php?t=6236&highlight=replayuseractions
_________________
Richard Mitchell
Project Manager
Red Gate Software Ltd
Back to top
View user's profile Send private message Send e-mail
jimboh



Joined: 29 Jan 2007
Posts: 17
Location: Melbourne Australia

PostPosted: Fri Mar 28, 2008 3:35 pm    Post subject: Reply with quote

Sorry for the unnecessary emphasis.

I have seen the reference and applied the function call you refer to in this manner:

using (ComparisonSession session = new ComparisonSession())
{
// Create the mappings between the two db
SchemaMappings mappings = new SchemaMappings();

project.ReplayUserActions(ref mappings);
// TODo 20080328 -- this is wierd !! http://www.red-gate.com/MessageBoard/viewtopic.php?t=6236&highlight=replayuseractions

mappings.Options = project2.Options;

mappings.CreateMappings(db1, db2);

session.CompareDatabases(db1, db2, mappings);

Console.WriteLine("Comparison run");

etc.
Back to top
View user's profile Send private message
richardjm



Joined: 20 May 2005
Posts: 383
Location: Red Gate Software Ltd

PostPosted: Fri Mar 28, 2008 3:56 pm    Post subject: Reply with quote

OK I can see what's going on there. What you're after is creating the mappings *then* applying the user actions and you're ready to roll...
Code:

using (ComparisonSession session = new ComparisonSession())
{
// Create the mappings between the two db
SchemaMappings mappings = new SchemaMappings();
mappings.Options = project2.Options;
mappings.CreateMappings(db1, db2);
project.ReplayUserActions(ref mappings);
session.CompareDatabases(db1, db2, mappings);
Console.WriteLine("Comparison run");


HTH
_________________
Richard Mitchell
Project Manager
Red Gate Software Ltd
Back to top
View user's profile Send private message Send e-mail
jimboh



Joined: 29 Jan 2007
Posts: 17
Location: Melbourne Australia

PostPosted: Fri Mar 28, 2008 4:06 pm    Post subject: Reply with quote

I like your style .. I'm actually smoking arolly right now.
also you picked up on project vs project2

Unfortunately the following loop :
foreach (TableMapping mapping in mappings.TableMappings) ...
still wants to use every table in the database - rather than just the ones in the project configuration.

Thanks
Jimboh
Back to top
View user's profile Send private message
jimboh



Joined: 29 Jan 2007
Posts: 17
Location: Melbourne Australia

PostPosted: Fri Mar 28, 2008 4:23 pm    Post subject: Reply with quote

perhaps you need to see the following preliminary lines ( copied from the template)

//Should check if this is true
LiveDatabaseSource liveDb = project2.DataSource1 as LiveDatabaseSource;
db1.RegisterForDataCompare(liveDb.ToConnectionProperties(), Options.Default);

//Should check if this is true
liveDb = project2.DataSource2 as LiveDatabaseSource;
db2.RegisterForDataCompare(liveDb.ToConnectionProperties(), Options.Default);

is there some thing more that should be done first ?
Back to top
View user's profile Send private message
richardjm



Joined: 20 May 2005
Posts: 383
Location: Red Gate Software Ltd

PostPosted: Fri Mar 28, 2008 4:58 pm    Post subject: Reply with quote

which would then continue (for project2)

Code:

SchemaMappings mappings = new SchemaMappings();
mappings.Options = project2.Options;
mappings.CreateMappings(db1, db2);
project2.ReplayUserActions(ref mappings);
session.CompareDatabases(db1, db2, mappings);


If you yourself are looping through mappings.TableMappings you'll need to pay attention to the .Include property.

Getting there I hope.
_________________
Richard Mitchell
Project Manager
Red Gate Software Ltd
Back to top
View user's profile Send private message Send e-mail
jimboh



Joined: 29 Jan 2007
Posts: 17
Location: Melbourne Australia

PostPosted: Fri Mar 28, 2008 5:09 pm    Post subject: Reply with quote

RichardJim

Please don't keep me in suspense. where and how do we use .Include and what object is it referring to ?

Jimboh
Back to top
View user's profile Send private message
richardjm



Joined: 20 May 2005
Posts: 383
Location: Red Gate Software Ltd

PostPosted: Fri Mar 28, 2008 6:23 pm    Post subject: Reply with quote

If you're using the
Code:

session.CompareDatabases(db1, db2, mappings);

It should all work.

If you're using the TableMappings you'll need something like...
Code:

foreach (TableMapping mapping in mappings.TableMappings)
{
  if (mapping.Include)
  {
    // Do your stuff whatever that may be you're not telling me much
  }
  else
  {
    // Read the license agreement to SQL Log Rescue
  }
}


Not sure what more you're after here?
_________________
Richard Mitchell
Project Manager
Red Gate Software Ltd
Back to top
View user's profile Send private message Send e-mail
jimboh



Joined: 29 Jan 2007
Posts: 17
Location: Melbourne Australia

PostPosted: Fri Mar 28, 2008 6:50 pm    Post subject: Reply with quote

richardjim

I think we are there. The use of mapping.Include property in the manner as you suggest, provides the necessary filter.

The API documentation could certainly be a bit more forthcoming in how this property is applied.

Ultimately, in this current exercise, I am trying to do an Export - similar to SQLDataCompare export - except I only want the left side and no duplicate columns in the CSV/xml file. This is mainly to get Static data for version control -- the aspect that is missing from SQL Compare scripting.

It must be getting close to close of business time in Cambridge and I thank you for your care and attention.

Until next time,

Jimboh
Back to top
View user's profile Send private message
richardjm



Joined: 20 May 2005
Posts: 383
Location: Red Gate Software Ltd

PostPosted: Mon Mar 31, 2008 9:34 am    Post subject: Reply with quote

Happy to help.
_________________
Richard Mitchell
Project Manager
Red Gate Software Ltd
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group