示例#1
0
        /// <summary>
        /// Gather the error/warning/informative messages from GPMessages
        /// <summary>
        /// <param name="gpMessages">GPMessages container</param>
        /// <returns>string of all GPMessages</returns>
        public string GetGPMessagesAsString(IGPMessages gpMessages)
        {
            // Gather Error/Warning/Informative Messages
            var messages = new StringBuilder();

            if (gpMessages != null)
            {
                for (int i = 0; i < gpMessages.Count; i++)
                {
                    IGPMessage gpMessage = gpMessages.GetMessage(i);
                    string     message   = gpMessage.Description;
                    switch (gpMessages.GetMessage(i).Type)
                    {
                    case esriGPMessageType.esriGPMessageTypeError:
                        messages.AppendLine("Error " + gpMessage.ErrorCode + ": " + message);
                        break;

                    case esriGPMessageType.esriGPMessageTypeWarning:
                        messages.AppendLine("Warning: " + message);
                        break;

                    default:
                        messages.AppendLine("Information: " + message);
                        break;
                    }
                }
            }
            return(messages.ToString());
        }
示例#2
0
        /// <summary>
        /// Called immediately after a tool is executed by the GeoProcessor.
        /// </summary>
        /// <param name="Tool"></param>
        /// <param name="Values"></param>
        /// <param name="result"></param>
        /// <param name="Messages"></param>
        void IGeoProcessorEvents.PostToolExecute(IGPTool Tool, IArray Values, int result, IGPMessages Messages)
        {
            GPMessageEventArgs[] messages  = new GPMessageEventArgs[Messages.Count];
            IGPMessage           gpMessage = null;

            for (int i = 0; i < Messages.Count; i++)
            {
                gpMessage = Messages.GetMessage(i);
                GPMessageEventArgs message = new GPMessageEventArgs(gpMessage.Description, gpMessage.Type, gpMessage.ErrorCode);
                messages[i] = message;
            }

            //create a new instance of GPPostToolExecuteEventArgs
            GPPostToolExecuteEventArgs e = new GPPostToolExecuteEventArgs();

            e.DisplayName  = Tool.DisplayName;
            e.Name         = Tool.Name;
            e.PathName     = Tool.PathName;
            e.Toolbox      = Tool.Toolbox.Alias;
            e.ToolCategory = Tool.ToolCategory;
            e.ToolType     = Tool.ToolType;
            e.Description  = Tool.Description;
            e.Result       = result;

            //fire the Post tool event
            if (null != GPPostToolExecute)
            {
                GPPostToolExecute(this, e);
            }
        }
示例#3
0
        public void gpToolExecuted(object sender, ToolExecutedEventArgs e)
        {
            IGeoProcessorResult2 result = e.GPResult as IGeoProcessorResult2;

            if (result.Status.Equals(esriJobStatus.esriJobSucceeded))
            {
                //Check that there are no information or warning messages.
                if (result.MaxSeverity == 0)
                {
                    //Get the return value.
                    object returnValue = result.ReturnValue;
                    //Application specific code,
                    //for example, find the layer to which this return value corresponds.
                }
                else
                {
                    //Application specific code.
                }
            }
            else
            {
                //Get all messages.
                IGPMessages msgs = result.GetResultMessages();
                for (int i = 0; i < result.MessageCount; i++)
                {
                    IGPMessage2 msg = msgs.GetMessage(i) as IGPMessage2;
                    //Application specific code.
                }
            }
        }
        /// <summary>
        /// Handles the MessagesCreated event.
        /// </summary>
        void _gp_MessagesCreated(object sender, MessagesCreatedEventArgs e)
        {
            IGPMessages gpMsgs = e.GPMessages;

            if (gpMsgs.Count > 0)
            {
                for (int count = 0; count < gpMsgs.Count; count++)
                {
                    IGPMessage msg         = gpMsgs.GetMessage(count);
                    string     imageToShow = "information";

                    switch (msg.Type)
                    {
                    case esriGPMessageType.esriGPMessageTypeAbort:
                        imageToShow = "warning";
                        break;

                    case esriGPMessageType.esriGPMessageTypeEmpty:
                        imageToShow = "information";
                        break;

                    case esriGPMessageType.esriGPMessageTypeError:
                        imageToShow = "error";
                        break;

                    case esriGPMessageType.esriGPMessageTypeGDBError:
                        imageToShow = "error";
                        break;

                    case esriGPMessageType.esriGPMessageTypeInformative:
                        imageToShow = "information";
                        break;

                    case esriGPMessageType.esriGPMessageTypeProcessDefinition:
                        imageToShow = "information";
                        break;

                    case esriGPMessageType.esriGPMessageTypeProcessStart:
                        imageToShow = "information";
                        break;

                    case esriGPMessageType.esriGPMessageTypeProcessStop:
                        imageToShow = "information";
                        break;

                    case esriGPMessageType.esriGPMessageTypeWarning:
                        imageToShow = "warning";
                        break;

                    default:
                        break;
                    }

                    listView1.Items.Add(new ListViewItem(new string[2] {
                        "MessagesCreated", msg.Description
                    }, imageToShow));
                }
            }
        }
示例#5
0
        private void ProcessGPMessages(Geoprocessor gp)
        {
            IGPMessages gpMsgs = gp.IGeoProcessor.GetReturnMessages();
            IArray      ir     = gpMsgs.Messages;
            int         ic     = ir.Count;

            for (int i = 0; i < ic; i++)
            {
                System.Diagnostics.Debug.Print(gpMsgs.GetMessage(i).Description);
            }
        }
        private static string GenerateStringOfAllGpMessages(IGPMessages gpMessages)
        {
            var gpMessagesStringBuilder = new StringBuilder();

            for (var messageIndex = 0; messageIndex < gpMessages.Count; messageIndex++)
            {
                var gpMessage = gpMessages.GetMessage(messageIndex);
                gpMessagesStringBuilder.AppendLine("Error Code: " + gpMessage.ErrorCode +
                                                   " Type: " + gpMessage.Type +
                                                   " Message " + messageIndex + ": " + gpMessage.Description);
            }
            return(gpMessagesStringBuilder.ToString());
        }
示例#7
0
        private void LoadListboxAfterPartialSolve(IGPMessages gpMessages)
        {
            lbOutput.Items.Add("Partial Solve Generated.");
            for (int msgIndex = 0; msgIndex < gpMessages.Messages.Count; msgIndex++)
            {
                string errorText = "";
                switch (gpMessages.GetMessage(msgIndex).Type)
                {
                case esriGPMessageType.esriGPMessageTypeError:
                    errorText = "Error " + gpMessages.GetMessage(msgIndex).ErrorCode.ToString() + " " + gpMessages.GetMessage(msgIndex).Description;
                    break;

                case esriGPMessageType.esriGPMessageTypeWarning:
                    errorText = "Warning " + gpMessages.GetMessage(msgIndex).ErrorCode.ToString() + " " + gpMessages.GetMessage(msgIndex).Description;
                    break;

                default:
                    errorText = "Information " + gpMessages.GetMessage(msgIndex).Description;
                    break;
                }
                lbOutput.Items.Add(errorText);
            }
        }
 //*********************************************************************************
 // Gather the error/warning/informative messages from GPMessages
 //*********************************************************************************
 public string GetGPMessagesAsString(IGPMessages gpMessages)
 {
     // Gather Error/Warning/Informative Messages
     var messages = new StringBuilder();
     if (gpMessages != null)
     {
         for (int i = 0; i < gpMessages.Count; i++)
         {
             IGPMessage gpMessage = gpMessages.GetMessage(i);
             string message = gpMessage.Description;
             switch (gpMessages.GetMessage(i).Type)
             {
                 case esriGPMessageType.esriGPMessageTypeError:
                     messages.AppendLine("Error " + gpMessage.ErrorCode + ": " + message);
                     break;
                 case esriGPMessageType.esriGPMessageTypeWarning:
                     messages.AppendLine("Warning: " + message);
                     break;
                 default:
                     messages.AppendLine("Information: " + message);
                     break;
             }
         }
     }
     return messages.ToString();
 }
        public void UpdateMessages(IArray paramvalues, IGPEnvironmentManager pEnvMgr, IGPMessages messages)
        {
            // Check for error message

            IGPMessage msg = (IGPMessage)messages;
            if (msg.IsError())
                return;

            // Verify chosen output file geodatabase has a ".gdb" extension

            var gpParam = paramvalues.get_Element(OutputFileGDB) as IGPParameter;
            IGPValue outputFileGDBValue = m_gpUtils.UnpackGPValue(gpParam);
            if (!outputFileGDBValue.IsEmpty())
            {
                string outputFileGDBValueAsText = outputFileGDBValue.GetAsText();
                if (!(outputFileGDBValueAsText.EndsWith(".gdb")))
                {
                    IGPMessage gpMessage = messages.GetMessage(OutputFileGDB);
                    gpMessage.Type = esriGPMessageType.esriGPMessageTypeError;
                    gpMessage.Description = "Input value is not a valid file geodatabase path.";
                }
            }

            // Verify chosen input MtdDST table has the expected fields

            gpParam = paramvalues.get_Element(InputMtdDSTTable) as IGPParameter;
            IGPValue tableValue = m_gpUtils.UnpackGPValue(gpParam);
            if (!tableValue.IsEmpty())
            {
                IDETable inputTable = m_gpUtils.DecodeDETable(tableValue);
                CheckForTableFields(inputTable, MtdDSTFieldNames, MtdDSTFieldTypes, messages.GetMessage(InputMtdDSTTable));
            }

            // Verify chosen input MtdCntryRef table has the expected fields

            gpParam = paramvalues.get_Element(InputMtdCntryRefTable) as IGPParameter;
            tableValue = m_gpUtils.UnpackGPValue(gpParam);
            if (!tableValue.IsEmpty())
            {
                IDETable inputTable = m_gpUtils.DecodeDETable(tableValue);
                CheckForTableFields(inputTable, MtdCntryRefFieldNames, MtdCntryRefFieldTypes, messages.GetMessage(InputMtdCntryRefTable));
            }

            // Verify chosen input MtdArea table has the expected fields

            gpParam = paramvalues.get_Element(InputMtdAreaTable) as IGPParameter;
            tableValue = m_gpUtils.UnpackGPValue(gpParam);
            if (!tableValue.IsEmpty())
            {
                IDETable inputTable = m_gpUtils.DecodeDETable(tableValue);
                CheckForTableFields(inputTable, MtdAreaFieldNames, MtdAreaFieldTypes, messages.GetMessage(InputMtdAreaTable));
            }

            // Verify chosen input AdminBndy feature classes have the expected fields

            gpParam = paramvalues.get_Element(InputAdminBndyFeatureClasses) as IGPParameter;
            IGPMultiValue multiValue = m_gpUtils.UnpackGPValue(gpParam) as IGPMultiValue;
            for (int i = 0; i < multiValue.Count; i++)
            {
                tableValue = multiValue.get_Value(i);
                if (!tableValue.IsEmpty())
                {
                    IDETable inputTable = m_gpUtils.DecodeDETable(tableValue);
                    CheckForTableFields(inputTable, AdminBndyFieldNames, AdminBndyFieldTypes, messages.GetMessage(InputAdminBndyFeatureClasses));
                }
            }

            // Check the input Streets feature class and Time Zone ID Field Name parameters together

            gpParam = paramvalues.get_Element(InputStreetsFeatureClass) as IGPParameter;
            tableValue = m_gpUtils.UnpackGPValue(gpParam);
            IGPParameter fieldNameParam = paramvalues.get_Element(InputTimeZoneIDBaseFieldName) as IGPParameter;
            IGPValue fieldNameValue = m_gpUtils.UnpackGPValue(fieldNameParam);
            if (!tableValue.IsEmpty())
            {
                // Verify chosen input Streets feature class has the expected fields

                IDETable inputTable = m_gpUtils.DecodeDETable(tableValue);
                CheckForTableFields(inputTable, StreetsFieldNames, StreetsFieldTypes, messages.GetMessage(InputStreetsFeatureClass));

                // Check to make sure that the Time Zone ID Base Field Name parameter is specified together with the Streets feature class

                if (fieldNameValue.IsEmpty())
                {
                    messages.GetMessage(InputTimeZoneIDBaseFieldName).Type = esriGPMessageType.esriGPMessageTypeError;
                    messages.GetMessage(InputTimeZoneIDBaseFieldName).Description = "This parameter must be specified together with the NW feature class.";
                }
                else
                {
                    // Verify chosen input time zone ID fields does not exist on the input Streets feature class

                    string fieldName = fieldNameValue.GetAsText();
                    if (inputTable.Fields.FindField("FT_" + fieldName) != -1)
                    {
                        messages.GetMessage(InputTimeZoneIDBaseFieldName).Type = esriGPMessageType.esriGPMessageTypeError;
                        messages.GetMessage(InputTimeZoneIDBaseFieldName).Description = "Field named FT_" + fieldName + " already exists.";
                    }
                    if (inputTable.Fields.FindField("TF_" + fieldName) != -1)
                    {
                        messages.GetMessage(InputTimeZoneIDBaseFieldName).Type = esriGPMessageType.esriGPMessageTypeError;
                        messages.GetMessage(InputTimeZoneIDBaseFieldName).Description = "Field named TF_" + fieldName + " already exists.";
                    }
                }
            }

            return;
        }
    /// <summary>
    /// Called immediately after a tool is executed by the GeoProcessor.
    /// </summary>
    /// <param name="Tool"></param>
    /// <param name="Values"></param>
    /// <param name="result"></param>
    /// <param name="Messages"></param>
    void IGeoProcessorEvents.PostToolExecute(IGPTool Tool, IArray Values, int result, IGPMessages Messages)
    {
      GPMessageEventArgs[] messages = new GPMessageEventArgs[Messages.Count];
      IGPMessage gpMessage = null;
      for (int i = 0; i < Messages.Count; i++)
      {
        gpMessage = Messages.GetMessage(i);
        GPMessageEventArgs message = new GPMessageEventArgs(gpMessage.Description, gpMessage.Type, gpMessage.ErrorCode);
        messages[i] = message;
      }

      //create a new instance of GPPostToolExecuteEventArgs
      GPPostToolExecuteEventArgs e = new GPPostToolExecuteEventArgs();
      e.DisplayName = Tool.DisplayName;
      e.Name = Tool.Name;
      e.PathName = Tool.PathName;
      e.Toolbox = Tool.Toolbox.Alias;
      e.ToolCategory = Tool.ToolCategory;
      e.ToolType = Tool.ToolType;
      e.Description = Tool.Description;
      e.Result = result;

      //fire the Post tool event
      if (null != GPPostToolExecute)
        GPPostToolExecute(this, e);
    }
        /// <summary>
        /// Takes an IGPMessages object and converts it to a nicely-formatted string.
        /// </summary>
        /// <param name="messages">An IGPMessages object containing one or more messages.</param>
        /// <param name="bFailureMessages">Set to true if any failure messages (aborts or errors) were detected; false otherwise</param>
        /// <returns>A string formatted in the GP-style message.</returns>
        private string ConvertGPMessagesToString(IGPMessages messages, out bool bFailureMessages)
        {
            string msgsAsString = String.Empty;
            StringBuilder sb = new StringBuilder();
            bFailureMessages = false;

            if (messages != null)
            {
                // Iterate through each of the messages
                for (int i = 0; i < messages.Count; i++)
                {
                    IGPMessage message = messages.GetMessage(i);

                    if ((message != null) && !string.IsNullOrEmpty(message.Description))
                    {
                        string strType = "";
                        switch (message.Type)
                        {
                            case esriGPMessageType.esriGPMessageTypeAbort:
                                strType = "Abort:";
                                bFailureMessages = true;
                                break;
                            case esriGPMessageType.esriGPMessageTypeEmpty:
                                strType = "Empty:";
                                break;
                            case esriGPMessageType.esriGPMessageTypeError:
                                strType = "Error:";
                                bFailureMessages = true;
                                break;
                            case esriGPMessageType.esriGPMessageTypeInformative:
                                strType = "Info:";
                                break;
                            case esriGPMessageType.esriGPMessageTypeProcessDefinition:
                                strType = "ProcessDef:";
                                break;
                            case esriGPMessageType.esriGPMessageTypeProcessStart:
                                strType = "ProcessStart:";
                                break;
                            case esriGPMessageType.esriGPMessageTypeProcessStop:
                                strType = "ProcessStop:";
                                break;
                            case esriGPMessageType.esriGPMessageTypeWarning:
                                strType = "Warning:";
                                break;
                        }

                        sb.AppendLine(strType + " " + message.Description);
                    }
                }
            }

            return sb.ToString();
        }
        public void UpdateMessages(IArray paramvalues, IGPEnvironmentManager pEnvMgr, IGPMessages messages)
        {
            // Check for error message

            IGPMessage msg = (IGPMessage)messages;
            if (msg.IsError())
                return;

            // Verify chosen output file geodatabase has a ".gdb" extension

            var gpParam = paramvalues.get_Element(OutputFileGDB) as IGPParameter;
            IGPValue outputFileGDBValue = m_gpUtils.UnpackGPValue(gpParam);
            if (!outputFileGDBValue.IsEmpty())
            {
                string outputFileGDBValueAsText = outputFileGDBValue.GetAsText();
                if (!(outputFileGDBValueAsText.EndsWith(".gdb")))
                {
                    IGPMessage gpMessage = messages.GetMessage(OutputFileGDB);
                    gpMessage.Type = esriGPMessageType.esriGPMessageTypeError;
                    gpMessage.Description = "Input value is not a valid file geodatabase path.";
                }
            }

            // Verify chosen output file geodatabase version is valid

            gpParam = paramvalues.get_Element(OutputFileGDBVersion) as IGPParameter;
            IGPValue outputFileGDBVersionValue = m_gpUtils.UnpackGPValue(gpParam);
            if (!outputFileGDBVersionValue.IsEmpty())
            {
                switch (outputFileGDBVersionValue.GetAsText())
                {
                    case "9.3":
                    case "10.0":
                    case "10.1":
                        // version is supported
                        break;
                    default:
                        IGPMessage gpMessage = messages.GetMessage(OutputFileGDBVersion);
                        gpMessage.Type = esriGPMessageType.esriGPMessageTypeError;
                        gpMessage.Description = "This version of the file geodatabase is not supported.";
                        break;
                }
            }

            // Verify chosen input Streets feature class has the expected fields

            gpParam = paramvalues.get_Element(InputStreetsFeatureClass) as IGPParameter;
            IGPValue tableValue = m_gpUtils.UnpackGPValue(gpParam);
            if (!tableValue.IsEmpty())
            {
                IDETable inputTable = m_gpUtils.DecodeDETable(tableValue);
                CheckForTableFields(inputTable, StreetsFieldNames, StreetsFieldTypes, messages.GetMessage(InputStreetsFeatureClass));
            }

            // Verify chosen input AltStreets feature class has the expected fields

            gpParam = paramvalues.get_Element(InputAltStreetsFeatureClass) as IGPParameter;
            tableValue = m_gpUtils.UnpackGPValue(gpParam);
            if (!tableValue.IsEmpty())
            {
                IDETable inputTable = m_gpUtils.DecodeDETable(tableValue);
                CheckForTableFields(inputTable, AltStreetsFieldNames, AltStreetsFieldTypes, messages.GetMessage(InputAltStreetsFeatureClass));
            }

            // Verify chosen input Z-Levels feature class has the expected fields

            gpParam = paramvalues.get_Element(InputZLevelsFeatureClass) as IGPParameter;
            tableValue = m_gpUtils.UnpackGPValue(gpParam);
            if (!tableValue.IsEmpty())
            {
                IDETable inputTable = m_gpUtils.DecodeDETable(tableValue);
                CheckForTableFields(inputTable, ZLevelsFieldNames, ZLevelsFieldTypes, messages.GetMessage(InputZLevelsFeatureClass));
            }

            // Verify chosen input Cdms table has the expected fields

            gpParam = paramvalues.get_Element(InputCdmsTable) as IGPParameter;
            tableValue = m_gpUtils.UnpackGPValue(gpParam);
            if (!tableValue.IsEmpty())
            {
                IDETable inputTable = m_gpUtils.DecodeDETable(tableValue);
                CheckForTableFields(inputTable, CdmsFieldNames, CdmsFieldTypes, messages.GetMessage(InputCdmsTable));
            }

            // Verify chosen input Rdms table has the expected fields

            gpParam = paramvalues.get_Element(InputRdmsTable) as IGPParameter;
            tableValue = m_gpUtils.UnpackGPValue(gpParam);
            if (!tableValue.IsEmpty())
            {
                IDETable inputTable = m_gpUtils.DecodeDETable(tableValue);
                CheckForTableFields(inputTable, RdmsFieldNames, RdmsFieldTypes, messages.GetMessage(InputRdmsTable));
            }

            // Verify chosen input Signs table has the expected fields

            gpParam = paramvalues.get_Element(InputSignsTable) as IGPParameter;
            tableValue = m_gpUtils.UnpackGPValue(gpParam);
            if (!tableValue.IsEmpty())
            {
                IDETable inputTable = m_gpUtils.DecodeDETable(tableValue);
                CheckForTableFields(inputTable, SignsFieldNames, SignsFieldTypes, messages.GetMessage(InputSignsTable));
            }

            // Verify chosen input time zone table has the expected fields

            gpParam = paramvalues.get_Element(InputTimeZoneTable) as IGPParameter;
            tableValue = m_gpUtils.UnpackGPValue(gpParam);
            if (!tableValue.IsEmpty())
            {
                IDETable inputTable = m_gpUtils.DecodeDETable(tableValue);
                CheckForTableFields(inputTable, TimeZoneFieldNames, TimeZoneFieldTypes, messages.GetMessage(InputTimeZoneTable));
            }

            // Verify chosen input Traffic table has the expected fields

            gpParam = paramvalues.get_Element(InputTrafficTable) as IGPParameter;
            tableValue = m_gpUtils.UnpackGPValue(gpParam);
            if (!tableValue.IsEmpty())
            {
                IDETable inputTable = m_gpUtils.DecodeDETable(tableValue);
                CheckForTableFields(inputTable, TrafficFieldNames, TrafficFieldTypes, messages.GetMessage(InputTrafficTable));
            }

            // Verify chosen Traffic Patterns files have a ".csv" extension

            gpParam = paramvalues.get_Element(InputLinkReferenceFileFC14) as IGPParameter;
            IGPValue inputLinkReferenceFileFC14Value = m_gpUtils.UnpackGPValue(gpParam);
            if (!inputLinkReferenceFileFC14Value.IsEmpty())
            {
                string inputLinkReferenceFileFC14ValueAsText = inputLinkReferenceFileFC14Value.GetAsText();
                if (!(inputLinkReferenceFileFC14ValueAsText.EndsWith(".csv")))
                {
                    IGPMessage gpMessage = messages.GetMessage(InputTMCReferenceFile);
                    gpMessage.Type = esriGPMessageType.esriGPMessageTypeError;
                    gpMessage.Description = "Input value is not a .csv file.";
                }
                else
                {
                    System.IO.StreamReader f = new System.IO.StreamReader(inputLinkReferenceFileFC14ValueAsText);
                    string firstLine;
                    if ((firstLine = f.ReadLine()) == null)
                    {
                        IGPMessage gpMessage = messages.GetMessage(InputLinkReferenceFileFC14);
                        gpMessage.Type = esriGPMessageType.esriGPMessageTypeError;
                        gpMessage.Description = "Input value is an empty .csv file.";
                    }
                    else if (firstLine != "LINK_PVID,TRAVEL_DIRECTION,U,M,T,W,R,F,S")
                    {
                        IGPMessage gpMessage = messages.GetMessage(InputLinkReferenceFileFC14);
                        gpMessage.Type = esriGPMessageType.esriGPMessageTypeError;
                        gpMessage.Description = "Input value is not a valid Traffic Patterns Link reference file.";
                    }
                    f.Close();
                }
            }

            gpParam = paramvalues.get_Element(InputLinkReferenceFileFC5) as IGPParameter;
            IGPValue inputLinkReferenceFileFC5Value = m_gpUtils.UnpackGPValue(gpParam);
            if (!inputLinkReferenceFileFC5Value.IsEmpty())
            {
                string inputLinkReferenceFileFC5ValueAsText = inputLinkReferenceFileFC5Value.GetAsText();
                if (!(inputLinkReferenceFileFC5ValueAsText.EndsWith(".csv")))
                {
                    IGPMessage gpMessage = messages.GetMessage(InputTMCReferenceFile);
                    gpMessage.Type = esriGPMessageType.esriGPMessageTypeError;
                    gpMessage.Description = "Input value is not a .csv file.";
                }
                else
                {
                    System.IO.StreamReader f = new System.IO.StreamReader(inputLinkReferenceFileFC5ValueAsText);
                    string firstLine;
                    if ((firstLine = f.ReadLine()) == null)
                    {
                        IGPMessage gpMessage = messages.GetMessage(InputLinkReferenceFileFC5);
                        gpMessage.Type = esriGPMessageType.esriGPMessageTypeError;
                        gpMessage.Description = "Input value is an empty .csv file.";
                    }
                    else if (firstLine != "LINK_PVID,TRAVEL_DIRECTION,U,M,T,W,R,F,S")
                    {
                        IGPMessage gpMessage = messages.GetMessage(InputLinkReferenceFileFC5);
                        gpMessage.Type = esriGPMessageType.esriGPMessageTypeError;
                        gpMessage.Description = "Input value is not a valid Traffic Patterns Link reference file.";
                    }
                    f.Close();
                }
            }

            gpParam = paramvalues.get_Element(InputTMCReferenceFile) as IGPParameter;
            IGPValue inputTMCReferenceFileValue = m_gpUtils.UnpackGPValue(gpParam);
            if (!inputTMCReferenceFileValue.IsEmpty())
            {
                string inputTMCReferenceFileValueAsText = inputTMCReferenceFileValue.GetAsText();
                if (!(inputTMCReferenceFileValueAsText.EndsWith(".csv")))
                {
                    IGPMessage gpMessage = messages.GetMessage(InputTMCReferenceFile);
                    gpMessage.Type = esriGPMessageType.esriGPMessageTypeError;
                    gpMessage.Description = "Input value is not a .csv file.";
                }
                else
                {
                    System.IO.StreamReader f = new System.IO.StreamReader(inputTMCReferenceFileValueAsText);
                    string firstLine;
                    if ((firstLine = f.ReadLine()) == null)
                    {
                        IGPMessage gpMessage = messages.GetMessage(InputTMCReferenceFile);
                        gpMessage.Type = esriGPMessageType.esriGPMessageTypeError;
                        gpMessage.Description = "Input value is an empty .csv file.";
                    }
                    else if (firstLine != "TMC,U,M,T,W,R,F,S")
                    {
                        IGPMessage gpMessage = messages.GetMessage(InputTMCReferenceFile);
                        gpMessage.Type = esriGPMessageType.esriGPMessageTypeError;
                        gpMessage.Description = "Input value is not a valid Traffic Patterns TMC reference file.";
                    }
                    f.Close();
                }
            }

            gpParam = paramvalues.get_Element(InputSPDFile) as IGPParameter;
            IGPValue inputSPDFileValue = m_gpUtils.UnpackGPValue(gpParam);
            if (!inputSPDFileValue.IsEmpty())
            {
                string inputSPDFileValueAsText = inputSPDFileValue.GetAsText();
                if (!(inputSPDFileValueAsText.EndsWith(".csv")))
                {
                    IGPMessage gpMessage = messages.GetMessage(InputSPDFile);
                    gpMessage.Type = esriGPMessageType.esriGPMessageTypeError;
                    gpMessage.Description = "Input value is not a .csv file.";
                }
                else
                {
                    System.IO.StreamReader f = new System.IO.StreamReader(inputSPDFileValueAsText);
                    string firstLine;
                    if ((firstLine = f.ReadLine()) == null)
                    {
                        IGPMessage gpMessage = messages.GetMessage(InputSPDFile);
                        gpMessage.Type = esriGPMessageType.esriGPMessageTypeError;
                        gpMessage.Description = "Input value is an empty .csv file.";
                    }
                    else if (firstLine.Length != 682)
                    {
                        IGPMessage gpMessage = messages.GetMessage(InputSPDFile);
                        gpMessage.Type = esriGPMessageType.esriGPMessageTypeError;
                        gpMessage.Description = "Input value is not a valid 15-minute granular Traffic Patterns speed file.";
                    }
                    f.Close();
                }
            }

            // Verify chosen input US CndMod table has the expected fields

            gpParam = paramvalues.get_Element(InputUSCndModTable) as IGPParameter;
            tableValue = m_gpUtils.UnpackGPValue(gpParam);
            if (!tableValue.IsEmpty())
            {
                IDETable inputTable = m_gpUtils.DecodeDETable(tableValue);
                CheckForTableFields(inputTable, CndModFieldNames, CndModFieldTypes, messages.GetMessage(InputUSCndModTable));
            }

            // Verify chosen input Non-US CndMod table has the expected fields

            gpParam = paramvalues.get_Element(InputNonUSCndModTable) as IGPParameter;
            tableValue = m_gpUtils.UnpackGPValue(gpParam);
            if (!tableValue.IsEmpty())
            {
                IDETable inputTable = m_gpUtils.DecodeDETable(tableValue);
                CheckForTableFields(inputTable, CndModFieldNames, CndModFieldTypes, messages.GetMessage(InputNonUSCndModTable));
            }

            return;
        }
        public void UpdateMessages(IArray paramvalues, IGPEnvironmentManager pEnvMgr, IGPMessages messages)
        {
            // Check for error message

            IGPMessage msg = (IGPMessage)messages;
            if (msg.IsError())
                return;

            // Verify chosen output file geodatabase has a ".gdb" extension

            var gpParam = paramvalues.get_Element(OutputFileGDB) as IGPParameter;
            IGPValue outputFileGDBValue = m_gpUtils.UnpackGPValue(gpParam);
            if (!outputFileGDBValue.IsEmpty())
            {
                string outputFileGDBValueAsText = outputFileGDBValue.GetAsText();
                if (!(outputFileGDBValueAsText.EndsWith(".gdb")))
                {
                    IGPMessage gpMessage = messages.GetMessage(OutputFileGDB);
                    gpMessage.Type = esriGPMessageType.esriGPMessageTypeError;
                    gpMessage.Description = "Input value is not a valid file geodatabase path.";
                }
            }

            // Verify chosen output file geodatabase version is valid

            gpParam = paramvalues.get_Element(OutputFileGDBVersion) as IGPParameter;
            IGPValue outputFileGDBVersionValue = m_gpUtils.UnpackGPValue(gpParam);
            if (!outputFileGDBVersionValue.IsEmpty())
            {
                switch (outputFileGDBVersionValue.GetAsText())
                {
                    case "9.3":
                    case "10.0":
                    case "10.1":
                        // version is supported
                        break;
                    default:
                        IGPMessage gpMessage = messages.GetMessage(OutputFileGDBVersion);
                        gpMessage.Type = esriGPMessageType.esriGPMessageTypeError;
                        gpMessage.Description = "This version of the file geodatabase is not supported.";
                        break;
                }
            }

            // Verify chosen input NW feature class has the expected fields

            gpParam = paramvalues.get_Element(InputNWFeatureClass) as IGPParameter;
            IGPValue tableValue = m_gpUtils.UnpackGPValue(gpParam);
            if (!tableValue.IsEmpty())
            {
                IDETable inputTable = m_gpUtils.DecodeDETable(tableValue);
                CheckForTableFields(inputTable, NWFieldNames, NWFieldTypes, messages.GetMessage(InputNWFeatureClass));
            }

            // Verify chosen input MN feature class has the expected fields

            gpParam = paramvalues.get_Element(InputMNFeatureClass) as IGPParameter;
            tableValue = m_gpUtils.UnpackGPValue(gpParam);
            if (!tableValue.IsEmpty())
            {
                IDETable inputTable = m_gpUtils.DecodeDETable(tableValue);
                CheckForTableFields(inputTable, MNFieldNames, MNFieldTypes, messages.GetMessage(InputMNFeatureClass));
            }

            // Verify chosen input MP table has the expected fields

            gpParam = paramvalues.get_Element(InputMPTable) as IGPParameter;
            tableValue = m_gpUtils.UnpackGPValue(gpParam);
            if (!tableValue.IsEmpty())
            {
                IDETable inputTable = m_gpUtils.DecodeDETable(tableValue);
                CheckForTableFields(inputTable, MPFieldNames, MPFieldTypes, messages.GetMessage(InputMPTable));
            }

            // Verify chosen input SI table has the expected fields

            gpParam = paramvalues.get_Element(InputSITable) as IGPParameter;
            tableValue = m_gpUtils.UnpackGPValue(gpParam);
            if (!tableValue.IsEmpty())
            {
                IDETable inputTable = m_gpUtils.DecodeDETable(tableValue);
                CheckForTableFields(inputTable, SIFieldNames, SIFieldTypes, messages.GetMessage(InputSITable));
            }

            // Verify chosen input SP table has the expected fields

            gpParam = paramvalues.get_Element(InputSPTable) as IGPParameter;
            tableValue = m_gpUtils.UnpackGPValue(gpParam);
            if (!tableValue.IsEmpty())
            {
                IDETable inputTable = m_gpUtils.DecodeDETable(tableValue);
                CheckForTableFields(inputTable, SPFieldNames, SPFieldTypes, messages.GetMessage(InputSPTable));
            }

            // Verify chosen input RS table has the expected fields

            gpParam = paramvalues.get_Element(InputRSTable) as IGPParameter;
            tableValue = m_gpUtils.UnpackGPValue(gpParam);
            if (!tableValue.IsEmpty())
            {
                IDETable inputTable = m_gpUtils.DecodeDETable(tableValue);
                CheckForTableFields(inputTable, RSFieldNames, RSFieldTypes, messages.GetMessage(InputRSTable));
            }

            // Verify chosen input time zone table has the expected fields

            gpParam = paramvalues.get_Element(InputTimeZoneTable) as IGPParameter;
            tableValue = m_gpUtils.UnpackGPValue(gpParam);
            if (!tableValue.IsEmpty())
            {
                IDETable inputTable = m_gpUtils.DecodeDETable(tableValue);
                CheckForTableFields(inputTable, TimeZoneFieldNames, TimeZoneFieldTypes, messages.GetMessage(InputTimeZoneTable));
            }

            // Verify chosen input HSNP table has the expected fields

            gpParam = paramvalues.get_Element(InputHSNPTable) as IGPParameter;
            tableValue = m_gpUtils.UnpackGPValue(gpParam);
            if (!tableValue.IsEmpty())
            {
                IDETable inputTable = m_gpUtils.DecodeDETable(tableValue);
                CheckForTableFields(inputTable, HSNPFieldNames, HSNPFieldTypes, messages.GetMessage(InputHSNPTable));
            }

            // Verify chosen input HSPR table has the expected fields

            gpParam = paramvalues.get_Element(InputHSPRTable) as IGPParameter;
            tableValue = m_gpUtils.UnpackGPValue(gpParam);
            if (!tableValue.IsEmpty())
            {
                IDETable inputTable = m_gpUtils.DecodeDETable(tableValue);
                CheckForTableFields(inputTable, HSPRFieldNames, HSPRFieldTypes, messages.GetMessage(InputHSPRTable));
            }

            // Verify chosen input RD table has the expected fields

            gpParam = paramvalues.get_Element(InputRDTable) as IGPParameter;
            tableValue = m_gpUtils.UnpackGPValue(gpParam);
            if (!tableValue.IsEmpty())
            {
                IDETable inputTable = m_gpUtils.DecodeDETable(tableValue);
                CheckForTableFields(inputTable, RDFieldNames, RDFieldTypes, messages.GetMessage(InputRDTable));
            }

            // Verify chosen input LTR table has the expected fields

            gpParam = paramvalues.get_Element(InputLTRTable) as IGPParameter;
            tableValue = m_gpUtils.UnpackGPValue(gpParam);
            if (!tableValue.IsEmpty())
            {
                IDETable inputTable = m_gpUtils.DecodeDETable(tableValue);
                CheckForTableFields(inputTable, LTRFieldNames, LTRFieldTypes, messages.GetMessage(InputLTRTable));
            }

            // Verify chosen input LRS table has the expected fields

            gpParam = paramvalues.get_Element(InputLRSTable) as IGPParameter;
            tableValue = m_gpUtils.UnpackGPValue(gpParam);
            if (!tableValue.IsEmpty())
            {
                IDETable inputTable = m_gpUtils.DecodeDETable(tableValue);
                CheckForTableFields(inputTable, LRSFieldNames, LRSFieldTypes, messages.GetMessage(InputLRSTable));
            }

            // Verify chosen input LVC table has the expected fields

            gpParam = paramvalues.get_Element(InputLVCTable) as IGPParameter;
            tableValue = m_gpUtils.UnpackGPValue(gpParam);
            if (!tableValue.IsEmpty())
            {
                IDETable inputTable = m_gpUtils.DecodeDETable(tableValue);
                CheckForTableFields(inputTable, LVCFieldNames, LVCFieldTypes, messages.GetMessage(InputLVCTable));
            }

            return;
        }