Exemple #1
0
        private void UpdateSubscriberList(string strNotifType, string strSubscribers, string sAddRemove)
        {
            try
            {
                if (sAddRemove.ToUpper() == "ADD")
                {
                    m_ipNotifConfig = m_ipDatabase.ConfigurationManager as IJTXNotificationConfiguration;
                    m_ipNotifType   = m_ipNotifConfig.GetNotificationType(strNotifType);

                    sList = strSubscribers.Split(',');
                    for (int i = 0; i < sList.Length; i++)
                    {
                        m_ipNotifType.Subscribe(sList[i]);
                    }
                    m_ipNotifType.Store();
                }
                else
                {
                    for (int i = 0; i < sList.Length; i++)
                    {
                        m_ipNotifType.UnSubscribe(sList[i]);
                    }
                    m_ipNotifType.Store();
                }
            }
            catch (Exception ex)
            {
                throw new Exception("An error occurred updating subscriber list!: " + ex.Message);
            }
        }
        static void Main(string[] args)
        {
            JTXReportNotification prog = new JTXReportNotification();

            if (prog.CheckoutLicense())
            {
                // Arguments list
                // /ReportID:<Report ID to execute>
                // /NotifType:<Notification type to send>
                // example: JTXReportNotification.exe /NotifType:ReportNotification /ReportID:401

                object[] pArgObjects = args as object[];

                // Get some variables ready
                int    iReportID             = 0;
                string sReportID             = "";
                string sNotificationTypeName = "";

                StepUtilities.GetArgument(ref pArgObjects, "ReportID", true, out sReportID);
                if (!int.TryParse(sReportID, out iReportID))
                {
                    Console.WriteLine("Invalid Report ID entered");
                    return;
                }
                StepUtilities.GetArgument(ref pArgObjects, "NotifType", true, out sNotificationTypeName);
                if (sNotificationTypeName == "")
                {
                    Console.WriteLine("A notification type must be entered.");
                }

                IJTXDatabaseManager jtxDBMan  = new JTXDatabaseManagerClass();
                IJTXDatabase        pJTXDB    = jtxDBMan.GetActiveDatabase(false);
                IJTXConfiguration2  jtxConfig = pJTXDB.ConfigurationManager as IJTXConfiguration2;

                string sReportOutput = prog.RunReport(jtxConfig, iReportID);

                // if there's output, send the notification
                if (sReportOutput != "")
                {
                    IJTXNotificationConfiguration pNotificationConfig = (IJTXNotificationConfiguration)jtxConfig;
                    IJTXNotificationType          pNotificationType   = pNotificationConfig.GetNotificationType(sNotificationTypeName);

                    if (pNotificationType == null)
                    {
                        Console.WriteLine("Please enter a valid notification type.");
                        return;
                    }

                    // Update the message
                    string sMessageBefore = pNotificationType.MessageTemplate;
                    pNotificationType.MessageTemplate = sReportOutput;
                    pNotificationType.Store();

                    // Send it!
                    JTXUtilities.SendNotification(sNotificationTypeName, pJTXDB, null, null);

                    // Set the message back.
                    pNotificationType.MessageTemplate = "";
                    pNotificationType.Store();
                }
                else
                {
                    Console.WriteLine("Please enter a valid report ID.");
                }

                prog.CheckinLicense();
            }
        }
        private void UpdateSubscriberList(string strNotifType, string strSubscribers, string sAddRemove)
        {
            try
            {
                if (sAddRemove.ToUpper() == "ADD")
                {
                    m_ipNotifConfig = m_ipDatabase.ConfigurationManager as IJTXNotificationConfiguration;
                    m_ipNotifType = m_ipNotifConfig.GetNotificationType(strNotifType);

                    sList = strSubscribers.Split(',');
                    for (int i = 0; i < sList.Length; i++)
                    {
                        m_ipNotifType.Subscribe(sList[i]);
                    }
                    m_ipNotifType.Store();
                }
                else
                {
                    for (int i = 0; i < sList.Length; i++)
                    {
                        m_ipNotifType.UnSubscribe(sList[i]);
                    }
                    m_ipNotifType.Store();
                }
            }
            catch (Exception ex)
            {
                throw new Exception("An error occurred updating subscriber list!: " + ex.Message);
            }
        }