Community
Showing results for 
Search instead for 
Do you mean 
Reply

"I am Serial"

Bronze Super Contributor
Posts: 1,231
Country: USA

"I am Serial"

Xavier,

Any plans on serializing Act.Framework.CustomEntities.CustomSubEntity.

I looked into doing it today but I could not find a field Enumerator on the object. The only way i know is on the Entity Manager. See sudo code.

thanks

-- jim durkin

   
  

<Serializable()> _

Public Class CustomSubEntityDurkin

Inherits Act.Framework.CustomEntities.CustomSubEntity

Implements ISerializable, Xml.Serialization.IXmlSerializable

Private _EntityManager As CustomSubEntityManager(Of Durkin.Common.Classes.CustomSubEntityDurkin)

 

'---------------------------------

' Required ACT SDK constructor

'---------------------------------

Public Sub New(ByVal state As CustomSubEntityInitializationState)MyBase.New(state)

End Sub

'---------------------------------

' Constructor WITH ENTITYMANAGER ??

'---------------------------------

Public Sub New(ByVal state As CustomSubEntityInitializationState, ByVal EntityManager As CustomSubEntityManager(Of Durkin.Common.Classes.CustomSubEntityDurkin)) MyBase.New(state)

_EntityManager = EntityManager

End Sub

 

Public Sub GetObjectData(ByVal info As System.Runtime.Serialization.SerializationInfo, ByVal context As System.Runtime.Serialization.StreamingContext) Implements System.Runtime.Serialization.ISerializable.GetObjectData

Return

End Sub

 

 

Public Function GetSchema() As System.Xml.Schema.XmlSchema Implements System.Xml.Serialization.IXmlSerializable.GetSchema

Return Nothing

End Function

 

Public Sub ReadXml(ByVal reader As System.Xml.XmlReader) Implements System.Xml.Serialization.IXmlSerializable.ReadXmlThrow New NotImplementedException()

End Sub

 

Public Sub WriteXml(ByVal writer As System.Xml.XmlWriter) Implements System.Xml.Serialization.IXmlSerializable.WriteXml

'---------------------------------------------

' TODO ??

' SERIALIZE THIS OBJECT IF POSSIBLE

'---------------------------------------------

 For Each cField As CustomEntityFieldDescriptor In _EntityManager.GetCustomEntityFieldDescriptors()

Dim sLocalName As String = cField.TableName + cField.Namewriter.WriteElementString(sLocalName, cField.GetValue(

Me))

Next

 End Sub

End Class

 

 

Employee
Posts: 236
Country: USA

Re: "I am Serial"

Hi Jim,

 

Serialization of ACT! business objects, both system and custom, currently isn't supported out of the box.  

 

I can share some of the complexities if you like.  Under the hood of an ACT! entity, a DataSet is used to contain the data.  That is certainly serializable, being that it naturally converts to XML.  However, because we fetch data in batches for efficiency/performance, and the data is relational in nature, the underlying DataSet often includes multiple tables and multiple rows/entities.  That is to say, there's some complexities and overhead we would need to deal with in serializing the underlying data.  Furthermore, there's likely some pieces of data which may be sensitive or may not be appropriate to serialize directly.  I'm not aware of other serialization requests, and this need hasn't presented itself in the application to date (other than in some specific form for debugging), so this currently isn't on the roadmap.

 

Now in the interest of helping your situation, you can access all of the fields of an entity via the fields collection, and should be able to do your own serialization.

 

 

Bronze Super Contributor
Posts: 1,231
Country: USA

Re: "I am Serial"

That's for the detailed explanation! That's kinda what I expected since I understand somewhat how ACT! objects work by querying just the GUIDs.  I am looking at serialization for export/import and copy/paste on my custom entity grids.

 

That said...

I don't see a way to enum the field on the entity.fields collection since it only takes a 'name' parameter.

 

Do I need to .add the field to the collection first? 

How would I do that from the entity?

 

thanks

-- jim durkin

Employee
Posts: 236
Country: USA

Re: "I am Serial"

The field collection is an IEnumerable, meaning it can be iterated over using foreach semantics.
Bronze Super Contributor
Posts: 1,231
Country: USA

Re: "I am Serial"

It might be cause I'm thick in the head or just that I am technically on vacation but the collection was always null whn i tried foreach.

 

How do I add a field to the collection?

 

thanks

-- jim durkin

New Member
Posts: 4
Country: USA

Re: "I am Serial"

Hi Jim,

 

Is this what you're looking for?

 

CustomEntityFieldDescriptor[] cefdArray = CustomEntityManager.GetCustomEntityFieldDescriptors();

for (int i = 0; i < cefdArray.Length; i++)

CustomEntityList.FieldDescriptors.Add(cefdArray[i])

 

Now a foreach should work

 

foreach (CustomEntityFieldDescriptor cefd in CustomEntityList.FieldDescriptors)
{

}

Sorry for the C# sample.

 

Sanford Silver

Bronze Super Contributor
Posts: 1,231
Country: USA

Re: "I am Serial"

OK, I know its that my brain is in idle so please be kind...

 

I know I can enum from the entitylist or the entitymanager but how can I enum from the subEntity object that inherits Act.Framework.CustomEntities.CustomSubEntity?

 

It's only constructor takes CustomSubEntityInitializationState.  I would love it if it took two parms, the State and the Manager.

See my sudo code above where the second constructor takes two parms. The econd sudo parm becomes the _EntityManager  and that _EntityManager is where i can enum the fields.  ( See "Public Sub WriteXml")

 

Let me ask another way since I don't have any code in front of me.

 

Can I reference the CustomSubEntity's parent manager? Or can I reference the EntityList that the CustomSubEntity is attached to?

If this is the case then I could enum the fields.

 

thanks

-- jim durkin

Bronze Elite Contributor
Posts: 2,115
Country: United_Kingdom

Re: "I am Serial"

Hi Jim,

 

If you are writing for ACT! 9 or above you could look at using .NET 3.5 and LINQ. It's quite cool and I'm finding it a real help on things like this, e.g:

CustomEntityFieldDescriptor[] cEFDArr = CustomEntityManager.GetCustomEntityFieldDescriptors();

var fields = from CustomEntityFieldDescriptor cFD in CEFDArr

                orderby cFD.Name ascending

                select cFD;

foreach(CustomEntityFieldDescriptor in fields){...;}

LINQ has really reduced the amount of code I write and is radically changing my whole approach as well, it's so **bleep** cool! The above code could be syntactically inaccurate since I dont have intellisense at hand but you should get the idea!

 

Vivek

Vivek Gargav
Caldere Associates Ltd.
www.caldere.com
vgargav@caldere.com
My Blog