Hi,
I'm trying to create a VS.Net 2005 add-in to do a limited number of management tasks on an LLBLGen project.
I've been able to load the project fine, but trying to refresh a catalog is proving unbelievably complicated. A lot of the classes used to do the refresh seem have been designed just for the LLBL Pro Designer... which is fair enough i suppose. :|
SqlServerCatalogRetriever throws a NullReferenceException if you dont provide a hashtable with all the callbacks it wants (null chks needed). So i had to make a bunch of blank methods to get that going.
**
Anyway... After i call refresher.MigrateProjectToNewCatalog my Entities collection (on the project instance) is empty. What am I doing wrong?
**
Code time:
private void RefreshCatalogButton_Click(object sender, EventArgs e)
{
UserConfiguration preferences = new UserConfiguration();
Hashtable catalogs = new Hashtable();
catalogs.Add(currentProject.Catalogs[0].CatalogName, currentProject.Catalogs[0]);
SchemaFetchFlags flags = GeneralUtils.DetermineRefreshFetchFlags(currentProject, catalogs);
Hashtable connectionElements = currentProject.ConnectionElements;
Hashtable properties = new Hashtable();
properties.Add(CatalogElementRetrievalOption.ManualSelectSProcsFromSchema, preferences.ManualSelectSProcsFromSchema);
properties.Add(CatalogElementRetrievalOption.SqlServerAutoDetermineSProcType, preferences.SqlServerAutoDetermineSProcType);
properties.Add(CatalogElementRetrievalOption.UnattendedRetrieval, true);
Hashtable callbacks = new Hashtable();
callbacks.Add(ProgressCallBack.SubTaskProgressInitCallBack, new SubTaskProgressInitCallBack(UselessMethod1));
callbacks.Add(ProgressCallBack.SubTaskProgressTaskCompletedCallBack, new SubTaskProgressTaskCompletedCallBack(UselessMethod2));
callbacks.Add(ProgressCallBack.SubTaskProgressTaskStartCallBack, new SubTaskProgressTaskStartCallBack(UselessMethod3));
callbacks.Add(ProgressCallBack.TaskProgressInitCallBack, new TaskProgressInitCallBack(UselessMethod1));
callbacks.Add(ProgressCallBack.TaskProgressTaskCompletedCallBack, new TaskProgressTaskCompletedCallBack(UselessMethod2));
callbacks.Add(ProgressCallBack.TaskProgressTaskStartCallBack, new TaskProgressTaskStartCallBack(UselessMethod3));
callbacks.Add(ProgressCallBack.SelectStoredProcsToRetrieveCallBack, new SelectStoredProcsToRetrieveCallBack(UselessMethod4));
ArrayList newCatalogs = currentProject.DatabaseDriver.PopulateSelectedCatalogs(callbacks, connectionElements, flags, properties);
ArrayList catalogsToRemove = new ArrayList();
foreach (IDBCatalog newCatalog in newCatalogs)
{
IDBCatalog oldCatalog = (IDBCatalog)catalogs[newCatalog.CatalogName];
catalogsToRemove.Add(oldCatalog);
CatalogRefresher refresher = new CatalogRefresher(currentProject, oldCatalog, newCatalog, preferences);
refresher.MigrateProjectToNewCatalog(true, null);
}
foreach (IDBCatalog unwantedCatalog in catalogsToRemove)
currentProject.Catalogs.Remove(unwantedCatalog);
foreach (IDBCatalog wantedCatalog in newCatalogs)
currentProject.Catalogs.Add(wantedCatalog);
currentProject.AddNewFoundElementsToProject(new LogNode(string.Empty, LogNodeType.None), true,
false);
//currentProject.Entities.Clear();
//currentProject.AddRawEntitiesToProject(currentProject.RetrieveEntitiesFromCatalogs(EntityMapTargetElementType.Table, true));
}
void UselessMethod1(int val)
{
}
void UselessMethod2(){
}
void UselessMethod3(string val)
{
}
void UselessMethod4(string val, bool b, ArrayList list, bool b2, ref Hashtable table)
{
}