Esempio n. 1
0
 protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
 {
     base.OnActivityResult(requestCode, resultCode, data);
     AuthenticationContinuationHelper.SetAuthenticationContinuationEventArgs(requestCode, resultCode, data);
 }
 public override bool OpenUrl(UIApplication app, NSUrl url, NSDictionary options)
 {
     AuthenticationContinuationHelper.SetAuthenticationContinuationEventArgs(url);
     return(true);
 }
Esempio n. 3
0
 public override bool OpenUrl(UIApplication application, NSUrl url, string sourceApplication, NSObject annotation)
 {
     //return base.OpenUrl(application, url, sourceApplication, annotation);
     AuthenticationContinuationHelper.SetAuthenticationContinuationEventArgs(url);
     return(ApplicationDelegate.SharedInstance.OpenUrl(application, url, sourceApplication, annotation));
 }
 /// <summary>
 /// Required override method for MSAL integration
 /// </summary>
 public override void OnMAMActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data)
 {
     base.OnMAMActivityResult(requestCode, resultCode, data);
     AuthenticationContinuationHelper.SetAuthenticationContinuationEventArgs(requestCode, resultCode, data);
 }
Esempio n. 5
0
        protected override async void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data)
        {
            switch (requestCode)
            {
            case BookDetailActivity.RequestCode:
                var dialog = UserDialogs.Instance.Loading("Loading");
                if (resultCode == Result.Ok)
                {
                    var bookXml      = data.GetStringExtra("book");
                    var autoComplete = data.GetBooleanExtra("autoComplete", false);

                    if (!string.IsNullOrEmpty(bookXml))
                    {
                        XmlSerializer xmlSerializer = new XmlSerializer(typeof(ClientBookDto));
                        StringReader  sr            = new StringReader(bookXml);
                        try
                        {
                            var book = (ClientBookDto)xmlSerializer.Deserialize(sr);

                            if (string.IsNullOrEmpty(book.BookId))
                            {
                                book.BookId = Guid.NewGuid().ToString();
                                if (CheckInternetConnection())
                                {
                                    using (var client = new HttpClient())
                                    {
                                        try
                                        {
                                            var request = new AddOrEditBookRequest
                                            {
                                                BookId           = Guid.NewGuid().ToString(),
                                                Author           = book.Author,
                                                GenreId          = book.GenreId,
                                                Isbn             = book.Isbn,
                                                PageNumber       = book.PageNumber,
                                                Title            = book.Title,
                                                AutoCompleteData = autoComplete,
                                                #region tmp ki lesz veve
                                                UserIdentifier = HbrApplication.UserIdentifier
                                                                 #endregion
                                            };

                                            var result = await client.PostAsJsonAsync("https://hbr.azurewebsites.net/api/book/addnewbook", request);

                                            if (result.IsSuccessStatusCode)
                                            {
                                                book = await result.Content.ReadAsAsync <ClientBookDto>();
                                            }
                                        }
                                        catch (Exception e)
                                        {
                                        }
                                    }
                                }

                                mAdapter.AddBooks(new List <ClientBookDto> {
                                    book
                                });
                                _database.AddElement(book);
                            }
                            else
                            {
                                if (CheckInternetConnection())
                                {
                                    using (var client = new HttpClient())
                                    {
                                        try
                                        {
                                            var request = new AddOrEditBookRequest
                                            {
                                                Author           = book.Author,
                                                BookId           = book.BookId,
                                                GenreId          = book.GenreId,
                                                Isbn             = book.Isbn,
                                                PageNumber       = book.PageNumber,
                                                Title            = book.Title,
                                                AutoCompleteData = autoComplete,
                                                #region tmp ki lesz veve
                                                UserIdentifier = HbrApplication.UserIdentifier
                                                                 #endregion
                                            };

                                            var response = await client.PostAsJsonAsync("https://hbr.azurewebsites.net/api/book/updatebook", request);
                                        }
                                        catch (Exception e)
                                        {
                                        }
                                    }
                                }

                                mAdapter.UpdateBook(book);
                                _database.AddElement(book);
                            }
                        }
                        catch (Exception e)
                        {
                        }
                    }
                }
                dialog.Dispose();
                break;

            case get_file_request_code:
                var    uri    = data.Data;
                var    stream = ContentResolver.OpenInputStream(uri);
                byte[] byteArray;
                using (var memoryStream = new MemoryStream())
                {
                    stream.CopyTo(memoryStream);
                    byteArray = memoryStream.ToArray();
                }
                using (var client = new HttpClient())
                    using (var formData = new MultipartFormDataContent())
                    {
                        var request = new AddOrEditBookRequest
                        {
                            Isbn = "9780316272247",
                            #region tmp ki lesz veve
                            UserIdentifier = HbrApplication.UserIdentifier
                                             #endregion
                        };
                        var a      = Encoding.ASCII.GetString(byteArray);
                        var result = await client.PostAsJsonAsync("https://hbr.azurewebsites.net/api/Book/UploadBook", request);

                        var resultData = await result.Content.ReadAsByteArrayAsync();

                        OpenPfd(resultData);
                        //HttpContent content = new StreamContent(stream);
                        //content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("form-data") { Name = "formFile", FileName = "UploadedFile" };
                        //content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/octet-stream");
                        //formData.Add(content);
                        //var response = await client.PostAsync("https://hbr.azurewebsites.net/api/book/uploadbook", formData);
                        //var str = await response.Content.ReadAsStringAsync();
                    }
                break;
            }

            if ((int)resultCode == sign_in_response_code)
            {
                AuthenticationContinuationHelper.SetAuthenticationContinuationEventArgs(requestCode, resultCode, data);
            }

            if (CheckInternetConnection())
            {
                await Refresh();
            }
        }
 public void OnActivityResult(IFileStorageSetupActivity activity, int requestCode, int resultCode, Intent data)
 {
     AuthenticationContinuationHelper.SetAuthenticationContinuationEventArgs(requestCode, (Result)resultCode,
                                                                             data);
 }
Esempio n. 7
0
 public override bool OpenUrl(UIApplication application, NSUrl url, string sourceApplication, NSObject annotation)
 {
     AuthenticationContinuationHelper.SetAuthenticationContinuationEventArgs(url);
     return(true);
 }
Esempio n. 8
0
 public static void SetAuthenticationResult(int requestCode, Result resultCode, Intent data) =>
 AuthenticationContinuationHelper.SetAuthenticationContinuationEventArgs(requestCode, resultCode, data);
Esempio n. 9
0
 protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
 {
     System.Diagnostics.Debug.WriteLine("Debug: called OnActivityResult");
     base.OnActivityResult(requestCode, resultCode, data);
     AuthenticationContinuationHelper.SetAuthenticationContinuationEventArgs(requestCode, resultCode, data);
 }