protected override void OnAppearing()
        {
            base.OnAppearing();

            ActivityLogger.AddLogger("Finish page On Appearing... Feedback data saved.");

            DateTime localDate = DateTime.Now;

            SaveRatings.SaveRatingInstance._endTime = localDate.ToString();

            SaveRatings.SaveRatingInstance.SaveRating(); // Save Data
        }
示例#2
0
        public void ContactDB()
        {
            Console.WriteLine("Contacting DB...");

            ClearOldData();

            Console.WriteLine(Settings.Language);
            Console.WriteLine(Settings.HotelCode);

            GetResult(Settings.HotelCode, Settings.Language, "GC"); // Execute method for get data from DB

            ActivityLogger.AddLogger("Retrived question data from DB"
                                     + Settings.HotelCode + "as Hotel, "
                                     + Settings.Language + "as Language, "
                                     + "and area code GC"
                                     );

            Console.WriteLine("DB connection success...");
        }
        private async void HandleClick(object sender, EventArgs e)
        {
            string isGiven = await CheckIsFeedbackGiven(Settings.HotelCode, resNoEditor.Text, guestID).ConfigureAwait(true);

            if (isGiven == "true")
            {
                await DisplayAlert("Hey!", "Selected person had already given a feedback", "OK");

                ActivityLogger.AddLogger("Selected Guest " + guestID + " had already given a feedback");
            }
            else
            {
                SaveRatings sr = SaveRatings.SaveRatingInstance;
                sr._hotelCode  = Settings.HotelCode;
                sr._roomNum    = roomNoEditor.Text;
                sr._resNum     = resNoEditor.Text;
                sr._guestID    = guestID;
                sr._guestName  = guestName;
                sr._guestPhone = guestPhoneEditor.Text;
                sr._guestEmail = guestMailEditor.Text;
                sr._arrDate    = this.arriveDate;
                sr._depDate    = this.departDate;
                sr._createdBy  = deviceID;

                ActivityLogger.AddLogger("Submitted Guest Details : "
                                         + sr._hotelCode + "as hotel code,"
                                         + sr._roomNum + "as room number,"
                                         + sr._resNum + "as reservation number,"
                                         + sr._guestID + "as guest ID,"
                                         + sr._guestName + "as guest name,"
                                         + sr._guestEmail + "as guest mail,"
                                         + sr._guestPhone + "as guest phone,"
                                         + sr._arrDate + "as arraival date,"
                                         + sr._depDate + "as departure date,"
                                         + sr._createdBy + "as device ID,"
                                         );

                await Navigation.PushAsync(new PageGen());
            }
        }
示例#4
0
        public static async Task <bool> ClearLogger()
        {
            ActivityLogger.AddLogger("Clear Activity Logger");
            Console.WriteLine("Clear Activity Logger");

            IFolder folder     = FileSystem.Current.LocalStorage;
            string  fileName   = "CGFS_Logger.txt";
            string  folderName = "CGFS Database";

            IFolder existFolder = await folder.GetFolderAsync(folderName);

            bool b = await PCLStorageHelper.DeleteFile(fileName, existFolder);

            if (b)
            {
                await InitPCLStorage();

                return(true);
            }
            else
            {
                return(false);
            }
        }
        /*
         * Method       :   InitComp
         * Task         :   Creates Page UI Dynamically
         */
        private void InitComp()
        {
            var layout = new StackLayout();

            layout.BackgroundColor = Color.Black;
            layout.VerticalOptions = LayoutOptions.StartAndExpand;

            var titleImage = new Image {
                Aspect = Aspect.AspectFit
            };

            titleImage.Source        = ImageSource.FromFile("images/cinnamon.png");
            titleImage.HeightRequest = 150;

            var titleLabel = new Label
            {
                Text     = "Please provide your contact details",
                FontSize = 24,
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment   = TextAlignment.Center,
                TextColor         = Color.White,
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                HeightRequest     = 200
            };

            var formLayout = new StackLayout();

            formLayout.Orientation     = StackOrientation.Vertical;
            formLayout.VerticalOptions = LayoutOptions.StartAndExpand;

            var guestPhoneLabel = new Label
            {
                Text      = "Mobile Phone Number",
                FontSize  = 18,
                TextColor = Color.White,
                HorizontalTextAlignment = TextAlignment.Start,
                VerticalTextAlignment   = TextAlignment.Center,
                VerticalOptions         = LayoutOptions.Start,
                HeightRequest           = 40,
            };

            guestPhoneEditor = new Entry
            {
                Placeholder   = "Your Mobile Number",
                Text          = SaveRatings.SaveRatingInstance._guestPhone,
                HeightRequest = 40,
                Keyboard      = Keyboard.Telephone
            };

            //Navigation

            var baseLayout = new StackLayout();

            baseLayout.Orientation       = StackOrientation.Vertical;
            baseLayout.HorizontalOptions = LayoutOptions.Center;
            baseLayout.VerticalOptions   = LayoutOptions.Center;

            var buttonPanel = new StackLayout();

            buttonPanel.Orientation       = StackOrientation.Horizontal;
            buttonPanel.HorizontalOptions = LayoutOptions.Center;

            var nextBtn = new Image {
                Aspect = Aspect.AspectFit
            };

            nextBtn.Source            = ImageSource.FromFile("images/next.png");
            nextBtn.WidthRequest      = 60;
            nextBtn.HeightRequest     = 60;
            nextBtn.HorizontalOptions = LayoutOptions.EndAndExpand;
            nextBtn.Margin            = new Thickness(820, 60);

            var backBtn = new Image {
                Aspect = Aspect.AspectFit
            };

            backBtn.Source            = ImageSource.FromFile("images/back.png");
            backBtn.WidthRequest      = 60;
            backBtn.HeightRequest     = 60;
            backBtn.HorizontalOptions = LayoutOptions.StartAndExpand;
            backBtn.Margin            = new Thickness(10, 60);

            buttonPanel.Children.Add(backBtn);
            buttonPanel.Children.Add(nextBtn);

            baseLayout.Children.Add(buttonPanel);

            /*
             * Event        :   guestPhoneEditor Completed Event
             * Task         :   Sets entered phone Number to 'SaveRatings' properties
             */
            guestPhoneEditor.TextChanged += delegate {
                if (guestPhoneEditor.Text.Length > 13)
                {
                    guestPhoneEditor.Text = guestPhoneEditor.Text.Remove(guestPhoneEditor.Text.Length - 1);
                }

                if (validator.MobileNumberValidator(guestPhoneEditor.Text))
                {
                    guestPhoneEditor.BackgroundColor = Color.FromRgb(205, 255, 196);;
                    validated = true;
                }
                else
                {
                    guestPhoneEditor.BackgroundColor = Color.FromRgb(255, 153, 168);
                    validated = false;
                }

                SaveRatings sr = SaveRatings.SaveRatingInstance;
                sr._guestPhone = guestPhoneEditor.Text;
            };

            guestPhoneEditor.Completed += delegate
            {
                guestMailEditor.Focus();
            };

            var guestMailLabel = new Label
            {
                Text                    = "E Mail Address",
                FontSize                = 18,
                TextColor               = Color.White,
                VerticalOptions         = LayoutOptions.Start,
                HorizontalTextAlignment = TextAlignment.Start,
                VerticalTextAlignment   = TextAlignment.Center,
                HeightRequest           = 40,
            };

            guestMailEditor = new Entry
            {
                Placeholder   = "Your e mail",
                HeightRequest = 40,
                Text          = SaveRatings.SaveRatingInstance._guestEmail,
                Keyboard      = Keyboard.Email
            };

            /*
             * Event        :   guestMailEditor Completed Event
             * Task         :   Sets entered email to 'SaveRatings' properties
             */
            guestMailEditor.TextChanged += delegate
            {
                if (validator.EmailValidator(guestMailEditor.Text))
                {
                    guestMailEditor.BackgroundColor = Color.FromRgb(205, 255, 196);
                    validated = true;
                }
                else
                {
                    guestMailEditor.BackgroundColor = Color.FromRgb(255, 153, 168);
                    validated = false;
                }

                SaveRatings sr = SaveRatings.SaveRatingInstance;
                sr._guestEmail = guestMailEditor.Text;
            };


            var backtapRecognizer = new TapGestureRecognizer();

            backtapRecognizer.Tapped += (s, e) =>
            {
                Navigation.PopAsync();
            };

            var NexttapRecognizer = new TapGestureRecognizer();

            NexttapRecognizer.Tapped += (s, e) =>
            {
                if (validator.EmailValidator(guestMailEditor.Text))
                {
                    guestMailEditor.BackgroundColor = Color.FromRgb(205, 255, 196);
                }
                else
                {
                    guestMailEditor.BackgroundColor = Color.FromRgb(255, 153, 168);
                    validated            = false;
                    guestMailEditor.Text = "";
                    guestMailEditor.Focus();
                }

                if (validator.MobileNumberValidator(guestPhoneEditor.Text))
                {
                    guestPhoneEditor.BackgroundColor = Color.FromRgb(205, 255, 196);;
                }
                else
                {
                    guestPhoneEditor.BackgroundColor = Color.FromRgb(255, 153, 168);
                    validated             = false;
                    guestPhoneEditor.Text = "";
                    guestPhoneEditor.Focus();
                }

                if (guestMailEditor.Text == "")
                {
                    validated = true;
                }

                if (guestPhoneEditor.Text == "")
                {
                    validated = true;
                }

                if (validated)
                {
                    ActivityLogger.AddLogger("Contact details entered and validated");

                    Navigation.PushAsync(new EndPage());
                }
            };

            backBtn.GestureRecognizers.Add(backtapRecognizer);
            nextBtn.GestureRecognizers.Add(NexttapRecognizer);

            //---------------------------------------------------------

            layout.Children.Add(titleImage);
            layout.Children.Add(titleLabel);
            layout.Children.Add(formLayout);
            layout.Children.Add(baseLayout);

            formLayout.Children.Add(guestPhoneLabel);
            formLayout.Children.Add(guestPhoneEditor);
            formLayout.Children.Add(guestMailLabel);
            formLayout.Children.Add(guestMailEditor);

            formLayout.Padding = new Thickness(150, 10, 150, 10);

            layout.Padding = 10;
            layout.Spacing = 10;

            Content = layout;
        }
        /*
         * Method       :   InitComp
         * Task         :   Creates Page UI Dynamically
         */
        private void InitComp()
        {
            var layout = new StackLayout();

            layout.BackgroundColor = Color.Black;
            layout.VerticalOptions = LayoutOptions.CenterAndExpand;

            var titleLabel = new Label
            {
                Text                  = "App Configurations",
                FontSize              = 24,
                TextColor             = Color.White,
                VerticalOptions       = LayoutOptions.Center,
                HorizontalOptions     = LayoutOptions.Center,
                VerticalTextAlignment = TextAlignment.Center,
                HeightRequest         = 100
            };

            var formLayout = new StackLayout();

            formLayout.BackgroundColor = Color.DarkSlateGray;
            formLayout.Orientation     = StackOrientation.Vertical;
            formLayout.VerticalOptions = LayoutOptions.Center;


            var hotelLabel = new Label
            {
                Text                  = "Hotel",
                FontSize              = 18,
                TextColor             = Color.White,
                VerticalOptions       = LayoutOptions.Start,
                VerticalTextAlignment = TextAlignment.End,
                HeightRequest         = 40
            };

            var hotelList = new List <string>();

            hotelList.Add("Cinnamon Grand");
            hotelList.Add("Cinnamon Lakeside");
            hotelList.Add("Cinnamon Red");
            hotelList.Add("Cinnamon Bey");
            hotelList.Add("Cinnamon Lodge");
            hotelList.Add("Cinnamon Citadel");
            hotelList.Add("Cinnamon Wild");
            hotelList.Add("Trinco Blu By Cinnamon");
            hotelList.Add("Habarana Village By Cinnamon");
            hotelList.Add("Bentota Beach By Cinnamon");
            hotelList.Add("Hikka Tranz By Cinnamon");
            hotelList.Add("Cinnamon Dhonveli Maldives");
            hotelList.Add("Cinnamon Hakuraa Huraa Maldives");
            hotelList.Add("Ellaidhoo Maldives By Cinnamon");

            hotelPicker = new Picker
            {
                Title         = "Select your place",
                ItemsSource   = hotelList,
                TextColor     = Color.Black,
                HeightRequest = 40,
                SelectedItem  = Settings.HotelName
            };

            var hotelNumber = new Label
            {
                Text                  = "Hotel No:",
                FontSize              = 18,
                TextColor             = Color.White,
                VerticalOptions       = LayoutOptions.Start,
                VerticalTextAlignment = TextAlignment.End,
                HeightRequest         = 40,
            };

            var hotelNumberEditor = new Entry
            {
                Placeholder   = "Hotel Number",
                HeightRequest = 40,
                TextColor     = Color.Black,
                IsEnabled     = false,
                Text          = Settings.HotelNumber
            };

            var hotelCode = new Label
            {
                Text                  = "Hotel Code:",
                FontSize              = 18,
                TextColor             = Color.White,
                VerticalOptions       = LayoutOptions.Start,
                VerticalTextAlignment = TextAlignment.End,
                HeightRequest         = 40,
            };

            var hotelCodeEditor = new Entry
            {
                Placeholder   = "Hotel Code",
                HeightRequest = 40,
                TextColor     = Color.Black,
                IsEnabled     = false,
                Text          = Settings.HotelCode
            };

            var developmentLabel = new Label
            {
                Text                  = "Development API",
                FontSize              = 18,
                TextColor             = Color.White,
                VerticalOptions       = LayoutOptions.Start,
                VerticalTextAlignment = TextAlignment.End,
                HeightRequest         = 40,
            };

            var DevelopmentEntry = new Entry
            {
                Text          = Settings.DevelopmentUrl,
                Placeholder   = "Development Uri",
                HeightRequest = 40,
                TextColor     = Color.Black,
            };

            var ProductionLabel = new Label
            {
                Text                  = "Production API",
                FontSize              = 18,
                TextColor             = Color.White,
                VerticalOptions       = LayoutOptions.Start,
                VerticalTextAlignment = TextAlignment.End,
                HeightRequest         = 40,
            };

            var ProductionEntry = new Entry
            {
                Text          = Settings.ProductionUrl,
                Placeholder   = "Get Guest Details API",
                HeightRequest = 40,
                TextColor     = Color.Black,
            };


            var APIMsubkeyDevLabel = new Label
            {
                Text                  = "APIM Dev Subscription Key",
                FontSize              = 18,
                TextColor             = Color.White,
                VerticalOptions       = LayoutOptions.Start,
                VerticalTextAlignment = TextAlignment.End,
                HeightRequest         = 40,
            };

            var APIMsubkeyDevEntry = new Entry
            {
                Text          = Settings.SubscriptionKey_Dev,
                Placeholder   = "Sub key dev",
                HeightRequest = 40,
                TextColor     = Color.Black,
            };

            var APIMsubkeyPrdLabel = new Label
            {
                Text                  = "APIM PRD Subscription Key",
                FontSize              = 18,
                TextColor             = Color.White,
                VerticalOptions       = LayoutOptions.Start,
                VerticalTextAlignment = TextAlignment.End,
                HeightRequest         = 40,
            };

            var APIMsubkeyPrdEntry = new Entry
            {
                Text          = Settings.SubscriptionKey_Prd,
                Placeholder   = "Sub key Prd",
                HeightRequest = 40,
                TextColor     = Color.Black,
            };

            var DevDateLabel = new Label
            {
                Text                  = "Dev Guest Inhouse Date",
                FontSize              = 18,
                TextColor             = Color.White,
                VerticalOptions       = LayoutOptions.Start,
                VerticalTextAlignment = TextAlignment.End,
                HeightRequest         = 40,
            };

            var DevDateEntry = new Entry
            {
                Text          = Settings.DevelopmentInhouseDate,
                Placeholder   = "Dev Date",
                HeightRequest = 40,
                TextColor     = Color.Black,
            };

            var MailSenderPW = new Label
            {
                Text                  = "SMTP password",
                FontSize              = 18,
                TextColor             = Color.White,
                VerticalOptions       = LayoutOptions.Start,
                VerticalTextAlignment = TextAlignment.End,
                HeightRequest         = 40,
            };

            var smtpPWEntry = new Entry
            {
                IsPassword    = true,
                Text          = Settings.SMTPPassword,
                Placeholder   = "password",
                HeightRequest = 40,
                TextColor     = Color.Black,
            };

            var switcherLayout = new StackLayout();

            switcherLayout.Orientation     = StackOrientation.Horizontal;
            switcherLayout.VerticalOptions = LayoutOptions.Center;

            var swicherLabel = new Label
            {
                Text                  = "Switch Production Domain",
                FontSize              = 18,
                TextColor             = Color.White,
                VerticalOptions       = LayoutOptions.Center,
                VerticalTextAlignment = TextAlignment.Center,
                HeightRequest         = 40,
            };

            swicherStatLabel = new Label
            {
                Text                  = "Development",
                FontSize              = 18,
                TextColor             = Color.Red,
                VerticalOptions       = LayoutOptions.Center,
                VerticalTextAlignment = TextAlignment.Center,
                HeightRequest         = 40,
                WidthRequest          = 200
            };

            var switcher = new Switch
            {
                VerticalOptions = LayoutOptions.Center,
                IsToggled       = Settings.DomainSwitcher
            };

            switcher.Toggled += delegate
            {
                if (switcher.IsToggled)
                {
                    swicherStatLabel.Text      = "Production";
                    swicherStatLabel.TextColor = Color.LightGreen;
                    Settings.DomainSwitcher    = true;
                }
                else
                {
                    swicherStatLabel.Text      = "Development";
                    swicherStatLabel.TextColor = Color.Red;
                    Settings.DomainSwitcher    = false;
                }
            };

            switcherLayout.Children.Add(swicherLabel);
            switcherLayout.Children.Add(switcher);
            switcherLayout.Children.Add(swicherStatLabel);

            var buttonLayout = new StackLayout();

            buttonLayout.BackgroundColor = Color.DarkSlateGray;
            buttonLayout.Orientation     = StackOrientation.Horizontal;
            buttonLayout.VerticalOptions = LayoutOptions.Center;

            var submitButton = new Button
            {
                Text              = "Submit",
                FontSize          = 36,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                HeightRequest     = 60,
                WidthRequest      = 150
            };

            var loggerButton = new Button
            {
                Text              = "Activity Logger",
                FontSize          = 20,
                TextColor         = Color.Yellow,
                HorizontalOptions = LayoutOptions.End,
                VerticalOptions   = LayoutOptions.End,
                HeightRequest     = 60,
                WidthRequest      = 200
            };

            hotelPicker.SelectedIndexChanged += delegate
            {
                if ((string)hotelPicker.ItemsSource[hotelPicker.SelectedIndex] == "Cinnamon Grand")
                {
                    hotelNumberEditor.Text = "3000";
                    SelectedHotel          = "Cinnamon Grand";
                    HotelCode            = "CNG";
                    hotelCodeEditor.Text = "CNG";
                }
                else if ((string)hotelPicker.ItemsSource[hotelPicker.SelectedIndex] == "Cinnamon Lakeside")
                {
                    hotelNumberEditor.Text = "3005";
                    SelectedHotel          = "Cinnamon Lakeside";
                    HotelCode            = "CNL";
                    hotelCodeEditor.Text = "CNL";
                }
                else if ((string)hotelPicker.ItemsSource[hotelPicker.SelectedIndex] == "Cinnamon Red")
                {
                    hotelNumberEditor.Text = "3015";
                    SelectedHotel          = "Cinnamon Red";
                    HotelCode            = "RED";
                    hotelCodeEditor.Text = "RED";
                }
                else if ((string)hotelPicker.ItemsSource[hotelPicker.SelectedIndex] == "Bentota Beach By Cinnamon")
                {
                    hotelNumberEditor.Text = "3100";
                    SelectedHotel          = "Bentota Beach By Cinnamon";
                    HotelCode            = "BBH";
                    hotelCodeEditor.Text = "BBH";
                }
                else if ((string)hotelPicker.ItemsSource[hotelPicker.SelectedIndex] == "Cinnamon Citadel")
                {
                    hotelNumberEditor.Text = "3110";
                    SelectedHotel          = "Cinnamon Citadel";
                    HotelCode            = "CIT";
                    hotelCodeEditor.Text = "CIT";
                }
                else if ((string)hotelPicker.ItemsSource[hotelPicker.SelectedIndex] == "Cinnamon Lodge")
                {
                    hotelNumberEditor.Text = "3115";
                    SelectedHotel          = "Cinnamon Lodge";
                    HotelCode            = "LOD";
                    hotelCodeEditor.Text = "LOD";
                }
                else if ((string)hotelPicker.ItemsSource[hotelPicker.SelectedIndex] == "Habarana Village By Cinnamon")
                {
                    hotelNumberEditor.Text = "3120";
                    SelectedHotel          = "Habarana Village By Cinnamon";
                    HotelCode            = "VIL";
                    hotelCodeEditor.Text = "VIL";
                }
                else if ((string)hotelPicker.ItemsSource[hotelPicker.SelectedIndex] == "Cinnamon Wild")
                {
                    hotelNumberEditor.Text = "3150";
                    SelectedHotel          = "Cinnamon Wild";
                    HotelCode            = "WLD";
                    hotelCodeEditor.Text = "WLD";
                }
                else if ((string)hotelPicker.ItemsSource[hotelPicker.SelectedIndex] == "Cinnamon Bey")
                {
                    hotelNumberEditor.Text = "3160";
                    SelectedHotel          = "Cinnamon Bey";
                    HotelCode            = "BEY";
                    hotelCodeEditor.Text = "BEY";
                }
                else if ((string)hotelPicker.ItemsSource[hotelPicker.SelectedIndex] == "Trinco Blu By Cinnamon")
                {
                    hotelNumberEditor.Text = "3165";
                    SelectedHotel          = "Trinco Blu By Cinnamon";
                    HotelCode            = "BLU";
                    hotelCodeEditor.Text = "BLU";
                }
                else if ((string)hotelPicker.ItemsSource[hotelPicker.SelectedIndex] == "Hikka Tranz By Cinnamon")
                {
                    hotelNumberEditor.Text = "3170";
                    SelectedHotel          = "Hikka Tranz By Cinnamon";
                    HotelCode            = "TRA";
                    hotelCodeEditor.Text = "TRA";
                }
                else if ((string)hotelPicker.ItemsSource[hotelPicker.SelectedIndex] == "Ellaidhoo Maldives By Cinnamon")
                {
                    hotelNumberEditor.Text = "3300";
                    SelectedHotel          = "Ellaidhoo Maldives By Cinnamon";
                    HotelCode            = "ELL";
                    hotelCodeEditor.Text = "ELL";
                }
                else if ((string)hotelPicker.ItemsSource[hotelPicker.SelectedIndex] == "Cinnamon Dhonveli Maldives")
                {
                    hotelNumberEditor.Text = "3310";
                    SelectedHotel          = "Cinnamon Dhonveli Maldives";
                    HotelCode            = "DHO";
                    hotelCodeEditor.Text = "DHO";
                }
                else if ((string)hotelPicker.ItemsSource[hotelPicker.SelectedIndex] == "Cinnamon Hakuraa Huraa Maldives")
                {
                    hotelNumberEditor.Text = "3305";
                    SelectedHotel          = "Cinnamon Hakuraa Huraa Maldives";
                    HotelCode            = "HAK";
                    hotelCodeEditor.Text = "HAK";
                }
                else
                {
                    //Do Nothing
                }
            };


            submitButton.Clicked += async delegate
            {
                Settings.DomainSwitcher         = switcher.IsToggled;
                Settings.HotelName              = SelectedHotel;
                Settings.HotelNumber            = hotelNumberEditor.Text;
                Settings.DevelopmentUrl         = DevelopmentEntry.Text;
                Settings.ProductionUrl          = ProductionEntry.Text;
                Settings.SubscriptionKey_Dev    = APIMsubkeyDevEntry.Text;
                Settings.SubscriptionKey_Prd    = APIMsubkeyPrdEntry.Text;
                Settings.HotelCode              = HotelCode;
                Settings.DevelopmentInhouseDate = DevDateEntry.Text;
                Settings.SMTPPassword           = smtpPWEntry.Text;

                ActivityLogger.AddLogger("App Configuration Settings Changed.");

                await Navigation.PopToRootAsync();
            };

            loggerButton.Clicked += async delegate
            {
                await Navigation.PushAsync(new LoggerView());
            };

            buttonLayout.Children.Add(submitButton);
            switcherLayout.Children.Add(loggerButton);

            formLayout.Children.Add(titleLabel);

            formLayout.Children.Add(switcherLayout);
            formLayout.Children.Add(hotelLabel);
            formLayout.Children.Add(hotelPicker);
            formLayout.Children.Add(hotelNumber);
            formLayout.Children.Add(hotelNumberEditor);
            formLayout.Children.Add(hotelCode);
            formLayout.Children.Add(hotelCodeEditor);
            formLayout.Children.Add(developmentLabel);
            formLayout.Children.Add(DevelopmentEntry);
            formLayout.Children.Add(ProductionLabel);
            formLayout.Children.Add(ProductionEntry);
            formLayout.Children.Add(APIMsubkeyDevLabel);
            formLayout.Children.Add(APIMsubkeyDevEntry);
            formLayout.Children.Add(APIMsubkeyPrdLabel);
            formLayout.Children.Add(APIMsubkeyPrdEntry);
            formLayout.Children.Add(DevDateLabel);
            formLayout.Children.Add(DevDateEntry);
            formLayout.Children.Add(MailSenderPW);
            formLayout.Children.Add(smtpPWEntry);
            formLayout.Children.Add(buttonLayout);


            formLayout.Padding = new Thickness(150, 10, 150, 10);

            var sv = new ScrollView
            {
                Orientation = ScrollOrientation.Vertical,
                Content     = formLayout
            }; // Sets dynamic layout to page 'Content' Property

            layout.Children.Add(sv);


            layout.Padding = 10;
            layout.Spacing = 10;

            Content = layout;
        }
        /*
         * Method       :   InitComp
         * Task         :   Creates Page UI Dynamically
         */
        private void InitComp()
        {
            var layout = new StackLayout();

            layout.BackgroundColor = Color.Black;
            layout.VerticalOptions = LayoutOptions.CenterAndExpand;

            var titleImage = new Image {
                Aspect = Aspect.AspectFit
            };

            titleImage.Source        = ImageSource.FromFile("images/lifestyle.png");
            titleImage.HeightRequest = 300;

            var thankLabel = new Label
            {
                Text     = "Thank You!",
                FontSize = 40,
                HorizontalTextAlignment = TextAlignment.Center,
                TextColor         = Color.White,
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                HeightRequest     = 100
            };

            var welcomeLabel = new Label
            {
                Text     = "Have A Wonderful Day!",
                FontSize = 24,
                HorizontalTextAlignment = TextAlignment.Center,
                TextColor         = Color.White,
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                HeightRequest     = 200
            };

            var titleLabel = new Label
            {
                Text     = "We value your feedback and thank you very much for selecting Cinnamon.",
                FontSize = 24,
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment   = TextAlignment.Center,
                TextColor         = Color.White,
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                HeightRequest     = 300
            };

            var copyrightLabel = new Label
            {
                Text     = "Designed and developed By Cinnamon IT | Copyrights © 2017",
                FontSize = 12,
                HorizontalTextAlignment = TextAlignment.Center,
                TextColor         = Color.DarkGray,
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                HeightRequest     = 200
            };

            var endButton = new Button
            {
                Text              = "Finish",
                FontSize          = 24,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                HeightRequest     = 60,
                WidthRequest      = 150
            };

            /*
             * Event        :   end Button 'Clicked' Event
             * Task         :   End Application thread
             */

            endButton.Clicked += async delegate {
                endButton.IsEnabled = false;

                //DateTime localDate = DateTime.Now;
                //SaveRatings.SaveRatingInstance._endTime = localDate.ToString();

                //SaveRatings.SaveRatingInstance.SaveRating(); // Save Data
                ActivityLogger.AddLogger("*************** Finish button pressed *******************");

                await Navigation.PopToRootAsync();
            };

            layout.Children.Add(thankLabel);
            layout.Children.Add(welcomeLabel);
            layout.Children.Add(titleImage);
            layout.Children.Add(titleLabel);
            layout.Children.Add(endButton);
            layout.Children.Add(copyrightLabel);

            layout.Padding = 10;
            layout.Spacing = 10;

            Content = layout;
        }
        /*
         * Method       :   InitComp
         * Task         :   Creates Page UI Dynamically
         */
        private void InitComp()
        {
            var layout = new StackLayout();

            layout.BackgroundColor = Color.Black;
            layout.VerticalOptions = LayoutOptions.StartAndExpand;

            titleImage = new Image {
                Aspect = Aspect.AspectFit
            };
            titleImage.Source        = ImageSource.FromFile("images/cinnamon.png");
            titleImage.HeightRequest = 150;

            //-------------------Settings panel---------------------------------

            var buttonPanel = new StackLayout();

            buttonPanel.Orientation       = StackOrientation.Horizontal;
            buttonPanel.HorizontalOptions = LayoutOptions.End;
            buttonPanel.Spacing           = 10;

            var settingsBtn = new Image {
                Aspect = Aspect.AspectFit
            };

            settingsBtn.Source            = ImageSource.FromFile("images/settings.png");
            settingsBtn.WidthRequest      = 40;
            settingsBtn.HeightRequest     = 40;
            settingsBtn.HorizontalOptions = LayoutOptions.EndAndExpand;

            var closeBtn = new Image {
                Aspect = Aspect.AspectFit
            };

            closeBtn.Source            = ImageSource.FromFile("images/close.png");
            closeBtn.WidthRequest      = 40;
            closeBtn.HeightRequest     = 40;
            closeBtn.HorizontalOptions = LayoutOptions.EndAndExpand;

            buttonPanel.Children.Add(settingsBtn);
            buttonPanel.Children.Add(closeBtn);

            layout.Children.Add(buttonPanel);

            //-------------------End of settings panel--------------------------

            var welcomeLabel = new Label
            {
                Text     = "Welcome!",
                FontSize = 48,
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment   = TextAlignment.Center,
                TextColor         = Color.White,
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                HeightRequest     = 200
            };

            var titleLabel = new Label
            {
                Text     = "Tell Us About Your Experience At Cinnamon",
                FontSize = 24,
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment   = TextAlignment.Center,
                TextColor         = Color.White,
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                HeightRequest     = 300
            };

            var copyrightLabel = new Label
            {
                Text     = "Designed and developed By Cinnamon IT | Copyrights © 2017",
                FontSize = 12,
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment   = TextAlignment.Center,
                TextColor         = Color.DarkGray,
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                HeightRequest     = 200
            };

            var indicator = new ActivityIndicator()
            {
                IsVisible      = false,
                Color          = Color.Green,
                IsRunning      = true,
                BindingContext = this,
            };

            startButton = new Button
            {
                Text              = "Start",
                FontSize          = 36,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                HeightRequest     = 60,
                WidthRequest      = 150,
            };

            /*
             * Event        :   Start Button 'Clicked' Event
             * Task         :   Asynchronously pushing content page object 'GuestDetails' into the Navigation stack
             * Arguments    :   Content page object (GuestDetails) --> new GuestDetails
             */

            startButton.Clicked += async delegate
            {
                indicator.SetBinding(IsVisibleProperty, "IsBusy");

                this.IsBusy         = true;
                indicator.IsVisible = true;
                indicator.IsRunning = true;

                startButton.IsEnabled = false;


                await TakePoto();

                Constants con = Constants.Instance;
                con.ClearOldData();

                bool apic = await APICheck().ConfigureAwait(true);

                Version versionCheck = await AppVersionCheck().ConfigureAwait(true);

                Global._IsMultiLangual = versionCheck.IsMultiLingual;

                int resul = DateTime.Compare(AppCurrDate, versionCheck.PriorVersionExpiryDate);

                if (versionCheck.AppVersion != AppVersionStatic || resul > 0)
                {
                    await DisplayAlert("Application is Expired", "Please update the App to latest release", "OK", "Cancel").ConfigureAwait(false);

                    await ms.SendsmtpMail("Expired device was found! in " + Settings.HotelName, "App Expired").ConfigureAwait(true);

                    Thread.CurrentThread.Abort();
                }

                if (apic != true)
                {
                    await ms.SendsmtpMail("Expired device was found! in " + Settings.HotelName, "App Expired").ConfigureAwait(true);

                    Thread.CurrentThread.Abort();
                }

                ActivityLogger.AddLogger("************** Start Button Pressed*****************");

                if (CheckInternetConnection() == false)
                {
                    bool res = await DisplayAlert("App is Exiting", "Please check your internet connection...", "OK", "Cancel");

                    ActivityLogger.AddLogger("Error : No Connection");
                    if (res)
                    {
                        Thread.CurrentThread.Abort();
                    }
                }
                else
                {
                    SaveRatings.SaveRatingInstance.ClearSavedData();
                    this.IsBusy         = false;
                    indicator.IsVisible = false;

                    await Navigation.PushAsync(new GuestDetails());

                    //SaveRatings.SaveRatingInstance.ClearSavedData();

                    DateTime localDate = DateTime.Now;
                    SaveRatings.SaveRatingInstance._startTime = localDate.ToString();
                }
            };

            var closetapRecognizer = new TapGestureRecognizer();

            closetapRecognizer.Tapped += async delegate
            {
                ActivityLogger.AddLogger("App Close Button Pressed");

                var x = await DisplayAlert("Warning!", "Are you sure want to exit from App?", "Yes", "No");

                Console.WriteLine("Cansel return :" + x);

                if (x == true)
                {
                    ActivityLogger.AddLogger("App Closed");
                    Thread.CurrentThread.Abort();
                }
            };

            var settingstapRecognizer = new TapGestureRecognizer();

            settingstapRecognizer.Tapped += async delegate
            {
                ActivityLogger.AddLogger("Settings Button Pressed");

                await Navigation.PushAsync(new Login());
            };

            closeBtn.GestureRecognizers.Add(closetapRecognizer);
            settingsBtn.GestureRecognizers.Add(settingstapRecognizer);

            layout.Children.Add(titleImage);
            layout.Children.Add(welcomeLabel);
            layout.Children.Add(titleLabel);
            layout.Children.Add(indicator);
            layout.Children.Add(startButton);
            layout.Children.Add(copyrightLabel);


            layout.Padding = 10;
            layout.Spacing = 10;

            Content = layout;
        }
示例#9
0
        /*
         * Method       :   InitComp
         * Task         :   Creates Page UI Dynamically
         */
        private void InitComp()
        {
            var layout = new StackLayout();

            layout.BackgroundColor = Color.Black;
            layout.VerticalOptions = LayoutOptions.CenterAndExpand;

            var titleImage = new Image {
                Aspect = Aspect.AspectFit
            };

            titleImage.Source        = ImageSource.FromFile("images/cinnamon.png");
            titleImage.HeightRequest = 100;

            var titleLabel = new Label
            {
                Text                  = "Login to Continue",
                FontSize              = 36,
                TextColor             = Color.White,
                VerticalOptions       = LayoutOptions.Center,
                HorizontalOptions     = LayoutOptions.Center,
                VerticalTextAlignment = TextAlignment.Center,
                HeightRequest         = 100
            };

            var formLayout = new StackLayout();

            formLayout.BackgroundColor = Color.DarkSlateGray;
            formLayout.Orientation     = StackOrientation.Vertical;
            formLayout.VerticalOptions = LayoutOptions.Center;

            var userNameLabel = new Label
            {
                Text                  = "User Name",
                FontSize              = 18,
                TextColor             = Color.White,
                VerticalOptions       = LayoutOptions.Start,
                VerticalTextAlignment = TextAlignment.End,
                HeightRequest         = 40
            };


            userNameEntry = new Entry
            {
                Placeholder   = "User Name",
                HeightRequest = 40,
                TextColor     = Color.Black,
            };

            var passwordLabel = new Label
            {
                Text                  = "Password",
                FontSize              = 18,
                TextColor             = Color.White,
                VerticalOptions       = LayoutOptions.Start,
                VerticalTextAlignment = TextAlignment.End,
                HeightRequest         = 40,
            };

            var passwordEditor = new Entry
            {
                IsPassword    = true,
                Placeholder   = "Password",
                HeightRequest = 40,
                TextColor     = Color.Black,
                Keyboard      = Keyboard.Numeric
            };

            var submitButton = new Button
            {
                Text              = "Login",
                FontSize          = 36,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                HeightRequest     = 60,
                WidthRequest      = 150
            };


            submitButton.Clicked += async delegate {
                if (userNameEntry.Text == "Admin" && passwordEditor.Text == "it@cinnamon")
                {
                    ActivityLogger.AddLogger("Login as Admin");
                    await Navigation.PushAsync(new ConfigSettings());
                }
                else
                {
                    await DisplayAlert("Authorization Failed!", "Please check your username or password", "OK");

                    ActivityLogger.AddLogger("Login attempt failed with : " + userNameEntry.Text + " and " + passwordEditor.Text);
                    userNameEntry.Text  = "";
                    passwordEditor.Text = "";
                    userNameEntry.Focus();
                }
            };

            formLayout.Children.Add(titleLabel);

            formLayout.Children.Add(userNameLabel);
            formLayout.Children.Add(userNameEntry);
            formLayout.Children.Add(passwordLabel);
            formLayout.Children.Add(passwordEditor);
            formLayout.Children.Add(submitButton);

            formLayout.Padding = new Thickness(150, 10, 150, 10);

            layout.Children.Add(formLayout);


            layout.Padding = 100;
            layout.Spacing = 10;

            Content = layout;             // Sets dynamic layout to page 'Content' Property
        }
        /*
         * Method       :   InitComp
         * Task         :   Creates Page UI Dynamically
         */
        private void InitComp()
        {
            var layout = new StackLayout();

            layout.BackgroundColor = Color.Black;
            layout.VerticalOptions = LayoutOptions.StartAndExpand;

            var titleImage = new Image {
                Aspect = Aspect.AspectFit
            };

            titleImage.Source        = ImageSource.FromFile("images/cinnamon.png");
            titleImage.HeightRequest = 100;

            formLayout                 = new StackLayout();
            formLayout.Orientation     = StackOrientation.Vertical;
            formLayout.VerticalOptions = LayoutOptions.StartAndExpand;

            //submitButton = new Button
            //{
            //    Text = "Submit",
            //    FontSize = 36,
            //    HorizontalOptions = LayoutOptions.CenterAndExpand,
            //    HeightRequest = 60,
            //    WidthRequest = 150
            //};

            var hotelLabel = new Label
            {
                Text                  = "Hotel",
                FontSize              = 18,
                TextColor             = Color.White,
                VerticalOptions       = LayoutOptions.Start,
                VerticalTextAlignment = TextAlignment.End,
                HeightRequest         = 40
            };

            var hotelNameLabel = new Entry
            {
                Text          = Settings.HotelName,
                IsEnabled     = false,
                TextColor     = Color.Black,
                HeightRequest = 40,
                Keyboard      = Keyboard.Default
            };

            var roomNoLabel = new Label
            {
                Text                  = "Room No:",
                FontSize              = 18,
                TextColor             = Color.White,
                VerticalOptions       = LayoutOptions.Start,
                VerticalTextAlignment = TextAlignment.End,
                HeightRequest         = 40,
            };

            roomNoEditor = new Entry
            {
                Placeholder   = "Room Number",
                TextColor     = Color.Black,
                HeightRequest = 40,
                Keyboard      = Keyboard.Numeric,
            };

            var indicator = new ActivityIndicator()
            {
                IsVisible      = false,
                Color          = Color.Green,
                IsRunning      = true,
                BindingContext = this,
            };

            resNoLabel = new Label
            {
                Text                  = "Reservation No:",
                FontSize              = 18,
                TextColor             = Color.White,
                VerticalOptions       = LayoutOptions.Start,
                VerticalTextAlignment = TextAlignment.End,
                HeightRequest         = 40,
            };

            resNoEditor = new Entry
            {
                Placeholder   = "Reservation Number",
                HeightRequest = 40,
                TextColor     = Color.Black,
                IsEnabled     = false
            };

            var guestPhoneLabel = new Label
            {
                Text      = "Mobile Phone Number",
                FontSize  = 18,
                TextColor = Color.White,
                HorizontalTextAlignment = TextAlignment.Start,
                VerticalTextAlignment   = TextAlignment.Center,
                VerticalOptions         = LayoutOptions.Start,
                HeightRequest           = 40,
            };

            guestPhoneEditor = new Entry
            {
                Placeholder   = "Your Mobile Number",
                HeightRequest = 40,
                Keyboard      = Keyboard.Telephone
            };

            var guestMailLabel = new Label
            {
                Text                    = "E Mail Address",
                FontSize                = 18,
                TextColor               = Color.White,
                VerticalOptions         = LayoutOptions.Start,
                HorizontalTextAlignment = TextAlignment.Start,
                VerticalTextAlignment   = TextAlignment.Center,
                HeightRequest           = 40,
            };

            guestMailEditor = new Entry
            {
                Placeholder   = "Your e mail",
                HeightRequest = 40,
                Keyboard      = Keyboard.Email
            };

            guestNameLabel = new Label
            {
                Text                  = "Tap On Your Name",
                FontSize              = 18,
                IsVisible             = false,
                TextColor             = Color.White,
                VerticalOptions       = LayoutOptions.Start,
                VerticalTextAlignment = TextAlignment.End,
                HeightRequest         = 40,
            };

            roomNoEditor.TextChanged += delegate
            {
                if (!roomNoEditor.Text.All(char.IsDigit))
                {
                    roomNoEditor.Text = roomNoEditor.Text.Remove(roomNoEditor.Text.Length - 1);
                }

                if (roomNoEditor.Text.Length > 4)
                {
                    roomNoEditor.Text = roomNoEditor.Text.Remove(roomNoEditor.Text.Length - 1);
                }
            };

            indicator.SetBinding(IsVisibleProperty, "IsBusy");

            /*
             * Event        :   Room Number Editer 'Unfocused' Event
             * Task         :   Gets Reservation number from TMS System using Romm Number which is entered by Guess and
             *                  Sets it into Reservation Number Editor UI element
             * Exception    :   Exception raised 'resNoText' is sets to null
             */

            roomNoEditor.Unfocused += async delegate
            {
                if (labelList != null)
                {
                    for (int i = 0; i < labelList.Count(); i++)
                    {
                        formLayout.Children.Remove(labelList[i]);
                    }
                }

                labelList = new List <Label>();


                ActivityLogger.AddLogger("Room Number" + roomNoEditor.Text + " Entered");

                GuestListInBooking = new List <ReservationDetails>();
                pickerDataSource   = new List <string>();

                if (roomNoEditor.Text != "")
                {
                    //submitButton.IsEnabled = false;
                }
                else
                {
                    //submitButton.IsEnabled = false;
                    guestNameLabel.IsVisible = false;
                    await DisplayAlert("Empty", "Field can't be empty. Please enter your room number", "OK");

                    ActivityLogger.AddLogger("Error\t:\tRoom Number is Empty");
                    roomNoEditor.Focus();
                    return;
                }


                this.IsBusy         = true;
                indicator.IsVisible = true;
                indicator.IsRunning = true;

                var DeviceInfo = CrossDeviceInfo.Current;
                deviceID = DeviceInfo.Id;
                Console.WriteLine("Device ID:" + DeviceInfo.Id + "Model :" + DeviceInfo.Model);


                try
                {
                    string roomNo = roomNoEditor.Text; // Get room Number from User
                    string date   = DateTime.Now.ToString("yyyy-MM-dd");

                    if (!Settings.DomainSwitcher)
                    {
                        date = Settings.DevelopmentInhouseDate;
                    }

                    List <ReservationDetails> reservationData = null;

                    //------------------------------------------------------------------------------

                    HttpClient client = new HttpClient();
                    client.BaseAddress = new Uri(Settings.BaseDomainURL);
                    client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", Settings.SubscriptionKey); //Production link
                    var response = await client.GetAsync("guestfeedback/Guest/GetGuestDetails/" + hotelNumber + "/" + roomNo + "/" + date);

                    //var response = await client.GetAsync("guest/Guest/GetGuestDetails/" + hotelNumber + "/" + roomNo + "/" + date);// Production link

                    var resultData = response.Content.ReadAsStringAsync().Result;

                    if (resultData != "")
                    {
                        reservationData = JsonConvert.DeserializeObject <List <ReservationDetails> >(resultData);
                        GC.KeepAlive(reservationData);
                        Console.WriteLine("JSON Guest Result Deserialized...List Size :" + resultData.Count());
                    }
                    else
                    {
                        Console.WriteLine("Service off part");
                        ActivityLogger.AddLogger("Reservation Data Null... Offline Mode Enabled.");

                        resNoLabel.IsVisible     = false;
                        resNoEditor.IsVisible    = false;
                        guestNameLabel.IsVisible = false;

                        foreach (var item in labelList)
                        {
                            item.IsVisible = false;
                        }

                        Random r         = new Random();
                        var    tempResNo = r.Next(100000) + 1000;
                        resNoEditor.Text = "00001" + tempResNo;

                        arriveDate = DateTime.Now.ToString("yyyy-MM-dd");
                        departDate = DateTime.Now.ToString("yyyy-MM-dd");

                        guestName = "Guest";

                        indicator.IsVisible = false;
                        indicator.IsRunning = false;
                        this.IsBusy         = false;
                    }
                    //------------------------------------------------------------------------------



                    //String responce = "";
                    //String ad1 = "";
                    //String ad2 = "";
                    //String ad3 = "";

                    foreach (var guestData in reservationData)
                    {
                        //string responce = guestData.BookingId; // Get first element value from NVC (Reservation Number)
                        //string ad1 = guestData.ArrivalDate;//Arr Date
                        //string ad2 = guestData.DepartureDate;//Dep Date
                        //string ad3 = guestData.Name;//Guest name

                        pickerDataSource.Add(guestData.Name);

                        ReservationDetails newDataSet = new ReservationDetails();
                        newDataSet.GuestId       = guestData.GuestId;
                        newDataSet.Name          = guestData.Name;
                        newDataSet.Country       = guestData.Country;
                        newDataSet.Nationality   = guestData.Nationality;
                        newDataSet.Email         = guestData.Email;
                        newDataSet.Telephone     = guestData.Telephone;
                        newDataSet.Mobile        = guestData.Mobile;
                        newDataSet.RoomNo        = guestData.RoomNo;
                        newDataSet.BookingId     = guestData.BookingId;
                        newDataSet.ArrivalDate   = guestData.ArrivalDate;
                        newDataSet.DepartureDate = guestData.DepartureDate;

                        GuestListInBooking.Add(newDataSet);
                    }

                    //-----------------------Guest Selector------------------------------


                    for (int i = 0; i < pickerDataSource.Count; i++)
                    {
                        var label = new Label()
                        {
                            BackgroundColor         = Color.Purple,
                            TextColor               = Color.White,
                            FontSize                = 20,
                            Text                    = pickerDataSource[i],
                            HorizontalTextAlignment = TextAlignment.Center,
                            VerticalTextAlignment   = TextAlignment.Center,
                            WidthRequest            = 500,
                            HeightRequest           = 40
                        };

                        labelList.Add(label);

                        //-------------------Single selection event---------------------------
                        var nameTapRecognizer = new TapGestureRecognizer();
                        nameTapRecognizer.Tapped += async(s, e) =>
                        {
                            int seq      = 0;
                            int selected = 1;

                            foreach (var item in labelList)
                            {
                                item.BackgroundColor = Color.FromRgb(60, 0, 70);
                                item.TextColor       = Color.White;
                                if (item.Id == ((Label)s).Id)
                                {
                                    item.BackgroundColor = Color.Purple;

                                    //Animating
                                    await item.ScaleTo(2, 200, Easing.CubicIn);

                                    await item.ScaleTo(1, 200, Easing.CubicOut);

                                    item.TextColor = Color.LightGreen;
                                    selected       = seq;
                                    Console.WriteLine("selected item :" + selected);
                                }

                                seq++;
                            }

                            ItemSelected(selected, s, e); //save selected item
                        };

                        label.GestureRecognizers.Add(nameTapRecognizer);

                        formLayout.Children.Add(label);
                    }

                    //-----------------------end guest selector--------------------------

                    if (GuestListInBooking[0].Name == "No reservations found")
                    {
                        indicator.IsVisible = false;
                        indicator.IsRunning = false;

                        await DisplayAlert("Alert", "Reservation not found!. Please check your room number", "OK");

                        ActivityLogger.AddLogger("Room Number" + roomNoEditor.Text + " Reservation Not Found.");

                        resNoEditor.Text  = "";
                        roomNoEditor.Text = "";

                        foreach (var item in labelList)
                        {
                            item.IsVisible = false;
                        }

                        roomNoEditor.Focus();
                        //submitButton.IsEnabled = false;

                        return;
                    }
                    else if (GuestListInBooking[0].Name == "Authentication Failed")
                    {
                        indicator.IsVisible = false;
                        indicator.IsRunning = false;

                        await DisplayAlert("Error", "#401 Internal Server error (Authentication). Please Contact your System administrator", "OK");

                        ActivityLogger.AddLogger("Reservation Details Service Authentication Failed");

                        resNoEditor.Text  = "";
                        roomNoEditor.Text = "";

                        foreach (var item in labelList)
                        {
                            item.IsVisible = false;
                        }

                        roomNoEditor.Focus();
                        //submitButton.IsEnabled = false;

                        return;
                    }

                    else if (GuestListInBooking[0].Name == "Unable to connect to the remote server")
                    {
                        indicator.IsVisible = false;
                        indicator.IsRunning = false;

                        await DisplayAlert("Error", "#500 Unable to connect server. Please Contact your System administrator", "OK");

                        ActivityLogger.AddLogger("Reservation Details Service Server Error");

                        resNoEditor.Text  = "";
                        roomNoEditor.Text = "";

                        foreach (var item in labelList)
                        {
                            item.IsVisible = false;
                        }

                        roomNoEditor.Focus();
                        //submitButton.IsEnabled = false;

                        return;
                    }
                    else if (GuestListInBooking[0].BookingId.All(char.IsDigit))
                    {
                        resNoEditor.Text      = GuestListInBooking[0].BookingId;
                        arriveDate            = GuestListInBooking[0].ArrivalDate;
                        departDate            = GuestListInBooking[0].DepartureDate;
                        guestPhoneEditor.Text = GuestListInBooking[0].Mobile;
                        guestMailEditor.Text  = GuestListInBooking[0].Email;

                        indicator.IsVisible = false;
                        indicator.IsRunning = false;
                        this.IsBusy         = false;

                        guestNameLabel.IsVisible = true;

                        return;
                    }
                    else
                    {
                        Console.WriteLine("Service off part");
                        ActivityLogger.AddLogger("Reservation Data Error... Offline Mode Enabled.");

                        resNoLabel.IsVisible     = false;
                        resNoEditor.IsVisible    = false;
                        guestNameLabel.IsVisible = false;

                        foreach (var item in labelList)
                        {
                            item.IsVisible = false;
                        }

                        Random r         = new Random();
                        var    tempResNo = r.Next(100000) + 1000;
                        resNoEditor.Text = "00001" + tempResNo;

                        arriveDate = DateTime.Now.ToString("yyyy-MM-dd");
                        departDate = DateTime.Now.ToString("yyyy-MM-dd");

                        guestName = "Guest";

                        indicator.IsVisible = false;
                        indicator.IsRunning = false;
                        this.IsBusy         = false;

                        if (roomNoEditor.Text != "")
                        {
                            //submitButton.IsEnabled = true;
                        }
                        else
                        {
                            //submitButton.IsEnabled = false;
                            await DisplayAlert("Empty", "Field can't be empty. Please enter your room number", "OK");

                            roomNoEditor.Focus();
                        }
                    }
                }
                catch (Exception)
                {
                    Console.WriteLine("Service off part");
                    ActivityLogger.AddLogger("Major Server Exception Occured... Offline Mode Enabled.");

                    resNoLabel.IsVisible     = false;
                    resNoEditor.IsVisible    = false;
                    guestNameLabel.IsVisible = false;

                    foreach (var item in labelList)
                    {
                        item.IsVisible = false;
                    }

                    Random r         = new Random();
                    var    tempResNo = r.Next(100000) + 1000;
                    resNoEditor.Text = "00001" + tempResNo;

                    arriveDate = DateTime.Now.ToString("yyyy-MM-dd");
                    departDate = DateTime.Now.ToString("yyyy-MM-dd");

                    indicator.IsVisible = false;
                    indicator.IsRunning = false;
                    this.IsBusy         = false;

                    if (roomNoEditor.Text != "")
                    {
                        //submitButton.IsEnabled = true;
                    }
                    else
                    {
                        //submitButton.IsEnabled = false;
                        await DisplayAlert("Empty", "Field can't be empty. Please enter your room number", "OK");

                        roomNoEditor.Focus();
                    }
                }
            };

            guestMailEditor.TextChanged += delegate
            {
                if (validator.EmailValidator(guestMailEditor.Text))
                {
                    guestMailEditor.BackgroundColor = Color.FromRgb(205, 255, 196);
                }
                else
                {
                    guestMailEditor.BackgroundColor = Color.FromRgb(255, 153, 168);
                }
            };

            guestPhoneEditor.TextChanged += delegate {
                if (guestPhoneEditor.Text.Length > 13)
                {
                    guestPhoneEditor.Text = guestPhoneEditor.Text.Remove(guestPhoneEditor.Text.Length - 1);
                }

                if (validator.MobileNumberValidator(guestPhoneEditor.Text))
                {
                    guestPhoneEditor.BackgroundColor = Color.FromRgb(205, 255, 196);
                }
                else
                {
                    guestPhoneEditor.BackgroundColor = Color.FromRgb(255, 153, 168);
                }
            };


            /*
             * Event        :   Room Number Editer 'Completed' Event
             * Task         :   Gets Reservation number from TMS System using Romm Number which is entered by Guess and
             *                  Sets it into Reservation Number Editor UI element
             * Exception    :   Exception raised 'resNoText' is sets to null
             */

            roomNoEditor.Completed += delegate
            {
                roomNoEditor.Unfocus();
            };


            //submitButton.Clicked += HandleClick;


            layout.Children.Add(titleImage);
            layout.Children.Add(indicator);

            formLayout.Children.Add(hotelLabel);
            formLayout.Children.Add(hotelNameLabel);
            formLayout.Children.Add(roomNoLabel);
            formLayout.Children.Add(roomNoEditor);
            formLayout.Children.Add(resNoLabel);
            formLayout.Children.Add(resNoEditor);
            formLayout.Children.Add(guestPhoneLabel);
            formLayout.Children.Add(guestPhoneEditor);
            formLayout.Children.Add(guestMailLabel);
            formLayout.Children.Add(guestMailEditor);
            formLayout.Children.Add(guestNameLabel);

            formLayout.Padding = new Thickness(150, 10, 150, 10);

            layout.Children.Add(formLayout);
            //layout.Children.Add(submitButton);

            layout.Padding = 10;
            layout.Spacing = 10;

            Content = new ScrollView
            {
                Orientation = ScrollOrientation.Horizontal,
                Content     = layout
            }; // Sets dynamic layout to page 'Content' Property
        }
        /*
         * Method       :   InitComp
         * Task         :   Creates Page UI Dynamically
         */
        private void InitComp()
        {
            var layout = new StackLayout();

            layout.BackgroundColor = Color.Black;

            var titleLabel = new Label
            {
                Text                  = "Activity Logger",
                FontSize              = 24,
                TextColor             = Color.White,
                VerticalOptions       = LayoutOptions.Center,
                HorizontalOptions     = LayoutOptions.Center,
                VerticalTextAlignment = TextAlignment.Center,
                HeightRequest         = 100
            };

            commentEditor = new Editor();
            commentEditor.BackgroundColor = Color.Black;
            commentEditor.TextColor       = Color.LightGreen;
            commentEditor.VerticalOptions = LayoutOptions.StartAndExpand;
            commentEditor.HeightRequest   = 500;

            var clearButton = new Button
            {
                Text              = "Clear",
                FontSize          = 24,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                HeightRequest     = 60,
                WidthRequest      = 150
            };

            clearButton.Clicked += async delegate {
                await ActivityLogger.ClearLogger().ConfigureAwait(false);

                ReadLogger();

                Device.StartTimer(TimeSpan.FromSeconds(1), () =>
                {
                    commentEditor.Text = loggerDetails;
                    return(false);
                });
            };

            layout.Children.Add(titleLabel);
            layout.Children.Add(commentEditor);
            layout.Children.Add(clearButton);


            layout.Padding = 10;
            layout.Spacing = 10;

            Content = new ScrollView {
                Orientation = ScrollOrientation.Horizontal,
                Content     = layout
            }; // Sets dynamic layout to page 'Content' Property

            Device.StartTimer(TimeSpan.FromSeconds(1), () =>
            {
                commentEditor.Text = loggerDetails;
                return(false);
            });
        }
        //---------------------------------------------- End Of InitComp --------------------------------------

        private async void ReadLogger()
        {
            loggerDetails = await ActivityLogger.ReadLogger();

            Console.WriteLine(loggerDetails);
        }
示例#13
0
        private async void InitPCLStore()
        {
            string res = await ActivityLogger.InitPCLStorage();

            Console.WriteLine(res);
        }