Exemple #1
0
        public void Configure(EntityTypeBuilder <Chat> builder)
        {
            builder.ToTable(TableName);

            // ID
            builder.HasKey(c => c.ID);
            builder.Property(c => c.ID)
            .HasColumnName("ROWID");

            // Properties
            builder.Property(c => c.Properties)
            .HasConversion(new DynamicPListValueConverter());

            // ServiceType
            builder.Property(c => c.ServiceType)
            .HasColumnName("service_name")
            .HasConversion <long>();

            // AccountLogin
            builder.Property(c => c.AccountLogin)
            .HasColumnName("account_login")
            .HasConversion(new ValueConverter <AccountLogin, string>(
                               a => a.ToString() // will call tostring method in AccountLogin
                               , a => new AccountLogin(a)
                               ));

            // IsArchived
            builder.Property(c => c.IsArchived)
            .HasColumnName("is_archived");

            // LastReadMessageTimestamp

            // older versions like version 8.* has no last_read_message_timestamp field in Photos.sqlite database
            var fieldExists = true;

            if (ConnectionString != null)
            {
                fieldExists = SQLiteSchemaCheckerUtils.IsFieldExists(ConnectionString, TableName, "last_read_message_timestamp");
                if (!fieldExists)
                {
                    builder.Ignore(p => p.LastReadMessageTimestamp);
                }
            }

            if (fieldExists)
            {
                builder.Property(c => c.LastReadMessageTimestamp)
                .HasColumnName("last_read_message_timestamp")
                .HasConversion(new CFTimeIntervalConverter());
            }

            // Handle

            // Messages

            // ChatHandleJoin
        }
Exemple #2
0
        protected string PredictTableName()
        {
            //======================================================================================
            // Check update number first, iOS 14 and later changed the table ZGENERICASSET to ZASSET
            //======================================================================================

            //try
            //{
            //    //var productVersion = (Backup as Backup).Info()?.ProductVersion;
            //    var updateNumber = ProductVersion.Major;

            //    return (updateNumber > 14)
            //        ? "ZASSET"
            //        : "ZGENERICASSET";
            //}
            //catch (FileNotFoundException)
            //{
            //    return "ZASSET";
            //}

            //======================================================================================
            // Check photos database directly by quering the table name
            //======================================================================================

            var assetTableNames = new string[] { "ZASSET", "ZGENERICASSET" };

            string[] tablesLookupResult = SQLiteSchemaCheckerUtils.WhichTableExists(ConnectionString, assetTableNames);

            if (tablesLookupResult.Length == 0)
            {
                var tablesNames = string.Join(" - ", tablesLookupResult);
                throw new NotSupportedException($"Unknown asset table name, table name is not one of those tables names [{tablesNames}]");
            }

            return(tablesLookupResult[0]);
        }
Exemple #3
0
        public void Configure(EntityTypeBuilder <ChatMessageJoin> builder)
        {
            builder.ToTable(TableName);

            builder.HasKey(t => new { t.Chat_ID, t.Message_Id });

            builder.HasOne(t => t.Chat)
            .WithMany(t => t.ChatMessageJoins)
            .HasForeignKey(t => t.Chat_ID);

            builder.HasOne(t => t.Message)
            .WithMany(t => t.ChatMessageJoins)
            .HasForeignKey(t => t.Message_Id);

            // older versions like version 8.* has no message_date field in Photos.sqlite database
            if (ConnectionString != null)
            {
                var messageDateFieldExists = SQLiteSchemaCheckerUtils.IsFieldExists(ConnectionString, TableName, "message_date");
                if (!messageDateFieldExists)
                {
                    builder.Ignore(p => p.Message_Date);
                }
            }
        }