BO Constructor


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
Objects that inherit from MicroFour.StrataFrame.Business.BusinessLayer, i.e. BusinessObjects, have 2 overloads on the constructor. The second one takes an IContainer.



How and when is that used?
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
The second constructor that accepts the IContainer is used when you drop a business object on a form or a user control. The IContainer that gets passed is the "components" collection on the form/user control. This constructor signature is a standard signature used by objects that inherit from Component, MarshalByValueComponent, or MarshalByRefComponent.
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
In a windows service you get some code like:

      private System.ComponentModel.Container components = null;



      public Service1()

      {

         // This call is required by the Windows.Forms Component Designer.

         InitializeComponent();



         // TODO: Add any initialization after the InitComponent call

      }



would there be any point/benefit to passing 'components' to the BO constructor?
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
Probably... if you drop a business object onto the service within the service designer, then the code generator will automatically call that method... I believe the service will cycle through it's "components" collection and Dispose() of each item when the service shuts down.
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
I'll try it.
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
Tried it...



The error says "The object that the business object has been dropped on must implement MicroFour.StrataFrame.UI.Windows.Forms.IContainerControl.



How do I do that?
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
Tried inheriting from MicroFour.StrataFrame.UI.Windows.Forms.IContainerControl -

got the following errors. Need documentation and/or guidance about how to implement this stuff on non-visual components.



TEST_FaxSending.Form1' does not implement interface member 'MicroFour.StrataFrame.UI.Windows.Forms.IContainerControl.AddObjectToInitOnLoad(MicroFour.StrataFrame.UI.IInitOnFormLoad)'   'TEST_FaxSending.Form1' does not implement interface member 'MicroFour.StrataFrame.UI.Windows.Forms.IContainerControl.AddBusinessObject(MicroFour.StrataFrame.Business.BusinessLayerBase)'   'TEST_FaxSending.Form1' does not implement interface member 'MicroFour.StrataFrame.UI.Windows.Forms.IContainerControl.AddObjectToPreInitOnLoad(MicroFour.StrataFrame.UI.IPreInitOnFormLoad)'   C:\_devel\release.90000\TEST-FaxSending\TEST-FaxSending\Form1.Designer.cs   TEST_FaxSending.Form1' does not implement interface member 'MicroFour.StrataFrame.UI.Windows.Forms.IContainerControl.RemoveBusinessObject(MicroFour.StrataFrame.Business.BusinessLayerBase)'   C:\_devel\release.90000\TEST-FaxSending\TEST-FaxSending\Form1.Designer.cs   

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
The "components" collection is only used for user interface stuff, and the IContainerControl interface is only also only used for user interface stuff. Since the service you're creating does not have a user interface, I wouldn't worry about trying to implement the IContainerControl interface, and avoid the user of that constructor overload all together.



What I would do is within the "start" method for the service, create your SqlDataSourceItem and add it to the DataSources collection, then create your business objects. Then, within the "stop" method, call Dispose() on the business objects to ensure that resources are released.
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
I've got this code in my service:



//-- Create Business Objects

_Log = new DdmLog();

_Queue = new DdmQueue();

_Log.ParentBusinessObject = _Queue;

_Log.Navigated += new BusinessLayer.NavigatedEventHandler(_Log_Navigated);



and

_Queue.FillPendingItems();

if (_Queue.Navigate(BusinessNavigationDirection.First))

{

do

{

MessageBox.Show(_Log.DocumentTitle);

}

while (_Queue.Navigate(BusinessNavigationDirection.Next));

}

and

void _Log_Navigated(NavigatedEventArgs e)

{

_Log.FillByParentPrimaryKey(_Queue.DocumentID);

}



and

public void FillPendingItems()

{

try

{

//-- Establish locals

SqlCommand loCommand = new SqlCommand();



//-- Create the command

loCommand.CommandText = "SELECT * FROM dbo.DdmQueue ORDER BY DttmQueued DESC";

loCommand.CommandType = CommandType.Text;



//-- Execute the command

this.FillDataTable(loCommand);

}

catch (ApplicationException ex)

{

Console.WriteLine(ex.Message);

}

}



and I get this error

"An error occurred while creating a new DataLayer for the business object."



I guess I'm still lost.
Gary C Wynne
Gary C Wynne
StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)
Group: Forum Members
Posts: 26, Visits: 236
Hi Daniel

Just a SWAG; maybe the connection information is missing? This is one reason that the datalayer may not be able to be created. I had a similar situation when I created BOs outside the general context of a standard SF application. Check the inner exception (if provided) on the error and see what it indicates.

HTH

-=Gary

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