예제 #1
0
 public ChangePassword(PromptPageState promptPageState)
 {
     InitializeComponent();
     this.promptPageState = promptPageState;
     configuration        = AiDataStore.GetConfiguration();
     user = AiDataStore.GetUser();
 }
예제 #2
0
        public QSections(DCAnalytics.ObjectType objectType, Questionaire _questionaire, QuestionairePageState questionairePageState = null, Certification _certification = null, FieldInspection _fieldInspection = null)
        {
            InitializeComponent();
            controls                   = new UIControls(this);
            ObjectType                 = objectType;
            selectPageState            = this;
            promptPageState            = this;
            picturePageState           = this;
            locationPageState          = this;
            questionaire               = null;
            questionaire               = _questionaire;
            FieldInspection            = _fieldInspection;
            certification              = _certification;
            Title                      = questionaire.Name;
            this.questionairePageState = questionairePageState;
            sectionViews               = new List <SectionView>();
            _questionaireStatus        = string.IsNullOrEmpty(questionaire.Key) ? QuestionaireStatus.Create : QuestionaireStatus.Modify;
            _dbManager                 = new DatabaseManager();
            user          = AiDataStore.GetUser();
            configuration = AiDataStore.GetConfiguration();
            isValid       = true;

            Sections.Clear();
            Sections = (FieldInspection != null) ?
                       FieldInspection.Sections:
                       (certification != null) ?
                       certification.Sections:
                       questionaire.Sections;
            dependencies.Clear();
            navigatedTargetSections.Clear();
            controls.targets.Clear();
            Init();
        }
예제 #3
0
        protected override void OnAppearing()
        {
            base.OnAppearing();
            try
            {
                configuration = AiDataStore.GetConfiguration();
                Inspections   = configuration.Inspections.Where(x => x.FarmerKey == questionaire.Key).ToList();

                if (Inspections.Count > 0)
                {
                    fields.IsVisible      = true;
                    nofields.IsVisible    = false;
                    lfieldStack.IsVisible = true;
                    fields.ItemsSource    = Inspections;
                }
                else
                {
                    fields.IsVisible      = false;
                    nofields.IsVisible    = true;
                    lfieldStack.IsVisible = false;
                }
            }
            catch (Exception ex)
            {
            }
        }
예제 #4
0
        public ChangeUsername(PromptPageState promptPageState)
        {
            InitializeComponent();
            this.promptPageState = promptPageState;
            this.configuration   = AiDataStore.GetConfiguration();
            this.user            = AiDataStore.GetUser();

            Username.Text = user.UserName;
        }
예제 #5
0
        public Trainings(string Title = null)
        {
            InitializeComponent();
            if (!string.IsNullOrEmpty(Title))
            {
                this.Title = Title;
            }

            this.configuration = AiDataStore.GetConfiguration();
            Init();
        }
예제 #6
0
 private async void OnSynchronizationTapped(object sender, EventArgs args)
 {
     try
     {
         configuration = AiDataStore.GetConfiguration();
         (Application.Current.MainPage as MasterDetailPage).IsPresented = false;
         Synchronize = new Synchronize(this);
         await PopupNavigation.Instance.PushAsync(Synchronize);
     }
     catch (Exception ex)
     {
     }
 }
예제 #7
0
        private void Init()
        {
            try
            {
                configuration = AiDataStore.GetConfiguration();
                user          = AiDataStore.GetUser();

                names.Text    = user.Firstname + " " + user.Lastname;
                username.Text = user.UserName;
                mail.Text     = user.Email;
            }
            catch (Exception ex)
            {
            }
        }
예제 #8
0
        private void Init()
        {
            configuration = AiDataStore.GetConfiguration();
            var _purchases = configuration.Purchases.Where(x => x.Farmer == questionaire.Key).ToList();

            if (_purchases.Count > 0)
            {
                purchases.IsVisible   = true;
                nextPageFAB.IsVisible = true;
                nopurchases.IsVisible = false;
                purchases.ItemsSource = _purchases;
            }
            else
            {
                purchases.IsVisible   = false;
                nextPageFAB.IsVisible = false;
                nopurchases.IsVisible = true;
            }
        }
예제 #9
0
 private void OnSignOutTapped(object sender, EventArgs args)
 {
     try
     {
         (Application.Current.MainPage as MasterDetailPage).IsPresented = false;
         configuration = AiDataStore.GetConfiguration();
         if (!IsDataExisting())
         {
             Task.Run(async() => await PopupNavigation.Instance.PushAsync(new MessageBox("You have unsynchronized data, are you sure you want to logout?", MessageType.Logout, this)));
         }
         else
         {
             OnExit();
         }
     }
     catch (Exception ex)
     {
     }
 }
예제 #10
0
        public Purchase(Models.Purchase purchase = null, Questionaire questionaire = null)
        {
            InitializeComponent();
            configuration     = AiDataStore.GetConfiguration();
            this.questionaire = questionaire;
            this.purchase     = purchase;

            Question qn = questionaire.Sections.FirstOrDefault().Questions.Find(x => x.QuestionText == "Name");

            if (qn != null)
            {
                name.Text = qn.Answers.FirstOrDefault().AnswerText;
            }

            if (purchase != null)
            {
                Init();
            }
        }
예제 #11
0
        private void Init()
        {
            try
            {
                configuration = AiDataStore.GetConfiguration();
                User          = AiDataStore.GetUser();

                var qns = configuration.Questionaires.Where(x => x.Status == DCAnalytics.Statuses.Partial || x.Status == DCAnalytics.Statuses.Completed).ToList();
                questionaires.IsVisible     = false;
                noquestionaires.IsVisible   = false;
                progressIndicator.IsVisible = true;
                (progressIndicator.Children[0] as ActivityIndicator).IsRunning = true;

                sQLiteQuestionaires.Clear();
                sQLiteQuestionaires = new DatabaseManager().GetSQLiteQuestionaires();

                savedQuestionaires.Clear();
                annotations.Clear();

                qItems.Clear();
                if (qns.Count > 0)
                {
                    foreach (Questionaire qn in qns)
                    {
                        annotations.Add(new SymbolAnnotation
                        {
                            Coordinates = new LatLng(qn.Latitude, qn.Longitude),
                            IconImage   = (ImageSource)"ic_marker.png",
                            IconSize    = 1,
                            IconColor   = Color.Green
                        });

                        qItems.Add(new QItem
                        {
                            ID       = qn.Key,
                            Distance = (location != null) ? Location.CalculateDistance(qn.Latitude, qn.Longitude, location, DistanceUnits.Kilometers) : 0,
                            Name     = (qn.Sections.FirstOrDefault().Questions.FirstOrDefault().Answers.Count() > 0)? qn.Sections.FirstOrDefault().Questions.FirstOrDefault().Answers.FirstOrDefault().AnswerText : qn.Key,
                            Sequence = (qns.IndexOf(qn) % 2 == 0) ? 0 : 1
                        });
                    }
                }

                progressIndicator.IsVisible = false;
                (progressIndicator.Children[0] as ActivityIndicator).IsRunning = false;

                //if no questionaires are saved
                if (qItems.Count == 0)
                {
                    noquestionaires.IsVisible = true;
                    nextPageFAB.IsVisible     = false;
                    questionaires.IsVisible   = false;
                }
                else
                {
                    map.ZoomLevel        = Device.RuntimePlatform == Device.Android ? 10 : 17;
                    map.LogoEnabled      = false;
                    map.CompassEnabled   = true;
                    map.ShowUserLocation = true;
                    map.Annotations      = annotations;
                    if (location != null)
                    {
                        map.Center = new LatLng(location.Latitude, location.Longitude);
                    }

                    questionaires.IsVisible   = true;
                    nextPageFAB.IsVisible     = true;
                    questionaires.ItemsSource = null;
                    questionaires.ItemsSource = qItems;
                }
            }
            catch (Exception ex)
            {
                Log.Warning("SqlLite Exception ", ex.Message);
            }
        }
예제 #12
0
 public SignIn()
 {
     InitializeComponent();
     configuration       = AiDataStore.GetConfiguration();
     Password.IsPassword = true;
 }