Microsoft.Protocols.TestSuites.MS_COPYS.MS_COPYSSUTControlAdapter.UndoCheckOutFileByUser C# (CSharp) Method

UndoCheckOutFileByUser() public method

A method used to undo checkout for a file by specified user credential.
public UndoCheckOutFileByUser ( string fileUrl, string userName, string password, string domain ) : bool
fileUrl string A parameter represents the absolute URL of a file which will be undo checkout by specified user.
userName string A parameter represents the user name which will check out the file. The file must be stored in the destination SUT which is indicated by "SutComputerName" property in "SharePointCommonConfiguration.deployment.ptfconfig" file.
password string A parameter represents the password of the user.
domain string A parameter represents the domain of the user.
return bool
        public bool UndoCheckOutFileByUser(string fileUrl, string userName, string password, string domain)
        {
            #region parameter validation
            FileUrlHelper.ValidateFileUrl(fileUrl);

            if (string.IsNullOrEmpty(userName))
            {
                throw new ArgumentNullException("userName");
            }

            #endregion parameter validation

            if (null == this.listswsProxy)
            {
                throw new InvalidOperationException("The LISTSWS proxy is not initialized, should call the [Initialize] method before calling this method.");
            }

            this.listswsProxy.Credentials = new NetworkCredential(userName, password, domain);

            bool undoCheckOutResult;
            try
            {
                undoCheckOutResult = this.listswsProxy.UndoCheckOut(fileUrl);
            }
            catch (SoapException soapEx)
            {
                this.Site.Log.Add(
                                LogEntryKind.Debug,
                                @"There is an exception generated when the SUT control adapter try to undo check out for a file[{0}]:\r\nExcetption Message:\r\n[{1}]\r\\nStackTrace:\r\n[{2}]",
                                fileUrl,
                                string.IsNullOrEmpty(soapEx.Message) ? "None" : soapEx.Message,
                                string.IsNullOrEmpty(soapEx.StackTrace) ? "None" : soapEx.StackTrace);
                return false;
            }
            finally
            {
                this.listswsProxy.Credentials = TestSuiteManageHelper.DefaultUserCredential;
            }

            return undoCheckOutResult;
        }