示例#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;
            }
        }
示例#2
0
文件: P4Message.cs 项目: mh52/P4.net
 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();
 }
示例#3
0
        public override void Prompt(string msg, ref string rsp, bool noEcho, p4dn.Error err)
        {
            // don't give the consumer any more messages if we're in an error state
            if (DeferedException != null)
            {
                return;
            }

            rsp = _P4Result.RaiseOnPromptEvent(msg);
        }
示例#4
0
        public override void Edit(System.IO.FileInfo f1, p4dn.Error err)
        {
            // don't give the consumer any more messages if we're in an error state
            if (DeferedException != null)
            {
                return;
            }

            // this only happens when the user is fetching a form w/o using FetchForm method.
            DeferedException = new P4API.Exceptions.FormCommandException();
        }
示例#5
0
        public override void ErrorPause(string errBuf, p4dn.Error err)
        {
            if (DeferedException != null)
            {
                return;
            }

            // don't know how this would be called.  AFIK, the only way to get here is to fill out a form
            // incorrectly, and other code should deal with that.
            DeferedException = new P4API.Exceptions.ErrorPauseCalled();
        }
示例#6
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);
        }
示例#7
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));
        }
示例#8
0
 public override void HandleError(p4dn.Error err)
 {
     if (DeferedException != null)
     {
         return;
     }
     try
     {
         _callback.OutputMessage(new P4Message(err));
     }
     catch (Exception e)
     {
         DeferedException = e;
     }
 }
示例#9
0
 public override void Prompt(string msg, ref string rsp, bool noEcho, p4dn.Error err)
 {
     if (DeferedException != null)
     {
         return;
     }
     try
     {
         _callback.Prompt(msg, ref rsp);
     }
     catch (Exception e)
     {
         DeferedException = e;
     }
 }
示例#10
0
 public override void InputData(ref string buff, p4dn.Error err)
 {
     System.Text.StringBuilder sb = new StringBuilder();
     if (DeferedException == null)
     {
         try
         {
             _callback.InputData(sb);
         }
         catch (Exception e)
         {
             DeferedException = e;
         }
     }
     buff = sb.ToString();
 }
示例#11
0
文件: P4Form.cs 项目: orecht/P4.net
        /// <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);

        }
示例#12
0
 public override void Message(p4dn.Error err)
 {
     // if we get any message, it's an error??
 }
示例#13
0
        public override void Merge(System.IO.FileInfo @base, System.IO.FileInfo leg1, System.IO.FileInfo leg2, System.IO.FileInfo result, p4dn.Error err)
        {
            // don't give the consumer any more messages if we're in an error state
            if (DeferedException != null)
            {
                return;
            }

            DeferedException = new Exceptions.MergeNotImplemented();;
        }
示例#14
0
文件: P4Form.cs 项目: orecht/P4.net
 /// <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;
 }
示例#15
0
        public override void Diff(System.IO.FileInfo f1, System.IO.FileInfo f2, int doPage, string diffFlags, p4dn.Error err)
        {
            // don't give the consumer any more messages if we're in an error state
            if (DeferedException != null)
            {
                return;
            }

            DeferedException = new Exceptions.DiffNotImplemented();
        }
示例#16
0
 public override void InputData(ref string buff, p4dn.Error err)
 {
     buff = _P4Result.InputData;
 }
示例#17
0
 public override void InputForm(ref Hashtable varList, ref string specdef, p4dn.Error err)
 {
     specdef = _P4Result.SpecDef;
     varList = _P4Result.FormInput;
 }
示例#18
0
 public override void HandleError(p4dn.Error err)
 {
     _P4Result.AddError(err.Fmt());
 }