Notification samples
Basics
Suggested code sample
First, you must create the web service object:
OKMWebservices ws = OKMWebservicesFactory.newInstance(host);
Then, you should log in using the method "login". You can access the "login" method from the web service object "ws" as shown below:
ws.login(user, password);
Once you are logged in with the web service, the session is kept in the web service object. Then you can use the other API methods.
At this point you can use all the Notification methods from the "notification" class as shown below:
ws.notification.notify(uuids, users, roles, mails, message, false);
Methods
notify
Description:
| Method | Return values | Description |
|---|---|---|
|
notify(List<String> uuids, List<String> users, List<String> roles, List<String> mails, String message, bool attachment) |
void |
Sends a mail notification. |
|
The parameter uuids contains the UUIDs of the nodes (document, folder, mail, or record). The parameter users contains a set of OpenKM users to be notified. The parameter roles contains a set of OpenKM roles to be notified. The parameter mails contains a set of email addresses - usually external email addresses - to be notified. The parameter message is the body of the email. When the attachment value is true, the node is attached to the email. |
||
Example:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;
namespace OKMRest
{
public class Program
{
static void Main(string[] args)
{
String host = "http://localhost:8180/openkm";
String username = "okmAdmin";
String password = "admin";
OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try
{
ws.login(user, password);
List<String> uuids = new List<string>();
uuids.Add(doc.uuid);
List<String> users = new List<string>();
users.Add("jperez");
List<String> roles = new List<string>();
roles.Add("ROLE_USER");
List<String> mails = new List<string>();
mails.Add("test@none.com");
String message = "Any message"
ws.notification.notify(uuids, users, roles, mails, message, false);
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}