├── sqlite_stored_data.png
├── MobileAppDocDBOfflineSyncSample.iOS
├── Resources
│ ├── Icon.png
│ ├── Default.png
│ ├── Icon-72.png
│ ├── Icon@2x.png
│ ├── Default@2x.png
│ ├── Icon-72@2x.png
│ ├── Default-568h@2x.png
│ ├── Default-Portrait.png
│ ├── Default-Landscape.png
│ ├── Default-Portrait@2x.png
│ └── Default-Landscape@2x.png
├── Main.cs
├── AppDelegate.cs
├── app.config
├── QSTodoListViewController.designer.cs
├── packages.config
├── Info.plist
├── QSTodoService.cs
├── QSTodoListViewController.cs
├── MobileAppDocDBOfflineSyncSample.iOS.csproj
├── MainStoryboard_iPad.storyboard
└── MainStoryboard_iPhone.storyboard
├── MobileAppDocDBOfflineSyncSample.UWP
├── Assets
│ ├── StoreLogo.png
│ ├── SplashScreen.scale-200.png
│ ├── LockScreenLogo.scale-200.png
│ ├── Square150x150Logo.scale-200.png
│ ├── Square44x44Logo.scale-200.png
│ ├── Wide310x150Logo.scale-200.png
│ └── Square44x44Logo.targetsize-24_altform-unplated.png
├── App.xaml
├── project.json
├── Properties
│ ├── AssemblyInfo.cs
│ └── Default.rd.xml
├── Package.appxmanifest
├── Common
│ ├── QuickStartTask.xaml
│ └── QuickStartTask.xaml.cs
├── App.xaml.cs
├── MainPage.xaml.cs
├── MobileAppDocDBOfflineSyncSample.UWP.csproj
└── MainPage.xaml
├── MobileAppDocDBOfflineSyncSample.Shared
├── packages.config
├── DataModel
│ ├── DoubleNestedItem.cs
│ ├── NestedItem.cs
│ ├── ToDoItemDocDb.cs
│ └── ComplexItem.cs
├── Properties
│ └── AssemblyInfo.cs
└── MobileAppDocDBOfflineSyncSample.Shared.csproj
├── MobileAppDocDBOfflineSyncSample.Droid
├── Resources
│ ├── drawable-hdpi
│ │ └── ic_launcher.png
│ ├── drawable-ldpi
│ │ └── ic_launcher.png
│ ├── drawable-mdpi
│ │ └── ic_launcher.png
│ ├── drawable-xhdpi
│ │ └── ic_launcher.png
│ ├── menu
│ │ └── activity_main.xml
│ ├── values-v11
│ │ └── styles.xml
│ ├── values-v14
│ │ └── styles.xml
│ ├── values
│ │ ├── Strings.xml
│ │ └── styles.xml
│ ├── layout
│ │ ├── Row_List_To_Do.axml
│ │ └── Activity_To_Do.axml
│ ├── AboutResources.txt
│ └── Resource.designer.cs
├── ToDoItemDocDbWrapper.cs
├── Properties
│ ├── AndroidManifest.xml
│ └── AssemblyInfo.cs
├── Assets
│ └── AboutAssets.txt
├── app.config
├── packages.config
├── ToDoItemDocDbAdapter.cs
├── XamarinMobileService.Droid.csproj.bak
├── ToDoActivity.cs
└── MobileAppDocDBOfflineSyncSample.Droid.csproj
├── MobileAppDocDBOfflineSyncSample.API
├── Startup.cs
├── DataObjects
│ ├── DoubleNestedItem.cs
│ ├── TodoItemDocDb.cs
│ ├── NestedItem.cs
│ └── ComplexItem.cs
├── Helpers
│ ├── DocumentResource.cs
│ ├── QueryableExpandAttribute.cs
│ └── DocumentDBDomainManager.cs
├── Web.Debug.config
├── Web.Release.config
├── Properties
│ └── AssemblyInfo.cs
├── App_Start
│ ├── Startup.Swagger.cs
│ └── Startup.MobileApp.cs
├── Controllers
│ ├── TodoItemDocDbController.cs
│ └── ComplexItemController.cs
├── packages.config
├── Web.config
└── MobileAppDocDBOfflineSyncSample.API.csproj
├── LICENSE
├── README.md
├── .gitignore
└── MobileAppDocDBOfflineSyncSample.sln
/sqlite_stored_data.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karolzak/mobile-app-documentdb-offlinesync-sample/HEAD/sqlite_stored_data.png
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.iOS/Resources/Icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karolzak/mobile-app-documentdb-offlinesync-sample/HEAD/MobileAppDocDBOfflineSyncSample.iOS/Resources/Icon.png
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.UWP/Assets/StoreLogo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karolzak/mobile-app-documentdb-offlinesync-sample/HEAD/MobileAppDocDBOfflineSyncSample.UWP/Assets/StoreLogo.png
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.iOS/Resources/Default.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karolzak/mobile-app-documentdb-offlinesync-sample/HEAD/MobileAppDocDBOfflineSyncSample.iOS/Resources/Default.png
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.iOS/Resources/Icon-72.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karolzak/mobile-app-documentdb-offlinesync-sample/HEAD/MobileAppDocDBOfflineSyncSample.iOS/Resources/Icon-72.png
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.iOS/Resources/Icon@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karolzak/mobile-app-documentdb-offlinesync-sample/HEAD/MobileAppDocDBOfflineSyncSample.iOS/Resources/Icon@2x.png
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.iOS/Resources/Default@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karolzak/mobile-app-documentdb-offlinesync-sample/HEAD/MobileAppDocDBOfflineSyncSample.iOS/Resources/Default@2x.png
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.iOS/Resources/Icon-72@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karolzak/mobile-app-documentdb-offlinesync-sample/HEAD/MobileAppDocDBOfflineSyncSample.iOS/Resources/Icon-72@2x.png
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.iOS/Resources/Default-568h@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karolzak/mobile-app-documentdb-offlinesync-sample/HEAD/MobileAppDocDBOfflineSyncSample.iOS/Resources/Default-568h@2x.png
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.iOS/Resources/Default-Portrait.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karolzak/mobile-app-documentdb-offlinesync-sample/HEAD/MobileAppDocDBOfflineSyncSample.iOS/Resources/Default-Portrait.png
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.UWP/Assets/SplashScreen.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karolzak/mobile-app-documentdb-offlinesync-sample/HEAD/MobileAppDocDBOfflineSyncSample.UWP/Assets/SplashScreen.scale-200.png
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.iOS/Resources/Default-Landscape.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karolzak/mobile-app-documentdb-offlinesync-sample/HEAD/MobileAppDocDBOfflineSyncSample.iOS/Resources/Default-Landscape.png
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.iOS/Resources/Default-Portrait@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karolzak/mobile-app-documentdb-offlinesync-sample/HEAD/MobileAppDocDBOfflineSyncSample.iOS/Resources/Default-Portrait@2x.png
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.Shared/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.UWP/Assets/LockScreenLogo.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karolzak/mobile-app-documentdb-offlinesync-sample/HEAD/MobileAppDocDBOfflineSyncSample.UWP/Assets/LockScreenLogo.scale-200.png
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.iOS/Resources/Default-Landscape@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karolzak/mobile-app-documentdb-offlinesync-sample/HEAD/MobileAppDocDBOfflineSyncSample.iOS/Resources/Default-Landscape@2x.png
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.UWP/Assets/Square150x150Logo.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karolzak/mobile-app-documentdb-offlinesync-sample/HEAD/MobileAppDocDBOfflineSyncSample.UWP/Assets/Square150x150Logo.scale-200.png
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.UWP/Assets/Square44x44Logo.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karolzak/mobile-app-documentdb-offlinesync-sample/HEAD/MobileAppDocDBOfflineSyncSample.UWP/Assets/Square44x44Logo.scale-200.png
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.UWP/Assets/Wide310x150Logo.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karolzak/mobile-app-documentdb-offlinesync-sample/HEAD/MobileAppDocDBOfflineSyncSample.UWP/Assets/Wide310x150Logo.scale-200.png
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.Droid/Resources/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karolzak/mobile-app-documentdb-offlinesync-sample/HEAD/MobileAppDocDBOfflineSyncSample.Droid/Resources/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.Droid/Resources/drawable-ldpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karolzak/mobile-app-documentdb-offlinesync-sample/HEAD/MobileAppDocDBOfflineSyncSample.Droid/Resources/drawable-ldpi/ic_launcher.png
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.Droid/Resources/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karolzak/mobile-app-documentdb-offlinesync-sample/HEAD/MobileAppDocDBOfflineSyncSample.Droid/Resources/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.Droid/Resources/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karolzak/mobile-app-documentdb-offlinesync-sample/HEAD/MobileAppDocDBOfflineSyncSample.Droid/Resources/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.UWP/Assets/Square44x44Logo.targetsize-24_altform-unplated.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/karolzak/mobile-app-documentdb-offlinesync-sample/HEAD/MobileAppDocDBOfflineSyncSample.UWP/Assets/Square44x44Logo.targetsize-24_altform-unplated.png
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.Droid/Resources/menu/activity_main.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.Droid/Resources/values-v11/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.API/Startup.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Owin;
2 | using Owin;
3 |
4 | [assembly: OwinStartup(typeof(MobileAppDocDBOfflineSyncSample.API.Startup))]
5 |
6 | namespace MobileAppDocDBOfflineSyncSample.API
7 | {
8 | public partial class Startup
9 | {
10 | public void Configuration(IAppBuilder app)
11 | {
12 | ConfigureMobileApp(app);
13 | }
14 | }
15 | }
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.UWP/App.xaml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.API/DataObjects/DoubleNestedItem.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Web;
6 |
7 | namespace MobileAppDocDBOfflineSyncSample.API.DataObjects
8 | {
9 | public class DoubleNestedItem
10 | {
11 | [JsonProperty(PropertyName = "doubleNestedBool")]
12 | public bool DoubleNestedBool { get; set; }
13 | }
14 | }
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.Droid/Resources/values-v14/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
11 |
12 |
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.Droid/ToDoItemDocDbWrapper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Newtonsoft.Json;
3 | using MobileAppDocDBOfflineSyncSample.Shared.DataModel;
4 |
5 | namespace MobileAppDocDBOfflineSyncSample.Droid
6 | {
7 |
8 | public class ToDoItemDocDbWrapper : Java.Lang.Object
9 | {
10 | public ToDoItemDocDbWrapper(ToDoItemDocDb item)
11 | {
12 | ToDoItem = item;
13 | }
14 |
15 | public ToDoItemDocDb ToDoItem { get; private set; }
16 | }
17 | }
18 |
19 |
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.Droid/Resources/values/Strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | MobileAppDocDBOfflineSyncSample
4 | Add a todo item
5 | Add
6 | Azure App Service
7 | Refresh
8 | Item Text
9 |
10 |
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.Shared/DataModel/DoubleNestedItem.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace MobileAppDocDBOfflineSyncSample.Shared.DataModel
9 | {
10 | public class DoubleNestedItem
11 | {
12 | [JsonProperty(PropertyName = "doubleNestedBool")]
13 | public bool DoubleNestedBool { get; set; }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.Droid/Resources/layout/Row_List_To_Do.axml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.UWP/project.json:
--------------------------------------------------------------------------------
1 | {
2 | "dependencies": {
3 | "Microsoft.Azure.Mobile.Client": "3.1.0",
4 | "Microsoft.Azure.Mobile.Client.SQLiteStore": "3.1.0",
5 | "Microsoft.NETCore.UniversalWindowsPlatform": "5.2.2",
6 | "Newtonsoft.Json": "9.0.1"
7 | },
8 | "frameworks": {
9 | "uap10.0": {}
10 | },
11 | "runtimes": {
12 | "win10-arm": {},
13 | "win10-arm-aot": {},
14 | "win10-x86": {},
15 | "win10-x86-aot": {},
16 | "win10-x64": {},
17 | "win10-x64-aot": {}
18 | }
19 | }
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.iOS/Main.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using Foundation;
5 | using UIKit;
6 |
7 | namespace MobileAppDocDBOfflineSyncSample.iOS
8 | {
9 | public class Application
10 | {
11 | // This is the main entry point of the application.
12 | static void Main (string[] args)
13 | {
14 | // if you want to use a different Application Delegate class from "AppDelegate"
15 | // you can specify it here.
16 | UIApplication.Main (args, null, "AppDelegate");
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.API/DataObjects/TodoItemDocDb.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Azure.Documents;
2 | using Microsoft.Azure.Mobile.Server;
3 | using Newtonsoft.Json;
4 | using MobileAppDocDBOfflineSyncSampleService.Helpers;
5 |
6 | namespace MobileAppDocDBOfflineSyncSampleService.DataObjects
7 | {
8 | public class TodoItemDocDb : DocumentResource
9 | {
10 | [JsonProperty(PropertyName = "text")]
11 | public string Text { get; set; }
12 |
13 | [JsonProperty(PropertyName = "complete")]
14 | public bool Complete { get; set; }
15 | }
16 | }
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.Droid/Properties/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.iOS/AppDelegate.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using Foundation;
5 | using UIKit;
6 |
7 | namespace MobileAppDocDBOfflineSyncSample.iOS
8 | {
9 | // The UIApplicationDelegate for the application. This class is responsible for launching the
10 | // User Interface of the application, as well as listening (and optionally responding) to
11 | // application events from iOS.
12 | [Register ("AppDelegate")]
13 | public partial class AppDelegate : UIApplicationDelegate
14 | {
15 | // class-level declarations
16 | public override UIWindow Window {get; set;}
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.Shared/DataModel/NestedItem.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 |
6 |
7 | namespace MobileAppDocDBOfflineSyncSample.Shared.DataModel
8 | {
9 | public class NestedItem
10 | {
11 | [JsonProperty(PropertyName = "nestedText")]
12 | public string NestedText { get; set; }
13 |
14 | [JsonProperty(PropertyName = "nestedBool")]
15 | public bool NestedBool { get; set; }
16 |
17 |
18 | [JsonProperty(PropertyName = "doubleNestedItem")]
19 | public DoubleNestedItem DoubleNestedItem { get; set; }
20 | }
21 |
22 | }
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.Droid/Assets/AboutAssets.txt:
--------------------------------------------------------------------------------
1 | Any raw assets you want to be deployed with your application can be placed in
2 | this directory (and child directories) and given a Build Action of "AndroidAsset".
3 |
4 | These files will be deployed with your package and will be accessible using Android's
5 | AssetManager, like this:
6 |
7 | public class ReadAsset : Activity
8 | {
9 | protected override void OnCreate (Bundle bundle)
10 | {
11 | base.OnCreate (bundle);
12 |
13 | InputStream input = Assets.Open ("my_asset.txt");
14 | }
15 | }
16 |
17 | Additionally, some Android functions will automatically load asset files:
18 |
19 | Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf");
20 |
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.API/DataObjects/NestedItem.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Web;
6 |
7 | namespace MobileAppDocDBOfflineSyncSample.API.DataObjects
8 | {
9 |
10 | [QueryableExpand("DoubleNestedItem")]
11 | public class NestedItem
12 | {
13 | [JsonProperty(PropertyName = "nestedText")]
14 | public string NestedText { get; set; }
15 |
16 | [JsonProperty(PropertyName = "nestedBool")]
17 | public bool NestedBool { get; set; }
18 |
19 |
20 | [JsonProperty(PropertyName = "doubleNestedItem")]
21 | public DoubleNestedItem DoubleNestedItem { get; set; }
22 | }
23 | }
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.Droid/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.iOS/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.Droid/Resources/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
14 |
15 |
16 |
19 |
20 |
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.iOS/QSTodoListViewController.designer.cs:
--------------------------------------------------------------------------------
1 | // WARNING
2 | //
3 | // This file has been generated automatically by Xamarin Studio from the outlets and
4 | // actions declared in your storyboard file.
5 | // Manual changes to this file will not be maintained.
6 | //
7 | using System;
8 | using Foundation;
9 | using System.Threading.Tasks;
10 | using UIKit;
11 | using System.CodeDom.Compiler;
12 |
13 | namespace MobileAppDocDBOfflineSyncSample.iOS
14 | {
15 | [Register ("QSTodoListViewController")]
16 | public partial class QSTodoListViewController
17 | {
18 | [Outlet]
19 | UIKit.UITextField itemText { get; set; }
20 |
21 | [Action("OnAdd:")]
22 | [GeneratedCode("iOS Designer", "1.0")]
23 | partial void OnAdd(UIButton sender);
24 |
25 | void ReleaseDesignerOutlets ()
26 | {
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.API/DataObjects/ComplexItem.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Azure.Documents;
2 | using Microsoft.Azure.Mobile.Server;
3 | using Newtonsoft.Json;
4 | using MobileAppDocDBOfflineSyncSampleService.Helpers;
5 | using MobileAppDocDBOfflineSyncSample.API.DataObjects;
6 | using System.Collections.Generic;
7 |
8 | namespace MobileAppDocDBOfflineSyncSampleService.DataObjects
9 | {
10 | public class ComplexItem : DocumentResource
11 | {
12 | [JsonProperty(PropertyName = "text")]
13 | public string Text { get; set; }
14 |
15 | [JsonProperty(PropertyName = "complete")]
16 | public bool Complete { get; set; }
17 |
18 | [JsonProperty(PropertyName ="nested")]
19 | public NestedItem Nested { get; set; }
20 |
21 |
22 | [JsonProperty(PropertyName = "nestedItems")]
23 | public ICollection NestedItems { get; set; }
24 | }
25 | }
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.Shared/DataModel/ToDoItemDocDb.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Newtonsoft.Json;
3 |
4 | namespace MobileAppDocDBOfflineSyncSample.Shared.DataModel
5 | {
6 | public class ToDoItemDocDb
7 | {
8 | public string Id { get; set; }
9 |
10 | [JsonProperty(PropertyName = "text")]
11 | public string Text { get; set; }
12 |
13 | [JsonProperty(PropertyName = "complete")]
14 | public bool Complete { get; set; }
15 | [JsonProperty(PropertyName = "version")]
16 | public byte[] Version { get; set; }
17 |
18 | [JsonProperty(PropertyName = "createdAt")]
19 | public DateTimeOffset? CreatedAt { get; set; }
20 |
21 | [JsonProperty(PropertyName = "updatedAt")]
22 | public DateTimeOffset? UpdatedAt { get; set; }
23 |
24 | [JsonProperty(PropertyName = "deleted")]
25 | public bool Deleted { get; set; }
26 | }
27 | }
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.iOS/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.API/Helpers/DocumentResource.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Azure.Documents;
2 | using Microsoft.Azure.Mobile.Server.Tables;
3 | using Newtonsoft.Json;
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 |
10 | namespace MobileAppDocDBOfflineSyncSampleService.Helpers
11 | {
12 | public abstract class DocumentResource : Document, ITableData
13 | {
14 |
15 | [JsonProperty(PropertyName = "id")]
16 | public override string Id { get; set; }
17 |
18 | [JsonProperty(PropertyName = "version")]
19 | public byte[] Version { get; set; }
20 |
21 | [JsonProperty(PropertyName = "createdAt")]
22 | public DateTimeOffset? CreatedAt { get; set; }
23 |
24 | [JsonProperty(PropertyName = "updatedAt")]
25 | public DateTimeOffset? UpdatedAt { get; set; }
26 |
27 | [JsonProperty(PropertyName = "deleted")]
28 | public bool Deleted { get; set; }
29 |
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.Droid/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Karol Żak
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.Droid/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using Android.App;
4 |
5 | // Information about this assembly is defined by the following attributes.
6 | // Change them to the values specific to your project.
7 |
8 | [assembly: AssemblyTitle("MobileAppDocDBOfflineSyncSample")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("")]
13 | [assembly: AssemblyCopyright("billholmes")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
18 | // The form "{Major}.{Minor}.*" will automatically update the build and revision,
19 | // and "{Major}.{Minor}.{Build}.*" will update just the revision.
20 |
21 | [assembly: AssemblyVersion("1.0.0")]
22 |
23 | // The following attributes are used to specify the signing key for the assembly,
24 | // if desired. See the Mono documentation for more information about signing.
25 |
26 | //[assembly: AssemblyDelaySign(false)]
27 | //[assembly: AssemblyKeyFile("")]
28 |
29 |
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.UWP/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("MobileAppDocDBOfflineSyncSample")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("MobileAppDocDBOfflineSyncSample")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Version information for an assembly consists of the following four values:
18 | //
19 | // Major Version
20 | // Minor Version
21 | // Build Number
22 | // Revision
23 | //
24 | // You can specify all the values or you can default the Build and Revision Numbers
25 | // by using the '*' as shown below:
26 | // [assembly: AssemblyVersion("1.0.*")]
27 | [assembly: AssemblyVersion("1.0.0.0")]
28 | [assembly: AssemblyFileVersion("1.0.0.0")]
29 | [assembly: ComVisible(false)]
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.Shared/DataModel/ComplexItem.cs:
--------------------------------------------------------------------------------
1 |
2 | using Newtonsoft.Json;
3 |
4 | using System;
5 | using System.Collections.Generic;
6 |
7 | namespace MobileAppDocDBOfflineSyncSample.Shared.DataModel
8 | {
9 | public class ComplexItem
10 | {
11 | [JsonProperty(PropertyName = "text")]
12 | public string Text { get; set; }
13 |
14 | [JsonProperty(PropertyName = "complete")]
15 | public bool Complete { get; set; }
16 |
17 | [JsonProperty(PropertyName = "nestedItems")]
18 | public ICollection NestedItems { get; set; }
19 |
20 | public string Id { get; set; }
21 |
22 | [JsonProperty(PropertyName = "nested")]
23 | public NestedItem Nested { get; set; }
24 |
25 | [JsonProperty(PropertyName = "version")]
26 | public byte[] Version { get; set; }
27 |
28 | [JsonProperty(PropertyName = "createdAt")]
29 | public DateTimeOffset? CreatedAt { get; set; }
30 |
31 | [JsonProperty(PropertyName = "updatedAt")]
32 | public DateTimeOffset? UpdatedAt { get; set; }
33 |
34 | [JsonProperty(PropertyName = "deleted")]
35 | public bool Deleted { get; set; }
36 |
37 |
38 | }
39 | }
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.Shared/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Resources;
2 | using System.Reflection;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 |
6 | // General Information about an assembly is controlled through the following
7 | // set of attributes. Change these attribute values to modify the information
8 | // associated with an assembly.
9 | [assembly: AssemblyTitle("MobileAppDocDBOfflineSyncSample.Shared")]
10 | [assembly: AssemblyDescription("")]
11 | [assembly: AssemblyConfiguration("")]
12 | [assembly: AssemblyCompany("AkzoNobel")]
13 | [assembly: AssemblyProduct("MobileAppDocDBOfflineSyncSample.Shared")]
14 | [assembly: AssemblyCopyright("Copyright © AkzoNobel 2017")]
15 | [assembly: AssemblyTrademark("")]
16 | [assembly: AssemblyCulture("")]
17 | [assembly: NeutralResourcesLanguage("en")]
18 |
19 | // Version information for an assembly consists of the following four values:
20 | //
21 | // Major Version
22 | // Minor Version
23 | // Build Number
24 | // Revision
25 | //
26 | // You can specify all the values or you can default the Build and Revision Numbers
27 | // by using the '*' as shown below:
28 | // [assembly: AssemblyVersion("1.0.*")]
29 | [assembly: AssemblyVersion("1.0.0.0")]
30 | [assembly: AssemblyFileVersion("1.0.0.0")]
31 |
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.API/Web.Debug.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.UWP/Properties/Default.rd.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
19 |
20 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.API/Web.Release.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
19 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.API/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("MobileAppDocDBOfflineSyncSampleService")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("MobileAppDocDBOfflineSyncSampleService")]
13 | [assembly: AssemblyCopyright("Copyright © 2014")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("2e8cfaa1-3743-49ef-9e21-2926ca18c058")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Revision and Build Numbers
33 | // by using the '*' as shown below:
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.API/App_Start/Startup.Swagger.cs:
--------------------------------------------------------------------------------
1 | using System.Web.Http;
2 |
3 | using System.Web.Http.Description;
4 |
5 | using Microsoft.Azure.Mobile.Server;
6 |
7 | using Microsoft.Azure.Mobile.Server.Swagger;
8 |
9 | using Swashbuckle.Application;
10 |
11 |
12 |
13 | namespace MobileAppDocDBOfflineSyncSample.API
14 |
15 | {
16 |
17 | public partial class Startup
18 |
19 | {
20 |
21 | public static void ConfigureSwagger(HttpConfiguration config)
22 |
23 | {
24 |
25 | // Use the custom ApiExplorer that applies constraints. This prevents
26 |
27 | // duplicate routes on /api and /tables from showing in the Swagger doc.
28 |
29 | config.Services.Replace(typeof(IApiExplorer), new MobileAppApiExplorer(config));
30 |
31 | config
32 |
33 | .EnableSwagger(c =>
34 |
35 | {
36 |
37 | c.SingleApiVersion("v1", "myService");
38 |
39 |
40 |
41 | // Tells the Swagger doc that any MobileAppController needs a
42 |
43 | // ZUMO-API-VERSION header with default 2.0.0
44 |
45 | c.OperationFilter();
46 |
47 |
48 |
49 | // Looks at attributes on properties to decide whether they are readOnly.
50 |
51 | // Right now, this only applies to the DatabaseGeneratedAttribute.
52 |
53 | c.SchemaFilter();
54 |
55 | })
56 |
57 | .EnableSwaggerUi();
58 |
59 | }
60 |
61 | }
62 |
63 | }
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.API/Helpers/QueryableExpandAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using System.Net.Http;
4 | using System.Web.Http.Controllers;
5 | using System.Web.Http.Filters;
6 |
7 | public class QueryableExpandAttribute : ActionFilterAttribute
8 | {
9 | private const string ODataExpandOption = "$expand=";
10 |
11 | public QueryableExpandAttribute(string expand)
12 | {
13 | this.AlwaysExpand = expand;
14 | }
15 |
16 | public string AlwaysExpand { get; set; }
17 |
18 | public override void OnActionExecuting(HttpActionContext actionContext)
19 | {
20 | HttpRequestMessage request = actionContext.Request;
21 | string query = request.RequestUri.Query.Substring(1);
22 | var parts = query.Split('&').ToList();
23 | bool foundExpand = false;
24 | for (int i = 0; i < parts.Count; i++)
25 | {
26 | string segment = parts[i];
27 | if (segment.StartsWith(ODataExpandOption, StringComparison.Ordinal))
28 | {
29 | foundExpand = true;
30 | parts[i] += "," + this.AlwaysExpand;
31 | break;
32 | }
33 | }
34 |
35 | if (!foundExpand)
36 | {
37 | parts.Add(ODataExpandOption + this.AlwaysExpand);
38 | }
39 |
40 | UriBuilder modifiedRequestUri = new UriBuilder(request.RequestUri);
41 | modifiedRequestUri.Query = string.Join("&",
42 | parts.Where(p => p.Length > 0));
43 | request.RequestUri = modifiedRequestUri.Uri;
44 | base.OnActionExecuting(actionContext);
45 | }
46 | }
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.UWP/Package.appxmanifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | MobileAppDocDBOfflineSync
7 | karolzak
8 | Assets\StoreLogo.png
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.iOS/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | UIDeviceFamily
6 |
7 | 1
8 | 2
9 |
10 | UISupportedInterfaceOrientations
11 |
12 | UIInterfaceOrientationPortrait
13 | UIInterfaceOrientationLandscapeLeft
14 | UIInterfaceOrientationLandscapeRight
15 |
16 | UISupportedInterfaceOrientations~ipad
17 |
18 | UIInterfaceOrientationPortrait
19 |
20 | UIMainStoryboardFile
21 | MainStoryboard_iPhone
22 | UIMainStoryboardFile~ipad
23 | MainStoryboard_iPad
24 | MinimumOSVersion
25 | 7.0
26 | CFBundleIconFiles
27 |
28 | Icon-72@2x.png
29 | Icon-72.png
30 | Icon@2x.png
31 | Icon.png
32 | Default.png
33 | Default@2x.png
34 | Default-568h@2x.png
35 | Default-Landscape.png
36 | Default-Landscape@2x.png
37 | Default-Portrait.png
38 | Default-Portrait@2x.png
39 |
40 | CFBundleDisplayName
41 | MobileAppDocDBOfflineSyncSample
42 | CFBundleIdentifier
43 | net.azure-mobile.MobileAppDocDBOfflineSyncSample
44 | CFBundleVersion
45 | 1.0
46 | CFBundleShortVersionString
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.Droid/Resources/AboutResources.txt:
--------------------------------------------------------------------------------
1 | Images, layout descriptions, binary blobs and string dictionaries can be included
2 | in your application as resource files. Various Android APIs are designed to
3 | operate on the resource IDs instead of dealing with images, strings or binary blobs
4 | directly.
5 |
6 | For example, a sample Android app that contains a user interface layout (main.axml),
7 | an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png)
8 | would keep its resources in the "Resources" directory of the application:
9 |
10 | Resources/
11 | drawable/
12 | icon.png
13 |
14 | layout/
15 | main.axml
16 |
17 | values/
18 | strings.xml
19 |
20 | In order to get the build system to recognize Android resources, set the build action to
21 | "AndroidResource". The native Android APIs do not operate directly with filenames, but
22 | instead operate on resource IDs. When you compile an Android application that uses resources,
23 | the build system will package the resources for distribution and generate a class called "R"
24 | (this is an Android convention) that contains the tokens for each one of the resources
25 | included. For example, for the above Resources layout, this is what the R class would expose:
26 |
27 | public class R {
28 | public class drawable {
29 | public const int icon = 0x123;
30 | }
31 |
32 | public class layout {
33 | public const int main = 0x456;
34 | }
35 |
36 | public class strings {
37 | public const int first_string = 0xabc;
38 | public const int second_string = 0xbcd;
39 | }
40 | }
41 |
42 | You would then use R.drawable.icon to reference the drawable/icon.png file, or R.layout.main
43 | to reference the layout/main.axml file, or R.strings.first_string to reference the first
44 | string in the dictionary file values/strings.xml.
45 |
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.API/Controllers/TodoItemDocDbController.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Azure.Mobile.Server;
2 | using System.Configuration;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using System.Web.Http;
6 | using System.Web.Http.Controllers;
7 | using System.Web.Http.OData;
8 | using MobileAppDocDBOfflineSyncSampleService.DataObjects;
9 | using MobileAppDocDBOfflineSyncSampleService.Helpers;
10 |
11 | namespace MobileAppDocDBOfflineSyncSampleService.Controllers
12 | {
13 | public class TodoItemDocDbController : TableController
14 | {
15 | protected override void Initialize(HttpControllerContext controllerContext)
16 | {
17 | base.Initialize(controllerContext);
18 |
19 | string collectioName = ConfigurationManager.AppSettings["todoItemCollection"];
20 | string databaseId = ConfigurationManager.AppSettings["databaseId"];
21 |
22 | //Using Custom Domain Manager
23 | DomainManager = new DocumentDBDomainManager(collectioName, databaseId, Request);//, Services);
24 | }
25 |
26 |
27 | public IQueryable GetAllTodoItems()
28 | {
29 | return Query();
30 | }
31 |
32 | public SingleResult GetTodoItem(string id)
33 | {
34 | return Lookup(id);
35 | }
36 |
37 | public Task PatchTodoItem(string id, Delta patch)
38 | {
39 | return UpdateAsync(id, patch);
40 | }
41 |
42 | public async Task PostTodoItem(TodoItemDocDb item)
43 | {
44 | TodoItemDocDb current = await InsertAsync(item);
45 | return CreatedAtRoute("Tables", new { id = current.Id }, current);
46 | }
47 |
48 | public Task DeleteTodoItem(string id)
49 | {
50 | return DeleteAsync(id);
51 | }
52 | }
53 | }
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.API/Controllers/ComplexItemController.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Azure.Mobile.Server;
2 | using System.Configuration;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using System.Web.Http;
6 | using System.Web.Http.Controllers;
7 | using System.Web.Http.OData;
8 | using MobileAppDocDBOfflineSyncSampleService.DataObjects;
9 | using MobileAppDocDBOfflineSyncSampleService.Helpers;
10 |
11 | namespace MobileAppDocDBOfflineSyncSampleService.Controllers
12 | {
13 | public class ComplexItemController : TableController
14 | {
15 | protected override void Initialize(HttpControllerContext controllerContext)
16 | {
17 | base.Initialize(controllerContext);
18 |
19 | string collectioName = ConfigurationManager.AppSettings["complexItemCollection"];
20 | string databaseId = ConfigurationManager.AppSettings["databaseId"];
21 |
22 | //Using Custom Domain Manager
23 | DomainManager = new DocumentDBDomainManager(collectioName, databaseId, Request);//, Services);
24 | }
25 |
26 |
27 | [QueryableExpand("Nested")]
28 | [QueryableExpand("NestedItems")]
29 |
30 | public IQueryable GetAllTodoItems()
31 | {
32 | var q = Query();
33 | return q;
34 | }
35 |
36 | public SingleResult GetTodoItem(string id)
37 | {
38 | return Lookup(id);
39 | }
40 |
41 | public Task PatchTodoItem(string id, Delta patch)
42 | {
43 | return UpdateAsync(id, patch);
44 | }
45 |
46 | public async Task PostTodoItem(ComplexItem item)
47 | {
48 | ComplexItem current = await InsertAsync(item);
49 | return CreatedAtRoute("Tables", new { id = current.Id }, current);
50 | }
51 |
52 | public Task DeleteTodoItem(string id)
53 | {
54 | return DeleteAsync(id);
55 | }
56 | }
57 | }
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.Droid/Resources/layout/Activity_To_Do.axml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
13 |
21 |
22 |
27 |
34 |
35 |
36 |
42 |
43 |
49 |
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.UWP/Common/QuickStartTask.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
28 |
29 |
30 |
31 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.API/App_Start/Startup.MobileApp.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Data.Entity;
5 | using System.Web.Http;
6 | using Microsoft.Azure.Mobile.Server;
7 | using Microsoft.Azure.Mobile.Server.Authentication;
8 | using Microsoft.Azure.Mobile.Server.Config;
9 | using MobileAppDocDBOfflineSyncSampleService.DataObjects;
10 | //using MobileAppDocDBOfflineSyncSampleService.Models;
11 | using Owin;
12 |
13 | namespace MobileAppDocDBOfflineSyncSample.API
14 | {
15 | public partial class Startup
16 | {
17 | public static void ConfigureMobileApp(IAppBuilder app)
18 | {
19 |
20 | HttpConfiguration config = new HttpConfiguration();
21 |
22 |
23 |
24 | //For more information on Web API tracing, see http://go.microsoft.com/fwlink/?LinkId=620686
25 |
26 | config.EnableSystemDiagnosticsTracing();
27 |
28 |
29 |
30 | new MobileAppConfiguration()
31 |
32 | .UseDefaultConfiguration()
33 |
34 | .ApplyTo(config);
35 |
36 |
37 |
38 | // To prevent Entity Framework from modifying your database schema, use a null database initializer
39 |
40 | // Database.SetInitializer(null);
41 |
42 |
43 |
44 | MobileAppSettingsDictionary settings = config.GetMobileAppSettingsProvider().GetMobileAppSettings();
45 |
46 |
47 |
48 | if (string.IsNullOrEmpty(settings.HostName))
49 |
50 | {
51 |
52 | // This middleware is intended to be used locally for debugging. By default, HostName will
53 |
54 | // only have a value when running in an App Service application.
55 |
56 | app.UseAppServiceAuthentication(new AppServiceAuthenticationOptions
57 |
58 | {
59 |
60 | SigningKey = ConfigurationManager.AppSettings["SigningKey"],
61 |
62 | ValidAudiences = new[] { ConfigurationManager.AppSettings["ValidAudience"] },
63 |
64 | ValidIssuers = new[] { ConfigurationManager.AppSettings["ValidIssuer"] },
65 |
66 | TokenHandler = config.GetAppServiceTokenHandler()
67 |
68 | });
69 |
70 | }
71 |
72 | app.UseWebApi(config);
73 |
74 |
75 |
76 | ConfigureSwagger(config);
77 | }
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.Droid/ToDoItemDocDbAdapter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Android.App;
3 | using Android.Views;
4 | using Android.Widget;
5 | using System.Collections.Generic;
6 | using MobileAppDocDBOfflineSyncSample.Shared.DataModel;
7 |
8 | namespace MobileAppDocDBOfflineSyncSample.Droid
9 | {
10 | public class ToDoItemDocDbAdapter : BaseAdapter
11 | {
12 | Activity activity;
13 | int layoutResourceId;
14 | List items = new List ();
15 |
16 | public ToDoItemDocDbAdapter(Activity activity, int layoutResourceId)
17 | {
18 | this.activity = activity;
19 | this.layoutResourceId = layoutResourceId;
20 | }
21 |
22 | //Returns the view for a specific item on the list
23 | public override View GetView (int position, Android.Views.View convertView, Android.Views.ViewGroup parent)
24 | {
25 | var row = convertView;
26 | var currentItem = this [position];
27 | CheckBox checkBox;
28 |
29 | if (row == null) {
30 | var inflater = activity.LayoutInflater;
31 | row = inflater.Inflate (layoutResourceId, parent, false);
32 |
33 | checkBox = row.FindViewById (Resource.Id.checkToDoItem);
34 |
35 | checkBox.CheckedChange += async (sender, e) => {
36 | var cbSender = sender as CheckBox;
37 | if (cbSender != null && cbSender.Tag is ToDoItemDocDbWrapper && cbSender.Checked) {
38 | cbSender.Enabled = false;
39 | if (activity is ToDoActivity)
40 | await ((ToDoActivity)activity).CheckItem ((cbSender.Tag as ToDoItemDocDbWrapper).ToDoItem);
41 | }
42 | };
43 | } else
44 | checkBox = row.FindViewById (Resource.Id.checkToDoItem);
45 |
46 | checkBox.Text = currentItem.Text;
47 | checkBox.Checked = false;
48 | checkBox.Enabled = true;
49 | checkBox.Tag = new ToDoItemDocDbWrapper (currentItem);
50 |
51 | return row;
52 | }
53 |
54 | public void Add (ToDoItemDocDb item)
55 | {
56 | items.Add (item);
57 | NotifyDataSetChanged ();
58 | }
59 |
60 | public void Clear ()
61 | {
62 | items.Clear ();
63 | NotifyDataSetChanged ();
64 | }
65 |
66 | public void Remove (ToDoItemDocDb item)
67 | {
68 | items.Remove (item);
69 | NotifyDataSetChanged ();
70 | }
71 |
72 | #region implemented abstract members of BaseAdapter
73 |
74 | public override long GetItemId (int position)
75 | {
76 | return position;
77 | }
78 |
79 | public override int Count {
80 | get {
81 | return items.Count;
82 | }
83 | }
84 |
85 | public override ToDoItemDocDb this [int position] {
86 | get {
87 | return items [position];
88 | }
89 | }
90 |
91 | #endregion
92 | }
93 | }
94 |
95 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | # Azure Mobile Apps using DocumentDb + Incremental and offline sync
3 |
4 | This is a proof of concept project where we tight up a DocumentDB instance with complex (nested) types with several SQLite mobile clients using Azure Mobile Apps with Offline Sync. In this project we are trying to achieve following features:
5 |
6 | - [x] Accessing data from DocumentDB on mobile clients through Azure Mobile Apps
7 | - [x] Ability for mobile clients to work with downloaded data in offline mode
8 | - [x] Incremental sync on client to download only updated/added/data (limits the data transfer)
9 | - [x] Support for flat DocumentDB objects
10 | - [ ] Support for more complex nested objects
11 |
12 |
13 | Key points:
14 | - [Custom DomainManager for TableController](https://github.com/karolzak/Mobile-App-DocumentDB-OfflineSync-Sample/blob/master/MobileAppDocDBOfflineSyncSample.API/Helpers/DocumentDBDomainManager.cs) - it allows us to sync data on client through Azure Mobile Apps Tables to work with DocumentDB objects
15 | - Azure Mobile Apps client SDK with offline sync configuration uses "createdAt" and "updatedAt" attributes to determine which objects needs to be synced. [THESE ARE CASE SENSITIVE!!](https://github.com/karolzak/Mobile-App-DocumentDB-OfflineSync-Sample/blob/master/MobileAppDocDBOfflineSyncSample.API/Helpers/DocumentResource.cs) We learned it the hard way...
16 | - At this point of time (16.01.2017), Azure Mobile Apps client SDK offline sync feature works only for flat objects. It's not suitable for more complex and nested types
17 | - Best we could achieve was to implement offline sync for level 1 nested objects similar to this:
18 | ```JSON
19 | {
20 | "text": "Mew task ios",
21 | "nested": {
22 | "nestedText": "144 J B Hazra Road",
23 | "nestedBool": "false"
24 | },
25 | "nestedItems": [
26 | {
27 | "nestedText": "xxoxoxoxoxox",
28 | "nestedBool": "true"
29 | }
30 | ],
31 | "complete": true,
32 | "id": "8d16700a-fcc0-4453-b740-e3eef8c0c340",
33 | "version": null,
34 | "createdat": "2017-01-11T12:27:24.1394782+00:00",
35 | "updatedat": "2017-01-11T14:24:03.4335527+00:00",
36 | "deleted": false
37 | }
38 | ```
39 | Unfortunately, nested objects/collections can only be stored as strings/JSON in SQLite store on mobile client:
40 | 
41 |
42 | We achieved this by implementing a [custom Expand attribute](https://github.com/karolzak/Mobile-App-DocumentDB-OfflineSync-Sample/blob/master/MobileAppDocDBOfflineSyncSample.API/Helpers/QueryableExpandAttribute.cs) to include nested objects when sending data from Azure Mobile App to client.
43 | We used it in our TableController [here](https://github.com/karolzak/Mobile-App-DocumentDB-OfflineSync-Sample/blob/master/MobileAppDocDBOfflineSyncSample.API/Controllers/ComplexItemController.cs#27)
44 |
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.Shared/MobileAppDocDBOfflineSyncSample.Shared.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 10.0
6 | Debug
7 | AnyCPU
8 | {A37F4160-6F2D-433E-A5F3-29AC70BFBAF7}
9 | Library
10 | Properties
11 | MobileAppDocDBOfflineSyncSample.Shared
12 | MobileAppDocDBOfflineSyncSample.Shared
13 | en-US
14 | 512
15 | {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
16 | Profile111
17 | v4.5
18 |
19 |
20 | true
21 | full
22 | false
23 | bin\Debug\
24 | DEBUG;TRACE
25 | prompt
26 | 4
27 |
28 |
29 | pdbonly
30 | true
31 | bin\Release\
32 | TRACE
33 | prompt
34 | 4
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 | ..\packages\Newtonsoft.Json.9.0.1\lib\portable-net45+wp80+win8+wpa81\Newtonsoft.Json.dll
46 | True
47 |
48 |
49 |
50 |
51 |
52 |
53 |
60 |
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.API/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.UWP/Common/QuickStartTask.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using Windows.Foundation;
6 | using Windows.Foundation.Collections;
7 | using Windows.UI.Xaml;
8 | using Windows.UI.Xaml.Controls;
9 | using Windows.UI.Xaml.Controls.Primitives;
10 | using Windows.UI.Xaml.Data;
11 | using Windows.UI.Xaml.Input;
12 | using Windows.UI.Xaml.Media;
13 | using Windows.UI.Xaml.Navigation;
14 |
15 | // The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236
16 |
17 | namespace MobileAppDocDBOfflineSyncSample
18 | {
19 | public sealed partial class QuickStartTask : UserControl
20 | {
21 | public QuickStartTask()
22 | {
23 | this.InitializeComponent();
24 | this.DataContext = this;
25 | }
26 |
27 | public int Number
28 | {
29 | get { return (int)GetValue(NumberProperty); }
30 | set { SetValue(NumberProperty, value); }
31 | }
32 |
33 | // Using a DependencyProperty as the backing store for Number. This enables animation, styling, binding, etc...
34 | public static readonly DependencyProperty NumberProperty =
35 | DependencyProperty.Register("Number", typeof(int), typeof(QuickStartTask), new PropertyMetadata(0));
36 |
37 | public string Title
38 | {
39 | get { return (string)GetValue(TitleProperty); }
40 | set { SetValue(TitleProperty, value); }
41 | }
42 |
43 | // Using a DependencyProperty as the backing store for Title. This enables animation, styling, binding, etc...
44 | public static readonly DependencyProperty TitleProperty =
45 | DependencyProperty.Register("Title", typeof(string), typeof(QuickStartTask), new PropertyMetadata(default(string)));
46 |
47 | public string Description
48 | {
49 | get { return (string)GetValue(DescriptionProperty); }
50 | set { SetValue(DescriptionProperty, value); }
51 | }
52 |
53 | // Using a DependencyProperty as the backing store for Description. This enables animation, styling, binding, etc...
54 | public static readonly DependencyProperty DescriptionProperty =
55 | DependencyProperty.Register("Description", typeof(string), typeof(QuickStartTask), new PropertyMetadata(default(string)));
56 |
57 | public Visibility LayoutFormatVisibility = Visibility.Visible;
58 |
59 | public bool ShowMinimal
60 | {
61 | get { return (bool)GetValue(ShowMinimalProperty); }
62 | set {
63 | SetValue(ShowMinimalProperty, value);
64 | }
65 | }
66 |
67 | // Using a DependencyProperty as the backing store for ShowMinimal. This enables animation, styling, binding, etc...
68 | public static readonly DependencyProperty ShowMinimalProperty =
69 | DependencyProperty.Register("ShowMinimal", typeof(bool), typeof(QuickStartTask), new PropertyMetadata(false, new PropertyChangedCallback(ChangeShowMinimal)));
70 |
71 | private static void ChangeShowMinimal(DependencyObject source, DependencyPropertyChangedEventArgs e)
72 | {
73 | (source as QuickStartTask).LayoutFormatVisibility = ((bool)e.NewValue == true) ? Visibility.Collapsed : Visibility.Visible;
74 | (source as QuickStartTask).Bindings.Update();
75 | }
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.UWP/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.WindowsAzure.MobileServices;
2 | using System;
3 | using Windows.ApplicationModel;
4 | using Windows.ApplicationModel.Activation;
5 | using Windows.UI.Xaml;
6 | using Windows.UI.Xaml.Controls;
7 | using Windows.UI.Xaml.Navigation;
8 |
9 | namespace MobileAppDocDBOfflineSyncSample
10 | {
11 | ///
12 | /// Provides application-specific behavior to supplement the default Application class.
13 | ///
14 | sealed partial class App : Application
15 | {
16 | // This MobileServiceClient has been configured to communicate with the Azure Mobile Service and
17 | // Azure Gateway using the application key. You're all set to start working with your Mobile Service!
18 | public static MobileServiceClient MobileService = new MobileServiceClient(
19 | "https://XamarinMobileService.azurewebsites.net"
20 | );
21 | //public static MobileServiceClient MobileService = new MobileServiceClient(
22 | // "http://localhost:50010/"
23 | //);
24 |
25 | ///
26 | /// Initializes the singleton application object. This is the first line of authored code
27 | /// executed, and as such is the logical equivalent of main() or WinMain().
28 | ///
29 | public App()
30 | {
31 | this.InitializeComponent();
32 | this.Suspending += OnSuspending;
33 | }
34 |
35 | ///
36 | /// Invoked when the application is launched normally by the end user. Other entry points
37 | /// will be used such as when the application is launched to open a specific file.
38 | ///
39 | /// Details about the launch request and process.
40 | protected override void OnLaunched(LaunchActivatedEventArgs e)
41 | {
42 |
43 | #if DEBUG
44 | if (System.Diagnostics.Debugger.IsAttached)
45 | {
46 | this.DebugSettings.EnableFrameRateCounter = true;
47 | }
48 | #endif
49 |
50 | Frame rootFrame = Window.Current.Content as Frame;
51 |
52 | // Do not repeat app initialization when the Window already has content,
53 | // just ensure that the window is active
54 | if (rootFrame == null)
55 | {
56 | // Create a Frame to act as the navigation context and navigate to the first page
57 | rootFrame = new Frame();
58 |
59 | rootFrame.NavigationFailed += OnNavigationFailed;
60 |
61 | if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
62 | {
63 | //TODO: Load state from previously suspended application
64 | }
65 |
66 | // Place the frame in the current Window
67 | Window.Current.Content = rootFrame;
68 | }
69 |
70 | if (rootFrame.Content == null)
71 | {
72 | // When the navigation stack isn't restored navigate to the first page,
73 | // configuring the new page by passing required information as a navigation
74 | // parameter
75 | rootFrame.Navigate(typeof(MainPage), e.Arguments);
76 | }
77 | // Ensure the current window is active
78 | Window.Current.Activate();
79 | }
80 |
81 | ///
82 | /// Invoked when Navigation to a certain page fails
83 | ///
84 | /// The Frame which failed navigation
85 | /// Details about the navigation failure
86 | void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
87 | {
88 | throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
89 | }
90 |
91 | ///
92 | /// Invoked when application execution is being suspended. Application state is saved
93 | /// without knowing whether the application will be terminated or resumed with the contents
94 | /// of memory still intact.
95 | ///
96 | /// The source of the suspend request.
97 | /// Details about the suspend request.
98 | private void OnSuspending(object sender, SuspendingEventArgs e)
99 | {
100 | var deferral = e.SuspendingOperation.GetDeferral();
101 | //TODO: Save application state and stop any background activity
102 | deferral.Complete();
103 | }
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.Droid/Resources/Resource.designer.cs:
--------------------------------------------------------------------------------
1 | #pragma warning disable 1591
2 | //------------------------------------------------------------------------------
3 | //
4 | // This code was generated by a tool.
5 | // Runtime Version:4.0.30319.42000
6 | //
7 | // Changes to this file may cause incorrect behavior and will be lost if
8 | // the code is regenerated.
9 | //
10 | //------------------------------------------------------------------------------
11 |
12 | [assembly: global::Android.Runtime.ResourceDesignerAttribute("MobileAppDocDBOfflineSyncSample.Droid.Resource", IsApplication=true)]
13 |
14 | namespace MobileAppDocDBOfflineSyncSample.Droid
15 | {
16 |
17 |
18 | [System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "1.0.0.0")]
19 | public partial class Resource
20 | {
21 |
22 | static Resource()
23 | {
24 | global::Android.Runtime.ResourceIdManager.UpdateIdValues();
25 | }
26 |
27 | public static void UpdateIdValues()
28 | {
29 | }
30 |
31 | public partial class Attribute
32 | {
33 |
34 | static Attribute()
35 | {
36 | global::Android.Runtime.ResourceIdManager.UpdateIdValues();
37 | }
38 |
39 | private Attribute()
40 | {
41 | }
42 | }
43 |
44 | public partial class Drawable
45 | {
46 |
47 | // aapt resource value: 0x7f020000
48 | public const int ic_launcher = 2130837504;
49 |
50 | static Drawable()
51 | {
52 | global::Android.Runtime.ResourceIdManager.UpdateIdValues();
53 | }
54 |
55 | private Drawable()
56 | {
57 | }
58 | }
59 |
60 | public partial class Id
61 | {
62 |
63 | // aapt resource value: 0x7f070000
64 | public const int LinearLayout1 = 2131165184;
65 |
66 | // aapt resource value: 0x7f070003
67 | public const int buttonAddToDo = 2131165187;
68 |
69 | // aapt resource value: 0x7f070005
70 | public const int checkToDoItem = 2131165189;
71 |
72 | // aapt resource value: 0x7f070004
73 | public const int listViewToDo = 2131165188;
74 |
75 | // aapt resource value: 0x7f070006
76 | public const int menu_refresh = 2131165190;
77 |
78 | // aapt resource value: 0x7f070002
79 | public const int textNewToDo = 2131165186;
80 |
81 | // aapt resource value: 0x7f070001
82 | public const int textViewTitle = 2131165185;
83 |
84 | static Id()
85 | {
86 | global::Android.Runtime.ResourceIdManager.UpdateIdValues();
87 | }
88 |
89 | private Id()
90 | {
91 | }
92 | }
93 |
94 | public partial class Layout
95 | {
96 |
97 | // aapt resource value: 0x7f030000
98 | public const int Activity_To_Do = 2130903040;
99 |
100 | // aapt resource value: 0x7f030001
101 | public const int Row_List_To_Do = 2130903041;
102 |
103 | static Layout()
104 | {
105 | global::Android.Runtime.ResourceIdManager.UpdateIdValues();
106 | }
107 |
108 | private Layout()
109 | {
110 | }
111 | }
112 |
113 | public partial class Menu
114 | {
115 |
116 | // aapt resource value: 0x7f060000
117 | public const int activity_main = 2131099648;
118 |
119 | static Menu()
120 | {
121 | global::Android.Runtime.ResourceIdManager.UpdateIdValues();
122 | }
123 |
124 | private Menu()
125 | {
126 | }
127 | }
128 |
129 | public partial class String
130 | {
131 |
132 | // aapt resource value: 0x7f040002
133 | public const int add_button_text = 2130968578;
134 |
135 | // aapt resource value: 0x7f040001
136 | public const int add_textbox_hint = 2130968577;
137 |
138 | // aapt resource value: 0x7f040000
139 | public const int app_name = 2130968576;
140 |
141 | // aapt resource value: 0x7f040005
142 | public const int checkbox_text = 2130968581;
143 |
144 | // aapt resource value: 0x7f040004
145 | public const int menu_refresh = 2130968580;
146 |
147 | // aapt resource value: 0x7f040003
148 | public const int mobile_services = 2130968579;
149 |
150 | static String()
151 | {
152 | global::Android.Runtime.ResourceIdManager.UpdateIdValues();
153 | }
154 |
155 | private String()
156 | {
157 | }
158 | }
159 |
160 | public partial class Style
161 | {
162 |
163 | // aapt resource value: 0x7f050000
164 | public const int AppBaseTheme = 2131034112;
165 |
166 | // aapt resource value: 0x7f050001
167 | public const int AppTheme = 2131034113;
168 |
169 | static Style()
170 | {
171 | global::Android.Runtime.ResourceIdManager.UpdateIdValues();
172 | }
173 |
174 | private Style()
175 | {
176 | }
177 | }
178 | }
179 | }
180 | #pragma warning restore 1591
181 |
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.iOS/QSTodoService.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * To add Offline Sync Support:
3 | * 1) Add the NuGet package Microsoft.Azure.Mobile.Client.SQLiteStore (and dependencies) to all client projects
4 | * 2) Uncomment the #define OFFLINE_SYNC_ENABLED
5 | *
6 | * For more information, see: http://go.microsoft.com/fwlink/?LinkId=717898
7 | */
8 | #define OFFLINE_SYNC_ENABLED
9 |
10 | using System;
11 | using System.Net.Http;
12 | using System.Threading.Tasks;
13 | using System.Collections.Generic;
14 | using Microsoft.WindowsAzure.MobileServices;
15 |
16 | using Microsoft.WindowsAzure.MobileServices.SQLiteStore; // offline sync
17 | using Microsoft.WindowsAzure.MobileServices.Sync; // offline sync
18 | using MobileAppDocDBOfflineSyncSample.Shared.DataModel;
19 |
20 | namespace MobileAppDocDBOfflineSyncSample.iOS
21 | {
22 | public class QSTodoService
23 | {
24 | static QSTodoService instance = new QSTodoService ();
25 |
26 | const string applicationURL = @"https://XamarinMobileService.azurewebsites.net";
27 |
28 | private MobileServiceClient client;
29 | const string localDbPath = "localstore.db";
30 |
31 | private IMobileServiceSyncTable todoTable;
32 |
33 | private QSTodoService ()
34 | {
35 | CurrentPlatform.Init();
36 |
37 | // Initialize the client with the mobile app backend URL.
38 | client = new MobileServiceClient(applicationURL);
39 |
40 | // Initialize the store
41 | InitializeStoreAsync().Wait();
42 |
43 | // Create an MSTable instance to allow us to work with the TodoItem table
44 | todoTable = client.GetSyncTable();
45 | }
46 |
47 | public static QSTodoService DefaultService {
48 | get {
49 | return instance;
50 | }
51 | }
52 |
53 | public List Items { get; private set;}
54 |
55 | public async Task InitializeStoreAsync()
56 | {
57 | var store = new MobileServiceSQLiteStore(localDbPath);
58 | store.DefineTable();
59 |
60 | // Uses the default conflict handler, which fails on conflict
61 | // To use a different conflict handler, pass a parameter to InitializeAsync.
62 | // For more details, see http://go.microsoft.com/fwlink/?LinkId=521416
63 | await client.SyncContext.InitializeAsync(store);
64 |
65 | }
66 |
67 | public async Task SyncAsync(bool pullData = false)
68 | {
69 | try
70 | {
71 | await client.SyncContext.PushAsync();
72 |
73 | if (pullData) {
74 | await todoTable.PullAsync("allTodoItems", todoTable.CreateQuery()); // query ID is used for incremental sync
75 | }
76 | }
77 |
78 | catch (MobileServiceInvalidOperationException e)
79 | {
80 | Console.Error.WriteLine(@"Sync Failed: {0}", e.Message);
81 | }
82 | }
83 |
84 | public async Task> RefreshDataAsync ()
85 | {
86 | try {
87 | // Update the local store
88 | await SyncAsync(pullData: true);
89 |
90 | // This code refreshes the entries in the list view by querying the local TodoItems table.
91 | // The query excludes completed TodoItems
92 | Items = await todoTable
93 | .Where (todoItem => todoItem.Complete == false).ToListAsync ();
94 |
95 | } catch (MobileServiceInvalidOperationException e) {
96 | Console.Error.WriteLine (@"ERROR {0}", e.Message);
97 | return null;
98 | }
99 |
100 | return Items;
101 | }
102 |
103 | public async Task InsertTodoItemAsync (ToDoItemDocDb todoItem)
104 | {
105 | try {
106 | await todoTable.InsertAsync (todoItem); // Insert a new TodoItem into the local database.
107 | #if OFFLINE_SYNC_ENABLED
108 | await SyncAsync(); // Send changes to the mobile app backend.
109 | #endif
110 |
111 | Items.Add (todoItem);
112 |
113 | } catch (MobileServiceInvalidOperationException e) {
114 | Console.Error.WriteLine (@"ERROR {0}", e.Message);
115 | }
116 | }
117 |
118 | public async Task CompleteItemAsync (ToDoItemDocDb item)
119 | {
120 | try {
121 | item.Complete = true;
122 | await todoTable.UpdateAsync (item); // Update todo item in the local database
123 | await SyncAsync(); // Send changes to the mobile app backend.
124 |
125 |
126 | Items.Remove (item);
127 |
128 | } catch (MobileServiceInvalidOperationException e) {
129 | Console.Error.WriteLine (@"ERROR {0}", e.Message);
130 | }
131 | }
132 | }
133 | }
134 |
135 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | x64/
19 | x86/
20 | bld/
21 | [Bb]in/
22 | [Oo]bj/
23 | [Ll]og/
24 |
25 | # Visual Studio 2015 cache/options directory
26 | .vs/
27 | # Uncomment if you have tasks that create the project's static files in wwwroot
28 | #wwwroot/
29 |
30 | # MSTest test Results
31 | [Tt]est[Rr]esult*/
32 | [Bb]uild[Ll]og.*
33 |
34 | # NUNIT
35 | *.VisualState.xml
36 | TestResult.xml
37 |
38 | # Build Results of an ATL Project
39 | [Dd]ebugPS/
40 | [Rr]eleasePS/
41 | dlldata.c
42 |
43 | # DNX
44 | project.lock.json
45 | artifacts/
46 |
47 | *_i.c
48 | *_p.c
49 | *_i.h
50 | *.ilk
51 | *.meta
52 | *.obj
53 | *.pch
54 | *.pdb
55 | *.pgc
56 | *.pgd
57 | *.rsp
58 | *.sbr
59 | *.tlb
60 | *.tli
61 | *.tlh
62 | *.tmp
63 | *.tmp_proj
64 | *.log
65 | *.vspscc
66 | *.vssscc
67 | .builds
68 | *.pidb
69 | *.svclog
70 | *.scc
71 |
72 | # Chutzpah Test files
73 | _Chutzpah*
74 |
75 | # Visual C++ cache files
76 | ipch/
77 | *.aps
78 | *.ncb
79 | *.opendb
80 | *.opensdf
81 | *.sdf
82 | *.cachefile
83 | *.VC.db
84 | *.VC.VC.opendb
85 |
86 | # Visual Studio profiler
87 | *.psess
88 | *.vsp
89 | *.vspx
90 | *.sap
91 |
92 | # TFS 2012 Local Workspace
93 | $tf/
94 |
95 | # Guidance Automation Toolkit
96 | *.gpState
97 |
98 | # ReSharper is a .NET coding add-in
99 | _ReSharper*/
100 | *.[Rr]e[Ss]harper
101 | *.DotSettings.user
102 |
103 | # JustCode is a .NET coding add-in
104 | .JustCode
105 |
106 | # TeamCity is a build add-in
107 | _TeamCity*
108 |
109 | # DotCover is a Code Coverage Tool
110 | *.dotCover
111 |
112 | # NCrunch
113 | _NCrunch_*
114 | .*crunch*.local.xml
115 | nCrunchTemp_*
116 |
117 | # MightyMoose
118 | *.mm.*
119 | AutoTest.Net/
120 |
121 | # Web workbench (sass)
122 | .sass-cache/
123 |
124 | # Installshield output folder
125 | [Ee]xpress/
126 |
127 | # DocProject is a documentation generator add-in
128 | DocProject/buildhelp/
129 | DocProject/Help/*.HxT
130 | DocProject/Help/*.HxC
131 | DocProject/Help/*.hhc
132 | DocProject/Help/*.hhk
133 | DocProject/Help/*.hhp
134 | DocProject/Help/Html2
135 | DocProject/Help/html
136 |
137 | # Click-Once directory
138 | publish/
139 |
140 | # Publish Web Output
141 | *.[Pp]ublish.xml
142 | *.azurePubxml
143 | # TODO: Comment the next line if you want to checkin your web deploy settings
144 | # but database connection strings (with potential passwords) will be unencrypted
145 | *.pubxml
146 | *.publishproj
147 |
148 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
149 | # checkin your Azure Web App publish settings, but sensitive information contained
150 | # in these scripts will be unencrypted
151 | PublishScripts/
152 |
153 | # NuGet Packages
154 | *.nupkg
155 | # The packages folder can be ignored because of Package Restore
156 | **/packages/*
157 | # except build/, which is used as an MSBuild target.
158 | !**/packages/build/
159 | # Uncomment if necessary however generally it will be regenerated when needed
160 | #!**/packages/repositories.config
161 | # NuGet v3's project.json files produces more ignoreable files
162 | *.nuget.props
163 | *.nuget.targets
164 |
165 | # Microsoft Azure Build Output
166 | csx/
167 | *.build.csdef
168 |
169 | # Microsoft Azure Emulator
170 | ecf/
171 | rcf/
172 |
173 | # Windows Store app package directories and files
174 | AppPackages/
175 | BundleArtifacts/
176 | Package.StoreAssociation.xml
177 | _pkginfo.txt
178 |
179 | # Visual Studio cache files
180 | # files ending in .cache can be ignored
181 | *.[Cc]ache
182 | # but keep track of directories ending in .cache
183 | !*.[Cc]ache/
184 |
185 | # Others
186 | ClientBin/
187 | ~$*
188 | *~
189 | *.dbmdl
190 | *.dbproj.schemaview
191 | *.pfx
192 | *.publishsettings
193 | node_modules/
194 | orleans.codegen.cs
195 |
196 | # Since there are multiple workflows, uncomment next line to ignore bower_components
197 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
198 | #bower_components/
199 |
200 | # RIA/Silverlight projects
201 | Generated_Code/
202 |
203 | # Backup & report files from converting an old project file
204 | # to a newer Visual Studio version. Backup files are not needed,
205 | # because we have git ;-)
206 | _UpgradeReport_Files/
207 | Backup*/
208 | UpgradeLog*.XML
209 | UpgradeLog*.htm
210 |
211 | # SQL Server files
212 | *.mdf
213 | *.ldf
214 |
215 | # Business Intelligence projects
216 | *.rdl.data
217 | *.bim.layout
218 | *.bim_*.settings
219 |
220 | # Microsoft Fakes
221 | FakesAssemblies/
222 |
223 | # GhostDoc plugin setting file
224 | *.GhostDoc.xml
225 |
226 | # Node.js Tools for Visual Studio
227 | .ntvs_analysis.dat
228 |
229 | # Visual Studio 6 build log
230 | *.plg
231 |
232 | # Visual Studio 6 workspace options file
233 | *.opt
234 |
235 | # Visual Studio LightSwitch build output
236 | **/*.HTMLClient/GeneratedArtifacts
237 | **/*.DesktopClient/GeneratedArtifacts
238 | **/*.DesktopClient/ModelManifest.xml
239 | **/*.Server/GeneratedArtifacts
240 | **/*.Server/ModelManifest.xml
241 | _Pvt_Extensions
242 |
243 | # Paket dependency manager
244 | .paket/paket.exe
245 | paket-files/
246 |
247 | # FAKE - F# Make
248 | .fake/
249 |
250 | # JetBrains Rider
251 | .idea/
252 | *.sln.iml
253 |
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.iOS/QSTodoListViewController.cs:
--------------------------------------------------------------------------------
1 | // This file has been autogenerated from parsing an Objective-C header file added in Xcode.
2 | using System;
3 | using UIKit;
4 | using Foundation;
5 | using System.Threading.Tasks;
6 | using MobileAppDocDBOfflineSyncSample.Shared.DataModel;
7 |
8 | namespace MobileAppDocDBOfflineSyncSample.iOS
9 | {
10 | public partial class QSTodoListViewController : UITableViewController
11 | {
12 | private QSTodoService todoService;
13 |
14 | public QSTodoListViewController (IntPtr handle) : base (handle)
15 | {
16 | }
17 |
18 | public override async void ViewDidLoad ()
19 | {
20 | base.ViewDidLoad ();
21 |
22 | todoService = QSTodoService.DefaultService;
23 | await todoService.InitializeStoreAsync ();
24 |
25 | RefreshControl.ValueChanged += async (sender, e) => {
26 | await RefreshAsync ();
27 | };
28 |
29 | await RefreshAsync ();
30 | }
31 |
32 | private async Task RefreshAsync ()
33 | {
34 | RefreshControl.BeginRefreshing ();
35 | await todoService.RefreshDataAsync ();
36 | RefreshControl.EndRefreshing ();
37 |
38 | TableView.ReloadData ();
39 | }
40 |
41 | #region UITableView methods
42 | public override nint RowsInSection (UITableView tableview, nint section)
43 | {
44 | if (todoService == null || todoService.Items == null)
45 | return 0;
46 |
47 | return todoService.Items.Count;
48 | }
49 |
50 | public override nint NumberOfSections (UITableView tableView)
51 | {
52 | return 1;
53 | }
54 |
55 | public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath)
56 | {
57 | const string CellIdentifier = @"Cell";
58 | var cell = tableView.DequeueReusableCell (CellIdentifier);
59 | if (cell == null) {
60 | cell = new UITableViewCell (UITableViewCellStyle.Default, CellIdentifier);
61 | }
62 |
63 | // Set the label on the cell and make sure the label color is black (in case this cell
64 | // has been reused and was previously greyed out
65 | var label = (UILabel)cell.ViewWithTag (1);
66 | label.TextColor = UIColor.Black;
67 | label.Text = todoService.Items [indexPath.Row].Text;
68 |
69 | return cell;
70 | }
71 |
72 | public override string TitleForDeleteConfirmation (UITableView tableView, NSIndexPath indexPath)
73 | {
74 | // Customize the Delete button to say "complete"
75 | return @"complete";
76 | }
77 |
78 | public override UITableViewCellEditingStyle EditingStyleForRow (UITableView tableView, NSIndexPath indexPath)
79 | {
80 | // Find the item that is about to be edited
81 | var item = todoService.Items [indexPath.Row];
82 |
83 | // If the item is complete, then this is just pending upload. Editing is not allowed
84 | if (item.Complete)
85 | return UITableViewCellEditingStyle.None;
86 |
87 | // Otherwise, allow the delete button to appear
88 | return UITableViewCellEditingStyle.Delete;
89 | }
90 |
91 | public async override void CommitEditingStyle (UITableView tableView, UITableViewCellEditingStyle editingStyle, NSIndexPath indexPath)
92 | {
93 | // Find item that was commited for editing (completed)
94 | var item = todoService.Items [indexPath.Row];
95 |
96 | // Change the appearance to look greyed out until we remove the item
97 | var label = (UILabel)TableView.CellAt (indexPath).ViewWithTag (1);
98 | label.TextColor = UIColor.Gray;
99 |
100 | // Ask the todoService to set the item's complete value to YES, and remove the row if successful
101 | await todoService.CompleteItemAsync (item);
102 |
103 | // Remove the row from the UITableView
104 | tableView.DeleteRows (new [] { indexPath }, UITableViewRowAnimation.Top);
105 | }
106 |
107 | #endregion
108 |
109 | #region UI Actions
110 | async partial void OnAdd(UIButton sender)
111 | {
112 | if (string.IsNullOrWhiteSpace(itemText.Text))
113 | return;
114 |
115 | var newItem = new ToDoItemDocDb
116 | {
117 | Text = itemText.Text,
118 | Complete = false
119 | };
120 |
121 | await todoService.InsertTodoItemAsync(newItem);
122 |
123 | var index = todoService.Items.FindIndex(item => item.Id == newItem.Id);
124 |
125 | TableView.InsertRows(new[] { NSIndexPath.FromItemSection(index, 0) },
126 | UITableViewRowAnimation.Top);
127 |
128 | itemText.Text = "";
129 | }
130 |
131 | #endregion
132 |
133 | [Export ("textFieldShouldReturn:")]
134 | public virtual bool ShouldReturn (UITextField textField)
135 | {
136 | textField.ResignFirstResponder ();
137 | return true;
138 | }
139 | }
140 | }
141 |
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.UWP/MainPage.xaml.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * To add Offline Sync Support:
3 | * 1) Add the NuGet package Microsoft.Azure.Mobile.Client.SQLiteStore (and dependencies) to all client projects
4 | * 2) Uncomment the #define OFFLINE_SYNC_ENABLED
5 | *
6 | * For more information, see: http://go.microsoft.com/fwlink/?LinkId=717898
7 | */
8 |
9 | using Microsoft.WindowsAzure.MobileServices;
10 | using System;
11 | using System.Threading.Tasks;
12 | using Windows.UI.Popups;
13 | using Windows.UI.Xaml;
14 | using Windows.UI.Xaml.Controls;
15 | using Windows.UI.Xaml.Navigation;
16 |
17 | using Microsoft.WindowsAzure.MobileServices.SQLiteStore; // offline sync
18 | using Microsoft.WindowsAzure.MobileServices.Sync; // offline sync
19 | using MobileAppDocDBOfflineSyncSample.Shared.DataModel;
20 |
21 | namespace MobileAppDocDBOfflineSyncSample
22 | {
23 | public sealed partial class MainPage : Page
24 | {
25 | private MobileServiceCollection todoItems;
26 | private MobileServiceCollection complexItems;
27 | private IMobileServiceSyncTable complexTable = App.MobileService.GetSyncTable();
28 | private IMobileServiceSyncTable todoTable = App.MobileService.GetSyncTable(); // offline sync
29 |
30 | public MainPage()
31 | {
32 | this.InitializeComponent();
33 |
34 | }
35 |
36 | protected override async void OnNavigatedTo(NavigationEventArgs e)
37 | {
38 | await InitLocalStoreAsync(); // offline sync
39 | ButtonRefresh_Click(this, null);
40 | }
41 |
42 | private async Task InsertTodoItem(ToDoItemDocDb todoItem)
43 | {
44 | // This code inserts a new TodoItem into the database. After the operation completes
45 | // and the mobile app backend has assigned an id, the item is added to the CollectionView.
46 | await todoTable.InsertAsync(todoItem);
47 | todoItems.Add(todoItem);
48 |
49 | try
50 | {
51 | await App.MobileService.SyncContext.PushAsync();
52 | }
53 | catch { }
54 | }
55 |
56 | private async Task RefreshTodoItems()
57 | {
58 | MobileServiceInvalidOperationException exception = null;
59 | try
60 | {
61 | // This code refreshes the entries in the list view by querying the TodoItems table.
62 | // The query excludes completed TodoItems.
63 | todoItems = await todoTable
64 | .Where(todoItem => todoItem.Complete == false)
65 | .ToCollectionAsync();
66 |
67 | complexItems = await complexTable
68 |
69 | .ToCollectionAsync();
70 | }
71 | catch (MobileServiceInvalidOperationException e)
72 | {
73 | exception = e;
74 | }
75 | catch (Exception e)
76 | {
77 |
78 | }
79 |
80 | if (exception != null)
81 | {
82 | await new MessageDialog(exception.Message, "Error loading items").ShowAsync();
83 | }
84 | else
85 | {
86 | ListItems.ItemsSource = todoItems;
87 | this.ButtonSave.IsEnabled = true;
88 | }
89 | }
90 |
91 | private async Task UpdateCheckedTodoItem(ToDoItemDocDb item)
92 | {
93 | // This code takes a freshly completed TodoItem and updates the database.
94 | // After the MobileService client responds, the item is removed from the list.
95 | await todoTable.UpdateAsync(item);
96 | todoItems.Remove(item);
97 | ListItems.Focus(Windows.UI.Xaml.FocusState.Unfocused);
98 |
99 | try
100 | {
101 | await App.MobileService.SyncContext.PushAsync();
102 | }
103 | catch { }
104 | }
105 |
106 | private async void ButtonRefresh_Click(object sender, RoutedEventArgs e)
107 | {
108 | ButtonRefresh.IsEnabled = false;
109 |
110 | await SyncAsync(); // offline sync
111 | await RefreshTodoItems();
112 |
113 | ButtonRefresh.IsEnabled = true;
114 | }
115 |
116 | private async void ButtonSave_Click(object sender, RoutedEventArgs e)
117 | {
118 | var todoItem = new ToDoItemDocDb { Text = TextInput.Text };
119 | TextInput.Text = "";
120 | await InsertTodoItem(todoItem);
121 | }
122 |
123 | private async void CheckBoxComplete_Checked(object sender, RoutedEventArgs e)
124 | {
125 | CheckBox cb = (CheckBox)sender;
126 | ToDoItemDocDb item = cb.DataContext as ToDoItemDocDb;
127 | await UpdateCheckedTodoItem(item);
128 | }
129 |
130 | private void TextInput_KeyDown(object sender, Windows.UI.Xaml.Input.KeyRoutedEventArgs e)
131 | {
132 | if (e.Key == Windows.System.VirtualKey.Enter) {
133 | ButtonSave.Focus(FocusState.Programmatic);
134 | }
135 | }
136 |
137 | #region Offline sync
138 | private async Task InitLocalStoreAsync()
139 | {
140 | if (!App.MobileService.SyncContext.IsInitialized)
141 | {
142 | var store = new MobileServiceSQLiteStore("localstore.db");
143 | store.DefineTable();
144 | store.DefineTable();
145 | await App.MobileService.SyncContext.InitializeAsync(store);
146 | }
147 |
148 | await SyncAsync();
149 | }
150 |
151 | private async Task SyncAsync()
152 | {
153 | try
154 | {
155 |
156 |
157 | await App.MobileService.SyncContext.PushAsync();
158 | await todoTable.PullAsync("allTodoItemDocDb", todoTable.CreateQuery());
159 | await complexTable.PullAsync("allComplexItem", complexTable.CreateQuery());
160 | //lastUpdateTimeStamp = DateTime.Now;
161 | }
162 | catch { }
163 |
164 | }
165 | #endregion
166 | }
167 | }
168 |
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.Droid/XamarinMobileService.Droid.csproj.bak:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 10.0.0
7 | 2.0
8 | {8E1FCCF4-1FA7-4C23-86B0-19C78B155AA3}
9 | {EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
10 | Library
11 | XamarinMobileService.Droid
12 | True
13 | Resources\Resource.designer.cs
14 | Resource
15 | Resources
16 | Assets
17 | XamarinMobileService.Droid
18 | Properties\AndroidManifest.xml
19 | true
20 |
21 |
22 | armeabi,armeabi-v7a,x86
23 |
24 |
25 | Xamarin
26 |
27 |
28 |
29 |
30 | true
31 | full
32 | false
33 | bin\Debug
34 | DEBUG;
35 | prompt
36 | 4
37 | None
38 | false
39 |
40 |
41 | full
42 | true
43 | bin\Release
44 | prompt
45 | 4
46 | false
47 | false
48 | armeabi,armeabi-v7a
49 |
50 |
51 |
52 | ..\packages\Microsoft.Azure.Mobile.Client.3.0.3\lib\monoandroid\Microsoft.WindowsAzure.Mobile.dll
53 |
54 |
55 | ..\packages\Microsoft.Azure.Mobile.Client.3.0.3\lib\monoandroid\Microsoft.WindowsAzure.Mobile.Ext.dll
56 |
57 |
58 | ..\packages\Microsoft.Azure.Mobile.Client.SQLiteStore.3.0.3\lib\portable-win+net45+wp8+wpa81+monotouch10+monoandroid10+xamarinios10\Microsoft.WindowsAzure.Mobile.SQLiteStore.dll
59 |
60 |
61 | ..\packages\SQLitePCLRaw.bundle_green.1.0.0\lib\MonoAndroid\SQLitePCLRaw.batteries_green.dll
62 |
63 |
64 | ..\packages\SQLitePCLRaw.core.1.0.0\lib\MonoAndroid\SQLitePCLRaw.core.dll
65 |
66 |
67 | ..\packages\SQLitePCLRaw.lib.e_sqlite3.android.1.0.0\lib\MonoAndroid\SQLitePCLRaw.lib.e_sqlite3.dll
68 |
69 |
70 | ..\packages\SQLitePCLRaw.provider.e_sqlite3.android.1.0.0\lib\MonoAndroid\SQLitePCLRaw.provider.e_sqlite3.dll
71 |
72 |
73 | ..\packages\Newtonsoft.Json.6.0.4\lib\portable-net45+wp80+win8+wpa81\Newtonsoft.Json.dll
74 |
75 |
76 |
77 | ..\packages\Microsoft.Net.Http.2.2.29\lib\monoandroid\System.Net.Http.Extensions.dll
78 |
79 |
80 | ..\packages\Microsoft.Net.Http.2.2.29\lib\monoandroid\System.Net.Http.Primitives.dll
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.API/Web.config:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
17 |
18 |
19 |
20 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.UWP/MobileAppDocDBOfflineSyncSample.UWP.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | x86
7 | {843213BD-FBDB-43C7-8523-F6FF2293FB61}
8 | AppContainerExe
9 | Properties
10 | MobileAppDocDBOfflineSyncSample.UWP
11 | MobileAppDocDBOfflineSyncSample.UWP
12 | en-US
13 | UAP
14 | 10.0.10240.0
15 | 10.0.10240.0
16 | 14
17 | 512
18 | {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
19 | MobileAppDocDBOfflineSyncSample.UWP_TemporaryKey.pfx
20 | C83B46EF1A57BA11D08D025F4BE2459A0088F64A
21 |
22 |
23 | true
24 | bin\x86\Debug\
25 | DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
26 | ;2008
27 | full
28 | x86
29 | false
30 | prompt
31 | true
32 |
33 |
34 | bin\x86\Release\
35 | TRACE;NETFX_CORE;WINDOWS_UWP
36 | true
37 | ;2008
38 | pdbonly
39 | x86
40 | false
41 | prompt
42 | true
43 | true
44 |
45 |
46 | true
47 | bin\ARM\Debug\
48 | DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
49 | ;2008
50 | full
51 | ARM
52 | false
53 | prompt
54 | true
55 |
56 |
57 | bin\ARM\Release\
58 | TRACE;NETFX_CORE;WINDOWS_UWP
59 | true
60 | ;2008
61 | pdbonly
62 | ARM
63 | false
64 | prompt
65 | true
66 | true
67 |
68 |
69 | true
70 | bin\x64\Debug\
71 | DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
72 | ;2008
73 | full
74 | x64
75 | false
76 | prompt
77 | true
78 |
79 |
80 | bin\x64\Release\
81 | TRACE;NETFX_CORE;WINDOWS_UWP
82 | true
83 | ;2008
84 | pdbonly
85 | x64
86 | false
87 | prompt
88 | true
89 | true
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 | App.xaml
99 |
100 |
101 | QuickStartTask.xaml
102 |
103 |
104 | MainPage.xaml
105 |
106 |
107 |
108 |
109 |
110 | Designer
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 | MSBuild:Compile
126 | Designer
127 |
128 |
129 | MSBuild:Compile
130 | Designer
131 |
132 |
133 | MSBuild:Compile
134 | Designer
135 |
136 |
137 |
138 |
139 | {a37f4160-6f2d-433e-a5f3-29ac70bfbaf7}
140 | MobileAppDocDBOfflineSyncSample.Shared
141 |
142 |
143 |
144 | 14.0
145 |
146 |
147 |
154 |
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.Droid/ToDoActivity.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * To add Offline Sync Support:
3 | * 1) Add the NuGet package Microsoft.Azure.Mobile.Client.SQLiteStore (and dependencies) to all client projects
4 | * 2) Uncomment the #define OFFLINE_SYNC_ENABLED
5 | *
6 | * For more information, see: http://go.microsoft.com/fwlink/?LinkId=717898
7 | */
8 |
9 | using System;
10 | using Android.OS;
11 | using Android.App;
12 | using Android.Views;
13 | using Android.Widget;
14 | using System.Net.Http;
15 | using System.Threading.Tasks;
16 | using Microsoft.WindowsAzure.MobileServices;
17 | using MobileAppDocDBOfflineSyncSample.Shared.DataModel;
18 |
19 | using Microsoft.WindowsAzure.MobileServices.Sync;
20 | using Microsoft.WindowsAzure.MobileServices.SQLiteStore;
21 |
22 | namespace MobileAppDocDBOfflineSyncSample.Droid
23 | {
24 | [Activity(MainLauncher = true,
25 | Icon = "@drawable/ic_launcher", Label = "@string/app_name",
26 | Theme = "@style/AppTheme")]
27 | public class ToDoActivity : Activity
28 | {
29 | // Client reference.
30 | private MobileServiceClient client;
31 |
32 | private IMobileServiceSyncTable todoTable;
33 |
34 | const string localDbFilename = "localstore.db";
35 |
36 | // Adapter to map the items list to the view
37 |
38 | private ToDoItemDocDbAdapter adapter;
39 |
40 | // EditText containing the "New ToDo" text
41 | private EditText textNewToDo;
42 |
43 | // URL of the mobile app backend.
44 | const string applicationURL = @"https://XamarinMobileService.azurewebsites.net";
45 | //const string applicationURL = @"http://localhost:50010";
46 |
47 | protected override async void OnCreate(Bundle bundle)
48 | {
49 | base.OnCreate(bundle);
50 |
51 | // Set our view from the "main" layout resource
52 | SetContentView(Resource.Layout.Activity_To_Do);
53 |
54 | CurrentPlatform.Init();
55 |
56 | // Create the client instance, using the mobile app backend URL.
57 | client = new MobileServiceClient(applicationURL);
58 |
59 | await InitLocalStoreAsync();
60 |
61 | // Get the sync table instance to use to store TodoItem rows.
62 | todoTable = client.GetSyncTable();
63 |
64 |
65 | textNewToDo = FindViewById(Resource.Id.textNewToDo);
66 |
67 | // Create an adapter to bind the items with the view
68 | adapter = new ToDoItemDocDbAdapter(this, Resource.Layout.Row_List_To_Do);
69 | var listViewToDo = FindViewById(Resource.Id.listViewToDo);
70 | listViewToDo.Adapter = adapter;
71 |
72 | // Load the items from the mobile app backend.
73 | OnRefreshItemsSelected();
74 | }
75 |
76 | private async Task InitLocalStoreAsync()
77 | {
78 | var store = new MobileServiceSQLiteStore(localDbFilename);
79 | store.DefineTable();
80 |
81 | // Uses the default conflict handler, which fails on conflict
82 | // To use a different conflict handler, pass a parameter to InitializeAsync.
83 | // For more details, see http://go.microsoft.com/fwlink/?LinkId=521416
84 | await client.SyncContext.InitializeAsync(store);
85 | }
86 |
87 | private async Task SyncAsync(bool pullData = false)
88 | {
89 | try {
90 | await client.SyncContext.PushAsync();
91 |
92 | if (pullData) {
93 | await todoTable.PullAsync("allTodoItems", todoTable.CreateQuery()); // query ID is used for incremental sync
94 | }
95 | }
96 | catch (Java.Net.MalformedURLException) {
97 | CreateAndShowDialog(new Exception("There was an error creating the Mobile Service. Verify the URL"), "Error");
98 | }
99 | catch (Exception e) {
100 | CreateAndShowDialog(e, "Error");
101 | }
102 | }
103 |
104 | //Initializes the activity menu
105 | public override bool OnCreateOptionsMenu(IMenu menu)
106 | {
107 | MenuInflater.Inflate(Resource.Menu.activity_main, menu);
108 | return true;
109 | }
110 |
111 | //Select an option from the menu
112 | public override bool OnOptionsItemSelected(IMenuItem item)
113 | {
114 | if (item.ItemId == Resource.Id.menu_refresh) {
115 | item.SetEnabled(false);
116 |
117 | OnRefreshItemsSelected();
118 |
119 | item.SetEnabled(true);
120 | }
121 | return true;
122 | }
123 |
124 | // Called when the refresh menu option is selected.
125 | private async void OnRefreshItemsSelected()
126 | {
127 | // Get changes from the mobile app backend.
128 | await SyncAsync(pullData: true);
129 | // refresh view using local store.
130 | await RefreshItemsFromTableAsync();
131 | }
132 |
133 | //Refresh the list with the items in the local store.
134 | private async Task RefreshItemsFromTableAsync()
135 | {
136 | try {
137 | // Get the items that weren't marked as completed and add them in the adapter
138 | var list = await todoTable.Where(item => item.Complete == false).ToListAsync();
139 |
140 | adapter.Clear();
141 |
142 | foreach (ToDoItemDocDb current in list)
143 | adapter.Add(current);
144 |
145 | }
146 | catch (Exception e) {
147 | CreateAndShowDialog(e, "Error");
148 | }
149 | }
150 |
151 | public async Task CheckItem(ToDoItemDocDb item)
152 | {
153 | if (client == null) {
154 | return;
155 | }
156 |
157 | // Set the item as completed and update it in the table
158 | item.Complete = true;
159 | try {
160 | // Update the new item in the local store.
161 | await todoTable.UpdateAsync(item);
162 | // Send changes to the mobile app backend.
163 | await SyncAsync();
164 |
165 | if (item.Complete)
166 | adapter.Remove(item);
167 |
168 | }
169 | catch (Exception e) {
170 | CreateAndShowDialog(e, "Error");
171 | }
172 | }
173 |
174 | [Java.Interop.Export()]
175 | public async void AddItem(View view)
176 | {
177 | if (client == null || string.IsNullOrWhiteSpace(textNewToDo.Text)) {
178 | return;
179 | }
180 |
181 | // Create a new item
182 | var item = new ToDoItemDocDb {
183 | Text = textNewToDo.Text,
184 | Complete = false
185 | };
186 |
187 | try {
188 | // Insert the new item into the local store.
189 | await todoTable.InsertAsync(item);
190 | // Send changes to the mobile app backend.
191 | await SyncAsync();
192 |
193 | if (!item.Complete) {
194 | adapter.Add(item);
195 | }
196 | }
197 | catch (Exception e) {
198 | CreateAndShowDialog(e, "Error");
199 | }
200 |
201 | textNewToDo.Text = "";
202 | }
203 |
204 | private void CreateAndShowDialog(Exception exception, String title)
205 | {
206 | CreateAndShowDialog(exception.Message, title);
207 | }
208 |
209 | private void CreateAndShowDialog(string message, string title)
210 | {
211 | AlertDialog.Builder builder = new AlertDialog.Builder(this);
212 |
213 | builder.SetMessage(message);
214 | builder.SetTitle(title);
215 | builder.Create().Show();
216 | }
217 | }
218 | }
219 |
220 |
221 |
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.Droid/MobileAppDocDBOfflineSyncSample.Droid.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 10.0.0
7 | 2.0
8 | {8E1FCCF4-1FA7-4C23-86B0-19C78B155AA3}
9 | {EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
10 | Library
11 | MobileAppDocDBOfflineSyncSample.Droid
12 | True
13 | Resources\Resource.designer.cs
14 | Resource
15 | Resources
16 | Assets
17 | MobileAppDocDBOfflineSyncSample.Droid
18 | Properties\AndroidManifest.xml
19 | true
20 | v7.0
21 | armeabi,armeabi-v7a,x86
22 |
23 |
24 | Xamarin
25 |
26 |
27 |
28 |
29 | true
30 | full
31 | false
32 | bin\Debug
33 | DEBUG;
34 | prompt
35 | 4
36 | None
37 | false
38 |
39 |
40 | full
41 | true
42 | bin\Release
43 | prompt
44 | 4
45 | false
46 | false
47 | armeabi,armeabi-v7a
48 |
49 |
50 |
51 | ..\packages\Microsoft.Azure.Mobile.Client.3.1.0\lib\monoandroid\Microsoft.WindowsAzure.Mobile.dll
52 | True
53 |
54 |
55 | ..\packages\Microsoft.Azure.Mobile.Client.3.1.0\lib\monoandroid\Microsoft.WindowsAzure.Mobile.Ext.dll
56 | True
57 |
58 |
59 | ..\packages\Microsoft.Azure.Mobile.Client.SQLiteStore.3.1.0\lib\portable-win+net45+wp8+wpa81+monotouch10+monoandroid10+xamarinios10\Microsoft.WindowsAzure.Mobile.SQLiteStore.dll
60 | True
61 |
62 |
63 | ..\packages\Newtonsoft.Json.9.0.1\lib\portable-net45+wp80+win8+wpa81\Newtonsoft.Json.dll
64 | True
65 |
66 |
67 | ..\packages\SQLitePCLRaw.bundle_green.1.1.2\lib\MonoAndroid\SQLitePCLRaw.batteries_green.dll
68 | True
69 |
70 |
71 | ..\packages\SQLitePCLRaw.bundle_green.1.1.2\lib\MonoAndroid\SQLitePCLRaw.batteries_v2.dll
72 | True
73 |
74 |
75 | ..\packages\SQLitePCLRaw.core.1.1.2\lib\MonoAndroid\SQLitePCLRaw.core.dll
76 | True
77 |
78 |
79 | ..\packages\SQLitePCLRaw.lib.e_sqlite3.android.1.1.2\lib\MonoAndroid\SQLitePCLRaw.lib.e_sqlite3.dll
80 | True
81 |
82 |
83 | ..\packages\SQLitePCLRaw.provider.e_sqlite3.android.1.1.2\lib\MonoAndroid\SQLitePCLRaw.provider.e_sqlite3.dll
84 | True
85 |
86 |
87 |
88 | ..\packages\Microsoft.Net.Http.2.2.29\lib\monoandroid\System.Net.Http.Extensions.dll
89 |
90 |
91 | ..\packages\Microsoft.Net.Http.2.2.29\lib\monoandroid\System.Net.Http.Primitives.dll
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 | {a37f4160-6f2d-433e-a5f3-29ac70bfbaf7}
134 | MobileAppDocDBOfflineSyncSample.Shared
135 |
136 |
137 |
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.iOS/MobileAppDocDBOfflineSyncSample.iOS.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | iPhoneSimulator
6 | 10.0.0
7 | 2.0
8 | {07F1CD1B-626F-4BE5-9840-97B44CBB94C9}
9 | {FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
10 | Exe
11 | MobileAppDocDBOfflineSyncSample.iOS
12 | Resources
13 | MobileAppDocDBOfflineSyncSample.iOS
14 | Xamarin.iOS
15 | v1.0
16 |
17 |
18 | true
19 | full
20 | false
21 | bin\iPhoneSimulator\Debug
22 | DEBUG;
23 | prompt
24 | 4
25 | None
26 | false
27 | true
28 |
29 |
30 | full
31 | true
32 | bin\iPhoneSimulator\Release
33 | prompt
34 | 4
35 | None
36 | false
37 |
38 |
39 | true
40 | full
41 | false
42 | bin\iPhone\Debug
43 | DEBUG;
44 | prompt
45 | 4
46 | true
47 | false
48 | iPhone Developer
49 | ARMv7
50 |
51 |
52 | full
53 | true
54 | bin\iPhone\Release
55 | prompt
56 | 4
57 | iPhone Developer
58 | false
59 | ARMv7, ARM64
60 |
61 |
62 |
63 | ..\packages\Microsoft.Azure.Mobile.Client.3.1.0\lib\Xamarin.iOS10\Microsoft.WindowsAzure.Mobile.dll
64 | True
65 |
66 |
67 | ..\packages\Microsoft.Azure.Mobile.Client.3.1.0\lib\Xamarin.iOS10\Microsoft.WindowsAzure.Mobile.Ext.dll
68 | True
69 |
70 |
71 | ..\packages\Microsoft.Azure.Mobile.Client.SQLiteStore.3.1.0\lib\portable-win+net45+wp8+wpa81+monotouch10+monoandroid10+xamarinios10\Microsoft.WindowsAzure.Mobile.SQLiteStore.dll
72 | True
73 |
74 |
75 | ..\packages\Newtonsoft.Json.9.0.1\lib\portable-net45+wp80+win8+wpa81\Newtonsoft.Json.dll
76 | True
77 |
78 |
79 | ..\packages\SQLitePCLRaw.bundle_green.1.1.2\lib\Xamarin.iOS10\SQLitePCLRaw.batteries_green.dll
80 | True
81 |
82 |
83 | ..\packages\SQLitePCLRaw.bundle_green.1.1.2\lib\Xamarin.iOS10\SQLitePCLRaw.batteries_v2.dll
84 | True
85 |
86 |
87 | ..\packages\SQLitePCLRaw.core.1.1.2\lib\Xamarin.iOS10\SQLitePCLRaw.core.dll
88 | True
89 |
90 |
91 | ..\packages\SQLitePCLRaw.provider.sqlite3.ios_unified.1.1.2\lib\Xamarin.iOS10\SQLitePCLRaw.provider.sqlite3.dll
92 | True
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 | ..\packages\Microsoft.Net.Http.2.2.29\lib\portable-net45+win8\System.Net.Http.Primitives.dll
102 |
103 |
104 | ..\packages\Microsoft.Net.Http.2.2.29\lib\portable-net45+win8\System.Net.Http.Extensions.dll
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 | QSTodoListViewController.cs
118 |
119 |
120 |
121 |
122 |
123 | Designer
124 |
125 |
126 | Designer
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 | {a37f4160-6f2d-433e-a5f3-29ac70bfbaf7}
146 | MobileAppDocDBOfflineSyncSample.Shared
147 |
148 |
149 |
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.UWP/MainPage.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | 0,8,8,0
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 | 72,5,10,5
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 | AZURE APP SERVICE
73 | Try Mobile Apps
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
91 |
92 |
93 |
94 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
115 |
122 |
123 |
124 |
127 |
128 |
129 |
130 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.iOS/MainStoryboard_iPad.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
42 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.iOS/MainStoryboard_iPhone.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.API/Helpers/DocumentDBDomainManager.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Azure.Documents;
2 | using Microsoft.Azure.Documents.Client;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Net.Http;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 | using Microsoft.Azure.Documents.Linq;
10 | using System.Web.Http;
11 | using System.Configuration;
12 | using System.IO;
13 | using System.Net;
14 | using Newtonsoft.Json;
15 | using System.Web.Http.OData;
16 | using Microsoft.Azure.Mobile.Server.Tables;
17 |
18 | namespace MobileAppDocDBOfflineSyncSampleService.Helpers
19 | {
20 | public class DocumentDBDomainManager :IDomainManager where TDocument : DocumentResource , new()
21 | {
22 | public HttpRequestMessage Request { get; set; }
23 | //public ApiServices Services { get; set; }
24 |
25 |
26 | private string _collectionId;
27 | private string _databaseId;
28 | private Database _database;
29 | private DocumentCollection _collection;
30 | private DocumentClient _client;
31 |
32 | public DocumentDBDomainManager(string collectionId, string databaseId, HttpRequestMessage request)//, ApiServices services)
33 | {
34 | Request = request;
35 | //Services = services;
36 | _collectionId = collectionId;
37 | _databaseId = databaseId;
38 | }
39 |
40 | // public DocumentDBDomainManager(HttpRequestMessage request, ApiServices services)
41 | //{
42 | // var attribute = typeof(TDocument).GetCustomAttributes(typeof(DocumentAttribute), true).FirstOrDefault() as DocumentAttribute;
43 | // if (attribute == null)
44 | // throw new ArgumentException("the model class must be decorated with the Document attribute");
45 |
46 | // Request = request;
47 | // Services = services;
48 | // _collectionId = attribute.CollectionId;
49 | // _databaseId = attribute.DatabaseId;
50 | //}
51 |
52 | public async Task DeleteAsync(string id)
53 | {
54 | try
55 | {
56 | var doc = GetDocument(id);
57 |
58 |
59 | if (doc == null)
60 | {
61 | return false;
62 | }
63 |
64 | await Client.DeleteDocumentAsync(doc.SelfLink);
65 |
66 | return true;
67 |
68 |
69 | }
70 | catch (Exception ex)
71 | {
72 | //Services.Log.Error(ex);
73 | throw new HttpResponseException(System.Net.HttpStatusCode.InternalServerError);
74 | }
75 | }
76 |
77 | public Task InsertAsync(TDocument data)
78 | {
79 | try
80 | {
81 | data.CreatedAt = DateTimeOffset.UtcNow;
82 | data.UpdatedAt = DateTimeOffset.UtcNow;
83 | return Client.CreateDocumentAsync(Collection.SelfLink, data)
84 | .ContinueWith(t=> GetDocFromResponse(t));
85 |
86 | }
87 | catch (Exception ex)
88 | {
89 | //Services.Log.Error(ex);
90 | throw new HttpResponseException(System.Net.HttpStatusCode.InternalServerError);
91 | }
92 | }
93 | private TDocument GetDocFromResponse(Task> source)
94 | {
95 | if (source.IsFaulted)
96 | {
97 | new InvalidOperationException("Parent task is faulted.",source.Exception);
98 | }
99 |
100 | return GetDocEntity(source.Result.Resource);
101 | }
102 |
103 | private TDocument GetDocEntity(Document source)
104 | {
105 | if (source == null)
106 | {
107 | new ArgumentNullException("source");
108 | }
109 |
110 | return JsonConvert.DeserializeObject(JsonConvert.SerializeObject(source));
111 |
112 | }
113 |
114 | public SingleResult Lookup(string id)
115 | {
116 | var qry = this.Query().Where(d => d.Id == id)
117 | .Select(d => d);
118 |
119 | var result = qry.ToList();
120 |
121 | return SingleResult.Create(result.AsQueryable());
122 | }
123 |
124 | public Task> LookupAsync(string id)
125 | {
126 | try
127 | {
128 | return Task>.Run(()=> Lookup(id));
129 |
130 | }
131 | catch (Exception ex)
132 | {
133 | //Services.Log.Error(ex);
134 | throw new HttpResponseException(System.Net.HttpStatusCode.InternalServerError);
135 | }
136 | }
137 |
138 | public IQueryable Query()
139 | {
140 | try
141 | {
142 | var qry = Client
143 | .CreateDocumentQuery(Collection.DocumentsLink)
144 | .ToList()
145 | .AsQueryable();
146 |
147 | return qry;
148 | }
149 | catch (Exception ex)
150 | {
151 | //Services.Log.Error(ex);
152 | throw new HttpResponseException(System.Net.HttpStatusCode.InternalServerError);
153 | }
154 | }
155 |
156 | public Task> QueryAsync()
157 | {
158 | throw new NotImplementedException();
159 | }
160 |
161 | public Task UpdateAsync(string id, Delta patch)
162 | {
163 | if (id == null)
164 | {
165 | throw new ArgumentNullException("id");
166 | }
167 |
168 | if (patch == null)
169 | {
170 | throw new ArgumentNullException("patch");
171 | }
172 |
173 |
174 | var doc = this.GetDocument(id);
175 | if (doc == null)
176 | {
177 | //Services.Log.Error(string.Format( "Resource with id {0} not found", id));
178 | throw new HttpResponseException(System.Net.HttpStatusCode.NotFound);
179 | }
180 |
181 |
182 | TDocument current = this.GetDocEntity(doc);
183 |
184 | patch.Patch(current);
185 | this.VerifyUpdatedKey(id, current);
186 | current.UpdatedAt = DateTimeOffset.UtcNow;
187 |
188 | try
189 | {
190 | return Client.ReplaceDocumentAsync(current.SelfLink, current)
191 | .ContinueWith(t => GetDocFromResponse(t));
192 | }
193 |
194 | catch (Exception ex)
195 | {
196 | //Services.Log.Error(ex);
197 | throw new HttpResponseException(System.Net.HttpStatusCode.InternalServerError);
198 | }
199 | }
200 |
201 | public Task ReplaceAsync(string id, TDocument data)
202 | {
203 |
204 | if (id == null)
205 | {
206 | throw new ArgumentNullException("id");
207 | }
208 | if (data == null)
209 | {
210 | throw new ArgumentNullException("data");
211 | }
212 |
213 | this.VerifyUpdatedKey(id, data);
214 | data.CreatedAt = DateTimeOffset.UtcNow;
215 |
216 | try
217 | {
218 | return Client.ReplaceDocumentAsync(data.SelfLink, data)
219 | .ContinueWith(t => GetDocFromResponse(t));
220 | }
221 |
222 | catch (Exception ex)
223 | {
224 | //Services.Log.Error(ex);
225 | throw new HttpResponseException(System.Net.HttpStatusCode.InternalServerError);
226 | }
227 |
228 | }
229 |
230 |
231 | private Document GetDocument(string id)
232 | {
233 | return Client.CreateDocumentQuery(Collection.DocumentsLink)
234 | .Where(d => d.Id == id)
235 | .AsEnumerable()
236 | .FirstOrDefault();
237 | }
238 | private void VerifyUpdatedKey(string id, TDocument data)
239 | {
240 | if (data == null || data.Id != id)
241 | {
242 | HttpResponseMessage badKey = this.Request.CreateErrorResponse(HttpStatusCode.BadRequest, "The keys don't match");
243 | throw new HttpResponseException(badKey);
244 | }
245 | }
246 |
247 | #region DocumentDBClient
248 |
249 | private DocumentClient Client
250 | {
251 | get
252 | {
253 | if (_client == null)
254 | {
255 | string endpoint = ConfigurationManager.AppSettings["endpoint"];
256 | string authKey = ConfigurationManager.AppSettings["authKey"];
257 | Uri endpointUri = new Uri(endpoint);
258 | _client = new DocumentClient(endpointUri, authKey);
259 | }
260 |
261 | return _client;
262 | }
263 | }
264 |
265 | private DocumentCollection Collection
266 | {
267 | get
268 | {
269 | if (_collection == null)
270 | {
271 | _collection = ReadOrCreateCollection(Database.SelfLink);
272 | }
273 |
274 | return _collection;
275 | }
276 | }
277 |
278 | private Database Database
279 | {
280 | get
281 | {
282 | if (_database == null)
283 | {
284 | _database = ReadOrCreateDatabase();
285 | }
286 |
287 | return _database;
288 | }
289 | }
290 |
291 | private DocumentCollection ReadOrCreateCollection(string databaseLink)
292 | {
293 | var col = Client.CreateDocumentCollectionQuery(databaseLink)
294 | .Where(c => c.Id == _collectionId)
295 | .AsEnumerable()
296 | .FirstOrDefault();
297 |
298 | if (col == null)
299 | {
300 | col = Client.CreateDocumentCollectionAsync(databaseLink, new DocumentCollection { Id = _collectionId }).Result;
301 | }
302 |
303 | return col;
304 | }
305 |
306 | private Database ReadOrCreateDatabase()
307 | {
308 | var db = Client.CreateDatabaseQuery()
309 | .Where(d => d.Id == _databaseId)
310 | .AsEnumerable()
311 | .FirstOrDefault();
312 |
313 | if (db == null)
314 | {
315 | db = Client.CreateDatabaseAsync(new Database { Id = _databaseId }).Result;
316 | }
317 |
318 | return db;
319 | }
320 | #endregion
321 |
322 |
323 |
324 |
325 | public Task> QueryAsync(System.Web.Http.OData.Query.ODataQueryOptions query)
326 | {
327 | throw new NotImplementedException();
328 | }
329 |
330 |
331 | }
332 |
333 | }
334 |
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.25420.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MobileAppDocDBOfflineSyncSample.API", "MobileAppDocDBOfflineSyncSample.API\MobileAppDocDBOfflineSyncSample.API.csproj", "{209FA716-A7AD-4095-BD70-C8710FC66FA7}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MobileAppDocDBOfflineSyncSample.Droid", "MobileAppDocDBOfflineSyncSample.Droid\MobileAppDocDBOfflineSyncSample.Droid.csproj", "{8E1FCCF4-1FA7-4C23-86B0-19C78B155AA3}"
9 | EndProject
10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MobileAppDocDBOfflineSyncSample.iOS", "MobileAppDocDBOfflineSyncSample.iOS\MobileAppDocDBOfflineSyncSample.iOS.csproj", "{07F1CD1B-626F-4BE5-9840-97B44CBB94C9}"
11 | EndProject
12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MobileAppDocDBOfflineSyncSample.UWP", "MobileAppDocDBOfflineSyncSample.UWP\MobileAppDocDBOfflineSyncSample.UWP.csproj", "{843213BD-FBDB-43C7-8523-F6FF2293FB61}"
13 | EndProject
14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MobileAppDocDBOfflineSyncSample.Shared", "MobileAppDocDBOfflineSyncSample.Shared\MobileAppDocDBOfflineSyncSample.Shared.csproj", "{A37F4160-6F2D-433E-A5F3-29AC70BFBAF7}"
15 | EndProject
16 | Global
17 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
18 | Debug|Any CPU = Debug|Any CPU
19 | Debug|ARM = Debug|ARM
20 | Debug|iPhone = Debug|iPhone
21 | Debug|iPhoneSimulator = Debug|iPhoneSimulator
22 | Debug|x64 = Debug|x64
23 | Debug|x86 = Debug|x86
24 | Release|Any CPU = Release|Any CPU
25 | Release|ARM = Release|ARM
26 | Release|iPhone = Release|iPhone
27 | Release|iPhoneSimulator = Release|iPhoneSimulator
28 | Release|x64 = Release|x64
29 | Release|x86 = Release|x86
30 | EndGlobalSection
31 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
32 | {209FA716-A7AD-4095-BD70-C8710FC66FA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
33 | {209FA716-A7AD-4095-BD70-C8710FC66FA7}.Debug|Any CPU.Build.0 = Debug|Any CPU
34 | {209FA716-A7AD-4095-BD70-C8710FC66FA7}.Debug|ARM.ActiveCfg = Debug|Any CPU
35 | {209FA716-A7AD-4095-BD70-C8710FC66FA7}.Debug|ARM.Build.0 = Debug|Any CPU
36 | {209FA716-A7AD-4095-BD70-C8710FC66FA7}.Debug|iPhone.ActiveCfg = Debug|Any CPU
37 | {209FA716-A7AD-4095-BD70-C8710FC66FA7}.Debug|iPhone.Build.0 = Debug|Any CPU
38 | {209FA716-A7AD-4095-BD70-C8710FC66FA7}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
39 | {209FA716-A7AD-4095-BD70-C8710FC66FA7}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
40 | {209FA716-A7AD-4095-BD70-C8710FC66FA7}.Debug|x64.ActiveCfg = Debug|Any CPU
41 | {209FA716-A7AD-4095-BD70-C8710FC66FA7}.Debug|x64.Build.0 = Debug|Any CPU
42 | {209FA716-A7AD-4095-BD70-C8710FC66FA7}.Debug|x86.ActiveCfg = Debug|Any CPU
43 | {209FA716-A7AD-4095-BD70-C8710FC66FA7}.Debug|x86.Build.0 = Debug|Any CPU
44 | {209FA716-A7AD-4095-BD70-C8710FC66FA7}.Release|Any CPU.ActiveCfg = Release|Any CPU
45 | {209FA716-A7AD-4095-BD70-C8710FC66FA7}.Release|Any CPU.Build.0 = Release|Any CPU
46 | {209FA716-A7AD-4095-BD70-C8710FC66FA7}.Release|ARM.ActiveCfg = Release|Any CPU
47 | {209FA716-A7AD-4095-BD70-C8710FC66FA7}.Release|ARM.Build.0 = Release|Any CPU
48 | {209FA716-A7AD-4095-BD70-C8710FC66FA7}.Release|iPhone.ActiveCfg = Release|Any CPU
49 | {209FA716-A7AD-4095-BD70-C8710FC66FA7}.Release|iPhone.Build.0 = Release|Any CPU
50 | {209FA716-A7AD-4095-BD70-C8710FC66FA7}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
51 | {209FA716-A7AD-4095-BD70-C8710FC66FA7}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
52 | {209FA716-A7AD-4095-BD70-C8710FC66FA7}.Release|x64.ActiveCfg = Release|Any CPU
53 | {209FA716-A7AD-4095-BD70-C8710FC66FA7}.Release|x64.Build.0 = Release|Any CPU
54 | {209FA716-A7AD-4095-BD70-C8710FC66FA7}.Release|x86.ActiveCfg = Release|Any CPU
55 | {209FA716-A7AD-4095-BD70-C8710FC66FA7}.Release|x86.Build.0 = Release|Any CPU
56 | {8E1FCCF4-1FA7-4C23-86B0-19C78B155AA3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
57 | {8E1FCCF4-1FA7-4C23-86B0-19C78B155AA3}.Debug|Any CPU.Build.0 = Debug|Any CPU
58 | {8E1FCCF4-1FA7-4C23-86B0-19C78B155AA3}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
59 | {8E1FCCF4-1FA7-4C23-86B0-19C78B155AA3}.Debug|ARM.ActiveCfg = Debug|Any CPU
60 | {8E1FCCF4-1FA7-4C23-86B0-19C78B155AA3}.Debug|ARM.Build.0 = Debug|Any CPU
61 | {8E1FCCF4-1FA7-4C23-86B0-19C78B155AA3}.Debug|ARM.Deploy.0 = Debug|Any CPU
62 | {8E1FCCF4-1FA7-4C23-86B0-19C78B155AA3}.Debug|iPhone.ActiveCfg = Debug|Any CPU
63 | {8E1FCCF4-1FA7-4C23-86B0-19C78B155AA3}.Debug|iPhone.Build.0 = Debug|Any CPU
64 | {8E1FCCF4-1FA7-4C23-86B0-19C78B155AA3}.Debug|iPhone.Deploy.0 = Debug|Any CPU
65 | {8E1FCCF4-1FA7-4C23-86B0-19C78B155AA3}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
66 | {8E1FCCF4-1FA7-4C23-86B0-19C78B155AA3}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
67 | {8E1FCCF4-1FA7-4C23-86B0-19C78B155AA3}.Debug|iPhoneSimulator.Deploy.0 = Debug|Any CPU
68 | {8E1FCCF4-1FA7-4C23-86B0-19C78B155AA3}.Debug|x64.ActiveCfg = Debug|Any CPU
69 | {8E1FCCF4-1FA7-4C23-86B0-19C78B155AA3}.Debug|x64.Build.0 = Debug|Any CPU
70 | {8E1FCCF4-1FA7-4C23-86B0-19C78B155AA3}.Debug|x64.Deploy.0 = Debug|Any CPU
71 | {8E1FCCF4-1FA7-4C23-86B0-19C78B155AA3}.Debug|x86.ActiveCfg = Debug|Any CPU
72 | {8E1FCCF4-1FA7-4C23-86B0-19C78B155AA3}.Debug|x86.Build.0 = Debug|Any CPU
73 | {8E1FCCF4-1FA7-4C23-86B0-19C78B155AA3}.Debug|x86.Deploy.0 = Debug|Any CPU
74 | {8E1FCCF4-1FA7-4C23-86B0-19C78B155AA3}.Release|Any CPU.ActiveCfg = Release|Any CPU
75 | {8E1FCCF4-1FA7-4C23-86B0-19C78B155AA3}.Release|Any CPU.Build.0 = Release|Any CPU
76 | {8E1FCCF4-1FA7-4C23-86B0-19C78B155AA3}.Release|Any CPU.Deploy.0 = Release|Any CPU
77 | {8E1FCCF4-1FA7-4C23-86B0-19C78B155AA3}.Release|ARM.ActiveCfg = Release|Any CPU
78 | {8E1FCCF4-1FA7-4C23-86B0-19C78B155AA3}.Release|ARM.Build.0 = Release|Any CPU
79 | {8E1FCCF4-1FA7-4C23-86B0-19C78B155AA3}.Release|ARM.Deploy.0 = Release|Any CPU
80 | {8E1FCCF4-1FA7-4C23-86B0-19C78B155AA3}.Release|iPhone.ActiveCfg = Release|Any CPU
81 | {8E1FCCF4-1FA7-4C23-86B0-19C78B155AA3}.Release|iPhone.Build.0 = Release|Any CPU
82 | {8E1FCCF4-1FA7-4C23-86B0-19C78B155AA3}.Release|iPhone.Deploy.0 = Release|Any CPU
83 | {8E1FCCF4-1FA7-4C23-86B0-19C78B155AA3}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
84 | {8E1FCCF4-1FA7-4C23-86B0-19C78B155AA3}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
85 | {8E1FCCF4-1FA7-4C23-86B0-19C78B155AA3}.Release|iPhoneSimulator.Deploy.0 = Release|Any CPU
86 | {8E1FCCF4-1FA7-4C23-86B0-19C78B155AA3}.Release|x64.ActiveCfg = Release|Any CPU
87 | {8E1FCCF4-1FA7-4C23-86B0-19C78B155AA3}.Release|x64.Build.0 = Release|Any CPU
88 | {8E1FCCF4-1FA7-4C23-86B0-19C78B155AA3}.Release|x64.Deploy.0 = Release|Any CPU
89 | {8E1FCCF4-1FA7-4C23-86B0-19C78B155AA3}.Release|x86.ActiveCfg = Release|Any CPU
90 | {8E1FCCF4-1FA7-4C23-86B0-19C78B155AA3}.Release|x86.Build.0 = Release|Any CPU
91 | {8E1FCCF4-1FA7-4C23-86B0-19C78B155AA3}.Release|x86.Deploy.0 = Release|Any CPU
92 | {07F1CD1B-626F-4BE5-9840-97B44CBB94C9}.Debug|Any CPU.ActiveCfg = Debug|iPhone
93 | {07F1CD1B-626F-4BE5-9840-97B44CBB94C9}.Debug|ARM.ActiveCfg = Debug|iPhoneSimulator
94 | {07F1CD1B-626F-4BE5-9840-97B44CBB94C9}.Debug|iPhone.ActiveCfg = Debug|iPhone
95 | {07F1CD1B-626F-4BE5-9840-97B44CBB94C9}.Debug|iPhone.Build.0 = Debug|iPhone
96 | {07F1CD1B-626F-4BE5-9840-97B44CBB94C9}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
97 | {07F1CD1B-626F-4BE5-9840-97B44CBB94C9}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
98 | {07F1CD1B-626F-4BE5-9840-97B44CBB94C9}.Debug|x64.ActiveCfg = Debug|iPhoneSimulator
99 | {07F1CD1B-626F-4BE5-9840-97B44CBB94C9}.Debug|x86.ActiveCfg = Debug|iPhoneSimulator
100 | {07F1CD1B-626F-4BE5-9840-97B44CBB94C9}.Release|Any CPU.ActiveCfg = Release|iPhone
101 | {07F1CD1B-626F-4BE5-9840-97B44CBB94C9}.Release|ARM.ActiveCfg = Release|iPhoneSimulator
102 | {07F1CD1B-626F-4BE5-9840-97B44CBB94C9}.Release|iPhone.ActiveCfg = Release|iPhone
103 | {07F1CD1B-626F-4BE5-9840-97B44CBB94C9}.Release|iPhone.Build.0 = Release|iPhone
104 | {07F1CD1B-626F-4BE5-9840-97B44CBB94C9}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
105 | {07F1CD1B-626F-4BE5-9840-97B44CBB94C9}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
106 | {07F1CD1B-626F-4BE5-9840-97B44CBB94C9}.Release|x64.ActiveCfg = Release|iPhoneSimulator
107 | {07F1CD1B-626F-4BE5-9840-97B44CBB94C9}.Release|x86.ActiveCfg = Release|iPhoneSimulator
108 | {843213BD-FBDB-43C7-8523-F6FF2293FB61}.Debug|Any CPU.ActiveCfg = Debug|x86
109 | {843213BD-FBDB-43C7-8523-F6FF2293FB61}.Debug|Any CPU.Build.0 = Debug|x86
110 | {843213BD-FBDB-43C7-8523-F6FF2293FB61}.Debug|Any CPU.Deploy.0 = Debug|x86
111 | {843213BD-FBDB-43C7-8523-F6FF2293FB61}.Debug|ARM.ActiveCfg = Debug|ARM
112 | {843213BD-FBDB-43C7-8523-F6FF2293FB61}.Debug|ARM.Build.0 = Debug|ARM
113 | {843213BD-FBDB-43C7-8523-F6FF2293FB61}.Debug|ARM.Deploy.0 = Debug|ARM
114 | {843213BD-FBDB-43C7-8523-F6FF2293FB61}.Debug|iPhone.ActiveCfg = Debug|x86
115 | {843213BD-FBDB-43C7-8523-F6FF2293FB61}.Debug|iPhoneSimulator.ActiveCfg = Debug|x86
116 | {843213BD-FBDB-43C7-8523-F6FF2293FB61}.Debug|iPhoneSimulator.Build.0 = Debug|x86
117 | {843213BD-FBDB-43C7-8523-F6FF2293FB61}.Debug|iPhoneSimulator.Deploy.0 = Debug|x86
118 | {843213BD-FBDB-43C7-8523-F6FF2293FB61}.Debug|x64.ActiveCfg = Debug|x64
119 | {843213BD-FBDB-43C7-8523-F6FF2293FB61}.Debug|x64.Build.0 = Debug|x64
120 | {843213BD-FBDB-43C7-8523-F6FF2293FB61}.Debug|x64.Deploy.0 = Debug|x64
121 | {843213BD-FBDB-43C7-8523-F6FF2293FB61}.Debug|x86.ActiveCfg = Debug|x86
122 | {843213BD-FBDB-43C7-8523-F6FF2293FB61}.Debug|x86.Build.0 = Debug|x86
123 | {843213BD-FBDB-43C7-8523-F6FF2293FB61}.Debug|x86.Deploy.0 = Debug|x86
124 | {843213BD-FBDB-43C7-8523-F6FF2293FB61}.Release|Any CPU.ActiveCfg = Release|x86
125 | {843213BD-FBDB-43C7-8523-F6FF2293FB61}.Release|ARM.ActiveCfg = Release|ARM
126 | {843213BD-FBDB-43C7-8523-F6FF2293FB61}.Release|ARM.Build.0 = Release|ARM
127 | {843213BD-FBDB-43C7-8523-F6FF2293FB61}.Release|ARM.Deploy.0 = Release|ARM
128 | {843213BD-FBDB-43C7-8523-F6FF2293FB61}.Release|iPhone.ActiveCfg = Release|x86
129 | {843213BD-FBDB-43C7-8523-F6FF2293FB61}.Release|iPhoneSimulator.ActiveCfg = Release|x86
130 | {843213BD-FBDB-43C7-8523-F6FF2293FB61}.Release|iPhoneSimulator.Build.0 = Release|x86
131 | {843213BD-FBDB-43C7-8523-F6FF2293FB61}.Release|iPhoneSimulator.Deploy.0 = Release|x86
132 | {843213BD-FBDB-43C7-8523-F6FF2293FB61}.Release|x64.ActiveCfg = Release|x64
133 | {843213BD-FBDB-43C7-8523-F6FF2293FB61}.Release|x64.Build.0 = Release|x64
134 | {843213BD-FBDB-43C7-8523-F6FF2293FB61}.Release|x64.Deploy.0 = Release|x64
135 | {843213BD-FBDB-43C7-8523-F6FF2293FB61}.Release|x86.ActiveCfg = Release|x86
136 | {843213BD-FBDB-43C7-8523-F6FF2293FB61}.Release|x86.Build.0 = Release|x86
137 | {843213BD-FBDB-43C7-8523-F6FF2293FB61}.Release|x86.Deploy.0 = Release|x86
138 | {A37F4160-6F2D-433E-A5F3-29AC70BFBAF7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
139 | {A37F4160-6F2D-433E-A5F3-29AC70BFBAF7}.Debug|Any CPU.Build.0 = Debug|Any CPU
140 | {A37F4160-6F2D-433E-A5F3-29AC70BFBAF7}.Debug|ARM.ActiveCfg = Debug|Any CPU
141 | {A37F4160-6F2D-433E-A5F3-29AC70BFBAF7}.Debug|ARM.Build.0 = Debug|Any CPU
142 | {A37F4160-6F2D-433E-A5F3-29AC70BFBAF7}.Debug|iPhone.ActiveCfg = Debug|Any CPU
143 | {A37F4160-6F2D-433E-A5F3-29AC70BFBAF7}.Debug|iPhone.Build.0 = Debug|Any CPU
144 | {A37F4160-6F2D-433E-A5F3-29AC70BFBAF7}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
145 | {A37F4160-6F2D-433E-A5F3-29AC70BFBAF7}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
146 | {A37F4160-6F2D-433E-A5F3-29AC70BFBAF7}.Debug|x64.ActiveCfg = Debug|Any CPU
147 | {A37F4160-6F2D-433E-A5F3-29AC70BFBAF7}.Debug|x64.Build.0 = Debug|Any CPU
148 | {A37F4160-6F2D-433E-A5F3-29AC70BFBAF7}.Debug|x86.ActiveCfg = Debug|Any CPU
149 | {A37F4160-6F2D-433E-A5F3-29AC70BFBAF7}.Debug|x86.Build.0 = Debug|Any CPU
150 | {A37F4160-6F2D-433E-A5F3-29AC70BFBAF7}.Release|Any CPU.ActiveCfg = Release|Any CPU
151 | {A37F4160-6F2D-433E-A5F3-29AC70BFBAF7}.Release|Any CPU.Build.0 = Release|Any CPU
152 | {A37F4160-6F2D-433E-A5F3-29AC70BFBAF7}.Release|ARM.ActiveCfg = Release|Any CPU
153 | {A37F4160-6F2D-433E-A5F3-29AC70BFBAF7}.Release|ARM.Build.0 = Release|Any CPU
154 | {A37F4160-6F2D-433E-A5F3-29AC70BFBAF7}.Release|iPhone.ActiveCfg = Release|Any CPU
155 | {A37F4160-6F2D-433E-A5F3-29AC70BFBAF7}.Release|iPhone.Build.0 = Release|Any CPU
156 | {A37F4160-6F2D-433E-A5F3-29AC70BFBAF7}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
157 | {A37F4160-6F2D-433E-A5F3-29AC70BFBAF7}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
158 | {A37F4160-6F2D-433E-A5F3-29AC70BFBAF7}.Release|x64.ActiveCfg = Release|Any CPU
159 | {A37F4160-6F2D-433E-A5F3-29AC70BFBAF7}.Release|x64.Build.0 = Release|Any CPU
160 | {A37F4160-6F2D-433E-A5F3-29AC70BFBAF7}.Release|x86.ActiveCfg = Release|Any CPU
161 | {A37F4160-6F2D-433E-A5F3-29AC70BFBAF7}.Release|x86.Build.0 = Release|Any CPU
162 | EndGlobalSection
163 | GlobalSection(SolutionProperties) = preSolution
164 | HideSolutionNode = FALSE
165 | EndGlobalSection
166 | GlobalSection(MonoDevelopProperties) = preSolution
167 | StartupItem = MobileAppDocDBOfflineSyncSample\MobileAppDocDBOfflineSyncSample.csproj
168 | EndGlobalSection
169 | EndGlobal
170 |
--------------------------------------------------------------------------------
/MobileAppDocDBOfflineSyncSample.API/MobileAppDocDBOfflineSyncSample.API.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | 2.0
8 | {209FA716-A7AD-4095-BD70-C8710FC66FA7}
9 | {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}
10 | Library
11 | Properties
12 | MobileAppDocDBOfflineSyncSample.API
13 | MobileAppDocDBOfflineSyncSample.API
14 | v4.6
15 | false
16 | true
17 | 44363
18 |
19 |
20 |
21 | true
22 | 10.0
23 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
24 | ..\
25 |
26 |
27 |
28 |
29 |
30 |
31 | true
32 | full
33 | false
34 | bin\
35 | DEBUG;TRACE
36 | prompt
37 | 4
38 | AnyCPU
39 |
40 |
41 | pdbonly
42 | true
43 | bin\
44 | TRACE
45 | prompt
46 | 4
47 |
48 |
49 |
50 |
51 |
52 | True
53 | True
54 | 50010
55 | /
56 | http://localhost:50010/
57 | False
58 | False
59 |
60 |
61 | False
62 |
63 |
64 |
65 |
66 |
67 |
68 | ..\packages\Microsoft.Azure.DocumentDB.1.10.0\lib\net45\Microsoft.Azure.Documents.Client.dll
69 | True
70 |
71 |
72 | ..\packages\Microsoft.Azure.Mobile.Server.2.0.0\lib\net46\Microsoft.Azure.Mobile.Server.dll
73 | True
74 |
75 |
76 | ..\packages\Microsoft.Azure.Mobile.Server.Swagger.2.0.0\lib\net46\Microsoft.Azure.Mobile.Server.Swagger.dll
77 | True
78 |
79 |
80 | ..\packages\Microsoft.Owin.Host.SystemWeb.3.0.1\lib\net45\Microsoft.Owin.Host.SystemWeb.dll
81 |
82 |
83 | ..\packages\Microsoft.Azure.Mobile.Server.Authentication.1.1.157.1\lib\net45\Microsoft.Azure.Mobile.Server.Authentication.dll
84 |
85 |
86 | ..\packages\Microsoft.Azure.Mobile.Server.Entity.1.1.157.1\lib\net45\Microsoft.Azure.Mobile.Server.Entity.dll
87 |
88 |
89 | ..\packages\Microsoft.Azure.Mobile.Server.Home.1.1.157.1\lib\net45\Microsoft.Azure.Mobile.Server.Home.dll
90 |
91 |
92 | ..\packages\Microsoft.Azure.Mobile.Server.Notifications.1.1.157.1\lib\net45\Microsoft.Azure.Mobile.Server.Notifications.dll
93 |
94 |
95 | ..\packages\Microsoft.Azure.Mobile.Server.Quickstart.1.1.157.1\lib\net45\Microsoft.Azure.Mobile.Server.Quickstart.dll
96 |
97 |
98 | ..\packages\Microsoft.Azure.Mobile.Server.Tables.1.1.157.1\lib\net45\Microsoft.Azure.Mobile.Server.Tables.dll
99 |
100 |
101 | ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll
102 |
103 |
104 | ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll
105 |
106 |
107 | ..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll
108 | True
109 |
110 |
111 | ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll
112 | True
113 |
114 |
115 | ..\packages\Swashbuckle.Core.5.5.3\lib\net40\Swashbuckle.Core.dll
116 | True
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 | False
125 | ..\packages\Microsoft.AspNet.WebApi.Core.5.2.3\lib\net45\System.Web.Http.dll
126 |
127 |
128 | ..\packages\Microsoft.AspNet.WebApi.OData.5.5.1\lib\net45\System.Web.Http.OData.dll
129 |
130 |
131 | ..\packages\Microsoft.Azure.NotificationHubs.1.0.2\lib\net45-full\Microsoft.Azure.NotificationHubs.dll
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 | ..\packages\Microsoft.Owin.3.0.1\lib\net45\Microsoft.Owin.dll
141 |
142 |
143 | ..\packages\Microsoft.AspNet.WebApi.Client.5.2.3\lib\net45\System.Net.Http.Formatting.dll
144 |
145 |
146 | ..\packages\Owin.1.0\lib\net40\Owin.dll
147 |
148 |
149 | ..\packages\Microsoft.AspNet.WebApi.Owin.5.2.3\lib\net45\System.Web.Http.Owin.dll
150 |
151 |
152 | ..\packages\Microsoft.Owin.Security.3.0.1\lib\net45\Microsoft.Owin.Security.dll
153 |
154 |
155 | ..\packages\Microsoft.WindowsAzure.ConfigurationManager.3.2.0\lib\net40\Microsoft.WindowsAzure.Configuration.dll
156 |
157 |
158 | ..\packages\System.IdentityModel.Tokens.Jwt.4.0.2.205111437\lib\net45\System.IdentityModel.Tokens.Jwt.dll
159 |
160 |
161 | ..\packages\AutoMapper.3.3.1\lib\net40\AutoMapper.dll
162 |
163 |
164 | ..\packages\AutoMapper.3.3.1\lib\net40\AutoMapper.Net4.dll
165 |
166 |
167 | ..\packages\Microsoft.Data.Edm.5.6.4\lib\net40\Microsoft.Data.Edm.dll
168 |
169 |
170 | ..\packages\Microsoft.Data.OData.5.6.4\lib\net40\Microsoft.Data.OData.dll
171 |
172 |
173 | ..\packages\System.Spatial.5.6.4\lib\net40\System.Spatial.dll
174 |
175 |
176 | ..\packages\Microsoft.AspNet.WebApi.Tracing.5.2.3\lib\net45\System.Web.Http.Tracing.dll
177 |
178 |
179 | ..\packages\Microsoft.AspNet.WebApi.WebHost.5.2.3\lib\net45\System.Web.Http.WebHost.dll
180 | True
181 |
182 |
183 |
184 | ..\packages\WebActivatorEx.2.0\lib\net40\WebActivatorEx.dll
185 | True
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 | Web.config
211 |
212 |
213 | Web.config
214 |
215 |
216 | Designer
217 |
218 |
219 |
220 |
221 | {a37f4160-6f2d-433e-a5f3-29ac70bfbaf7}
222 | MobileAppDocDBOfflineSyncSample.Shared
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
238 |
239 |
240 |
241 |
--------------------------------------------------------------------------------