当前位置: 首页>>代码示例>>C#>>正文


C# IDataStoreContext类代码示例

本文整理汇总了C#中IDataStoreContext的典型用法代码示例。如果您正苦于以下问题:C# IDataStoreContext类的具体用法?C# IDataStoreContext怎么用?C# IDataStoreContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IDataStoreContext类属于命名空间,在下文中一共展示了IDataStoreContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ImportJson

        private static void ImportJson (IDataStoreContext ctx, WorkspaceUserData data, WorkspaceUserJson json)
        {
            var workspaceId = GetLocalId<WorkspaceData> (ctx, json.WorkspaceId);
            var user = GetByRemoteId<UserData> (ctx, json.UserId, null);

            // Update linked user data:
            if (user == null) {
                user = new UserData () {
                    RemoteId = json.UserId,
                    Name = json.Name,
                    Email = json.Email,
                    DefaultWorkspaceId = workspaceId,
                    ModifiedAt = DateTime.MinValue,
                };
            } else {
                user.Name = json.Name;
                user.Email = json.Email;
            }
            user = ctx.Put (user);

            data.IsAdmin = json.IsAdmin;
            data.IsActive = json.IsActive;
            data.WorkspaceId = workspaceId;
            data.UserId = user.Id;

            ImportCommonJson (data, json);
        }
开发者ID:readiescards,项目名称:mobile,代码行数:27,代码来源:WorkspaceUserJsonConverter.cs

示例2: Import

 public static CommonData Import (this CommonJson json, IDataStoreContext ctx,
                                  Guid? localIdHint = null, CommonData mergeBase = null)
 {
     var type = json.GetType ();
     if (type == typeof (ClientJson)) {
         return Import ((ClientJson)json, ctx, localIdHint, (ClientData)mergeBase);
     } else if (type == typeof (ProjectJson)) {
         return Import ((ProjectJson)json, ctx, localIdHint, (ProjectData)mergeBase);
     } else if (type == typeof (ProjectUserJson)) {
         return Import ((ProjectUserJson)json, ctx, localIdHint, (ProjectUserData)mergeBase);
     } else if (type == typeof (TagJson)) {
         return Import ((TagJson)json, ctx, localIdHint, (TagData)mergeBase);
     } else if (type == typeof (TaskJson)) {
         return Import ((TaskJson)json, ctx, localIdHint, (TaskData)mergeBase);
     } else if (type == typeof (TimeEntryJson)) {
         return Import ((TimeEntryJson)json, ctx, localIdHint, (TimeEntryData)mergeBase);
     } else if (type == typeof (UserJson)) {
         return Import ((UserJson)json, ctx, localIdHint, (UserData)mergeBase);
     } else if (type == typeof (WorkspaceJson)) {
         return Import ((WorkspaceJson)json, ctx, localIdHint, (WorkspaceData)mergeBase);
     } else if (type == typeof (WorkspaceUserJson)) {
         return Import ((WorkspaceUserJson)json, ctx, localIdHint, (WorkspaceUserData)mergeBase);
     }
     throw new InvalidOperationException (String.Format ("Unknown type of {0}", type));
 }
开发者ID:VDBBjorn,项目名称:toggl_mobile,代码行数:25,代码来源:JsonExtensions.cs

示例3: Export

        public WorkspaceUserJson Export (IDataStoreContext ctx, WorkspaceUserData data)
        {
            var userRows = ctx.Connection.Table<UserData> ()
                .Take (1).Where (m => m.Id == data.UserId).ToList ();
            if (userRows.Count == 0) {
                throw new InvalidOperationException (String.Format (
                    "Cannot export data with invalid local relation ({0}#{1}) to JSON.",
                    typeof(UserData).Name, data.UserId
                ));
            }
            var user = userRows [0];
            if (user.RemoteId == null) {
                throw new RelationRemoteIdMissingException (typeof(UserData), data.UserId);
            }

            var workspaceId = GetRemoteId<WorkspaceData> (ctx, data.WorkspaceId);

            return new WorkspaceUserJson () {
                Id = data.RemoteId,
                ModifiedAt = data.ModifiedAt.ToUtc (),
                IsAdmin = data.IsAdmin,
                IsActive = data.IsActive,
                Name = user.Name,
                Email = user.Email,
                WorkspaceId = workspaceId,
                UserId = user.RemoteId.Value,
            };
        }
开发者ID:readiescards,项目名称:mobile,代码行数:28,代码来源:WorkspaceUserJsonConverter.cs

示例4: GetTimeEntryTags

 private List<string> GetTimeEntryTags (IDataStoreContext ctx, Guid id)
 {
     if (id == Guid.Empty) {
         return new List<string> (0);
     }
     return ctx.GetTimeEntryTagNames (id);
 }
开发者ID:peeedge,项目名称:mobile,代码行数:7,代码来源:TimeEntryJsonConverter.cs

示例5: Import

        public ClientData Import (IDataStoreContext ctx, ClientJson json, Guid? localIdHint = null, ClientData mergeBase = null)
        {
            var data = GetByRemoteId<ClientData> (ctx, json.Id.Value, localIdHint);

            var merger = mergeBase != null ? new ClientMerger (mergeBase) : null;
            if (merger != null && data != null)
                merger.Add (new ClientData (data));

            if (json.DeletedAt.HasValue) {
                if (data != null) {
                    ctx.Delete (data);
                    data = null;
                }
            } else if (merger != null || ShouldOverwrite (data, json)) {
                data = data ?? new ClientData ();
                ImportJson (ctx, data, json);

                if (merger != null) {
                    merger.Add (data);
                    data = merger.Result;
                }

                data = ctx.Put (data);
            }

            return data;
        }
开发者ID:readiescards,项目名称:mobile,代码行数:27,代码来源:ClientJsonConverter.cs

示例6: Export

        public ClientJson Export (IDataStoreContext ctx, ClientData data)
        {
            var workspaceId = GetRemoteId<WorkspaceData> (ctx, data.WorkspaceId);

            return new ClientJson () {
                Id = data.RemoteId,
                ModifiedAt = data.ModifiedAt.ToUtc (),
                Name = data.Name,
                WorkspaceId = workspaceId,
            };
        }
开发者ID:VDBBjorn,项目名称:toggl_mobile,代码行数:11,代码来源:ClientJsonConverter.cs

示例7: ImportJson

        private static void ImportJson (IDataStoreContext ctx, ProjectUserData data, ProjectUserJson json)
        {
            var projectId = GetLocalId<ProjectData> (ctx, json.ProjectId);
            var userId = GetLocalId<UserData> (ctx, json.UserId);

            data.HourlyRate = json.HourlyRate;
            data.IsManager = json.IsManager;
            data.ProjectId = projectId;
            data.UserId = userId;

            ImportCommonJson (data, json);
        }
开发者ID:readiescards,项目名称:mobile,代码行数:12,代码来源:ProjectUserJsonConverter.cs

示例8: Merge

        private static void Merge (IDataStoreContext ctx, TaskData data, TaskJson json)
        {
            var projectId = GetLocalId<ProjectData> (ctx, json.ProjectId);
            var workspaceId = GetLocalId<WorkspaceData> (ctx, json.WorkspaceId);

            data.Name = json.Name;
            data.IsActive = json.IsActive;
            data.Estimate = json.Estimate;
            data.ProjectId = projectId;
            data.WorkspaceId = workspaceId;

            MergeCommon (data, json);
        }
开发者ID:jblj,项目名称:mobile,代码行数:13,代码来源:TaskJsonConverter.cs

示例9: Export

        public ProjectUserJson Export (IDataStoreContext ctx, ProjectUserData data)
        {
            var projectId = GetRemoteId<ProjectData> (ctx, data.ProjectId);
            var userId = GetRemoteId<UserData> (ctx, data.UserId);

            return new ProjectUserJson () {
                Id = data.RemoteId,
                ModifiedAt = data.ModifiedAt.ToUtc (),
                HourlyRate = data.HourlyRate,
                IsManager = data.IsManager,
                ProjectId = projectId,
                UserId = userId,
            };
        }
开发者ID:readiescards,项目名称:mobile,代码行数:14,代码来源:ProjectUserJsonConverter.cs

示例10: Export

        public TaskJson Export (IDataStoreContext ctx, TaskData data)
        {
            var projectId = GetRemoteId<ProjectData> (ctx, data.ProjectId);
            var workspaceId = GetRemoteId<WorkspaceData> (ctx, data.WorkspaceId);

            return new TaskJson () {
                Id = data.RemoteId,
                ModifiedAt = data.ModifiedAt.ToUtc (),
                Name = data.Name,
                IsActive = data.IsActive,
                Estimate = data.Estimate,
                ProjectId = projectId,
                WorkspaceId = workspaceId,
            };
        }
开发者ID:jblj,项目名称:mobile,代码行数:15,代码来源:TaskJsonConverter.cs

示例11: Export

 public WorkspaceJson Export (IDataStoreContext ctx, WorkspaceData data)
 {
     return new WorkspaceJson () {
         Id = data.RemoteId,
         ModifiedAt = data.ModifiedAt.ToUtc (),
         Name = data.Name,
         IsPremium = data.IsPremium,
         DefaultRate = data.DefaultRate,
         DefaultCurrency = data.DefaultCurrency,
         OnlyAdminsMayCreateProjects = data.ProjectCreationPrivileges == AccessLevel.Admin,
         OnlyAdminsSeeBillableRates = data.BillableRatesVisibility == AccessLevel.Admin,
         RoundingMode = data.RoundingMode,
         RoundingPercision = data.RoundingPercision,
         LogoUrl = data.LogoUrl,
     };
 }
开发者ID:VDBBjorn,项目名称:toggl_mobile,代码行数:16,代码来源:WorkspaceJsonConverter.cs

示例12: Import

        public TagData Import (IDataStoreContext ctx, TagJson json, Guid? localIdHint = null, bool forceUpdate = false)
        {
            var data = GetByRemoteId<TagData> (ctx, json.Id.Value, localIdHint);

            if (json.DeletedAt.HasValue) {
                if (data != null) {
                    ctx.Delete (data);
                    data = null;
                }
            } else if (data == null || forceUpdate || data.ModifiedAt < json.ModifiedAt) {
                data = Merge (ctx, data, json);
                data = ctx.Put (data);
            }

            return data;
        }
开发者ID:jblj,项目名称:mobile,代码行数:16,代码来源:TagJsonConverter.cs

示例13: ImportJson

        private static void ImportJson (IDataStoreContext ctx, UserData data, UserJson json)
        {
            var defaultWorkspaceId = GetLocalId<WorkspaceData> (ctx, json.DefaultWorkspaceId);

            data.Name = json.Name;
            data.Email = json.Email;
            data.StartOfWeek = json.StartOfWeek;
            data.DateFormat = json.DateFormat;
            data.TimeFormat = json.TimeFormat;
            data.ImageUrl = json.ImageUrl;
            data.Locale = json.Locale;
            data.Timezone = json.Timezone;
            data.SendProductEmails = json.SendProductEmails;
            data.SendTimerNotifications = json.SendTimerNotifications;
            data.SendWeeklyReport = json.SendWeeklyReport;
            data.TrackingMode = json.StoreStartAndStopTime ? TrackingMode.StartNew : TrackingMode.Continue;
            data.DefaultWorkspaceId = defaultWorkspaceId;

            ImportCommonJson (data, json);
        }
开发者ID:readiescards,项目名称:mobile,代码行数:20,代码来源:UserJsonConverter.cs

示例14: ImportJson

        private static TagData ImportJson (IDataStoreContext ctx, TagData data, TagJson json)
        {
            var workspaceId = GetLocalId<WorkspaceData> (ctx, json.WorkspaceId);

            if (data == null) {
                // Fallback to name lookup for unsynced tags:
                var rows = ctx.Connection.Table<TagData> ().Take (1)
                    .Where (r => r.WorkspaceId == workspaceId && r.Name == json.Name && r.RemoteId == null);
                data = rows.FirstOrDefault ();
            }

            // As a last chance create new tag:
            data = data ?? new TagData ();

            data.Name = json.Name;
            data.WorkspaceId = workspaceId;

            ImportCommonJson (data, json);

            return data;
        }
开发者ID:readiescards,项目名称:mobile,代码行数:21,代码来源:TagJsonConverter.cs

示例15: Import

        public ClientData Import (IDataStoreContext ctx, ClientJson json, Guid? localIdHint = null, ClientData mergeBase = null)
        {
            var log = ServiceContainer.Resolve<ILogger> ();

            var data = GetByRemoteId<ClientData> (ctx, json.Id.Value, localIdHint);

            var merger = mergeBase != null ? new ClientMerger (mergeBase) : null;
            if (merger != null && data != null) {
                merger.Add (new ClientData (data));
            }

            if (json.DeletedAt.HasValue) {
                if (data != null) {
                    log.Info (Tag, "Deleting local data for {0}.", data.ToIdString ());
                    ctx.Delete (data);
                    data = null;
                }
            } else if (merger != null || ShouldOverwrite (data, json)) {
                data = data ?? new ClientData ();
                ImportJson (ctx, data, json);

                if (merger != null) {
                    merger.Add (data);
                    data = merger.Result;
                }

                if (merger != null) {
                    log.Info (Tag, "Importing {0}, merging with local data.", data.ToIdString ());
                } else {
                    log.Info (Tag, "Importing {0}, replacing local data.", data.ToIdString ());
                }

                data = ctx.Put (data);
            } else {
                log.Info (Tag, "Skipping import of {0}.", json.ToIdString ());
            }

            return data;
        }
开发者ID:VDBBjorn,项目名称:toggl_mobile,代码行数:39,代码来源:ClientJsonConverter.cs


注:本文中的IDataStoreContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。