private string ReplaceToken(string token, IJTXDatabase pDB, IJTXJob pJob, ESRI.ArcGIS.esriSystem.IPropertySet pOverrides) { string tokenout = token; // Drop the [] and convert to uppercase token = token.Substring(1, token.Length - 2).ToUpper(); // Split the prefix from the actual token string[] parts = token.Split(new char[] { ':' }, 2); // make sure it is a environment token (starts with "ENV:") if (parts.Length == 2) { if (parts[0].Equals("ENV")) { // try to get the env variable string value = Environment.GetEnvironmentVariable(parts[1]); if (value != null) { tokenout = value; } } } return(tokenout); }
/// <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); }
public RecreateWorkflowModel() { utils = new JTXUtility() as IJTXSystemUtilities3; var dbmgr = new JTXDatabaseManager(); db = dbmgr.GetActiveDatabase(); }
public void GetSupportedTokens2(IJTXDatabase pDB, out string[] supportedTokens, out string[] tokenDescriptions) { System.Collections.ICollection keys = Environment.GetEnvironmentVariables().Keys; List<string> tokens = new List<string>(); List<string> descriptions = new List<string>(); // Copy each key to the list of tokens, and make it a token foreach (object o in keys) { if (o is string) { string s = o as string; tokens.Add("[ENV:" + s + "]"); } } // Sort the tokens tokens.Sort(); // Get the descriptions for each token foreach (string s in tokens) { string value = null; value = Environment.GetEnvironmentVariable(s.Substring(5,s.Length-6)); if (value != null) descriptions.Add("Current Value: " + value); else descriptions.Add("Current Value: [NOT SET]"); } supportedTokens = tokens.ToArray(); tokenDescriptions = descriptions.ToArray(); }
private void Export(string alias, Dictionary <esriGeometryType, IFeatureClass> fcs) { // Connect to the WMX Repository IJTXDatabaseManager dbMgr = new JTXDatabaseManager(); db = dbMgr.GetDatabase(alias); IJTXTransactionManager transactionMgr = db.TransactionManager; // Get all transactions and insert into the appropriate ouput feature class IJTXTransactionSet transactions = transactionMgr.GetLoggedTransactions(new QueryFilter()); for (int i = 0; i < transactions.Count; i++) { try { IJTXTransaction2 trans = transactions.get_Item(i) as IJTXTransaction2; InsertTransaction(trans, fcs); } catch (Exception) { bInsertErrors = true; } } db = null; }
public string Parse(string sourceText, IJTXDatabase pDB, IJTXJob pJob, ESRI.ArcGIS.esriSystem.IPropertySet pOverrides) { // Find the token string strSource = sourceText; string strFinal = sourceText; int curpos = strSource.IndexOf('['); int startmarker; int endmarker = -1; int nestedcount; int curtokenpos; string strToken; string strNewValue; while (curpos >= 0) { nestedcount = 1; curtokenpos = curpos + 1; strToken = ""; //need to find the whole token (including any nested tokens) while (nestedcount > 0) { startmarker = strSource.IndexOf('[', curtokenpos); endmarker = strSource.IndexOf(']', curtokenpos); if (startmarker >= 0 && startmarker < endmarker) { nestedcount++; curtokenpos = startmarker + 1; } else if (endmarker < 0) { break; } else { nestedcount--; curtokenpos = endmarker + 1; } } if (endmarker >= 0) { strToken = strSource.Substring(curpos, endmarker - curpos + 1); strNewValue = ReplaceToken(strToken, pDB, pJob, pOverrides); strFinal = strFinal.Replace(strToken, strNewValue); } curpos = strSource.IndexOf('[', curpos + 1); } return(strFinal); }
public void GetSupportedTokens2(IJTXDatabase pDB, out string[] supportedTokens, out string[] tokenDescriptions) { System.Collections.ICollection keys = Environment.GetEnvironmentVariables().Keys; List <string> tokens = new List <string>(); List <string> descriptions = new List <string>(); // Copy each key to the list of tokens, and make it a token foreach (object o in keys) { if (o is string) { string s = o as string; tokens.Add("[ENV:" + s + "]"); } } // Sort the tokens tokens.Sort(); // Get the descriptions for each token foreach (string s in tokens) { string value = null; value = Environment.GetEnvironmentVariable(s.Substring(5, s.Length - 6)); if (value != null) { descriptions.Add("Current Value: " + value); } else { descriptions.Add("Current Value: [NOT SET]"); } } supportedTokens = tokens.ToArray(); tokenDescriptions = descriptions.ToArray(); }
/// <summary> /// Called when the step is instantiated in the workflow. /// </summary> /// <param name="ipDatabase">Database connection to the JTX repository.</param> public void OnCreate(IJTXDatabase ipDatabase) { m_ipDatabase = ipDatabase; }
/// <summary> /// Helper function to update the status of a job /// </summary> /// <param name="wmxDb">A reference to the active Workflow Manager database</param> /// <param name="job">The job whose status is to be updated</param> public static void UpdateJobStatus(IJTXDatabase wmxDb, IJTXJob3 job) { // NOTE: The ConfigurationCache must be initialized before calling this function // (this is now handled elsewhere). ESRI.ArcGIS.JTXUI.JobUtilities.UpdateStatusOfJob(wmxDb, job, false); }
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(); } }
public string Parse(string sourceText, IJTXDatabase pDB, IJTXJob pJob, ESRI.ArcGIS.esriSystem.IPropertySet pOverrides) { // Find the token string strSource = sourceText; string strFinal = sourceText; int curpos = strSource.IndexOf('['); int startmarker; int endmarker = -1; int nestedcount; int curtokenpos; string strToken; string strNewValue; while (curpos >= 0) { nestedcount = 1; curtokenpos = curpos + 1; strToken = ""; //need to find the whole token (including any nested tokens) while (nestedcount > 0) { startmarker = strSource.IndexOf('[', curtokenpos); endmarker = strSource.IndexOf(']', curtokenpos); if (startmarker >= 0 && startmarker < endmarker) { nestedcount++; curtokenpos = startmarker + 1; } else if (endmarker < 0) { break; } else { nestedcount--; curtokenpos = endmarker + 1; } } if (endmarker >= 0) { strToken = strSource.Substring(curpos, endmarker - curpos + 1); strNewValue = ReplaceToken(strToken, pDB, pJob, pOverrides); strFinal = strFinal.Replace(strToken, strNewValue); } curpos = strSource.IndexOf('[', curpos + 1); } return strFinal; }
/// <summary> /// Called when the step is instantiated in the workflow. /// </summary> /// <param name="ipDatabase">Database connection to the JTX repository.</param> public void OnCreate(IJTXDatabase ipDatabase) { m_ipDatabase = ipDatabase; m_pStrLogMessages = new StringBuilder(); Log("JTXTempLog: ExecuteGPTool.OnCreate Initializing logging.."); }
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."); } }
public ArgEditor(IJTXDatabase database, string[] expectedArgs) { InitializeComponent(); m_ipDatabase = database; m_expectedArgs = expectedArgs; }
private string ReplaceToken(string token, IJTXDatabase pDB, IJTXJob pJob, ESRI.ArcGIS.esriSystem.IPropertySet pOverrides) { string tokenout = token; // Drop the [] and convert to uppercase token = token.Substring(1,token.Length - 2).ToUpper(); // Split the prefix from the actual token string[] parts = token.Split(new char[] { ':' }, 2); // make sure it is a environment token (starts with "ENV:") if (parts.Length == 2) { if (parts[0].Equals("ENV")) { // try to get the env variable string value = Environment.GetEnvironmentVariable(parts[1]); if (value != null) { tokenout = value; } } } return tokenout; }
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"); } }