sharepoint-hosted app

Post on 02-Jan-2016

95 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

SharePoint-hosted app. Alexander Krupsky Artur Kukharevich. Содержание. Вариант SharePoint-hosted app Проблемы Шаблоны сайтов Cross-domain calls Localization Выводы. Вариант SharePoint-hosted app. Запрос на отпуск. Необходимо: Реализовать простой процесс - PowerPoint PPT Presentation

TRANSCRIPT

SharePoint-hosted app

Alexander Krupsky

Artur Kukharevich

• Вариант SharePoint-hosted app• Проблемы• Шаблоны сайтов• Cross-domain calls• Localization• Выводы

2

Содержание.

Запрос на отпуск.

Необходимо:1. Реализовать простой процесс2. Вывести данные на временную линию3. Возможность создания заявки должна

быть на любой странице сайта

Вариант SharePoint-hosted app

Установка прав на элемент списка

- Workflow не поддерживает (не актуально)- Нет Event Receiver- Переопределение момента сохранения через JS

не возможно при наличии прикрепленных файлов

Проблемы. Права

Фиг с ним с элементом. Как установить изначальные права на сайте app и установить изначальные настройки?

Что говорит по этому поводу MSDN:In some cases, the app will require certain information or choices to be provided before the app can function. When your app requires information before it can function, you should provide a user experience that guides the user to the settings page to update the configuration.

You should add the settings page URL to the app’s top-right menu if appropriate so that users can find it easily. If your app has a getting started experience or other settings, you can add those also. For more information, see How to: Use the client chrome control in apps for SharePoint.

Проблемы. Права

Я хочу чтобы у меня отпуск был каждый месяц по два дня, выпадающих на первую неделю в течении двух лет.

Если список находится не на сайте app, то сочувствую, т к SharePoint API позволяет сделать повторяющиеся события:1. Серверный код2. Запрос к сервису с установкой Date Overlap

Проблемы. Календарь

Ограничения:• Встраивается на страницу при помощи

iFrame• Фиксированный размер

Проблемы. Client Web Parts

Изменения размера iframevar resizeMessage = '<message senderId={Sender_ID}>resize({Width}, {Height})</message>';resizeMessage = resizeMessage.replace("{Sender_ID}", senderId);resizeMessage = resizeMessage.replace("{Height}", newHeight);resizeMessage = resizeMessage.replace("{Width}", newWidth);window.parent.postMessage(resizeMessage, "*");

Где SenderId – параметр, который берется с query string.Важно!!! Этот метод работает, когда для Client Web Part задана автоматическая ширина и(или) высота.

Проблемы. Client Web Parts

Скрытые активности

Как локализовать workflow?

Проблемы. Workflow

Возможно, но используйте с умом, а лучше вообще не используйте)

Что говорит по этому поводу MSDN:Do not use the WebTemplate element in the app manifest to designate any of the built-in SharePoint site definition configurations as the app web's site type. We do not support using any of the built-in site definition configurations, other than APP#0, for app webs.

Шаблоны сайтов

Using REST (работает через AppWebProxy.aspx):$.getScript(scriptbase + "SP.RequestExecutor.js", execCrossDomainRequest); function execCrossDomainRequest() { var executor;

executor = new SP.RequestExecutor(appweburl);

executor.executeAsync( { url: appweburl + "/_api/SP.AppContextSite(@target)/web/title?@target='" + hostweburl + "'", method: "GET", headers: { "Accept": "application/json; odata=verbose" }, success: successHandler, error: errorHandler } ); }

Cross-domain calls

Cross-domain calls. Architecture

Using REST (не использует AppWebProxy.aspx):var context = new SP.ClientContext(_appweburl);var factory = new SP.ProxyWebRequestExecutorFactory(_appweburl);context.set_webRequestExecutorFactory(factory);var appContextSite = new SP.AppContextSite(context, _hostweburl);

// наш запрос

context.executeQueryAsync();

Пример запроса:<Request xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="Javascript Library"> <Actions> <ObjectPath Id="69" ObjectPathId="68" /> </Actions> <ObjectPaths> <Constructor Id="68" TypeId="{5530f782-6a0d-41ec-bfd9-2cb628fe1557}"> <Parameters> <Parameter Type="String">https://spsitepro.sharepoint.com/sites/apps</Parameter> </Parameters> </Constructor> </ObjectPaths> </Request>

Cross-domain calls

А начинается все безобидно)В настройках AppManifest указываем поддерживаемые языки и Visual Studio автоматически сгенерирует необходимые ресурсные файлы.

Localization. С чего начать

Для локализации модулей(Lists, ContentTypes и т.п.), которые будут доступны только на App Web необходимо использовать стандартную конструкцию:

$Resources:Resource_key;

Localization. В контексте App Web

Может применяться для локализации App Client Web Part, Ribbon Actions.Используем:

$Resources:Resource_key;

Получаем:

Localization. В контексте Hosted-Web

Вот так Microsoft описывает проблему:To add OPC relationship markup to the app package1. Append a .zip extension to the app package.2. In the .zip file, open the folder named _rels.3. Open the AppManifest.xml.rels file. This file specifies the OPC relationships of the AppManifest.xml file to other files in the package. The file contains a

Relationship element for the Resources.resx file and for each of the Resources.LL-CC.resx files. The following are examples:

<Relationship Type="http://schemas.microsoft.com/sharepoint/2012/app/relationships/content-defaultresource" Target="/Resources.resx" Id="R8d5c4429fc13446e" /><Relationship Type="http://schemas.microsoft.com/sharepoint/2012/app/relationships/content-resource" Target="/Resources.en-US.resx" Id="R71986f3a45e24d8f" />

4. Copy these resource-related Relationship elements and save them in a text file outside the package so you can reuse them in a later step.5. Close the AppManifest.xml.rels file.6. In the _rels folder, open the featureGUID.xml.rels file. This file specifies the OPC relationships of the featureGUID.xml file and all its child files, such as

elements.xml files, to other files in the package.7. Paste into the Relationships element all of the Relationship elements that you copied from the AppManifest.xml.rels file. It’s OK to use the same

relationship IDs because you are pasting them into a different parent Relationships element.8. Save (as UTF-8) and close the file.9. Close the .zip file and then remove the ".zip" from the end of the file name. The app package can now be installed on your test SharePoint website.

Localization. В контексте Hosted-Web

Скачать с Msdn утилиту AddRelsToAppPackage(http://msdn.microsoft.com/en-us/library/fp179919.aspx)

СПОСОБ РАБОТАЕТ ТОЛЬКО ПРИ Deploy!!!!!

Localization. В контексте Hosted-Web

Сделаем, что бы работало при deploy и publish. В .csproj файл добавить следующее: <Target Name="ConfigureResourses" AfterTargets="PackageSharePointApp"> <Exec Command="$(SolutionDir)ConfigureRelsToAppPackage.exe $(TargetDir)"

ContinueOnError="false"></Exec> </Target>

после строки: <Import Project="$(VSToolsPath)\SharePointTools\Microsoft.VisualStudio.SharePoint.targets"

Condition="'$(VSToolsPath)' != ''" />

Localization. В контексте Hosted-Web

Localization. UI

А как же быть с alert и ему подобным???

А выводы делайте сами ;)

Выводы

top related