|
You start by creating a gmail account. Only then can you use their server to send mail.
Programming is work, it isn't finger painting. Luc Pattyn
|
|
|
|
|
Hi ,
Thank you very much for the code C# scheduler.(Anthony Roach)
In that particular code I could see the Time interval is set 60secs . Only doubt I have is that is there any chance of overlapping of the calls made through the windows service.
For example: First the service call is made, is there any chance that Second service call starts before the first call ends as the scheduling is done for 60 secs.
Thank you very much in advance.
Sateesh
|
|
|
|
|
You're better off asking this question in the article's[^] forum.
/ravi
|
|
|
|
|
I am trying to do a simple filter between two dates using a DataView. I have read that the format of the date string is important and have had good results using the ToShortDateString() method:
string filter = " (Date >= #" + Convert.ToDateTime(dateTimePicker1.Text).ToShortDateString() + "# And Date <= #" + Convert.ToDateTime(dateTimePicker2.Text).ToShortDateString() + "# ) ";
This gives the string "
filter = " (Date >= #04/05/2012# And Date <= #16/05/2012# ) "
"But, the filter reports a "String was not recognized as a valid DateTime." error if the day value is more than 12. The filtering is OK at day 12 and below.
If I change the date format the filter does not operate correctly.
My system is in en-GB culture.
The source table is a local DataTable.
Has anyone seen this type of problem?
Paul.
|
|
|
|
|
Member 1439977 wrote: Has anyone seen this type of problem?
Often; your data is in a string, formatted for a culture. You should be using a strongly typed DATE . A date is merely a number, and the computer can turn that into various culture-dependant string-representations. Next, you're putting the date into that string; it'd be best to use parameters.
SomeCommand.CommandText = @"
SELECT *
FROM Bla
WHERE SomeDate BETWEEN @StartDate AND @EndDate";
SomeCommand.Parameters.AddWithValue("@StartDate", DateTime.Now);
SomeCommand.Parameters.AddWithValue("@EndDate", DateTime.Now.AddDays(-30));
Bastard Programmer from Hell
|
|
|
|
|
You're misunderstanding: the client-side Filter property on DataView is a string, so you have no choice but to do it the 'wrong' way.
|
|
|
|
|
Ah, my apologies. You'll need this[^] syntax, and the InvariantCulture .
Bastard Programmer from Hell
|
|
|
|
|
Thanks for your reply.
I'll give that a go.
I am creating the DateTime column data from a csv file. I wonder if it is the way the csv date is formatted. it is yyyy/dd/mm.
|
|
|
|
|
two more remarks:
1. Convert.ToDateTime(dateTimePicker1.Text) is ugly and unnecessary, a DateTimePicker has a value property which gives a DateTime, there is no need to parse or convert a string here.
2. .ToShortDateString() obviously is culture dependent and therefore inappropriate in a conversation with a database which is likely to expect a culture independent format, as it possibly has to serve people and applications with diverse cultures. You could use the invariant culture, or use ToString(...) with an explicit format, say ToString("yyyy-MM-dd").
|
|
|
|
|
Thanks all for your help,
Filter working Ok now with filter:
string filter = " (Date >= #" + dateTimePicker1.Value.ToString("yyyy-MM-dd") + "# And Date <= #" + dateTimePicker2.Value.ToString("yyyy-MM-dd") + "# ) ";
A error in the sample csv file I create the date from was also causing a problem.
|
|
|
|
|
Hello.
Using Microsoft Visual Studio 2008, I try to make a graphic tool. like a photoshop.
Most of the problems were solved by using the user control.
But Several problems related to font occurred.
First, Font size!!! Separate width and height size can not be changed.
Second, Kerning!!!
I've tried hard to solve problem.
I know that my question is widely and abstract.
But my work is faced stagnant. And I do not know what to do
Please help me who know information or advice to solve problems.
Wish your help
|
|
|
|
|
Assuming this is WinForms, not WPF, you can apply a matrix transform to the graphics context, which will stretch everything in one direction:
Font font = new Font("Verdana", 12.0F);
private void myPanel_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
g.DrawString("Hello", font, Brushes.Black, 10, 10);
Matrix m = new Matrix();
m.Scale(2, 1);
g.Transform = m;
g.DrawString("Hello", font, Brushes.Black, 10, 30);
g.ResetTransform();
m = new Matrix();
m.Scale(1.5F, 1);
g.Transform = m;
g.DrawString("Hello", font, Brushes.Black, 10, 60);
g.ResetTransform();
}
I suspect that WPF could do this pretty easily (but there is a learning curve associated with WPF).
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
As mentioned before,I want to make graphic tool.
Therefore, many objects will be drawn.
some objects can cover letter's part.
example, "N" looks like "V","W" looks like "N" etc..
many problems can occur.
So I need a another method. but thanks for your comment
|
|
|
|
|
You will have to draw each letter individually. I'm not sure you can add text to a path with the .Net drawing tools, so for some of the cleverer stuff (using text as a clipping path, for example) you'd have to read the font file yourself and draw the curves.
|
|
|
|
|
An interesting article (to go along with BobJanova's comment) can be found here[^]. While it's in VB.NET, someone has provided a C# alternative in the messages.
|
|
|
|
|
Hello,
I was reading through the active directory tutorial "almost everything in active directory" but I'm not able to figure out (from it) how to query active directory for values. I'd like to query all domains based on certain attributes, log in name, last name and email address.
From that key value, I'd then like to return an array of all AD objects associated to that account.
Can anyone help me with this? I can post my code, but it doesn't work at all so it probably wouldn't be of much help. Thanks for reading.
|
|
|
|
|
What do you mean by "all AD objects associated to that account"?
|
|
|
|
|
Hi Dave,
I'd like to enter a unique identifier and get all of the account related objects for that account.
After I receive all, I can then parse through and display the ones I want in my gui. An example would be first name, last name, phone, email, any status codes/custom attributes, etc.
|
|
|
|
|
There's a problem with what you want to do.
turbosupramk3 wrote: a unique identifier
Such as??? Are you looking for everything about a User object, or are you looking for everything related to ANY kind of object in AD??
turbosupramk3 wrote: get all of the account related objects for that account.
Such as what "related objects"?? What kind of objects are you talking about?? Give an example.
turbosupramk3 wrote: An example would be first name, last name, phone, email, any status codes/custom
attributes, etc.
Those are not objects, they are Properties of a User object. Maybe you're confusing terms here?
|
|
|
|
|
I may be using the wrong terminology, if so I am sorry.
I've always called them object attributes, but I noticed in my googling that .net calls them properties which is inline with what you have said.
I would like to return all properties associated with a user object. I'll provide the GUI with a user id, last name or email, which I believe are properties named "samaccountname", "sn" and "mail", and with any of those being the unique identifier, query AD and return all other properties associated to that account into a parsable format.
|
|
|
|
|
using (var rootDirectory = new DirectoryEntry("LDAP://[Server IP or Host name]", "[user name in the directory]", "[User Password]")) {
using (var directorySearch = new DirectorySearcher(rootDirectory)) {
directorySearch.Filter = string.Format("(|(sAMAccountName={0})(name={0}))", "[User Name you want or account you want]");
directorySearch.PropertiesToLoad.Add("[Name of the property you want, exactly as it appears in the AD]");
var result = directorySearch.FindOne();
if (result != null) {
var directoryEntry = result.GetDirectoryEntry();
var propertyIwant = directoryEntry.Properties["Name of the property you want"];
}
}
}
this should get you started, if you want more then the first item associated with your query, use "FindAll" and then iterate on the results
Edit: totally forgot, remember you need to reference System.DirectoryServices to use this code.
|
|
|
|
|
Thank you randprin.
I'm trying to do directorySearch.FindAll(); and I can't seem to get results?
I thought I'd be able to get a count and use a for statement, but when I'm debugging I cannot seem to display any values while paused over directorySearch.FindAll() and hovering over it with the mouse? Do you have any ideas?
Under FindOne(), I'll see 77 properties, but I'm coming up empty with the FindAll() .
modified 24-May-12 15:57pm.
|
|
|
|
|
Here is what I ended up using in case this comes up in a search (you'll have to change the txtbox stuff to fit your gui or console app
using (var rootDirectory = new DirectoryEntry("LDAP://" + domain))
{
using (var directorySearch = new DirectorySearcher(rootDirectory))
{
if (tBoxPin.Text != "")
{
directorySearch.Filter = string.Format("(|(sAMAccountName={0}))", tBoxPin.Text);
}
if (tBoxLastName.Text != "")
{
directorySearch.Filter = string.Format("((sn={0}))", tBoxLastName.Text);
}
if (tBoxEmail.Text != "")
{
directorySearch.Filter = string.Format("((mail={0}))", tBoxEmail.Text);
}
var result = directorySearch.FindOne();
if (tBoxLastName.Text != "")
{
SearchResultCollection searchResults = directorySearch.FindAll();
foreach (SearchResult searchResult in searchResults)
{
foreach (string propertyKey in searchResult.Properties.PropertyNames)
{
ResultPropertyValueCollection valueCollection = searchResult.Properties[propertyKey];
ResultPropertyValueCollection accountCollection = searchResult.Properties["userprincipalname"];
foreach (Object propertyValue in valueCollection)
{
if (propertyKey == "name")
{
lastNames.Add(propertyValue.ToString());
if (tBoxLastName.Text != "")
{
tBoxDomains.Text += (propertyValue.ToString()) + " - ";
foreach (Object account in accountCollection)
{
tBoxDomains.Text += account.ToString() + System.Environment.NewLine;
}
}
}
}
}
}
}
if (lastNames.Count > 1)
{
return;
}
if (result != null)
{
DirectoryEntry myDirectoryEntry = result.GetDirectoryEntry();
ResultPropertyCollection myResultPropColl;
myResultPropColl = result.Properties;
foreach (string myKey in myResultPropColl.PropertyNames)
{
if ((myKey == "samaccountname"))
{
foreach (Object myCollection in myResultPropColl[myKey])
{
tBoxPin.Text = (myCollection.ToString());
}
}
if ((myKey == "name"))
{
foreach (Object myCollection in myResultPropColl[myKey])
{
tBoxLastName.Text = (myCollection.ToString());
}
}
if ((myKey == "mail"))
{
foreach (Object myCollection in myResultPropColl[myKey])
{
tBoxEmail.Text = (myCollection.ToString());
}
}
if ((myKey == "name"))
{
foreach (Object myCollection in myResultPropColl[myKey])
{
tBoxTopSecret.Text = (myCollection.ToString().ToUpper());
}
}
if ((myKey == "homemdb"))
{
foreach (Object myCollection in myResultPropColl[myKey])
{
int delimiter = myCollection.ToString().IndexOf(",");
string trimmed = myCollection.ToString();
trimmed = trimmed.Remove(delimiter);
trimmed = trimmed.Replace("CN=", "");
tBoxExchangeServer.Text = (trimmed);
}
}
if ((myKey == "telephonenumber"))
{
foreach (Object myCollection in myResultPropColl[myKey])
{
tBoxPhone.Text = (myCollection.ToString());
}
}
}
}
}
}
|
|
|
|
|
Hi folks,
I desparatly and urgently need your help... I need a code sample or some guidance on how to write a .Net program (preferably in C#) that used ADWS (Microsoft Active Directory Web Services) to retrieve user's information, search for users that have some active directory field set to some text, etc.
T.I.A,
Yuval.
|
|
|
|
|