Checking in and out active document file

Checking in and out active document file

iakhun
Explorer Explorer
995 Views
1 Reply
Message 1 of 2

Checking in and out active document file

iakhun
Explorer
Explorer

Hello All,

I'm writing an automation for Autocad. I need my application to check in an active documents file and stay checked out.

I wrote the following code using the examples. But it fails to check in the file into Vault. Can anyone help me with my problem.

 

 

        public static void CheckIn(string fileName)
        {
            VDF.Vault.Results.LogInResult login_results = VDF.Vault.Library.ConnectionManager.LogIn(Settings.VAULT_IP, Settings.VAULT_NAME, Settings.VAULT_USER, "", VDF.Vault.Currency.Connections.AuthenticationFlags.WindowsAuthentication, null);
            VDF.Vault.Currency.Connections.Connection conn = null;

            if (login_results.Success)
            {

                conn = login_results.Connection;
            }
            else
            {

                MessageBox.Show("Couldn't login");
                return;
            }

            var fileIteration = getFileIteration(fileName, conn);


            //check if file Exists
            if (!System.IO.File.Exists(fileIteration.CheckedOutSpec))
            {
                Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("The file you are attempting to check in does not exist on disk.");
                VDF.Vault.Library.ConnectionManager.LogOut(conn);
                return;
            }

            if (fileIteration.IsCheckedOut)
            {
                conn.FileManager.CheckinFile(fileIteration, "Take off update", true, new Autodesk.Connectivity.WebServices.FileAssocParam[] { }, null, false, fileName, fileIteration.FileClassification, false);
            }

        }
        private static FileIteration getFileIteration(string fileName, Connection conn)
        {
            SrchCond[] conditions = new SrchCond[1];
            long lCode = 1;

            var Defs = conn.WebServiceManager.PropertyService.GetPropertyDefinitionsByEntityClassId("FILE");

            PropDef Prop = null;

            foreach (var def in Defs)
            {
                if (def.DispName == "File Name")
                {
                    Prop = def;
                    break;
                }

            }

            var searchCondition = new Autodesk.Connectivity.WebServices.SrchCond();

            searchCondition.PropDefId = Prop.Id;
            searchCondition.SrchOper = lCode;
            searchCondition.SrchTxt = Path.GetFileName(fileName);

            conditions[0] = searchCondition;

           List<Autodesk.Connectivity.WebServices.File> fileList = new List<Autodesk.Connectivity.WebServices.File> ();

            String sBookmark = "";
            SrchStatus Status = null;

            Autodesk.Connectivity.WebServices.File[] files = null;

            while(Status == null || fileList.Count < Status.TotalHits)
            {
                files = conn.WebServiceManager.DocumentService.FindFilesBySearchConditions(conditions, null, null, true, true, ref sBookmark, out Status);

                if (files != null)
                {
                    fileList.AddRange(files);
                }
            }

            VDF.Vault.Currency.Entities.FileIteration oFileIteration = new VDF.Vault.Currency.Entities.FileIteration(conn, fileList[0]);

            return oFileIteration;

        }

I get the following error message:

 

{System.Web.Services.Protocols.SoapException: 1108
at Autodesk.Connectivity.WebServices.DocumentSvc._DocumentService.Execute(String methodName, Object[] parameters, IWebServiceCommandEventsCollection events, WebServiceCommandEventArgs args)
at Autodesk.Connectivity.WebServices.DocumentService.CheckinUploadedFile(Int64 fileMasterId, String comment, Boolean keepCheckedOut, DateTime lastWrite, FileAssocParam[] associations, BOM bom, Boolean copyBom, String newFileName, FileClassification fileClassification, Boolean hidden, ByteArray uploadticket)
at Autodesk.DataManagement.Client.Framework.Vault.Services.Connection.Implementation.FileManager.CheckinFile(FileIteration file, String comment, Boolean keepCheckedOut, DateTime lastWrite, FileAssocParam[] associations, BOM bom, Boolean copyBom, String newFileName, FileClassification classification, Boolean hidden, Stream inputStream)
at Autodesk.DataManagement.Client.Framework.Vault.Services.Connection.Implementation.FileManager.CheckinFile(FileIteration file, String comment, Boolean keepCheckedOut, FileAssocParam[] associations, BOM bom, Boolean copyBom, String newFileName, FileClassification classification, Boolean hidden, FilePathAbsolute filePath)
at CWVDuctImport.VaultInterface.CheckIn(String fileName) in H:\cwv-mobile-client\src\acad\cwvtools\vaultinterface.cs:line 195
at CWVDuctImport.Commands.cwv_iterate() in H:\cwv-mobile-client\src\acad\cwvtools\commands.cs:line 1161
at Autodesk.AutoCAD.Runtime.CommandClass.InvokeWorker(MethodInfo mi, Object commandObject, Boolean bLispFunction)
at Autodesk.AutoCAD.Runtime.CommandClass.InvokeWorkerWithExceptionFilter(MethodInfo mi, Object commandObject, Boolean bLispFunction)
at Autodesk.AutoCAD.Runtime.CommandClass.CommandThunk.Invoke()}

 

0 Likes
Accepted solutions (1)
996 Views
1 Reply
Reply (1)
Message 2 of 2

iakhun
Explorer
Explorer
Accepted solution

I found the problem. The parameter fileName was incorrect. It contained the full path rather then just the file name.

0 Likes