예제 #1
0
        private string MessageIdToText(DataExchangeMessageId id)
        {
            string messageText = "";

            try
            {
                messageText = m_messageList[id];
            }
            catch (System.Collections.Generic.KeyNotFoundException)
            {
                TaskDialog.Show("Conversion log", "Message id not found"); // debug message - shouldn't be visible to users. probably shouldn't be in TaskDialog.
            }
            catch (System.ArgumentNullException)
            {
                TaskDialog.Show("ConversionLog", "Invalid message id"); // debug message - shouldn't be visible to users. probably shouldn't be in TaskDialog.
            }

            return(messageText);
        }
예제 #2
0
        public virtual bool ProcessMessage(DataExchangeMessageId messageId, DataExchangeMessageSeverity messageSeverity, System.Collections.Generic.IList <string> entityIds)
        {
            // First update counters
            switch (messageSeverity)
            {
            case DataExchangeMessageSeverity.FatalError:
            {
                //WriteLine(Properties.Resource.ErrorMessage_OnFatalError);
                FatalError = true;
                break;   // we always abort on a fatal error
            }

            case DataExchangeMessageSeverity.Error:
                ErrorCount += 1;
                break;

            case DataExchangeMessageSeverity.Warning:
                WarningCount += 1;
                break;

            case DataExchangeMessageSeverity.Info:
                break;

            default:
                break; // should have a debug message
            }


            // Next pick up messages that need special treatment

            switch (messageId)
            {
            case DataExchangeMessageId.ObjectCreated:
                // log created objects. The entityIds list is expected to contain object types as strings.
                foreach (var name in entityIds)
                {
                    if (!m_convertedEntityList.ContainsKey(name))
                    {
                        m_convertedEntityList.Add(name, 1); // first time we see this type
                    }
                    else
                    {
                        m_convertedEntityList[name] += 1;
                    }
                }
                return(true); // logged another entity converted, continue

            //case DataExchangeMessageId.ObjectNotSupported:
            //// log not yet supported objects that were skipped during conversion. The entityIds list is expected to contain object types as strings.
            //   foreach (var name in entityIds)
            //   {
            //      if (!m_skippedEntityList.ContainsKey(name))
            //      {
            //         m_skippedEntityList.Add(name, 1); // first time we see this type
            //      }
            //      else
            //      {
            //         m_skippedEntityList[name] += 1;
            //      }
            //   }
            //   return true; // logged another entity converted, continue

            case DataExchangeMessageId.UnitOfProgressCompleted:
                return(!CancelRequested); // CancelRequested == true means UI requested a cancellation. Not enabled in UI yet
            }

            // report other messages


            m_logStream.WriteLine();
            WriteLine(MessageIdToText(messageId));

            //WriteReportedEntities(Properties.Resource.LogMessage_EntitiesProcessed , entityIds);

            if (CancelCondition <= messageSeverity) // Cancel condition is less or equal to current message severity: terminate
            {
                //WriteReportedEntities(Properties.Resource.LogMessage_ConversionCancelled, entityIds);
                return(false);
            }


            // TODO: design and implement a cancel condition. Possibly reuse the severity or verbosity enum: cancel at error, at warning, etc.
            return(true);
        }