|
I find myself wondering how this question could possibly reflect a real-world scenario.
The fact that there are "any number of approval levels" does not justify an assumption that the possible conditions are "infinite:" there is probably a fixed number of maximum approvals possible, or required. And, probably, a certain minimum of approvals required to even process the order.
That the set of all possible permutations of approvals would require a unique action for each permutation: also seems a dubious assumption.
And, isn't there some "hierarchy" involved here: a decision by upper-management to cancel/void/dis-approve takes precedence over other lower-level decision makers, which means you can deduce the action required without consideration of certain other levels ?
In the real world, "hierarchy" also "kicks-in," in financial transactions, dependent upon customer credit, and $ize of order, as well as customer history, or internal (or external credit agency) rating.
My guess is there is a finite, and well-defined, set of actions to be taken based on approvals of purchase order.
So, present an interface with CheckBoxes: logical analysis of which are Checked then can be mapped to a list of appropriate actions. Or, present a TreeView with CheckBoxes, where you handle "hierarchy" by activating, or de-activting, sub-nodes, depending on whether "parent" nodes are checked. Then iterate the TreeView (recursively), and generate a list of actions based on all Checked Nodes.
"The first principle is that you must not fool yourself, and you are the easiest person to fool." Richard Feynman
|
|
|
|
|
The answer to this depends on how flexible the user input and required response is supposed to be. It can go from simply holding a list of allowed values to embedding a scripting engine. To give any useful guidance we'll need to know more about what the user is expecting to be able to enter as conditions and actions.
|
|
|
|
|
SilimSayo wrote: I am just wondering if there is a pattern for programming conditions which are
not known by the programmer at programming time; i.e. the conditions are set by
the user.
That is not specific enough. There are a number of ways of dealing with that of which the specifics matter which way to implement it.
SilimSayo wrote: For example, the user may define a set IF conditions, and corresponding actions
As expressed that requires an interpreter idiom (which is a pattern.)
SilimSayo wrote: but N is unknown at programming time. So I can't use the the typical if-else
block.
That of course has nothing to do with the problem as you expressed it. If you have defined conditions/actions and ALL the user does is pick from that set then the solution is trivial - use a set with an appropriate definition block. This is a very, very simple form of interpreter.
However that doesn't solve it if the conditions/actions themselves are user defined.
|
|
|
|
|
I would consider a collection of Func<bool>, Action pairs. then simply foreach the collection and if the Func<bool> returns true invoke the Action.
building the collection is another matter and would really depend on what conditions you want the user to be able to define
Pedis ex oris
Quidquid latine dictum sit, altum sonatur
|
|
|
|
|
Please help! do I need to synchronize mysql to Access database. preferably via xml. I managed to get mysql database structure:
Table name="data">
<Field name="id" type="int(11)" null="NO" key="PRI" default="" autoincrement="false"/>
<Field name="data" type="varchar(255)" null="NO" key="" default="" autoincrement="false"/>
<Field name="data2" type="varchar(255)" null="NO" key="" default="" autoincrement="false"/>
</Table>
I do not know how to write the database access.When I need to add a column in MySQL to create and access databases, without losing the original data.I also needed to synchronize data that has changed. many thanks for your help
|
|
|
|
|
What do you mean "write the database access?"
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
MS Access does not read XML. You can create a MYSQL connection in ODBC, and you can link MS Access to any ODBC data source i.e. use linked tables. Linked tables don't store data so if you make a change in the data in Access, you would be changing data in MYSQL and vice-versa.
|
|
|
|
|
You could write an API as an application to sit in front of MySQL and then a macro or application to sit in front of the Access database to consume the XML, but it would be... interesting, not to mention the deadlocks you would probably get would be a nightmare to sort out.
|
|
|
|
|
hi
i try to reverse string on access in sql query and C# like this:
SQL = "SELECT StrReverse(Des) from MyTbl";
dsView = new DataSet();
adp = new OleDbDataAdapter(SQL, Main.Conn);
adp.Fill(dsView, "MyTbl");
adp.Dispose();
dataGridView1.DataSource = dsView.Tables["MyTbl"].DefaultView;
and i get this error: Undefined function 'StrReverse' in expression.
but if i run this query on access its works excellent
what can be the problem ?
|
|
|
|
|
StrReverse is a VBA function that is not available outside of Access. You can only use the supported SQL functions from outside of Access.
The list of what Access supports in SQL statements can be found here[^].
Basically, if you can use the function name in VB, you can't use it in SQL.
|
|
|
|
|
In addition to Dave Kreskowiak's answer. OleDb also has "predefined" keywords. Sometimes you'll need to change column names or change the SQL to pass around this.
Just for info.
(PS: I don't think that's the case here btw)
V.
|
|
|
|
|
hey.. can anyone tell me that how can i convert files(doc,pdf etc) to UDF(universal disk formate) using .net libraries.. if not then is there any third party software tht does so.. doc to udf conversion ? i have checked out but found plenty of third party softwares that convert udf to other formats not ..other formats to udf ????plz reply otherwise i will be fired.. lolx
|
|
|
|
|
That makes no sense. It's like asking how to convert a doc file to a zip file. Or like asking how to convert a stack of paper to a suitcase. The paper goes inside, it does not "become" the suitcase.
What do you really want? Put files together in an UDF file? Or convert an ISO to UDF perhaps?
|
|
|
|
|
hmm thanks.. iso to udf.. regards
|
|
|
|
|
Ok, I don't know of any .NET libraries that will help you with that.
|
|
|
|
|
and wht about the third party softwares ?
|
|
|
|
|
Nero can definitely do it, I thought MagicISO too but I'm not very sure about that one.
|
|
|
|
|
hmm ok thanks.. very much..
|
|
|
|
|
Hi everyone,
I'm having trouble with the Application.DoEvents() in my c# application.
The application is for setting up a measurement with an oscilloscope and reading the data.
I have a loop, doing roughly this:
SetupHardware();
while(this.Run == true)
{
Application.DoEvents();
StartMeasurement();
ReadData();
AddDataToGraphControl();
}
I added the "Application.DoEvents()" because the user can change instrument settings with a form, and the controls' events need to be handled for that. Also the "Stop" button sets the global boolean "Run" to false.
Since the Application.DoEvents() doesn't seem to handle ALL pending events (I'm probably doing something wrong here, but that's another story), I started googling about Appication.DoEvents(), and found that I should avoid using it, and use multithreading instead.
I'd like to believe that, but I think in this case the use of Applicaition.DoEvents is the best practice here...
Can someone shine some light on this? Am I correct in thinking this is an exception to the "don't-use-DoEvents()" rule? How could I approach this using multitheading (which I haven't used before)?
modified 7-Feb-12 5:36am.
|
|
|
|
|
DoEvents is rarely the correct approach, and I don't think this is an exception. What you should do is have a thread which handles the instrument I/O (well, I, in this case ) and fires events which the main thread hooks up to:
class InstrumentThread {
Thread t;
public event EventHandler<InstrumentEventArgs> DataReceived;
public Thread Thread { get { return t; } }
public InstrumentThread(){
t = new Thread(Run);
}
private void Run(){
while(running){
StartMeasurement();
ReadData();
DataReceived(new InstrumentDataEventArgs(data));
}
}
}
class InstrumentEventArgs : EventArgs {
SomeType Data { get; private set; }
public InstrumentEventArgs(SomeType data) { Data = data; }
}
class MyForm : Form {
public MyForm(){
it = new InstrumentThread();
it.DataReceived += InstrumentDataReceived;
it.Thread.Start();
}
void InstrumentDataReceived(object sender, InstrumentEventArgs ea){
if(InvokeRequired) {
BeginInvoke(new EventHandler<InstrumentEventArgs>(InstrumentDataReceived), new object[] { sender, ea });
return;
}
AddDataToGraphControl(ea.Data);
}
}
|
|
|
|
|
Thank you for your reply. I'm still struggling with the instrument setup (setting vertical range, timebase, etc).
These settings should (to maintain a decent framerate) only be written to the instrument when the user changes a setting on the form. And on a fixed position: before StartMeasurement() (well, most importan is not between StartMeasurement() and ReadData(); that would cause problems).
I could ofcourse do:
NumericUpDown_VerticalRange_ValueChanges(Object sender, EventArgs e)
{
this.InstrumentSetupChanged = true;
}
and then in the InstrumentThread's Run method use
private void Run(){
while(running){
StartMeasurement();
ReadData();
DataReceived(new InstrumentDataEventArgs(data));
}
}
But I doubt working with this flag is a proper approach?
|
|
|
|
|
I'd have no problem with that, though normally I'd push messages onto a queue or something and then clear it where you put your comment. But if the message is just 'do something' then a flag is fine.
|
|
|
|
|
Application.DoEvents() is evil and should be avoided at all costs. You cannot seriously mention it and "best practice" in one and the same sentence.
A long winding operation needs to be handled in a separate thread; that is the way to keep your GUI operational, and to preserve a normal user experience. Often a BackgroundWorker comes in handy, as its ProgressChanged event fires on the GUI thread.
There is one alternative, and that is based on a timer, i.e. one operation (measurement) gets executed per timer tick. I am wondering about your setup, does it run "as fast as it can"? I see no code that synchronizes to a clock?
Luc Pattyn [My Articles] Nil Volentibus Arduum
Fed up by FireFox memory leaks I switched to Opera and now CP doesn't perform its paste magic, so links will not be offered. Sorry.
|
|
|
|
|
As stated in my reply to BobJanova, i don't use DoEvents() because of a "normal user experience", but because that is the moment I want to handle the instrument-setup events.
My application is an pc-scope application, so indeed it runs "as fast as it can".
|
|
|
|
|
The problem with DoEvents is that you're not just handling your instrument events. You handling ALL events, including your form controls and repaint commands. So if the use clicks a button a second time when they're not supposed to, or changes text, or moves the form, or whatever, those events get handled right along with your instrument events.
DoEvents processes all pending event messages until the message queue is empty. This opens you up to reenterant code possibilities where your code is not written to handle it.
|
|
|
|