|
AFAIK UPS does not publish this information. They want you to use their services.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
|
I am using this code to send email through Gmailand everything was fine until recently.. I am now getting this error:
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required.
What's the problem?!!
This is is code I was using for long time already:
NetworkCredential loginInfo = new NetworkCredential(gMailAccount, password);
MailMessage msg = new MailMessage();
msg.Sender = new MailAddress(from, displayname);
msg.ReplyTo = new MailAddress(from, displayname);
msg.From = new MailAddress(from, displayname);
msg.To.Add(new MailAddress(to, "Jassim Rahma"));
msg.Subject = subject;
message = message.Replace(@"\r\n", Environment.NewLine);
msg.Body = message;
msg.Priority = MailPriority.High;
msg.IsBodyHtml = true;
Attachment mail_attachment = new Attachment(Application.StartupPath + "\\rbuilder.log");
if (technical_data == true)
{
msg.Attachments.Add(mail_attachment);
}
SmtpClient client = new SmtpClient("smtp.gmail.com");
client.Port = 587;
client.EnableSsl = true;
client.UseDefaultCredentials = false;
client.Credentials = loginInfo;
client.Send(msg);
MessageBox.Show("Thank you." +Environment.NewLine + Environment.NewLine + "Your email was receieved.", "Feedback", MessageBoxButtons.OK, MessageBoxIcon.Information);
return true;
|
|
|
|
|
I found this information[^] on the GMail site.
txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
but how can I apply that in my code?
|
|
|
|
|
Consider the following: this was a change implemented by Google. On that basis who do you think would be the best people to ask?
[edit]Check the methods and properties of your SmtpClient[^]object.[/edit]
txtspeak is the realm of 9 year old children, not developers. Christian Graus
modified on Monday, March 29, 2010 5:47 PM
|
|
|
|
|
Hi,
I want to do the following:
1) when a node is checked, all the child nodes must be checked
2) when a node is unchecked, uncheck all the child nodes and see if there is at least one other node which is checked.
Because the method AfterCheck is launched after every change of the checked state, this method will also be launched when a childnode is checked/unchecked.
So when a node is unchecked, the recursive method to see if there is at least one node in the treeview still checked, will be launched for every child node.
Is there a way to only launch this method once instead of once a node?
code:
private void treeViewRekeningen_AfterCheck(object sender, TreeViewEventArgs e)
{
Boolean ret = false;
TreeNode node = e.Node;
if (node.Nodes != null)
{
foreach (TreeNode subnode in node.Nodes)
{
subnode.Checked = node.Checked;
}
}
if (e.Node.Checked == true)
{
ret = true;
}
else
{
doorloopTreeview(node, ref ret);
}
if (ret == false)
{
Console.WriteLine("No node is checked")
}
else
{
Console.WriteLine("At least one node is checked")
}
}
private void doorloopTreeview(TreeNode parent, ref Boolean gevonden)
{
if (gevonden == false)
{
foreach (TreeNode node in parent.Nodes)
{
doorloopTreeview(node, ref gevonden);
}
if (parent.Checked == true)
gevonden = true;
}
}
|
|
|
|
|
I just did the same thing last night.
Define a class level int var that you increment or derement in the AfterCheck method. That
way you can always tell any time if any nodes are checked.
Everything makes sense in someone's mind
|
|
|
|
|
Wannes Geysen wrote: Is there a way to only launch this method once instead of once a node?
private void treeViewRekeningen_AfterCheck(object sender, TreeViewEventArgs e)
{
if (e.Action != TreeViewAction.Unknown)
{
}
}
By checking the e.Action, you can know if the user caused the checked state to change or not.
Tarakeshwar Reddy
There are two kinds of people, those who do the work and those who take the credit. Try to be in the first group; there is less competition there. - Indira Gandhi
|
|
|
|
|
|
Hi
I am getting the list of groups for a particular user using ActiveDirectory.
I am using the following code.
void GetUserDetailsFromAD()
{
string _userName = Environment.UserName;
string _userDomain = Environment.UserDomainName;
using (DirectoryEntry de = new DirectoryEntry(string.Format("LDAP://URL /OU=XYZ,DC={0},DC=XYZ,DC=XYZ,DC=com",_userDomain)))
{
TextWriter tw = new StreamWriter("C:\\LDAP.txt");
de.AuthenticationType = AuthenticationTypes.Secure |AuthenticationTypes.ReadonlyServer;
using (DirectorySearcher search = new DirectorySearcher(de))
{
search.Filter = "(sAMAccountName=" + _userName + ")";
search.PropertiesToLoad.Add("displayName");
search.PropertiesToLoad.Add("memberof");
SearchResult result = search.FindOne();
if (result != null)
{
_displayName = result.Properties["displayname"][0].ToString();
foreach (object item in result.Properties["memberof"])
{
tw.WriteLine(item.ToString());
if (item.ToString().StartsWith("CN=ABC,DC=DEF"))
{
}
else
{
}
}
}
}
tw.Close();
}
}
When i run these program from my local machine(let's say machine A) ,the list of groups which _userName belongs to is populated in C:\\LDAP.txt file.However if i run this from another machine (machine B) in same network,only some groups are displayed ,not all.Eg:If machine A lists group 1,2,3,4 ,machine B lists only 1,2.
1)How can i know whether there are any restrictions in place on other system?(due to which all groups are not displayed)
2)How to check whether there any changes in network settings in the second machine with respect to Active Directory?
Please suggest.
"Every morning I go through Forbes list of 40 richest people in the world. If my name is not in there, I go to work..!!!"
|
|
|
|
|
This[^] might provide some assistance.
Me, I'm dishonest. And a dishonest man you can always trust to be dishonest. Honestly. It's the honest ones you want to watch out for...
|
|
|
|
|
|
I would like that my Server (Windows 2003) automaticly shutdown at 20.00 and for it I think that the Best solution is to create a Net C# Windows Service, but could anybody tell me the C# command for getting the system down, I know that inside the Operating System the order is ShutDown but how to access the Operative System from inside the C# code, not existing shell orders as in older languages.
Best Regards
|
|
|
|
|
There are several alternatives on this SO thread[^].
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
This may be a dumb question from me but why can't you just use the Task Scheduler to schedule a shutdown at the required time?
|
|
|
|
|
Why would you need to write any code at all since you can just put a SHUTDOWN command line in a Scheduled Task job?
Open a CMD prompt and type shutdown /? for the command line options.
|
|
|
|
|
I would like to know what happens if objects are removed from a list while operations are performed on this list?
Let's say we have this class:
class MyListObject
{
int MyInt {get;set;}
string MyString {get;set;}
}
And we have a list of "MyListObject" called "MyList". We also have an eventhandler that can trigger randomly. In that eventhandler a random item in "MyList" is removed from "MyList".
Now, what happens if I do something like:
MyList.Find(delegate (MyListObject mlo) {return mlo.MyString == "hello";});
And at the same time we perform this operation on the list the event is triggered and the eventhandler removes some item from the list. Will that throw some kind of exception? I don't know how to test it so that's why I'm asking you guys.
If this can cause problems, how can I get around this?
Thanks for help!
|
|
|
|
|
You get a System.InvalidOperationException exception with the message "Collection was modified; enumeration operation may not execute.".
To fix:
lock (MyList)
{
MyList.Find(delegate (MyListObject mlo) {return mlo.MyString == "hello";});
}
This locks the object so that only the code block can modify / access it. If you put more than one lock around the object in different places, you need to think about race and deadlock conditions, but for your example it should be fine.
Dalek Dave: There are many words that some find offensive, Homosexuality, Alcoholism, Religion, Visual Basic, Manchester United, Butter.
Pete o'Hanlon: If it wasn't insulting tools, I'd say you were dumber than a bag of spanners.
|
|
|
|
|
|
For much too long I have not used Transaction s in my DB apps - let's not go into how stupid that is.
So I'm working on an existing app and trying to wrap Transaction s around sequences of SqlCommand s that I need to keep atomic. The approach I've followed thus far is something like:
SqlTransaction mySqlTransaction = mySqlConnection.BeginTransaction()
try
{
using (SqlCommand sqlCommand = new SqlCommand("...", mySqlConnection, mySqlTransaction))
{
mySqlCommand.ExecuteScalar();
}
using (SqlCommand sqlCommand = new SqlCommand("...", mySqlConnection, mySqlTransaction))
{
mySqlCommand.ExecuteScalar();
}
mySqlTransaction.Commit();
}
catch
{
mySqlTransaction.Rollback();
}
Then, as I reached the halfway mark (as always happens), it occurred to me that, surely, you can wrap the SqlTransaction in a using block as well. I can't seem to find thorough documentation on how to do that though. Could someone help out perhaps?
If you put your SqlTransaction in a using block, when is it committed? What happens if an exception occurs? Will it automatically roll back?
|
|
|
|
|
Dewald wrote: If you put your SqlTransaction in a using block, when is it committed?
On the "mySqlTransaction.Commit()" statement.
Dewald wrote: What happens if an exception occurs?
The catch-block is executed, doing a rollback. This might cause an InvalidOperationException if the connection is already closed or rolled back. (Source: MSDN[^])
Dewald wrote: Will it automatically roll back?
Yup, because you called "Rollback". Shouldn't be a problem if that fails, because there's no commit called - and thus the data shouldn't be saved even if you fail to rollback the transaction.
I are Troll
|
|
|
|
|
The following snippet should help:
using (SqlConnection cn = new SqlConnection())
using (SqlTransaction tr = cn.BeginTransaction())
{
tr.Commit();
}
Note that if the transaction is not committed, calling dispose on the SqlTransaction object rolls-back automatically.
Dalek Dave: There are many words that some find offensive, Homosexuality, Alcoholism, Religion, Visual Basic, Manchester United, Butter.
Pete o'Hanlon: If it wasn't insulting tools, I'd say you were dumber than a bag of spanners.
|
|
|
|
|
You should be using it through using block like following
using (SqlTransaction mySqlTransaction = mySqlConnection.BeginTransaction())
{
using (SqlCommand sqlCommand = new SqlCommand("...", mySqlConnection, mySqlTransaction))
{
mySqlCommand.ExecuteScalar();
}
using (SqlCommand sqlCommand = new SqlCommand("...", mySqlConnection, mySqlTransaction))
{
mySqlCommand.ExecuteScalar();
}
mySqlTransaction.Commit();
}
Using block implements try-catch-finally internally, so your transaction will be rolled backed automatically in case any exception occurs.
WWW, WCF, WWF, WPF, WFC .... WTF
|
|
|
|
|
Thanks for that. But now, does this mean I lose the usage of the transaction once I commit it? I mean, after the mySqlTransaction.Commit() statement but still inside the using block, can I start the transaction again or do I have to close the using block and open a new using block to start a new transaction?
Here is an analogy as implemented according to my original approach:
SqlTransaction mySqlTransaction = new;
try
{
mySqlTransaction = mySqlConnection.BeginTransaction();
using (SqlCommand sqlCommand = new SqlCommand("...", mySqlConnection, mySqlTransaction))
{
mySqlCommand.ExecuteScalar();
}
using (SqlCommand sqlCommand = new SqlCommand("...", mySqlConnection, mySqlTransaction))
{
mySqlCommand.ExecuteScalar();
}
mySqlTransaction.Commit();
mySqlTransaction = mySqlConnection.BeginTransaction();
using (SqlCommand sqlCommand = new SqlCommand("...", mySqlConnection, mySqlTransaction))
{
mySqlCommand.ExecuteScalar();
}
using (SqlCommand sqlCommand = new SqlCommand("...", mySqlConnection, mySqlTransaction))
{
mySqlCommand.ExecuteScalar();
}
}
catch
{
mySqlTransaction.Rollback();
}
It's probably no big deal and if need be I can start a new using block for the second set of atomic SQL commands but in the application that I'm working on it will introduce some scope problems with local variables which I'd have to work around - and I'm a rather lazy programmer
|
|
|
|
|
Dewald wrote: can I start the transaction again or do I have to close the using block and open a new using block to start a new transaction?
In that case you need to open a new using block for sure.
WWW, WCF, WWF, WPF, WFC .... WTF
|
|
|
|
|