A customer of ours needed an easy way to turn off Client notification for all their clients so we whipped up this little utility and we’re posting it here as an example.
It’s a console application run from the command line that iterates all clients, sets their SendNotifications property to false and saves the updated client.
http://api.ayanova.com/files/ApiExample_UnNotifyClients.exe
The AyaNova API is free, comes with AyaNova already installed (AyaNova uses the same business object library API files) and can be used to perform any operation that can be done by users from within AyaNova itself as well as much more.
See the START HERE pinned topic to get started with the API.
If you just want to view the source code, here it is:
using System;
//The AyaNova business object library:
using GZTW.AyaNova.BLL;
//The security library required for
//processing the login
using CSLA.Security;
//Used for login confirmation
using System.Threading;
namespace UnNotifyClients
{
/// <summary>
/// Turn off notification to all clients
///
/// This is a sample console (command line) application showing how to interact with AyaNova api
/// from the command line.
///
/// This was originally developed for a customer who needed to reset a *lot* of clients to turn off notification.
/// </summary>
class Program
{
static void Main(string[] args)
{
try
{
GZTW.AyaNova.BLL.AyaBizUtils.Initialize();
}
catch (Exception ex)
{
//"crack" the exception to get to the innermost exception
while (ex.InnerException != null)
ex = ex.InnerException;
Console.WriteLine("Error initializing AyaNova connection!\rAre you running this from the AyaNova program folder?\rFull error is:\r" + ex.Message);
return;
}
Console.WriteLine("Enter the login name for the administrator:");
string UserName=Console.ReadLine();
Console.WriteLine("Enter the password for the administrator:");
string PassWord = Console.ReadLine();
AyaBizUtils.Login(UserName, PassWord);
//confirm the user is logged in:
if (Thread.CurrentPrincipal.Identity.IsAuthenticated == false)
{
//Nope, they are not authenticated so
//show an error and bail out
Console.WriteLine("Login failed, check the username and password.");
return;
}
//Connected and logged in and ready to roll
ClientPickList cpl = ClientPickList.GetList(false);//Get a list of all clients regardless of region
Console.WriteLine("Found " + cpl.Count.ToString() + " clients to process.");
foreach (ClientPickList.ClientPickListInfo i in cpl)
{
Client c = Client.GetItem(i.ID);//fetch the actual client for editing
c.SendNotifications = false;
c.Save();//save it
Console.WriteLine(i.Name + " - notification turned off");
}
Console.WriteLine("All done!");
}//end main
}//end class
}//end namespace