|
If you do 2, then the situation may have changed by the time you get your results. So I do 1
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I do both. It's always best to give the user a chance to correct data as soon as possible so the second option is aimed at letting the user know before they actually try to commit the records. The first option is a safeguard for the cases where multiple users hit the database at roughly the same time.
This space for rent
|
|
|
|
|
So do you throw your own custom exceptions?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Yes. The reason I do this is because the code that writes to the database is often several layers away and catching a specific DuplicateCustomerName exception at the point of clicking save is a lot neater than having to pass return codes all the way up the chain.
This space for rent
|
|
|
|
|
I agree. Thanks Pete
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Pete O'Hanlon wrote: I do both.
I would probably put a constraint on the table though either in addition to or instead of.
But that is probably overkill.
|
|
|
|
|
Depending on the volume and the latency I often put in an auto complete box that kicks in after 3 characters, disables the textbox while getting the data from the DB. This can be annoying if the latency is too slow.
And/Or I add a manual search button.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
"Save" means "add or update"; unless you're dealing with "modes"; in which case, you add in "new mode" and save / replace / update in "edit mode". (And maybe "delete" in "neither" mode).
And insert is usually atomic whereas an "update" usually involves a transaction (i.e. commit / roll-back).
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Kevin Marois wrote: How would you check for a duplicate company name?
Besides the reply below however I would also verify the requirement (business makes that requirement not developers.)
Because unless the company is only doing business in one region there will be companies with duplicate names and often in the same type of business as well. Not a good idea if the sales people have to tell "Joes pizza" that they cannot have that name because some one in a different region already has it.
|
|
|
|
|
Can anyone suggest how to learn design and architecture in .NET
|
|
|
|
|
|
At least for me "Architecture" in most cases is not "in" anything. If I consider there to be a significant point that requires a specific solve then I might document a specific technology for that.
Often technology is not even specified explicitly. So I might document an api in general in the Architecture document but implicitly assume that it will be Rest methods.
Conversely a design, might specify a technology but again it might be implicit. So for example if I want to document the significant parts of a message being passed to a Rest method then I might do it as a JSON object without stating that the Rest methods will be using JSON. Again this might change if there is a specific problem that seems to require a specific technology then I would use that.
Conversely if you want to work in the .NET eco-system then understanding the technologies available in it would enable to you implicitly start relying on them.
|
|
|
|
|
Are there any recommended articles on codeproject to get started with this topic ?
(PS: I know google may be my friend but..)
Caveat Emptor.
"Progress doesn't come from early risers – progress is made by lazy men looking for easier ways to do things." Lazarus Long
|
|
|
|
|
The only way to find out is to go and search the articles section.
|
|
|
|
|
heee
Caveat Emptor.
"Progress doesn't come from early risers – progress is made by lazy men looking for easier ways to do things." Lazarus Long
|
|
|
|
|
I have an app that FTP's files to clients PC's. I only want to get files that have changed since the last get.
Problem is, the file dates are all set to the Date/Time the file was FTP'd to the server.
I tried using FtpWebRequest
FtpWebRequest request = (FtpWebRequest)WebRequest.Create("<a href="ftp:
request.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
request.Credentials = new NetworkCredential("user", "pwd");
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
Stream responseStream = response.GetResponseStream();
StreamReader reader = new StreamReader(responseStream);
string names = reader.ReadToEnd();
reader.Close();
response.Close();
But this only shows the last modified date, which is the date it was uploaded to the server.
How can I tell weather or not a file has changed since the last download?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
modified 30-Jan-18 12:37pm.
|
|
|
|
|
You're using a WebRequest; not sure if it would work, but for a normal webserver I'd set the LastModified[^] and see if it returns a HTTP304.
That's how I keep my host-file up to date
Kevin Marois wrote: How can I tell weather or not a file has changed since the last download? If files are only modified over FTP, then the upload is the last change, isn't it?
For the host-file, I "remember" locally when I fetched my version, and send that datetime when requesting the new version. Only http-headers are sent back, so not much traffic
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Problem definition is fuzzy.
If you are sending files to a client PC then you can manage the files on your server completely.
For example
1. You have a landing directory, on your server, where files arrive
2. You MOVE files from that directory to your processing directory and update a processing log file.
3. You keep track of the files that were successfully sent to each client and correlate it with the file in 2 to insure what new files need to be sent. You send files from the processing directory, not the landing directory.
|
|
|
|
|
Dear Community. I'm not professional developer, but I have constant need for some small specific applications. Usually I can't find free and adequate solutions for these purposes and finally decided to learn how to write my own. But I can't find suitable development solution.
1. I know C# (more or less) since I'm learning Unity coding and was studying this language at University. I don't want to learn something else at this point.
2. I need to create applications that run on Windows and Linux (since I use both OS) without re-writing front-end (or the whole application) from scratch for each platform.
3. I need rich GUI like in JavaFX or desktop-web applications (like Electron-based) which will be looking the same way on each platform. I DO NOT need native look/feel. Two purposes for that: 1) I need to implement some graphical data visualization (bars, diagrams, etc.) and 2) I'm a designer and I love nice looking applications.
4. I need free solution. I'm not planning some kind of distribution or selling my apps, they're just for me for now, but if one day I decide to do this, I don't want something that will stop me or force me to open my code somehow (through GPL, for example).
5. Ideally I need solution with WYSIWYG-editor (like with WPF or JavaFX).
Is there something that fits these conditions?
* I think GTK is not suitable for me because of its orientation to native looking. And GTK apps look just odd on Windows. And as far as I can say there's not much visual capabilities here.
* I think Qt is also not suitable because of its license. Most of Qt libraries are GPL, while some of them LGPL. And the whole license theme here is unclear for me (and not only for me, there's a lot of topics on forums about it).
* I don't want to use Electron because, well – wrapping relatively small application with the whole Chromium engine? Really? I've used some of Electron application and they're slow, big (in term of disk space) and eating lot of memory.
* JavaFX is looking really great, but it is the new programming language for me. I get the point that C# and Java are relatively similar, but I really don't want to dive deeper into some new language. And besides I'm still not sure about performance and dependency from JRE.
* Xamarin doesn't have compiling ability to Linux.
* There's also JUCE Framework, but as far as I can say it needs C++ and hasn't truly free license.
* I heard about AvaloniaUI, but as far as I get it – it's not mature enough for production needs.
For now I ended up learning Sciter (didn't hear anything about it before and I'm sure that many people didn't). It's like Electron but without Chromium and with lightweighted engine instead. And it can use C# for back-end. But there's very few tutorials on the web, absolutely nothing on YouTube, small community. And I found creating UI just with bare HTML/CSS/JS without some kind of WYSIWYG-editor is pain in my ass. And, well, I almost don't know JS, so it takes time to make something.
I understand that I probably want too much. But maybe I missed something? Thanks in advance!
|
|
|
|
|
There is one truly obvious option that you have neglected that would actually fit your needs, and that's a WCF (or other web host) based application interface that provides a UI like a web app. An OWIN server is pretty much trivial in terms of resource usage, and I can't imagine that the ASP.NET Core web server is that different based on what I've read about it.
It works, there's tones of references that you can follow for running an integral server, and it's honestly the only real free cross-platform solution I've seen that will not take a mountain of custom code to achieve. The minus is that you need a foundation in JavaScript and web apps to work with it.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
I'm using simple and plain old WinForms, on both Ubuntu/Mono and Windows/Net. Works like advertised.
You can use VS (the free version) to "draw" your forms.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Guys,
Is it possible to synch 4 databases in mysql? I mean there are 4 servers on different location and databases on server will be in Auto Synch mode. If any one goes down rest of the three gets sync automatically and it goes UP, all 4 gets synch automatically.
Please reply...!
|
|
|
|
|
You're talking about sharding, replication, and load balancing, which is great, but unless you're writing software that will perform this task, this is the wrong forum for it. I'd suggest the System Administrator or Database forums.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
I'm working on a C/WPF/SQL Server app.
My SQL tables all have the following columns:
CreatedById INT NOT NULL FOREIGN KEY REFERENCES Users(UserId),
CreatedDt DATETIME NOT NULL,
LastModifiedById INT NULL FOREIGN KEY REFERENCES Users(UserId),
LastModifiedDT DATETIME NULL,
DeletedById INT NULL FOREIGN KEY REFERENCES Users(UserId),
DeletedDt DATETIME NULL
When the user logs into the app the login function returns a User object which is stored on the MainWindowViewModel.
The question is this: What's the righ way to get the ID of he logged in user into the DAL?
I could simply pass the use Id into every DAL function, but I'd like to hear other suggestions.
Thanks
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
The "right" way is entirely contingent on what you want to achieve.
If you're trying to provide a security layer, it could be parsed through an authorization provider with full transactional change tracking posted to a completely different database. This would, by necessity, have the transaction and user info passed to an authorization (or even AAA) provider, which would pass the results of the authorization to the DAL on success in an object that should contain the UserId regardless.
If you're looking for basic audit trails, a simple M-M mapping table that triggers off of update events would be just fine (user, table, item id, SQL query OR enumeration describing transaction). You could also create multiple M-M tables for each data table to provide robust relational support. Using this method, the context information, including the UserId, can be passed through an event handler rather than as a parameter.
If you just want the UserId as a creator, you can just pass the value or have it available in a context that is passed to the DAL on construction.
And there are, of course, other approaches ad nauseum.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|