コード例 #1
0
        public async Task <Response> AddItemAsync(Apartment_Visual item, IEnumerable <string> ImageList)
        {
            Response result = new Response();

            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters.Add("Name", item.Name);
            parameters.Add("BuildingApartmentId", item.BuildingApartmentId);
            parameters.Add("AdditionalConsideration", item.AdditionalConsideration);

            parameters.Add("ExteriorElements", item.ExteriorElements);
            parameters.Add("WaterProofingElements", item.WaterProofingElements);
            parameters.Add("ConditionAssessment", item.ConditionAssessment);
            parameters.Add("VisualReview", item.VisualReview);

            parameters.Add("AnyVisualSign", item.AnyVisualSign);
            parameters.Add("FurtherInasive", item.FurtherInasive);
            parameters.Add("LifeExpectancyEEE", item.LifeExpectancyEEE);
            parameters.Add("LifeExpectancyLBC", item.LifeExpectancyLBC);

            parameters.Add("LifeExpectancyAWE", item.LifeExpectancyAWE);
            parameters.Add("UserID", App.LogUser.Id.ToString());

            parameters.Add("ImageDescription", item.ImageDescription);


            result = await HttpUtil.VisualDataAdd(item.Name, "api/VisualBuildingApartment/Add", parameters, ImageList);


            return(await Task.FromResult(result));
        }
コード例 #2
0
        private async Task DeleteVisualFormCommandExecute(Apartment_Visual obj)
        {
            var result = await Shell.Current.DisplayAlert(
                "Alert",
                "Are you sure you want to remove?",
                "Yes", "No");

            if (result)
            {
                IsBusyProgress = true;
                var response = await Task.Run(() =>
                                              VisualFormApartmentDataStore.DeleteItemAsync(obj)
                                              );

                if (response.Status == ApiResult.Success)
                {
                    IsBusyProgress = false;
                    await LoadData();
                }

                // Shell.Current.Navigation.RemovePage(new BuildingLocationDetail());

                // await Shell.Current.Navigation.PushAsync(new ProjectDetail() { BindingContext = new ProjectDetailViewModel() { Project = project } });
            }
        }
コード例 #3
0
        private async Task NewViusalReportCommandExecue()
        {
            Apartment_Visual visualForm = new Apartment_Visual();

            visualForm = new Apartment_Visual();
            // visualForm.Id = Guid.NewGuid().ToString();
            visualForm.BuildingApartmentId = BuildingApartment.Id;



            App.VisualEditTracking            = new List <MultiImage>();
            App.VisualEditTrackingForInvasive = new List <MultiImage>();
            VisualApartmentLocationPhotoDataStore.Clear();
            InvasiveVisualApartmentLocationPhotoDataStore.Clear();
            //await VisualFormProjectLocationDataStore.AddItemAsync(vloc);
            //  VisualFormProjectLocationItems = new ObservableCollection<ProjectLocation_Visual>(await VisualFormProjectLocationDataStore.GetItemsAsyncByProjectLocationId(ProjectLocation.Id));
            await Shell.Current.Navigation.PushAsync(new VisualApartmentLocationForm()
            {
                BindingContext = new VisualApartmentFormViewModel()
                {
                    BuildingApartment = BuildingApartment, VisualForm = visualForm
                }
            });

            //{ BindingContext = new EditProjectLocationeageViewModel() { Title = "New Common Location Image", ProjectCommonLocationImages = new ProjectCommonLocationImages() { ImageUrl = "blank.png" }, ProjectLocation = ProjectLocation } });
        }
コード例 #4
0
        private async Task GoToVisualForm(Apartment_Visual parm)
        {
            VisualApartmentFormViewModel vm = new VisualApartmentFormViewModel();

            vm.ExteriorElements           = new ObservableCollection <string>(parm.ExteriorElements.Split(',').ToList());
            vm.WaterProofingElements      = new ObservableCollection <string>(parm.WaterProofingElements.Split(',').ToList());
            vm.CountExteriorElements      = vm.ExteriorElements.Count.ToString();
            vm.CountWaterProofingElements = vm.WaterProofingElements.Count.ToString();
            vm.RadioList_VisualReviewItems.Where(c => c.Name == parm.VisualReview).Single().IsChecked          = true;
            vm.RadioList_AnyVisualSignItems.Where(c => c.Name == parm.AnyVisualSign).Single().IsChecked        = true;
            vm.RadioList_FurtherInasiveItems.Where(c => c.Name == parm.FurtherInasive).Single().IsChecked      = true;
            vm.RadioList_ConditionAssessment.Where(c => c.Name == parm.ConditionAssessment).Single().IsChecked = true;
            vm.RadioList_LifeExpectancyEEE.Where(c => c.Name == parm.LifeExpectancyEEE).Single().IsChecked     = true;
            vm.RadioList_LifeExpectancyLBC.Where(c => c.Name == parm.LifeExpectancyLBC).Single().IsChecked     = true;
            vm.RadioList_LifeExpectancyAWE.Where(c => c.Name == parm.LifeExpectancyAWE).Single().IsChecked     = true;
            //  vm.ExteriorElements = new CheakBoxListReturntModel() {selectedList= parm.ExteriorElements.Split(',').ToList(),Count= parm.ExteriorElements.Split(',').ToList().Count };
            // vm.CountExteriorElements = vm.ExteriorElements.selectedList.Count.ToString();
            //foreach (var item in parm.ExteriorElements.Split(',').ToList())
            //{
            //    vm.ExteriorElements=new CheakBoxListReturntModel() {selectedList }
            //}
            //vm.CountExteriorElements = vm.ExteriorElements.selectedList.Count.ToString();

            App.VisualEditTracking            = new List <MultiImage>();
            App.VisualEditTrackingForInvasive = new List <MultiImage>();
            VisualApartmentLocationPhotoDataStore.Clear();
            InvasiveVisualApartmentLocationPhotoDataStore.Clear();
            // InvasiveVisualApartmentLocationPhotoDataStore.Clear();

            //vm.WaterProofingElements.selectedList = parm.ExteriorElements.Split(',').ToList();
            vm.VisualForm        = parm;
            vm.BuildingApartment = BuildingApartment;
            vm.VisualApartmentLocationPhotoItems = new ObservableCollection <VisualApartmentLocationPhoto>(await VisualApartmentLocationPhotoDataStore.GetItemsAsyncByProjectVisualID(parm.Id, true));
            if (App.IsInvasive == false)
            {
                if (Shell.Current.Navigation.NavigationStack[Shell.Current.Navigation.NavigationStack.Count - 1].GetType() != typeof(VisualApartmentLocationForm))
                {
                    await Shell.Current.Navigation.PushAsync(new VisualApartmentLocationForm()
                    {
                        BindingContext = vm
                    });
                }
            }
            else
            {
                vm.InvasiveVisualApartmentLocationPhotoItems = new ObservableCollection <VisualApartmentLocationPhoto>(await InvasiveVisualApartmentLocationPhotoDataStore.GetItemsAsyncByProjectVisualID(parm.Id, true));
                if (Shell.Current.Navigation.NavigationStack[Shell.Current.Navigation.NavigationStack.Count - 1].GetType() != typeof(Views._8_VisualReportForm.TabbedPageInvasive))
                {
                    await Shell.Current.Navigation.PushAsync(new Views._8_VisualReportForm.TabbedPageInvasive(vm));
                }
                //await Shell.Current.Navigation.PushAsync(new VisualProjectLocationForm() { BindingContext = vm });
            }

            //await Shell.Current.Navigation.PushAsync(new EditProjectLocationImage()
            //{ BindingContext = new EditProjectLocationImageViewModel() { Title = "New Common Location Image", ProjectCommonLocationImages = new ProjectCommonLocationImages() { ImageUrl = "blank.png" }, ProjectLocation = ProjectLocation } });
        }
コード例 #5
0
        public async Task <Response> DeleteItemAsync(Apartment_Visual item)
        {
            item.IsDelete = true;
            item.UserId   = App.LogUser.Id.ToString();
            using (HttpClient client = new HttpClient())
            {
                client.BaseAddress = new Uri(App.AzureBackendUrl);
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(
                    new MediaTypeWithQualityHeaderValue("application/json"));
                using (HttpResponseMessage response = await client.PostAsJsonAsync($"api/VisualBuildingApartment/DeleteVisualBuildingApartment", item))
                {
                    var responseBody = await response.Content.ReadAsStringAsync();

                    Response result = JsonConvert.DeserializeObject <Response>(responseBody);

                    response.EnsureSuccessStatusCode();

                    return(await Task.FromResult(result));
                }
            }
        }
コード例 #6
0
        public async Task <Response> UpdateItemAsync(Apartment_Visual item, List <MultiImage> finelList)
        {
            Response result = new Response();

            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters.Add("Id", item.Id);
            parameters.Add("Name", item.Name);
            parameters.Add("BuildingApartmentId", item.BuildingApartmentId);
            parameters.Add("AdditionalConsideration", item.AdditionalConsideration);

            parameters.Add("ExteriorElements", item.ExteriorElements);
            parameters.Add("WaterProofingElements", item.WaterProofingElements);
            parameters.Add("ConditionAssessment", item.ConditionAssessment);
            parameters.Add("VisualReview", item.VisualReview);

            parameters.Add("AnyVisualSign", item.AnyVisualSign);
            parameters.Add("FurtherInasive", item.FurtherInasive);
            parameters.Add("LifeExpectancyEEE", item.LifeExpectancyEEE);
            parameters.Add("LifeExpectancyLBC", item.LifeExpectancyLBC);

            parameters.Add("LifeExpectancyAWE", item.LifeExpectancyAWE);
            parameters.Add("UserID", App.LogUser.Id.ToString());

            parameters.Add("ImageDescription", item.ImageDescription);
            // parameters.Add("UserID", App.LogUser.Id.ToString());


            if (App.IsInvasive == true)
            {
                parameters.Add("IsInvaiveImage", "TRUE");
                // parameters.Add("IsInvasive", "FALSE");
            }
            else
            {
                parameters.Add("IsInvaiveImage", null);
                //  parameters.Add("IsInvasive", "FALSE");
            }


            //  result = await HttpUtil.VisualDataAdd(item.Name, "api/VisualProjectLocation/Add", parameters, ImageList);

            HttpContent DictionaryItems = new FormUrlEncodedContent(parameters);

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(App.AzureBackendUrl);

                using (var formData = new MultipartFormDataContent())
                {
                    //https://www.dotnetperls.com/split

                    int Index = 1000;
                    foreach (MultiImage img in finelList)
                    {
                        Index++;
                        if (img.IsServerData == false && img.Status != "FromServer")
                        {
                            string ServerFileName = "New_" + img.Id;

                            string[] array     = ServerFileName.Split('_');
                            string   operation = array[0];
                            string   searchId  = array[1];
                            formData.Add(new ByteArrayContent(File.ReadAllBytes(img.Image)), Index.ToString(), ServerFileName);
                        }
                        if (img.IsServerData == true && img.Status == "Update")
                        {
                            string ServerFileName = "Update_" + img.Id;
                            formData.Add(new ByteArrayContent(File.ReadAllBytes(img.Image)), Index.ToString(), ServerFileName);
                        }
                        if (img.IsServerData == true && img.Status == "Delete")
                        {
                            string ServerFileName     = "Delete_" + img.Id;
                            var    sevenThousandItems = new byte[7000];
                            formData.Add(new ByteArrayContent(sevenThousandItems), Index.ToString(), ServerFileName);
                        }
                        //if (img.IsServerData == true && img.Status == "Delete")
                        //{
                        //    string ServerFileName = "Delete" + img.Id + ".png";
                        //    formData.Add(new ByteArrayContent(File.ReadAllBytes(img.Image)), Index.ToString(), ServerFileName);
                    }
                    // var extension = Path.GetExtension(img);
                    formData.Add(DictionaryItems, "Model");


                    var response = client.PostAsync("api/VisualBuildingApartment/Edit", formData).Result;

                    var responseBody = await response.Content.ReadAsStringAsync();

                    result = JsonConvert.DeserializeObject <Response>(responseBody);
                    return(await Task.FromResult(result));
                }
            }
        }