实现可以离线工作的桌面.NET应用程序。
我需要在 .NET 中创建桌面 WPF 应用程序。
该应用程序与 Web 服务器通信,并且可以在 Web 服务器不可用时以离线模式工作。
例如,应用程序需要计算用户在一个项目上工作的时间。应用程序连接到服务器并获取项目列表,用户选择一个项目,然后按按钮启动计时器。用户可以稍后停止计时器。项目开始和停止时间需要发送到服务器。
当应用程序处于离线模式时如何实现此功能?
是否有一些现有的解决方案或一些库可以简化此任务?
提前致谢。
I need to create a desktop WPF application in .NET.
The application communicates with a web server, and can work in offline mode when the web server isn't available.
For example the application needs to calculate how much time the user works on a project. The application connects to the server and gets a list of projects, the user selects one project, and presses a button to start timer. The user can later stop the timer. The project start and stop times need to be sent to the server.
How to implement this functionality when the application is in offline mode?
Is there are some existing solution or some libraries to simplify this task?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
为了离线工作,您需要做一些不同的事情。
首先,您需要缓存项目列表。这样,用户不必上网即可获取项目列表 - 您可以在用户离线时从本地缓存中提取它。
其次,您需要在本地保存计时结果。一旦您再次上线,您就可以更新服务器所有的历史计时数据。
这只需要在本地保存信息即可。您可以选择将其保存在您希望的任何位置,甚至一个简单的 XML 文件就足以保存您要保存的信息,因为它很简单 - 只需一个项目 + 一个时间跨度。
听起来这是一个用于业务跟踪目的的计时应用程序,在这种情况下,您将希望防止用户轻松更改数据。就我个人而言,我可能会将其保存在 独立存储 中,并可能对其进行加密。
You'll need to do a couple of things differently in order to work offline.
First, you'll need to cache a list of projects. This way, the user doesn't have to go online to get the project list - you can pull it from your local cache when the user is offline.
Secondly, you'll need to save your timing results locally. Once you go online again, you can update the server will all of the historic timing data.
This just requires saving the information locally. You can choose to save it anywhere you wish, and even a simple XML file would suffice for the information you're saving, since it's simple - just a project + a timespan.
It sounds like this is a timing application for business tracking purposes, in which case you'll want to prevent the user from easily changing the data. Personally, I would probably save this in Isolated Storage, and potentially encrypt it.
您可以使用 Sql Server Compact 作为本地存储,然后使用 microsoft 同步框架将本地数据库同步到服务器数据库。我建议对 Microsoft Sync Framework 进行一些研究。
You can use Sql Server Compact for you local storage and then you microsoft sync framework to sync your local database to the server database. I recommend doing some research on the Microsoft Sync Framework.
大家好,我实现了这个应用程序,我创建了自己的离线框架
基于此文章和 Microsoft Disconnected Service Agent
DSA
我已根据自己的需要调整了此框架。
谢谢大家。
Hello all I implemented this application I've created my own off-line framework
based on this article and Microsoft Disconnected Service Agent
DSA
I've adapted this framework for my needs.
Thank you for all.
您可以使用类型化或非类型化数据集进行离线存储。
当在线(连接到互联网)时,您可以将数据下载到数据集中并将其上传回数据库服务器。数据集可以从本地文件加载和保存到本地文件。
you can use a typed or untyped dataset for offline-storage.
when online (connected to internet) you can download the data into a dataset and upload it back to the database server. the dataset can be loaded from and saved to a local file.