コード例 #1
0
        //Binding all reservations into the Reservations Listview
        public async void BindDataToListView(String result)
        {
            try
            {
                reservationHeader = new List <ReservationHeader>();

                //Clear the ListView
                ReservationsListView.ItemsSource = null;
                if (result.Contains("Enter your user ID in the format"))
                {
                    await DisplayAlert(Constants._headerMessage, Constants._unableToGetHotelReservations, Constants._buttonOkay);
                }
                else
                {
                    if (result != null)
                    {
                        //Solving Date Ticks erro
                        result = result.Replace("Date(-", "Date(");
                        var output = JObject.Parse(result);

                        int cellColourCount = 1;

                        //Setting initial colo
                        Color  temporary_status_color = Color.Gray;
                        Color  cellColour;
                        Color  textColor;
                        string reservationImage    = "";
                        string roomStatusImage     = "";
                        string numberOfVisits      = "";
                        string totalNumberOfVisits = "";

                        //Looping all Dat
                        for (int i = 0; i < Enumerable.Count(output["d"]["results"]); i++)
                        {
                            //Checking reservation availabilit
                            if (Enumerable.Count(output["d"]["results"][i]["ReservationNaviSapGuests"]["results"]) > 0)
                            {
                                numberOfVisits      = Convert.ToString(output["d"]["results"][i]["ReservationNaviSapGuests"]["results"][0]["Visitperhotel"]).TrimStart(new Char[] { '0' }).Trim();
                                totalNumberOfVisits = Convert.ToString(output["d"]["results"][i]["ReservationNaviSapGuests"]["results"][0]["Totalvisit"]).TrimStart(new Char[] { '0' }).Trim();
                                reservationImage    = reservationNaviAndNaviSapGuestDetails(output, cellColourCount, out temporary_status_color, out cellColour, out textColor, reservationImage, i);
                                if (temporary_status != Constants._reservationStatusCancelled)
                                {
                                    reservationHeader.Add(new ReservationHeader(
                                                              Convert.ToString(output["d"]["results"][i]["XreservaId"]).TrimStart(new Char[] { '0' }),
                                                              Convert.ToString(output["d"]["results"][i]["ReservationNaviSapGuests"]["results"][0]["McName1"]),
                                                              Convert.ToString(output["d"]["results"][i]["Xclientname"]),
                                                              temporary_status,
                                                              temporary_status_color,
                                                              cellColour,
                                                              textColor,
                                                              reservationImage,
                                                              serviceDataValidation.roomNumberValidation(Convert.ToString(output["d"]["results"][i]["XhabitacionId"])),
                                                              serviceDataValidation.roomImageValidation(Convert.ToString(output["d"]["results"][i]["XstdoLimpia"])),
                                                              numberOfVisits,
                                                              totalNumberOfVisits
                                                              ));
                                }
                            }
                            else if (Enumerable.Count(output["d"]["results"][i]["ReservationNaviGuest"]["results"]) > 0)
                            {
                                numberOfVisits      = "0";
                                totalNumberOfVisits = "0";
                                reservationImage    = reservationNaviAndNaviSapGuestDetails(output, cellColourCount, out temporary_status_color, out cellColour, out textColor, reservationImage, i);

                                if (temporary_status != Constants._reservationStatusCancelled)
                                {
                                    reservationHeader.Add(new ReservationHeader(
                                                              Convert.ToString(output["d"]["results"][i]["XreservaId"]).TrimStart(new Char[] { '0' }),
                                                              Convert.ToString(output["d"]["results"][i]["ReservationNaviGuest"]["results"][0]["Xnombre"]),
                                                              Convert.ToString(output["d"]["results"][i]["Xclientname"]),
                                                              temporary_status,
                                                              temporary_status_color,
                                                              cellColour,
                                                              textColor,
                                                              reservationImage,
                                                              serviceDataValidation.roomNumberValidation(Convert.ToString(output["d"]["results"][i]["XhabitacionId"])),
                                                              serviceDataValidation.roomImageValidation(Convert.ToString(output["d"]["results"][i]["XstdoLimpia"])),
                                                              numberOfVisits,
                                                              totalNumberOfVisits
                                                              ));
                                }
                            }
                            cellColourCount = cellColourCount + 1;
                        }

                        //Bind the Data to ListVie
                        Device.BeginInvokeOnMainThread(() =>
                        {
                            items = new ItemList(reservationHeader);
                            ReservationsListView.ItemsSource = items.Items;

                            ReservationsListViewNoItems.IsVisible = false;
                            ListViewManualRefreshIcon.IsVisible   = false;
                            ReservationsListView.IsVisible        = true;

                            ChartModel.resCount       = reservationHeader.Count;
                            ChartModel.checkedinCount = reservationHeader.Count(x => x.Status == Constants._reservationStatusCheckedIn);
                            ChartModel.pendingCount   = reservationHeader.Count(x => x.Status == Constants._reservationStatusPending);

                            MessagingCenter.Send <ReservationsList>(this, "chart");
                        });
                        hideLoading();
                    }
                    else
                    {
                        //Reservation details not availabl
                        ReservationsListViewNoItems.IsVisible = true;
                        ListViewManualRefreshIcon.IsVisible   = true;
                        hideReservationList();
                        hideLoading();
                    }
                }


                //Hide Loading Message
                Device.BeginInvokeOnMainThread(() =>
                {
                    hideLoading();
                });

                //Finish Refreshing
                if (ReservationsListView.IsRefreshing)
                {
                    ReservationsListView.EndRefresh();
                }
            }
            catch (Exception e)
            {
                ReservationsListViewNoItems.IsVisible = true;
                ListViewManualRefreshIcon.IsVisible   = true;
                hideReservationList();
                hideLoading();

                //Finish Refreshing
                if (ReservationsListView.IsRefreshing)
                {
                    ReservationsListView.EndRefresh();
                }
            }
        }
コード例 #2
0
        async void DisplayAttachments()
        {
            try
            {
                attachmentListView.IsVisible = false;

                var responce = await new CheckInManager().GetAttachments("JPG");
                var output   = JObject.Parse(responce);

                List <ReservationAttachment> AttachmentList = new List <ReservationAttachment>();
                List <AttachmentsModel>      ImagesList     = new List <AttachmentsModel>();

                ItemList itemList;

                if (Enumerable.Any(output["d"]["results"]))
                {
                    var result = Convert.ToString(output["d"]["results"]);

                    AttachmentList = JsonConvert.DeserializeObject <List <ReservationAttachment> >(result);
                }

                int i = 1;

                foreach (var item in AttachmentList)
                {
                    if (item.AttachmentName.Contains("Passport"))
                    {
                        byte[] data   = Convert.FromBase64String(item.AttachmentString);
                        var    source = ImageSource.FromStream(() => new MemoryStream(data));

                        ImagesList.Add(new AttachmentsModel {
                            Sequence = i, Source = source
                        });

                        i++;
                    }
                }

                if (ImagesList != null)
                {
                    itemList = new ItemList(ImagesList);
                    attachmentListView.ItemsSource = itemList.Items;
                    attachmentListView.IsVisible   = true;
                }

                indicator.IsVisible             = false;
                indicator.IsRunning             = false;
                headerImage.IsVisible           = true;
                attachementBaseLayout.IsVisible = true;
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                indicator.IsVisible             = false;
                indicator.IsRunning             = false;
                headerImage.IsVisible           = true;
                attachementBaseLayout.IsVisible = true;
            }

            MessagingCenter.Unsubscribe <GuestEdit>(this, "Passport");
        }