public void SimpleTest() { using (IMobeelizerTransaction db = Mobeelizer.GetDatabase().BeginTransaction()) { var departments = db.GetModelSet <Department>(); Department department = new Department(); department.Name = "Dep1"; department.InternalNumber = 333; departments.InsertOnSubmit(department); Department department2 = new Department(); department.Name = "Dep2"; department.InternalNumber = 333; departments.InsertOnSubmit(department2); Department department3 = new Department(); department.Name = "Dep3"; department.InternalNumber = 333; departments.InsertOnSubmit(department3); db.SubmitChanges(); } using (var transaction = Mobeelizer.GetDatabase().BeginTransaction()) { var query = from d in transaction.GetModelSet <Department>() select d; foreach (Department dep in query) { } } }
private void RefreshEntitiesList() { this.Entities.Clear(); bool inConflict = false; var database = Mobeelizer.GetDatabase(); using (var transaction = database.BeginTransaction()) { var query = from conflictsEntity entity in transaction.GetModelSet <conflictsEntity>() select entity; foreach (var entity in query) { if (entity.Conflicted) { inConflict = true; } Entities.Add(entity); } } if (IsWarningVisable != inConflict) { IsWarningVisable = inConflict; } }
public void GetModels() { using (IMobeelizerTransaction db = Mobeelizer.GetDatabase().BeginTransaction()) { Assert.IsInstanceOfType(new Employee(), typeof(MobeelizerWp7Model)); Assert.IsNotNull(db.GetModelSet <Employee>()); Assert.IsInstanceOfType(db.GetModelSet <Employee>(), typeof(ITable <Employee>)); Assert.IsInstanceOfType(new Department(), typeof(MobeelizerWp7Model)); Assert.IsNotNull(db.GetModelSet <Department>()); Assert.IsInstanceOfType(db.GetModelSet <Department>(), typeof(ITable <Department>)); } }
private void RefreshEntitiesList() { this.Entities.Clear(); var database = Mobeelizer.GetDatabase(); using (var transaction = database.BeginTransaction()) { var query = from fileSyncEntity entity in transaction.GetModelSet <fileSyncEntity>() select entity; foreach (var entity in query) { this.Entities.Add(entity); } } }
private void OnAdd(object param) { Movie movie = DataUtil.GetRandomMovie(); simpleSyncEntity entity = new simpleSyncEntity(); entity.Title = movie.Title; using (var transaction = Mobeelizer.GetDatabase().BeginTransaction()) { transaction.GetModelSet <simpleSyncEntity>().InsertOnSubmit(entity); transaction.SubmitChanges(); } this.Entities.Add(entity); }
private string GetName() { int count = 0; using (var transaction = Mobeelizer.GetDatabase().BeginTransaction()) { var query = from e in transaction.GetModelSet <graphsConflictsOrderEntity>() select e; count = query.ToList().Count; } String user = App.CurrentUser.ToString(); return(String.Format("{0}/000{1}", user, count + 1)); }
protected override void ValidateValue(object value, MobeelizerFieldAccessor field, IDictionary <string, string> options, MobeelizerErrorsHolder errors) { String stringValue = (String)value; if (!errors.IsValid) { return; } if (!((MobeelizerDatabase)Mobeelizer.GetDatabase()).Exists(options["model"], stringValue)) { errors.AddFieldMissingReferenceError(field.Name, stringValue); return; } }
private void OnAdd(object arg) { Movie movie = DataUtil.GetRandomMovie(); permissionsEntity entity = new permissionsEntity(); entity.Title = movie.Title; entity.Director = movie.Director; using (var transaction = Mobeelizer.GetDatabase().BeginTransaction()) { transaction.GetModelSet <permissionsEntity>().InsertOnSubmit(entity); transaction.SubmitChanges(); } this.Entities.Add(entity); }
private void OnAdd(object param) { graphsConflictsOrderEntity entity = new graphsConflictsOrderEntity(); entity.Name = this.GetName(); entity.Status = new Random().Next(1, 5); entity.AddCommand = AddItemCommand; entity.Items = new ObservableCollection <graphsConflictsItemEntity>(); using (var transaction = Mobeelizer.GetDatabase().BeginTransaction()) { transaction.GetModelSet <graphsConflictsOrderEntity>().InsertOnSubmit(entity); transaction.SubmitChanges(); } this.Entities.Add(entity); }
public void SyncAll() { UTWebRequest.SyncData = "firstSync.zip"; Mobeelizer.Login("user", "password", (s) => { syncAllLoginEvent.Set(); }); syncAllLoginEvent.WaitOne(); String justAddEntityGuid = string.Empty; using (IMobeelizerTransaction db = Mobeelizer.GetDatabase().BeginTransaction()) { var departmentTable = db.GetModelSet <Department>(); Department de = new Department(); de.InternalNumber = 1; de.Name = "ddd"; departmentTable.InsertOnSubmit(de); db.SubmitChanges(); justAddEntityGuid = de.Guid; } MobeelizerOperationError status = null; Mobeelizer.SyncAll((s) => { status = s; this.syncAllEvent.Set(); }); syncAllEvent.WaitOne(); Assert.IsNull(status); Department foundObject = null; using (IMobeelizerTransaction db = Mobeelizer.GetDatabase().BeginTransaction()) { var departmentTable = db.GetModelSet <Department>(); var query = from d in departmentTable where d.Guid == justAddEntityGuid select d; try { foundObject = query.Single(); } catch { } Assert.IsNull(foundObject); Assert.AreEqual(1, departmentTable.Count()); } }
private void OnRemoveRelation(object param) { if (Mobeelizer.CheckSyncStatus().IsRunning()) { navigationService.ShowMessage(Resources.Errors.e_title, Resources.Errors.e_waitUntilSyncFinish); } else { graphsConflictsItemEntity item = param as graphsConflictsItemEntity; using (var transaction = Mobeelizer.GetDatabase().BeginTransaction()) { transaction.GetModelSet <graphsConflictsItemEntity>().DeleteOnSubmit(item); transaction.SubmitChanges(); } RefreshEntitiesList(); } }
private void RefreshEntitiesList() { this.Entities.Clear(); var database = Mobeelizer.GetDatabase(); using (var transaction = database.BeginTransaction()) { DateTime start = DateTime.Now; var query = from simpleSyncEntity entity in transaction.GetModelSet <simpleSyncEntity>() select entity; foreach (var entity in query) { this.Entities.Add(entity); String owner = entity.Owner; } DateTime end = DateTime.Now; TimeSpan difference = (end - start); Debug.WriteLine("Time is: {0} {1}", difference.Seconds, difference.Milliseconds); } }
private void StatusSelected(object arg) { int value = (int)arg; if (Mobeelizer.CheckSyncStatus().IsRunning()) { navigationService.ShowMessage(Resources.Errors.e_title, Resources.Errors.e_waitUntilSyncFinish); } else { using (var transaction = Mobeelizer.GetDatabase().BeginTransaction()) { var query = from graphsConflictsOrderEntity e in transaction.GetModelSet <graphsConflictsOrderEntity>() where e.Guid == modelGuid select e; graphsConflictsOrderEntity entity = query.Single(); entity.Status = value; transaction.SubmitChanges(); } this.navigationService.GoBack(); } }
public void Commit_Delete() { String justAddedGuid = string.Empty; using (var transaction = Mobeelizer.GetDatabase().BeginTransaction()) { var departments = transaction.GetModelSet <Department>(); Department department = new Department() { Name = "department", InternalNumber = 13 }; departments.InsertOnSubmit(department); transaction.SubmitChanges(); justAddedGuid = department.Guid; } using (var transaction = Mobeelizer.GetDatabase().BeginTransaction()) { var departments = transaction.GetModelSet <Department>(); departments.DeleteOnSubmit((from d in departments where d.Guid == justAddedGuid select d).Single()); transaction.SubmitChanges(); } using (var transaction = Mobeelizer.GetDatabase().BeginTransaction()) { var departments = transaction.GetModelSet <Department>(); var query = from d in departments where d.Guid == justAddedGuid select d; bool thrown = false; try { Department department = query.Single(); } catch { thrown = true; } Assert.IsTrue(thrown); } }
public SelectStatusViewModel(INavigationService navigationService, String modelGuid) : base(navigationService) { ICommand selectCommand = new DelegateCommand(StatusSelected); this.modelGuid = modelGuid; using (var transaction = Mobeelizer.GetDatabase().BeginTransaction()) { var query = from graphsConflictsOrderEntity e in transaction.GetModelSet <graphsConflictsOrderEntity>() where e.Guid == modelGuid select e; graphsConflictsOrderEntity entity = query.Single(); this.Title = entity.Name; } this.Options = new ObservableCollection <ListOption>(); for (int i = 1; i < 6; ++i) { this.Options.Add(new ListOption() { Status = i, Command = selectCommand }); } }
private void OnAddRelation(object param) { graphsConflictsOrderEntity order = param as graphsConflictsOrderEntity; Movie movie = DataUtil.GetRandomMovie(); graphsConflictsItemEntity entity = new graphsConflictsItemEntity(); entity.Title = movie.Title; entity.OrderGuid = order.Guid; entity.RemoveCommand = RemoveItemCommand; using (var transaction = Mobeelizer.GetDatabase().BeginTransaction()) { transaction.GetModelSet <graphsConflictsItemEntity>().InsertOnSubmit(entity); transaction.SubmitChanges(); } if (order.Items == null) { order.Items = new ObservableCollection <graphsConflictsItemEntity>(); } order.Items.Add(entity); }
private void RefreshEntitiesList() { bool inConflict = false; this.Entities.Clear(); var database = Mobeelizer.GetDatabase(); using (var transaction = database.BeginTransaction()) { var query = from graphsConflictsOrderEntity entity in transaction.GetModelSet <graphsConflictsOrderEntity>() select entity; foreach (var entity in query) { entity.Items = new ObservableCollection <graphsConflictsItemEntity>(); var relationQuery = from graphsConflictsItemEntity r in transaction.GetModelSet <graphsConflictsItemEntity>() where r.OrderGuid == entity.Guid select r; foreach (var relation in relationQuery) { if (relation.Conflicted) { inConflict = true; } relation.RemoveCommand = RemoveItemCommand; entity.Items.Add(relation); } if (entity.Conflicted) { inConflict = true; } entity.AddCommand = AddItemCommand; Entities.Add(entity); } } if (IsWarningVisable != inConflict) { IsWarningVisable = inConflict; } }
public void Commit_Validation01() { String guid; using (IMobeelizerTransaction db = Mobeelizer.GetDatabase().BeginTransaction()) { var departments = db.GetModelSet <Department>(); Department department = new Department(); department.Name = "Dep1"; department.InternalNumber = 333; departments.InsertOnSubmit(department); db.SubmitChanges(); guid = department.Guid; } using (IMobeelizerTransaction db = Mobeelizer.GetDatabase().BeginTransaction()) { var employees = db.GetModelSet <Employee>(); Employee employee = new Employee(); employee.Name = "NameNameNameNameNameNameNameNameNameNameName"; employee.Surname = "Surname"; employee.Position = "Position"; employee.Department = guid; employees.InsertOnSubmit(employee); String exceptionMessage = string.Empty; bool thrown = false; try { db.SubmitChanges(); } catch (ArgumentException e) { thrown = true; exceptionMessage = e.Message; } Assert.IsTrue(thrown); Assert.IsTrue(exceptionMessage.Contains("Name")); } }
public void Querys() { String justAddEntityGuid = string.Empty; using (IMobeelizerTransaction db = Mobeelizer.GetDatabase().BeginTransaction()) { var departmentTable = db.GetModelSet <Department>(); Department de = new Department(); de.InternalNumber = 1; de.Name = "ddd"; departmentTable.InsertOnSubmit(de); db.SubmitChanges(); justAddEntityGuid = de.Guid; } using (IMobeelizerTransaction transaction = Mobeelizer.GetDatabase().BeginTransaction()) { var employees = transaction.GetModelSet <Employee>(); Employee employee = new Employee() { Department = justAddEntityGuid, Name = "name", Position = "position", Surname = "surname", Salary = 13 }; employees.InsertOnSubmit(employee); transaction.SubmitChanges(); } using (IMobeelizerTransaction transaction = Mobeelizer.GetDatabase().BeginTransaction()) { var employees = transaction.GetModelSet <Employee>(); var departments = transaction.GetModelSet <Department>(); var query = from e in employees join d in departments on e.Department equals d.Guid select new { eName = e.Name, dName = d.Name }; int found = 0; foreach (var result in query) { ++found; } Assert.IsTrue(found > 0); } }
private void OnAdd(object param) { (this.navigationService as IFilesPageNavigationService).GetPhoto((photo) => { fileSyncEntity entity = new fileSyncEntity(); if (photo == null) { photo = this.GetRandomPhoto(); } entity.PhotoFile = photo; using (var transaction = Mobeelizer.GetDatabase().BeginTransaction()) { transaction.GetModelSet <fileSyncEntity>().InsertOnSubmit(entity); transaction.SubmitChanges(); } Deployment.Current.Dispatcher.BeginInvoke(new Action(() => { this.Entities.Add(entity); })); }); }