Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace WAZVerwaltung.Console
- {
- using Microsoft.SharePoint.Client;
- using SharePointManipulator.Library.Services;
- using System.Security;
- public class Startup
- {
- public static void Main()
- {
- string siteUrl = "https://onevirtualoffice.sharepoint.com/sites/ct_dev_ln/APP0008";
- string userName = @"jordan.georgiev@external.atlascopco.com";
- SecureString password = "Atlas2017".ConvertToSecureString();
- using (ClientContext context = new ClientContext(siteUrl))
- {
- context.Credentials = new SharePointOnlineCredentials(userName, password);
- RegisterRibbonCustomActionsToChargensuchenListView(context);
- //RegisterRibbonCustomActionsToChargensuchenListDocumentSet(context);
- RegisterRibbonCustomActionsToIdentnummernListView(context);
- //RegisterRibbonCustomActionsToIdentnummernListDocumentSet(context);
- }
- }
- private static void RegisterRibbonCustomActionsToChargensuchenListView(ClientContext clientContext)
- {
- string scriptSrc = "~Site/SiteAssets/Scripts/RibbonCustomActionsScript.js";
- string customActionName = "WAZVerwaltung.Chargensuchen.CreateNewItem";
- string scriptLinkName = "WAZVerwaltung.Chargensuchen.NewItem";
- string listTitle = "Chargensuchen";
- string customActionLocation = "CommandUI.Ribbon";
- string commandUIExtension = string.Concat(
- "<CommandUIExtension>",
- "<CommandUIDefinitions>",
- "<CommandUIDefinition Location=\"Ribbon.Documents.Manage.Controls._children\">",
- "<Button ",
- "Id=\"WAZVerwaltung.Chargensuchen.Ribbon.IdentnummerVergeben\" ",
- "Alt=\"Identnummer vergeben\" ",
- "Sequence=\"40\" Image32by32=\"~site/SiteAssets/create-new-item.png\" ",
- "Command=\"WAZVerwaltung_Chargensuchen_CreateNewItemIdentnummerVergeben\" ",
- "LabelText=\"Identnummer vergeben\" ",
- "TemplateAlias=\"o1\"/>",
- "</CommandUIDefinition>",
- "<CommandUIDefinition Location=\"Ribbon.Documents.Manage.Controls._children\">",
- "<Button ",
- "Id=\"WAZVerwaltung.Chargensuchen.Ribbon.Umstempelung\" ",
- "Alt=\"Umstempelung\" ",
- "Sequence=\"40\" Image32by32=\"~site/SiteAssets/create-new-item.png\" ",
- "Command=\"WAZVerwaltung_Chargensuchen_CreateNewItemUmstempelung\" ",
- "LabelText=\"Umstempelung\" ",
- "TemplateAlias=\"o1\"/>",
- "</CommandUIDefinition>",
- "</CommandUIDefinitions>",
- "<CommandUIHandlers>",
- "<CommandUIHandler ",
- "Command=\"WAZVerwaltung_Chargensuchen_CreateNewItemIdentnummerVergeben\" ",
- "CommandAction=\"javascript: wazVerwaltung.Chargensuche.IdentnummerVergeben('{SelectedItemId}', '{SelectedListId}', '{SiteUrl}');\" ",
- "EnabledScript=\"javascript: SP.ListOperation.Selection.getSelectedItems().length == 1;\" />",
- "<CommandUIHandler ",
- "Command=\"WAZVerwaltung_Chargensuchen_CreateNewItemUmstempelung\" ",
- "CommandAction=\"javascript: wazVerwaltung.Umstempelung('{SelectedItemId}', '{SelectedListId}', '{SiteUrl}');\" ",
- "EnabledScript=\"javascript: SP.ListOperation.Selection.getSelectedItems().length == 1;\" />",
- "</CommandUIHandlers>",
- "</CommandUIExtension>");
- SPMListsService listService = new SPMListsService(clientContext);
- // Create the Export & Import custom actions
- listService.CreateCustomAction(listTitle, customActionName, customActionLocation, commandUIExtension, 15, PermissionKind.ViewListItems);
- // Attach the SpreadsheetActions.js file to scriptlink custom action
- listService.CreateScriptLink(scriptSrc, scriptLinkName, 21);
- }
- private static void RegisterRibbonCustomActionsToChargensuchenListDocumentSet(ClientContext clientContext)
- {
- string scriptSrc = "~Site/SiteAssets/Scripts/RibbonCustomActionsScript.js";
- string customActionName = "WAZVerwaltung.Chargensuchen.CreateNewItemDocumentSet";
- string scriptLinkName = "WAZVerwaltung.Chargensuchen.NewItemDocumentSet";
- string listTitle = "Chargensuchen";
- string customActionLocation = "CommandUI.Ribbon";
- string commandUIExtension = string.Concat(
- "<CommandUIExtension>",
- "<CommandUIDefinitions>",
- "<CommandUIDefinition Location=\"Ribbon.ManageDocumentSet.MDS.Manage.Controls._children\">",
- "<Button ",
- "Id=\"WAZVerwaltung.Chargensuchen.DocumentSet.Ribbon.IdentnummerVergeben\" ",
- "Alt=\"Identnummer vergeben\" ",
- "Sequence=\"40\" Image32by32=\"~site/SiteAssets/create-new-item.png\" ",
- "Command=\"WAZVerwaltung_Chargensuchen_DocumentSet_CreateNewItemIdentnummerVergeben\" ",
- "LabelText=\"Identnummer vergeben\" ",
- "TemplateAlias=\"o1\"/>",
- "</CommandUIDefinition>",
- "<CommandUIDefinition Location=\"Ribbon.ManageDocumentSet.MDS.Manage.Controls._children\">",
- "<Button ",
- "Id=\"WAZVerwaltung.Chargensuchen.DocumentSet.Ribbon.Umstempelung\" ",
- "Alt=\"Umstempelung\" ",
- "Sequence=\"40\" Image32by32=\"~site/SiteAssets/create-new-item.png\" ",
- "Command=\"WAZVerwaltung_Chargensuchen_DocumentSet_CreateNewItemUmstempelung\" ",
- "LabelText=\"Umstempelung\" ",
- "TemplateAlias=\"o1\"/>",
- "</CommandUIDefinition>",
- "</CommandUIDefinitions>",
- "<CommandUIHandlers>",
- "<CommandUIHandler ",
- "Command=\"WAZVerwaltung_Chargensuchen_DocumentSet_CreateNewItemIdentnummerVergeben\" ",
- "CommandAction=\"javascript: wazVerwaltung.Chargensuche.IdentnummerVergeben('{SelectedItemId}', '{SelectedListId}', '{SiteUrl}');\" />",
- "<CommandUIHandler ",
- "Command=\"WAZVerwaltung_Chargensuchen_DocumentSet_CreateNewItemUmstempelung\" ",
- "CommandAction=\"javascript: wazVerwaltung.Umstempelung('{SelectedItemId}', '{SelectedListId}', '{SiteUrl}');\" />",
- "</CommandUIHandlers>",
- "</CommandUIExtension>");
- SPMListsService listService = new SPMListsService(clientContext);
- // Create the Export & Import custom actions
- listService.CreateCustomAction(listTitle, customActionName, customActionLocation, commandUIExtension, 15, PermissionKind.ViewListItems);
- // Attach the SpreadsheetActions.js file to scriptlink custom action
- listService.CreateScriptLink(scriptSrc, scriptLinkName, 21);
- }
- private static void RegisterRibbonCustomActionsToIdentnummernListView(ClientContext clientContext)
- {
- string scriptSrc = "~Site/SiteAssets/Scripts/RibbonCustomActionsScript.js";
- string customActionName = "WAZVerwaltung.Identnummern.CreateNewItem";
- string scriptLinkName = "WAZVerwaltung.Identnummern.NewItem";
- string listTitle = "Identnummern";
- string customActionLocation = "CommandUI.Ribbon";
- string commandUIExtension = string.Concat(
- "<CommandUIExtension>",
- "<CommandUIDefinitions>",
- "<CommandUIDefinition Location=\"Ribbon.Documents.Manage.Controls._children\">",
- "<Button ",
- "Id=\"WAZVerwaltung.Identnummern.Ribbon.IdentnummerVergeben\" ",
- "Alt=\"Identnummern anlagen\" ",
- "Sequence=\"40\" Image32by32=\"~site/SiteAssets/create-new-item.png\" ",
- "Command=\"WAZVerwaltung_Identnummern_CreateNewItemIdentnummernAnlagen\" ",
- "LabelText=\"Identnummern anlagen\" ",
- "TemplateAlias=\"o1\"/>",
- "</CommandUIDefinition>",
- "<CommandUIDefinition Location=\"Ribbon.Documents.Manage.Controls._children\">",
- "<Button ",
- "Id=\"WAZVerwaltung.Identnummern.Ribbon.Umstempelung\" ",
- "Alt=\"Umstempelung\" ",
- "Sequence=\"40\" Image32by32=\"~site/SiteAssets/create-new-item.png\" ",
- "Command=\"WAZVerwaltung_Identnummern_CreateNewItemUmstempelung\" ",
- "LabelText=\"Umstempelung\" ",
- "TemplateAlias=\"o1\"/>",
- "</CommandUIDefinition>",
- "</CommandUIDefinitions>",
- "<CommandUIHandlers>",
- "<CommandUIHandler ",
- "Command=\"WAZVerwaltung_Identnummern_CreateNewItemIdentnummernAnlagen\" ",
- "CommandAction=\"javascript: wazVerwaltung.Identnummern.IdentnummernAnlagen('{SelectedItemId}', '{SelectedListId}', '{SiteUrl}');\" ",
- "EnabledScript=\"javascript: SP.ListOperation.Selection.getSelectedItems().length == 1;\" />",
- "<CommandUIHandler ",
- "Command=\"WAZVerwaltung_Identnummern_CreateNewItemUmstempelung\" ",
- "CommandAction=\"javascript: wazVerwaltung.Umstempelung('{SelectedItemId}', '{SelectedListId}', '{SiteUrl}');\" ",
- "EnabledScript=\"javascript: SP.ListOperation.Selection.getSelectedItems().length == 1;\" />",
- "</CommandUIHandlers>",
- "</CommandUIExtension>");
- SPMListsService listService = new SPMListsService(clientContext);
- // Create the Export & Import custom actions
- listService.CreateCustomAction(listTitle, customActionName, customActionLocation, commandUIExtension, 15, PermissionKind.ViewListItems);
- // Attach the SpreadsheetActions.js file to scriptlink custom action
- listService.CreateScriptLink(scriptSrc, scriptLinkName, 21);
- }
- private static void RegisterRibbonCustomActionsToIdentnummernListDocumentSet(ClientContext clientContext)
- {
- string scriptSrc = "~Site/SiteAssets/Scripts/RibbonCustomActionsScript.js";
- string customActionName = "WAZVerwaltung.Identnummern.CreateNewItemDocumentSet";
- string scriptLinkName = "WAZVerwaltung.Identnummern.NewItemDocumentSet";
- string listTitle = "Identnummern";
- string customActionLocation = "CommandUI.Ribbon";
- string commandUIExtension = string.Concat(
- "<CommandUIExtension>",
- "<CommandUIDefinitions>",
- "<CommandUIDefinition Location=\"Ribbon.ManageDocumentSet.MDS.Manage.Controls._children\">",
- "<Button ",
- "Id=\"WAZVerwaltung.Identnummern.DocumentSet.Ribbon.IdentnummerVergeben\" ",
- "Alt=\"Identnummern anlagen\" ",
- "Sequence=\"40\" Image32by32=\"~site/SiteAssets/create-new-item.png\" ",
- "Command=\"WAZVerwaltung_Identnummern_DocumentSet_CreateNewItemIdentnummernAnlagen\" ",
- "LabelText=\"Identnummern anlagen\" ",
- "TemplateAlias=\"o1\"/>",
- "</CommandUIDefinition>",
- "<CommandUIDefinition Location=\"Ribbon.ManageDocumentSet.MDS.Manage.Controls._children\">",
- "<Button ",
- "Id=\"WAZVerwaltung.Identnummern.DocumentSet.Ribbon.Umstempelung\" ",
- "Alt=\"Umstempelung\" ",
- "Sequence=\"40\" Image32by32=\"~site/SiteAssets/create-new-item.png\" ",
- "Command=\"WAZVerwaltung_Identnummern_DocumentSet_CreateNewItemUmstempelung\" ",
- "LabelText=\"Umstempelung\" ",
- "TemplateAlias=\"o1\"/>",
- "</CommandUIDefinition>",
- "</CommandUIDefinitions>",
- "<CommandUIHandlers>",
- "<CommandUIHandler ",
- "Command=\"WAZVerwaltung_Identnummern_DocumentSet_CreateNewItemIdentnummernAnlagen\" ",
- "CommandAction=\"javascript: wazVerwaltung.Identnummern.IdentnummernAnlagen('{SelectedItemId}', '{SelectedListId}', '{SiteUrl}');\" />",
- "<CommandUIHandler ",
- "Command=\"WAZVerwaltung_Identnummern_DocumentSet_CreateNewItemUmstempelung\" ",
- "CommandAction=\"javascript: wazVerwaltung.Umstempelung('{SelectedItemId}', '{SelectedListId}', '{SiteUrl}');\" ",
- "EnabledScript=\"javascript: SP.ListOperation.Selection.getSelectedItems().length == 0;\" />",
- "</CommandUIHandlers>",
- "</CommandUIExtension>");
- SPMListsService listService = new SPMListsService(clientContext);
- // Create the Export & Import custom actions
- listService.CreateCustomAction(listTitle, customActionName, customActionLocation, commandUIExtension, 15, PermissionKind.ViewListItems);
- // Attach the SpreadsheetActions.js file to scriptlink custom action
- listService.CreateScriptLink(scriptSrc, scriptLinkName, 21);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement