本文整理汇总了C#中SPRemoteEventProperties类的典型用法代码示例。如果您正苦于以下问题:C# SPRemoteEventProperties类的具体用法?C# SPRemoteEventProperties怎么用?C# SPRemoteEventProperties使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SPRemoteEventProperties类属于命名空间,在下文中一共展示了SPRemoteEventProperties类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessEvent
/// <summary>
/// Handles events that occur before an action occurs, such as when a user adds or deletes a list item.
/// </summary>
/// <param name="properties">Holds information about the remote event.</param>
/// <returns>Holds information returned from the remote event.</returns>
public SPRemoteEventResult ProcessEvent(SPRemoteEventProperties properties)
{
SPRemoteEventResult result = new SPRemoteEventResult();
switch (properties.EventType)
{
case SPRemoteEventType.ItemUpdating:
result.ErrorMessage = "You cannot add this list item";
result.Status = SPRemoteEventServiceStatus.CancelNoError;
break;
case SPRemoteEventType.ItemAdding:
result.ErrorMessage = "You cannot add this list item";
result.Status = SPRemoteEventServiceStatus.CancelNoError;
break;
}
using (ClientContext clientContext = TokenHelper.CreateRemoteEventReceiverClientContext(properties))
{
if (clientContext != null)
{
clientContext.Load(clientContext.Web);
clientContext.ExecuteQuery();
}
}
return result;
}
示例2: ProcessEvent
/// <summary>
/// Handles app events that occur after the app is installed or upgraded, or when app is being uninstalled.
/// </summary>
/// <param name="properties">Holds information about the app event.</param>
/// <returns>Holds information returned from the app event.</returns>
public SPRemoteEventResult ProcessEvent(SPRemoteEventProperties properties)
{
SPRemoteEventResult result = new SPRemoteEventResult();
try
{
switch (properties.EventType)
{
case SPRemoteEventType.ItemAdded:
HandleAutoTaggingItemAdded(properties);
break;
case SPRemoteEventType.AppInstalled:
AppInstalled(properties);
break;
case SPRemoteEventType.AppUninstalling:
AppUninstalling(properties);
break;
}
}
catch (Exception ex)
{
LogHelper.Log(ex.Message + ex.StackTrace, LogSeverity.Error);
}
return result;
}
示例3: HandleItemUpdated
private void HandleItemUpdated(SPRemoteEventProperties properties)
{
using (ClientContext clientContext = TokenHelper.CreateRemoteEventReceiverClientContext(properties))
{
if(clientContext != null)
{
List requestList = clientContext.Web.Lists.GetById(properties.ItemEventProperties.ListId);
ListItem item = requestList.GetItemById(properties.ItemEventProperties.ListItemId);
clientContext.Load(item);
clientContext.ExecuteQuery();
if (String.Compare(item[SiteRequestFields.State].ToString(), "Approved", true) == 0)
{
try
{
string site_title = item[SiteRequestFields.Title].ToString();
string site_description = item[SiteRequestFields.Description].ToString();
string site_template = item[SiteRequestFields.Template].ToString();
string site_url = item[SiteRequestFields.Url].ToString();
SharePointUser site_owner = LabHelper.BaseSetUser(clientContext, item, SiteRequestFields.Owner);
LabHelper.CreateSiteCollection(clientContext, site_url, site_template, site_title, site_description, site_owner.Email);
item[SiteRequestFields.State] = "COMPLETED";
}
catch(Exception ex)
{
item[SiteRequestFields.State] = "ERROR";
item[SiteRequestFields.StatusMessage] = ex.Message;
}
item.Update();
clientContext.ExecuteQuery();
}
}
}
}
示例4: ProcessEvent
/// <summary>
/// Handles app events that occur after the app is installed or upgraded, or when app is being uninstalled.
/// </summary>
/// <param name="properties">Holds information about the app event.</param>
/// <returns>Holds information returned from the app event.</returns>
public SPRemoteEventResult ProcessEvent(SPRemoteEventProperties properties)
{
SPRemoteEventResult result = new SPRemoteEventResult();
using (ClientContext clientContext = TokenHelper.CreateAppEventClientContext(properties, false))
{
if (clientContext != null)
{
string listTitle = "External Events";
string remoteEventReceiverSvcTitle = "ConnectORGRER";
string remoteEventReceiverName = "ConnectORGRemoteEvent";
clientContext.Load(clientContext.Web);
List myList = clientContext.Web.Lists.GetByTitle(listTitle);
clientContext.Load(myList);
clientContext.ExecuteQuery();
if (properties.EventType == SPRemoteEventType.AppInstalled)
{
string opContext = OperationContext.Current.Channel.LocalAddress.Uri.AbsoluteUri.Substring(0, OperationContext.Current.Channel.LocalAddress.Uri.AbsoluteUri.LastIndexOf("/"));
string remoteEventReceiverSvcUrl = string.Format("{0}/{1}.svc", opContext, remoteEventReceiverSvcTitle);
RegisterEventReceiver(clientContext, myList, remoteEventReceiverName, remoteEventReceiverSvcUrl, EventReceiverType.ItemUpdated, 15010);
}
else if (properties.EventType == SPRemoteEventType.AppUninstalling)
{
UnregisterAllEventReceivers(clientContext, myList, remoteEventReceiverName);
}
}
}
return result;
}
示例5: ProcessEvent
/// <summary>
/// Handles app events that occur after the app is installed or upgraded, or when app is being uninstalled.
/// </summary>
/// <param name="properties">Holds information about the app event.</param>
/// <returns>Holds information returned from the app event.</returns>
public SPRemoteEventResult ProcessEvent(SPRemoteEventProperties properties)
{
SPRemoteEventResult _result = new SPRemoteEventResult();
try
{
switch (properties.EventType)
{
case SPRemoteEventType.AppInstalled:
HandleAppInstalled(properties);
break;
case SPRemoteEventType.AppUninstalling:
HandleAppUninstalling(properties);
break;
case SPRemoteEventType.ItemAdding:
new RemoteEventReceiverManager().ItemAddingToListEventHandler(properties, _result);
break;
case SPRemoteEventType.ItemUpdated:
HandleItemUpdated(properties);
break;
}
_result.Status = SPRemoteEventServiceStatus.Continue;
}
catch (Exception ex)
{
//You should log here.
}
return _result;
}
示例6: ProcessEvent
/// <summary>
/// Handles app events that occur after the app is installed or upgraded, or when app is being uninstalled.
/// </summary>
/// <param name="properties">Holds information about the app event.</param>
/// <returns>Holds information returned from the app event.</returns>
public SPRemoteEventResult ProcessEvent(SPRemoteEventProperties properties)
{
SPRemoteEventResult result = new SPRemoteEventResult();
using (ClientContext clientContext = TokenHelper.CreateAppEventClientContext(properties, useAppWeb: false))
{
if (clientContext != null)
{
clientContext.Load(clientContext.Site);
clientContext.ExecuteQuery();
if (properties.EventType == SPRemoteEventType.AppInstalled)
{
AddJsLink(clientContext, clientContext.Site, BuildScript(), "PTCTopMenu", true );
}
else if (properties.EventType == SPRemoteEventType.AppUninstalling)
{
DeleteJsLink(clientContext, clientContext.Site, "PTCTopMenu");
}
}
}
result.Status = SPRemoteEventServiceStatus.Continue;
return result;
}
示例7: ProcessEvent
/// <summary>
/// Handles app events that occur after the app is installed or upgraded, or when app is being uninstalled.
/// </summary>
/// <param name="properties">Holds information about the app event.</param>
/// <returns>Holds information returned from the app event.</returns>
public SPRemoteEventResult ProcessEvent(SPRemoteEventProperties properties)
{
SPRemoteEventResult result = new SPRemoteEventResult();
using (ClientContext clientContext = TokenHelper.CreateAppEventClientContext(properties, useAppWeb: false))
{
if (clientContext != null)
{
clientContext.Load(clientContext.Web);
clientContext.ExecuteQuery();
switch (properties.EventType)
{
case SPRemoteEventType.AppInstalled:
RemoveQuickLaunchNode(clientContext);
AddSiteInformationJsLink(clientContext);
result.Status = SPRemoteEventServiceStatus.Continue;
break;
case SPRemoteEventType.AppUninstalling:
RemoveQuickLaunchNode(clientContext);
Web web = clientContext.Web;
clientContext.Load(web, w => w.UserCustomActions, w => w.Url, w => w.AppInstanceId);
clientContext.ExecuteQuery();
DeleteExistingActions(clientContext, web);
break;
}
}
}
return result;
}
示例8: RERIsEnabled
protected Boolean RERIsEnabled(SPRemoteEventProperties properties, ClientContext clientContext)
{
//check and execute if RER is enabled on list
string DbxlRerEnabledProperty = properties.ItemEventProperties.ListId + Constants.KEY_DBXL_PROPERTY_RER_ENABLED;
Boolean RerEnabled = Convert.ToBoolean(WebUtils.GetAppProperty(DbxlRerEnabledProperty, clientContext));
return RerEnabled;
}
示例9: AppPartPropertyUIOverrider
/// <summary>
/// Initializes a new instance of the <see cref="AppPartPropertyUIOverrider" /> class.
/// </summary>
/// <param name="hostWebManager">The host web manager.</param>
/// <param name="properties">The properties of the app event receiver event.</param>
/// <param name="jQueryFileName">Filename of jquery-x.x.x.min.js sitting in the ASP.NET (Remote Web) Scripts directory. Example: "jquery-2.1.0.min.js"</param>
/// <param name="remoteWebFullUrlOverride">Optional override to the remote web full url detection logic. Example: "https://acutalurl.contoso.com"</param>
public AppPartPropertyUIOverrider(HostWebManager hostWebManager, SPRemoteEventProperties properties, string jQueryFileName, string remoteWebFullUrlOverride)
{
this.hostWebManagerField = hostWebManager;
this.propertiesField = properties;
this.jQueryFileNameField = jQueryFileName;
this.remoteWebFullUrlOverrideField = remoteWebFullUrlOverride;
}
示例10: ProcessEvent
/// <summary>
/// Handles events that occur before an action occurs, such as when a user adds or deletes a list item.
/// </summary>
/// <param name="properties">Holds information about the remote event.</param>
/// <returns>Holds information returned from the remote event.</returns>
public SPRemoteEventResult ProcessEvent(SPRemoteEventProperties properties)
{
Trace.WriteLine("Processing remote event. " + properties.EventType);
var result = new SPRemoteEventResult();
try
{
using (ClientContext clientContext = TokenHelper.CreateAppEventClientContext(properties, false))
{
if (clientContext != null)
{
if (properties.EventType == SPRemoteEventType.AppInstalled)
{
Trace.WriteLine("Creating sharepoints objects.");
EnsureObjectsCreated(clientContext);
Trace.WriteLine("Sharepoints objects created.");
}
if (properties.EventType == SPRemoteEventType.AppUninstalling)
{
Trace.WriteLine("Removing sharepoint objects.");
RemoveObjects(clientContext);
Trace.WriteLine("Sharepoint objects removed.");
}
}
}
}
catch (Exception e)
{
Trace.WriteLine("An error occured during processing remote event: " + e);
result.ErrorMessage = e.ToString();
}
return result;
}
示例11: ProcessEvent
/// <summary>
/// Handles app events that occur after the app is installed or upgraded, or when app is being uninstalled.
/// </summary>
/// <param name="properties">Holds information about the app event.</param>
/// <returns>Holds information returned from the app event.</returns>
public SPRemoteEventResult ProcessEvent(SPRemoteEventProperties properties)
{
SPRemoteEventResult result = new SPRemoteEventResult();
switch (properties.EventType)
{
case SPRemoteEventType.WebProvisioned:
WebProvisionedMethod(properties);
break;
case SPRemoteEventType.AppInstalled:
AppInstalledMethod(properties);
break;
case SPRemoteEventType.AppUpgraded:
// not implemented
break;
case SPRemoteEventType.AppUninstalling:
AppUnistallingMethod(properties);
break;
case SPRemoteEventType.WebAdding:
// you can implement webaddding event
break;
case SPRemoteEventType.WebDeleting:
//you can implemet web deleting event if needed.
default:
break;
}
return result;
}
示例12: CreateList
private Guid CreateList(String listTitle, SPRemoteEventProperties properties)
{
Guid listID = Guid.Empty;
using (ClientContext clientContext = TokenHelper.CreateAppEventClientContext(properties, useAppWeb: false))
{
if (clientContext != null)
{
// SharePoint might be retrying the event after a time-out. It
// may have created the list on the last try of this handler, so
// check to see if there's already a list with that name.
List targetList = GetListByTitle(listTitle, clientContext);
// If there isn't one, create it.
if (targetList == null)
{
ListCreationInformation listInfo = new ListCreationInformation();
listInfo.Title = listTitle;
listInfo.TemplateType = (int)ListTemplateType.GenericList;
listInfo.Url = listTitle;
targetList = clientContext.Web.Lists.Add(listInfo);
clientContext.Load(targetList, l => l.Id);
clientContext.ExecuteQuery();
listID = targetList.Id;
}
}
}
return listID;
}
示例13: ProcessEvent
public SPRemoteEventResult ProcessEvent(SPRemoteEventProperties properties)
{
TraceHelper.RemoteLog("app event triggered: " + properties.EventType.ToString());
SPRemoteEventResult result = new SPRemoteEventResult();
using (ClientContext clientContext = TokenHelper.CreateAppEventClientContext(properties, false))
{
if (clientContext != null)
{
clientContext.Load(clientContext.Web);
clientContext.Load(clientContext.Web.SiteUsers);
clientContext.ExecuteQuery();
RegisterEventReceivers(clientContext);
PlaybasisHelper.Instance.Auth();
foreach (var user in clientContext.Web.SiteUsers)
{
if (string.IsNullOrWhiteSpace(user.Email))
continue;
PlaybasisHelper.Instance.Register(user, true);
}
}
}
return result;
}
示例14: ProcessEvent
public SPRemoteEventResult ProcessEvent(SPRemoteEventProperties properties) {
// create SPRemoteEventResult object to use as return value
SPRemoteEventResult result = new SPRemoteEventResult();
// inspect the event type of the current event
if ((properties.EventType == SPRemoteEventType.ItemAdding) ||
(properties.EventType == SPRemoteEventType.ItemUpdating)) {
// get user input to perform validation
string title = properties.ItemEventProperties.AfterProperties["Title"].ToString();
string body = properties.ItemEventProperties.AfterProperties["Body"].ToString();
// perform simple validation on user input
if (title.ToLower().Contains("lobster") || title.ToLower().Contains("clam") ) {
// cancel action due to validation error
result.Status = SPRemoteEventServiceStatus.CancelWithError;
result.ErrorMessage = "Title cannot contain inflammatory terms such as 'lobster' or 'clam'";
}
// Process user input before it's added to the content database
if (!title.ToUpper().Equals(title)) {
result.ChangedItemProperties.Add("Title", title.ToUpper());
}
}
return result; // always return SPRemoteEventResult back to SharePoint host
}
示例15: TryUpdateInventory
private bool TryUpdateInventory(SPRemoteEventProperties properties)
{
bool successFlag = false;
try
{
var arrived = Convert.ToBoolean(properties.ItemEventProperties.AfterProperties["Arrived"]);
var addedToInventory = Convert.ToBoolean(properties.ItemEventProperties.AfterProperties["Added_x0020_to_x0020_Inventory"]);
if (arrived && !addedToInventory)
{
using (SqlConnection conn = SQLAzureUtilities.GetActiveSqlConnection())
using (SqlCommand cmd = conn.CreateCommand())
{
conn.Open();
cmd.CommandText = "UpdateInventory";
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter tenant = cmd.Parameters.Add("@Tenant", SqlDbType.NVarChar);
tenant.Value = properties.ItemEventProperties.WebUrl + "/";
SqlParameter product = cmd.Parameters.Add("@ItemName", SqlDbType.NVarChar, 50);
product.Value = properties.ItemEventProperties.AfterProperties["Title"]; // not "Product"
SqlParameter quantity = cmd.Parameters.Add("@Quantity", SqlDbType.SmallInt);
quantity.Value = Convert.ToUInt16(properties.ItemEventProperties.AfterProperties["Quantity"]);
cmd.ExecuteNonQuery();
}
successFlag = true;
}
}
catch (KeyNotFoundException)
{
successFlag = false;
}
return successFlag;
}
开发者ID:OfficeDev,项目名称:SharePoint_Provider-hosted_Add-ins_Tutorials,代码行数:35,代码来源:RemoteEventReceiver1.svc.cs