/// <summary>
        /// Required by IGPFunction2 interface; this function is called when the GP tool is ready to be executed.
        /// </summary>
        /// <param name="paramValues"></param>
        /// <param name="trackCancel"></param>
        /// <param name="envMgr"></param>
        /// <param name="msgs"></param>
        public override void Execute(IArray paramValues, ITrackCancel trackCancel, IGPEnvironmentManager envMgr, IGPMessages msgs)
        {
            // Do some common error-checking
            base.Execute(paramValues, trackCancel, envMgr, msgs);

            try
            {
                // Update the internal parameters used by this GP tool
                string styleFileName = this.DetermineStyleFileName(this.m_xmlFilePath);

                // Retrieve the TA workbook
                IJTXConfiguration3 defaultDbReadonly      = WmxDatabase.ConfigurationManager as IJTXConfiguration3;
                IJTXTaskAssistantWorkflowRecord tamRecord = defaultDbReadonly.GetTaskAssistantWorkflowRecord(this.m_sourceName);

                // Delete any existing workflow or style files that we're going to replace
                this.DeleteFile(this.m_xmlFilePath);
                this.DeleteFile(styleFileName);

                // Save the TAM workbook data out to file
                this.SaveStringToXmlFile(tamRecord.WorkflowXML, this.m_xmlFilePath);
                this.SaveStringToXmlFile(tamRecord.StyleXML, styleFileName);

                msgs.AddMessage(Properties.Resources.MSG_DONE);
            }
            catch (System.IO.IOException ioEx)
            {
                try
                {
                    WmauError error = new WmauError(WmauErrorCodes.C_FILE_ACCESS_ERROR);
                    msgs.AddError(error.ErrorCodeAsInt, error.Message + "; " + ioEx.Message);
                }
                catch
                {
                    // Catch anything else that possibly happens
                }
            }
            catch (WmauException wmEx)
            {
                try
                {
                    msgs.AddError(wmEx.ErrorCodeAsInt, wmEx.Message);
                }
                catch
                {
                    // Catch anything else that possibly happens
                }
            }
            catch (Exception ex)
            {
                try
                {
                    WmauError error = new WmauError(WmauErrorCodes.C_TAM_DOWNLOAD_ERROR);
                    msgs.AddError(error.ErrorCodeAsInt, error.Message + "; " + ex.Message);
                }
                catch
                {
                    // Catch anything else that possibly happens
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Post validates the given set of values.
        /// This is where you flag parameters with warnings and error messages, among other things.
        /// </summary>
        /// <param name="paramValues"></param>
        /// <param name="pEnvMgr"></param>
        /// <param name="msgs"></param>
        public override void UpdateMessages(IArray paramValues, IGPEnvironmentManager pEnvMgr, IGPMessages msgs)
        {
            // Call the base class function first
            try
            {
                UpdateMessagesCommon(paramValues, pEnvMgr, msgs);
            }
            catch (WmxDefaultDbNotSetException)
            {
                // If the default DB wasn't set, stop executing
                return;
            }

            // Build a hash of which parameter is at which index, for ease of access
            WmauParameterMap paramMap = new WmauParameterMap(paramValues);

            IGPParameter3 dataWorkspace = paramMap.GetParam(C_PARAM_DATA_WORKSPACE);

            // Ensure that there is at least one data workspace defined in the database
            if (dataWorkspace.Domain == null || (dataWorkspace.Domain as IGPCodedValueDomain).CodeCount <= 0)
            {
                WmauError error = new WmauError(WmauErrorCodes.C_NO_WORKSPACES_DEFINED_ERROR);
                msgs.ReplaceError(paramMap.GetIndex(C_PARAM_DATA_WORKSPACE), error.ErrorCodeAsInt, error.Message);
            }
        }
コード例 #3
0
        /// <summary>
        /// Required by IGPFunction2 interface; this function is called when the GP tool is ready to be executed.
        /// </summary>
        /// <param name="paramValues"></param>
        /// <param name="trackCancel"></param>
        /// <param name="envMgr"></param>
        /// <param name="msgs"></param>
        public override void Execute(IArray paramValues, ITrackCancel trackCancel, IGPEnvironmentManager envMgr, IGPMessages msgs)
        {
            // Do some common error-checking
            base.Execute(paramValues, trackCancel, envMgr, msgs);

            try
            {
                // Ensure that the current user has admin access to the current Workflow Manager DB
                if (!CurrentUserIsWmxAdministrator())
                {
                    throw new WmauException(WmauErrorCodes.C_USER_NOT_ADMIN_ERROR);
                }

                // Retrieve the parameter in which the list of MXDs will be stored
                WmauParameterMap  paramMap  = new WmauParameterMap(paramValues);
                IGPParameter3     param     = paramMap.GetParam(C_PARAM_MAP_DOCUMENT_LIST);
                IGPParameterEdit3 paramEdit = paramMap.GetParamEdit(C_PARAM_MAP_DOCUMENT_LIST);

                // Set up the multi-value objects
                IGPMultiValue mvValue = new GPMultiValueClass();
                mvValue.MemberDataType = param.DataType;

                // Get the list of MXD names and add them all to the multivalue
                SortedList <string, string> mapDocuments = this.ListMapDocumentsInDatabase();
                foreach (string mapDocName in mapDocuments.Keys)
                {
                    IGPString strVal = new GPStringClass();
                    strVal.Value = mapDocName;
                    mvValue.AddValue(strVal as IGPValue);
                    msgs.AddMessage("Map Document: " + mapDocName);
                }

                paramEdit.Value = (IGPValue)mvValue;

                msgs.AddMessage(Properties.Resources.MSG_DONE);
            }
            catch (WmauException wmEx)
            {
                try
                {
                    msgs.AddError(wmEx.ErrorCodeAsInt, wmEx.Message);
                }
                catch
                {
                    // Catch anything else that possibly happens
                }
            }
            catch (Exception ex)
            {
                try
                {
                    WmauError error = new WmauError(WmauErrorCodes.C_UNSPECIFIED_ERROR);
                    msgs.AddError(error.ErrorCodeAsInt, error.Message + "; " + ex.Message);
                }
                catch
                {
                    // Catch anything else that possibly happens
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// Required by IGPFunction2 interface; this function is called when the GP tool is ready to be executed.
        /// </summary>
        /// <param name="paramValues"></param>
        /// <param name="trackCancel"></param>
        /// <param name="envMgr"></param>
        /// <param name="msgs"></param>
        public override void Execute(IArray paramValues, ITrackCancel trackCancel, IGPEnvironmentManager envMgr, IGPMessages msgs)
        {
            // Do some common error-checking
            base.Execute(paramValues, trackCancel, envMgr, msgs);

            // Close the requested job
            try
            {
                IJTXJobManager     jobManager = this.WmxDatabase.JobManager;
                IJTXJob3           job        = jobManager.GetJob(m_jobToClose) as IJTXJob3;
                IJTXConfiguration3 configMgr  = this.WmxDatabase.ConfigurationManager as IJTXConfiguration3;

                if (job.Stage != jtxJobStage.jtxJobStageClosed && !job.CanClose())
                {
                    throw new WmauException(WmauErrorCodes.C_CANNOT_CLOSE_JOB_ERROR);
                }

                msgs.AddMessage("Closing job " + m_jobToClose + " (" + job.Name + ")");
                job.Close();

                // Once the job is closed, do the other things that still need to be handled
                // separately (status updates, notifications, ...)
                Common.WmauHelperFunctions.UpdateJobStatus(this.WmxDatabase, job);
                job.Store();

                job.LogJobAction(
                    configMgr.GetActivityType(ESRI.ArcGIS.JTX.Utilities.Constants.ACTTYPE_CLOSE_JOB),
                    null,
                    string.Empty);
                Common.WmauHelperFunctions.SendNotification(
                    ESRI.ArcGIS.JTX.Utilities.Constants.NOTIF_JOB_CLOSED,
                    this.WmxDatabase,
                    job);

                // Set the output parameter
                WmauParameterMap  paramMap     = new WmauParameterMap(paramValues);
                IGPParameterEdit3 outParamEdit = paramMap.GetParamEdit(C_PARAM_JOB_CLOSED);
                IGPLong           outValue     = new GPLongClass();
                outValue.Value     = m_jobToClose;
                outParamEdit.Value = outValue as IGPValue;

                msgs.AddMessage(Properties.Resources.MSG_DONE);
            }
            catch (WmauException wmEx)
            {
                try
                {
                    msgs.AddError(wmEx.ErrorCodeAsInt, wmEx.Message);
                }
                catch
                {
                    // Catch anything else that possibly happens
                }
            }
            catch (Exception ex)
            {
                WmauError error = new WmauError(WmauErrorCodes.C_UNSPECIFIED_ERROR);
                msgs.AddError(error.ErrorCodeAsInt, error.Message + "; " + ex.Message);
            }
        }
        /// <summary>
        /// Post validates the given set of values.
        /// This is where you flag parameters with warnings and error messages, among other things.
        /// </summary>
        /// <param name="paramValues"></param>
        /// <param name="pEnvMgr"></param>
        /// <param name="msgs"></param>
        public override void UpdateMessages(IArray paramValues, IGPEnvironmentManager pEnvMgr, IGPMessages msgs)
        {
            try
            {
                UpdateMessagesCommon(paramValues, pEnvMgr, msgs);
            }
            catch (WmxDefaultDbNotSetException)
            {
                // If the default DB wasn't set, stop executing
                return;
            }

            // Build a hash of which parameter is at which index for ease of access
            WmauParameterMap paramMap          = new WmauParameterMap(paramValues);
            IGPParameter3    dataWorkspaceName = paramMap.GetParam(C_PARAM_DATA_WORKSPACE);
            IGPParameter3    parentVersion     = paramMap.GetParam(C_PARAM_PARENT_VERSION);

            // If there's no domain on the parent version parameter, then something went
            // awry
            if (parentVersion.Domain == null)
            {
                WmauError error = new WmauError(WmauErrorCodes.C_VERSION_LOOKUP_ERROR);
                msgs.ReplaceError(paramMap.GetIndex(C_PARAM_PARENT_VERSION), error.ErrorCodeAsInt, error.Message);
            }

            // Store away the latest value of the data workspace
            m_dataWorkspaceName = dataWorkspaceName.Value.GetAsText();
        }
コード例 #6
0
        /// <summary>
        /// Required by IGPFunction2 interface; this function is called when the GP tool is ready to be executed.
        /// </summary>
        /// <param name="paramValues"></param>
        /// <param name="trackCancel"></param>
        /// <param name="envMgr"></param>
        /// <param name="msgs"></param>
        public override void Execute(IArray paramValues, ITrackCancel trackCancel, IGPEnvironmentManager envMgr, IGPMessages msgs)
        {
            // Do some common error-checking
            base.Execute(paramValues, trackCancel, envMgr, msgs);

            try
            {
                WmauParameterMap   paramMap  = new WmauParameterMap(paramValues);
                IJTXConfiguration3 configMgr = this.WmxDatabase.ConfigurationManager as IJTXConfiguration3;

                // Determine which query the user has selected
                SortedList <string, IJTXJobQuery> queryMap = new SortedList <string, IJTXJobQuery>();
                AddQueriesFromContainer(configMgr.GetPublicQueryContainer(), string.Empty, queryMap);
                if (!queryMap.Keys.Contains(m_queryName))
                {
                    throw new WmauException(WmauErrorCodes.C_UNKNOWN_QUERY_ERROR);
                }

                // Run the selected job query
                IJTXJobQuery tempQuery = queryMap[m_queryName];

                // TODO: Change this to use ".Evaluate()" once it's fixed
                List <int> jobIds = ParseJobIdsFromXml(tempQuery.EvaluateXML());
                jobIds.Sort();

                // Store the job IDs from the query into the output GP param
                IGPMultiValue outputValues = new GPMultiValueClass();
                outputValues.MemberDataType = paramMap.GetParam(C_PARAM_OUT_JOB_ID_LIST).DataType;
                for (int i = 0; i < jobIds.Count; i++)
                {
                    IGPLong jobIdVal = new GPLongClass();
                    jobIdVal.Value = jobIds[i];
                    outputValues.AddValue(jobIdVal as IGPValue);
                    msgs.AddMessage("Found job: " + jobIds[i]);
                }

                paramMap.GetParamEdit(C_PARAM_OUT_JOB_ID_LIST).Value = (IGPValue)outputValues;

                msgs.AddMessage(Properties.Resources.MSG_DONE);
            }
            catch (WmauException wmEx)
            {
                try
                {
                    msgs.AddError(wmEx.ErrorCodeAsInt, wmEx.Message);
                }
                catch
                {
                    // Catch anything else that possibly happens
                }
            }
            catch (Exception ex)
            {
                WmauError error = new WmauError(WmauErrorCodes.C_UNSPECIFIED_ERROR);
                msgs.AddError(error.ErrorCodeAsInt, error.Message + "; " + ex.Message);
            }
        }
コード例 #7
0
        /// <summary>
        /// Post validates the given set of values.
        /// This is where you flag parameters with warnings and error messages, among other things.
        /// </summary>
        /// <param name="paramValues"></param>
        /// <param name="pEnvMgr"></param>
        /// <param name="msgs"></param>
        public override void UpdateMessages(IArray paramValues, IGPEnvironmentManager pEnvMgr, IGPMessages msgs)
        {
            // Call the base class function first
            try
            {
                UpdateMessagesCommon(paramValues, pEnvMgr, msgs);
            }
            catch (WmxDefaultDbNotSetException)
            {
                // If the default DB wasn't set, stop executing
                return;
            }

            // Build a hash of which parameter is at which index, for ease of access
            WmauParameterMap paramMap = new WmauParameterMap(paramValues);

            IGPParameter3     snName     = paramMap.GetParam(C_PARAM_SPATIAL_NOTIFICATION);
            IGPParameter3     altAoi     = paramMap.GetParam(C_PARAM_ALTERNATE_AOI);
            IGPParameterEdit3 altAoiEdit = paramMap.GetParamEdit(C_PARAM_ALTERNATE_AOI);

            // Ensure that there is at least one existing spatial notification in the database
            if (snName.Domain == null || (snName.Domain as IGPCodedValueDomain).CodeCount <= 0)
            {
                WmauError error = new WmauError(WmauErrorCodes.C_NO_SPATIAL_NOTIFICATIONS_FOUND);
                msgs.ReplaceError(paramMap.GetIndex(C_PARAM_SPATIAL_NOTIFICATION), error.ErrorCodeAsInt, error.Message);
            }

            // Check the AOI; ensure that there is exactly one feature selected
            if (altAoi.Value != null && !altAoi.Value.GetAsText().Equals(string.Empty))
            {
                try
                {
                    ILayer            aoiLayer  = m_gpUtilities.DecodeLayer(altAoi.Value);
                    IFeatureLayer     featLayer = aoiLayer as IFeatureLayer;
                    IFeatureSelection featSel   = aoiLayer as IFeatureSelection;
                    ISelectionSet     selSet    = featSel.SelectionSet as ISelectionSet;

                    if (featLayer.FeatureClass.ShapeType != esriGeometryType.esriGeometryPolygon)
                    {
                        WmauError error = new WmauError(WmauErrorCodes.C_AOI_NOT_POLYGON_ERROR);
                        msgs.ReplaceWarning(paramMap.GetIndex(C_PARAM_ALTERNATE_AOI), error.Message);
                    }
                    else if (selSet.Count != 1)
                    {
                        WmauError error = new WmauError(WmauErrorCodes.C_EXPECTED_ONE_SELECTED_FEATURE_ERROR);
                        msgs.ReplaceWarning(paramMap.GetIndex(C_PARAM_ALTERNATE_AOI), error.Message);
                    }
                }
                catch (System.Runtime.InteropServices.COMException comEx)
                {
                    WmauError error = new WmauError(WmauErrorCodes.C_AOI_INPUT_ERROR);
                    msgs.ReplaceError(paramMap.GetIndex(C_PARAM_ALTERNATE_AOI), error.ErrorCodeAsInt, error.Message + "; " + comEx.Message);
                }
            }
        }
コード例 #8
0
        /// <summary>
        /// Required by IGPFunction2 interface; this function is called when the GP tool is ready to be executed.
        /// </summary>
        /// <param name="paramValues"></param>
        /// <param name="trackCancel"></param>
        /// <param name="envMgr"></param>
        /// <param name="msgs"></param>
        public override void Execute(IArray paramValues, ITrackCancel trackCancel, IGPEnvironmentManager envMgr, IGPMessages msgs)
        {
            // Do some common error-checking
            base.Execute(paramValues, trackCancel, envMgr, msgs);

            try
            {
                // Ensure that the current user has admin access to the current Workflow Manager DB
                if (!CurrentUserIsWmxAdministrator())
                {
                    throw new WmauException(WmauErrorCodes.C_USER_NOT_ADMIN_ERROR);
                }

                // Retrieve the MXD and delete it
                IJTXConfiguration3 configMgr = WmxDatabase.ConfigurationManager as IJTXConfiguration3;
                IJTXMap            map       = configMgr.GetJTXMap(m_mxdName);
                configMgr.DeleteJTXMap(map.ID);

                // Update the output parameter
                WmauParameterMap  paramMap     = new WmauParameterMap(paramValues);
                IGPParameterEdit3 outParamEdit = paramMap.GetParamEdit(C_PARAM_OUT_MXD_NAME);
                IGPString         outValue     = new GPStringClass();
                outValue.Value     = m_mxdName;
                outParamEdit.Value = outValue as IGPValue;

                msgs.AddMessage(Properties.Resources.MSG_DONE);
            }
            catch (WmauException wmEx)
            {
                try
                {
                    msgs.AddError(wmEx.ErrorCodeAsInt, wmEx.Message);
                }
                catch
                {
                    // Catch anything else that possibly happens
                }
            }
            catch (Exception ex)
            {
                try
                {
                    WmauError error = new WmauError(WmauErrorCodes.C_DELETE_MXD_ERROR);
                    msgs.AddError(error.ErrorCodeAsInt, error.Message + "; " + ex.Message);
                }
                catch
                {
                    // Catch anything else that possibly happens
                }
            }
            finally
            {
                // Release any COM objects here!
            }
        }
コード例 #9
0
        /// <summary>
        /// Required by IGPFunction2 interface; this function is called when the GP tool is ready to be executed.
        /// </summary>
        /// <param name="paramValues"></param>
        /// <param name="trackCancel"></param>
        /// <param name="envMgr"></param>
        /// <param name="msgs"></param>
        public override void Execute(IArray paramValues, ITrackCancel trackCancel, IGPEnvironmentManager envMgr, IGPMessages msgs)
        {
            // Do some common error-checking
            base.Execute(paramValues, trackCancel, envMgr, msgs);

            // Assign the requested job
            try
            {
                IJTXJobManager     jobManager = this.WmxDatabase.JobManager;
                IJTXConfiguration3 configMgr  = this.WmxDatabase.ConfigurationManager as IJTXConfiguration3;
                IJTXJob3           job        = jobManager.GetJob(m_jobId) as IJTXJob3;

                // As of Jan. 2011, the core Workflow Manager libraries do not
                // seem to check if the user has the privilege to add a comment
                // if a job as a hold on it.  So run the check here.
                IJTXJobHolds jobHolds = job as IJTXJobHolds;
                if (jobHolds.Holds != null &&
                    jobHolds.Holds.Count > 0 &&
                    !CurrentUserHasPrivilege(ESRI.ArcGIS.JTX.Utilities.Constants.PRIV_CAN_ADD_COMMENTS_FOR_HELD_JOBS))
                {
                    throw new WmauException(WmauErrorCodes.C_NO_ADD_COMMENTS_HELD_JOBS_ERROR);
                }

                // If we get this far, then add the comment to the job.
                IJTXActivityType commentType = configMgr.GetActivityType(ESRI.ArcGIS.JTX.Utilities.Constants.ACTTYPE_COMMENT);
                job.LogJobAction(commentType, null, m_comment);
                job.Store();

                // Set the output parameter
                WmauParameterMap  paramMap     = new WmauParameterMap(paramValues);
                IGPParameterEdit3 outParamEdit = paramMap.GetParamEdit(C_PARAM_OUT_JOB_ID);
                IGPLong           outValue     = new GPLongClass();
                outValue.Value     = m_jobId;
                outParamEdit.Value = outValue as IGPValue;

                msgs.AddMessage(Properties.Resources.MSG_DONE);
            }
            catch (WmauException wmEx)
            {
                try
                {
                    msgs.AddError(wmEx.ErrorCodeAsInt, wmEx.Message);
                }
                catch
                {
                    // Catch anything else that possibly happens
                }
            }
            catch (Exception ex)
            {
                WmauError error = new WmauError(WmauErrorCodes.C_UNSPECIFIED_ERROR);
                msgs.AddError(error.ErrorCodeAsInt, error.Message + "; " + ex.Message);
            }
        }
コード例 #10
0
        /// <summary>
        /// Required by IGPFunction2 interface; this function is called when the GP tool is ready to be executed.
        /// </summary>
        /// <param name="paramValues"></param>
        /// <param name="trackCancel"></param>
        /// <param name="envMgr"></param>
        /// <param name="msgs"></param>
        public override void Execute(IArray paramValues, ITrackCancel trackCancel, IGPEnvironmentManager envMgr, IGPMessages msgs)
        {
            // Do some common error-checking
            base.Execute(paramValues, trackCancel, envMgr, msgs);

            try
            {
                WmauParameterMap paramMap = new WmauParameterMap(paramValues);

                // Retrieve the parameter in which the list of workbook names will be stored
                IGPParameter3     param       = paramMap.GetParam(C_PARAM_JOB_ID_LIST);
                IGPParameterEdit3 paramEdit   = paramMap.GetParamEdit(C_PARAM_JOB_ID_LIST);
                IGPParameter3     filterParam = paramMap.GetParam(C_PARAM_SQL_QUERY_FILTER);

                // Get the multivalue object into which the output will be stored
                IGPMultiValue outputValues = new GPMultiValueClass();
                outputValues.MemberDataType = param.DataType;
                for (int i = 0; i < outputValues.Count; i++)
                {
                    outputValues.Remove(i);
                }

                // Get the list of job IDs and add them all to the multivalue
                SortedList <int, string> jobs = this.ListJobsInDatabase(filterParam.Value.GetAsText());
                msgs.AddMessage("Jobs matching query:");
                foreach (KeyValuePair <int, string> item in jobs)
                {
                    IGPLong value = new GPLongClass();
                    value.Value = item.Key;
                    outputValues.AddValue(value as IGPValue);
                    msgs.AddMessage("  " + value.Value.ToString() + " (" + item.Value + ")");
                }

                paramEdit.Value = (IGPValue)outputValues;

                msgs.AddMessage(Properties.Resources.MSG_DONE);
            }
            catch (WmauException wmEx)
            {
                try
                {
                    msgs.AddError(wmEx.ErrorCodeAsInt, wmEx.Message);
                }
                catch
                {
                    // Catch anything else that possibly happens
                }
            }
            catch (Exception ex)
            {
                WmauError error = new WmauError(WmauErrorCodes.C_UNSPECIFIED_ERROR);
                msgs.AddError(error.ErrorCodeAsInt, error.Message + "; " + ex.Message);
            }
        }
コード例 #11
0
        /// <summary>
        /// Required by IGPFunction2 interface; this function is called when the GP tool is ready to be executed.
        /// </summary>
        /// <param name="paramValues"></param>
        /// <param name="trackCancel"></param>
        /// <param name="envMgr"></param>
        /// <param name="msgs"></param>
        public override void Execute(IArray paramValues, ITrackCancel trackCancel, IGPEnvironmentManager envMgr, IGPMessages msgs)
        {
            // Do some common error-checking
            base.Execute(paramValues, trackCancel, envMgr, msgs);

            try
            {
                // Retrieve the parameter in which the list of workbook names will be stored
                WmauParameterMap  paramMap  = new WmauParameterMap(paramValues);
                IGPParameter3     param     = paramMap.GetParam(C_PARAM_TAM_WORKBOOK_LIST);
                IGPParameterEdit3 paramEdit = paramMap.GetParamEdit(C_PARAM_TAM_WORKBOOK_LIST);

                // Set up the multi-value objects
                IGPMultiValue mvValue = new GPMultiValueClass();
                mvValue.MemberDataType = param.DataType;

                // Get the list of TA workbook names and add them all to the multivalue
                SortedList <string, string> tamWorkbooks = this.ListTamWorkbooksInDatabase();
                foreach (string workbookAlias in tamWorkbooks.Keys)
                {
                    IGPString strVal = new GPStringClass();
                    strVal.Value = workbookAlias;
                    mvValue.AddValue(strVal as IGPValue);
                    msgs.AddMessage("Workbook: " + workbookAlias);
                }

                paramEdit.Value = (IGPValue)mvValue;

                msgs.AddMessage(Properties.Resources.MSG_DONE);
            }
            catch (WmauException wmEx)
            {
                try
                {
                    msgs.AddError(wmEx.ErrorCodeAsInt, wmEx.Message);
                }
                catch
                {
                    // Catch anything else that possibly happens
                }
            }
            catch (Exception ex)
            {
                try
                {
                    WmauError error = new WmauError(WmauErrorCodes.C_UNSPECIFIED_ERROR);
                    msgs.AddError(error.ErrorCodeAsInt, error.Message + "; " + ex.Message);
                }
                catch
                {
                    // Catch anything else that possibly happens
                }
            }
        }
コード例 #12
0
        /// <summary>
        /// Required by IGPFunction2 interface; this function is called when the GP tool is ready to be executed.
        /// </summary>
        /// <param name="paramValues"></param>
        /// <param name="trackCancel"></param>
        /// <param name="envMgr"></param>
        /// <param name="msgs"></param>
        public override void Execute(IArray paramValues, ITrackCancel trackCancel, IGPEnvironmentManager envMgr, IGPMessages msgs)
        {
            // Do some common error-checking
            base.Execute(paramValues, trackCancel, envMgr, msgs);

            // Assign the requested job
            try
            {
                IJTXJobManager         jobManager = this.WmxDatabase.JobManager;
                IJTXWorkflowExecution3 jobExec    = jobManager.GetJob(m_jobId) as IJTXWorkflowExecution3;

                // Don't try to deal with the case of multiple active steps
                int[] currentStepIds = jobExec.GetCurrentSteps();
                if (currentStepIds.Length != 1)
                {
                    throw new WmauException(WmauErrorCodes.C_NO_OR_MULTIPLE_STEPS_ERROR);
                }

                jobExec.RunStepChecks(currentStepIds[0], true);
                IJTXExecuteInfo execInfo = jobExec.RunStep(currentStepIds[0], false, true, false, this);
                if (execInfo.ThrewError)
                {
                    throw new WmauException(
                              WmauErrorCodes.C_JOB_EXECUTION_ERROR,
                              new Exception(execInfo.ErrorCode.ToString() + ": " + execInfo.ErrorDescription));
                }

                // Set the output parameter
                WmauParameterMap  paramMap     = new WmauParameterMap(paramValues);
                IGPParameterEdit3 outParamEdit = paramMap.GetParamEdit(C_PARAM_OUT_JOB_ID);
                IGPLong           outValue     = new GPLongClass();
                outValue.Value     = m_jobId;
                outParamEdit.Value = outValue as IGPValue;

                msgs.AddMessage(Properties.Resources.MSG_DONE);
            }
            catch (WmauException wmEx)
            {
                try
                {
                    msgs.AddError(wmEx.ErrorCodeAsInt, wmEx.Message);
                }
                catch
                {
                    // Catch anything else that possibly happens
                }
            }
            catch (Exception ex)
            {
                WmauError error = new WmauError(WmauErrorCodes.C_UNSPECIFIED_ERROR);
                msgs.AddError(error.ErrorCodeAsInt, error.Message + "; " + ex.Message);
            }
        }
コード例 #13
0
        /// <summary>
        /// Mandatory override. Provide GP tool body and logic.
        /// </summary>
        public virtual void Execute(IArray paramValues, ITrackCancel trackCancel, IGPEnvironmentManager envMgr, IGPMessages msgs)
        {
            // Basic error checking; ensure a Workflow Manager database is defined
            if (!IsWorkflowManagerDatabaseSet())
            {
                WmauError error = new WmauError(WmauErrorCodes.C_INVALID_WMX_DB_ERROR);
                msgs.AddError(error.ErrorCodeAsInt, error.Message);
                throw new WmxDefaultDbNotSetException();
            }

            // Update the internal parameters used by this GP tool
            this.ExtractParameters(paramValues);
        }
コード例 #14
0
        /// <summary>
        /// Helper function for the "UpdateMessages" interface; meant to be called directly by
        /// child classes who override "UpdateMessages", rather than calling "UpdateMessages"
        /// itself.
        /// </summary>
        /// <param name="paramValues">The IArray of parameters passed into UpdateMessages</param>
        /// <param name="pEnvMgr">The GP environment manager object</param>
        /// <param name="msgs">The GP messages object to be updated by this function</param>
        protected void UpdateMessagesCommon(IArray paramValues, IGPEnvironmentManager pEnvMgr, IGPMessages msgs)
        {
            // Ensure that a Workflow Manager database is set.
            if (!IsWorkflowManagerDatabaseSet())
            {
                if (msgs.Count > 0)
                {
                    WmauParameterMap paramMap = new WmauParameterMap(paramValues);
                    WmauError        error    = new WmauError(WmauErrorCodes.C_INVALID_WMX_DB_ERROR);
                    msgs.ReplaceError(paramMap.GetIndex(C_PARAM_WMX_DATABASE_ALIAS), error.ErrorCodeAsInt, error.Message);
                }

                throw new WmxDefaultDbNotSetException();
            }
        }
コード例 #15
0
        /// <summary>
        /// Opens up the workbook, using the filename specified
        /// </summary>
        /// <returns></returns>
        public bool Open()
        {
            if (!IsOpen)
            {
                try
                {
                    m_excelObj = new Application();
                    m_workbook = OpenWorkbook(m_excelObj);
                    m_isOpen   = true;
                }
                catch (NullReferenceException nullEx)
                {
                    WmauError error = new WmauError(WmauErrorCodes.C_EXCEL_WORKBOOK_ERROR);
                    this.m_gpMessages.AddError(error.ErrorCodeAsInt, error.Message + "; Stack Trace: " + nullEx.StackTrace);
                    Close();
                }
            }

            return(IsOpen);
        }
コード例 #16
0
        /// <summary>
        /// Post validates the given set of values.
        /// This is where you flag parameters with warnings and error messages, among other things.
        /// </summary>
        /// <param name="paramValues"></param>
        /// <param name="pEnvMgr"></param>
        /// <param name="msgs"></param>
        public override void UpdateMessages(IArray paramValues, IGPEnvironmentManager pEnvMgr, IGPMessages msgs)
        {
            try
            {
                UpdateMessagesCommon(paramValues, pEnvMgr, msgs);
            }
            catch (WmxDefaultDbNotSetException)
            {
                // If the default DB wasn't set, stop executing
                return;
            }

            // Build a hash of which parameter is at which index for ease of access
            WmauParameterMap paramMap = new WmauParameterMap(paramValues);

            // Ensure that the current user has permissions to be adding attachments to jobs
            if (!CurrentUserHasPrivilege(ESRI.ArcGIS.JTX.Utilities.Constants.PRIV_MANAGE_ATTACHMENTS))
            {
                WmauError error = new WmauError(WmauErrorCodes.C_NO_MANAGE_ATTACHMENTS_PRIV_ERROR);
                msgs.ReplaceError(paramMap.GetIndex(C_PARAM_JOB_ID), error.ErrorCodeAsInt, error.Message);
            }
        }
コード例 #17
0
        /// <summary>
        /// Required by IGPFunction2 interface; this function is called when the GP tool is ready to be executed.
        /// </summary>
        /// <param name="paramValues"></param>
        /// <param name="trackCancel"></param>
        /// <param name="envMgr"></param>
        /// <param name="msgs"></param>
        public override void Execute(IArray paramValues, ITrackCancel trackCancel, IGPEnvironmentManager envMgr, IGPMessages msgs)
        {
            // Do some common error-checking
            base.Execute(paramValues, trackCancel, envMgr, msgs);

            try
            {
                // Send the notification
                IJTXJobManager jobManager = this.WmxDatabase.JobManager;
                Common.WmauHelperFunctions.SendNotification(
                    m_notificationName, this.WmxDatabase, jobManager.GetJob(m_jobId));

                // Set the output parameter
                WmauParameterMap  paramMap     = new WmauParameterMap(paramValues);
                IGPParameterEdit3 outParamEdit = paramMap.GetParamEdit(C_PARAM_OUT_JOB_ID);
                IGPLong           outValue     = new GPLongClass();
                outValue.Value     = m_jobId;
                outParamEdit.Value = outValue as IGPValue;

                msgs.AddMessage(Properties.Resources.MSG_DONE);
            }
            catch (WmauException wmEx)
            {
                try
                {
                    msgs.AddError(wmEx.ErrorCodeAsInt, wmEx.Message);
                }
                catch
                {
                    // Catch anything else that possibly happens
                }
            }
            catch (Exception ex)
            {
                WmauError error = new WmauError(WmauErrorCodes.C_UNSPECIFIED_ERROR);
                msgs.AddError(error.ErrorCodeAsInt, error.Message + "; " + ex.Message);
            }
        }
コード例 #18
0
        /// <summary>
        /// Post validates the given set of values.
        /// This is where you flag parameters with warnings and error messages, among other things.
        /// </summary>
        /// <param name="paramValues"></param>
        /// <param name="pEnvMgr"></param>
        /// <param name="msgs"></param>
        public override void UpdateMessages(IArray paramValues, IGPEnvironmentManager pEnvMgr, IGPMessages msgs)
        {
            // Call the base class function first
            try
            {
                UpdateMessagesCommon(paramValues, pEnvMgr, msgs);
            }
            catch (WmxDefaultDbNotSetException)
            {
                // If the default DB wasn't set, stop executing
                return;
            }

            // Build a hash of which parameter is at which index for ease of access
            WmauParameterMap paramMap = new WmauParameterMap(paramValues);

            IGPParameter3     snNameParam     = paramMap.GetParam(C_PARAM_NAME);
            IGPParameterEdit3 snNameParamEdit = paramMap.GetParamEdit(C_PARAM_NAME);

            // Ensure that the named spatial notification doesn't already exist
            if (snNameParam.Value != null && !snNameParam.Value.GetAsText().Equals(string.Empty))
            {
                IJTXDatabase2     db             = this.WmxDatabase as IJTXDatabase2;
                string            changeRuleName = snNameParam.Value.GetAsText();
                IJTXChangeRuleSet allChangeRules = db.SpatialNotificationManager.ChangeRules;
                for (int i = 0; i < allChangeRules.Count; i++)
                {
                    IJTXChangeRule tempRule = allChangeRules.get_Item(i);
                    if (tempRule.Name.Equals(snNameParam.Value.GetAsText()))
                    {
                        WmauError error = new WmauError(WmauErrorCodes.C_SN_EXISTS_ERROR);
                        msgs.ReplaceError(paramMap.GetIndex(C_PARAM_NAME), error.ErrorCodeAsInt, error.Message);
                        break;
                    }
                }
            }
        }
コード例 #19
0
 /// <summary>
 /// Default constructor; sets up a default error type
 /// </summary>
 private WmauException() : base()
 {
     m_errorDetails = new WmauError();
 }
        /// <summary>
        /// Required by IGPFunction2 interface; this function is called when the GP tool is ready to be executed.
        /// </summary>
        /// <param name="paramValues"></param>
        /// <param name="trackCancel"></param>
        /// <param name="envMgr"></param>
        /// <param name="msgs"></param>
        public override void Execute(IArray paramValues, ITrackCancel trackCancel, IGPEnvironmentManager envMgr, IGPMessages msgs)
        {
            // Do some common error-checking
            base.Execute(paramValues, trackCancel, envMgr, msgs);

            try
            {
                // Ensure that the current user has admin access to the current Workflow Manager DB
                if (!CurrentUserIsWmxAdministrator())
                {
                    throw new WmauException(WmauErrorCodes.C_USER_NOT_ADMIN_ERROR);
                }

                // Stash away the executing user's information, if appropriate
                string             username      = ESRI.ArcGIS.JTXUI.ConfigurationCache.GetCurrentSystemUser(ESRI.ArcGIS.JTXUI.ConfigurationCache.UseUserDomain);
                IJTXConfiguration3 configMgr     = this.WmxDatabase.ConfigurationManager as IJTXConfiguration3;
                IJTXUser3          executingUser = configMgr.GetUser(username) as IJTXUser3;

                // Import the AD information
                string domain         = System.Environment.UserDomainName;
                string domainUsername = string.Empty;
                string domainPassword = string.Empty;
                int    numUsers       = 0;
                int    numGroups      = 0;
                ActiveDirectoryHelper.SyncronizeJTXDatabaseWithActiveDirectory(this.WmxDatabase, domain, domainUsername, domainPassword, m_userGroup, m_groupGroup, out numGroups, out numUsers);

                // If the tool was set to preserve the current user's account and the user
                // was removed from the DB, then re-add their account
                if (configMgr.GetUser(username) == null)
                {
                    if (m_preserveCurrentUser)
                    {
                        IJTXConfigurationEdit2 configEdit = this.WmxDatabase.ConfigurationManager as IJTXConfigurationEdit2;
                        IJTXUserConfig         newUser    = configEdit.CreateUser() as IJTXUserConfig;
                        newUser.FirstName_2 = executingUser.FirstName;
                        newUser.FullName_2  = executingUser.FullName;
                        newUser.LastName_2  = executingUser.LastName;
                        newUser.UserName_2  = executingUser.UserName;
                        (newUser as IJTXUser3).IsAdministrator = executingUser.IsAdministrator;
                        newUser.Store();

                        msgs.AddMessage("User '" + username + "' not found in Active Directory group '" + m_userGroup + "'; re-added placeholder to Workflow Manager database");
                    }
                    else
                    {
                        msgs.AddWarning("User '" + username + "' removed from Workflow Manager database");
                    }
                }

                // Update the output parameters
                WmauParameterMap  paramMap = new WmauParameterMap(paramValues);
                IGPParameterEdit3 outParam = paramMap.GetParamEdit(C_PARAM_OUT_NUM_USERS);
                IGPLong           value    = new GPLongClass();
                value.Value    = numUsers;
                outParam.Value = value as IGPValue;

                outParam       = paramMap.GetParamEdit(C_PARAM_OUT_NUM_GROUPS);
                value          = new GPLongClass();
                value.Value    = numGroups;
                outParam.Value = value as IGPValue;

                msgs.AddMessage(Properties.Resources.MSG_DONE);
            }
            catch (WmauException wmEx)
            {
                try
                {
                    msgs.AddError(wmEx.ErrorCodeAsInt, wmEx.Message);
                }
                catch
                {
                    // Catch anything else that possibly happens
                }
            }
            catch (Exception ex)
            {
                try
                {
                    WmauError error = new WmauError(WmauErrorCodes.C_UNSPECIFIED_ERROR);
                    msgs.AddError(error.ErrorCodeAsInt, error.Message + "; " + ex.Message);
                }
                catch
                {
                    // Catch anything else that possibly happens
                }
            }
            finally
            {
                // Release any COM objects here!
            }
        }
コード例 #21
0
        /// <summary>
        /// Required by IGPFunction2 interface; this function is called when the GP tool is ready to be executed.
        /// </summary>
        /// <param name="paramValues"></param>
        /// <param name="trackCancel"></param>
        /// <param name="envMgr"></param>
        /// <param name="msgs"></param>
        public override void Execute(IArray paramValues, ITrackCancel trackCancel, IGPEnvironmentManager envMgr, IGPMessages msgs)
        {
            // Do some common error-checking
            base.Execute(paramValues, trackCancel, envMgr, msgs);

            try
            {
                // Ensure that the current user has admin access to the current Workflow Manager DB
                if (!CurrentUserIsWmxAdministrator())
                {
                    throw new WmauException(WmauErrorCodes.C_USER_NOT_ADMIN_ERROR);
                }

                IJTXConfiguration3 configMgr = WmxDatabase.ConfigurationManager as IJTXConfiguration3;
                IJTXMapEdit        wmxMapDoc = configMgr.GetJTXMap(this.m_targetName) as IJTXMapEdit;

                // If we're not allowed to overwrite an existing map document, then do some error checking
                if (!this.m_overwriteExisting && wmxMapDoc != null)
                {
                    msgs.AddWarning("Did not overwrite Map Document: " + this.m_targetName);
                    return;
                }
                else if (wmxMapDoc != null)
                {
                    msgs.AddMessage("Replacing Map Document '" + this.m_targetName + "' in database...");
                }
                else // wmxMapDoc == null
                {
                    msgs.AddMessage("Adding Map Document '" + this.m_targetName + "' to database...");
                    wmxMapDoc = configMgr.CreateJTXMap() as IJTXMapEdit;
                }

                IMapDocument mapDoc = new MapDocumentClass() as IMapDocument;
                mapDoc.Open(this.m_mxdFilePath, string.Empty);
                wmxMapDoc.Name = this.m_targetName;
                if (!string.IsNullOrEmpty(this.m_targetCategory))
                {
                    wmxMapDoc.Category = this.m_targetCategory;
                }
                if (!string.IsNullOrEmpty(this.m_description))
                {
                    wmxMapDoc.Description = this.m_description;
                }
                wmxMapDoc.Directory   = string.Empty;
                wmxMapDoc.FileName    = string.Empty;
                wmxMapDoc.MapDocument = mapDoc;
                wmxMapDoc.Store();
                mapDoc.Close();

                // Update the output parameter
                WmauParameterMap  paramMap     = new WmauParameterMap(paramValues);
                IGPParameterEdit3 outParamEdit = paramMap.GetParamEdit(C_PARAM_OUT_TARGET_NAME);
                IGPString         outValue     = new GPStringClass();
                outValue.Value     = m_targetName;
                outParamEdit.Value = outValue as IGPValue;

                msgs.AddMessage(Properties.Resources.MSG_DONE);
            }
            catch (WmauException wmEx)
            {
                try
                {
                    msgs.AddError(wmEx.ErrorCodeAsInt, wmEx.Message);
                }
                catch
                {
                    // Catch anything else that possibly happens
                }
            }
            catch (Exception ex)
            {
                try
                {
                    WmauError error = new WmauError(WmauErrorCodes.C_MXD_UPLOAD_ERROR);
                    msgs.AddError(error.ErrorCodeAsInt, error.Message + "; " + ex.Message);
                }
                catch
                {
                    // Catch anything else that possibly happens
                }
            }
        }
コード例 #22
0
 /// <summary>
 /// Creates a new WmauException
 /// </summary>
 /// <param name="errorObj">The WmauError describing specifically what caused this exception</param>
 /// <param name="ex">An exception that was the root cause of this one</param>
 public WmauException(WmauError errorObj, Exception ex) : base(string.Empty, ex)
 {
     m_errorDetails = errorObj;
 }
コード例 #23
0
        /// <summary>
        /// Required by IGPFunction2 interface; this function is called when the GP tool is ready to be executed.
        /// </summary>
        /// <param name="paramValues"></param>
        /// <param name="trackCancel"></param>
        /// <param name="envMgr"></param>
        /// <param name="msgs"></param>
        public override void Execute(IArray paramValues, ITrackCancel trackCancel, IGPEnvironmentManager envMgr, IGPMessages msgs)
        {
            // Do some common error-checking
            base.Execute(paramValues, trackCancel, envMgr, msgs);

            try
            {
                // Ensure that the current user has admin access to the current Workflow Manager DB
                if (!CurrentUserIsWmxAdministrator())
                {
                    throw new WmauException(WmauErrorCodes.C_USER_NOT_ADMIN_ERROR);
                }

                // Retrieve the TA workbook
                IJTXConfiguration3 defaultDbReadonly      = WmxDatabase.ConfigurationManager as IJTXConfiguration3;
                IJTXTaskAssistantWorkflowRecord tamRecord = defaultDbReadonly.GetTaskAssistantWorkflowRecord(this.m_targetName);
                string styleFileName = this.DetermineStyleFileName(this.m_xmlFilePath);

                // If we're not allowed to overwrite an existing TA record, then do some error checking
                if (!this.m_overwriteExisting && tamRecord != null)
                {
                    msgs.AddWarning("Did not overwrite Task Assistant workbook: " + this.m_targetName);
                    return;
                }
                else if (tamRecord != null)
                {
                    msgs.AddMessage("Replacing Task Assistant workbook '" + m_targetName + "' in database...");
                    defaultDbReadonly.ReplaceTaskAssistantWorkflowRecord(this.m_targetName, this.m_targetName, this.m_xmlFilePath, styleFileName);
                }
                else // tamRecord == null
                {
                    msgs.AddMessage("Adding Task Assistant workbook '" + m_targetName + "' to database...");
                    defaultDbReadonly.AddTaskAssistantWorkflowRecord(this.m_targetName, this.m_xmlFilePath, styleFileName);
                }

                // Update the output parameter
                WmauParameterMap  paramMap     = new WmauParameterMap(paramValues);
                IGPParameterEdit3 outParamEdit = paramMap.GetParamEdit(C_PARAM_OUT_TARGET_NAME);
                IGPString         outValue     = new GPStringClass();
                outValue.Value     = m_targetName;
                outParamEdit.Value = outValue as IGPValue;

                msgs.AddMessage(Properties.Resources.MSG_DONE);
            }
            catch (WmauException wmEx)
            {
                try
                {
                    msgs.AddError(wmEx.ErrorCodeAsInt, wmEx.Message);
                }
                catch
                {
                    // Catch anything else that possibly happens
                }
            }
            catch (Exception ex)
            {
                try
                {
                    WmauError error = new WmauError(WmauErrorCodes.C_TAM_UPLOAD_ERROR);
                    msgs.AddError(error.ErrorCodeAsInt, error.Message + "; " + ex.Message);
                }
                catch
                {
                    // Catch anything else that possibly happens
                }
            }
        }
コード例 #24
0
 /// <summary>
 /// Creates a new WmauException
 /// </summary>
 /// <param name="errorObj">The WmauError describing specifically what caused this exception</param>
 public WmauException(WmauError errorObj)
 {
     m_errorDetails = errorObj;
 }
コード例 #25
0
 /// <summary>
 /// Creates a new WmauException
 /// </summary>
 /// <param name="errorCode">An error code describing specifically what caused this exception</param>
 public WmauException(WmauErrorCodes errorCode)
 {
     m_errorDetails = new WmauError(errorCode);
 }
コード例 #26
0
        /// <summary>
        /// Required by IGPFunction2 interface; this function is called when the GP tool is ready to be executed.
        /// </summary>
        /// <param name="paramValues"></param>
        /// <param name="trackCancel"></param>
        /// <param name="envMgr"></param>
        /// <param name="msgs"></param>
        public override void Execute(IArray paramValues, ITrackCancel trackCancel, IGPEnvironmentManager envMgr, IGPMessages msgs)
        {
            // Do some common error-checking
            base.Execute(paramValues, trackCancel, envMgr, msgs);

            try
            {
                // Ensure that the current user has admin access to the current Workflow Manager DB
                if (!CurrentUserIsWmxAdministrator())
                {
                    throw new WmauException(WmauErrorCodes.C_USER_NOT_ADMIN_ERROR);
                }

                IJTXSpatialNotificationManager snManager          = this.WmxDatabase.SpatialNotificationManager;
                IJTXSpatialNotifierNameSet     allSnNames         = snManager.SpatialNotifiers;
                IJTXNotificationConfiguration  notificationConfig = this.WmxDatabase.ConfigurationManager as IJTXNotificationConfiguration;

                // Create a new spatial notification
                IJTXChangeRule2 changeRule = snManager.AddChangeRule() as IJTXChangeRule2;

                // Set the name
                changeRule.Name = m_snName;

                // Set the notifier
                IJTXNotificationType srcNotifType = notificationConfig.GetNotificationType(m_emailNotifier);

                // Set the properties of the spatial notification's e-mail notification to match that
                // of the source e-mail notification (phew!)
                IJTXEmailSpatialNotifier emailNotifier = this.CreateSpatialNotifierByName(C_TYPE_EMAIL_NOTIFIER) as IJTXEmailSpatialNotifier;
                emailNotifier.Subject           = srcNotifType.SubjectTemplate;
                emailNotifier.Body              = srcNotifType.MessageTemplate;
                emailNotifier.SenderEmail       = srcNotifType.SenderTemplate;
                emailNotifier.SenderDisplayName = srcNotifType.SenderDisplayNameTemplate;

                string[]     subscribers    = srcNotifType.get_Subscribers();
                IStringArray subscribersObj = new StrArrayClass();
                foreach (string subscriber in subscribers)
                {
                    subscribersObj.Add(subscriber);
                }
                emailNotifier.Subscribers = subscribersObj;

                changeRule.Notifier = emailNotifier as IJTXSpatialNotifier;

                // Set the description, if applicable
                if (!string.IsNullOrEmpty(m_snDescription))
                {
                    changeRule.Description = m_snDescription;
                }

                // Set the summarization behavior
                changeRule.SummarizeNotifications = m_summarize;

                // Store the resulting change rule
                changeRule.Store();

                // Update the output parameter
                WmauParameterMap  paramMap = new WmauParameterMap(paramValues);
                IGPParameterEdit3 outParam = paramMap.GetParamEdit(C_PARAM_OUT_NAME);
                IGPString         strValue = new GPStringClass();
                strValue.Value = m_snName;
                outParam.Value = strValue as IGPValue;

                msgs.AddWarning("To avoid database corruption, at least one dataset or area evaluator must be added to notification '" + m_snName + "' immediately!");
                msgs.AddMessage(Properties.Resources.MSG_DONE);
            }
            catch (WmauException wmEx)
            {
                try
                {
                    msgs.AddError(wmEx.ErrorCodeAsInt, wmEx.Message);
                }
                catch
                {
                    // Catch anything else that possibly happens
                }
            }
            catch (Exception ex)
            {
                try
                {
                    WmauError error = new WmauError(WmauErrorCodes.C_SN_CREATION_ERROR);
                    msgs.AddError(error.ErrorCodeAsInt, error.Message + "; " + ex.Message);
                }
                catch
                {
                    // Catch anything else that possibly happens
                }
            }
            finally
            {
                // Release any COM objects here!
            }
        }
コード例 #27
0
 /// <summary>
 /// Creates a new WmauException
 /// </summary>
 /// <param name="errorCode">An error code describing specifically what caused this exception</param>
 /// <param name="ex">An exception that was the root cause of this one</param>
 public WmauException(WmauErrorCodes errorCode, Exception ex)
     : base(string.Empty, ex)
 {
     m_errorDetails = new WmauError(errorCode);
 }
        /// <summary>
        /// Required by IGPFunction2 interface; this function is called when the GP tool is ready to be executed.
        /// </summary>
        /// <param name="paramValues"></param>
        /// <param name="trackCancel"></param>
        /// <param name="envMgr"></param>
        /// <param name="msgs"></param>
        public override void Execute(IArray paramValues, ITrackCancel trackCancel, IGPEnvironmentManager envMgr, IGPMessages msgs)
        {
            // Do some common error-checking
            base.Execute(paramValues, trackCancel, envMgr, msgs);

            // Back up the database
            IJTXTransfer transfer = WmxDatabase as IJTXTransfer;

            try
            {
                // Ensure that the current user has admin access to the current Workflow Manager DB
                if (!CurrentUserIsWmxAdministrator())
                {
                    throw new WmauException(WmauErrorCodes.C_USER_NOT_ADMIN_ERROR);
                }

                msgs.AddMessage("Retrieving data from Workflow Manager database...");
                string xml = transfer.ExportConfiguration();

                // Pretty-print the JXL file, if the user has selected that option
                if (this.m_prettyPrint)
                {
                    msgs.AddMessage("Making the data more easily human-readable...");
                    XmlDocument   xmlDoc        = new XmlDocument();
                    XmlTextReader xmlTextReader = new XmlTextReader(xml, XmlNodeType.Document, null);
                    xmlTextReader.WhitespaceHandling = WhitespaceHandling.None;
                    xmlDoc.Load(xmlTextReader);
                    xmlTextReader.Close();

                    msgs.AddMessage("Saving data to file...");
                    System.IO.TextWriter textWriter    = new System.IO.StreamWriter(this.m_jxlFilePath, false, System.Text.Encoding.UTF8, xml.Length);
                    XmlTextWriter        xmlTextWriter = new XmlTextWriter(textWriter);
                    xmlTextWriter.Formatting = Formatting.Indented;
                    xmlDoc.Save(xmlTextWriter);
                    xmlTextWriter.Close();
                    textWriter.Close();
                }
                else
                {
                    msgs.AddMessage("Saving data to file...");
                    System.IO.TextWriter textWriter = new System.IO.StreamWriter(this.m_jxlFilePath, false, System.Text.Encoding.UTF8, xml.Length);
                    textWriter.Write(xml);
                    textWriter.Close();
                }

                msgs.AddMessage(Properties.Resources.MSG_DONE);
            }
            catch (WmauException wmEx)
            {
                try
                {
                    msgs.AddError(wmEx.ErrorCodeAsInt, wmEx.Message);
                }
                catch
                {
                    // Catch anything else that possibly happens }
                }
            }
            catch (Exception ex)
            {
                try
                {
                    WmauError error = new WmauError(WmauErrorCodes.C_JXL_BACKUP_ERROR);
                    msgs.AddError(error.ErrorCodeAsInt, error.Message + "; " + ex.Message);
                }
                catch
                {
                    // Catch anything else that possibly happens }
                }
            }
        }
コード例 #29
0
        /// <summary>
        /// Required by IGPFunction2 interface; this function is called when the GP tool is ready to be executed.
        /// </summary>
        /// <param name="paramValues"></param>
        /// <param name="trackCancel"></param>
        /// <param name="envMgr"></param>
        /// <param name="msgs"></param>
        public override void Execute(IArray paramValues, ITrackCancel trackCancel, IGPEnvironmentManager envMgr, IGPMessages msgs)
        {
            // Do some common error-checking
            base.Execute(paramValues, trackCancel, envMgr, msgs);

            // Assign the requested job
            try
            {
                IJTXJobManager     jobManager = this.WmxDatabase.JobManager;
                IJTXJob3           job        = jobManager.GetJob(m_jobId) as IJTXJob3;
                IJTXConfiguration3 configMgr  = this.WmxDatabase.ConfigurationManager as IJTXConfiguration3;

                // As of Jan. 2011, the core Workflow Manager libraries do not
                // seem to check if the user has the privilege to add an attachment
                // if a job as a hold on it.  So run the check here.
                IJTXJobHolds jobHolds = job as IJTXJobHolds;
                if (jobHolds.Holds != null &&
                    jobHolds.Holds.Count > 0 &&
                    !CurrentUserHasPrivilege(ESRI.ArcGIS.JTX.Utilities.Constants.PRIV_CAN_ADD_ATTACHES_FOR_HELD_JOBS))
                {
                    throw new WmauException(WmauErrorCodes.C_NO_ADD_ATTACHMENTS_HELD_JOBS_ERROR);
                }

                // If we get this far, then figure out how to associate the attachment
                // with the job, and add the attachment.
                jtxFileStorageType attachmentType;
                if (m_attachmentType.Equals(C_OPT_EMBEDDED))
                {
                    attachmentType = jtxFileStorageType.jtxStoreInDB;
                }
                else
                {
                    attachmentType = jtxFileStorageType.jtxStoreAsLink;
                }

                msgs.AddMessage("Adding attachment '" + m_attachmentPath + "' to job " + m_jobId + " (" + job.Name + ")");
                job.AddAttachment(m_attachmentPath, attachmentType, m_attachmentType);
                job.Store();

                // Do the other things that still need to be handled manually, such as logging
                // the job's reassignment and sending any necessary notifications.
                IPropertySet propSet = new PropertySetClass();
                propSet.SetProperty(C_PROP_VAL_ATTACHMENT, "'" + m_attachmentPath + "'");
                job.LogJobAction(
                    configMgr.GetActivityType(ESRI.ArcGIS.JTX.Utilities.Constants.ACTTYPE_ADD_ATTACHMENT),
                    propSet,
                    string.Empty);
                Common.WmauHelperFunctions.SendNotification(
                    ESRI.ArcGIS.JTX.Utilities.Constants.NOTIF_ATTACHMENT_ADDED,
                    this.WmxDatabase,
                    job);

                // Set the output parameter
                WmauParameterMap  paramMap     = new WmauParameterMap(paramValues);
                IGPParameterEdit3 outParamEdit = paramMap.GetParamEdit(C_PARAM_OUT_JOB_ID);
                IGPLong           outValue     = new GPLongClass();
                outValue.Value     = m_jobId;
                outParamEdit.Value = outValue as IGPValue;

                msgs.AddMessage(Properties.Resources.MSG_DONE);
            }
            catch (WmauException wmEx)
            {
                try
                {
                    msgs.AddError(wmEx.ErrorCodeAsInt, wmEx.Message);
                }
                catch
                {
                    // Catch anything else that possibly happens
                }
            }
            catch (Exception ex)
            {
                WmauError error = new WmauError(WmauErrorCodes.C_UNSPECIFIED_ERROR);
                msgs.AddError(error.ErrorCodeAsInt, error.Message + "; " + ex.Message);
            }
        }
        /// <summary>
        /// Required by IGPFunction2 interface; this function is called when the GP tool is ready to be executed.
        /// </summary>
        /// <param name="paramValues"></param>
        /// <param name="trackCancel"></param>
        /// <param name="envMgr"></param>
        /// <param name="msgs"></param>
        public override void Execute(IArray paramValues, ITrackCancel trackCancel, IGPEnvironmentManager envMgr, IGPMessages msgs)
        {
            // Do some common error-checking
            base.Execute(paramValues, trackCancel, envMgr, msgs);

            // Set the default properties for the specified job type
            try
            {
                IJTXConfiguration3     configMgr  = this.WmxDatabase.ConfigurationManager as IJTXConfiguration3;
                IJTXConfigurationEdit2 configEdit = this.WmxDatabase.ConfigurationManager as IJTXConfigurationEdit2;
                IJTXJobTypeEdit3       jobType    = configEdit.GetJobType(m_jobTypeName) as IJTXJobTypeEdit3;

                // Set the default data workspace for the selected job type
                if (m_dataWorkspaceName.Equals(C_OPT_NONE))
                {
                    jobType.DefaultDataWorkspace = null;
                    msgs.AddMessage("Clearing default data workspace for job type '" + m_jobTypeName + "'");
                }
                else
                {
                    // Translate the workspace name to a DB name object
                    IJTXDataWorkspaceName dwName =
                        Common.WmauHelperFunctions.LookupWorkspaceNameObj(this.WmxDatabase, m_dataWorkspaceName);

                    msgs.AddMessage("Default data workspace for job type '" + m_jobTypeName + "' is now '" + dwName.Name + "'");
                    jobType.DefaultDataWorkspace = dwName;
                }

                // Set the default parent version for the selected job type
                if (m_parentVersion.Equals(C_OPT_NONE))
                {
                    msgs.AddMessage("Clearing default parent version for job type '" + m_jobTypeName + "'");
                    jobType.DefaultParentVersionName_2 = string.Empty;
                }
                else
                {
                    msgs.AddMessage("Default parent version for job type '" + m_jobTypeName + "' is now '" + m_parentVersion + "'");
                    jobType.DefaultParentVersionName_2 = m_parentVersion;
                }

                // Save the changes to the job type
                jobType.Store();

                // Set the output parameter
                WmauParameterMap  paramMap     = new WmauParameterMap(paramValues);
                IGPParameterEdit3 outParamEdit = paramMap.GetParamEdit(C_PARAM_OUT_DATA_WORKSPACE);
                IGPString         outValue     = new GPStringClass();
                outValue.Value     = m_jobTypeName;
                outParamEdit.Value = outValue as IGPValue;

                msgs.AddMessage(Properties.Resources.MSG_DONE);
            }
            catch (WmauException wmEx)
            {
                try
                {
                    msgs.AddError(wmEx.ErrorCodeAsInt, wmEx.Message);
                }
                catch
                {
                    // Catch anything else that possibly happens
                }
            }
            catch (Exception ex)
            {
                WmauError error = new WmauError(WmauErrorCodes.C_UNSPECIFIED_ERROR);
                msgs.AddError(error.ErrorCodeAsInt, error.Message + "; " + ex.Message);
            }
        }