예제 #1
0
        protected override void OnStart(string[] args)
        {
            bool isBound = ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.Desktop);

            if (!isBound)
            {
                return;
            }

            IAoInitialize aoInitialize = new AoInitializeClass();

            aoInitialize.Initialize(esriLicenseProductCode.esriLicenseProductCodeAdvanced);
            aoInitialize.CheckOutExtension(esriLicenseExtensionCode.esriLicenseExtensionCodeWorkflowManager);

            IJTXDatabaseManager databaseMan = new JTXDatabaseManagerClass();

            m_database = (IJTXDatabase2)databaseMan.GetActiveDatabase(false);

            //m_lastDate = (DateTime.Now;

            m_dataWorkspaceNames = m_database.GetDataWorkspaceNames(null);

            IJTXSpatialNotificationManager spatNotifMan = m_database.SpatialNotificationManager;

            m_regLayers = spatNotifMan.RegisteredLayerInfos;

            for (int i = 0; i < m_dataWorkspaceNames.Count; i++)
            {
                IWorkspace ws  = m_database.GetDataWorkspace(m_dataWorkspaceNames.get_Item(i).DatabaseID, "");
                DateTime   now = (DateTime)((IDatabaseConnectionInfo2)ws).ConnectionCurrentDateTime;
                m_workspaces.Add(new WorkspaceInfo(m_dataWorkspaceNames.get_Item(i).DatabaseID, ws, now));
            }

            m_timer.Enabled = true;
        }
        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();
            }
        }
        static void Main(string[] args)
        {
            // Convert the arguments to objects
            object[] argv = new object[args.Length];
            for (int i = 0; i < args.Length; i++)
            {
                argv[i] = args[i];
            }

            // Check if they want to display the usage message
            string tmpOut;

            if (StepUtilities.GetArgument(ref argv, "h", true, out tmpOut) || StepUtilities.GetArgument(ref argv, "?", true, out tmpOut))
            {
                PrintUsageMessage();
                return;
            }

            if (CheckoutLicense())
            {
                try
                {
                    IJTXDatabaseManager2 dbMgr = new JTXDatabaseManagerClass() as IJTXDatabaseManager2;
                    IJTXDatabase         ipDB  = null;
                    if (StepUtilities.GetArgument(ref argv, argNames[0], true, out tmpOut))
                    {
                        // Database was specified
                        try
                        {
                            ipDB = dbMgr.GetDatabase(tmpOut);
                        }
                        catch (COMException)
                        {
                            Console.WriteLine("{0} is not a valid Workflow Manager database alias", tmpOut);
                        }
                        Console.WriteLine("Using database {0}", tmpOut);
                    }
                    else
                    {
                        // Use the default database
                        Console.WriteLine("Using default database");
                        ipDB = dbMgr.GetActiveDatabase(false);
                    }

                    // Get the domain. If one is not specified, use the current domain
                    string strDomain;
                    if (StepUtilities.GetArgument(ref argv, argNames[1], true, out tmpOut))
                    {
                        strDomain = tmpOut;
                    }
                    else
                    {
                        strDomain = Environment.UserDomainName;
                    }

                    // Get the username
                    string strUsername = "";
                    if (StepUtilities.GetArgument(ref argv, argNames[2], true, out tmpOut))
                    {
                        strUsername = tmpOut;
                    }

                    // Get the password
                    string strPassword = "";
                    if (strUsername != "" && StepUtilities.GetArgument(ref argv, argNames[3], true, out tmpOut))
                    {
                        strPassword = tmpOut;
                    }

                    // Get the userGroup.  If one is not specified, check the registry for the value the UI stored
                    string strUserGroup;
                    if (StepUtilities.GetArgument(ref argv, argNames[4], true, out tmpOut))
                    {
                        strUserGroup = tmpOut;
                    }
                    else
                    {
                        strUserGroup = GetGroupFromReg("UserADGroup");
                    }

                    // Get the groupGroup.  If one is not specified, check the registry for the value the UI stored
                    string strGroupGroup;
                    if (StepUtilities.GetArgument(ref argv, argNames[5], true, out tmpOut))
                    {
                        strGroupGroup = tmpOut;
                    }
                    else
                    {
                        strGroupGroup = GetGroupFromReg("GroupADGroup");
                    }

                    if (String.IsNullOrEmpty(strUserGroup) || String.IsNullOrEmpty(strGroupGroup))
                    {
                        Console.WriteLine("Error: Empty userGroup or groupGroup");
                        return;
                    }

                    ConfigurationCache.InitializeCache(ipDB);

                    // Synchronize
                    int groupCount, userCount;
                    ActiveDirectoryHelper.SyncronizeJTXDatabaseWithActiveDirectory(ipDB, strDomain, strUsername, strPassword,
                                                                                   strUserGroup, strGroupGroup, out groupCount, out userCount);

                    Console.WriteLine("Successfully imported {0} users in {1} groups", userCount, groupCount);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Failed with error: " + e.Message + e.StackTrace);
                }
                finally
                {
                    CheckinLicense();
                }
            }
            else
            {
                Console.WriteLine("Could not checkout license... exiting");
            }
        }
예제 #4
0
        static void Main(string[] args)
        {

            // Convert the arguments to objects
            object[] argv = new object[args.Length];
            for (int i = 0; i < args.Length; i++)
            {
                argv[i] = args[i];
            }

            // Check if they want to display the usage message
            string tmpOut;
            if (StepUtilities.GetArgument(ref argv, "h", true, out tmpOut) || StepUtilities.GetArgument(ref argv, "?", true, out tmpOut))
            {
                PrintUsageMessage();
                return;
            }
            
            if (CheckoutLicense())
            {
                try
                {

                    IJTXDatabaseManager2 dbMgr = new JTXDatabaseManagerClass() as IJTXDatabaseManager2;
                    IJTXDatabase ipDB = null;
                    if (StepUtilities.GetArgument(ref argv, argNames[0], true, out tmpOut))
                    {
                        // Database was specified
                        try
                        {
                            ipDB = dbMgr.GetDatabase(tmpOut);
                        }
                        catch (COMException)
                        {
                            Console.WriteLine("{0} is not a valid Workflow Manager database alias", tmpOut);
                        }
                        Console.WriteLine("Using database {0}", tmpOut);
                    }
                    else
                    {
                        // Use the default database
                        Console.WriteLine("Using default database");
                        ipDB = dbMgr.GetActiveDatabase(false);
                    }

                    // Get the domain. If one is not specified, use the current domain
                    string strDomain;
                    if (StepUtilities.GetArgument(ref argv, argNames[1], true, out tmpOut))
                        strDomain = tmpOut;
                    else
                        strDomain = Environment.UserDomainName;

                    // Get the username
                    string strUsername = "";
                    if (StepUtilities.GetArgument(ref argv, argNames[2], true, out tmpOut))
                        strUsername = tmpOut;
                    
                    // Get the password
                    string strPassword = "";
                    if (strUsername != "" && StepUtilities.GetArgument(ref argv, argNames[3], true, out tmpOut))
                        strPassword = tmpOut;

                    // Get the userGroup.  If one is not specified, check the registry for the value the UI stored
                    string strUserGroup;
                    if (StepUtilities.GetArgument(ref argv, argNames[4], true, out tmpOut))
                        strUserGroup = tmpOut;
                    else
                        strUserGroup = GetGroupFromReg("UserADGroup");

                    // Get the groupGroup.  If one is not specified, check the registry for the value the UI stored
                    string strGroupGroup;
                    if (StepUtilities.GetArgument(ref argv, argNames[5], true, out tmpOut))
                        strGroupGroup = tmpOut;
                    else
                        strGroupGroup = GetGroupFromReg("GroupADGroup");

                    if (String.IsNullOrEmpty(strUserGroup) || String.IsNullOrEmpty(strGroupGroup))
                    {
                        Console.WriteLine("Error: Empty userGroup or groupGroup");
                        return;
                    }

                    ConfigurationCache.InitializeCache(ipDB);

                    // Synchronize
                    int groupCount, userCount;
                    ActiveDirectoryHelper.SyncronizeJTXDatabaseWithActiveDirectory(ipDB, strDomain, strUsername, strPassword,
                        strUserGroup, strGroupGroup, out groupCount, out userCount);

                    Console.WriteLine("Successfully imported {0} users in {1} groups", userCount, groupCount);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Failed with error: " + e.Message + e.StackTrace);
                }
                finally
                {
                    CheckinLicense();
                }
            }
            else
                Console.WriteLine("Could not checkout license... exiting");
        }
        static void Main(string[] args)
        {
            JTXOverdueNotification prog = new JTXOverdueNotification();

            if (prog.CheckoutLicense())
            {
                try
                {
                    // Arguments list
                    // /NotifType:<Notification type to send>
                    // example: JTXOverdueNotification.exe /NotifType:OverdueJob

                    object[] pArgObjects = args as object[];

                    // Get some variables ready
                    string sNotificationTypeName = "";

                    StepUtilities.GetArgument(ref pArgObjects, "NotifType", true, out sNotificationTypeName);
                    if (sNotificationTypeName == "")
                    {
                        Console.WriteLine("A notification type must be entered.");
                        return;
                    }

                    IJTXDatabaseManager jtxDBMan   = new JTXDatabaseManagerClass();
                    IJTXDatabase        pJTXDB     = jtxDBMan.GetActiveDatabase(false);
                    IJTXConfiguration   pJTXConfig = pJTXDB.ConfigurationManager;

                    // Create a simple query to find jobs that were due before today
                    IQueryFilter pQF = new QueryFilterClass();

                    // NOTE #1: Verify the date format matches your selected RDBMS
                    // NOTE #2: Verify the status id for 'Closed' with the JTX Administrator
                    pQF.WhereClause = "DUE_DATE < '" + DateTime.Today.ToString() + "'" + " AND STATUS <> 9";
                    Console.WriteLine(pQF.WhereClause);

                    // Get the notification type for the notification that will be sent
                    IJTXNotificationConfiguration pNotificationConfig = pJTXConfig as IJTXNotificationConfiguration;
                    IJTXNotificationType          pNotificationType   = pNotificationConfig.GetNotificationType(sNotificationTypeName);
                    if (pNotificationType == null)
                    {
                        Console.WriteLine("Please enter a valid notification type.");
                        return;
                    }

                    // Get the job manager to execute the query and find the jobs in question
                    IJTXJobManager pJobManager = pJTXDB.JobManager;
                    IJTXJobSet     pJobs       = pJobManager.GetJobsByQuery(pQF);

                    pJobs.Reset();
                    for (int a = 0; a < pJobs.Count; a++)
                    {
                        IJTXJob pJob = pJobs.Next();
                        Console.WriteLine(pJob.Name);

                        // Send it!
                        JTXUtilities.SendNotification(sNotificationTypeName, pJTXDB, pJob, null);
                    }
                }
                catch (Exception except)
                {
                    Console.WriteLine("An error occurred: " + except.Message);
                }
                prog.CheckinLicense();
                Console.WriteLine("Completed.");
            }
        }
예제 #6
0
        protected override void OnStart(string[] args)
        {
            bool isBound = ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.Desktop);
            if (!isBound)
                return;

            IAoInitialize aoInitialize = new AoInitializeClass();
            aoInitialize.Initialize(esriLicenseProductCode.esriLicenseProductCodeAdvanced);
            aoInitialize.CheckOutExtension(esriLicenseExtensionCode.esriLicenseExtensionCodeWorkflowManager);

            IJTXDatabaseManager databaseMan = new JTXDatabaseManagerClass();
            m_database = (IJTXDatabase2)databaseMan.GetActiveDatabase(false);

            //m_lastDate = (DateTime.Now;

            m_dataWorkspaceNames = m_database.GetDataWorkspaceNames(null);
            
            IJTXSpatialNotificationManager spatNotifMan = m_database.SpatialNotificationManager;
            m_regLayers = spatNotifMan.RegisteredLayerInfos;

            for (int i = 0; i < m_dataWorkspaceNames.Count; i++)
            {
                IWorkspace ws = m_database.GetDataWorkspace(m_dataWorkspaceNames.get_Item(i).DatabaseID, "");
                DateTime now = (DateTime)((IDatabaseConnectionInfo2)ws).ConnectionCurrentDateTime;
                m_workspaces.Add(new WorkspaceInfo(m_dataWorkspaceNames.get_Item(i).DatabaseID, ws, now));
            }

            m_timer.Enabled = true;
            
        }
        static void Main(string[] args)
        {
            JTXOverdueNotification prog = new JTXOverdueNotification();
            if (prog.CheckoutLicense())
            {
                try
                {
                    // Arguments list
                    // /NotifType:<Notification type to send>
                    // example: JTXOverdueNotification.exe /NotifType:OverdueJob

                    object[] pArgObjects = args as object[];

                    // Get some variables ready
                    string sNotificationTypeName = "";

                    StepUtilities.GetArgument(ref pArgObjects, "NotifType", true, out sNotificationTypeName);
                    if (sNotificationTypeName == "")
                    {
                        Console.WriteLine("A notification type must be entered.");
                        return;
                    }

                    IJTXDatabaseManager jtxDBMan = new JTXDatabaseManagerClass();
                    IJTXDatabase pJTXDB = jtxDBMan.GetActiveDatabase(false);
                    IJTXConfiguration pJTXConfig = pJTXDB.ConfigurationManager;

                    // Create a simple query to find jobs that were due before today
                    IQueryFilter pQF = new QueryFilterClass();

                    // NOTE #1: Verify the date format matches your selected RDBMS
                    // NOTE #2: Verify the status id for 'Closed' with the JTX Administrator
                    pQF.WhereClause = "DUE_DATE < '" + DateTime.Today.ToString() + "'" + " AND STATUS <> 9";
                    Console.WriteLine(pQF.WhereClause);

                    // Get the notification type for the notification that will be sent
                    IJTXNotificationConfiguration pNotificationConfig = pJTXConfig as IJTXNotificationConfiguration;
                    IJTXNotificationType pNotificationType = pNotificationConfig.GetNotificationType(sNotificationTypeName);
                    if (pNotificationType == null)
                    {
                        Console.WriteLine("Please enter a valid notification type.");
                        return;
                    }

                    // Get the job manager to execute the query and find the jobs in question
                    IJTXJobManager pJobManager = pJTXDB.JobManager;
                    IJTXJobSet pJobs = pJobManager.GetJobsByQuery(pQF);

                    pJobs.Reset();
                    for (int a = 0; a < pJobs.Count; a++)
                    {
                        IJTXJob pJob = pJobs.Next();
                        Console.WriteLine(pJob.Name);

                        // Send it!
                        JTXUtilities.SendNotification(sNotificationTypeName, pJTXDB, pJob, null);
                    }
                }
                catch (Exception except)
                {
                    Console.WriteLine("An error occurred: " + except.Message);
                }
                prog.CheckinLicense();
                Console.WriteLine("Completed.");
            }
        }
        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();
            }
        }