コード例 #1
0
        public async Task <bool> PostWorkOrderPhotoAsync(WorkOrdersPhotos wop)
        {
            RestClient <WorkOrdersPhotos> restClient = new RestClient <WorkOrdersPhotos>();

            restClient.WebServiceUrl = url + "/api/WorkOrdersPhotoes/PostWorkOrdersPhoto/";

            var result = await restClient.PostAsync(wop);

            return(result);
        }
コード例 #2
0
        //private async void bind()
        //{
        //    lwop = await rcs.getAllImagesAsync();
        //    foreach (WorkOrdersPhotos p in lwop)
        //    {
        //        Stream stream = new System.IO.MemoryStream(p.imageData);
        //        p.imageSource = ImageSource.FromStream(() => { return stream; });
        //    }

        //    imageListView.BindingContext = lwop;
        //}

        private async void CameraButton_Clicked(object sender, EventArgs e)
        {
            var photo = await Plugin.Media.CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions()
            {
            });


            biContainar.IsVisible = true;
            busyindicator.IsBusy  = true;
            //Convert to byte
            Byte[] ImageBytes;
            using (var memoryStream = new System.IO.MemoryStream())
            {
                photo.GetStream().CopyTo(memoryStream);
                ImageBytes = memoryStream.ToArray();
            }



            //write to server
            WorkOrdersPhotos wop = new WorkOrdersPhotos();

            wop.WOID_FK   = 24;
            wop.imageData = ImageBytes;
            wop.date      = System.DateTime.Now;
            bool isOk = await rcs.PostWorkOrderPhotoAsync(wop);

            if (isOk)
            {
                await DisplayAlert("", "تم الاضافة بنجاح", "ok");

                biContainar.IsVisible = false;
                busyindicator.IsBusy  = false;
            }
            else
            {
                await DisplayAlert("", "خطأ", "ok");

                biContainar.IsVisible = false;
                busyindicator.IsBusy  = false;
            }

            //read from server
            //WorkOrdersPhotos wopRead = new WorkOrdersPhotos();
            //Byte[] readImage;
            //wopRead = await rcs.getImageByIDAsync(27);
            //readImage = wopRead.imageData;

            //display to control
            //Stream stream = new System.IO.MemoryStream(readImage);
            //PhotoImage.Source = ImageSource.FromStream(() => { return stream; });
            //biContainar.IsVisible = false;
            //busyindicator.IsBusy = false;
        }
コード例 #3
0
        private async void tackPicEvent_Tapped(object sender, EventArgs e)
        {
            var action = await DisplayActionSheet("الرجاء الاختيار", "الغاء", null, "التقاط صورة", "اختيار صورة");

            if (action.Equals("التقاط صورة"))
            {
                await DisplayAlert("تنبيه", "سوف تقوم بالتقاط صورة لأمر العمل" + Environment.NewLine + "بعد التقاط الصورة الرجاء منك الانتظار حتى تتم عملية رفع الصور", "موافق");
            }
            else if (action.Equals("اختيار صورة"))
            {
                await DisplayAlert("تنبيه", "سوف تقوم باختيار صورة لأمر العمل" + Environment.NewLine + "بعد اختيار الصورة الرجاء منك الانتظار حتى تتم عملية رفع الصور", "موافق");
            }



            Byte[] ImageBytes = null;
            try
            {
                if (action.Equals("التقاط صورة"))
                {
                    var photo = await Plugin.Media.CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions()
                    {
                        PhotoSize          = Plugin.Media.Abstractions.PhotoSize.Medium,
                        CompressionQuality = 25
                    });

                    //Convert to byte
                    using (var memoryStream = new System.IO.MemoryStream())
                    {
                        photo.GetStream().CopyTo(memoryStream);
                        ImageBytes = memoryStream.ToArray();
                    }
                }
                else if (action.Equals("اختيار صورة"))
                {
                    var photo = await Plugin.Media.CrossMedia.Current.PickPhotoAsync(new Plugin.Media.Abstractions.PickMediaOptions()
                    {
                        PhotoSize          = Plugin.Media.Abstractions.PhotoSize.Medium,
                        CompressionQuality = 25
                    });

                    //Convert to byte
                    using (var memoryStream = new System.IO.MemoryStream())
                    {
                        photo.GetStream().CopyTo(memoryStream);
                        ImageBytes = memoryStream.ToArray();
                    }
                }



                await BeBusy(true);

                //write to server
                WorkOrdersPhotos wop = new WorkOrdersPhotos();
                wop.WOID_FK   = n;
                wop.imageData = ImageBytes;
                wop.date      = System.DateTime.Now;
                try
                {
                    bool isOk = await rcs.PostWorkOrderPhotoAsync(wop);

                    if (isOk)
                    {
                        await DisplayAlert("", "تم الاضافة بنجاح", "ok");
                        await BeBusy(false);
                    }
                    else
                    {
                        await DisplayAlert("", "خطأ", "ok");
                        await BeBusy(false);
                    }
                }
                catch (Exception err)
                {
                    await DisplayAlert("", err.Message, "ok");
                    await BeBusy(false);
                }
            }
            catch (Exception err)
            {
            }
        }