|
Please anyone help me!! I am doing an Expression Tree Parser project and I would like to demonstrate a tree with nested nodes that holds the operands and operators, it is easy to implement in design time but I failed to implement it at run time please anyone reply to me and give me some hints.
Note: (they must be nested nodes and not separated nodes)
Koko Wawa
|
|
|
|
|
This is really simpler than it may appear.
Example:
preface
|____ adjective
|____ noun
verb
target noun
|_____adjective
|_____adjectiveCollection
|_____noun
|___connector
|___adjective
|___noun
So here is a possible tree of a sentance.
Programmatically you would do as follows:
Create treenode named preface.
Create treenodes named adjective and noun. add these nodes to the preface.Nodes .
Add preface to control.Nodes .
Create treenode named targetNoun.
Create treenodes for adjective, adjectiveCollection, and noun and add to targetNoun.Nodes .
Create connector, adjective, noun and add these treenodes to noun.Nodes .
Add targetNoun to control.Nodes .
Create verb and add verb to control.Nodes .
You can do this more randomly if you are populating from a database using the Find method. So you get a node that is a parent. You add that node to the control. When you read a child record, you Find the parent node, create the child, and add to the parent.Nodes collection.
This signature left intentionally blank
|
|
|
|
|
I need to set up an automated email system , which means users should
not be able to respond back to the emails but at the same time, we
need to track bounced emails. This is important as our customers are
paying for this service, so we need to track the bounced email Id's.
This is the code which I have tried:-
MailMessage msgRequest = new MailMessage();
msgRequest.BodyFormat = MailFormat.Text;
msgRequest.Subject = "Do Not reply to this email";
msgRequest.To = "Customer1@abc.com";
msgRequest.From = "automated@company.com";
msgRequest.Body = "Message Body";
msgRequest.Headers.Add("Return-Path", "validemailId@company.com");
//msgRequest.Headers.Add("Errors-To", "validemailId@company.com");
SmtpMail.SmtpServer = "SMTPServerName";
SmtpMail.Send(msgRequest);
I have tried both "Return-Path" and "Errors-to". But both of them
falied. The functionality that users cannot reply us back works fine
with this code but this code fails in tracking bounced emails. So for
invalid email id in "To", have no action reported to "return-path" or
"errors-to" valid Email Id.
I have also tried doing this:-
MailMessage msgRequest = new MailMessage();
msgRequest.BodyFormat = MailFormat.Text;
msgRequest.Subject = "Do Not reply to this email";
msgRequest.To = "Customer1@abc.com";
msgRequest.From = "validemailId@company.com";
msgRequest.Body = "Message Body";
msgRequest.Headers.Add("From", "automated@company.com");
SmtpMail.SmtpServer = "SMTPServerName";
SmtpMail.Send(msgRequest);
Using this code, user only sees automated@company.com and never sees
validemailId@company.com so they cannot reply us back. But again this
code fails for tracking bounced emails. It doesnt send me bounced
emails at validemailId@company.com.
Can somebody suggest me what is going wrong here?
Quick response will be really appreciated and Thanks in Advance for
any help.
Simran.
|
|
|
|
|
And what code do you have to track bounced emails? This is a function of the SMTP server. Since SmtpMail.Send uses CDO (provided by Microsoft SMTP Services or Microsoft Exchange), an exception may be thrown but it depends on the queue for the SMTP server.
It's the SMTP server that gets the bounces, not you, nor can you unless you are the SMTP server. You could always consider writing your own, but I don't recommend it. There's a lot more to do than you might realize, but most SMTP servers let you hook functionality (I know that Exchange and sendmail do).
One other option is to write your own SMTP client. Remember, SmtpMail uses CDO (a COM server), but SMTP clients only need a telnet connection to the MX host (mail exchanger), the communication is pretty easy.
I've posted code several times in this forum in the past for both MX-lookups as well as SMTP clients. I recommend you click "Search comments" directly above this message board and search for "SMTP" or something simple.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Thanks for replying, but the problem is that if I write this code without using any headers for return-path, I get bounced emails back immediately in the account which I mention in "From".
MailMessage msg=new Message();
msg.To="Some Invalid Email Id";
msg.From="validComapnyEmailId";
msg.Body="message";
.....
But the thing is I dont want to give valid Email id In "From" because we dont want our users to reply back but we still want to track bounced emails.
I have tried all options and Dont know, where I am doing wrong.
Simrang
|
|
|
|
|
Again, this is entirely a server feature. If you don't want a "valid" email address (i.e., a mailbox to where mail is delivered), the SMTP server has to queue bouces and deal with them appropriately. This is greatly specific to an SMTP server and has absolutely nothing to do with C#.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
In addition to what Heath said, depending on the server that your SMTP server is trying to send the mail to, it may take quite a while to get a bounce message back from the destination server. I've seen bounce messages take over 6 hours to come back telling me there was a problem.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks for replying, but the problem is that if I write this code without using any headers for return-path, I get bounced emails back immediately in the account which I mention in "From".
MailMessage msg=new Message();
msg.To="Some Invalid Email Id";
msg.From="validComapnyEmailId";
msg.Body="message";
.....
But the thing is I dont want to give valid Email id In "From" because we dont want our users to reply back but we still want to track bounced emails.
I have tried all options and Dont know, where I am doing wrong.
|
|
|
|
|
Geez.
you need to deliver that mail directly, if you "absolutely require" that you be notified of any possible bounce.
You know how SMTP works?
You connect to your SMTP-Server and deliver your message there. Your SMTP-Server then delivers the message to another SMTP-Server based on information in the DNS-System or other rules (some servers always deliver to a certain other server).
Finally, the message is auto-magically delivered to the receiving users SMTP-Server, which will then determine if there is any problem - like non-existant user or such.
Then it will either deliver your message to the recipient's inbox or send an error message. This usually happens while the last SMTP-Server in row is still connected to the recipient's SMTP-Server. Upon receiving the error message (still via SMTP), (usually) the last SMTP-Server in the row will send an error notification via eMail.
This means, as eMail means SMTP again, if the account the mail should be delivered to does not exist, the error-message is lost.
Maybe you should check your "Catch-All"-Account.
And "thou shalt not create bulk-mailing tools".
Cheers
Sebastian
|
|
|
|
|
Looking for some answers on MSDN I ran across the following code.
If (null != email)
Is that legal in C#, and even if it does compile, is it logical?
Shouldn't it more likely read:
If (email != null)
Best,
Jerry
Contrary to the cliche, genuinely nice guys most often finish first or very near it.--Malcolm Forbes Toasty0.com
|
|
|
|
|
This is a wierd convention that older C programmers follow. It is perfectly legal.
The reason that it is done, is that in C, it is legal to say if (email = null) , (note the single equal sign) and it will always evaluate to true. So, to prevent possible errors caused by mistypes, C programmers switch the arguments, i.e. if (null = email) . This second version is not legal syntax, and will give a compiler error. The programmer can then fix it by changing it to if (null == email) .
This is not necessary in C# (but neither is it illegal), because the C# compiler will complain at if (email = null) .
my blog
|
|
|
|
|
|
I'd expect it to be true, because the assignment would not fail.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
The condition isn't checking the assignment, it would check the resultant expression. In ths case, that'd be email . The code breaks apart like so:
email = null;
if (email)
{
} In C#, however, the above expression isn't valid like it would be in C/C++ (where NULL is defined as 0). You would get an error in this case, but not because you'd be using an assignment operator instead of an equivalence operator.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Oh, OK. Obviously I had not tried it.
Heath Stewart wrote:
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
Cool. Do you know anything about DX9, specifically the AudioVideoPlayback namespace ? Was it released by mistake ? I've had a lot of fun figuring out it's many flaws.....
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
I've worked with DX9 a little, but I admit I don't know a whole lot about it (mostly from a graphics manipulation regard, not API use).
I recommend reading Managed DirectX 9 Kick Start : Graphics and Game Programming[^]. It's a very good book and you'd probably have a better time with it. Like I said, I understand all the API stuff, but matrices - when it comes to graphics - always seem to elude me. I will say, however, that you're articles have helped clear a few things up.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Heath Stewart wrote:
I recommend reading Managed DirectX 9 Kick Start : Graphics and Game Programming[^].
I have it. I assume the rest of the book is better, the bit on audio video playback is 3 pages which glosses over the API, tells me that Microsoft does not regard it as a full implimentation, and it's not going to be updated. It doesn't cover any of the bugs in the API, I presume the author has never actually used this part of DirectX9, and felt they needed to cover it, so they skimmed the docs.
I'm writing an article on all the ways that the AudioVideoPlayback namespace fails to perform as expected, and a wrapper class that will make it a little bit close to usable. I've built an entire project around DX9, and I'm kind of wishing I hadn't.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Steven Campbell wrote:
The programmer can then fix it by changing it to if (null == email).
Ok, but how can null be "equal to" anything? This has got to be a concept I'm not able to fathom or I am just unfamiliar with it. And, for now, it just seem logical.
Best,
Jerry
Contrary to the cliche, genuinely nice guys most often finish first or very near it.--Malcolm Forbes Toasty0.com
|
|
|
|
|
Any reference object - like email (presumably a string, which is a reference type) - is null if it doesn't reference an object. So, it's "value" is null.
string email = null;
null == email;
email = "you@codeproject.com";
null == email;
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
if 2+2 = 4, then 4 = 2+2. The concept is the same. The two values are checked for equality, that the constant value is on the left makes no difference to the compiler, and in C++ was a good was to avoid a bug that can be a nightmare to find. I know, I still sometimes write code like this, a habit I formed in my C++ days.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Ok, thanks Heath and Christian. I think I understand what's going on with that now.
Best,
while(null==jerry)
{
null++;
return;
}
Contrary to the cliche, genuinely nice guys most often finish first or very near it.--Malcolm Forbes Toasty0.com
|
|
|
|
|
To expand on what Steven said, the two are the same because it's a simple comparison. The IL generated from about would be:
ldnull
ldfld email
beq Equal
Equal:
It doesn't matter if you load null or the field (or variable, whichever) first, you're still comparing the value of two objects.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Thanks for the answers all. Would this also hold true for the is-equal-to '==' also?
Best,
Jerry
Contrary to the cliche, genuinely nice guys most often finish first or very near it.--Malcolm Forbes Toasty0.com
|
|
|
|
|
OMG! I just woke up and realized what a stupid question that was.
That's what I get for watching the grandchildren and coding at the same time...
Best,
Jerry
Contrary to the cliche, genuinely nice guys most often finish first or very near it.--Malcolm Forbes Toasty0.com
|
|
|
|
|
In C++, it's possible to write:
if (x = 0)
when you mean to write
if (x == 0)
Because of that, some developers invert the order of what they write, as:
if (0 = x)
is illegal, while
if (0 == x)
is legal.
This is not a problem in C#, where if (x = 0) is prohibited.
|
|
|
|
|