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(); } }
public void Dispose() { if (dataContext != null) { dataContext.Dispose(); db.RemoveTransaction(this); dataContext = null; } }
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); } }
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); }
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); }
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); }
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); }
internal MobeelizerTable(ITable <T> table, MobeelizerDatabaseContext db) { this.table = table; this.db = db; }
internal MobeelizerTransaction(MobeelizerDatabase db) { dataContext = new MobeelizerDatabaseContext(db.ConnectionString); this.db = db; }
public MobeelizerSyncFileEnumerator(Database.MobeelizerDatabaseContext transaction) { this.transaction = transaction; enumerator = (from f in transaction.Files where f.Modyfied == 2 select f).GetEnumerator(); }
internal MobeelizerSyncFileEnumerable(Database.MobeelizerDatabaseContext transaction) { this.transaction = transaction; this.enumerator = new MobeelizerSyncFileEnumerator(transaction); }