Ejemplo n.º 1
0
        DbArchiveRecord InsertReference(MappedTable <DbArchiveRecord> table, IReferenceJson reference, DateTime lastFetchedUtc)
        {
            DbArchiveRecord archiveRecord = new DbArchiveRecord();

            archiveRecord.Id             = reference.Id;
            archiveRecord.LastFetchedUtc = lastFetchedUtc;
            archiveRecord.Json           = reference.RawJson;
            Mapper.InsertRecord(table, archiveRecord, SQLiteConflictResolution.Replace);
            return(archiveRecord);
        }
Ejemplo n.º 2
0
        void UpdateConversation(DbArchiveRecord archiveConversationRef)
        {
            JsonConversationReference conversationRef = SQLiteJsonConverter.LoadFromJson <JsonConversationReference>(
                archiveConversationRef.Json);

            DbConversation coreConversation = new DbConversation();

            coreConversation.LastFetchedUtc = archiveConversationRef.LastFetchedUtc;
            coreConversation.ConversationId = conversationRef.Id;
            coreConversation.ParticipantUserIds.AssignFrom(conversationRef.Participants.Select(x => x.Id));

            Conversations.InsertRecord(coreConversation, SQLiteConflictResolution.Replace);
        }
Ejemplo n.º 3
0
        void UpdateUser(DbArchiveRecord archiveUser)
        {
            JsonUserReference userRef = SQLiteJsonConverter.LoadFromJson <JsonUserReference>(archiveUser.Json);

            DbUser coreUser = new DbUser();

            coreUser.LastFetchedUtc = archiveUser.LastFetchedUtc;
            coreUser.UserId         = userRef.Id;
            coreUser.Alias          = userRef.Alias ?? "";
            coreUser.Email          = userRef.Email ?? "";
            coreUser.FullName       = userRef.DisplayValue ?? "";
            coreUser.JobTitle       = userRef.JobTitle ?? "";
            coreUser.WebUrl         = userRef.Permalink ?? "";
            coreUser.MugshotUrl     = userRef.MugshotUrl ?? "";

            Users.InsertRecord(coreUser, SQLiteConflictResolution.Replace);
        }
Ejemplo n.º 4
0
        void UpdateGroup(DbArchiveRecord archiveGroupRef)
        {
            JsonGroupReference groupRef = SQLiteJsonConverter.LoadFromJson <JsonGroupReference>(archiveGroupRef.Json);

            bool incompleteRecord = false;

            DbGroup coreGroup = new DbGroup();

            coreGroup.LastFetchedUtc   = archiveGroupRef.LastFetchedUtc;
            coreGroup.GroupId          = groupRef.Id;
            coreGroup.GroupName        = groupRef.FullName ?? "";
            coreGroup.GroupDescription = groupRef.Description ?? "";

            if (!Enum.TryParse <DbGroupPrivacy>(groupRef.Privacy, true, out coreGroup.Privacy))
            {
                if (!string.IsNullOrEmpty(groupRef.Privacy))
                {
                    throw new YamsterProtocolException(string.Format("Unsupported group privacy \"{0}\"", coreGroup.Privacy));
                }
                coreGroup.Privacy = DbGroupPrivacy.Unknown;
                incompleteRecord  = true;
            }

            coreGroup.WebUrl     = groupRef.WebUrl ?? "";
            coreGroup.MugshotUrl = groupRef.MugshotUrl ?? "";

            // If the record is incomplete, don't overwrite an existing record that might have complete data
            // TODO: this merging should be more fine-grained
            Groups.InsertRecord(coreGroup, incompleteRecord ? SQLiteConflictResolution.Ignore : SQLiteConflictResolution.Replace);

            DbGroupState groupState = new DbGroupState()
            {
                GroupId = groupRef.Id
            };

            GroupStates.InsertRecord(groupState, SQLiteConflictResolution.Ignore);
        }