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.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);
            }
        }
示例#3
0
        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);
            }
        }
        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 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();
                });
            }
        }
示例#6
0
        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);
        }
 partial void OnUpdateItemButtonTapped(MonoTouch.UIKit.UIButton sender)
 {
     if (null == this.CreatedItemPath)
     {
         AlertHelper.ShowLocalizedAlertWithOkOption("Message", "Create item at first");
     }
     else
     {
         this.SendUpdateRequest();
     }
 }
示例#8
0
 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();
     }
 }
 partial void OnGetItemButtonTouched(NSObject sender)
 {
     if (String.IsNullOrEmpty(queryTextField.Text))
     {
         AlertHelper.ShowLocalizedAlertWithOkOption("Error", "Please type query");
     }
     else
     {
         this.HideKeyboard(this.queryTextField);
         this.SendRequest();
     }
 }
        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(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();
            }
        }
示例#12
0
 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();
     }
 }
示例#13
0
        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 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()) {
                    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 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();
                });
            }
        }
示例#17
0
        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();
                });
            }
        }
示例#18
0
        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 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();
                });
            }
        }
示例#20
0
        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();
                });
            }
        }
示例#21
0
        private async void SendEntityByIdRequest()
        {
            //get entity by id

            try {
                using (ISitecoreSSCSession session = this.instanceSettings.GetSession()) {
                    var request = EntitySSCRequestBuilder.ReadEntityRequestById(this.EntityIdTextField.Text)
                                  .Namespace("aggregate")
                                  .Controller("admin")
                                  .Action("Todo")
                                  .Build();

                    this.ShowLoader();

                    ScEntityResponse response = await session.ReadEntityAsync(request);

                    if (response.Any())
                    {
                        AlertHelper.ShowLocalizedAlertWithOkOption("Entity Title", response[0]["Title"].RawValue);
                        foreach (var entity in response)
                        {
                            Console.WriteLine("ENTITY: " + entity.Id);
                        }
                    }
                    else
                    {
                        AlertHelper.ShowLocalizedAlertWithOkOption("Message", "Entities not found");
                    }
                }
            } catch (Exception e) {
                AlertHelper.ShowLocalizedAlertWithOkOption("Error", e.Message);
            } finally {
                BeginInvokeOnMainThread(delegate {
                    this.HideLoader();
                });
            }
        }