コード例 #1
0
 internal void DeleteFileFromSync(String guid)
 {
     using (MobeelizerDatabaseContext transaction = new MobeelizerDatabaseContext(this.ConnectionString))
     {
         var query = from f in transaction.Files where f.Guid == guid select f;
         transaction.Files.DeleteAllOnSubmit(query);
         transaction.SubmitChanges();
     }
 }
コード例 #2
0
 public void Dispose()
 {
     if (dataContext != null)
     {
         dataContext.Dispose();
         db.RemoveTransaction(this);
         dataContext = null;
     }
 }
コード例 #3
0
 private void AddFile(String guid, String path, int modificationFlag)
 {
     using (MobeelizerDatabaseContext transaction = new MobeelizerDatabaseContext(this.ConnectionString))
     {
         MobeelizerFilesTableEntity entity = new MobeelizerFilesTableEntity();
         entity.Guid     = guid;
         entity.Path     = path;
         entity.Modyfied = modificationFlag;
         transaction.Files.InsertOnSubmit(entity);
         transaction.SubmitChanges(ConflictMode.FailOnFirstConflict);
     }
 }
コード例 #4
0
        internal String GetFilePath(String guid)
        {
            String path = null;

            using (MobeelizerDatabaseContext transaction = new MobeelizerDatabaseContext(this.ConnectionString))
            {
                try
                {
                    var query  = from f in transaction.Files where f.Guid == guid select f;
                    var result = query.Single();
                    path = result.Path;
                }
                catch { }
            }
            return(path);
        }
コード例 #5
0
        internal bool Exists(string modelName, string guid)
        {
            bool exists = true;

            try
            {
                using (MobeelizerDatabaseContext dataContext = new MobeelizerDatabaseContext(this.ConnectionString))
                {
                    var table = from MobeelizerWp7Model m in dataContext.GetTable(models[modelName].Type) where m.Guid == guid select m;
                    table.Single();
                }
            }
            catch (SystemException)
            {
                exists = false;
            }

            return(exists);
        }
コード例 #6
0
        internal bool IsFileExists(String guid)
        {
            bool fileExists = false;

            using (MobeelizerDatabaseContext transaction = new MobeelizerDatabaseContext(this.ConnectionString))
            {
                try
                {
                    var query  = from f in transaction.Files where f.Guid == guid select f;
                    var result = query.Single();
                    if (result != null)
                    {
                        fileExists = true;
                    }
                }
                catch
                {
                    fileExists = false;
                }
            }

            return(fileExists);
        }
コード例 #7
0
        internal MobeelizerOperationError UpdateEntitiesFromSync(IEnumerable <MobeelizerJsonEntity> entities, bool isAllSynchronization)
        {
            MobeelizerOperationError transactionErrors = null;

            using (MobeelizerDatabaseContext dataContext = new MobeelizerDatabaseContext(this.ConnectionString))
            {
                if (isAllSynchronization)
                {
                    foreach (var model in models.Values)
                    {
                        var table = dataContext.GetTable(model.Type);
                        table.DeleteAllOnSubmit(from MobeelizerWp7Model record in table select record);
                    }

                    dataContext.ModelMetadata.DeleteAllOnSubmit(from m in dataContext.ModelMetadata select m);
                    // TODO: check it
                    //dataContext.Files.DeleteAllOnSubmit(from f in dataContext.Files select f);
                    dataContext.SubmitChanges();
                }

                foreach (MobeelizerJsonEntity entity in entities)
                {
                    transactionErrors = models[entity.Model].UpdateFromSync(entity, dataContext);
                    if (transactionErrors != null)
                    {
                        break;
                    }
                }

                if (transactionErrors == null)
                {
                    dataContext.SubmitChanges();
                }
            }

            return(transactionErrors);
        }
コード例 #8
0
 internal MobeelizerTable(ITable <T> table, MobeelizerDatabaseContext db)
 {
     this.table = table;
     this.db    = db;
 }
コード例 #9
0
 internal MobeelizerTransaction(MobeelizerDatabase db)
 {
     dataContext = new MobeelizerDatabaseContext(db.ConnectionString);
     this.db     = db;
 }
コード例 #10
0
 public MobeelizerSyncFileEnumerator(Database.MobeelizerDatabaseContext transaction)
 {
     this.transaction = transaction;
     enumerator       = (from f in transaction.Files where f.Modyfied == 2 select f).GetEnumerator();
 }
コード例 #11
0
 internal MobeelizerSyncFileEnumerable(Database.MobeelizerDatabaseContext transaction)
 {
     this.transaction = transaction;
     this.enumerator  = new MobeelizerSyncFileEnumerator(transaction);
 }