public override async Task Run()
        {
            var token = JsonConvert.DeserializeObject <BoxAuthTokenDO>(AuthorizationToken.Token);
            var desiredCrateDescription = ActivityUI.FileChooser.CrateDescriptions.Single(x => x.Selected);
            var tableCrate = Payload.CratesOfType <StandardTableDataCM>()
                             .FirstOrDefault(x => x.Label == desiredCrateDescription.Label &&
                                             x.ManifestType.Type == desiredCrateDescription.ManifestType);

            if (tableCrate == null)
            {
                RaiseError($"Selected crate {desiredCrateDescription.Label} doesn't contains table data");
                return;
            }
            var    fileName = ActivityUI.Filename.Value.Trim();
            var    service  = new BoxService(token);
            string fileId;

            using (var stream = new MemoryStream())
            {
                CreateWorkbook(stream, tableCrate);
                // Need to reset stream before saving it to box.
                stream.Seek(0, SeekOrigin.Begin);
                fileId = await service.SaveFile($"{fileName}.xlsx", stream);
            }
            var downloadLink = await service.GetFileLink(fileId);

            await _pushNotificationService.PushUserNotification(MyTemplate, "File Download URL Generated", "File was upload to Box. You can download it using this url: " + downloadLink);
        }
        /// <summary>
        /// Get a down scoped token.
        /// </summary>
        /// <returns>The down scoped access token.</returns>
        public string Exchange()
        {
            BoxRequest boxRequest = new BoxRequest(new Uri(Constants.BoxApiHostUriString), Constants.AuthTokenEndpointString)
                                    .Method(RequestMethod.Post)
                                    .Payload(Constants.RequestParameters.SubjectToken, token)
                                    .Payload(Constants.RequestParameters.SubjectTokenType, Constants.RequestParameters.AccessTokenTypeValue)
                                    .Payload(Constants.RequestParameters.Scope, scope)
                                    .Payload(Constants.RequestParameters.Resource, resourceUrl)
                                    .Payload(Constants.RequestParameters.GrantType, Constants.RequestParameters.TokenExchangeGrantTypeValue);

            if (actorToken != null)
            {
                boxRequest = boxRequest.Payload(Constants.RequestParameters.ActorToken, actorToken)
                             .Payload(Constants.RequestParameters.ActorTokenType, Constants.RequestParameters.IdTokenTypeValue);
            }

            var handler   = new HttpRequestHandler();
            var converter = new BoxJsonConverter();
            var service   = new BoxService(handler);

            IBoxResponse <OAuthSession> boxResponse = service.ToResponseAsync <OAuthSession>(boxRequest).Result;

            boxResponse.ParseResults(converter);

            return(boxResponse.ResponseObject.AccessToken);
        }
        /// <summary>
        /// Get a down scoped token.
        /// </summary>
        /// <returns>The down scoped access token.</returns>
        public string Exchange()
        {
            BoxRequest boxRequest = new BoxRequest(new Uri(Constants.BoxApiHostUriString), Constants.AuthTokenEndpointString)
                .Method(RequestMethod.Post)
                .Payload(Constants.RequestParameters.SubjectToken, token)
                .Payload(Constants.RequestParameters.SubjectTokenType, Constants.RequestParameters.AccessTokenTypeValue)
                .Payload(Constants.RequestParameters.Scope, scope)
                .Payload(Constants.RequestParameters.Resource, resourceUrl)
                .Payload(Constants.RequestParameters.GrantType, Constants.RequestParameters.TokenExchangeGrantTypeValue);

            if (actorToken != null)
            {
                boxRequest = boxRequest.Payload(Constants.RequestParameters.ActorToken, actorToken)
                    .Payload(Constants.RequestParameters.ActorTokenType, Constants.RequestParameters.IdTokenTypeValue);
            }

            var handler = new HttpRequestHandler();
            var converter = new BoxJsonConverter();
            var service = new BoxService(handler);

            IBoxResponse<OAuthSession> boxResponse = service.ToResponseAsync<OAuthSession>(boxRequest).Result;
            boxResponse.ParseResults(converter);

            return boxResponse.ResponseObject.AccessToken;
        }
Beispiel #4
0
 public BorrowModel(BorrowService borrowService, BoxService boxService, PlayerService playerService, ISharedCultureLocalizer locService)
 {
     _borrowService = borrowService;
     _boxService    = boxService;
     _playerService = playerService;
     _locService    = locService;
 }
Beispiel #5
0
        private async void MakeLockRollete(AlertDialog.Builder alert)
        {
            using (var client = ClientHelper.GetClient(CrossSettings.Current.GetValueOrDefault("token", "")))
            {
                BoxService.InitializeClient(client);
                var o_data = new ServiceResponseObject <SuccessResponse>();
                o_data = await BoxService.LockRollete(StaticBox.id);

                if (o_data.Status == HttpStatusCode.OK)
                {
                    alert.Dispose();
                    Android.App.AlertDialog.Builder alert1 = new Android.App.AlertDialog.Builder(Activity);
                    alert1.SetTitle("Опустить роллету");
                    alert1.SetMessage(o_data.Message);
                    alert1.SetPositiveButton("Закрыть", (senderAlert1, args1) =>
                    {
                    });
                    Dialog dialog1 = alert1.Create();
                    dialog1.Show();

                    btn_gate.Text    = "Поднять";
                    BoxTextGate.Text = "Закрыта";

                    FragmentTransaction transaction1 = this.FragmentManager.BeginTransaction();
                    BoxActivity         content2     = new BoxActivity();
                    transaction1.Replace(Resource.Id.frameDriverlayout, content2);
                    transaction1.Commit();
                }
                else
                {
                    Toast.MakeText(Activity, o_data.Message, ToastLength.Long).Show();
                }
            }
        }
Beispiel #6
0
        private async void MakeFold(AlertDialog.Builder alert)
        {
            using (var client = ClientHelper.GetClient(CrossSettings.Current.GetValueOrDefault("token", "")))
            {
                BoxService.InitializeClient(client);
                var o_data = new ServiceResponseObject <SuccessResponse>();
                o_data = await BoxService.FoldContainer(StaticBox.id);

                if (o_data.Status == HttpStatusCode.OK)
                {
                    alert.Dispose();
                    Android.App.AlertDialog.Builder alert1 = new Android.App.AlertDialog.Builder(Activity);
                    alert1.SetTitle("Сложить контейнер");
                    alert1.SetMessage(o_data.ResponseData.Message);
                    alert1.SetPositiveButton("Закрыть", (senderAlert1, args1) =>
                    {
                    });
                    Dialog dialog1 = alert1.Create();
                    dialog1.Show();

                    btn_fold.Text    = "Разложить";
                    BoxTextFold.Text = "Сложен";

                    FragmentTransaction transaction1 = this.FragmentManager.BeginTransaction();
                    BoxActivity         content2     = new BoxActivity();
                    transaction1.Replace(Resource.Id.frameDriverlayout, content2);
                    transaction1.Commit();
                }
            }
        }
Beispiel #7
0
        private async void Attach(AlertDialog.Builder alert)
        {
            using (var client = ClientHelper.GetClient(CrossSettings.Current.GetValueOrDefault("token", "")))
            {
                BoxService.InitializeClient(client);
                var o_data = new ServiceResponseObject <SuccessResponse>();
                o_data = await BoxService.Attach(StaticBox.id);

                if (o_data.Status == HttpStatusCode.OK)
                {
                    alert.Dispose();
                    Android.App.AlertDialog.Builder alert1 = new Android.App.AlertDialog.Builder(Activity);
                    alert1.SetTitle("Прикрепить контейнер");
                    alert1.SetMessage(o_data.ResponseData.Message);
                    alert1.SetPositiveButton("Закрыть", (senderAlert1, args1) =>
                    {
                    });
                    Dialog dialog1 = alert1.Create();
                    dialog1.Show();

                    FragmentTransaction   transaction1 = this.FragmentManager.BeginTransaction();
                    MainBoxStatusActivity content2     = new MainBoxStatusActivity();
                    transaction1.Replace(Resource.Id.frameDriverlayout, content2).AddToBackStack(null).Commit();
                }
                else
                {
                    Toast.MakeText(Activity, o_data.Message, ToastLength.Long).Show();
                }
            }
        }
Beispiel #8
0
        public bool RemoveFromCard(PackagedBoxDTO pPackagedBoxDTO)
        {
            bool Result = false;
            var  Box    = new BoxService().GetByID(pPackagedBoxDTO.BoxID);

            if (Box != null)
            {
                pPackagedBoxDTO.BoxImageName = Box.ImageName;
                pPackagedBoxDTO.BoxTitle     = Box.Name;
                var CardList = (List <PackagedBoxDTO>)System.Web.HttpContext.Current.Session["Card"];
                if (CardList != null)
                {
                    CardList.Add(pPackagedBoxDTO);
                }
                else
                {
                    CardList = new List <PackagedBoxDTO>
                    {
                        pPackagedBoxDTO
                    };
                }
                System.Web.HttpContext.Current.Session["Card"] = CardList;
                Result = true;
            }
            return(Result);
        }
Beispiel #9
0
        private async void GetVideo()
        {
            try
            {
                using (var client = ClientHelper.GetClient(CrossSettings.Current.GetValueOrDefault("token", "")))
                {
                    BoxService.InitializeClient(client);
                    var o_data = new ServiceResponseObject <SuccessResponse>();
                    o_data = await BoxService.GetVideo(StaticBox.id);

                    if (o_data.Status == HttpStatusCode.OK)
                    {
                        StaticOrder.File_Name     = o_data.ResponseData.Message;
                        StaticOrder.MessageResult = "0";
                        StartUp.StartTracking(Activity, 2);
                    }
                    else
                    {
                        Toast.MakeText(Activity, o_data.Message, ToastLength.Long).Show();
                    }
                }
            }
            catch (Exception ex)
            {
                Toast.MakeText(Activity, ex.Message, ToastLength.Long).Show();
            }
        }
Beispiel #10
0
        static void Main(string[] args)
        {
            BoxService bService = new BoxService();

            Box b1 = new Box
            {
                MinWatts = 1,
                MaxWatts = 80,
                Brand    = "iStick Rim Leaf"
            };

            Box b2 = new Box
            {
                MinWatts = 1,
                MaxWatts = 80,
                Brand    = "iKuu i80"
            };

            b1.Id = bService.Insert(b1);
            b2.Id = bService.Insert(b2);

            AtomiserService aService = new AtomiserService();

            Atomiser a1 = new Atomiser
            {
                MinWatt    = 1,
                MaxWatt    = 80,
                Brand      = "TFV V8 Baby",
                Ml         = 4,
                Resistance = 0.4
            };

            Atomiser a2 = new Atomiser
            {
                MinWatt    = 1,
                MaxWatt    = 60,
                Brand      = "Melo 5",
                Ml         = 5,
                Resistance = 0.2
            };

            a1.Id = aService.Insert(a1);
            a2.Id = aService.Insert(a2);

            MontageService mService = new MontageService();

            Montage m1 = new Montage
            {
                BoxId      = b1.Id,
                AtomiserId = a2.Id,
                Nickname   = "yolo"
            };


            m1.Id = mService.Insert(m1);
            Console.ReadKey();
        }
Beispiel #11
0
        public void GetSurfaceSquareTest()
        {
            BoxService target   = new BoxService();
            Box        box      = new Box(1, 2, 3);
            double     expected = 1 * 2 * 2 + 1 * 3 * 2 + 2 * 3 * 2;
            double     actual   = target.GetSurfaceSquare(box);

            Assert.AreEqual(expected, actual);
        }
Beispiel #12
0
        public static BoxClient GetClient(OAuthSession session)
        {
            var handler = new BoxHttpRequestHandler();
            var converter = new BoxJsonConverter();
            var service = new BoxService(handler);
            var authRepository = new AuthRepository(Config, service, converter, session);

            var client = new BoxClient(Config, converter, handler, service, authRepository);
            return client;
        }
Beispiel #13
0
        public void GetVolumeTest()
        {
            BoxService target   = new BoxService();
            Box        box      = new Box(1, 2, 3);
            double     expected = 6F;
            double     actual;

            actual = target.GetVolume(box);
            Assert.AreEqual(expected, actual);
        }
Beispiel #14
0
        public static BoxClient GetClient(OAuthSession session)
        {
            var handler        = new BoxHttpRequestHandler();
            var converter      = new BoxJsonConverter();
            var service        = new BoxService(handler);
            var authRepository = new AuthRepository(Config, service, converter, session);

            var client = new BoxClient(Config, converter, handler, service, authRepository);

            return(client);
        }
Beispiel #15
0
        public async Task GetOnePageOfBoxesAsync_getsAllBoxesAndPagingThem()
        {
            // Arrange:
            var service = new BoxService(Context, _mapper);

            // Act:
            var onePageOfBoxes = await service.GetOnePageOfBoxesAsync(currentPage : 1, howManyItemsPerPage : 2, String.Empty);

            // Assert:
            Assert.True(onePageOfBoxes.HasNextPage == true);
            Assert.True(onePageOfBoxes.TotalItemCount == await Context.Boxes.CountAsync());
        }
Beispiel #16
0
        public async Task GetBoxWithRelatedGameDataAsync_getsCorrectData()
        {
            // Arrange:
            var service = new BoxService(Context, _mapper);

            // Act:
            var boxDTO = await service.GetBoxWithRelatedGameDataAsync(1);

            // Assert:
            Assert.Equal("TestGame1", boxDTO.Game.Title);
            Assert.Equal("Publisher1", boxDTO.Game.Publisher);
        }
        public async Task AuthenticateLive_InvalidAuthCode_Exception()
        {
            // Arrange
            IRequestHandler handler = new HttpRequestHandler();
            IBoxService service = new BoxService(handler);
            IBoxConfig config = new BoxConfig(null, null, null);

            IAuthRepository authRepository = new AuthRepository(config, service, _converter);

            // Act
            OAuthSession response = await authRepository.AuthenticateAsync("fakeAuthorizationCode");
        }
        public async Task AuthenticateLive_InvalidAuthCode_Exception()
        {
            // Arrange
            IRequestHandler handler = new HttpRequestHandler();
            IBoxService     service = new BoxService(handler);
            IBoxConfig      config  = new BoxConfig(null, null, null);

            IAuthRepository authRepository = new AuthRepository(config, service, Converter);

            // Act
            OAuthSession response = await authRepository.AuthenticateAsync("fakeAuthorizationCode");
        }
Beispiel #19
0
        private async void UpdateFileData(Context context, string file_name)
        {
            var        authValue = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes($"{CrossSettings.Current.GetValueOrDefault("token", "")}:")));
            HttpClient client    = new HttpClient()
            {
                DefaultRequestHeaders = { Authorization = authValue },
                BaseAddress           = new Uri("https://smartboxcity.ru/media.php?media=")
            };

            if (CrossSettings.Current.GetValueOrDefault("role", "") == "driver")
            {
                BoxService.InitializeClient(client);
                var o_data = await BoxService.CheckFile(file_name);

                if (o_data.Status == System.Net.HttpStatusCode.OK)
                {
                    StaticOrder.MessageResult = o_data.Message;
                    //дописать
                    if (o_data.Message == "1")
                    {
                        StartUp.StopTracking(context, 2);
                    }

                    return;
                }
                else
                {
                    return;
                }
            }
            else
            {
                ManageOrderService.InitializeClient(client);
                var o_data = await ManageOrderService.CheckFile(file_name);

                if (o_data.Status == System.Net.HttpStatusCode.OK)
                {
                    StaticOrder.MessageResult = o_data.Message;
                    //дописать
                    if (o_data.Message == "1")
                    {
                        StartUp.StopTracking(context, 2);
                    }

                    return;
                }
                else
                {
                    return;
                }
            }
        }
Beispiel #20
0
        public long Save(BoxDTO pBoxDTO)
        {
            long Result = 0;

            if (pBoxDTO.ID != 0)
            {
                Result = new BoxService().Edit(pBoxDTO);
            }
            else
            {
                Result = new BoxService().Add(pBoxDTO);
            }
            return(Result);
        }
Beispiel #21
0
        public async Task UpdateBoxAsync_updatesBox()
        {
            // Arrange:
            var boxDTOtoUpdate = new BoxDTO {
                BoxId = 4, GameId = 1
            };
            var service = new BoxService(Context, _mapper);

            // Act:
            await service.UpdateBoxAsync(boxDTOtoUpdate);

            // Assert:
            Assert.True(Context.Boxes.Count() == 4);
            Assert.True(Context.Boxes.FirstOrDefault(x => x.BoxId == 4).GameId == 1);
        }
Beispiel #22
0
        public async Task GetGameTitlesAsync_getAllTitles()
        {
            // Arrange:
            var service = new BoxService(Context, _mapper);

            // Act:
            var gameTitles = await service.GetGameTitlesAsync();

            // Assert:
            Assert.True(gameTitles.Count == 4);
            Assert.Contains(gameTitles, x => x.Text == ("TestGame1"));
            Assert.Contains(gameTitles, x => x.Text == ("TestGame2"));
            Assert.Contains(gameTitles, x => x.Text == ("TestGame3"));
            Assert.Contains(gameTitles, x => x.Text == ("TestGame4"));
        }
Beispiel #23
0
        private async void GetVideo()
        {
            try
            {
                if (CrossSettings.Current.GetValueOrDefault("role", "") == "driver")
                {
                    using (var client = ClientHelper.GetClient(CrossSettings.Current.GetValueOrDefault("token", "")))
                    {
                        BoxService.InitializeClient(client);
                        var o_data = new ServiceResponseObject <SuccessResponse>();
                        o_data = await BoxService.GetVideo(StaticBox.id);

                        if (o_data.Status == HttpStatusCode.OK)
                        {
                            StaticOrder.File_Name = o_data.Message;
                        }
                        else
                        {
                            Toast.MakeText(context, o_data.Message, ToastLength.Long).Show();
                        }
                    }
                }
                else
                {
                    using (var client = ClientHelper.GetClient(CrossSettings.Current.GetValueOrDefault("token", "")))
                    {
                        ManageOrderService.InitializeClient(client);
                        var o_data = new ServiceResponseObject <SuccessResponse>();
                        o_data = await ManageOrderService.GetVideo(StaticBox.id);

                        if (o_data.Status == HttpStatusCode.OK)
                        {
                            StaticOrder.File_Name = o_data.Message;
                        }
                        else
                        {
                            Toast.MakeText(context, o_data.Message, ToastLength.Long).Show();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Toast.MakeText(context, ex.Message, ToastLength.Long).Show();
            }
        }
Beispiel #24
0
        public async Task GetBoxAsync_getsCorrectDTO()
        {
            // Arrange:
            var service = new BoxService(Context, _mapper);

            // Act:
            var boxDTO1 = await service.GetBoxAsync(1);

            var boxDTO2 = await service.GetBoxAsync(2);

            // Assert:
            Assert.True(boxDTO1.GameId == 1);
            Assert.True(boxDTO1.BoxId == 1);
            Assert.True(boxDTO1.Game.Title == "TestGame1");
            Assert.True(boxDTO2.GameId == 2);
            Assert.True(boxDTO2.BoxId == 2);
            Assert.True(boxDTO2.Game.Title == "TestGame2");
        }
        private async void GetEvents()
        {
            var o_data = new ServiceResponseObject <EventsBoxResponse>();

            using (var client = ClientHelper.GetClient(CrossSettings.Current.GetValueOrDefault("token", "")))
            {
                BoxService.InitializeClient(client);
                o_data = await BoxService.Events(StaticBox.id);

                if (o_data.Status == HttpStatusCode.OK)
                {
                    Toast.MakeText(Activity, o_data.Message, ToastLength.Long).Show();
                    var number = 0;

                    if (o_data.ResponseData.EVENTS == null || o_data.ResponseData.EVENTS.Count == 0)
                    {
                        throw new Exception("Событий нет");
                    }

                    foreach (KeyValuePair <string, List <Entity.Model.BoxResponse.EventResponse> > kvp in o_data.ResponseData.EVENTS)
                    {
                        for (int i = 0; i < o_data.ResponseData.EVENTS[kvp.Key].Count; i++)
                        {
                            string[] times = kvp.Value[i].created_at.Split(new char[] { ' ' });
                            Eventlist.Add(new EventModel
                            {
                                id          = number++,
                                Id          = StaticBox.id,
                                Name        = kvp.Value[i].message,
                                Time        = "(" + times[1] + ")",
                                Date        = times[0],
                                ContentType = kvp.Value[i].type
                            });
                        }
                    }

                    UpdateList();
                }
                else
                {
                    Toast.MakeText(Activity, o_data.Message, ToastLength.Long).Show();//"Unexpected character encountered while parsing value: <. Path '', line 0, position 0."
                }
            }
        }
Beispiel #26
0
        public async Task DoesBoxExistAsync_saysTrueAboutIt()
        {
            // Arrange:
            var service = new BoxService(Context, _mapper);

            // Act:
            var shouldBeTrue1 = await service.DoesBoxExistAsync(1);

            var shouldBeTrue2 = await service.DoesBoxExistAsync(2);

            var shouldBeFalse1 = await service.DoesBoxExistAsync(8);

            var shouldBeFalse2 = await service.DoesBoxExistAsync(9);

            // Assert:
            Assert.True(shouldBeTrue1 == true);
            Assert.True(shouldBeTrue2 == true);
            Assert.True(shouldBeFalse1 == false);
            Assert.True(shouldBeFalse2 == false);
        }
Beispiel #27
0
        public async Task AddNewBoxAsync_addsNewBox()
        {
            // Arrange:
            ulong boxId       = 1234;
            var   boxDTOtoAdd = new BoxDTO {
                BoxId = boxId, GameId = 4
            };
            var service = new BoxService(Context, _mapper);

            // Act:
            await service.AddBoxAsync(boxDTOtoAdd);

            // Assert:
            var addedBox = await service.GetBoxAsync(boxId);

            Assert.Equal(addedBox.BoxId, boxDTOtoAdd.BoxId);
            Assert.Equal(boxId, addedBox.BoxId);
            Assert.Equal(4, addedBox.GameId);
            Assert.True(await Context.Boxes.CountAsync() == 5);
        }
        private OAuthSession JWTAuthPost(string assertion)
        {
            BoxRequest boxRequest = new BoxRequest(this.boxConfig.BoxApiHostUri, Constants.AuthTokenEndpointString)
                                    .Method(RequestMethod.Post)
                                    .Header(Constants.RequestParameters.UserAgent, this.boxConfig.UserAgent)
                                    .Payload(Constants.RequestParameters.GrantType, Constants.RequestParameters.JWTAuthorizationCode)
                                    .Payload(Constants.RequestParameters.Assertion, assertion)
                                    .Payload(Constants.RequestParameters.ClientId, this.boxConfig.ClientId)
                                    .Payload(Constants.RequestParameters.ClientSecret, this.boxConfig.ClientSecret);

            var handler   = new HttpRequestHandler();
            var converter = new BoxJsonConverter();
            var service   = new BoxService(handler);

            IBoxResponse <OAuthSession> boxResponse = service.ToResponseAsync <OAuthSession>(boxRequest).Result;

            boxResponse.ParseResults(converter);

            return(boxResponse.ResponseObject);
        }
Beispiel #29
0
        private async void StopCommands()
        {
            using (var client = ClientHelper.GetClient(CrossSettings.Current.GetValueOrDefault("token", "")))
            {
                BoxService.InitializeClient(client);
                var o_data = new ServiceResponseObject <SuccessResponse>();
                o_data = await BoxService.StopCommands(StaticBox.id);

                if (o_data.Status == HttpStatusCode.OK)
                {
                    Toast.MakeText(Activity, "Успешно!", ToastLength.Long).Show();
                    FragmentTransaction   transaction1 = this.FragmentManager.BeginTransaction();
                    MainBoxStatusActivity content2     = new MainBoxStatusActivity();
                    transaction1.Replace(Resource.Id.frameDriverlayout, content2);
                    transaction1.Commit();
                }
                else
                {
                    Toast.MakeText(Activity, o_data.Message, ToastLength.Long).Show();
                }
            }
        }
Beispiel #30
0
        //private async void GetVideo(AlertDialog.Builder alert)
        //{
        //    using (var client = ClientHelper.GetClient(CrossSettings.Current.GetValueOrDefault("token", "")))
        //    {
        //        BoxService.InitializeClient(client);
        //        var o_data = new ServiceResponseObject<SuccessResponse>();
        //        o_data = await BoxService.GetVideo(StaticBox.id);

        //        if (o_data.Status == HttpStatusCode.OK)
        //        {
        //            alert.Dispose();

        //            LayoutInflater layoutInflater = LayoutInflater.From(Activity);
        //            View view = layoutInflater.Inflate(Resource.Layout.modal_video, null);
        //            var img_get_video = view.FindViewById<VideoView>(Resource.Id.img_get_video);

        //            var src = Android.Net.Uri.Parse(URL + o_data.ResponseData.Message);
        //            img_get_video.SetVideoURI(src);
        //            img_get_video.Start();

        //            //var imageBitmap = HomeService.GetImageBitmapFromUrl(URL + o_data.ResponseData.Message);
        //            //img_get_video.SetVideoURI(imageBitmap);

        //            Android.App.AlertDialog.Builder alert1 = new Android.App.AlertDialog.Builder(Activity);
        //            alert1.SetTitle("Сделать видео");
        //            alert1.SetView(view);
        //            alert1.SetPositiveButton("Закрыть", (senderAlert1, args1) =>
        //            {
        //            });
        //            Dialog dialog1 = alert1.Create();
        //            dialog1.Show();
        //        }
        //        else
        //        {
        //            Toast.MakeText(Activity, o_data.Message, ToastLength.Long).Show();
        //        }
        //    }
        //}

        private async void GetPhoto(AlertDialog.Builder alert)
        {
            using (var client = ClientHelper.GetClient(CrossSettings.Current.GetValueOrDefault("token", "")))
            {
                BoxService.InitializeClient(client);
                var o_data = new ServiceResponseObject <SuccessResponse>();
                o_data = await BoxService.GetPhoto(StaticBox.id);

                if (o_data.Status == HttpStatusCode.OK)
                {
                    alert.Dispose();

                    LayoutInflater layoutInflater = LayoutInflater.From(Activity);
                    View           view           = layoutInflater.Inflate(Resource.Layout.modal_photo, null);
                    var            img_get_photo  = view.FindViewById <ImageView>(Resource.Id.img_get_photo);

                    var src = Android.Net.Uri.Parse(URL + o_data.ResponseData.Message);
                    img_get_photo.SetImageURI(src);

                    var imageBitmap = HomeService.GetImageBitmapFromUrl(URL + o_data.ResponseData.Message);
                    img_get_photo.SetImageBitmap(imageBitmap);

                    Android.App.AlertDialog.Builder alert1 = new Android.App.AlertDialog.Builder(Activity);
                    alert1.SetView(view);
                    ////
                    alert1.SetCancelable(false);
                    alert1.SetPositiveButton("Закрыть", (senderAlert1, args1) =>
                    {
                    });
                    Dialog dialog1 = alert1.Create();
                    dialog1.Show();
                }
                else
                {
                    Toast.MakeText(Activity, o_data.Message, ToastLength.Long).Show();
                }
            }
        }
 public BoxesController(ILogger <BoxesController> logger, BoxService boxservice)
 {
     _logger     = logger;
     _boxService = boxservice;
 }
Beispiel #32
0
 public UserController(IBoxService boxService, ILogger <UserController> logger)
 {
     _boxService = boxService as BoxService;
     _logger     = logger;
 }
 internal BoxFoldersEndpoint(BoxService service) {
     Service = service;
 }
Beispiel #34
0
 public CreateModel(BoxService boxService, ISharedCultureLocalizer locService, ILogger <CreateModel> logger)
 {
     _boxService = boxService;
     _locService = locService;
     _logger     = logger;
 }
Beispiel #35
0
        private OAuthSession JWTAuthPost(string assertion)
        {
            BoxRequest boxRequest = new BoxRequest(this.boxConfig.BoxApiHostUri, Constants.AuthTokenEndpointString)
                                            .Method(RequestMethod.Post)
                                            .Header(Constants.RequestParameters.UserAgent, this.boxConfig.UserAgent)
                                            .Payload(Constants.RequestParameters.GrantType, Constants.RequestParameters.JWTAuthorizationCode)
                                            .Payload(Constants.RequestParameters.Assertion, assertion)
                                            .Payload(Constants.RequestParameters.ClientId, this.boxConfig.ClientId)
                                            .Payload(Constants.RequestParameters.ClientSecret, this.boxConfig.ClientSecret);

            var handler = new HttpRequestHandler();
            var converter = new BoxJsonConverter();
            var service = new BoxService(handler);

            IBoxResponse<OAuthSession> boxResponse = service.ToResponseAsync<OAuthSession>(boxRequest).Result;
            boxResponse.ParseResults(converter);

            return boxResponse.ResponseObject;
        }