|
Hmmm, not very friendly then.
No worries, I'm always optimistic and don't mind a 'challenge' when I come across one.
I'll give you a more extended LaTeX formula example:
\left ( Availability~ \right ) \times \left ( Performance~ \right ) \times \left ( Quality~ \right ) \times 100 ~ =~ \left (\frac{ I}{II} \right ) \times \left (\frac{ III}{ \left ( IV \times I \right ) } \right ) \times \left (\frac{ V}{III} \right ) \times 100
This is an example from how it's actually being used at this very moment.
I'm not sure what more information you need to clarify the "why"?
"Nope" isn't a very articulate way of asking me for the information you require to clarify this to you.
So please let me know what it is you require of me other than what I've told you in order to clarify the "why" more accurately.
Just to recap, I need to objectify a LaTeX formula.
All I need, is a regex that is able to work with nested and multi-dimensional formulas as explained in the previous posts.
The reason I'm exploring this, is because I've been commented upon that I didn't use tokenization by regex to get the formula elements.
If there's anybody who knows how to tokenize a string that is a formula with nested and/or multi-dimensional elements, please let me know, otherwise I'll set this aside as:"Not a viable option, can't be done within a reasonable amount of time."
modified on Wednesday, November 4, 2009 12:25 PM
|
|
|
|
|
I'm not going to try and work it out myself, but you may find this handy: Expresso[^] - examines and generates Regular expressions.
Best bit is it break it down and explains it in English!
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Thank you for your advise.
The application is a good one and I would certainly advise it to anyone who's going to work with regular expressions.
Limited, controlled recursions of a finite count, can be tackled with regular expressions, though it makes the regular expressions cumbersome.
Infinite and intuitive recursions with regular expressions can't be done in .NET as of yet.
http://badassery.blogspot.com/2006/03/regex-recursion-without-balancing.html[^]
I'm still investigating this and will post my findings if there's anything interesting to report.
|
|
|
|
|
I am wanting to create a crystal report. In doing so I want to point the report to a xsd data object. If there is a better way please let me know.
The issue here is their may be 50 to 200 columns on the fly in this report and it may increase over time. I don't want to keep having to modify the application and recompiling to generate the report.
So I thought that I would find a way to dynamically create the xsd data object. But I don't know how to do this. Any Suggestions?
|
|
|
|
|
I'm trying to implement the idea of a default interface. Maybe this isn't possible, and if there's another manner in which I can implement this please let me know.
The reason for this is that I have an ErrorLog class that I'd like others to use while allowing them to customize the actual writing of the data (if they choose). I have written a default WriteLog method that will write some basic information to a general database table but it obviously won't apply in all cases, therefore I would like to provide the option to override this.
My code is similar to the following. I've left out some syntax and details, but it should be close enough to understand. Please ask for any clarification.
Both of these classes are in the same project:
ErrorLog.cs:
namespace Library {
public interface IErrorLog {
void WriteLog(ErrorLog el)
}
public class ErrorLog
{
public void Log() {
WriteLog(this);
}
}
}
WriteLog.cs:
namespace Library {
public class Write : IErrorLog {
public void WriteLog(ErrorLog el) {
}
}
}
I'd like other applications/projects to implement the IErrorLog interface which would require them to create a WriteLog() method. If they'd like to use the default they can simply refer to the Write.WriteLog() method.
Something is off with my organization or implementation, though. It seems I can't include the WriteLog() "default" in the same project because when I add a reference to Library.ErrorLog in the other application it doesn't require me to implement WriteLog(). I suppose that's because it's already been defined in the project. Do I need to split these into two projects? If so, how do I reference the "default" method?
Thanks for any help since I've thoroughly confused myself.
|
|
|
|
|
Maybe I didn't understand your question clearly, but your ErrorLog class should contain a reference to an IErrorLog interface or you can't access any WriteLog() method.
Example:
namespace Library {
public interface IErrorLog {
void WriteLog(ErrorLog el)
}
public class ErrorLog
{
private IErrorLog errorLog;
public ErrorLog(IErrorLog errorLog) {
if (errorLog == null)
this.errorLog = new Write();
else
this.errorLog = errorLog;
}
public void Log() {
errorLog.WriteLog(this);
}
}
}
In the example you can pass an IErrorLog to the constructor if you wish to use a custom IErrorLog , or null if you want to use the "default" Write class.
I don't think that there is a "default" interface that you can force to implement in an assembly.
|
|
|
|
|
Thank you. I've been able to get this working by then calling the aggregated interface so it looks like all is good. I am assuming that you meant to assign Log() to the interface, though?
Thanks for your time!
|
|
|
|
|
|
That's very confusing. What is ErrorLog supposed to be? An error to be logged or something that should log an error? It appears in your code that it is both, and that is likely to be a rather poor design.
In an application, an error occurs and you want to log it. You need a class to represent that error and you need a class to handle logging the error.
In most cases, your error class should derive from System.Exception . Your error logging class should then handle such errors.
namespace Library
{
interface IErrorLog
{
void WriteLog ( System.Exception Error ) ;
}
public class ErrorLog : IErrorLog
{
// Constructor
void WriteLog
(
System.Exception Error
)
{
// Perhaps write to the Console
}
}
}
Other ErrorLogs can then be derived to log to other destinations.
You can then instantiate an ErrorLog and call el.WriteLog ( someexception ) ;
But I'm wondering whether or not you are trying to write someexception.Log ( el ) ;
If so, you could write an Extension Method to accomplish that:
public static void
Log
(
this System.Exception Error
,
IErrorLog ErrorLog
)
{
ErrorLog.WriteLog ( Error ) ;
}
(None of this code has been tested.)
|
|
|
|
|
If you want to spend your time on more "productive" things, then you should look at the MS Enterprise Library (free) which already includes tried and proven application blocks (ie. classes) for Logging, Error Handling, and other "common" infrastructure code blocks. Get the Hands - On Labs for a quick and painless way to using these blocks.
|
|
|
|
|
I am getting problem when i launch a UI Application from windows Service Application.
My requirement is while starting up of the service i need to run a UI Application.for Example i have taken notepad.exe.
The below code is the code i have implemented to run the process.
Process p = new Process();
p.StartInfo.FileName = @"C:\WINDOWS\system32\notepad.exe";
bool bretval = p.Start();
Problem here is: It is running the process(notepad.exe) in background.
I am not able to see it.
I have gone through several Articles and i felt that WINDOWS service
will supress the UI. Is there any Work around or any other Option so that
my requirement can be obtained.
Pls help me in this regard.
|
|
|
|
|
You can try to activate "interact with desktop" for your service.
However on Vista or later this flag become obsolete.
Generally a service should not have to do anything with UI, because they also can run if nobody is logged in.
Greetings
Covean
|
|
|
|
|
I Thank you for your awesome reply. It helped me and it worked out.
As u told that this option cannot be implemented in Vista.
I will tell you my requirement which is, I have a USB Device, when ever it is plugged in i need to Open my Application(.exe). It is just like iTunes Application for iPod. I have code for Detecting my USB Device. So i thought of implementing the device detecting code in windows service and if the device is found i can launch my application.
Can you tell me any work around or any other way to Implement this senario so that it will work even in Vista.
Regards,
Prasad.
|
|
|
|
|
I would try the following way.
In your service handler function wait for the SERVICE_CONTROL_SESSIONCHANGE event.
(You have to say the system that your service wants this notification (SetServiceStatus with SERVICE_ACCEPT_SESSIONCHANGE)).
After you received the SERVICE_CONTROL_SESSIONCHANGE (WTS_SESSION_LOGON) event, get the users new session id from the WTSSESSION_NOTIFICATION structure and "save" it.
If you want to start the new process you have to do the following steps.
Use WTSQueryUserToken to get the primary access token. Now try to acquire TOKEN_QUERY, TOKEN_DUPLICATE, and TOKEN_ASSIGN_PRIMARY for this token by using SetTokenInformation.
Last Step: CreateProcessAsUser to start your process.
I'm short in time so I couldn't test it but I think this should do the work.
Greetings
Covean
|
|
|
|
|
Thank you Covean,
Sorry,I could not completely Implement the suggestion given by you.
Here is what i implemented.
PROCESS_INFORMATION pi;
STARTUPINFO si =new STARTUPINFO();
System.IntPtr hToken;
string commandLine, userPart, domainPart, password, lpCurrentDirectory;
// Initialize structs
si.cb = Marshal.SizeOf(si);
userPart = "Prasad";
password = "pass";
domainPart = "";
commandLine = "";
lpCurrentDirectory = @"D:\DemoApplication\bin\Debug";
// Get the user token
if (NativeWin32Methods.LogonUser(userPart, domainPart, password, (int)LOGON_TYPE.LOGON32_LOGON_BATCH, (int)LOGON_PROVIDER.LOGON32_PROVIDER_DEFAULT, out hToken))
{
// Create structs
SECURITY_ATTRIBUTES saProcessAttributes = new SECURITY_ATTRIBUTES();
SECURITY_ATTRIBUTES saThreadAttributes = new SECURITY_ATTRIBUTES();
// Now create the process as the user
if (!NativeWin32Methods.CreateProcessAsUser(hToken, appPath, commandLine,
ref saProcessAttributes, ref saThreadAttributes, false, 0, IntPtr.Zero, lpCurrentDirectory, ref si, out pi))
{
// Throw exception
throw new Exception("Failed to CreateProcessAsUser");
}
}
If you can tell me the modified one i would be very much thank ful to you.
Prasad.
|
|
|
|
|
In your example code I miss the SetTokenInformation part.
Thats all I can say at the first look.
I also received your e-Mail and I will answer if I have the time for (I hope this will be tommorrow ).
Greetings
Covean
|
|
|
|
|
Hi everyone
(I hope this is the appropriate place to ask this)
Performance Counter Instances, is there some way to persist them? Can I set it up in some way so that (if need be) a certain service/process can keep them alive even if all the other services are stopped/dead? Currently, as soon as the counters doesn't perform read/write operations to those Counter Instances within a certain time or if the Process/Service that used them closes, then they no longer exist.
The reason why I need instances is that we need to associated multiple "Entities" to the same kind of Counters, i.e. to know if "Entity A" made a number of Authorizations Per Second, and how much "Entity B" did, etc. which all fall under a Counter "C" (for argument sake).
Now using Instances seems like the way to go but because of the problems mentioned above, it doesn't seem viable.
So the only way we currently can solve this is to recreate the Category and create new Counters which implies a desired "Entity" (which will be expensive and more complicated in the end).
Unfortunately I no longer have the time to explore this further and I have spent a whole lot of time on Performance Counter research. Is there someone who could be able to assist?
Thanks
- Last Attacker
|
|
|
|
|
Hi All,
first i would like to say that i'm new to c# so patience will be appreciated
i have a window application that display 3 graphs and a thread that do some other stuff.
the main looks like that:
static class Program
{
static void Main(){
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault( false );
Thread t = new Thread(new ThreadStart(new
SpecialEventQueueHendlerThread().threadRun));
t.Start();
Application.Run( new Form1() );
t.Abort();
}
}
i noticed that if i put a breakpoint in the thread code the graphs also stop to be updated although it runs in a different thread (the main thread).
my question is:
with no breakpoints, does the graph will not be updated while the thread code is executed?
and if this is the case then what is the meaning of thread-safe if they are not run in paralel mode anyway?
Thanks,
Tomer.
|
|
|
|
|
Hi,
1.
most if not all debuggers, when they stop one thread (e.g. due to a breakpoint) also stop all the other threads in that process; otherwise you would be looking at a moving target, with other threads continuously changing some of the data, making it almost impossible to understand what is going on.
2.
if your "other thread" is not related to anything in the GUI, all is fine. Both will be able to run concurrently, which means Windows will switch from one to the other at any time (and actually can execute both in parallel on a multi-core CPU).
if your other thread wants to touch GUI Controls, you need to use Invoke, see here[^].
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
Hi Luc,
Thanks for your reply, it made some sense in my messed up mind.
the main thread and the other thread only share a Queue<datetime> one is a producer and the other is a consumer.
but i was worried that while the latter is running the main will stop like he did in the breakpoint. (using eclipse to debug a web application over tomcat using Java did not result the same when stopping one thread.)
thanks for the help,
Tomer.
|
|
|
|
|
you're welcome.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
Dear Mr. Tomer,
Like Mr. Luc said, the threads will act as expected when running. If you would like the other threads to keep going while you are debugging (stopping and going) on another thread, I think you can change this in
Tools > Options > Debugging > `Break all processes when one process breaks' You should check that list of options anyway to check out some cool options. Good luck!
In Christ,
Aaron Laws
http://ProCure.com
|
|
|
|
|
Hi,
I have an application in C#.Net.
This application uses a DSO ActiveX Framer control to load the MS Office applications.
I am loading an excel document here.The loading of the excel comes with default 3 sheets.
I enter some data in Sheet1.
And now i got to the Sheet2 and right click on the tab and click 'Insert' and insert a chart.
Now after selecting the option 'Select Data' from sheet2, i click on Sheet1 to select the Chart data range for the box 'Select Data Source'.
Now when i click on the Sheet1, my application hangs and in order to proceed i have to kill my application from the Task manager.
This does not happen with MSOffice 2003 but only with Office 2007.
My application does not directly get any click events of the Excel. There is a timer and we get this timer tick event.
Could any one help me out in this?
|
|
|
|
|
Hi,
Can any one help to develop a method in C#, so that i can use that statement to INSERT - UPDATE - DELETE operations upon Database.
I'd achieved this in JAVA but couldn't C#
|
|
|
|
|
.Net provides namespaces like System.Data.OleDb and System.Data.SqlClient . These have a lot classes that will help doing these operations. Look into them. If you get stuck somewhere while trying, post the query. There are plenty of members here to help.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|