Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
        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;
            }
        }
Ejemplo n.º 3
0
        private void ScoreSelected(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 conflictsEntity e in transaction.GetModelSet <conflictsEntity>() where e.Guid == modelGuid select e;
                    conflictsEntity entity = query.Single();

                    entity.Score = value;
                    transaction.SubmitChanges();
                }

                this.navigationService.GoBack();
            }
        }
Ejemplo n.º 4
0
        public SelectScorePageViewModel(INavigationService navigationService, String modelGuid)
            : base(navigationService)
        {
            ICommand selectCommand = new DelegateCommand(ScoreSelected);

            this.modelGuid = modelGuid;
            using (var transaction = Mobeelizer.GetDatabase().BeginTransaction())
            {
                var             query  = from conflictsEntity e in transaction.GetModelSet <conflictsEntity>() where e.Guid == modelGuid select e;
                conflictsEntity entity = query.Single();
                this.Title = entity.Title;
            }

            this.Options = new ObservableCollection <ListOption>();
            for (int i = 1; i < 6; ++i)
            {
                this.Options.Add(new ListOption()
                {
                    Score = i, Command = selectCommand
                });
            }
        }
Ejemplo n.º 5
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);
                }));
            });
        }
Ejemplo n.º 6
0
        public void Commit_Validation02()
        {
            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();
            }

            using (IMobeelizerTransaction db = Mobeelizer.GetDatabase().BeginTransaction())
            {
                var      employees = db.GetModelSet <Employee>();
                Employee employee  = new Employee();
                employee.Name       = "Name";
                employee.Surname    = "Surname";
                employee.Position   = "Position";
                employee.Department = "wrong 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("Department"));
            }
        }
Ejemplo n.º 7
0
        private void OnSendToB(object args)
        {
            this.BusyMessage = "Sending push notification";
            this.IsBusy      = true;
            IDictionary <String, String> notification = new Dictionary <String, String>();

            notification.Add("X-NotificationClass", "2");
            notification.Add("X-WindowsPhone-Target", "toast");
            notification.Add("Text1", "Push received!");
            notification.Add("Text2", "Wp7 device greets user B.");
            notification.Add("Param", "/View/MainPage.xaml");
            notification.Add("alert", "Wp7 device greets user B.");
            IList <String> users = new List <String>();

            users.Add("B");
            Mobeelizer.SendRemoteNotificationToUsers(notification, users, (error) =>
            {
                this.IsBusy = false;
                if (error != null)
                {
                    this.navigationService.ShowMessage(Resources.Errors.e_title, "Unable to send push notification.");
                }
            });
        }
Ejemplo n.º 8
0
 // Code to execute when the application is closing (eg, user hit Back)
 // This code will not execute when the application is deactivated
 private void Application_Closing(object sender, ClosingEventArgs e)
 {
     Mobeelizer.OnClosing();
 }
Ejemplo n.º 9
0
 // Code to execute when the application is deactivated (sent to background)
 // This code will not execute when the application is closing
 private void Application_Deactivated(object sender, DeactivatedEventArgs e)
 {
     Mobeelizer.OnDeactivated();
 }
Ejemplo n.º 10
0
 // Code to execute when the application is activated (brought to foreground)
 // This code will not execute when the application is first launched
 private void Application_Activated(object sender, ActivatedEventArgs e)
 {
     Mobeelizer.OnActivated(e.IsApplicationInstancePreserved);
 }
Ejemplo n.º 11
0
 // Code to execute when the application is launching (eg, from Start)
 // This code will not execute when the application is reactivated
 private void Application_Launching(object sender, LaunchingEventArgs e)
 {
     Mobeelizer.OnLaunching();
     PushNotificationService.Instance.RegisterForRemoteNotification();
 }
Ejemplo n.º 12
0
 public void _OnLaunching()
 {
     Mobeelizer.OnLaunching();
 }
Ejemplo n.º 13
0
 private void PushChannel_ErrorOccurred(object sender, NotificationChannelErrorEventArgs e)
 {
     channelUri = null;
     Mobeelizer.UnregisterForRemoteNotifications((result) => { });
 }