I saw "Ole Automation" examples of creating Physical Database Model elements, but there is no examples of opening an existing DB model.
Can someone please help me? My expectations are similar to this pseudo-code:
PdCommon.Application pd;
pd = PdCommon.OpenApplication(%Path%);
...
pascal was right.
PdCommon.Application pdApplication;
PdPDM.Model pdModel;
pdApplication = new PdCommon.Application();
pdModel = (PdPDM.Model)pdApplication.OpenModel(#"C:\SVN\RAS_DB_Control\trunk\Northwind - MS\Model\Northwind.pdm");
Related
I'm a software developer working at Architecture Design Firm (Archcorp.biz). Here we are developing custom plugins for Revit 2017 using Revit API. I'd like to know is this possible to read family type and instance properties before importing it into the Revit 2017 editor? If yes, would appreciate some initial guide. Thank you.
There is a class available called BasicFileInfo http://www.revitapidocs.com/2018/f7a75811-b2ec-8b4c-10d3-6ed0eadf4551.htm that will give you some basic information about the file (rvt) without opening it.
There is also a method described here that extracts some Parameters that have values set in the familiy without actually opening it. http://thebuildingcoder.typepad.com/blog/2009/11/extract-part-atoms.html
By struggling through some hours, I finally came up with a solution. All I have to do was to read revit family file by using application.OpenDocumentFile(FamilyPath); method. The following code will help anyone to extract revit family types information.
private void ExtractFamilyInfo(Application app)
{
//A placeholder to store types information
string types = "Family Types: ";
//Open Revit Family File in a separate document
var famDoc = app.OpenDocumentFile(FamilyPath);
//Get the familyManager instance from the open document
var familyManager = famDoc.FamilyManager;
//Get the reference of revit family types
FamilyTypeSet familyTypes = familyManager.Types;
//Set iteration to forward
FamilyTypeSetIterator familyTypesItor = familyTypes.ForwardIterator();
familyTypesItor.Reset();
//Loop through all family types
while (familyTypesItor.MoveNext())
{
FamilyType familyType = familyTypesItor.Current as FamilyType;
//read all family type names
types += "\n" + familyType.Name;
}
//Display text on the UI
DefaultControl.Instance.PropertyText.Text = types.ToString();
}
I have a program I created in Visual studio. The program is basically a place for everyone to store passwords for company and external accounts. I want to further this application by automatically creating the company accounts when I create a new user. I approached this by using the binding source. I can get the row into the database but it doesn't use the sql supplied auto increment. I will post the code but I am trying to figure out if I went about this the wrong way. I am not 100% familiar with how the connector and classes that visual studio create when you connect the solution to the database. I am not looking for code to help me do this I am looking for explanations and guidance. If responding with code please help me understand by explaining the code.
DataSet.AccountsRow newdomainuserrow = DBDataSet.Accounts.NewAccountsRow();
newdomainuserrow.USer = userIDTextBox.Text.ToString();
newdomainuserrow.UserName = userIDTextBox.Text.ToString();
System.DateTime moment = new DateTime();
newdomainuserrow.Password = moment.Year;
newdomainuserrow.AccountName = "Domain";
drawingNumDBDataSet.Accounts.Rows.Add(newdomainuserrow);
MessageBox.Show("User Saved");
this.Validate();
this.usersBindingSource.EndEdit();
this.accountBindingSource.Endedit();
this.tableAdapterManager.UpdateAll(this.DataSet);
All help is greatly appreciated.
Matt
I found a solution. The id field is not longer an identity autoincrement field. To increment the id field one by one programmatically like I need to I wrote a simply while statement to get all numbers that were not used. This works if there is a deleted row it will insert one where there is one missing. here is the code I used.
Boolean gotnum;
gotnum = false;
int idnum = 1;
while (gotnum != true)
{
DrawingNumDBDataSet.AccountsRow actrw = drawingNumDBDataSet.Accounts.FindById(idnum);
idnum++;
if (actrw==null)
{
gotnum = true;
idnum--;
}
}
I then set the Id field = to idnum. This is probably not the best practice but it is the best I could come up with.
I am finding my self looking in front of a wall right now. I've started working with eConnect to communicate with Dynamic GP in order to access information.
I've come accross a questions that I have yet to see answered and I'm tired of searching all over the web and all over the bunch of documents I have. In case someone reads this I'll give you a few sources after my question so you can guide your self even if this post doesn't help you.
My question is how can I create a new PMClassMaster through C#? In the end its an XML file that you need to generate but I wonder if there is a method that does that for me? For example, to create a new Vendor you can do the following:
PMVendorMasterType vendorMasterType = new PMVendorMasterType();
vendorMasterType.eConnectProcessInfo = new eConnectProcessInfo();
vendorMasterType.eConnectProcessInfo.ConnectionString = dynamicGPcs;
vendorMasterType.taUpdateCreateVendorRcd = new taUpdateCreateVendorRcd();
vendorMasterType.taUpdateCreateVendorRcd.VENDORID = vendorGP.VENDORID;
vendorMasterType.taUpdateCreateVendorRcd.VENDNAME = vendorGP.VENDNAME;
vendorMasterType.taUpdateCreateVendorRcd.VENDSHNM = vendorGP.VENDSHNM;
//... etc...
PMVendorMasterType[] vendors = { vendorMasterType };
eConnect.PMVendorMasterType = vendors;
This will pretty much create an XML for you, because thats what GP recevies through eConnect's "CreateEntity" and "UpdateEntity" methods.
I can't seem to find the same for PMClassMaster which is the table that has all the Vendor Class IDs. Does anyone know the answer? For reference: https://www.gptablereference.com/2010/Table/PM00100
----- Sources for GP -----
http://mbsguru.blogspot.pt/
http://victoriayudin.com/
http://www.gptablereference.com
There is no eConnect node for the PM Class Master. Not everything that can be done in GP can be done via eConnect.
For this you will have to manually insert records into the relevant SQL table in the desired database.
Hi I had developed a C# Budget application using SQL Compact and EF4, I created the EF model through the VS2010 Entity Data Model template. It is all working very well. However I am considering developing a iPhone app to support cash transactions and thought it would be better to have the back end DB supported on both platforms. After creating the SQLite DB and creating a new model I have come across a problem when trying to access referenced data via the Navigation properties in my model. I am getting a NullReferenceException when trying to display a property of a referenced table.
When using the following code I get the exception on the last line:
BudgetEntities budget = new BudgetEntities();
var accounts = budget.BankAccounts.ToList();
foreach (BankAccount a in accounts)
{
Console.WriteLine("Name:" + a.Description);
Console.WriteLine("Number:" + a.AccountNumber);
Console.WriteLine("Type:" + a.BankAccountType.AccountType); //Exception occurs here.
}
Strange thing is that the exception doesn't occur in this example. I'm not sure what is going on?
BudgetEntities budget = new BudgetEntities();
var accoutTypes = budget.BankAccountTypes;
var account = new BankAccount();
account.ID = Guid.NewGuid();
account.AccountTypeID = accoutTypes.First(t => t.AccountType.StartsWith("Credit")).ID;
account.BSB = "3434";
account.AccountNumber = "32323";
account.Description = "Test";
account.TrackingAccount = true;
budget.AddObject("BankAccounts", account);
budget.SaveChanges();
var accounts = budget.BankAccounts.ToList();
foreach (BankAccount a in accounts)
{
Console.WriteLine("Name:" + a.Description);
Console.WriteLine("Number:" + a.AccountNumber);
Console.WriteLine("Type:" + a.BankAccountType.AccountType); //Exception doesn't happen.
}
This is only a simple example and I know I could fix it by adding .Include("BankAccountTypes") to the query however I have other queries that are quite complex that are creating object which include properties from referenced object with in the query and I am not quite sure how to get around this issue for them.
EDIT:
After having a break between projects I have come back to this problem and I have finally resolved my problem. it had nothing to do with the code. It was with the data. I had converted a SQL Compact database to SQLite via a dump and load and had the syntax wrong for my Guid column data. I was inserting the Guid as '7cee3e1c-7a2b-462d-8c3d-82dd6ae62fb4' when it should have been x'7cee3e1c7a2b462d8c3d82dd6ae62fb4'
Hopefully the hair I pulled out working through this problem will grow back :)
Thanks everyone for your input.
In second example your code snippet begins with:
var accoutTypes = budget.BankAccountTypes;
This loads all bank account types to your application and you don't need lazy loading anymore (EF will automatically recognize that these entities were already loaded and fix relations with bank accounts).
First check if your account class is dynamic proxy (just check type of a in the debugger). If it is not you made some mistake in the class definition and lazy loading will not work. Next check if lazy loading is enabled on your context instance (budget.ContextOptions.LazyLoadingEnabled property).
Make sure the BankAccountType property is declared virtual in BudgetEntities.
I'm having major difficulties to start off with NHiberante.
Main problems:
Where my hbm.xml files should reside? I create a Mappings folder but I received an error "Could not find xxx.hbm.xml file."
I tried to load the specific class through the dialect cf.AddClass(typeof(xxx)); but it still gives me the same error (the files are marked as embebed resources.
Also I'm having major problems in connection to it. I stopped trying to use the cfg xml file and tried a more direct approach with a library I have here.
Configuration cfg = new Configuration();
cfg.AddClass(typeof(Tag));
ISessionFactory sessions = cfg.BuildSessionFactory();
AgnosticConnectionHandler agch = new AgnosticConnectionHandler("xxx","xxx","geo_biblio","localhost",
5432,DatabaseInstance.PostgreSQL);
ISession sessao = sessions.OpenSession(agch.GetConnection);
ITransaction tx = sessao.BeginTransaction();
Tag tag1 = new Tag();
tag1.NomeTag = "Teste Tag NHibernate!!!";
sessao.Save(tag1);
tx.Commit();
sessao.Close();
Any tips for me? I'm getting the exception in line 2 of this code, and still not sure what to do.
Any help is appreciated. Thanks
If you're starting with nHibernate I think you really should take a look at fluent nhibernate, its way easier do develop and maintain the mapping, it even has an auto-mapping option.
Another option is confORM from Fabio Maulo (nhibernate lead developer), looks like a great tool.
Also, you can take a look at s#arp architecture, you can get some nice ideas from this project.