/// <summary> /// Method to validate the configured arguments for the step type. The /// logic of this method depends on the implementation of the custom step /// but typically checks for proper argument names and syntax. /// </summary> /// <param name="argv">Array of arguments configured for the step type</param> /// <returns>Returns 'true' if arguments are valid, 'false' if otherwise</returns> public bool ValidateArguments(ref object[] argv) { IJTXConfiguration ipConfig = m_ipDatabase.ConfigurationManager; string strAssignType = ""; string strAssignTo = ""; if (!StepUtilities.GetArgument(ref argv, m_expectedArgs[0], true, out strAssignType)) { throw new ArgumentNullException(m_expectedArgs[0], string.Format("\nMissing the {0} parameter!", m_expectedArgs[0])); } if (!StepUtilities.GetArgument(ref argv, m_expectedArgs[1], true, out strAssignTo)) { throw new ArgumentNullException(m_expectedArgs[1], string.Format("\nMissing the {0} parameter!", m_expectedArgs[1])); } if (strAssignType == "group") { if (ipConfig.GetUserGroup(strAssignTo) == null) { throw new ArgumentOutOfRangeException(m_expectedArgs[1], string.Format("\nThe group {0} is not a group defined in the JTX database!", strAssignTo)); } } else { if (ipConfig.GetUser(strAssignTo) == null) { throw new ArgumentOutOfRangeException(m_expectedArgs[1], string.Format("\nThe user {0} is not a user defined in the JTX database!", strAssignTo)); } } return(true); }
/// <summary> /// Method to validate the configured arguments for the step type. The /// logic of this method depends on the implementation of the custom step /// but typically checks for proper argument names and syntax. /// </summary> /// <param name="argv">Array of arguments configured for the step type</param> /// <returns>Returns 'true' if arguments are valid, 'false' if otherwise</returns> public bool ValidateArguments(ref object[] argv) { IJTXDatabase pJTXDB = m_ipDatabase; // Get the arguments string sHoldTypeName = ""; string sHoldRemarks = ""; bool bHoldType = StepUtilities.GetArgument(ref argv, "HoldType", true, out sHoldTypeName); if (!bHoldType) { MessageBox.Show("Invalid arguments entered. No hold type entered."); return(false); } bool bHoldRemarks = StepUtilities.GetArgument(ref argv, "HoldRemarks", true, out sHoldRemarks); // Get the hold type IJTXConfiguration pJTXConfig = pJTXDB.ConfigurationManager; IJTXHoldType pHoldType = pJTXConfig.GetHoldType(sHoldTypeName); if (pHoldType == null) { MessageBox.Show("Invalid hold type name entered: " + sHoldTypeName); return(false); } return(true); }
/// <summary> /// Called when a step of this type is executed in the workflow. /// </summary> /// <param name="JobID">ID of the job being executed</param> /// <param name="StepID">ID of the step being executed</param> /// <param name="argv">Array of arguments passed into the step's execution</param> /// <param name="ipFeedback">Feedback object to return status messages and files</param> /// <returns>Return code of execution for workflow path traversal</returns> public int Execute(int jobID, int stepID, ref object[] argv, ref IJTXCustomStepFeedback ipFeedback) { if (jobID <= 0) { throw (new ArgumentOutOfRangeException("JobID", jobID, "Job ID must be a positive value")); } string strNotifType = ""; string strSubscribers = ""; if (!StepUtilities.GetArgument(ref argv, m_expectedArgs[0], true, out strNotifType)) { throw new ArgumentNullException(m_expectedArgs[0], string.Format("\nMissing the {0} parameter!", m_expectedArgs[0])); } bool bSubscribers = StepUtilities.GetArgument(ref argv, m_expectedArgs[1], true, out strSubscribers); IJTXJob ipJob = m_ipDatabase.JobManager.GetJob(jobID); if (bSubscribers) { UpdateSubscriberList(strNotifType, strSubscribers, "add"); } JTXUtilities.SendNotification(strNotifType, m_ipDatabase, ipJob, null); if (bSubscribers) { UpdateSubscriberList(strNotifType, strSubscribers, "remove"); } return(0); }
/// <summary> /// Method to validate the configured arguments for the step type. The /// logic of this method depends on the implementation of the custom step /// but typically checks for proper argument names and syntax. /// </summary> /// <param name="argv">Array of arguments configured for the step type</param> /// <returns>Returns 'true' if arguments are valid, 'false' if otherwise</returns> public bool ValidateArguments(ref object[] argv) { string strValue = ""; if (!StepUtilities.GetArgument(ref argv, m_expectedArgs[0], true, out strValue)) { return(false); } return(StepUtilities.AreArgumentNamesValid(ref argv, m_expectedArgs)); }
public DialogResult ShowDialog(object[] argsIn, out object[] argsOut) { // Populate the combo boxes with the appropriate information IJTXConfiguration2 ipJTXConfig = m_ipDatabase.ConfigurationManager as IJTXConfiguration2; PopulateJobTypes(ipJTXConfig); PopulateUsers(ipJTXConfig); PopulateGroups(ipJTXConfig); // Populate the dialog with the existing argument information string strTemp = ""; if (StepUtilities.GetArgument(ref argsIn, m_expectedArgs[0], true, out strTemp)) { // Then the job type has been entered int iJobTypeID = Convert.ToInt32(strTemp); IJTXJobType ipJobType = ipJTXConfig.GetJobTypeByID(iJobTypeID); cmbJobTypes.SelectedItem = ipJobType.Name; } if (StepUtilities.GetArgument(ref argsIn, m_expectedArgs[1], true, out strTemp)) { // Then a user group has been selected for the new job assignment chkGroup.Checked = true; chkUser.Checked = false; cmbUsers.Enabled = false; cmbGroups.SelectedItem = strTemp; } if (StepUtilities.GetArgument(ref argsIn, m_expectedArgs[2], true, out strTemp)) { // Then a user has been selected for the new job assignment chkGroup.Checked = false; chkUser.Checked = true; cmbGroups.Enabled = false; cmbUsers.SelectedItem = strTemp; } // Show the dialog this.ShowDialog(); argsOut = m_Arguments.ToArray(); return(DialogResult); }
/// <summary> /// Called when a step of this type is executed in the workflow. /// </summary> /// <param name="JobID">ID of the job being executed</param> /// <param name="StepID">ID of the step being executed</param> /// <param name="argv">Array of arguments passed into the step's execution</param> /// <param name="ipFeedback">Feedback object to return status messages and files</param> /// <returns>Return code of execution for workflow path traversal</returns> public int Execute(int jobID, int stepID, ref object[] argv, ref IJTXCustomStepFeedback ipFeedback) { IJTXJobManager ipJobManager = m_ipDatabase.JobManager; IJTXConfiguration ipConfig = m_ipDatabase.ConfigurationManager; IJTXJob ipJob = ipJobManager.GetJob(jobID); string strAssignType = ""; string strAssignTo = ""; if (!StepUtilities.GetArgument(ref argv, m_expectedArgs[0], true, out strAssignType)) { throw new ArgumentNullException(m_expectedArgs[0], string.Format("\nMissing the {0} parameter!", m_expectedArgs[0])); } if (!StepUtilities.GetArgument(ref argv, m_expectedArgs[1], true, out strAssignTo)) { throw new ArgumentNullException(m_expectedArgs[1], string.Format("\nMissing the {0} parameter!", m_expectedArgs[1])); } if (strAssignType == "group") { if (ipConfig.GetUserGroup(strAssignTo) == null) { throw new ArgumentOutOfRangeException(m_expectedArgs[1], string.Format("\nThe group {0} is not a group defined in the JTX database!", strAssignTo)); } ipJob.AssignedType = jtxAssignmentType.jtxAssignmentTypeGroup; } else { if (ipConfig.GetUser(strAssignTo) == null) { throw new ArgumentOutOfRangeException(m_expectedArgs[1], string.Format("\nThe user {0} is not a user defined in the JTX database!", strAssignTo)); } ipJob.AssignedType = jtxAssignmentType.jtxAssignmentTypeUser; } ipJob.AssignedTo = strAssignTo; ipJob.Store(); return(0); }
/// <summary> /// Called when a step of this type is executed in the workflow. /// </summary> /// <param name="JobID">ID of the job being executed</param> /// <param name="StepID">ID of the step being executed</param> /// <param name="argv">Array of arguments passed into the step's execution</param> /// <param name="ipFeedback">Feedback object to return status messages and files</param> /// <returns>Return code of execution for workflow path traversal</returns> public int Execute(int jobID, int stepID, ref object[] argv, ref IJTXCustomStepFeedback ipFeedback) { if (jobID <= 0) { throw (new ArgumentOutOfRangeException("JobID", jobID, "Job ID must be a positive value")); } System.Diagnostics.Debug.Assert(m_ipDatabase != null); IJTXJob pJob = m_ipDatabase.JobManager.GetJob(jobID); string strValue = ""; if (StepUtilities.GetArgument(ref argv, m_expectedArgs[0], true, out strValue) || StepUtilities.GetArgument(ref argv, m_expectedArgs[1], true, out strValue)) { if (pJob.VersionExists()) { pJob.DeleteVersion(null); } } if (StepUtilities.GetArgument(ref argv, m_expectedArgs[2], true, out strValue) || StepUtilities.GetArgument(ref argv, m_expectedArgs[3], true, out strValue)) { if (pJob.MXDExists()) { pJob.DeleteMXD(); } } if (StepUtilities.GetArgument(ref argv, m_expectedArgs[4], true, out strValue) || StepUtilities.GetArgument(ref argv, m_expectedArgs[5], true, out strValue)) { IJTXAttachmentSet attachments = pJob.Attachments; for (int i = attachments.Count - 1; i >= 0; i--) { int id = (attachments.get_Item(i).ID); pJob.DeleteAttachment(id); } } return(0); }
/// <summary> /// Called when a step of this type is executed in the workflow. /// </summary> /// <param name="JobID">ID of the job being executed</param> /// <param name="StepID">ID of the step being executed</param> /// <param name="argv">Array of arguments passed into the step's execution</param> /// <param name="ipFeedback">Feedback object to return status messages and files</param> /// <returns>Return code of execution for workflow path traversal</returns> public int Execute(int jobID, int stepID, ref object[] argv, ref IJTXCustomStepFeedback ipFeedback) { // Get the arguments string sHoldTypeName = ""; string sHoldRemarks = ""; bool bHoldType = StepUtilities.GetArgument(ref argv, "HoldType", true, out sHoldTypeName); if (!bHoldType) { MessageBox.Show("Invalid arguments entered. No hold type entered."); return(-1); } bool bHoldRemarks = StepUtilities.GetArgument(ref argv, "HoldRemarks", true, out sHoldRemarks); // Get the hold type IJTXConfiguration pJTXConfig = m_ipDatabase.ConfigurationManager; IJTXHoldType pHoldType = pJTXConfig.GetHoldType(sHoldTypeName); if (pHoldType == null) { MessageBox.Show("Invalid hold type name entered: " + sHoldTypeName); return(-1); } // Get the job IJTXJobManager pJobManager = m_ipDatabase.JobManager; IJTXJob pJob = pJobManager.GetJob(jobID); IJTXJobHolds pJobHolds = pJob as IJTXJobHolds; // Add new job hold IJTXJobHold pNewHold = pJobHolds.CreateHold(pHoldType); if (bHoldRemarks) { pNewHold.HoldComments = sHoldRemarks; pNewHold.Store(); } return(0); }
private void btnOK_Click(object sender, EventArgs e) { if (cmbJobTypes.SelectedItem.ToString() != "") { IJTXConfiguration ipJTXConfig = m_ipDatabase.ConfigurationManager; IJTXJobType ipJobType = ipJTXConfig.GetJobType(cmbJobTypes.SelectedItem.ToString()); m_Arguments.Add(StepUtilities.CreateSingleArgument(m_expectedArgs[0], ipJobType.ID.ToString())); } if (chkGroup.Checked) { m_Arguments.Add(StepUtilities.CreateSingleArgument(m_expectedArgs[1], cmbGroups.SelectedItem.ToString())); } else if (chkUser.Checked) { m_Arguments.Add(StepUtilities.CreateSingleArgument(m_expectedArgs[2], cmbUsers.SelectedItem.ToString())); } DialogResult = DialogResult.OK; this.Hide(); }
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(); } }
/// <summary> /// Called when a step of this type is executed in the workflow. /// </summary> /// <param name="JobID">ID of the job being executed</param> /// <param name="StepID">ID of the step being executed</param> /// <param name="argv">Array of arguments passed into the step's execution</param> /// <param name="ipFeedback">Feedback object to return status messages and files</param> /// <returns>Return code of execution for workflow path traversal</returns> public int Execute(int JobID, int stepID, ref object[] argv, ref IJTXCustomStepFeedback ipFeedback) { System.Diagnostics.Debug.Assert(m_ipDatabase != null); string strValue = ""; int jobTypeID = 0; if (!StepUtilities.GetArgument(ref argv, m_expectedArgs[0], true, out strValue)) { throw new ArgumentNullException(m_expectedArgs[0], string.Format("\nMissing the {0} parameter!", m_expectedArgs[0])); } if (!Int32.TryParse(strValue, out jobTypeID)) { throw new ArgumentNullException(m_expectedArgs[0], "Argument must be an integrer!"); } IJTXJobType pJobType = m_ipDatabase.ConfigurationManager.GetJobTypeByID(jobTypeID); IJTXJobManager pJobMan = m_ipDatabase.JobManager; IJTXJob pNewJob = pJobMan.CreateJob(pJobType, 0, true); IJTXActivityType pActType = m_ipDatabase.ConfigurationManager.GetActivityType(Constants.ACTTYPE_CREATE_JOB); if (pActType != null) { pNewJob.LogJobAction(pActType, null, ""); } JTXUtilities.SendNotification(Constants.NOTIF_JOB_CREATED, m_ipDatabase, pNewJob, null); // Assign a status to the job if the Auto Assign Job Status setting is enabled IJTXConfigurationProperties pConfigProps = (IJTXConfigurationProperties)m_ipDatabase.ConfigurationManager; if (pConfigProps.PropertyExists(Constants.JTX_PROPERTY_AUTO_STATUS_ASSIGN)) { string strAutoAssign = pConfigProps.GetProperty(Constants.JTX_PROPERTY_AUTO_STATUS_ASSIGN); if (strAutoAssign == "TRUE") { pNewJob.Status = m_ipDatabase.ConfigurationManager.GetStatus("Created"); } } // Associate the current job with the new job with a parent-child relationship pNewJob.ParentJob = JobID; // Assign the job as specified in the arguments string strAssignTo = ""; if (StepUtilities.GetArgument(ref argv, m_expectedArgs[1], true, out strAssignTo)) { pNewJob.AssignedType = jtxAssignmentType.jtxAssignmentTypeGroup; pNewJob.AssignedTo = strAssignTo; } else if (StepUtilities.GetArgument(ref argv, m_expectedArgs[2], true, out strAssignTo)) { pNewJob.AssignedType = jtxAssignmentType.jtxAssignmentTypeUser; pNewJob.AssignedTo = strAssignTo; } pNewJob.Store(); // Copy the workflow to the new job WorkflowUtilities.CopyWorkflowXML(m_ipDatabase, pNewJob); // Create 1-1 extended property entries IJTXAuxProperties pAuxProps = (IJTXAuxProperties)pNewJob; System.Array contNames = pAuxProps.ContainerNames; IEnumerator contNamesEnum = contNames.GetEnumerator(); contNamesEnum.Reset(); while (contNamesEnum.MoveNext()) { string strContainerName = (string)contNamesEnum.Current; IJTXAuxRecordContainer pAuxContainer = pAuxProps.GetRecordContainer(strContainerName); if (pAuxContainer.RelationshipType == esriRelCardinality.esriRelCardinalityOneToOne) { pAuxContainer.CreateRecord(); } } m_ipDatabase.LogMessage(5, 1000, System.Diagnostics.Process.GetCurrentProcess().MainWindowTitle); // Update Application message about the new job if (System.Diagnostics.Process.GetCurrentProcess().MainWindowTitle.Length > 0) //if its not running in server { MessageBox.Show("Created " + pJobType.Name + " Job " + pNewJob.ID, "Job Created", MessageBoxButtons.OK, MessageBoxIcon.Information); } return(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"); } }
//////////////////////////////////////////////////////////////////////// // METHOD: GetInputParams private bool GetInputParams(object [] argv) { string sTemp = ""; // Job Type StepUtilities.GetArgument(ref argv, m_ExpectedArgs[0], true, out m_paramJobTypeName); // Job Assignment StepUtilities.GetArgument(ref argv, m_ExpectedArgs[1], true, out m_paramAssignToGroup); StepUtilities.GetArgument(ref argv, m_ExpectedArgs[2], true, out m_paramAssignToUser); // Job Dependencies m_paramDependThisStep = StepUtilities.GetArgument(ref argv, m_ExpectedArgs[3], true, out sTemp); m_paramDependNextStep = StepUtilities.GetArgument(ref argv, m_ExpectedArgs[4], true, out sTemp); m_paramHasStatusType = StepUtilities.GetArgument(ref argv, m_ExpectedArgs[5], true, out m_paramStatusType); // Number of Jobs and AOI Definition m_paramUseParentAOI = StepUtilities.GetArgument(ref argv, m_ExpectedArgs[6], true, out sTemp); StepUtilities.GetArgument(ref argv, m_ExpectedArgs[7], true, out m_AOIOverlapFeatureClassName); if (StepUtilities.GetArgument(ref argv, m_ExpectedArgs[8], true, out sTemp)) { m_paramNumberChildJobs = Convert.ToInt16(sTemp); } // Versioning StepUtilities.GetArgument(ref argv, m_ExpectedArgs[9], true, out sTemp); if (string.IsNullOrEmpty(sTemp)) { m_paramCreateVersionType = CreateVersionType.None; } else if (sTemp.Equals("The parent job's version")) { m_paramCreateVersionType = CreateVersionType.UseParentJobsVersion; } else if (sTemp.Equals("The parent job's parent version")) { m_paramCreateVersionType = CreateVersionType.UseParentJobsParentVersion; } else if (sTemp.Equals("The parent job's DEFAULT version")) { m_paramCreateVersionType = CreateVersionType.UseParentJobsDefaultVersion; } else if (sTemp.Equals("The job type's default properties parent version")) { m_paramCreateVersionType = CreateVersionType.UseJobTypeDefaultSettings; } StepUtilities.GetArgument(ref argv, m_ExpectedArgs[10], true, out sTemp); if (string.IsNullOrEmpty(sTemp)) { m_paramAssignVersionType = AssignVersionType.None; } else if (sTemp.Equals("The parent job's version")) { m_paramAssignVersionType = AssignVersionType.UseParentJobsVersion; } // Extended Properties StepUtilities.GetArgument(ref argv, m_ExpectedArgs[11], true, out m_paramExtendedProperties); StepUtilities.GetArgument(ref argv, m_ExpectedArgs[12], true, out sTemp); if (!String.IsNullOrEmpty(sTemp)) { m_dueDate = JTXUtilities.GenerateDateString(m_ipDatabase.JTXWorkspace, sTemp, false); } StepUtilities.GetArgument(ref argv, m_ExpectedArgs[13], true, out sTemp); if (!String.IsNullOrEmpty(sTemp)) { int.TryParse(sTemp, out m_duration); } return(true); }
/// <summary> /// Method to validate the configured arguments for the step type. The /// logic of this method depends on the implementation of the custom step /// but typically checks for proper argument names and syntax. /// </summary> /// <param name="argv">Array of arguments configured for the step type</param> /// <returns>Returns 'true' if arguments are valid, 'false' if otherwise</returns> public bool ValidateArguments(ref object[] argv) { return(StepUtilities.AreArgumentNamesValid(ref argv, m_expectedArgs)); }
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."); } }
/// <summary> /// Called when a step of this type is executed in the workflow. /// </summary> /// <param name="JobID">ID of the job being executed</param> /// <param name="StepID">ID of the step being executed</param> /// <param name="argv">Array of arguments passed into the step's execution</param> /// <param name="ipFeedback">Feedback object to return status messages and files</param> /// <returns>Return code of execution for workflow path traversal</returns> public int Execute(int JobID, int stepID, ref object[] argv, ref IJTXCustomStepFeedback ipFeedback) { if (JobID <= 0) { throw new ArgumentOutOfRangeException("JobID", JobID, "Job ID must be a positive value"); } try { string strTemp = ""; bool bAttach = false; if (StepUtilities.GetArgument(ref argv, m_expectedArgs[1], false, out strTemp)) { bAttach = true; } string strResolution; if (!StepUtilities.GetArgument(ref argv, m_expectedArgs[2], false, out strResolution)) { strResolution = "1200"; } int iResolution = 1200; if (!Int32.TryParse(strResolution, out iResolution)) { iResolution = 1200; } string outputPath = ""; if (!bAttach) { SaveFileDialog pSaveFileDialog = new SaveFileDialog(); pSaveFileDialog.Filter = "PDF files (*.pdf)|*.pdf"; pSaveFileDialog.Title = "Choose output location..."; string strInitDir = ""; if (StepUtilities.GetArgument(ref argv, m_expectedArgs[0], true, out strInitDir)) { if (System.IO.Directory.Exists(strInitDir)) { pSaveFileDialog.InitialDirectory = strInitDir; } } if (pSaveFileDialog.ShowDialog() != DialogResult.OK) { return(-1); } outputPath = pSaveFileDialog.FileName; } string inputPath = JTXUtilities.SaveJobMXD(JobID); if (bAttach) { outputPath = SystemUtilities.GetTemporaryFileLocation(inputPath, "pdf"); } // delete output file if it already exists System.IO.FileInfo fi = new System.IO.FileInfo(outputPath); if (fi.Exists) { fi.Delete(); } MapDocumentClass map = new MapDocumentClass(); if (!map.get_IsMapDocument(inputPath)) { throw new ApplicationException("Invalid map or specified map not found."); } map.Open(inputPath, null); IActiveView pActiveView = (IActiveView)map.PageLayout; IExport pExport = new ExportPDFClass(); pExport.ExportFileName = outputPath; tagRECT deviceFrameRect; deviceFrameRect.left = 0; deviceFrameRect.right = 800; deviceFrameRect.top = 0; deviceFrameRect.bottom = 600; pActiveView.ScreenDisplay.DisplayTransformation.set_DeviceFrame(ref deviceFrameRect); int iOutputResolution = iResolution; int iScreenResolution = 96; pExport.Resolution = iOutputResolution; IOutputRasterSettings pOutputRasterSettings = (IOutputRasterSettings)pExport; pOutputRasterSettings.ResampleRatio = 1; tagRECT exportRect; exportRect.left = pActiveView.ExportFrame.left * (iOutputResolution / iScreenResolution); exportRect.top = pActiveView.ExportFrame.top * (iOutputResolution / iScreenResolution); exportRect.right = pActiveView.ExportFrame.right * (iOutputResolution / iScreenResolution); exportRect.bottom = pActiveView.ExportFrame.bottom * (iOutputResolution / iScreenResolution); IEnvelope pPixelBoundsEnv = new EnvelopeClass(); pPixelBoundsEnv.PutCoords(exportRect.left, exportRect.top, exportRect.right, exportRect.bottom); pExport.PixelBounds = pPixelBoundsEnv; int hdc = pExport.StartExporting(); pActiveView.Output(hdc, iOutputResolution, ref exportRect, null, null); pExport.FinishExporting(); pExport.Cleanup(); if (bAttach) { JTXUtilities.AddAttachmentToJob(JobID, outputPath, jtxFileStorageType.jtxStoreInDB); } return(0); } catch (Exception ex) { throw ex; } }
public DialogResult ShowDialog(object[] argsIn, out object[] argsOut) { // Populate the combo boxes with the appropriate information IJTXConfiguration2 ipJTXConfig = m_ipDatabase.ConfigurationManager as IJTXConfiguration2; PopulateJobTypes(ipJTXConfig); PopulateUsers(ipJTXConfig); PopulateGroups(ipJTXConfig); PopulateStatusTypes(ipJTXConfig); // Populate the dialog with the existing argument information string strTemp = ""; if (StepUtilities.GetArgument(ref argsIn, m_expectedArgs[0], true, out strTemp)) { // Then the job type has been entered IJTXJobType ipJobType = ipJTXConfig.GetJobType(strTemp); if (ipJobType != null) { cmbJobTypes.SelectedItem = ipJobType.Name; } } if (StepUtilities.GetArgument(ref argsIn, m_expectedArgs[1], true, out strTemp)) { // Then a user group has been selected for the new job assignment chkGroup.Checked = true; chkUser.Checked = false; cmbUsers.Enabled = false; int idx = cmbGroups.Items.IndexOf(strTemp); cmbGroups.SelectedIndex = idx; if (idx < 0) { cmbGroups.Text = strTemp; } } if (StepUtilities.GetArgument(ref argsIn, m_expectedArgs[2], true, out strTemp)) { // Then a user has been selected for the new job assignment chkGroup.Checked = false; chkUser.Checked = true; cmbGroups.Enabled = false; int idx = cmbUsers.Items.IndexOf(strTemp); cmbUsers.SelectedIndex = idx; if (idx < 0) { cmbUsers.Text = strTemp; } } if (StepUtilities.GetArgument(ref argsIn, m_expectedArgs[3], true, out strTemp)) { // Then a dependency is being created ... chkDependThisStep.Checked = true; lblStatus.Enabled = true; cboDependentStatus.Enabled = true; } if (StepUtilities.GetArgument(ref argsIn, m_expectedArgs[4], true, out strTemp)) { // Then a dependency is being created ... chkDependNextStep.Checked = true; lblStatus.Enabled = true; cboDependentStatus.Enabled = true; } if (StepUtilities.GetArgument(ref argsIn, m_expectedArgs[5], true, out strTemp)) { // Then a user has been selected for the new job assignment lblStatus.Enabled = true; lblStatus.Enabled = true; cboDependentStatus.SelectedItem = strTemp; } if (StepUtilities.GetArgument(ref argsIn, m_expectedArgs[6], true, out strTemp)) { // Then the parent job's AOI will be used by the child chkAssignParentAOIToChild.Checked = true; } if (StepUtilities.GetArgument(ref argsIn, m_expectedArgs[7], true, out strTemp)) { // Then the number of child jobs and their AOIs will be determined by a // spatial overlap with an input feature class chkAssignParentAOIToChild.Enabled = false; radioButton_generateNumberJobs.Checked = true; txtAOIFeatureClassName.Enabled = true; txtAOIFeatureClassName.Text = strTemp; } if (StepUtilities.GetArgument(ref argsIn, m_expectedArgs[8], true, out strTemp)) { // Then the user will specify the number of child jobs txtAOIFeatureClassName.Enabled = false; radioButton_DefineNumberOfJobs.Checked = true; lstNumberOfJobs.Value = Convert.ToDecimal(strTemp); chkAssignParentAOIToChild.Enabled = true; } if (StepUtilities.GetArgument(ref argsIn, m_expectedArgs[9], true, out strTemp)) { // Then a version will be created for the child job(s) from the Default version chkCreateVersion.Checked = true; cboCreateVersionSetting.Enabled = true; int idx = cboCreateVersionSetting.Items.IndexOf(strTemp); cboCreateVersionSetting.SelectedIndex = idx; if (idx < 0) { cboCreateVersionSetting.Text = strTemp; } } if (StepUtilities.GetArgument(ref argsIn, m_expectedArgs[10], true, out strTemp)) { // Then a version will be created for the child job(s) from the Default version chkAssignVersion.Checked = true; cboAssignVersionSetting.Enabled = true; int idx = cboAssignVersionSetting.Items.IndexOf(strTemp); cboAssignVersionSetting.SelectedIndex = idx; if (idx < 0) { cboAssignVersionSetting.Text = strTemp; } } if (StepUtilities.GetArgument(ref argsIn, m_expectedArgs[11], true, out strTemp)) { // Then the user will not be able to modify any parameters that were pre-configured chkSetExtProps.Checked = true; txtSetExtProps.Text = strTemp; } if (StepUtilities.GetArgument(ref argsIn, m_expectedArgs[12], true, out strTemp)) { chkDueDate.Checked = true; dtpDueDate.Value = JTXUtilities.GenerateDateString(m_ipDatabase.JTXWorkspace, strTemp, false); } else if (StepUtilities.GetArgument(ref argsIn, m_expectedArgs[13], true, out strTemp)) { txtDuration.Text = strTemp; } // Show the dialog this.ShowDialog(); argsOut = m_Arguments.ToArray(); return(DialogResult); }
/// <summary> /// Called when a step of this type is executed in the workflow. /// </summary> /// <param name="JobID">ID of the job being executed</param> /// <param name="StepID">ID of the step being executed</param> /// <param name="argv">Array of arguments passed into the step's execution</param> /// <param name="ipFeedback">Feedback object to return status messages and files</param> /// <returns>Return code of execution for workflow path traversal</returns> public int Execute(int jobID, int stepID, ref object[] argv, ref IJTXCustomStepFeedback ipFeedback) { if (jobID <= 0) { throw (new ArgumentOutOfRangeException("JobID", jobID, "Job ID must be a positive value")); } System.Diagnostics.Debug.Assert(m_ipDatabase != null); IJTXJobManager pJobMan = m_ipDatabase.JobManager; IJTXJob2 pJob = pJobMan.GetJob(jobID) as IJTXJob2; // Make sure all the information exists to create this verion if (pJob.ActiveDatabase == null) { System.Windows.Forms.MessageBox.Show("Job does not have a data workspace"); return(-1); } if (pJob.ParentVersion == "") { System.Windows.Forms.MessageBox.Show("Job does not have a parent version"); return(-1); } string strVersionNameOverride; bool bVNOverride = StepUtilities.GetArgument(ref argv, m_expectedArgs[1], true, out strVersionNameOverride); if (pJob.VersionName == "" & !bVNOverride) { System.Windows.Forms.MessageBox.Show("The job does not have a version name"); return(-1); } IVersion pNewVersion; string strVersionName; if (bVNOverride) { strVersionName = strVersionNameOverride; } else { strVersionName = pJob.VersionName; } int index = strVersionName.IndexOf(".", 0); if (index >= 0) { strVersionName = strVersionName.Substring(index + 1); } esriVersionAccess verAccess = esriVersionAccess.esriVersionAccessPrivate; string strVerScope = ""; if (StepUtilities.GetArgument(ref argv, m_expectedArgs[0], true, out strVerScope)) { strVerScope = strVerScope.ToLower().Trim(); if (strVerScope == "public") { verAccess = esriVersionAccess.esriVersionAccessPublic; } else if (strVerScope == "protected") { verAccess = esriVersionAccess.esriVersionAccessProtected; } } pJob.VersionName = strVersionName; pNewVersion = pJob.CreateVersion(verAccess); if (pNewVersion == null) { throw (new System.SystemException("Unable to create version")); } IPropertySet pOverrides = new PropertySetClass(); pOverrides.SetProperty("[VERSION]", pNewVersion.VersionName); IJTXActivityType pActType = m_ipDatabase.ConfigurationManager.GetActivityType(Constants.ACTTYPE_CREATE_VERSION); if (pActType != null) { pJob.LogJobAction(pActType, pOverrides, ""); } JTXUtilities.SendNotification(Constants.NOTIF_VERSION_CREATED, m_ipDatabase, pJob, pOverrides); System.Runtime.InteropServices.Marshal.ReleaseComObject(pNewVersion); return(0); }
private void btnOK_Click(object sender, EventArgs e) { if (cmbJobTypes.SelectedItem.ToString() != "") { m_Arguments.Add(StepUtilities.CreateSingleArgument(m_expectedArgs[0], cmbJobTypes.SelectedItem.ToString())); } if (chkGroup.Checked) { m_Arguments.Add(StepUtilities.CreateSingleArgument(m_expectedArgs[1], cmbGroups.Text)); } else if (chkUser.Checked) { m_Arguments.Add(StepUtilities.CreateSingleArgument(m_expectedArgs[2], cmbUsers.Text)); } if (chkDependThisStep.Checked) { m_Arguments.Add(StepUtilities.CreateFlagArgument(m_expectedArgs[3])); } if (chkDependNextStep.Checked) { m_Arguments.Add(StepUtilities.CreateFlagArgument(m_expectedArgs[4])); } if (chkDependThisStep.Checked || chkDependNextStep.Checked) { m_Arguments.Add(StepUtilities.CreateSingleArgument(m_expectedArgs[5], cboDependentStatus.SelectedItem.ToString())); } if (radioButton_DefineNumberOfJobs.Checked) { m_Arguments.Add(StepUtilities.CreateSingleArgument(m_expectedArgs[8], lstNumberOfJobs.Value.ToString())); if (chkAssignParentAOIToChild.Checked) { m_Arguments.Add(StepUtilities.CreateFlagArgument(m_expectedArgs[6])); } } if (radioButton_generateNumberJobs.Checked) { m_Arguments.Add(StepUtilities.CreateSingleArgument(m_expectedArgs[7], txtAOIFeatureClassName.Text)); } if (chkCreateVersion.Checked) { m_Arguments.Add(StepUtilities.CreateSingleArgument(m_expectedArgs[9], cboCreateVersionSetting.Text)); } if (chkAssignVersion.Checked) { m_Arguments.Add(StepUtilities.CreateSingleArgument(m_expectedArgs[10], cboAssignVersionSetting.Text)); } if (chkSetExtProps.Checked) { m_Arguments.Add(StepUtilities.CreateSingleArgument(m_expectedArgs[11], txtSetExtProps.Text)); } // Deal with the date options if (chkDueDate.Checked) { string strDate = JTXUtilities.GenerateDBMSDate(m_ipDatabase.JTXWorkspace, dtpDueDate.Value); m_Arguments.Add(StepUtilities.CreateSingleArgument(m_expectedArgs[12], strDate)); } else if (!String.IsNullOrEmpty(txtDuration.Text)) { int duration = -1; // Make sure the duration is a positive number int.TryParse(txtDuration.Text, out duration); if (duration > 0) { m_Arguments.Add(StepUtilities.CreateSingleArgument(m_expectedArgs[13], txtDuration.Text)); } } DialogResult = DialogResult.OK; this.Hide(); }