Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/293.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在哪里存储SPItemEventReceivers的全局设置?_C#_Sharepoint - Fatal编程技术网

C# 在哪里存储SPItemEventReceivers的全局设置?

C# 在哪里存储SPItemEventReceivers的全局设置?,c#,sharepoint,C#,Sharepoint,我有一个SPItemEventReceiver,它除了使用POST请求将事件通知位于给定IP和端口的另一个HTTP服务器外,什么都不做 HTTP服务器与sharepoint运行在同一台计算机上,因此我使用localhost和固定端口号发送通知。但是,由于可以在服务器场中的其他服务器中调用eventreceiver,因此localhost:端口将不可用 因此,每次我的HTTP服务器启动时,它都需要将其IP地址和端口保存在SharePoint中的某个位置,所有EventReceiver都可以访问该位

我有一个SPItemEventReceiver,它除了使用POST请求将事件通知位于给定IP和端口的另一个HTTP服务器外,什么都不做

HTTP服务器与sharepoint运行在同一台计算机上,因此我使用localhost和固定端口号发送通知。但是,由于可以在服务器场中的其他服务器中调用eventreceiver,因此localhost:端口将不可用

因此,每次我的HTTP服务器启动时,它都需要将其IP地址和端口保存在SharePoint中的某个位置,所有EventReceiver都可以访问该位置,无论调用它们的服务器是什么

什么是存储这些全球可用信息的好地方


我考虑过
SPWebService.ContentService.Properties
,但我不确定这是否是个好主意。你觉得怎么样?

嗯,如果你使用SharePoint 2010,我会考虑将这些值存储在属性包中。使用客户端对象模型,甚至Javascript/ECMAScript客户端对象模型。这些代码可能对你有帮助

using (var context = new ClientContext("http://localhost"))
{
  var allProperties = context.Web.AllProperties;
  allProperties["testing"] = "Hello there";
  context.Web.Update();
  context.ExecuteQuery();
}
或使用javascript:

    function getWebProperty() {
        var ctx = new SP.ClientContext.get_current();
        var web = ctx.get_site().get_rootweb();
        this.props =  web.get_allProperties();
        this.props.set_item(“aProperty”, “aValue”);
        ctx.load(web);

        ctx.executeQueryAsync(Function.createDelegate(this, gotProperty), Function.createDelegate(this, failedGettingProperty));
    }

    function gotProperty() {
        alert(this.props.get_item(“aProperty”));
    }

    function failedGettingProperty() {
        alert("failed");
    }
资料来源:


< P> >如果你使用SharePoint 2010,我会考虑将这些值存储在属性包中。使用客户端对象模型,甚至Javascript/ECMAScript客户端对象模型。这些代码可能对你有帮助

using (var context = new ClientContext("http://localhost"))
{
  var allProperties = context.Web.AllProperties;
  allProperties["testing"] = "Hello there";
  context.Web.Update();
  context.ExecuteQuery();
}
或使用javascript:

    function getWebProperty() {
        var ctx = new SP.ClientContext.get_current();
        var web = ctx.get_site().get_rootweb();
        this.props =  web.get_allProperties();
        this.props.set_item(“aProperty”, “aValue”);
        ctx.load(web);

        ctx.executeQueryAsync(Function.createDelegate(this, gotProperty), Function.createDelegate(this, failedGettingProperty));
    }

    function gotProperty() {
        alert(this.props.get_item(“aProperty”));
    }

    function failedGettingProperty() {
        alert("failed");
    }
资料来源:


在SharePoint中保存配置值实际上有几种方法:

  • SharePoint对象的属性包
    SPWebApplication、SPFarm、
    SPSite、SPWeb、SPList、splistem`
  • SharePoint中的“配置”列表-只是一个常规列表,您可以将其设置为
    Hidden=TRUE
  • web.config文件-特别是

    当您谈到一个外部进程试图将其设置保存到某个地方时,通常我会推荐web.config,但是web.config中的每一个更改都会导致一个
    IISRESET
    ,这不是一个好的选项。我强烈建议您使用属性包(例如
    SPWebApplication.Properties
    bag)或您喜爱的网站中的隐藏列表。您可以这样设置属性包:

    SPWebApplication webApplication = ...
    object customObject = ...
    // set value in hashtable
    webApp.Add("MySetting", customObject);
    // persist the hashtable
    webApp.Update();
    

    看看这有什么酷的?实际上,您可以在web应用程序中存储一个对象,该应用程序可以包含多个设置,只要您保持对象可序列化。

    在SharePoint中保存配置值实际上有几种方法:

    • SharePoint对象的属性包
      SPWebApplication、SPFarm、
      SPSite、SPWeb、SPList、splistem`
    • SharePoint中的“配置”列表-只是一个常规列表,您可以将其设置为
      Hidden=TRUE
    • web.config文件-特别是

      当您谈到一个外部进程试图将其设置保存到某个地方时,通常我会推荐web.config,但是web.config中的每一个更改都会导致一个
      IISRESET
      ,这不是一个好的选项。我强烈建议您使用属性包(例如
      SPWebApplication.Properties
      bag)或您喜爱的网站中的隐藏列表。您可以这样设置属性包:

      SPWebApplication webApplication = ...
      object customObject = ...
      // set value in hashtable
      webApp.Add("MySetting", customObject);
      // persist the hashtable
      webApp.Update();
      

      看看这有什么酷的?您可以使用web应用程序存储一个对象,该应用程序可以包含多个设置,只要您保持对象可序列化。

      因此,我必须将信息存储在服务器场中的每个SPWeb、每个SPSite和每个SPWebApplication上。属性包可用于多个级别,例如SPWeb、SPSite,甚至SPFarm级别。虽然我从未在SPFarm中使用过,但我正在尝试寻找一些好的参考资料。这些参考资料可能会有所帮助:我会尝试编写一些代码示例,但我现在无法访问sharepoint环境。有时,我希望我能接受多个答案,而不仅仅是我最终使用的众多正确答案中的一个…@moontear答案非常好且完整,这实际上是我在论坛上的第一个答案。还在学习!!因此,我必须在服务器场中的每个SPWeb、每个SPSite和每个SPWebApplication上存储信息?属性包可以在多个级别上使用,例如SPWeb、SPSite甚至SPFarm级别。虽然我从未在SPFarm中使用过,但我正在尝试寻找一些好的参考资料。这些参考资料可能会有所帮助:我会尝试编写一些代码示例,但我现在无法访问sharepoint环境。有时,我希望我能接受多个答案,而不仅仅是我最终使用的众多正确答案中的一个…@moontear答案非常好且完整,这实际上是我在论坛上的第一个答案。还在学习!!