예제 #1
0
        public GetChecklistMobileResponse getDamageCheckListMobile(GetChecklistMobileRequest checklistMobileRequest, string token)
        {
            GetChecklistMobileResponse result = null;

            try
            {
                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri(ConstantData.ApiURL.ToString() + "CheckListMobile/GetClientChecklistMobile");
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);

                    var myContent   = JsonConvert.SerializeObject(checklistMobileRequest);
                    var buffer      = Encoding.UTF8.GetBytes(myContent);
                    var byteContent = new ByteArrayContent(buffer);
                    byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");

                    var response = client.PostAsync(client.BaseAddress, byteContent).Result;
                    if (response.IsSuccessStatusCode)
                    {
                        var responseStream = response.Content.ReadAsStringAsync().Result;
                        result = JsonConvert.DeserializeObject <GetChecklistMobileResponse>(responseStream);
                    }
                }
            }

            catch (Exception ex)
            {
                throw ex;
            }
            return(result);
        }
        public GetChecklistMobileResponse getDamageCheckListMobile(GetChecklistMobileRequest checklistMobileRequest, string token)
        {
            GetChecklistMobileResponse response = null;

            try
            {
                response = vehicleService.getDamageCheckListMobile(checklistMobileRequest, token);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(response);
        }
예제 #3
0
        private GetChecklistMobileResponse getDamageCheckListMobile(GetChecklistMobileRequest checklistMobileRequest, string token)
        {
            GetChecklistMobileResponse response = null;
            VehicleController          vehicle  = new VehicleController();

            try
            {
                response = vehicle.getDamageCheckListMobile(checklistMobileRequest, token);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(response);
        }
예제 #4
0
 public DamageCheckListCheckIn(int agreementId, string AgreementNumber, int VehicleId)
 {
     InitializeComponent();
     this.agreementId                   = agreementId;
     this.agreementNumber               = AgreementNumber;
     this.vehicleId                     = VehicleId;
     checklistMobileRequest             = new GetChecklistMobileRequest();
     checklistMobileRequest.AgreementId = agreementId;
     checklistMobileRequest.clientId    = Constants.ClientId;
     checklistMobileResponse            = null;
     token                                   = App.Current.Properties["currentToken"].ToString();
     SignMobileRequest                       = new AddDamageSignMobileRequest();
     signMobileResponse                      = null;
     imageURLMobileRequest                   = new ReloadSignatureImageURLMobileRequest();
     imageURLMobileRequest.agreementId       = agreementId;
     imageURLMobileRequest.IsCheckIn         = true;
     imageURLMobileRequest.isDamageView      = true;
     imageURLMobileResponse                  = null;
     imageURLMobileRequest.SignatureImageUrl = "";
 }
 public DamageCheckListCheckOut(int agreementId, string agreementNo, int status, int VehicleId)
 {
     InitializeComponent();
     On <Xamarin.Forms.PlatformConfiguration.iOS>().SetUseSafeArea(true);
     this.agreementId                   = agreementId;
     AgreementNumber                    = agreementNo;
     this.VehicleId                     = VehicleId;
     this.status                        = status;
     checklistMobileRequest             = new GetChecklistMobileRequest();
     checklistMobileRequest.AgreementId = agreementId;
     checklistMobileRequest.clientId    = Constants.ClientId;
     checklistMobileResponse            = null;
     token = App.Current.Properties["currentToken"].ToString();
     signMobileResponse                      = null;
     SignMobileRequest                       = new AddDamageSignMobileRequest();
     imageURLMobileRequest                   = new ReloadSignatureImageURLMobileRequest();
     imageURLMobileRequest.agreementId       = agreementId;
     imageURLMobileRequest.IsCheckIn         = false;
     imageURLMobileRequest.isDamageView      = true;
     imageURLMobileResponse                  = null;
     imageURLMobileRequest.SignatureImageUrl = "";
 }
예제 #6
0
        protected override async void OnAppearing()
        {
            base.OnAppearing();

            if (PopupNavigation.Instance.PopupStack.Count > 0)
            {
                if (PopupNavigation.Instance.PopupStack[PopupNavigation.Instance.PopupStack.Count - 1].GetType() == typeof(ErrorWithClosePagePopup))
                {
                    await PopupNavigation.Instance.PopAllAsync();
                }
            }

            bool busy = false;

            if (!busy)
            {
                try
                {
                    busy = true;
                    await PopupNavigation.Instance.PushAsync(new LoadingPopup("Loading damage list..."));

                    await Task.Run(async() =>
                    {
                        try
                        {
                            checklistMobileResponse = getDamageCheckListMobile(checklistMobileRequest, token);
                            imageURLMobileResponse  = getDamageSignature(imageURLMobileRequest, token);
                        }
                        catch (Exception ex)
                        {
                            await PopupNavigation.Instance.PushAsync(new ErrorWithClosePagePopup(ex.Message));
                        }
                    });
                }
                finally
                {
                    busy = false;
                    if (PopupNavigation.Instance.PopupStack.Count == 1)
                    {
                        await PopupNavigation.Instance.PopAllAsync();
                    }
                    else if (PopupNavigation.Instance.PopupStack.Count > 1)
                    {
                        if (PopupNavigation.Instance.PopupStack[PopupNavigation.Instance.PopupStack.Count - 1].GetType() != typeof(ErrorWithClosePagePopup))
                        {
                            await PopupNavigation.Instance.PopAllAsync();
                        }
                    }
                }
                if (checklistMobileResponse != null)
                {
                    if (checklistMobileResponse.message.ErrorCode == "200")
                    {
                        optionList = new List <DefaultDamageList>();
                        List <DefaultDamageList> nonOptionList = new List <DefaultDamageList>();
                        List <DefaultDamageList> calenderList  = new List <DefaultDamageList>();

                        foreach (DefaultDamageList ddm in checklistMobileResponse.DefaultDamageChecklistIn)
                        {
                            if (ddm.SelectOption == "Optional")
                            {
                                optionList.Add(ddm);
                            }
                            else if (ddm.SelectOption == "ShortAnswer")
                            {
                                if (!string.IsNullOrEmpty(ddm.Area))
                                {
                                    nonOptionList.Add(ddm);
                                }
                            }
                            else if (ddm.SelectOption == "Calendar")
                            {
                                if (!string.IsNullOrEmpty(ddm.calendarstr))
                                {
                                    calenderList.Add(ddm);
                                }
                            }
                        }

                        damageList.ItemsSource   = optionList;
                        damageList.HeightRequest = 60 * (optionList.Count + 1);

                        damageListNonOption.ItemsSource   = nonOptionList;
                        damageListNonOption.HeightRequest = 100 * nonOptionList.Count;

                        damageListCalender.ItemsSource   = calenderList;
                        damageListCalender.HeightRequest = 100 * calenderList.Count;
                    }
                    else
                    {
                        await PopupNavigation.Instance.PushAsync(new ErrorWithClosePagePopup(checklistMobileResponse.message.ErrorMessage));
                    }
                }
                if (imageURLMobileResponse != null)
                {
                    if (imageURLMobileResponse.message.ErrorCode == "200")
                    {
                        if (!string.IsNullOrEmpty(imageURLMobileResponse.SignatureImageUrl))
                        {
                            byte[] Base64Stream = Convert.FromBase64String(imageURLMobileResponse.SignatureImageUrl);
                            signatureImage.Source       = ImageSource.FromStream(() => new MemoryStream(Base64Stream));
                            signaturePadFrame.IsVisible = false;
                            signatureBtnGrid.IsVisible  = false;
                            imageFrame.IsVisible        = true;
                        }
                        else
                        {
                            signatureBtnGrid.IsVisible = true;
                            signatureView.IsVisible    = true;
                            imageFrame.IsVisible       = false;
                        }
                    }
                    else
                    {
                        signatureBtnGrid.IsVisible = true;
                        signatureView.IsVisible    = true;
                        imageFrame.IsVisible       = false;
                    }
                }
                else
                {
                    signatureBtnGrid.IsVisible = true;
                    signatureView.IsVisible    = true;
                    imageFrame.IsVisible       = false;
                }
            }
        }