I've been doing some research around on how to properly store and save the Date and Time in a Web Application but I couldn't find a post that has a marked answer.
I have a ASP.NET MVC website and I use C# for backend code and MS SQL for the database, let say you have different client with different TimeZone currently I'm storing the DateTime by DateTime.UtcNow and I just display it back in "YYYY/MM/DD" format.
All you really need to do is make sure the application server and the database server share the same time settings and are in sync.
IIS, .NET, and SQL Server all use the system time by default.
Clients in different time zones will still use the system time of the IIS server they are connected too. Most sites just format the date on the client side, to the clients zone.
If you want to get fancy, you can write database triggers that handle transaction time stamps. This comes in handy if you do a lot of back-end processing.
Related
Assume that I have a third-party database application with SDK that can be used to retrieve data out of the database in XML.
On the other side, I have developed a website using Laravel framework of PHP. The website is supposed to display data from the database of the application.
In regards to above I have the following questions:
As far as I understand, I can either store the requested data in my website database or just show it without storing. What technique do you suggest?
How do I achieve xml data transfer from the database server to the website?
Taking into account that I have experience of development in C#, I assume that I have to develop some web-service that would run on the database server, retrieve the required data and send it to my website. So the web-service has to receive the requests from my Laravel website, retrieve data from database server accordingly and pass the xml response to my website that would finally display it. Am I on the right way? If so, could you please guide me on how to code and bind these parts?
Thank you in advance.
I have to agree with #Serge in the comments - there are many ways to do this because it is a very broad question.
My answer was mostly going to deal with how regularly the third party database was going to be updated but judging from your comments, I'm assuming it will be fairly often? In which case, I would likely connect directly to the third party database from your laravel app using the firebird driver found here: https://github.com/jacquestvanzuydam/laravel-firebird (Please note, I have never used this so I cannot comment on it's quality) instead of writing a C# web service. I don't know much about firebird itself but you will likely want to connect using an SSH tunnel or VPN for security reasons.
Then I would either store data in MySQL if you know it isn't likely to change very often (in this case you would use a laravel command, run on a schedule, to pull data out of firebird every [X] days/hours/minutes depending on the data) or, if the data is likely to change on each potential web request, using some form of caching system (redis, memcache, file cache etc) to speed up the web requests.
Sorry if that isn't particularly helpful - if you can provide more information maybe I can help you out further :)
Good luck!
I have one existing ASP.NET application. This application built in .net framework 2.0
We used DateTime.Now at many places to store current datetime in application. Its for different purposes including logging.
Currently application hosted on server which of USA. When I access application from my machine, it returns current datetime of server. Is there any way, I can get my local machine.
I researched and got that I need to use TimeZone class to get current datetime of my local machine. But in that case, I need to change wherever I used Datetime.Now and get time from timezone.
Is there any way, I can set globally and when I use datetime.now, it returns local machine time?
Please help.
No, you can't. There is no way to set TimeZone globally.
Best options:
Convert DateTime.Now to DateTime.UtcNow and do the appropriate
calculations (what if you have to move the server to another zone of
US?)
Use DateTimeOffset insted of DateTime which use the TimeZone.
In any case, you have to handle the date time conversion to the local time zone in client side of you app, not in the server side.
You could also possibly set the timezone on the server itself to the one you need.
There's is a "practice" in my new work place. Each and every web application development, the "manager/designer" wants to have a local db.
Currently we are consuming a web service from an external source for getting master data. However he doesn't want to do "through out day" updates into the external source. He wants to keep these updates into the local db and at the end of the day, do a batch update to external source.
Which makes sense for now. But if the website has to be accessed over mobile (in the future - seems like soon...) having a local db-sql processing will be an issue when accessing via mobile?
Yes the application is layered and have few different interfaces for services, access and connections.
Yes it gives issues because when you run your application in mobile then it is not going to connect your local db....
It will connect your master db . so updating db at the end of day is not good for mobile users.
I am creating a .NET service that gets timestamp information (in the local server time zone) from another Windows 2008 server. I don't have control over the other server, and I need a way to programatically get the timezone offset from that server so that I can interpret the timestamp information as a time in UTC. Is there a builtin service to get the time (and timezone) from a windows 2008 server? Thanks.
Check out this post: http://blogs.technet.com/b/heyscriptingguy/archive/2012/03/28/use-powershell-to-see-time-zone-information-on-remote-computers.aspx
It discusses using powershell, you may need to have access to the server, but perhaps it will help if your looking for a way to access programatically.
If you are able to map to the server, you could also try:
net time \\SERVER_NAME
I recently developed a Java Application for a client with MySQL database. Now he wants to have ASP.NET website connected with the Java Application.
I'm thinking of placing the database on a local server which would support both the desktop application and the website.
What i want to know is, is it the good way to handle these kind of scenario or is there any standard method?
I also want to know what are the steps to do this?
If you're worried about having both the desktop application and the web site accessing the database, you shouldn't worry as databases are designed to have many different programs accessing them at once.
If you're worried about keeping your data in a consistent state, you should look at using a transactional MySQL database engine such as InnoDB for a start. Also, in both your application and your website you are going to have to make sure that you validate any data going in/out of the database. i.e. if someone enters garbage data from the website, make sure that this will not be saved to the database and will not crash the desktop application.