Several how-to questions


Author
Message
Daniel Essin
Daniel Essin
StrataFrame User (339 reputation)StrataFrame User (339 reputation)StrataFrame User (339 reputation)StrataFrame User (339 reputation)StrataFrame User (339 reputation)StrataFrame User (339 reputation)StrataFrame User (339 reputation)StrataFrame User (339 reputation)StrataFrame User (339 reputation)
Group: Forum Members
Posts: 235, Visits: 309
1 - If I have existing stored procs in a database, how can I make the deployment toolkit aware of them? They don't show up during database import.



2 - If I have existing views in a database, how can I make the deployment toolkit aware of them? They don't show up during database import.



3 - I have a bo with a property called PrimaryKeyField. The value is "A class derived from MicroFour.StrataFrame.Business.BusinessLayer must override the property 'PrimaryKeyField'". There is a property in the BO called PrimaryKeyFields. What's going on here?



4 - I have a bo to retrieve a user row after login. If I log in with an incorrect password, no application exception is thrown but if I inspect the bo, it throws an internal exception on each of the fields. I'm confused. The code is:



private static void ShowLoginAndInitMainForm(ShowLoginAndInitFormEventArgs e)

{

FormLogin fl = new FormLogin();

if (fl.ShowDialog() == DialogResult.OK)

{

string conn;

Hashtable cfg = (Hashtable)ConfigurationManager.GetSection("database");

conn = "server=" + cfg["server"] + ";initial catalog=" + cfg["initialCatalog"] + ";uid=" + fl.UserName + ";pwd=" + fl.Password + ";";

DataLayer.DataSources.Add(new SqlDataSourceItem("", conn));

ConnectionManager.SetConnections();

BoUsers user = new BoUsers();

user.GetUserInfo(fl.UserName);

e.LoginSuccessful = true;

}

}





   public void GetUserInfo(string UserCode)

{

SqlCommand cmd = new SqlCommand();

cmd.CommandText = "SELECT * FROM SvcUsers WHERE LogonName = '" + UserCode + "'";

FillDataTable(cmd);

}





StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
1 & 2. The DDT does not currently import stored procedures or views. That is on our list of enhancements for the DDT, but is not done, yet.



3. This sounds like a version mismatch problem. The PrimaryKeyField property on the BusinessLayer class was changed to not overridable in version 1.4. Instead, a new overridable property was added called PrimaryKeyFields which returns an array of the field names that comprise the primary key. The PrimaryKeyField property is not overridable and returns the first field from the PrimaryKeyFields property (for backward compatibility).



In version 1.3, the PrimaryKeyField threw a NotImplemented exception in the base class, but since you're on version 1.4 (because you have the PrimaryKeyFields property), it shouldn't be throwing that exception any more. Open up your GAC folder in windows explorer (C:\Windows\assembly\) and make sure that you don't have version 1.3.0.0 of any of the "MicroFour StrataFrame" dlls. Then, check the version on your assembly references. There's some piece of 1.3 hanging around on your machine.



4. You don't need to call ConnectionManager.SetConnections() if you're adding a new SqlDataSourceItem manually. You only need to call SetConnections() when you call ConnectionManager.AddRequiredDataSourceItem(). The SetConnections() method adds the SqlDataSourceItems to the collection, which you've already done manually.



I'm confused as to what part is actually throwing the internal exception. If the user logs in with an invalid username and password, are does the application go through the GetUserInfo() method properly? because it should fail when you call FillDataTable()... The whole issue might be caused by the call to SetConnections() because you're adding the SqlDataSourceItem manually, and calling SetConnections() is modifying your collection. So, remove the call to ConnectionManager.SetConnections() and see if you get the desired result. If you don't then try to post some more detailed information on where the exception is being thrown.
Daniel Essin
Daniel Essin
StrataFrame User (339 reputation)StrataFrame User (339 reputation)StrataFrame User (339 reputation)StrataFrame User (339 reputation)StrataFrame User (339 reputation)StrataFrame User (339 reputation)StrataFrame User (339 reputation)StrataFrame User (339 reputation)StrataFrame User (339 reputation)
Group: Forum Members
Posts: 235, Visits: 309
re number 2 - I removed SF with add/remove and then checked the GAC and the app dir. All traces gone. I then reinstalled 1.4. The PrimaryKeyField property still says "A class derived from MicroFour.StrataFrame.Business.BusinessLayer must override the property 'PrimaryKeyField'"



re number 4 - I removed the SetConnections call and it does throw an exception on FillDataTable. The only problem is that it takes 30 seconds to complain. Any suggestion on how to speed that up without embedding a password to read the users table and without making that table public? btw - I can't use integrated security for this app.
StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
4. Add "Timeout=3;" to the end of your connection string... with 3 being the number of seconds to wait before throwing the exception. The default is 30 seconds, which is why it takes about 30 seconds to throw you the error Smile



2. Hrm... not sure why you're getting this error then. Here's the current code for the PrimaryKeyField property:



Public ReadOnly Property PrimaryKeyField() As String

Get

If Me.PrimaryKeyFields.Length = 1 Then

Return Me.PrimaryKeyFields(0)

Else

Throw New BusinessLayerException("The PrimaryKeyFields property must have exactly 1 field to use the PrimaryKeyField property.")

End If

End Get

End Property



Here's the code from version 1.3:



Public Overrides ReadOnly Property PrimaryKeyField() As String

Get

Throw New NotImplementedException("A class derived from " & GetType(BusinessLayer).FullName & " must override the property 'PrimaryKeyField'")

End Get

End Property



Did you ever download the source code for version 1.3 and compile it? You might try to download the version 1.4 source code, compile it in debug mode and step through it. You should be able to find where that exception is being thrown.
Daniel Essin
Daniel Essin
StrataFrame User (339 reputation)StrataFrame User (339 reputation)StrataFrame User (339 reputation)StrataFrame User (339 reputation)StrataFrame User (339 reputation)StrataFrame User (339 reputation)StrataFrame User (339 reputation)StrataFrame User (339 reputation)StrataFrame User (339 reputation)
Group: Forum Members
Posts: 235, Visits: 309
Ben Chase (05/05/2006)
4. Add "Timeout=3;" to the end of your connection string... with 3 being the number of seconds to wait before throwing the exception. The default is 30 seconds, which is why it takes about 30 seconds to throw you the error Smile



2. Hrm... not sure why you're getting this error then. Here's the current code for the PrimaryKeyField property:



Public ReadOnly Property PrimaryKeyField() As String

Get

If Me.PrimaryKeyFields.Length = 1 Then

Return Me.PrimaryKeyFields(0)

Else

Throw New BusinessLayerException("The PrimaryKeyFields property must have exactly 1 field to use the PrimaryKeyField property.")

End If

End Get

End Property



Here's the code from version 1.3:



Public Overrides ReadOnly Property PrimaryKeyField() As String

Get

Throw New NotImplementedException("A class derived from " & GetType(BusinessLayer).FullName & " must override the property 'PrimaryKeyField'")

End Get

End Property



Did you ever download the source code for version 1.3 and compile it? You might try to download the version 1.4 source code, compile it in debug mode and step through it. You should be able to find where that exception is being thrown.




I never compiled the source. I will try it over the weekend. The timeout problem is resolved thanks.
StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
My pleasure on the timeout issue... keep me updated on your other problem.
Daniel Essin
Daniel Essin
StrataFrame User (339 reputation)StrataFrame User (339 reputation)StrataFrame User (339 reputation)StrataFrame User (339 reputation)StrataFrame User (339 reputation)StrataFrame User (339 reputation)StrataFrame User (339 reputation)StrataFrame User (339 reputation)StrataFrame User (339 reputation)
Group: Forum Members
Posts: 235, Visits: 309
OK - I've done the following



- Compiled the source.

- Installed the new binaries in the GAC (since it wouldn't let me delete the existing ones).

- Examined the source. The PrimaryKeyField property of the BusinessLayer does not contain any code that would throw a not implemented exception.

- The PropertyGrid for my BO still containes "A class derived from MicroFour.StrataFrame.Business.BusinessLayer must override the property 'PrimaryKeyField'" in the PrimaryKeyField slot.



I then copied all of the source directories and included them in my solution. I set the references to the projects rather than to the assemblies in the GAC or the Assemblies in the StrataFrame directory. Everything builds without errors BUT the "A class derived from MicroFour.StrataFrame.Business.BusinessLayer must override the property 'PrimaryKeyField'" message is still there.



I have grepped all of the source files for "A class derived from .+ must override". It appears in 5 locations but not in PrimaryKeyField.



I'm sorry but I have no clue as to wha't going on here.
StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Where are you getting that error message?  Within the property sheet at design time? 

I never understood where you were getting that message.  Now it makes more sense. 

When you go to the component designer for a business object, Visual Studio creates a instance of the object in memory for you work with.  However, in the designer, it doesn't create an instance of your class, but rather the base class for your class (which happens to be BusinessLayer).  So, Visual Studio actually creates an instance of BusinessLayer rather than an instance of your class, and that instance of BusinessLayer is what gets shown within the property sheet. 

Now, whenever we added the PrimaryKeyFields property, I essentiall renamed the PrimaryKeyField property to PrimaryKeyFields and wrote a new PrimaryKeyField property.  So, the code within the PrimaryKeyFields property was the code that was throwing the NotImplementedException.  This is the proper behavior since the object placed in the property sheet is an instance of BusinessLayer rather than your class.  The reason you're getting that message is that I forgot to place the [Browsable(false)] attribute on the PrimaryKeyField property when I created it.  I've fixed it, and it won't show up in the property sheet in future versions. 

So, the message won't cause any runtime problems since you create instances of your classes rather than BusinessLayer.

Daniel Essin
Daniel Essin
StrataFrame User (339 reputation)StrataFrame User (339 reputation)StrataFrame User (339 reputation)StrataFrame User (339 reputation)StrataFrame User (339 reputation)StrataFrame User (339 reputation)StrataFrame User (339 reputation)StrataFrame User (339 reputation)StrataFrame User (339 reputation)
Group: Forum Members
Posts: 235, Visits: 309
Thanks. That makes sense.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search