C# - Which Design Pattern For Activity Logging (Audit Trailing)

Jun 15, 2012

I have a winform which allows people to edit data from a database, to simplify things assume there is a Customer table in database with 3 fields - Name, City, Country. Through winform(s) people can Add/Edit/Delete customers.For each of these actions we need to save:

What the field names are (Name,City,Country in this case)What the field values were before they were modified What the field values are after they are modified.If the action is Add or Delete then 2 and 3 will be the same.I have already implemented this using XMLSerialisation (but not using any of the design patterns) and my XML output looks like this.

<?xml version="1.0" encoding="utf-8"?>
<ActivityItem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<UserID>26</UserID>
<FormTitle>frmCustomer</FormTitle>

[code]....

The solution can handle different areas of the system with different number of fields (i.e the same thing works when you are modifying Products for instance).is there a well defined design pattern to deal with this kind of behavior?

View 2 Replies


ADVERTISEMENT

VS 2008 Logging Connections / Activity

Dec 22, 2010

I'm wondering if its possible to log who is connecting remotely to my local hard drive and also log what they do if possible?A lot of people access my hard drive and im curious to what they do while there.

View 1 Replies

Looking For Design Pattern / For Each Instead Of For With Index

Jun 4, 2012

Using VB.Net, I'm looking for best practices in dealing with the following idiom:[code]What I really want is something VB.Net doesn't offer -- additional and simultaneous iterators on For Each statements.[code]I'm interested in both Linq and non-Linq recommendations, comments about Copy method design, comparisions to C# or other languages.

View 3 Replies

.net - Design Pattern For TypeOf Subclass?

Mar 4, 2012

I am working on a parser for a serial data protocol. I have an overarching Packet class, a couple sub-classes such as CommandPacket and StatusPacket, and then a few sub-classes of each of those:

[Code]..

While I don't think it is entirely relelvant to the discussion, I am doing this in VB.NET. There is also a similar (but not quite the same) question posted here: Java - subclass validation design pattern

View 2 Replies

C# - Design Pattern For Custom Events In .NET?

Feb 21, 2010

What is the proper design pattern for custom events in .NET (VB or C#).

I am refering to custom events, where in you override the AddHandler, RemoveHander, and RaiseEvent methods.

View 1 Replies

Design Pattern For Database Interaction?

Mar 12, 2012

I've been studying design patterns off-and-on now for a project I've recently been working on. I've been fortunate with this last one not to have to work with databases, but will soon have an opportunity.

View 8 Replies

'Producer Consumer' Design Pattern Using Queues?

Jul 23, 2009

I'm trying to replicate a design pattern used in a graphical programming language called LabVIEW. One thread produces commands, and another thread, or series of threads, consumes the commands.This is very similar to using Queues in VB...but there doesn't seem to be an easy way to start the consumer thread when new items are added to the queue.

Here is what I would like to accomplish, please let me know if there is a straightforward way to accomplish this with out of box .Net functionality.1) Start the Consumer Thread...it sits idle, waiting for some new commands to appear in its Queue.2) Producer places a few commands into the Queue. Example: "Home X Axis", "Home Y Axis", "Initialize Pump", "Display Ready Message"3) Consumer thread 'wakes up' at seeing the new commands, then performs the 4 tasks specified in 2.4) Consumer thread goes 'idle' again, and simply waits for new commands to appear in the Queue.

Process can continue on and on forever. The main problem I see with Queues is that there is no 'Wait for Something to Appear in Queue then Retrieve it" functionality. I don't want to use a perpetual loop to keep checking ever n milliseconds.

View 1 Replies

C# - Anonymous Method Alternative For Design Pattern?

Apr 18, 2012

With C# anonymous delegates, we can avoid declaration of extra method, I know in VB.NET they're not available, but is there a design pattern that I can use so that I can avoid writing an extra method each time? I need it for SPSecurity.RunWithElevatedPrivileges which will be used a lot of times in our code.

[Code]...

View 1 Replies

C# - Design Pattern For Dealing With Syncing Variables?

Jan 30, 2012

Suppose I have two events:

Public Sub Control1Updated() Handles control1.TextChanged
control2.Text = SomeFunction(control1.Text)
End Sub

[code]....

Basically the pairs of {control1.Text, control2.Text} and {control2.Text, control1.Text} should be the same. If control1.Text is changed to let's say "a" then control2.Text is ALWAYS "b". If control2.Text is changed to "b" then control1.Text is ALWAYS "a". How do I achieve this with events without going into an infinite loop? [the best I can think of is to make a check if the other control.Text is already the desired value].

View 1 Replies

What Are The Features Of The Controller Class In The MVC Design Pattern

Aug 13, 2009

In the MVC design pattern we must use a controller(s) classes.

What are the fucntions (features) of the controller apart from handling communication bewteen Model and View?e.eg; can we include input validation code in the controller?

View 4 Replies

What Type Of Code Should Put In The Controller In The MVC Design Pattern

Jul 7, 2009

In teh MVC design pattern, Controller is strongly related to the view (GUI). IN my application i need to generated a new BrandID, i used stored procedure to retreive the highest BrandID from teh DB (The model calls the stored procedure and sends the retreival value to the Controller), then in the controller increments the BrandID by "1" to create a new brand ID. SInce, controller is strogly related to "view", should i include this "brandID increment" part in teh controller or in the model classes?

View 3 Replies

Lifetime Of Multiple Instances Of An Object / Design Pattern?

Sep 5, 2009

having difficulty with understanding object lifetime / instantiation.I have a windows from with a datagridview and a panel. The datagridview has a checkbox column and a list of names which is populated from a database.The panel has a few text boxes (e.g. name, age, favourite sports team) and a 'save changes' button.

The idea is that when the user selects a person in the datagridview by checking the appropriate checkbox then the panel shows the relevant data for that person (name, age, fav sports team) by pulling the data from a database. If the user would like to update the person's details they can do so by typing in the textboxes and then clicking the 'save changes' button. All quite simple so far.

The way I have designed this is to have a 'panel' class and to create an instance when the user checks a checkbox.(NB - the reason I have created a 'panel' class is that I intend to replicate the datagridview and panel on other tabpages within my form and thought it would be useful to have a generic 'panel' class that I could re-use.)

My code looks a bit like this:

If CheckBoxClicked Then
Dim UpdatePanel As New UpdatePanel(MyForm.NameTextBox, MyForm.AgeTextBox, MyForm.FavSportTeamTextBox, MyForm.SaveButton)
UpdatePanel.GetData()
...

When the user clicks the SaveButton the data is updated to the database and I have a display message (simple textbox) which says "Update successful" and displays for 5 seconds before hiding itself.

Here is the problem:Suppose a user checks a checkbox, reviews the data and does not make any changes, and then checks another checkbox and decides to update the data by clicking the 'save changes' button. What happens is that the "Update successful" message is displayed twice.

I think this is because every time the user checks a checkbox an instance of UpdatePanel is created. If a I select five different people using the checkboxes and then hit 'save changes' I get five "Update successful" messages.

I am not sure how to overcome this. It feels like each time a checkbox is clicked I need to check if an instance of UpdatePanel exists and then destroy it. I tried using UpdatePanel = Nothing and also investigated IDisposable and GC.Collect() but with no luck.

[code]....

View 1 Replies

Asp.net - Refactor To Design Pattern: Displaying/hiding Different Combinations Of Controls Based On State?

May 26, 2009

Assume you have controls A, B, C, D and E all with a Visibility property. You also have states 1,2,3,4,5 and 6 in which various combinations of your controls would be displayed. Currently this is being handled by switch statements for each state: i.e.

Select Case PageState
case "1"
a.visible = false
b.visible = true

[code]....

As you can imagine, this becomes a pain as every state needs a show/hide statement for each control. How can I refactor this so that adding controls and/or states becomes trivial?My first instinct is to extend the control and add a collection of states that it should display for but this sounds like overkill.

Edit:I was deliberately vague in my question in case this has other implications. In my current instance the "controls" in question are ASP Panels. Does that change anything?

View 4 Replies

C# - Get A Code Template/design Pattern Can Use When Reacting To Mouse Clicks Or Button Presses?

May 3, 2011

One of the problems that I constantly see with Winforms applications is that the GUI thread is stuck while a long-running task is running or just plain stops refreshing (yes, I know - needs threading). Is there a code template/design pattern I can use when reacting to mouse clicks or button presses? Should there be a processing thread always running in the GUI app? Basically, how do I write a great Winforms Application that is easy to maintain and doesn't have any quirky refresh bugs?

View 4 Replies

Visual Studio Logging In/ Logging Out?

Feb 17, 2012

Using visual studio (Winforms) with sql server (R2). If you can login by inserting the correct values in the textfields (vb.net) that is connected in the database . How do i code the log out?

View 2 Replies

Asp.net - Trailing Zero On Decimal

Nov 16, 2010

I have a string which looks like this 512.3 is there a way to add a trailing zero so it looks like this 512.30 Just to clarify (sorry I didn't know there where different ways etc.) My string is an amount which is passed so changes all the time I only need the trailing zero on amounts like 512.3, 512.4,512.5 etc. as some of my amounts will pass values like 512.33 and 512.44 and so on

View 4 Replies

Remove Only TRAILING Whitespace?

Nov 7, 2011

I'm having difficulty with some strings of varying 'meaningful' length from a different database (not under my control) that I am trying to trim in my vb.net code.

I only want to remove TRAILING whitespace... therefore, I can't really use .trim method.

The reasoning behind this being that the field sent from the french database usefully uses a <space> to represent a 0 (as you do).

The string is always the same length but the meaningful length can vary, an example being 95WO<space>5CA<space><space><space>...etc

Or it could be this...

<space><space>WO<space><space><space>... etc

Or this...

<space>5WO95CA<space><space><space>...etc

I've got my methods in place to split the string into pairs and perform various lookups but until I can remove the trailing whitespace I'm a bit stuck

View 2 Replies

Trailing Ampersand In .NET Hexadecimal?

Jul 22, 2011

What's the trailing ampersand on VB hexadecimal numbers for? I've read it forces conversion to an Int32 on the chance VB wants to try and store as an Int16. That makes sense to me. But the part I didn't get from the blurb was to always use the trailing ampersand for bitmasks, flags, enums, etc. Apparantly, it has something to do with overriding VB's fetish for using signed numbers for things internally, which can lead to weird results in comparisons.

So to get easy points, what are the rules for VB.Net hexadecimal numbers, with and without the trailing ampersand? Please include the specific usage in the case of bitmasks/flags and such, and how one would also use it to force signed vs. unsigned.

View 2 Replies

C# - Remove A Trailing Part Of String In .NET?

Jun 12, 2012

For removing trailing part is I use the code

str.substring(0,str.length -2)

Is there a better way? I especially dislike using str.length.

Edit I wanted the question to be as short and simple as possible and I supposed that I just overlooked some String method. I try to be more precise.

I need to remove given number of characters from the end of a string. I don't want to care what the characters are and I don't want to introduce a risk of removing more characters.

If the number is larger then string length let's there is an exception (the string should be validated earlier).

I don't have the problem especially with length, but with referencing a variable twice (imagine a function instead of a variable). I also don't like necessity of subtraction but it is only a personal preference.

The question is taged vb.net so there is vb.net code (should be in a module):

<System.Runtime.CompilerServices.Extension> _
Public Shared Function RemoveFromEnd(stringValue As String, removedCharacters As Integer) As String
Return stringValue.Substring(0, stringValue.Length - removedCharacters)
End Function

View 5 Replies

C# - Performing An Audit Using Reflection?

Nov 11, 2010

I would like to perform an audit as part of a unit test that uses reflection to verify some assumptions, the basic-psuedo code for this would be as follows:

[Code]...

View 2 Replies

Creating An Audit Trail

May 4, 2009

I was hoping that the various controls for WinForms in VB.Net 2008 would have a property such as OldValue and NewValue that I could pull from the Change property.

I'm wanting to write a generic code that will save the OldValue, NewValue, name of field and name of table, and date of change directly to a simple Audit table.

Items aren't changed often, but we need to be able to trace the history of changes to certain fields. I've got the code written for saving to the table, but I'm not finding anything that will show me the two values I need.

I get the NewValue from the changed property but how can I locate the OldValue for date/time pickers, text boxes, check boxes are the main items on the forms.

View 11 Replies

PC Audit Software Examples?

Nov 16, 2009

Are there any examples of PC Audit software or tutorials/code? While I found 80% of my questions on this forum, like how to retrieve ram info, how to retrieve hard drive space, etc..

View 1 Replies

Add Trailing Text After Checkbox For A Datagridview CheckBoxColumn?

Oct 2, 2011

Is is it possible to add trailing text after the checkbox for a Datagridview CheckBoxColumn?

The situation is like this. Say the DataGridView shows name of employees from datatable. The user can select employees from the displayed list in the DGV. For the selection, I inserted a checkboxcolumn into the datagrid. Everything OK.

But just want to know whether it is possible to merge the two column into 1, so that the check box precedes the name of the employee in the same cell rather than in a different column.

View 2 Replies

Audit Option In Loging Form

Apr 30, 2011

[Code]...

above the sql statment, I want to use in my login form. When a user loging in software then it will set up all above option in sql end but how to set in code

View 1 Replies

Audit Trail Of Record Changes In A Form?

Aug 17, 2009

How To Create Audit Trail Of Record Changes In A Form In Vb Net?I get the NewValue from the changed property but how can I locate the OldValue for date/time pickers, text boxes, check boxes are the main items on the forms.

View 1 Replies

Audit Trails And Password Manager?

Aug 1, 2009

im beginner in using vb.net. creat an audit trail and password manager using vb.net and sql or ms access.

View 2 Replies

Writing Text Lines To A File / Removing Trailing Zero's

Mar 24, 2010

I am using the following code to write lines to a file. I seem to get Zero's after my text.Any suggestions to get the trailing zeros out of my text file? [code]

View 2 Replies

Create An Audit Of A Folder Structure, And Tell Is/what Has Changed?

Aug 16, 2010

I've got an application that takes the files in a folder structure and publishes them to another location. Currently it goes through every folder/file and compares the dates in the source and destination. If the file doesn't exist in the destination, or is older, then it copies it across from the source. It's obviously foil proof, but not as fast as it could be.

Ideally, I'd like to create an audit (or audits) saying what the current state of play is in the destination and compare the source folders/files against that instead.

This of course assumes the destination isn't messed around with manually, but I think that's a fair limitation.

So has anyone got any suggestions for how this audit could work? ie: How I could store data/values, such that on the next run when I look down the source folder/files I could compare it to the audit and see 99% of the files are unchanged, so only send across the X new ones etc?

ps: I don't suppose there's a valid (in Windows) that can tell you the date any file in a folder was created/amended? ie: So rather than checking down 200 files to see their individual dates/times, if I could get a single folder level value saying the date of last update/create, if it hasn't changed since the last run, there's no work to do! There is GetLastWriteTime but this doesn't seem to get updated if you amend/update a file, rather than creating a new one!

View 6 Replies

Determine When App Has Had Any Activity?

Nov 11, 2011

Does anyone know of a way to detect recent activity in a VB.net windows forms application?

We have a retail store where users share floor computers, the application will be on each machine and require a log in before use. I am trying to find a way to automatically close the application if it has been idle for lets say 10 minutes.

I guess I could do something similar with the current windows log on session - set a gp that logs the user out after 10 minutes of inactivity - but if there is an easy, non memory intensive way to do it in vb.net i would rather use that method

View 4 Replies

Css - Design A Webpage In Asp.net Design View Which Support Multi Resolution?

Nov 26, 2010

I have created my webpage in asp.net in 1024*768 resolution, my problem was that when i change my monitor resolution then the controls in my webpage will be displayed in unmanaged manner .

How to arrange items in my webpage which support multiple resolution ...

Whatever the resolution of my monitor the controls in my webpage will display as it is as managed in 1024*768 reolution !

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved