AyaNova service management & work order software
AyaNova Support Forum
Home       Members    Calendar    Who's On
Welcome Guest ( Login | Register )
        



UnNotifyClients api example Expand / Collapse
Author
Message
Posted 1/22/2010 4:24:30 PM
AyaNova Development & Support

AyaNova Development & SupportAyaNova Development & SupportAyaNova Development & SupportAyaNova Development & SupportAyaNova Development & SupportAyaNova Development & SupportAyaNova Development & SupportAyaNova Development & Support

Group: Administrators
Last Login: 2/11/2010 12:27:00 PM
Posts: 140, Visits: 493
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/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
{
///
/// 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.
///

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
Post #4987
« Prev Topic | Next Topic »


Reading This Topic Expand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: AyaNova Sales & Support, John

Permissions Expand / Collapse

All times are GMT -8:00, Time now is 5:01am

Powered by InstantForum.NET v4.1.4 © 2010
Execution: 0.047. 9 queries. Compression Disabled.