public IGPMessage ValidateValue(IGPValue Value, IGPDomain Domain) { IGPMessage validateValueMessage = new GPMessageClass(); IGPUtilities3 gpUtilities = new GPUtilitiesClass(); IHttpBasicGPValue targetValue = gpUtilities.UnpackGPValue(Value) as IHttpBasicGPValue; if (targetValue == null) { IGPString targetValueString = gpUtilities.UnpackGPValue(Value) as IGPString; if (targetValueString != null) { return(validateValueMessage); } } if (targetValue == null) { validateValueMessage.Type = esriGPMessageType.esriGPMessageTypeError; validateValueMessage.ErrorCode = 502; validateValueMessage.Description = resourceManager.GetString("GPTools_Authentication_HttpBasicDataType_valuevalidation"); } if (Domain != null) { validateValueMessage = Domain.MemberOf((IGPValue)targetValue); } return(validateValueMessage); }
/// <summary> /// Validates the value. /// </summary> /// <param name="value">The value.</param> /// <param name="domain">The domain.</param> /// <returns></returns> public IGPMessage ValidateValue(IGPValue value, IGPDomain domain) { IGPMessage message = new GPMessageClass(); IGPUtilities3 utilities = new GPUtilitiesClass(); IGPAutoValue autoValue = utilities.UnpackGPValue(value) as IGPAutoValue; if (autoValue == null) { message.Type = esriGPMessageType.esriGPMessageTypeError; message.ErrorCode = 502; message.Description = @"The value is not an auto value."; } return(message); }
public IGPMessage ValidateValue(IGPValue Value, IGPDomain Domain) { IGPMessage validateValueMessage = new GPMessageClass(); IGPUtilities3 gpUtilities = new GPUtilitiesClass(); IHttpBasicGPValue targetValue = gpUtilities.UnpackGPValue(Value) as IHttpBasicGPValue; if ( targetValue == null ) { IGPString targetValueString = gpUtilities.UnpackGPValue(Value) as IGPString; if ( targetValueString != null ) return validateValueMessage; } if (targetValue == null) { validateValueMessage.Type = esriGPMessageType.esriGPMessageTypeError; validateValueMessage.ErrorCode = 502; validateValueMessage.Description = resourceManager.GetString("GPTools_Authentication_HttpBasicDataType_valuevalidation"); } if (Domain != null) { validateValueMessage = Domain.MemberOf((IGPValue)targetValue); } return validateValueMessage; }
/// <summary> /// Pre validates the given set of values. /// This is where you populate derived parameters based on input, among other things. /// </summary> /// <param name="paramValues"></param> /// <param name="pEnvMgr"></param> public override void UpdateParameters(IArray paramValues, IGPEnvironmentManager pEnvMgr) { try { UpdateParametersCommon(paramValues, pEnvMgr); } catch (WmxDefaultDbNotSetException) { // If the default DB wasn't set, stop executing return; } catch (NullReferenceException) { // If one of the parameters was null, stop executing return; } // Get the parameters as a map for easier access WmauParameterMap paramMap = new WmauParameterMap(paramValues); IGPParameter3 jobTypeParam = paramMap.GetParam(C_PARAM_JOB_TYPE); IGPParameterEdit3 jobTypeParamEdit = paramMap.GetParamEdit(C_PARAM_JOB_TYPE); IGPParameter3 dataWorkspace = paramMap.GetParam(C_PARAM_DATA_WORKSPACE); IGPParameterEdit3 dataWorkspaceEdit = paramMap.GetParamEdit(C_PARAM_DATA_WORKSPACE); IGPParameter3 parentVersion = paramMap.GetParam(C_PARAM_PARENT_VERSION); IGPParameterEdit3 parentVersionEdit = paramMap.GetParamEdit(C_PARAM_PARENT_VERSION); // Set the domains for any parameters that need them if (jobTypeParam.Domain == null) { jobTypeParamEdit.Domain = Common.WmauGpDomainBuilder.BuildJobTypeDomain(this.WmxDatabase); } if (dataWorkspace.Domain == null) { dataWorkspaceEdit.Domain = Common.WmauGpDomainBuilder.BuildWorkspaceDomain( this.WmxDatabase, new string[] { C_OPT_NONE }); } // Only update the domain for the parent version field if it hasn't yet been // populated, or if the value of the data workspace parameter has changed string newDataWorkspace = dataWorkspace.Value.GetAsText(); if (parentVersion.Domain == null || !m_dataWorkspaceName.Equals(newDataWorkspace)) { IGPDomain versionDomain = null; string newJobType = jobTypeParam.Value.GetAsText(); IJTXJobType3 jobType = this.WmxDatabase.ConfigurationManager.GetJobType(newJobType) as IJTXJobType3; if (newDataWorkspace.Equals(C_OPT_NONE) || newDataWorkspace.Equals(string.Empty)) { // Case 1: the only acceptable option for the parent version is "none". IGPCodedValueDomain cvDomain = new GPCodedValueDomainClass(); cvDomain.AddStringCode(C_OPT_NONE, C_OPT_NONE); versionDomain = cvDomain as IGPDomain; } else { // Case 2: we need to retrieve the version list for an existing // data workspace try { versionDomain = Common.WmauGpDomainBuilder.BuildVersionsDomain( this.WmxDatabase, newDataWorkspace, new string[] { C_OPT_NONE }); } catch (WmauException) { // Use the "null" as an error value; we'll check for this later versionDomain = null; } } parentVersionEdit.Domain = versionDomain; } }