简体   繁体   English

.net Windows应用程序脱机存储数据并在存在网络时存储到db

[英].net windows application store data offline and store to db when there is network

I am developing a windows application for agricultural purpose. 我正在开发用于农业目的的Windows应用程序。 This application will be used by multiple users to maintain the data. 多个用户将使用该应用程序来维护数据。 The main issue is there won't be network connectivity on the work location. 主要问题是工作地点将没有网络连接。 But however by end of the day they can go and synchronize if there are any option. 但是到了一天结束时,如果有任何选择,他们可以进行同步。

I just want to know how can we import and store all the data locally and update the data to database when there is network. 我只想知道如何在存在网络的情况下本地导入和存储所有数据以及如何将数据更新到数据库。

The options that i thought is to have SQL on every machine that runs this application. 我认为的选项是在运行此应用程序的每台计算机上都有SQL。 Store the data to local database when there is no network. 没有网络时,将数据存储到本地数据库。

Having a separate button to export the local data to the centralized database when there is network. 有一个单独的按钮,可以在有网络时将本地数据导出到集中式数据库。

Looks like this is complicated. 看起来这很复杂。 Is there any better and easier option. 有没有更好更好的选择。

I prefer using c#, Visual studio. 我更喜欢使用c#,Visual Studio。

Thanks. 谢谢。

You can use SQLite for storing data locally. 您可以使用SQLite在本地存储数据。 It's fast, lightweight, and public domain. 它是快速,轻量级的公共领域。

You can use whatever the database of choice for the centralized server. 您可以使用集中式服务器选择的任何数据库。

Well, this a quite broad question, as it has many options and scenarios. 嗯,这是一个相当广泛的问题,因为它有很多选择和方案。 The questions you should ask yourself are: 您应该问自己的问题是:

  1. Does user handle new information only or any information from any other user from the previous syncing? 用户是仅处理新信息还是来自先前同步中来自任何其他用户的任何信息?
  2. Do you have to handle update conflicts? 您必须处理更新冲突吗?
  3. Do you handle text information only or you have complex types and binary files? 您仅处理文本信息还是具有复杂的类型和二进制文件?

As for the solution, the easiest way, from my point of view, would be using SQL Lite on portable devices, is a lightweight SQL client that will allow you to handle information easily. 对于该解决方案,从我的角度来看,最简单的方法是在便携式设备上使用SQL Lite,这是一种轻量级的SQL客户端,可让您轻松处理信息。 On the server you can use whatever you want, SQL Server, MySQL or any other SQL flavor you may like. 在服务器上,您可以使用任何您想使用的东西,SQL Server,MySQL或任何其他SQL风格。 Just make sure there is a connector for your portable device OS. 只需确保您的便携式设备OS有一个连接器即可。

If you keep thinking of using SQL server on the portable device, it's a battery hogger!!!, you might want to check Microsoft Sync framework , as it provides almost all possible scenarios for handling data syncing, manage conflicts, etc. 如果您一直想在便携式设备上使用SQL Server,那就太麻烦了!!!!,您可能要检查Microsoft Sync框架 ,因为它提供了几乎所有可能的方案来处理数据同步,管理冲突等。

Thanks for the answers. 感谢您的回答。 Please find the below solution that we implemented. 请找到我们实施的以下解决方案。

1) Installed SQL express on all the local machines 1)在所有本地计算机上安装SQL Express

2) Used Microsoft Sync framework to sync the data. 2)使用Microsoft Sync框架同步数据。 The sync is configured on demand. 同步是按需配置的。

Issues faced: 面临的问题:

1) We were using geometry datatype on few tables and this was not supported by sync framework. 1)我们在几个表上使用了geometry数据类型,而同步框架不支持此类型。

2) Any change in the database schema will not reflect on the client machine. 2)数据库架构中的任何更改都不会反映在客户端计算机上。 We will have to delete all the system generated procedures used to track the table change and regenerate it. 我们将必须删除用于跟踪表更改的所有系统生成的过程,然后重新生成它。 I am sure there will be a much better way to do this. 我相信会有更好的方法来做到这一点。

Cheers, Jebli 干杯,吉卜力

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM