This commit is contained in:
75
API/UnNotifyClients/Backup/UnNotifyClients/Program.cs
Normal file
75
API/UnNotifyClients/Backup/UnNotifyClients/Program.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
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!\r\nAre you running this from the AyaNova program folder?\r\nFull error is:\r\n" + 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);
|
||||
Console.WriteLine("Found " + cpl.Count.ToString() + " clients to process.");
|
||||
foreach (ClientPickList.ClientPickListInfo i in cpl)
|
||||
{
|
||||
|
||||
Client c = Client.GetItem(i.ID);
|
||||
c.SendNotifications = false;
|
||||
c.Save();
|
||||
Console.WriteLine(i.Name + " - notification turned off");
|
||||
}
|
||||
|
||||
Console.WriteLine("All done!");
|
||||
|
||||
}//end main
|
||||
|
||||
}//end class
|
||||
|
||||
}//end namespace
|
||||
Reference in New Issue
Block a user