|
Also, please note that MSDN documentations are linked together, so if an object is used together with any other type or class, MSDN documentation will have a "See also" section at the bottom of the pages, where you can find details about other types. At the bottom of that page, (for DirectorySearcher), there was the section, https://msdn.microsoft.com/en-us/library/system.directoryservices.directorysearcher(v=vs.110).aspx#See Also, that had the information about the more objects that you should consider understanding.
Secondly, one must first understand what he has to do... Like, if you want to go to City 1234, then you should know the route to the destination, the local Bus Stop 12 and Bus Terminal 34 are just the in betweens. If you know where you are headed off to, then you will be easily able to find the correct types. — try search for "c# file system watcher" and, once you're working with that, search for "background thread event management", you will see that MSDN will provide you with the types you need to build a background manager that keeps a track of your file system for any changes in it. But of course, this is just an example.
Finding the correct classes is just like treasure hunt. Only this is somewhat easy, thanks to uncle Google.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
|
|
Hello,
I'm using a datagridview in windowsform application and would like to make changes and adding new records into my Datagridview.
After calling the BD.SavChanges() and using the BD.ChangeTracker.Entries(), only the modified rows are updated into the SQL table and no added rows.
Can you help me for this?
The DataGridView1.DataSource is the gammeBindingSource on the Form.
This is the code form my Form:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.Entity.Infrastructure;
namespace PRODATA
{
public partial class Gammes : Form
{
PRODATAEntities BD;
public Gammes()
{
InitializeComponent();
}
private void Gammes_Load(object sender, EventArgs e)
{
BD = new PRODATAEntities();
BD.Configuration.ProxyCreationEnabled = false;
BD.Configuration.LazyLoadingEnabled = false;
gammeBindingSource.DataSource = BD.Gammes.ToList();
}
private void button1_Click(object sender, EventArgs e)
{
try
{
foreach (DbEntityEntry entry in BD.ChangeTracker.Entries())
{
switch (entry.State)
{
case EntityState.Added:
entry.CurrentValues["Utilisateur"] = ((PRODATAparent)(this.MdiParent)).mUtilisateur;
entry.CurrentValues["Dateheure"] = DateTime.Now;
break;
case EntityState.Modified:
entry.CurrentValues["Utilisateur"] = ((PRODATAparent)(this.MdiParent)).mUtilisateur;
entry.CurrentValues["Dateheure"] = DateTime.Now;
break;
case EntityState.Deleted:
break;
}
}
dataGridView1.EndEdit();
gammeBindingSource.EndEdit();
BD.SaveChanges();
MessageBox.Show("Enregistrement effectué...", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
gammeBindingSource.ResetBindings(false);
}
}
}
}
Best regards.
modified 14-Mar-17 10:27am.
|
|
|
|
|
Hi,
I need to connect to LDAP but want to manage a timeout in case of problems connection to LDAP.
So, I want stop the 'binding' if it's not done (for example) in 10 seconds (and do not want to wait for the 'default' timeout of the server (which goes up to more than 45 seconds)).
Read something about the 'timeout'-property for the LdapConnection-class but it seems not to be working.
I've set the timeout-property to 10 seconds but the bind doesn't timeout after 10 seconds.
Can anyone please help me?
Thank you!
Here the code:
try
{
string context = string.Empty;
string root = null;
using (LdapConnection connection = new LdapConnection(root))
{
connection.Timeout = new TimeSpan(0, 0, 10);
connection.Bind();
var filter = "(&(objectClass=*))";
var searchRequest = new SearchRequest(null, filter, system.DirectoryServices.Protocols.SearchScope.Base, DEFAULTNAMINGCONTEXT);
var response = connection.SendRequest(searchRequest) as SearchResponse;
context = response.Entries[0].Attributes[DEFAULTNAMINGCONTEXT][0].ToString();
}
return 1;
}
catch (Exception ex)
{
return -1;
}
finally
{
}
|
|
|
|
|
from memory, you never get an 'exact' 'timeout'
I'm a bit worried about Quote: but the bind doesn't timeout after 10 seconds are we talking about the same thing ? if you bind successfully, you wont be timed out - the Timeout setting is to set a time +/- a factor that may depend on your network/the MSAD/LDAP server, that says 'time me out if I cant connect/bind to the server within this time'
(it could be that my understanding is wrong of course)
|
|
|
|
|
Hi Garth,
Thanks for your reply.
Indeed, if the bind is successful... no time out and everything is fine.
My concern is when the bind isn't successful ("server not reachable" for example): I want to 'time out' if the bind hasn't been established within (for example) 10 seconds.
I did the test with the code I posted setting the timeout on 5 seconds: the time out was not near the 5 seconds... it gets up to 90seconds.
So, it seems that or my code is wrong or the 'timeout'-property is not used for this purpose...
Thanks,
Marc.
|
|
|
|
|
hmmm, well, obviously you're using System.DirectoryServices.Protocols LdapConnection otherwise the Timeout property wouldn't be exposed (System.DirectoryServices was the old model that didn't expose/honour any timeout)
I wouldn't have expected 90 seconds though, and unfortunately these days I'm not in a position to test for you .. are you sure you're timing the right thing (sorry to play 'second guess a pro')
what happens if you put
stopWatch.Start();
connection.Bind();
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10);
Console.WriteLine("Bind Time " + elapsedTime);
|
|
|
|
|
Indeed, I 'switched' from System.DirectoryServices to System.DirectoryServices.Protocols in order to have the property 'Timeout' at my disposal.
I've timed like you suggested... and no surprises (for me)
- when no problem : 00:00:00.18
- when problem ("server not reachable") : 00:00:50:05 (and above)
|
|
|
|
|
obviously I don't know your network environment, whether your client is on one subnet and the MS AD/LDAP server on another (routing issues) and what other factors may be involved - MS AD/LDAP running on an under-powered server or all sorts of things in-between
if
MarcSchmidtmayer wrote: 00:00:50:05 (and above)
is hard to swallow - if you have a user looking at a GUI I'd suggest authenticating in the background and keeping the user happy, if its a high speed automated process or something, well, if you cant get a better response time to the server via the network/increase server threads/performance etc I'd be thinking about some 're-architecting' of the software stack, caching ...
|
|
|
|
|
Unfortunate is the fact that I can't make up if it's the 'TimeOut'-property that doesn't work
(like I think) or that it is a 'network issue'.
When I read your answers, I guess you also believe that the 'TimeOut'-property should work...
Anyhow... thanks for your answers and suggestions...
Don't forget to let me know whenever you should haven another 'idea'...
|
|
|
|
|
there is no timeout property for Bind. no solution found for .net core.
Kamran Shahid
Sr. Software Engineer
(MCP, MCAD.net, MCSD.net, MCTS, MCPD.net[web])
Netprosys Inc.
www.netprosys.com
|
|
|
|
|
Wow, your internet connection must be terrible! Your first post in over eight years, and it's a response to a thread from 4½ years ago.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Probably a 600 baud line.
|
|
|
|
|
hehehehehehehhehehe
Kamran Shahid
Sr. Software Engineer
(MCP, MCAD.net, MCSD.net, MCTS, MCPD.net[web])
Netprosys Inc.
www.netprosys.com
|
|
|
|
|
There is a way to get QuickSharp to run your program in a separate window but I can't find any info on this. Anyone have any insight into this?
|
|
|
|
|
|
I assume you are talking about the version on SourceForge. You would be better off asking questions like this on the forum there. Alternatively, you could read the documentation[^].
This space for rent
|
|
|
|
|
microsoft report viewer simple invoice format code c#
send me full code
how to add grid in report viewer
|
|
|
|
|
|
It doesn't quite work like that.
We do not do your work for you.
If you want someone to write your code, you have to pay - I suggest you go to Freelancer.com and ask there.
But be aware: you get what you pay for. Pay peanuts, get monkeys.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Member 12951091 wrote: send me full code
send me full payment.
$3,000 USD will do for a deposit to establish your requirements.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
My issue is trying to understand where and how platform specific code can be used. i.e. hearing Raspberry PI will support .NET Core I thought "Hey, how I write a UI for that"? But the question might not make much sense. So let's see if I got things right.
.NET Standard: a .NET Standard library target no particular environment and should be supported on all platform that support that Standard library level. These are the new PCL (with a little less hassle).
.NET Core: A multiplatform .NET runtime execution environment. Much like the .NET Framework itself. Except it has less API and more platform support. It can execute latest .NET Standard library as well as .NET Core library.
.NET Framework: A Windows specific .NET runtime and execution environment.
Xamarin Android: An android specific .NET Runtime and execution environment. Can execute Xamarin library as well as .NET Standard library (though some some .NET Standard library calls throw "NotImplementedException" as of now! )
Now if I want to write a PCL UI library that will run on Android I need to delegate some call to some interface / type that will be registered by the Xamarin Android execution environment at startup before it starts the PCL library.
Similarly I am confused as to one do platform specific code in .NET Core. Since I start the .NET Core environment directly (as opposed to a .NET environment specific to the host), how could I stub in native UI technology?
|
|
|
|
|
|
Thanks.
I spent the whole evening yesterday playing with various cross framework compatibility (.NET Standard 1.6, .NET Core, .NET Framework, Xamarin iOS, Xamarin Android, UWP) and I have the feeling the whole thing is... unfinished...
For example, .NET Standart 1.6 is compatible with an, as of yet, unpublished version of the .NET Framework!
Or my .NET Standard 1.6 library was correctly linked into Xamarin Android but had post compile error (creating debug info) with Xamarin iOS, and some method threw NotImplementedException when run on Android.
Anyhow it looks like one will have to wait for .NET Standard 2.0 for better compatibility story, which, last year, they said should be around VS2017 release date....
|
|
|
|