public void ShowFieldsForItem(ISitecoreItem item) { BeginInvokeOnMainThread(delegate { this.Title = item.DisplayName; this.CleanupTableViewBindingsSync(); this.fieldsDataSource = new FieldsDataSource(); this.fieldsTableDelegate = new FieldCellSelectionHandler(); FieldsDataSource dataSource = this.fieldsDataSource; dataSource.SitecoreItem = item; dataSource.TableView = this.TableView; FieldCellSelectionHandler tableDelegate = this.fieldsTableDelegate; tableDelegate.TableView = this.TableView; tableDelegate.SitecoreItem = item; FieldCellSelectionHandler.TableViewDidSelectFieldAtIndexPath onFieldSelected = delegate(UITableView tableView, IField itemField, NSIndexPath indexPath) { AlertHelper.ShowLocalizedAlertWithOkOption("Field Raw Value", itemField.RawValue); }; tableDelegate.OnFieldCellSelectedDelegate = onFieldSelected; this.TableView.DataSource = dataSource; this.TableView.Delegate = tableDelegate; this.TableView.ReloadData(); }); }
private async void SendQueryRequest() { try { using (ISitecoreSSCSession session = this.instanceSettings.GetSession()) { var request = ItemSSCRequestBuilder.StoredQuerryRequest(queryTextField.Text) .PageNumber(0) .ItemsPerPage(100) .Build(); this.ShowLoader(); ScItemsResponse response = await session.RunStoredQuerryAsync(request); this.HideLoader(); if (response.ResultCount > 0) { this.ShowItemsList(response); } else { AlertHelper.ShowLocalizedAlertWithOkOption("Message", "No item found"); } } } catch (Exception e) { this.HideLoader(); AlertHelper.ShowLocalizedAlertWithOkOption("Error", e.Message); } }
private async void SendRequest() { try { using (ISitecoreSSCSession session = this.instanceSettings.GetSession()) { this.ShowLoader(); var request = ItemSSCRequestBuilder.SitecoreSearchRequest(queryTextField.Text) .AddDescendingFieldsToSort("title") .AddAscendingFieldsToSort("title") .AddDescendingFieldsToSort("text") .Build(); ScItemsResponse response = await session.RunSearchAsync(request); this.HideLoader(); if (response.ResultCount > 0) { this.ShowItemsList(response); } else { AlertHelper.ShowLocalizedAlertWithOkOption("Message", "No items found"); } } } catch (Exception e) { this.HideLoader(); AlertHelper.ShowLocalizedAlertWithOkOption("Error", e.Message); } }
private async void SendRequest() { try { using (ISitecoreWebApiSession session = this.instanceSettings.GetSession()) { var request = ItemWebApiRequestBuilder.RenderingHtmlRequestWithSourceAndRenderingId(sourceIdTextField.Text, renderingIdTextField.Text) .Build(); this.ShowLoader(); Stream response = await session.ReadRenderingHtmlAsync(request); response.Position = 0; string htmlText = ""; using (StreamReader reader = new StreamReader(response)) { htmlText = await reader.ReadToEndAsync(); } this.resultWebView.LoadHtmlString(htmlText, null); } } catch (Exception e) { AlertHelper.ShowLocalizedAlertWithOkOption("Error", e.Message); } finally { BeginInvokeOnMainThread(delegate { this.HideLoader(); }); } }
private async void SendDeleteByIdRequest() { try { using (var session = this.instanceSettings.GetSession()) { var request = ItemSSCRequestBuilder.DeleteItemRequestWithId(this.itemIdField.Text) .Database("master") .Build(); this.ShowLoader(); ScDeleteItemsResponse response = await session.DeleteItemAsync(request); if (response.Deleted) { AlertHelper.ShowLocalizedAlertWithOkOption("Message", "The item deleted successfully"); } } } catch (Exception e) { AlertHelper.ShowLocalizedAlertWithOkOption("Error", e.Message); } finally { BeginInvokeOnMainThread(delegate { this.HideLoader(); }); } }
private async void SendDeleteByPathRequest() { try { using (var session = this.instanceSettings.GetSession()) { var request = ItemWebApiRequestBuilder.DeleteItemRequestWithPath(this.itemPathField.Text) .Build(); this.ShowLoader(); ScDeleteItemsResponse response = await session.DeleteItemAsync(request); this.ProceedResponce(response); } } catch (Exception e) { AlertHelper.ShowLocalizedAlertWithOkOption("Error", e.Message); } finally { BeginInvokeOnMainThread(delegate { this.HideLoader(); }); } }
protected void Handle_FinishedPickingMedia(object sender, UIImagePickerMediaPickedEventArgs e) { bool isImage = false; switch (e.Info[UIImagePickerController.MediaType].ToString()) { case "public.image": { Console.WriteLine("Image selected"); isImage = true; break; } case "public.video": { Console.WriteLine("Video selected"); break; } } if (isImage) { UIImage originalImage = e.Info[UIImagePickerController.OriginalImage] as UIImage; if (originalImage != null) { } } else { AlertHelper.ShowLocalizedAlertWithOkOption("Alert", "Video uploading is not supported"); } imagePicker.DismissViewController(true, null); }
private async void SendRequest() { try { using (ISitecoreWebApiSession session = this.instanceSettings.GetSession()) { var request = ItemWebApiRequestBuilder.ReadItemsRequestWithSitecoreQuery(queryTextField.Text) .Build(); this.ShowLoader(); ScItemsResponse response = await session.ReadItemAsync(request); this.HideLoader(); if (response.ResultCount > 0) { this.ShowItemsList(response); } else { AlertHelper.ShowLocalizedAlertWithOkOption("Message", "Item is not exist"); } } } catch (Exception e) { this.HideLoader(); AlertHelper.ShowLocalizedAlertWithOkOption("Error", e.Message); } }
private async void SendRequest() { try { using (ISitecoreWebApiSession session = this.instanceSettings.GetSession()) { var builder = ItemWebApiRequestBuilder.ReadItemsRequestWithId(itemIdTextField.Text) .Payload(this.currentPayloadType) .AddFieldsToRead(this.fieldNameTextField.Text); if (this.parentScopeButton.Selected) { builder = builder.AddScope(ScopeType.Parent); } if (this.selfScopeButton.Selected) { builder = builder.AddScope(ScopeType.Self); } if (this.childrenScopeButton.Selected) { builder = builder.AddScope(ScopeType.Children); } var request = builder.Build(); this.ShowLoader(); ScItemsResponse response = await session.ReadItemAsync(request); if (response.Any()) { this.ShowItemsList(response); //items serialization test ScItem item = response[0] as ScItem; string json = JsonConvert.SerializeObject(item); ScItem restoredItem = JsonConvert.DeserializeObject <ScItem>(json); Console.WriteLine(restoredItem.DisplayName); } else { AlertHelper.ShowLocalizedAlertWithOkOption("Message", "Item is not exist"); } } } catch (Exception e) { this.CleanupTableViewBindings(); AlertHelper.ShowLocalizedAlertWithOkOption("Error", e.Message); } finally { BeginInvokeOnMainThread(delegate { this.HideLoader(); this.FieldsTableView.ReloadData(); }); } }
public static void ShowLocalizedAlertWithOkOption(string title, string message) { string localizedTitle = NSBundle.MainBundle.LocalizedString(title, null); string localizedMessage = NSBundle.MainBundle.LocalizedString(message, null); string localizedButtonTitle = NSBundle.MainBundle.LocalizedString("OK", null); AlertHelper.ShowAlertWithSingleButton(localizedTitle, localizedMessage, localizedButtonTitle); }
private async void SendRequest() { try { using (ISitecoreWebApiSession session = this.instanceSettings.GetSession()) { IDownloadMediaOptions options = new MediaOptionsBuilder() .Set .Width(this.width) .Height(this.height) .BackgroundColor("white") .Build(); string path = this.MediaPathTextField.Text; var request = ItemWebApiRequestBuilder.DownloadResourceRequestWithMediaPath(path) .DownloadOptions(options) .Build(); byte[] data = null; using (Stream response = await session.DownloadMediaResourceAsync(request)) using (MemoryStream responseInMemory = new MemoryStream()) { await response.CopyToAsync(responseInMemory); data = responseInMemory.ToArray(); } BeginInvokeOnMainThread(delegate { using (UIImage image = new UIImage(NSData.FromArray(data))) { // no need disposing // since this.ImageView.Image creates a // new C# object on each call this.ImageView.Image = image; // Update Overlay this.HideLoader(); } }); } } catch (Exception e) { AlertHelper.ShowLocalizedAlertWithOkOption("Error", e.Message); } finally { BeginInvokeOnMainThread(delegate { this.HideLoader(); }); } }
private void ProceedResponce(ScDeleteItemsResponse response) { if (response.Count > 0) { AlertHelper.ShowLocalizedAlertWithOkOption("Message", "The item deleted successfully"); } else { AlertHelper.ShowLocalizedAlertWithOkOption("Message", "Item is not exist"); } }
partial void OnUpdateItemButtonTapped(MonoTouch.UIKit.UIButton sender) { if (null == this.CreatedItemPath) { AlertHelper.ShowLocalizedAlertWithOkOption("Message", "Create item at first"); } else { this.SendUpdateRequest(); } }
partial void OnUpdateItemButtonTapped(NSObject sender) { if (null == this.CreatedItemId) { AlertHelper.ShowLocalizedAlertWithOkOption("Message", "Create item at first"); } else { this.SendUpdateRequest(); } }
partial void OnGetItemButtonTouched(Foundation.NSObject sender) { if (String.IsNullOrEmpty(itemIdTextField.Text)) { AlertHelper.ShowLocalizedAlertWithOkOption("Error", "Please type item Id"); } else { this.HideKeyboardForAllFields(); this.SendRequest(); } }
partial void OnStoredSearchButtonTouched(Foundation.NSObject sender) { if (String.IsNullOrEmpty(queryTextField.Text)) { AlertHelper.ShowLocalizedAlertWithOkOption("Error", "Please type search id"); } else { this.HideKeyboard(this.queryTextField); this.SendSearchRequest(); } }
private async void SendRequest() { try { using (ISitecoreWebApiSession session = this.instanceSettings.GetSession()) { var builder = ItemWebApiRequestBuilder.ReadItemsRequestWithPath(this.ItemPathField.Text) .Payload(this.currentPayloadType) .AddFieldsToRead(this.fieldNameTextField.Text); if (this.parentScopeButton.Selected) { builder = builder.AddScope(ScopeType.Parent); } if (this.selfScopeButton.Selected) { builder = builder.AddScope(ScopeType.Self); } if (this.childrenScopeButton.Selected) { builder = builder.AddScope(ScopeType.Children); } var request = builder.Build(); this.ShowLoader(); ScItemsResponse response = await session.ReadItemAsync(request); if (response.Any()) { this.ShowItemsList(response); } else { AlertHelper.ShowLocalizedAlertWithOkOption("Message", "Item is not exist"); } } } catch (Exception e) { this.CleanupTableViewBindings(); AlertHelper.ShowLocalizedAlertWithOkOption("Error", e.Message); } finally { BeginInvokeOnMainThread(delegate { this.FieldsTableView.ReloadData(); this.HideLoader(); }); } }
partial void OnGetItemButtonTouched(NSObject sender) { if (String.IsNullOrEmpty(queryTextField.Text)) { AlertHelper.ShowLocalizedAlertWithOkOption("Error", "Please type query"); } else { this.HideKeyboard(this.queryTextField); this.SendRequest(); } }
partial void OnGetItemButtonTouched(MonoTouch.Foundation.NSObject sender) { if (String.IsNullOrEmpty(this.ItemPathField.Text)) { AlertHelper.ShowLocalizedAlertWithOkOption("Error", "Please type item path"); } else { this.HideKeyboard(this.ItemPathField); this.HideKeyboard(this.fieldNameTextField); this.SendRequest(); } }
partial void OnGetRenderingTouch(Foundation.NSObject sender) { if (String.IsNullOrEmpty(sourceIdTextField.Text)) { AlertHelper.ShowLocalizedAlertWithOkOption("Error", "Please type source Id"); } else if (String.IsNullOrEmpty(renderingIdTextField.Text)) { AlertHelper.ShowLocalizedAlertWithOkOption("Error", "Please type rendering Id"); } else { this.HideKeyboardForAllFields(); } }
partial void OnDownloadButtonTouched(NSObject sender) { try { if (String.IsNullOrEmpty(this.WidthTextField.Text) || String.IsNullOrEmpty(this.HeightTextField.Text)) { AlertHelper.ShowLocalizedAlertWithOkOption("Error", "Incorect width or height value"); return; } this.width = Convert.ToInt32(this.WidthTextField.Text); this.height = Convert.ToInt32(this.HeightTextField.Text); if (String.IsNullOrEmpty(this.MediaPathTextField.Text)) { AlertHelper.ShowLocalizedAlertWithOkOption("Error", "Please type media path"); } else { bool wrongSizeData = this.width <= 0 || this.width > this.maxWidth || this.height <= 0 || this.height > this.maxHeight; if (wrongSizeData) { AlertHelper.ShowLocalizedAlertWithOkOption("Error", "Incorect width or height value"); } else { this.HideKeyboard(this.MediaPathTextField); this.HideKeyboard(this.WidthTextField); this.HideKeyboard(this.HeightTextField); this.SendRequest(); } } } catch (Exception e) { AlertHelper.ShowLocalizedAlertWithOkOption("Error", e.Message); } }
private async void SendCreateRequest() { try { using (ISitecoreSSCSession session = this.instanceSettings.GetSession()) { var request = EntitySSCRequestBuilder.CreateEntityRequest(this.EntityIdTextField.Text) .Namespace("aggregate") .Controller("admin") .Action("Todo") .AddFieldsRawValuesByNameToSet("Title", this.EntityTitleTextField.Text) .AddFieldsRawValuesByNameToSet("Url", null) .Build(); this.ShowLoader(); ScCreateEntityResponse response = await session.CreateEntityAsync(request); string entityId = response.CreatedEntity.Id; string entityTitle = response.CreatedEntity["Title"].RawValue; if (response.Created) { AlertHelper.ShowLocalizedAlertWithOkOption("Message", "Entity created successfully, Id is " + entityId + " Title: " + entityTitle); } else { string responseCode = "Unknown"; if (response != null) { responseCode = response.StatusCode.ToString(); } AlertHelper.ShowLocalizedAlertWithOkOption("Message", "Entity was not created, response code: " + responseCode); } } } catch (Exception e) { AlertHelper.ShowLocalizedAlertWithOkOption("Message", "Entity was not created: " + e.Message); } finally { BeginInvokeOnMainThread(delegate { this.HideLoader(); }); } }
private async void SendImage(UIImage image) { try { using (ISitecoreWebApiSession session = this.instanceSettings.GetSession()) { Stream stream = image.AsJPEG().AsStream(); var request = ItemWebApiRequestBuilder.UploadResourceRequestWithParentPath(itemPathTextField.Text) .ItemDataStream(stream) .ContentType("image/jpg") .ItemName(this.itemNameTextField.Text) .FileName("imageFile.jpg") .Build(); this.ShowLoader(); var response = await session.UploadMediaResourceAsync(request); if (response != null) { AlertHelper.ShowAlertWithOkOption("upload image result", "The image uploaded successfuly"); } else { AlertHelper.ShowAlertWithOkOption("upload image result", "something wrong"); } } } catch (Exception e) { AlertHelper.ShowLocalizedAlertWithOkOption("Error", e.Message); } finally { BeginInvokeOnMainThread(delegate { this.HideLoader(); }); } }
private async void SendRequest() { try { using (ISitecoreSSCSession session = this.instanceSettings.GetSession()) { this.ShowLoader(); var ext = ExtendedSessionBuilder.ExtendedSessionWith(session) .Build(); var request = ExtendedSSCRequestBuilder.SitecoreQueryRequest("/sitecore/content//*[@@templateid='{DA86D7C6-DBF8-464C-8B43-68ED1EBB44EA}']") .PageNumber(0) .ItemsPerPage(20) .Database("web") .AddFieldsToRead("title") .Build(); var response = await ext.SearchBySitecoreQueryAsync(request); Console.WriteLine("RESULT COUNT: " + response.Count().ToString()); if (response.Any()) { this.ShowItemsList(response); } else { AlertHelper.ShowLocalizedAlertWithOkOption("Message", "Item is not exist"); } } } catch (Exception e) { this.CleanupTableViewBindings(); AlertHelper.ShowLocalizedAlertWithOkOption("Error", e.Message); } finally { BeginInvokeOnMainThread(delegate { this.HideLoader(); this.FieldsTableView.ReloadData(); }); } }
private async void SendRequest() { try { using (ISitecoreWebApiSession session = this.instanceSettings.GetSession()) { var request = ItemWebApiRequestBuilder.CreateItemRequestWithParentId(this.pathField.Text) .ItemTemplatePath("Sample/Sample Item") .ItemName(this.nameField.Text) .AddFieldsRawValuesByNameToSet("Title", titleField.Text) .AddFieldsRawValuesByNameToSet("Text", textField.Text) .Build(); this.ShowLoader(); ScItemsResponse response = await session.CreateItemAsync(request); if (response.Any()) { ISitecoreItem item = response[0]; this.CreatedItemId = item.Id; AlertHelper.ShowLocalizedAlertWithOkOption("The item created successfully", "Item path: " + item.Path); } else { AlertHelper.ShowLocalizedAlertWithOkOption("Message", "Item is not exist"); } } } catch (Exception e) { AlertHelper.ShowLocalizedAlertWithOkOption("Error", e.Message); } finally { BeginInvokeOnMainThread(delegate { this.HideLoader(); }); } }
private async void SendRequest() { try { using (ISitecoreSSCSession session = this.instanceSettings.GetSession()) { var request = ItemSSCRequestBuilder.CreateItemRequestWithParentPath(this.pathField.Text) .ItemTemplateId("76036f5e-cbce-46d1-af0a-4143f9b557aa") .ItemName(this.nameField.Text) .AddFieldsRawValuesByNameToSet("Title", titleField.Text) .AddFieldsRawValuesByNameToSet("Text", textField.Text) .Build(); this.ShowLoader(); var response = await session.CreateItemAsync(request); if (response.Created) { AlertHelper.ShowLocalizedAlertWithOkOption("Message", "The item created successfully, Id is " + response.ItemId); } else { AlertHelper.ShowLocalizedAlertWithOkOption("Message", "Item was not created"); } } } catch { AlertHelper.ShowLocalizedAlertWithOkOption("Message", "Item was not created"); } finally { BeginInvokeOnMainThread(delegate { this.HideLoader(); }); } }
private async void SendAuthRequest() { try { using (var credentials = new SecureStringPasswordProvider(this.loginField.Text, this.passwordField.Text)) using ( var session = SitecoreWebApiSessionBuilder.AuthenticatedSessionWithHost(this.urlField.Text) .Credentials(credentials) .Site(this.siteField.Text) .BuildReadonlySession() ) { this.ShowLoader(); bool response = await session.AuthenticateAsync(); if (response) { AlertHelper.ShowLocalizedAlertWithOkOption("Message", "This user exist"); } else { AlertHelper.ShowLocalizedAlertWithOkOption("Message", "This user not exist"); } } } catch (Exception e) { AlertHelper.ShowLocalizedAlertWithOkOption("Error", e.Message); } finally { BeginInvokeOnMainThread(delegate { this.HideLoader(); }); } }
private async void SendRequest() { try { using (ISitecoreSSCSession session = this.instanceSettings.GetSession()) { var request = ItemSSCRequestBuilder.ReadItemsRequestWithPath(this.ItemPathField.Text) .AddFieldsToRead(this.fieldNameTextField.Text) .Build(); this.ShowLoader(); ScItemsResponse response = await session.ReadItemAsync(request); if (response.Any()) { this.ShowItemsList(response); } else { AlertHelper.ShowLocalizedAlertWithOkOption("Message", "Item is not exist"); } } } catch (Exception e) { this.CleanupTableViewBindings(); AlertHelper.ShowLocalizedAlertWithOkOption("Error", e.Message); } finally { BeginInvokeOnMainThread(delegate { this.FieldsTableView.ReloadData(); this.HideLoader(); }); } }
private async void SendUpdateRequest() { try { using (var session = this.instanceSettings.GetSession()) { var request = ItemSSCRequestBuilder.UpdateItemRequestWithId(this.pathField.Text) .AddFieldsRawValuesByNameToSet("Title", this.titleField.Text) .AddFieldsRawValuesByNameToSet("Text", this.textField.Text) .Database("master") .Build(); this.ShowLoader(); var response = await session.UpdateItemAsync(request); if (response.Updated) { AlertHelper.ShowLocalizedAlertWithOkOption("Message", "The item updated successfully"); } else { AlertHelper.ShowLocalizedAlertWithOkOption("Message", "Item is not exist"); } } } catch { AlertHelper.ShowLocalizedAlertWithOkOption("Message", "The item updated successfully"); } finally { BeginInvokeOnMainThread(delegate { this.HideLoader(); }); } }
private async void SendUpdateRequest() { try { using (var session = this.instanceSettings.GetSession()) { var request = EntitySSCRequestBuilder.UpdateEntityRequest(this.EntityIdTextField.Text) .Namespace("aggregate") .Controller("admin") .Action("Todo") .AddFieldsRawValuesByNameToSet("Title", this.EntityTitleTextField.Text) .Build(); this.ShowLoader(); ScUpdateEntityResponse response = await session.UpdateEntityAsync(request); if (response.Updated) { AlertHelper.ShowLocalizedAlertWithOkOption("Message", "The entity updated successfully"); } else { string responseCode = "Unknown"; if (response != null) { responseCode = response.StatusCode.ToString(); } AlertHelper.ShowLocalizedAlertWithOkOption("Message", "Entity was not updated, response code: " + responseCode); } } } catch { AlertHelper.ShowLocalizedAlertWithOkOption("Message", "The item updated successfully"); } finally { BeginInvokeOnMainThread(delegate { this.HideLoader(); }); } }