XML files, how to create and maintain them?


Author
Message
Edhy Rijo
E
StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Well, I came up with solution that it is working eventhough I am not completed sure it is coded the right way:

     Public Sub FillAllWithXMLBasics(ByVal ValidationKey As String)

     '-- Establish Locals

     Dim lcFile As String = MicroFour.StrataFrame.Strings.StringBasics.AddBS(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location))

     '-- Save the XML file to disk

     lcFile &= ConstantInformation.ServerSettingsXMLFileName

     '-- Get all data columns from the TableSchema in the BO

     ' to pass it in the xmlBasics.OpenXmlFile

     Dim boTableColumnArray As New List(Of DataColumn)

     For Each I As DataColumn In Me.CreateTableSchema

          boTableColumnArray.Add(I)

     Next

     '-- Load the XML file and add one row

     _myXMLDS = XmlBasics.OpenXmlFile("ConsoleSettings", lcFile, boTableColumnArray)

     If _myXMLDS.Tables("ConsoleSettings").Rows.Count = 0 Then

          _myXMLDS.Tables("ConsoleSettings").Rows.Add()

     End If

     '-- Move the data into the business object

     Me.CopyDataFrom(_myXMLDS.Tables("ConsoleSettings"), MicroFour.StrataFrame.Business.BusinessCloneDataType.ClearAndFillFromCompleteTable)

     '-- In this case we need only one record so

     ' if there is no record, add one here.

     If Me.Count = 0 Then

          Me.Add()

          Me.CurrentDataTable.AcceptChanges()

     End If

End Sub

In the above code I am not sure if I neede to create the boTableColumnArray or there is an easy way to pass the BO columns to the OpenXmlFile() method.

And to save the file from the BO to the XML I am using this method:

Private Sub SaveToXML()

     '-- Establish Locals

     Dim lcFile As String = MicroFour.StrataFrame.Strings.StringBasics.AddBS(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location))

     '-- Save the XML file to disk

     lcFile &= ConstantInformation.ServerSettingsXMLFileName

     '-- I am not sure if the file needs to be deleted

     If System.IO.File.Exists(lcFile) Then

          System.IO.File.Delete(lcFile)

     End If

     '-- Remove the Row created in the FillAllWithXMLBasics and import the one from the BO.

     '-- I guess there is probably a better way to do this?

     _myXMLDS.Tables("ConsoleSettings").Rows.RemoveAt(0)

     _myXMLDS.Tables("ConsoleSettings").ImportRow(Me.CurrentRow)

     '-- Write the XML file back to disk. Notice that you DO NOT NEED the validation key

     ' to write back to disk. This is used only for opening (and the creation of) the XML table.

     XmlBasics.WriteXmlFile(_myXMLDS, lcFile, False)

     Me.CurrentDataTable.AcceptChanges()

End Sub

I appreciate if someone can review these code and confirm they are code appropriately.

Thanks!

Edhy Rijo

Edhy Rijo
E
StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Ok, I am getting somewhere here Hehe I used the code in the XML Sample project and added to my BO, and in the BO.FillAll() method added code to add a new row to the new XML file so I can edit the data in the form as follow:

 

Public Sub FillAll()

     '-- Establish Locals

     Dim loDS As New DataSet

     Dim lcFile As String = MicroFour.StrataFrame.Strings.StringBasics.AddBS(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location))

     '-- Save the XML file to disk

     lcFile &= ConstantInformation.ServerSettingsXMLFileName

     If Not System.IO.File.Exists(lcFile) Then

          Me.CurrentDataTable.WriteXml(lcFile, XmlWriteMode.WriteSchema, True)

     End If

     '-- Load the XML file

     loDS.ReadXml(lcFile)

     '-- Move the data into the business object

     Me.CopyDataFrom(loDS.Tables(0), MicroFour.StrataFrame.Business.BusinessCloneDataType.ClearAndFillFromCompleteTable)

     *-- If there is no record, add one here.

     If Me.Count = 0 Then

          Me.Add()

          Me.CurrentDataTable.AcceptChanges()

     End If

     '-- Clean Up

     loDS.Dispose()

End Sub

In my form I am able to see the data bounded to the xml file and save it back to the xml using the methods in the Sample BO to overwrite the Save() methods.  I now need to add the logic to use the XmlBasics classes to take advantage of having the XML file encrypted and password protected. I am not so sure how to do this since the BO is getting the data via the loDS.ReadXml() method and that does not support the xmlBasics classes, so any help in this regard will be greatly appreciated.

Edhy Rijo

Edhy Rijo
E
StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Trent, Dustin,

I am a bit confused here with the XML Samples and the XmlBasics classes.  Here what I need:

Create an encrypted/password protected XML file to hold information about a Server Settings which will be used by a Windows Service application as implemented in your version of a Server Console explained here http://forum.strataframe.net/FindPost21316.aspx

I went to the XML Sample, but it does not used the xmlBasics classes, also I can not find information in the help file about the xmlBasics classes, so could it be possible for you to post a simple sample of a form which uses the xmlBasic classes to do the following:

  1. Create the XML file with fields based on metadata in BO which was created from the DDT instead of SQL Server.
  2. Update the XML file data via a form

If the sample can not be create at this time, could you give me some hints on how to do 1 and 2 above.

Thanks!

Edhy Rijo

Edhy Rijo
E
StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Thanks Trent,

I will look at the sample and create a dummy DDT profile for the BO mapping.

But still it would be nice that from the DDT I would simple have an option to:

  1. Create an XML file structure metadata.
  2. Use all the DDT designer to add fields, field types,  etc.
  3. Then an option to deploy (creates the file) the XML in an specific folder.

I know that would be a really nice feature, but probably no one that many users will actually use or need right now. Unsure

Edhy Rijo

Trent Taylor
Trent Taylor
StrataFrame Developer (8.7K reputation)StrataFrame Developer (8.7K reputation)StrataFrame Developer (8.7K reputation)StrataFrame Developer (8.7K reputation)StrataFrame Developer (8.7K reputation)StrataFrame Developer (8.7K reputation)StrataFrame Developer (8.7K reputation)StrataFrame Developer (8.7K reputation)StrataFrame Developer (8.7K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Yeah..the DDT. Smile  Just create the structure of the DDT to which you want to map the BO.  This way it is mapped to a DDT profile that never gets deployed.  Then look at the XML sample that comes with the framework (may have to update some references) to see how to talk to the XML file and create the XML file as there are XML file creatiion and structure updating classes within the framework.
Edhy Rijo
E
StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
I want to work with XML file for some forms, I know the BO support the XML file used, but is there any designer that will help me in the creation of the XML file and to maintain its structure?

Probably it could be an enhancement of the DDT to allow the creation and maintanance of XML files and use that metadata in the BOM, unless I am missing something here and there is something like that somewhere in the framework.

Edhy Rijo

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