Well, let me start by saying that this program is an advanced kinda-level program, but this part in particular isn't that complex.
I'm just trying to work out the best method to store the following information, without having the user install something like SQL Express (which for this program would be counter productive!)
This program will sort through the current running processes, checking if any processes are listed in the program. If a match is found, the commands attached are executed (starting or stopping processes). Also, a process may just be designated as part of a group, so executing the group's commands instead (say if you have a number of full-screen games installed, and you want MSN Messenger to close whenever you open one of them, you assign all of them to a group named 'Game', and make the 'Game' group when executed close MSN Messenger).
What is the best method of storing that, without requiring extra software installed? It needs to be easy to modify through code, I don't care if they can modify it by hand.
The options I've been tossing up are XML Serialization (which I believe could get messy as I'd use ArrayList kinda things), or simply binary serialization. Is there a better option?
Thanks in advance.
Storage IssueStoring a process or groupname, and attaching stuff to it...
Page 1 of 1
6 Replies - 586 Views - Last Post: 10 December 2008 - 07:53 AM
Replies To: Storage Issue
#2
Re: Storage Issue
Posted 14 October 2008 - 08:12 AM
I would serialize classes myself. Simple and fast, and with LINQ there are lots of advantages to using collections/classes over arraylists.
#3
Re: Storage Issue
Posted 15 October 2008 - 12:01 AM
#4
Re: Storage Issue
Posted 09 December 2008 - 02:26 AM
I need help. I have ABSOLUTELY no idea how to do this.
This post has been edited by dawmail333: 09 December 2008 - 02:32 AM
#5
Re: Storage Issue
Posted 09 December 2008 - 06:57 AM
Well start off by telling us what fields you need to store.
#6
Re: Storage Issue
Posted 09 December 2008 - 05:15 PM
magicmonkey, on 9 Dec, 2008 - 05:57 AM, said:
Well start off by telling us what fields you need to store.
Thanks.
I have a system set up, where events are triggered when a program starts/stops.
I need to store the following information for each program:
When listed program...
Starts...
- Start Programs (string Filename, boolean OnceOnly)
- End Programs (string FileName)
- Start Programs (string Filename, boolean OnceOnly)
- End Programs (string FileName)
Appreciate help thank you.
#7
Re: Storage Issue
Posted 10 December 2008 - 07:53 AM
I am being really generous here...
Example of using Classes...
Classes to store and serialize your data...
Example of XML file created from serialization process...
Example of using Classes...
Private Sub ProcessMonitor_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
MyDataStore.Open(Application.StartupPath & "\Data.xml")
'Display Data Store Contents
For Each selWP As WatchProcess In MyDataStore.WatchProcesses
Debug.WriteLine(selWP.ProcessName)
Debug.Indent()
For Each selSP As StartProcess In selWP.StartProcesses
Debug.WriteLine(selSP.ProcessFile & " - " & selSP.StartSingleInstanceOnly)
Next
For Each selEP As EndProcess In selWP.EndProcesses
Debug.WriteLine(selEP.ProcessName)
Next
Debug.Unindent()
Next
End Sub
Private Sub butAddProcess_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butAddProcess.Click
'Add data to Data Store
Dim newWP As WatchProcess = MyDataStore.WatchProcesses.Add("IEXPLORER")
newWP.StartProcesses.Add("PAINT.EXE", False)
newWP.EndProcesses.Add("NOTEPAD")
MyDataStore.Save()
End Sub
Classes to store and serialize your data...
Public Class MyDataStore
Private Shared _FileName As String
Public Shared ReadOnly Property FileName() As String
Get
Return _FileName
End Get
End Property
Private Shared _WatchProcesses As WatchProcesses
Public Shared ReadOnly Property WatchProcesses() As WatchProcesses
Get
Return _WatchProcesses
End Get
End Property
Public Shared Sub Open(ByVal FileName As String)
If IO.File.Exists(FileName) Then
'Open Data Store
Dim xs As New Xml.Serialization.XmlSerializer(GetType(WatchProcesses))
Using sr As New IO.StreamReader(FileName)
_WatchProcesses = CType(xs.Deserialize(sr), WatchProcesses)
End Using
_FileName = FileName
Else
'Create new Data Store
_WatchProcesses = New List(Of WatchProcess)
_FileName = FileName
Save()
End If
End Sub
Public Shared Sub Save()
If Not String.IsNullOrEmpty(_FileName) Then
'Save Data Store
Dim xs As New Xml.Serialization.XmlSerializer(GetType(WatchProcesses))
Using sw As New IO.StreamWriter(FileName, False)
xs.Serialize(sw, _WatchProcesses)
End Using
Else
'Throw Error
Throw New Exception("Data Store not Open.")
End If
End Sub
End Class
<Serializable()> _
Public Class WatchProcesses
Inherits List(Of WatchProcess)
Public Overloads Function Add(ByVal ProcessName As String) As WatchProcess
Dim newWP As New WatchProcess With {.ProcessName = ProcessName}
MyBase.Add(newWP)
Return newWP
End Function
End Class
<Serializable()> _
Public Class WatchProcess
Private _ProcessName As String
Public Property ProcessName() As String
Get
Return _ProcessName
End Get
Set(ByVal value As String)
_ProcessName = value
End Set
End Property
Private _StartProcesses As New StartProcesses
Public ReadOnly Property StartProcesses() As StartProcesses
Get
Return _StartProcesses
End Get
End Property
Private _EndProcesses As New EndProcesses
Public ReadOnly Property EndProcesses() As EndProcesses
Get
Return _EndProcesses
End Get
End Property
End Class
<Serializable()> _
Public Class StartProcesses
Inherits List(Of StartProcess)
Public Overloads Function Add(ByVal ProcessFile As String, ByVal StartSingleInstanceOnly As Boolean) As StartProcess
Dim newSP As New StartProcess With {.ProcessFile = ProcessFile, .StartSingleInstanceOnly = StartSingleInstanceOnly}
MyBase.Add(newSP)
Return newSP
End Function
End Class
<Serializable()> _
Public Class StartProcess
Private _ProcessFile As String
Public Property ProcessFile() As String
Get
Return _ProcessFile
End Get
Set(ByVal value As String)
_ProcessFile = value
End Set
End Property
Private _StartSingleInstanceOnly As Boolean
Public Property StartSingleInstanceOnly() As Boolean
Get
Return _StartSingleInstanceOnly
End Get
Set(ByVal value As Boolean)
_StartSingleInstanceOnly = value
End Set
End Property
End Class
<Serializable()> _
Public Class EndProcesses
Inherits List(Of EndProcess)
Public Overloads Function Add(ByVal ProcessName As String) As EndProcess
Dim newEP As New EndProcess With {.ProcessName = ProcessName}
MyBase.Add(newEP)
Return newEP
End Function
End Class
<Serializable()> _
Public Class EndProcess
Private _ProcessName As String
Public Property ProcessName() As String
Get
Return _ProcessName
End Get
Set(ByVal value As String)
_ProcessName = value
End Set
End Property
End Class
Example of XML file created from serialization process...
<?xml version="1.0" encoding="utf-8"?> <ArrayOfWatchProcess xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <WatchProcess> <ProcessName>IEXPLORER</ProcessName> <StartProcesses> <StartProcess> <ProcessFile>PAINT.EXE</ProcessFile> <StartSingleInstanceOnly>false</StartSingleInstanceOnly> </StartProcess> </StartProcesses> <EndProcesses> <EndProcess> <ProcessName>NOTEPAD</ProcessName> </EndProcess> </EndProcesses> </WatchProcess> </ArrayOfWatchProcess>
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote




|