客户端服务器数据共享问题
我有一个带有移动应用程序的网络服务。用户与应用程序共享服务器上的数据 - 在数据库中存在一个约束,即每个用户的共享对象的名称是唯一的。此外,应用程序在本地存储所有创建的数据(由用户 - 也是共享的)。
我有以下场景:
- 用户创建数据名称为 X 的数据。
- 用户共享此数据。
- 服务器中有该用户的数据库数据名称 X
- 用户有一部新手机并安装该应用程序。
- 无互联网连接
- 用户再次创建数据名为 X 的数据。
- 它仅存储在本地 - 因为无互联网连接。
- 互联网连接已恢复。
- 现在,BG 服务运行并开始共享 BG 中的所有共享数据。
- 发现问题是因为约束。
应该怎样做才能解决问题呢?我可以弹出一个新窗口,说它已经共享,并要求用户重命名/覆盖它,提供将该数据 D/L 到其本地数据库等的选项。但由于它是在 BG 中完成的 - 用户是否友好显示这个弹出窗口?
还有其他想法吗?
可能有一种通用的方法可以做到这一点。
我确实需要一些帮助来解决这个问题。
I have a webservice with a mobile application. The user, with the application shares the data on the server - have a constraint in the DB that the name of the shared object is unique per user. Also application stores locally all created data (by the user - that is also shared).
I have the following scenario:
- User creates data with data-name X.
- User shares this data.
- Server has in it DB data-name X for this user
- User has a new phone and install the application.
- NO INTERNET CONNECTION
- user creates again data with data-name X.
- it is stored only locally - since NO INTERNET CONNECTION.
- Internet connection restored.
- Now a BG service run and start sharing all u shared data - in the BG.
- The problem found because of the constraint.
What should be done to solve the problem? I can popup a new window saying that it already shared and ask the user to rename/overwrite it, give option to D/L this data to its local DB etc. But since it is done in the BG - is it user-friendly to show this popup?
Any other ideas?
Probably there is a common way of doing it.
I can really use some help reagrding this issue.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
以下是我最近完成的一个应用程序处理此问题的方式:
在我的情况下,这非常有效。
Here is how a recent app I've done handles this:
In my situation, this works perfectly.
为此,您通常不使用名称或类似的东西,而是使用 UUID - 即唯一标识对象的 32 到 64 个字符长的随机字符串。创建对象时,只需在设备上创建一个 UUID 并将其同步到服务器即可。这是 android 中 UUID 类的文档。
虽然理论上具有相同的 UUID 是可行的,但您通常不必太担心,如下所述:http://en.wikipedia.org/wiki/Universally_unique_identifier#Random_UUID_probability_of_duplicates
对于 iOS,您可以使用 CFUUID 类生成UUID
UUID的另一个名称是GUID,全局唯一标识符。因此,您可以删除任何类型的唯一性约束。
for this, you generally don't use a name or something of that sort, but UUIDs - i.e. 32-to-64 character long random strings that uniquely identify an object. When you create an object, just create a UUID on the device and sync this to the server. Heres the documentation of the UUID class in android.
While it theoretically feasible to have the same UUIDs, it's something you generally don't worry too much about it, as stated here: http://en.wikipedia.org/wiki/Universally_unique_identifier#Random_UUID_probability_of_duplicates
For iOS, you can use the CFUUID class to generate UUID
Another name for UUIDs ist GUID, Globaly unique identifiers. Hence, you remove any kind of uniqueness constraint.