Ejemplo n.º 1
0
        void TestService()
        {
            RegServices.Service service = new RegServices.Service(ProgramVars.URL);

            LoadSyncInput inputObject = new LoadSyncInput()
            {
                installationID = 1, userID = "ff38aa48-20cd-40fd-b90b-a106ec9e3b13", loadSyncList = "Status|MobUser|RegistrationType", parameters = ""
            };

            service.Load(inputObject, (response) =>
            {
                string message;
                if (service.HasError)
                {
                    message = "ERROR : " + service.Error;
                }
                else
                {
                    message = "Upload done :" + response.status;
                }
                Action action = delegate
                {
                    //App.mainLabel.Text = message;
                    LoginPage startPage = new LoginPage();
                    MainPage.Navigation.PushAsync(startPage, true);
                };
                Device.BeginInvokeOnMainThread(action);
            });


            //service.Execute();
        }
Ejemplo n.º 2
0
        async Task <RestLoadResult> TestHttpService()
        {
            RegServices.MobRegService service     = new RegServices.MobRegService(ProgramVars.URL);
            LoadSyncInput             inputObject = new LoadSyncInput()
            {
                installationID = 1, userID = "ff38aa48-20cd-40fd-b90b-a106ec9e3b13", loadSyncList = "Status", parameters = ""
            };

            RestLoadResult result = await service.LoadAsync(inputObject);

            return(result);
        }
Ejemplo n.º 3
0
 public void Load(LoadSyncInput input, Action <RestLoadResult> whenCompleted)
 {
     ProcessRestRequest <LoadSyncInput, RestLoadResult>("Load", input, whenCompleted);
 }
Ejemplo n.º 4
0
        private async Task LoadLookupDataAsync()
        {
            ShowActivityUI(true);

            RegServices.MobRegService service     = new RegServices.MobRegService(ProgramVars.URL);
            LoadSyncInput             inputObject = new LoadSyncInput()
            {
                installationID = App.appSettings.installationID,
                userID         = App.appSettings.loginVars.userID.ToString(),
                loadSyncList   = "Status|RegistrationType|MobUser",
                parameters     = ""
            };

            RestLoadResult result = await service.LoadAsync(inputObject);

            if (result.statusCode != 0)
            {
                ShowActivityUI(false);
                await DisplayAlert(AppResources.Error, result.status, AppResources.OK);
            }
            else
            {
                App.dbHandler.db.DeleteAll <RegistrationType> ();
                App.dbHandler.db.DeleteAll <Status> ();
                //App.dbHandler.db.DeleteAll<MobUser> ();

                if (result.RegistrationTypes != null)
                {
                    foreach (rsRegistrationType rt in result.RegistrationTypes)
                    {
                        RegistrationType regType = new RegistrationType()
                        {
                            ID = rt.ID, Name = rt.Name
                        };
                        switch (rt.ID)
                        {
                        case RegistrationTypes.Text:
                            regType.icon = "text.png";
                            break;

                        case RegistrationTypes.Picture:
                            regType.icon = "picture.png";
                            break;

                        case RegistrationTypes.SingleChoice:
                            regType.icon = "single.png";
                            break;

                        default:
                            regType.icon = "questionmark.png";
                            break;
                        }
                        App.dbHandler.db.Insert(regType);
                    }
                }

                if (result.Status != null)
                {
                    foreach (rsStatus st in result.Status)
                    {
                        Status status = new Status()
                        {
                            ID          = st.ID,
                            Text        = st.Text,
                            R           = st.R,
                            G           = st.G,
                            B           = st.B,
                            doStopTime  = st.doStopTime,
                            doStartTime = st.doStartTime
                        };
                        switch (st.ID)
                        {
                        case StatusTypes.Planned:
                            status.iconBlack = "planned.png";
                            break;

                        case StatusTypes.Accepted:
                            status.iconBlack = "accepted.png";
                            break;

                        case StatusTypes.DriveTo:
                            status.iconBlack = "driveto.png";
                            break;

                        case StatusTypes.Started:
                            status.iconBlack = "started.png";
                            break;

                        case StatusTypes.Pauzed:
                            status.iconBlack = "pauzed.png";
                            break;

                        case StatusTypes.Stopped:
                            status.iconBlack = "stopped.png";
                            break;

                        case StatusTypes.DriveFrom:
                            status.iconBlack = "drivefrom.png";
                            break;

                        case StatusTypes.FinishedOK:
                            status.iconBlack = "ok.png";
                            break;

                        case StatusTypes.FinishedNOK:
                            status.iconBlack = "nok.png";
                            break;

                        default:
                            status.iconBlack = "questionmark,png";
                            break;
                        }
                        App.dbHandler.db.Insert(status);
                    }             //end foreach
                }                 // end if null

                ShowActivityUI(false);
            }
        }
Ejemplo n.º 5
0
        private async Task SynchronizeDataAsync()
        {
            ShowActivityUI(true);

            SQLiteConnection db = App.dbHandler.db;

            //db.DeleteAll<Article> ();
            //db.DeleteAll<ArticleGroup> ();

            var  articles         = db.Query <Article> ("select * from Article ORDER by SysRevision DESC");
            long maxSysRevArticle = articles.FirstOrDefault() == null ? 0 : articles.FirstOrDefault().SysRevision;
            //db.Execute("select MAX(SysRevision) from Article");
            var  articleGroups         = db.Query <Article> ("select * from ArticleGroup ORDER by SysRevision DESC");
            long maxSysRevArticleGroup = articleGroups.FirstOrDefault() == null ? 0 : articleGroups.FirstOrDefault().SysRevision;

            //= db.Execute("select MAX(SysRevision) from ArticleGroup");

            RegServices.MobRegService service     = new RegServices.MobRegService(ProgramVars.URL);
            LoadSyncInput             inputObject = new LoadSyncInput()
            {
                installationID = App.appSettings.installationID,
                userID         = App.appSettings.loginVars.userID.ToString(),
                loadSyncList   = string.Format("Article={0:d}|ArticleGroup={1:d}", maxSysRevArticle, maxSysRevArticleGroup),
                parameters     = ""
            };

            RestSyncResult result = await service.SynchronizeAsync(inputObject);

            if (result.statusCode != 0)
            {
                ShowActivityUI(false);
                await DisplayAlert(AppResources.Error, result.status, AppResources.Cancel);
            }
            else
            {
                if (result.Articles != null)
                {
                    foreach (rsArticle a in result.Articles)
                    {
                        Article article = db.Find <Article> (a.ID);
                        if (article != null)
                        {
                            if (a.SysDeleted)
                            {
                                db.Delete(article);
                            }
                            else
                            {
                                article.SysRevision = a.SysRevision;
                                article.Name        = a.Name;
                                article.GroupID     = a.GroupID;
                                db.Update(article);
                            }
                        }
                        else
                        {
                            if (!a.SysDeleted)
                            {
                                article = new Article(a);
                                db.Insert(article);
                            }
                        }
                    }
                }
                if (result.ArticleGroups != null)
                {
                    foreach (rsArticleGroup g in result.ArticleGroups)
                    {
                        ArticleGroup artGroup = db.Find <ArticleGroup> (g.ID);
                        if (artGroup != null)
                        {
                            if (g.SysDeleted)
                            {
                                db.Delete(artGroup);
                            }
                            else
                            {
                                artGroup.Name        = g.Name;
                                artGroup.SysRevision = g.SysRevision;
                                db.Update(artGroup);
                            }
                        }
                        else
                        {
                            if (!g.SysDeleted)
                            {
                                artGroup = new ArticleGroup(g);
                                db.Insert(artGroup);
                            }
                        }
                    }
                }

                //end foreach
            }             // end if null

            ShowActivityUI(false);
        }
Ejemplo n.º 6
0
 public async Task <RestSyncResult> SynchronizeAsync(LoadSyncInput input)
 {
     return(await ProcessAsync <LoadSyncInput, RestSyncResult> ("Synchronize", input, new RestSyncResult()));
 }
Ejemplo n.º 7
0
 public async Task <RestLoadResult> LoadAsync(LoadSyncInput input)
 {
     return(await ProcessAsync <LoadSyncInput, RestLoadResult> ("Load", input, new RestLoadResult()));
 }