Notifications.UpdateReminderSubscriptions 方法

设置为当前用户的提醒订阅。

命名空间:  WebSvcNotifications
程序集:  ProjectServerServices(位于 ProjectServerServices.dll 中)

语法

声明
<SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/Notifications/UpdateReminderSubscriptions", RequestNamespace := "https://schemas.microsoft.com/office/project/server/webservices/Notifications/",  _
    ResponseNamespace := "https://schemas.microsoft.com/office/project/server/webservices/Notifications/",  _
    Use := SoapBindingUse.Literal, ParameterStyle := SoapParameterStyle.Wrapped)> _
Public Sub UpdateReminderSubscriptions ( _
    subscriptionDataset As ReminderSubscriptionInfoDataSet _
)
用法
Dim instance As Notifications
Dim subscriptionDataset As ReminderSubscriptionInfoDataSet

instance.UpdateReminderSubscriptions(subscriptionDataset)
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/Notifications/UpdateReminderSubscriptions", RequestNamespace = "https://schemas.microsoft.com/office/project/server/webservices/Notifications/", 
    ResponseNamespace = "https://schemas.microsoft.com/office/project/server/webservices/Notifications/", 
    Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public void UpdateReminderSubscriptions(
    ReminderSubscriptionInfoDataSet subscriptionDataset
)

参数

备注

如果IsSubscribed设置为 true 时,还必须设置FrequencyValueFrequencyPeriod,并RecipientType或您在应用更新时,将收到错误。

Project Server 权限

权限

说明

非标准

用户必须是资源。

ManagePersonalNotifications

允许用户自我管理通知。全局权限。

ManageResourceNotifications

允许用户管理其他资源的通知。全局权限。

示例

此示例检索当前用户的提醒订阅信息切换订阅标志、 设置某些传递信息,将更新发送到服务器,并显示更新的设置。

Please see Project 2013 中基于 ASMX 的代码示例的先决条件 for critical information on running this code sample.

using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Net;
using System.Web.Services.Protocols;
using System.Threading;
using PSLibrary = Microsoft.Office.Project.Server.Library;

namespace Microsoft.SDK.Project.Samples.UpdateReminderSubscriptions
{
   class Program
   {
      [STAThread]
      static void Main()
      {
         try
         {
            #region Setup
            const string PROJECT_SERVER_URI = "https://ServerName/ProjectServerName/";
            const string NOTIFICATIONS_SERVICE_PATH = "_vti_bin/psi/notifications.asmx";
            // Set up the Web service objects
            SvcNotifications.Notifications notificationsSvc = new SvcNotifications.Notifications();
            notificationsSvc.Url = PROJECT_SERVER_URI + NOTIFICATIONS_SERVICE_PATH;
            notificationsSvc.UseDefaultCredentials = true;

            #endregion
            #region Update Reminder Subscriptions
            // Read the original settings
            SvcNotifications.ReminderSubscriptionInfoDataSet reminderSubscriptionDs = notificationsSvc.ReadReminderSubscriptions();
            WriteTablesToConsole(reminderSubscriptionDs.Tables);

            // Update settings
            reminderSubscriptionDs.ReminderSubscriptionInfo[0].IsSubscribed = !reminderSubscriptionDs.ReminderSubscriptionInfo[0].IsSubscribed;
                        if (reminderSubscriptionDs.ReminderSubscriptionInfo[0].IsSubscribed)
            {
               reminderSubscriptionDs.ReminderSubscriptionInfo[0].RecipientType = (int)PSLibrary.Notification.RecipientType.OnlyToTeamMember;
               reminderSubscriptionDs.ReminderSubscriptionInfo[0].FrequencyPeriod = (int)PSLibrary.Notification.ReminderFrequencyType.Week;
               reminderSubscriptionDs.ReminderSubscriptionInfo[0].FrequencyValue = 0; // Magic number meaning every day
            }

            notificationsSvc.UpdateReminderSubscriptions(reminderSubscriptionDs);

            // Read settings back and display
            Console.WriteLine("Updated settings:");
            WriteTablesToConsole(reminderSubscriptionDs.Tables);
            #endregion
         }
         #region Error Handling and Final
         catch (SoapException ex)
         {
            PSLibrary.PSClientError error = new PSLibrary.PSClientError(ex);
            PSLibrary.PSErrorInfo[] errors = error.GetAllErrors();
            string errMess = "==============================\r\nError: \r\n";
            for (int i = 0; i < errors.Length; i++)
            {
               errMess += "\n" + ex.Message.ToString() + "\r\n";
               errMess += "".PadRight(30, '=') + "\r\nPSCLientError Output:\r\n \r\n";
               errMess += errors[i].ErrId.ToString() + "\n";

               for (int j = 0; j < errors[i].ErrorAttributes.Length; j++)
               {
                  errMess += "\r\n\t" + errors[i].ErrorAttributeNames()[j] + ": " + errors[i].ErrorAttributes[j];
               }
               errMess += "\r\n".PadRight(30, '=');
            }
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine(errMess);
         }
         catch (WebException ex)
         {
            string errMess = ex.Message.ToString() +
               "\n\nLog on, or check the Project Server Queuing Service";
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("Error: " + errMess);
         }
         catch (Exception ex)
         {
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("Error: " + ex.Message);
         }
         finally
         {
            Console.ResetColor();
            Console.WriteLine("\r\n\r\nPress any key...");
            Console.ReadKey();
         }
         #endregion
      }
      #region Supporting Classes
      private static void WriteTablesToConsole(System.Data.DataTableCollection theTables)
      {
         Console.ForegroundColor = ConsoleColor.DarkGreen;
         foreach (System.Data.DataTable table in theTables)
         {

            int[] columnWidths = new int[table.Columns.Count];
            int tableWidth = 0;
            string dataString;
            Console.WriteLine("Table: " + table.TableName);

            // Write out the column names and get their spacing
            StringBuilder tableRow = new StringBuilder();
            for (int i = 0; i < table.Columns.Count; i++)
            {
               columnWidths[i] = GetColumnWidth(table.Columns[i]);
               tableRow.Append(table.Columns[i].ColumnName.PadRight(columnWidths[i]));

               tableWidth += columnWidths[i];
            }
            // add a space so it won't wrap
            tableWidth += 1;
            // make the console as wide as the widest table
            Console.BufferWidth = (Console.BufferWidth > tableWidth ? Console.BufferWidth : tableWidth);
            tableRow.Append("\r\n");
            Console.Write(tableRow.ToString());

            // Write out the data
            foreach (DataRow row in table.Rows)
            {
               tableRow = new StringBuilder();
               for (int i = 0; i < table.Columns.Count; i++)
               {
                  dataString = row[i].ToString();
                  // truncate output if it is wider than 
                  // the desired column width
                  if (dataString.Length >= columnWidths[i])
                  {
                     dataString = dataString.Substring(0, columnWidths[i] - 1);
                  }
                  // add the output to the stringbuilder and pad right to fill
                  // up to the column width.
                  tableRow.Append(dataString.PadRight(columnWidths[i]));
               }
               tableRow.Append("\r\n");
               Console.Write(tableRow.ToString());
            }
            Console.Write("\r\n".PadLeft(tableWidth, '-'));
         }
         Console.ResetColor();
      }
      // Helper function for WriteTablesToConsole
      private static int GetColumnWidth(DataColumn column)
      {
         // Note: may not handle byte[]data types well
         const int MAX_COL_WIDTH = 40;
         int dataWidth = 0;

         //return 12 for numbers, 30 for dates, and string width for strings.
         switch (column.DataType.UnderlyingSystemType.ToString())
         {
            case "System.Boolean":
            case "System.Byte":
            case "System.Byte[]":
            case "System.Char":
            case "System.Decimal":
            case "System.Double":
            case "System.Int16":
            case "System.Int32":
            case "System.Int64":
            case "System.SByte":
            case "System.Single":
            case "System.UInt16":
            case "System.UInt32":
            case "System.UInt64":
               dataWidth = 12;
               break;
            case "System.DateTime":
            case "System.TimeSpan":
               dataWidth = 30;
               break;
            case "System.Guid":
               dataWidth = 37;
               break;
            case "System.String":
               // If it has a maxlength, use it
               if (column.MaxLength > 0)
               {
                  dataWidth = column.MaxLength;
               }
               else
               {
                  // Otherwise use the max col width
                  dataWidth = MAX_COL_WIDTH;
               }
               break;
            default:
               dataWidth = column.ColumnName.Length;
               break;
         }
         // truncate if over the max length
         if (dataWidth > MAX_COL_WIDTH)
         {
            dataWidth = MAX_COL_WIDTH;
         }
         // always be at least as wide as the colum name
         return (column.ColumnName.Length > (dataWidth) ? column.ColumnName.Length + 1 : dataWidth);
      }
   }
      #endregion
}

另请参阅

引用

Notifications 类

Notifications 成员

WebSvcNotifications 命名空间