コード例 #1
0
        /// <summary>
        /// Saves the form to Perforce.
        /// </summary>
        /// <param name="formCommand">The form command to run.</param>
        /// <param name="formSpec">The formatted spec.</param>
        /// <param name="args">Arguments to the form command.</param>
        /// <returns>P4UnParsedRecordSet.  Output can be parsed to verify the form was processed correctly.</returns>
        public P4UnParsedRecordSet Save_Form(string formCommand, string formSpec, params string[] args)
        {
            if (formCommand == null)
            {
                throw new ArgumentNullException("formCommand");
            }
            if (formCommand == string.Empty)
            {
                throw new ArgumentException("Parameter 'formCommand' can not be empty");
            }
            if (formSpec == null)
            {
                throw new ArgumentNullException("formSpec");
            }
            if (formSpec == string.Empty)
            {
                throw new ArgumentException("Parameter 'formSpec' can not be empt");
            }

            P4UnParsedRecordSet r  = new P4UnParsedRecordSet();
            P4RecordsetCallback cb = new P4RecordsetCallback(r);

            r.InputData = formSpec;
            List <string> formargs = new List <string>();

            foreach (string arg in args)
            {
                if (arg == "-i" || arg == "-o")
                {
                    throw new InvalidFormArgument();
                }
                formargs.Add(arg);
            }
            formargs.Add("-i");

            RunCallbackUnparsed(cb, formCommand, formargs.ToArray());

            if (((_exceptionLevel == P4ExceptionLevels.ExceptionOnBothErrorsAndWarnings ||
                  _exceptionLevel == P4ExceptionLevels.NoExceptionOnWarnings) &&
                 r.HasErrors())
                ||
                (_exceptionLevel == P4ExceptionLevels.ExceptionOnBothErrorsAndWarnings &&
                 r.HasWarnings())
                )
            {
                throw new RunUnParsedException(r);
            }
            return(r);
        }
コード例 #2
0
        /// <summary>
        /// Fetch a form object from Perforce.
        /// </summary>
        /// <param name="FormCommand">The form command.</param>
        /// <param name="Args">The args.</param>
        /// <returns>
        /// A Form object.  The fields of the form can be read or updated.  If you update a filed, you can save it with Save_Form.
        /// </returns>
        /// <include file='CodeDocuments.xml' path='//Forms/remarks' />
        public P4Form Fetch_Form(string FormCommand, params string[] Args)
        {
            if (FormCommand == null)
            {
                throw new ArgumentNullException();
            }
            if (Args == null)
            {
                throw new ArgumentNullException();
            }

            string[] AllArgs = new string[Args.Length + 1];
            AllArgs[0] = "-o";

            for (int i = 0; i < Args.Length; i++)
            {
                if (Args[i] == null)
                {
                    throw new ArgumentNullException();
                }
                if (Args[i] == "-o")
                {
                    throw new InvalidFormArgument();
                }
                AllArgs[i + 1] = Args[i];
            }

            EstablishConnection(true);

            P4FormRecordSet     r  = new P4FormRecordSet(FormCommand, m_ClientApi.Encoding);
            P4RecordsetCallback cb = new P4RecordsetCallback(r);

            //RunIt(FormCommand, AllArgs, r.ResultClientUser);
            RunCallback(cb, FormCommand, AllArgs);

            // The Fetch_Form command must always throw an error
            // because there will be no form to return if there's a
            // problem
            if (r.HasErrors())
            {
                throw new FormFetchException(FormCommand, r.ErrorMessage);
            }

            // save the spec def, in case Parse_Form is called in the future
            cachedSpecDefs[FormCommand] = r.Form.SpecDef;

            return(r.Form);
        }
コード例 #3
0
        /// <summary>
        /// Executes a Perforce command in tagged mode.
        /// </summary>
        /// <param name="Command">The command.</param>
        /// <param name="Args">The arguments to the Perforce command.  Remember to use a dash (-) in front of all switches</param>
        /// <returns>A P4Recordset containing the results of the command.</returns>
        public P4RecordSet Run(string Command, params string[] Args)
        {
            EstablishConnection(true);
            P4RecordSet         r  = new P4RecordSet();
            P4RecordsetCallback cb = new P4RecordsetCallback(r);

            RunCallback(cb, Command, Args);
            if (((_exceptionLevel == P4ExceptionLevels.ExceptionOnBothErrorsAndWarnings ||
                  _exceptionLevel == P4ExceptionLevels.NoExceptionOnWarnings) &&
                 r.HasErrors())
                ||
                (_exceptionLevel == P4ExceptionLevels.ExceptionOnBothErrorsAndWarnings &&
                 r.HasWarnings())
                )
            {
                throw new RunException(r);
            }


            return(r);
        }
コード例 #4
0
        /// <summary>
        /// Login to the Perforce Server
        /// </summary>
        /// <param name="password">The password.</param>
        public void Login(string password)
        {
            if (password == null)
            {
                throw new ArgumentNullException();
            }

            // if password is empty, then don't do anything
            if (password == string.Empty)
            {
                return;
            }

            P4ExceptionLevels oldLevel = _exceptionLevel;

            try
            {
                P4UnParsedRecordSet r  = new P4UnParsedRecordSet();
                P4RecordsetCallback cb = new P4RecordsetCallback(r);
                r.LoginPassword = password;
                string[] Args = { };
                _exceptionLevel = P4ExceptionLevels.NoExceptionOnErrors;


                RunCallbackUnparsed(cb, "login", Args);

                //for good measure delete the password
                r.LoginPassword = null;

                if (r.HasErrors())
                {
                    throw new P4API.Exceptions.InvalidLogin(r.ErrorMessage);
                }
            }
            finally
            {
                _exceptionLevel = oldLevel;
            }
        }
コード例 #5
0
        /// <summary>
        /// Executes a Perforce command in non-tagged mode.
        /// </summary>
        /// <param name="Command">The command.</param>
        /// <param name="Args">The args.</param>
        /// <returns></returns>
        public P4UnParsedRecordSet RunUnParsed(string Command, params string[] Args)
        {
            P4UnParsedRecordSet r  = new P4UnParsedRecordSet();
            P4RecordsetCallback cb = new P4RecordsetCallback(r);

            P4BaseRecordSet.OnPromptEventHandler handler = new P4BaseRecordSet.OnPromptEventHandler(this.HandleOnPrompt);
            r.OnPrompt += handler;
            RunCallbackUnparsed(cb, Command, Args);
            r.OnPrompt -= handler;

            if (((_exceptionLevel == P4ExceptionLevels.ExceptionOnBothErrorsAndWarnings ||
                  _exceptionLevel == P4ExceptionLevels.NoExceptionOnWarnings) &&
                 r.HasErrors())
                ||
                (_exceptionLevel == P4ExceptionLevels.ExceptionOnBothErrorsAndWarnings &&
                 r.HasWarnings())
                )
            {
                throw new RunUnParsedException(r);
            }

            return(r);
        }
コード例 #6
0
ファイル: P4Connection.cs プロジェクト: orecht/P4.net
        /// <summary>
        /// Saves the form to Perforce.
        /// </summary>
        /// <param name="formCommand">The form command to run.</param>
        /// <param name="formSpec">The formatted spec.</param>
        /// <param name="args">Arguments to the form command.</param>
        /// <returns>P4UnParsedRecordSet.  Output can be parsed to verify the form was processed correctly.</returns>
        public P4UnParsedRecordSet Save_Form(string formCommand, string formSpec, params string[] args)
        {
            if (formCommand == null) throw new ArgumentNullException("formCommand");
            if (formCommand == string.Empty) throw new ArgumentException("Parameter 'formCommand' can not be empty");
            if (formSpec == null) throw new ArgumentNullException("formSpec");
            if (formSpec == string.Empty) throw new ArgumentException("Parameter 'formSpec' can not be empt");

            P4UnParsedRecordSet r = new P4UnParsedRecordSet();
            P4RecordsetCallback cb = new P4RecordsetCallback(r);
            r.InputData = formSpec;
            List<string> formargs = new List<string>();
            foreach (string arg in args)
            {
                if (arg == "-i" || arg == "-o")
                {
                    throw new InvalidFormArgument();
                }
                formargs.Add(arg);
            }
            formargs.Add("-i");

            RunCallbackUnparsed(cb, formCommand, formargs.ToArray());
        
            if (((_exceptionLevel == P4ExceptionLevels.ExceptionOnBothErrorsAndWarnings
                 || _exceptionLevel == P4ExceptionLevels.NoExceptionOnWarnings)
                 && r.HasErrors())
                ||
                  (_exceptionLevel == P4ExceptionLevels.ExceptionOnBothErrorsAndWarnings
                   && r.HasWarnings())
                )
            {
                throw new RunUnParsedException(r);
            }
            return r;
        }
コード例 #7
0
ファイル: P4Connection.cs プロジェクト: orecht/P4.net
        /// <summary>
        /// Fetch a form object from Perforce.
        /// </summary>
        /// <param name="FormCommand">The form command.</param>
        /// <param name="Args">The args.</param>
        /// <returns>
        /// A Form object.  The fields of the form can be read or updated.  If you update a filed, you can save it with Save_Form.
        /// </returns>
        /// <include file='CodeDocuments.xml' path='//Forms/remarks' />
        public P4Form Fetch_Form(string FormCommand, params string[] Args)
        {
            if (FormCommand == null) throw new ArgumentNullException();
            if (Args == null) throw new ArgumentNullException();

            string[] AllArgs = new string[Args.Length + 1];
            AllArgs[0] = "-o";

            for (int i = 0; i < Args.Length ; i++)
            {
                if (Args[i] == null)
                {
                    throw new ArgumentNullException();
                }
                if (Args[i] == "-o")
                {
                    throw new InvalidFormArgument();
                }
                AllArgs[i+1] = Args[i];
            }

            EstablishConnection(true);

            P4FormRecordSet r = new P4FormRecordSet(FormCommand, m_ClientApi.Encoding);
            P4RecordsetCallback cb = new P4RecordsetCallback(r);

            //RunIt(FormCommand, AllArgs, r.ResultClientUser);
            RunCallback(cb, FormCommand, AllArgs);

            // The Fetch_Form command must always throw an error
            // because there will be no form to return if there's a 
            // problem
            if (r.HasErrors())
            {
                throw new FormFetchException(FormCommand, r.ErrorMessage);
            }

            // save the spec def, in case Parse_Form is called in the future
            cachedSpecDefs[FormCommand] = r.Form.SpecDef;

            return r.Form;
        }
コード例 #8
0
ファイル: P4Connection.cs プロジェクト: orecht/P4.net
        /// <summary>
        /// Executes a Perforce command in non-tagged mode.
        /// </summary>
        /// <param name="Command">The command.</param>
        /// <param name="Args">The args.</param>
        /// <returns></returns>
        public P4UnParsedRecordSet RunUnParsed(string Command, params string[] Args)
        {
            P4UnParsedRecordSet r = new P4UnParsedRecordSet();
            P4RecordsetCallback cb = new P4RecordsetCallback(r);
            P4BaseRecordSet.OnPromptEventHandler handler = new P4BaseRecordSet.OnPromptEventHandler(this.HandleOnPrompt);
            r.OnPrompt += handler;
            RunCallbackUnparsed(cb, Command, Args);
            r.OnPrompt -= handler;

            if (((_exceptionLevel == P4ExceptionLevels.ExceptionOnBothErrorsAndWarnings
                 || _exceptionLevel == P4ExceptionLevels.NoExceptionOnWarnings)
                 && r.HasErrors())
                ||
                  (_exceptionLevel == P4ExceptionLevels.ExceptionOnBothErrorsAndWarnings
                   && r.HasWarnings())
                )
            {
                throw new RunUnParsedException(r);
            }

            return r;
        }
コード例 #9
0
ファイル: P4Connection.cs プロジェクト: orecht/P4.net
        /// <summary>
        /// Executes a Perforce command in tagged mode.
        /// </summary>
        /// <param name="Command">The command.</param>
        /// <param name="Args">The arguments to the Perforce command.  Remember to use a dash (-) in front of all switches</param>
        /// <returns>A P4Recordset containing the results of the command.</returns>
        public P4RecordSet Run(string Command, params string[] Args)
        {
            EstablishConnection(true);
            P4RecordSet r = new P4RecordSet();
            P4RecordsetCallback cb = new P4RecordsetCallback(r);

            RunCallback(cb, Command, Args);
            if (((_exceptionLevel == P4ExceptionLevels.ExceptionOnBothErrorsAndWarnings
                 || _exceptionLevel == P4ExceptionLevels.NoExceptionOnWarnings)
                 && r.HasErrors())
                ||
                  (_exceptionLevel == P4ExceptionLevels.ExceptionOnBothErrorsAndWarnings
                   && r.HasWarnings())
                )
            {
                throw new RunException(r);
            }


            return r;
        }
コード例 #10
0
ファイル: P4Connection.cs プロジェクト: orecht/P4.net
        /// <summary>
        /// Login to the Perforce Server
        /// </summary>
        /// <param name="password">The password.</param>
        public void Login(string password)
        {
            if (password == null) throw new ArgumentNullException();
            
            // if password is empty, then don't do anything
            if (password == string.Empty) return;

            P4ExceptionLevels oldLevel = _exceptionLevel;
            try
            {
                P4UnParsedRecordSet r = new P4UnParsedRecordSet();
                P4RecordsetCallback cb = new P4RecordsetCallback(r);
                r.LoginPassword = password;
                string[] Args = { };
                _exceptionLevel = P4ExceptionLevels.NoExceptionOnErrors;
                
               
                RunCallbackUnparsed(cb, "login", Args);

                //for good measure delete the password
                r.LoginPassword = null;

                if (r.HasErrors())
                {
                    throw new P4API.Exceptions.InvalidLogin(r.ErrorMessage);
                }
            }
            finally
            {
                _exceptionLevel = oldLevel;
            }

        }