Exemple #1
0
        public override void Message(p4dn.Error err)
        {
            switch (err.Severity)
            {
            case p4dn.Error.ErrorSeverity.Empty:      // E_EMPTY (0) | no error
                // Is this ever even a legit severity???  I've never hit it in my testing.
                _P4Result.AddString(err.Fmt());
                break;

            case p4dn.Error.ErrorSeverity.Info:      // E_INFO  (1) | information, not necessarily an error
                _P4Result.AddInfo(err.Fmt());
                break;

            case p4dn.Error.ErrorSeverity.Warning:      // E_WARN  (2) | a minor error occurred
                _P4Result.AddWarning(err.Fmt());
                break;

            case p4dn.Error.ErrorSeverity.Failed:      // E_FAILED(3) | the command was used incorrectly
                _P4Result.AddError(err.Fmt());
                break;

            case p4dn.Error.ErrorSeverity.Fatal:      // E_FATAL (4) | fatal error, the command can't be processed
                _P4Result.AddError(err.Fmt());
                break;

            default:
                //TODO throw an error... unknown severity
                break;
            }
        }
Exemple #2
0
 internal P4Message(p4dn.Error error)
 {
     // cache all the data from the error so we don't have to implement IDisposable
     _vars = new SortedDictionary <string, string>();
     error.GetVariables(_vars);
     _id       = error.GetErrorID().code;
     _severity = (P4MessageSeverity)error.GetErrorID().Severity();
     _format   = error.Fmt();
 }
Exemple #3
0
        /// <summary>
        /// Formats the P4Form as a formated Perforce spec.
        /// </summary>
        /// <returns>String of the formated form spec.</returns>
        public string FormatSpec()
        {
            string ret = null;

            using (p4dn.Error err = new p4dn.Error(_encoding))
            {
                ret = _spec.Format(base.AllFieldDictionary, err);
                if (err.Test())
                {
                    throw new Exceptions.FormParseException(_formCommand, err.Fmt());
                }
            }
            return(ret);
        }
Exemple #4
0
        /// <summary>
        /// Parses a Perforce form without making a server connection.
        /// </summary>
        /// <param name="formCommand">The command that would otherwise be used to fetch the form.</param>
        /// <param name="specDef">The Perforce 'specdef' for the form.</param>
        /// <param name="formContents">The raw formated form text.</param>
        /// <param name="encoding">Server encoding (either ANSI or UFT-8).</param>
        /// <returns>A Perforce form object.</returns>
        /// <remarks>
        /// LoadFromSpec can be used to parse a form without making a call to the server.
        /// LoadFromSpec can be useful in form triggers.
        /// It does require you to know the SpecDef to call, which can change when upgrading or changing
        /// the server configuration.
        /// </remarks>
        public static P4Form LoadFromSpec(string formCommand, string specDef, string formContents, System.Text.Encoding encoding)
        {
            p4dn.Spec spec = new p4dn.Spec(specDef, encoding);
            Hashtable ht   = null;

            using (p4dn.Error err = new p4dn.Error(encoding))
            {
                ht = spec.Parse(formContents, err);
                if (err.Test())
                {
                    throw new Exceptions.FormParseException(formCommand, err.Fmt());
                }
            }
            return(new P4Form(formCommand, specDef, ht, encoding));
        }
Exemple #5
0
        /// <summary>
        /// Parses a Perforce form without making a server connection.
        /// </summary>
        /// <param name="formCommand">The command that would otherwise be used to fetch the form.</param>
        /// <param name="specDef">The Perforce 'specdef' for the form.</param>
        /// <param name="formContents">The raw formated form text.</param>
        /// <param name="encoding">Server encoding (either ANSI or UFT-8).</param>
        /// <returns>A Perforce form object.</returns>
        /// <remarks>
        /// LoadFromSpec can be used to parse a form without making a call to the server.  
        /// LoadFromSpec can be useful in form triggers.
        /// It does require you to know the SpecDef to call, which can change when upgrading or changing
        /// the server configuration.
        /// </remarks>
        public static P4Form LoadFromSpec(string formCommand, string specDef, string formContents, System.Text.Encoding encoding)
        {

            p4dn.Spec spec = new p4dn.Spec(specDef, encoding);
            Dictionary<string, string> ht = null;
            using (p4dn.Error err = new p4dn.Error(encoding))
            {
                ht = spec.Parse(formContents, err);
                if (err.Test())
                {
                    throw new Exceptions.FormParseException(formCommand, err.Fmt());
                }
            }
            return new P4Form(formCommand, specDef, ht, encoding);

        }
Exemple #6
0
 public override void HandleError(p4dn.Error err)
 {
     _P4Result.AddError(err.Fmt());
 }
Exemple #7
0
 /// <summary>
 /// Formats the P4Form as a formated Perforce spec.
 /// </summary>
 /// <returns>String of the formated form spec.</returns>
 public string FormatSpec()
 {
     string ret = null;
     using (p4dn.Error err = new p4dn.Error(_encoding))
     {
         ret = _spec.Format(base.AllFieldDictionary, err);
         if (err.Test())
         {
             throw new Exceptions.FormParseException(_formCommand, err.Fmt());
         }
     }
     return ret;
 }