Presentation is loading. Please wait.

Presentation is loading. Please wait.

SharePoint-hosted app

Similar presentations


Presentation on theme: "SharePoint-hosted app"— Presentation transcript:

1 SharePoint-hosted app
Alexander Krupsky Artur Kukharevich

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

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

4 Установка прав на элемент списка
Проблемы. Права Установка прав на элемент списка Workflow не поддерживает (не актуально) Нет Event Receiver Переопределение момента сохранения через JS не возможно при наличии прикрепленных файлов

5 Проблемы. Права Фиг с ним с элементом. Как установить изначальные права на сайте 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.

6 Проблемы. Календарь Я хочу чтобы у меня отпуск был каждый месяц по два дня, выпадающих на первую неделю в течении двух лет. Если список находится не на сайте app, то сочувствую, т к SharePoint API позволяет сделать повторяющиеся события: Серверный код Запрос к сервису с установкой Date Overlap

7 Проблемы. Client Web Parts
Ограничения: Встраивается на страницу при помощи iFrame Фиксированный размер

8 Проблемы. Client Web Parts
Изменения размера iframe var 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 задана автоматическая ширина и(или) высота.

9 Проблемы. Workflow Скрытые активности Как локализовать workflow?

10 Возможно, но используйте с умом, а лучше вообще не используйте)
Шаблоны сайтов Возможно, но используйте с умом, а лучше вообще не используйте) Что говорит по этому поводу 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.

11 Using REST (работает через AppWebProxy.aspx):
Cross-domain calls Using REST (работает через AppWebProxy.aspx): $.getScript(scriptbase + "SP.RequestExecutor.js", execCrossDomainRequest); function execCrossDomainRequest() { var executor; executor = new SP.RequestExecutor(appweburl); executor.executeAsync( { url: appweburl + + hostweburl + "'", method: "GET", headers: { "Accept": "application/json; odata=verbose" }, success: successHandler, error: errorHandler } );

12 Cross-domain calls. Architecture

13 Using REST (не использует AppWebProxy.aspx):
Cross-domain calls 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=" SchemaVersion=" " LibraryVersion=" " ApplicationName="Javascript Library"> <Actions> <ObjectPath Id="69" ObjectPathId="68" /> </Actions> <ObjectPaths> <Constructor Id="68" TypeId="{5530f782-6a0d-41ec-bfd9-2cb628fe1557}"> <Parameters> <Parameter Type="String"> </Parameters> </Constructor> </ObjectPaths> </Request>

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

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

16 $Resources:Resource_key;
Localization. В контексте Hosted-Web Может применяться для локализации App Client Web Part, Ribbon Actions. Используем: $Resources:Resource_key; Получаем:

17 Localization. В контексте Hosted-Web
Вот так Microsoft описывает проблему: To add OPC relationship markup to the app package Append a .zip extension to the app package. In the .zip file, open the folder named _rels. 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=" Target="/Resources.resx" Id="R8d5c4429fc13446e" /> Type=" Target="/Resources.en-US.resx" Id="R71986f3a45e24d8f" /> 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. Close the AppManifest.xml.rels file. 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. 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. Save (as UTF-8) and close the file. 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.

18 Localization. В контексте Hosted-Web
Скачать с Msdn утилиту AddRelsToAppPackage ( СПОСОБ РАБОТАЕТ ТОЛЬКО ПРИ Deploy!!!!!

19 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)' != ''" />

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

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


Download ppt "SharePoint-hosted app"

Similar presentations


Ads by Google