コード例 #1
0
        private void objectListView1_SelectionChanged(object sender, EventArgs e)
        {
            if (objectListView1.SelectedItem != null)
            {
                string selectedItemName = ((PartToImport)objectListView1.SelectedItem.RowObject).name;

                selectedItemName = selectedItemName + ".ipt";

                Autodesk.Connectivity.WebServices.File    webServicesFile = selectedFiles.FirstOrDefault(sel => sel.Name == selectedItemName);
                VDF.Vault.Currency.Entities.FileIteration fileIter        = new Vault.Currency.Entities.FileIteration(connection, webServicesFile);

                picBoxIpt.Image = ResizeImage(getThumbNail(fileIter), 115, 115);

                string selectedSymName = symFolder + System.IO.Path.GetFileNameWithoutExtension(selectedItemName) + ".sym";

                if (System.IO.File.Exists(selectedSymName))
                {
                    ShellFile shellFile  = ShellFile.FromFilePath(selectedSymName);
                    Bitmap    shellThumb = shellFile.Thumbnail.Bitmap;
                    this.picBoxSym.Image = ResizeImage(shellThumb, 115, 115);
                }
                else
                {
                    this.picBoxSym.Image = null;
                }

                toolStripStatusLabel.Text = "";
                progressBar.Value         = 0;

                objectListView1.Refresh();
            }
        }
コード例 #2
0
        /*****************************************************************************************/
        public static List <AWS.FileAssocParam> UpdateFileAssociations(VDF.Vault.Currency.Connections.Connection connection,
                                                                       VDF.Vault.Currency.Entities.FileIteration fileIterationParent,
                                                                       List <AWS.FileAssocLite> fileAssocsLite)
        {
            List <AWS.FileAssocParam> fileAssocParams = new List <AWS.FileAssocParam>();

            foreach (AWS.FileAssocLite fileAssocLite in fileAssocsLite)
            {
                AWS.File childAsReferenced = connection.WebServiceManager.DocumentService.GetFileById(fileAssocLite.CldFileId);

                // of any reason, the parent is referenced by it self in the list, but we dont want that
                if (fileIterationParent.EntityMasterId == childAsReferenced.MasterId)
                {
                    continue;
                }

                AWS.File childLatest = connection.WebServiceManager.DocumentService.GetLatestFileByMasterId(childAsReferenced.MasterId);

                AWS.FileAssocParam fileAssocParam = new AWS.FileAssocParam();

                fileAssocParam.CldFileId         = childLatest.Id;
                fileAssocParam.RefId             = fileAssocLite.RefId;
                fileAssocParam.Source            = fileAssocLite.Source;
                fileAssocParam.Typ               = fileAssocLite.Typ;
                fileAssocParam.ExpectedVaultPath = fileAssocLite.ExpectedVaultPath;
                fileAssocParams.Add(fileAssocParam);
            }

            return(fileAssocParams);
        }
コード例 #3
0
        public static FileState GetLastRelevantFileState(int fileVersion, long fileMasterId, Vault.Currency.Connections.Connection connection, ref AWS.File releasedFile, List <string> states, List <string> invalidStates)
        {
            AWS.File file = connection.WebServiceManager.DocumentService.GetFileByVersion(fileMasterId, fileVersion);

            foreach (string state in states)
            {
                if (file.FileLfCyc.LfCycStateName.Equals(state, StringComparison.CurrentCultureIgnoreCase))
                {
                    releasedFile = file;
                    return(FileState.Ok);
                }
                // else if (file.FileLfCyc.LfCycStateName.Equals("Obsolete", StringComparison.CurrentCultureIgnoreCase))
                //  return FileState.Obsolete;
            }
            foreach (string state in invalidStates)
            {
                if (file.FileLfCyc.LfCycStateName.Equals(state, StringComparison.CurrentCultureIgnoreCase))
                {
                    return(FileState.Obsolete);
                }
            }
            try
            {
                if (string.IsNullOrWhiteSpace(file.FileLfCyc.LfCycStateName))
                {
                    return(FileState.None);
                }
                return(fileVersion == 1 ? FileState.None : GetLastRelevantFileState(fileVersion - 1, fileMasterId, connection, ref releasedFile, states, invalidStates));
            }
            catch
            {
                return(FileState.None);
            }
        }
コード例 #4
0
 public DownloadFile(Autodesk.Connectivity.WebServices.File file, string downloadPath, bool writable, bool run)
     : base(downloadPath)
 {
     File     = file;
     Writable = writable;
     Run      = run;
 }
コード例 #5
0
        /// <summary>
        /// Returns result of operation.
        /// </summary>

        /*public IEnumerable<FilePath> Files
         * {
         *  get { return _files; }
         * }*/

        /// <summary>
        /// Finds orphaned files in given folders.
        /// </summary>
        /// <param name="folders"></param>
        public void GenerateAndAdd(IEnumerable <Item> items)
        {
            //_files.Clear();
            foreach (Item item in items)
            {
                if (CanContinue() == false)
                {
                    return;
                }
                Item       itemRev = ServiceManager.ItemService.GetLatestItemByItemNumber(item.ItemNum);
                PropInst[] props;
                props = ServiceManager.PropertyService.GetProperties("ITEM", new long[] { item.Id }, new long[] { 109 });
                String KiestraProductGroup = "";
                if (props[0].Val != null)
                {
                    KiestraProductGroup = props[0].Val.ToString();
                }
                if ((KiestraProductGroup == "1100") ||
                    (KiestraProductGroup == "3000") ||
                    (KiestraProductGroup == "4000") ||
                    (KiestraProductGroup == "7000") ||
                    IgnoreKPG)
                {
                    Autodesk.Connectivity.WebServices.File iptiamfile = FindIptIamFile(itemRev);
                    if (iptiamfile != null)
                    {
                        bool AllFinal = true;
                        if (IgnoreDS == false)
                        {
                            FilePathArray[] fparray = ServiceManager.DocumentService.GetLatestAssociatedFilePathsByMasterIds(new long[] { iptiamfile.MasterId }, FileAssociationTypeEnum.None, false, FileAssociationTypeEnum.Dependency, true, false, true, false);
                            foreach (FilePath fp in fparray[0].FilePaths)
                            {
                                props = ServiceManager.PropertyService.GetProperties("FILE", new long[] { fp.File.Id }, new long[] { 44 });
                                if (props[0].Val == null)
                                {
                                    AllFinal = false;
                                }
                                else
                                {
                                    AllFinal = AllFinal && (props[0].Val.ToString() == "Final");
                                }
                            }
                        }
                        if (AllFinal || IgnoreDS)
                        {
                            ProcessItem(itemRev, iptiamfile);
                        }
                        else
                        {
                            OnItemStatusUpdate(new ItemStatusUpdateEventArgs(item, "Not all dependencies are Final"));
                        }
                    }
                }
                else
                {
                    OnItemStatusUpdate(new ItemStatusUpdateEventArgs(item, "Invalid Product Group"));
                }
            }
        }
コード例 #6
0
        /// <summary>
        /// Check in updated file back into Vault
        /// </summary>
        /// <returns>void</returns>
        public static void CheckinFileStream(byte[] filecontents)
        {
            ByteArray uploadTckt = UploadFileResource(filecontents);

            Autodesk.Connectivity.WebServices.File checkedinFile = _connection.WebServiceManager.DocumentService.CheckinUploadedFile(checkedoutfile.MasterId,
                                                                                                                                     "Updated Comments via DA", false, DateTime.Now, null, null, true, checkedoutfile.Name,
                                                                                                                                     checkedoutfile.FileClass, checkedoutfile.Hidden, uploadTckt);
        }
コード例 #7
0
ファイル: FileHelper.cs プロジェクト: 15831944/ZSharpHelpers
 public static File geFilebyID(VDF.Vault.Currency.Connections.Connection connection, long fileID)
 {
     Autodesk.Connectivity.WebServices.File selectedFile = null;
     try
     {
         selectedFile = connection.WebServiceManager.DocumentService.GetLatestFileByMasterId(fileID);
     }
     catch (SystemException ex)
     {
         Debug.Write(ex.ToString());
         //MessageBox.Show(ex.ToString());
     }
     return(selectedFile);
 }
コード例 #8
0
        internal void CheckOutFile(long masterId)
        {
            Autodesk.Connectivity.WebServices.File latestFileVersion =
                _webServiceManager.DocumentService.FindLatestFilesByMasterIds(new long[] { masterId }).First();
            ByteArray ticket = null;

            _webServiceManager.DocumentService.CheckoutFile(
                latestFileVersion.Id,
                CheckoutFileOptions.Master,
                null,
                null,
                "Data Migration - Updating File Revision",
                out ticket);
        }
コード例 #9
0
        private void DownloadFile(ADSK.File file, string filePath)
        {
            // remove the read-only attribute
            if (System.IO.File.Exists(filePath))
            {
                System.IO.File.SetAttributes(filePath, System.IO.FileAttributes.Normal);
            }

            VDF.Vault.Settings.AcquireFilesSettings settings = new VDF.Vault.Settings.AcquireFilesSettings(connection);

            Vault.Currency.Entities.FileIteration fIter = new Vault.Currency.Entities.FileIteration(connection, file);
            settings.AddFileToAcquire(fIter, VDF.Vault.Settings.AcquireFilesSettings.AcquisitionOption.Download, new VDF.Currency.FilePathAbsolute(filePath));

            connection.FileManager.AcquireFiles(settings);
        }
コード例 #10
0
ファイル: Util.cs プロジェクト: smilinger/Vault-Thunderdome
        public static Autodesk.Connectivity.WebServices.File AddOrUpdateFile(
            string localPath, string fileName, Folder vaultFolder, Connection conn)
        {
            string vaultPath = vaultFolder.FullName + "/" + fileName;

            Autodesk.Connectivity.WebServices.File[] result = conn.WebServiceManager.DocumentService.FindLatestFilesByPaths(
                vaultPath.ToSingleArray());

            Autodesk.Connectivity.WebServices.File retVal = null;
            if (result == null || result.Length == 0 || result[0].Id < 0)
            {
                VDF.Vault.Currency.Entities.Folder vdfFolder = new VDF.Vault.Currency.Entities.Folder(
                    conn, vaultFolder);

                // using a stream so that we can set a different file name
                using (FileStream stream = new FileStream(localPath, FileMode.Open, FileAccess.Read))
                {
                    VDF.Vault.Currency.Entities.FileIteration newFile = conn.FileManager.AddFile(
                        vdfFolder, fileName, "Thunderdome deployment",
                        System.IO.File.GetLastWriteTime(localPath), null, null,
                        FileClassification.None, false, stream);

                    retVal = newFile;
                }
            }
            else
            {
                VDF.Vault.Currency.Entities.FileIteration vdfFile = new VDF.Vault.Currency.Entities.FileIteration(conn, result[0]);

                AcquireFilesSettings settings = new AcquireFilesSettings(conn);
                settings.AddEntityToAcquire(vdfFile);
                settings.DefaultAcquisitionOption = AcquireFilesSettings.AcquisitionOption.Checkout;
                AcquireFilesResults results = conn.FileManager.AcquireFiles(settings);

                if (results.FileResults.First().Exception != null)
                {
                    throw results.FileResults.First().Exception;
                }

                vdfFile = results.FileResults.First().File;
                vdfFile = conn.FileManager.CheckinFile(vdfFile, "Thunderdome deployment", false,
                                                       null, null, false, null, FileClassification.None, false, localPath.ToVDFPath());

                retVal = vdfFile;
            }

            return(retVal);
        }
コード例 #11
0
ファイル: FileHelper.cs プロジェクト: 15831944/ZSharpHelpers
 public static string getPathbyFileID(VDF.Vault.Currency.Connections.Connection connection, long fileID)
 {
     try
     {
         Autodesk.Connectivity.WebServices.File selectedFile = null;
         selectedFile = connection.WebServiceManager.DocumentService.GetLatestFileByMasterId(fileID);
         Autodesk.Connectivity.WebServices.Folder fld = connection.WebServiceManager.DocumentService.GetFolderById(selectedFile.FolderId);
         resultVal = fld.FullName + "/" + selectedFile.Name;
     }
     catch (SystemException ex)
     {
         Debug.Write(ex.ToString());
         //MessageBox.Show(ex.ToString());
     }
     return(resultVal);
 }
コード例 #12
0
 internal void UpdateLifeCycleStateInfo(long masterID, out long revMasterId, out long revFileId)
 {
     try
     {
         _webServiceManager.DocumentServiceExtensions.UpdateFileLifeCycleStates(
             new long[] { masterID }, new long[] { _settings.ReleasedStateID }, "Data Migration - Released new File Revision");
         Autodesk.Connectivity.WebServices.File file =
             _webServiceManager.DocumentService.FindLatestFilesByMasterIds(
                 new long[] { masterID }).First();
         revMasterId = file.MasterId;
         revFileId   = file.Id;
     }
     catch (Exception ex)
     {
         throw (ex);
     }
 }
コード例 #13
0
        private void PopulateListBox()
        {
            PartsToImport.Clear();

            foreach (ISelection selection in selectionSet)
            {
                Autodesk.Connectivity.WebServices.File selectedFile = null;
                if (selection.TypeId == SelectionTypeId.File)
                {
                    // our ISelection.Id is really a File.MasterId
                    selectedFile = connection.WebServiceManager.DocumentService.GetLatestFileByMasterId(selection.Id);
                }
                else if (selection.TypeId == SelectionTypeId.FileVersion)
                {
                    // our ISelection.Id is really a File.Id
                    selectedFile = connection.WebServiceManager.DocumentService.GetFileById(selection.Id);
                }

                if (selectedFile != null)
                {
                    if (selectedFile.Name.EndsWith(".ipt"))
                    {
                        PartToImport part = new PartToImport();
                        part.name = selectedFile.Name.Replace(".ipt", "");

                        VDF.Vault.Currency.Entities.FileIteration fileIter = new Vault.Currency.Entities.FileIteration(connection, selectedFile);
                        part.desc = GetERPDescriptionProperty(fileIter);

                        part.thickness    = radInterface.GetThicknessFromSym(symFolder + part.name + ".sym");
                        part.materialType = radInterface.GetMaterialTypeFromSym(symFolder + part.name + ".sym");
                        part.qty          = 0;

                        PartsToImport.Add(part);
                        selectedFiles.Add(selectedFile);
                    }
                }
            }

            if (PartsToImport.Count > 0)
            {
                objectListView1.SetObjects(PartsToImport);
            }
        }
コード例 #14
0
        private Autodesk.Connectivity.WebServices.File FindIptIamFile(Item item)
        {
            ItemFileAssoc[] associations = ServiceManager.ItemService.GetItemFileAssociationsByItemIds(new long[] { item.Id }, ItemFileLnkTypOpt.Primary);
            string          ext          = "";

            Autodesk.Connectivity.WebServices.File iptiamfile = null;
            //kunnen er meer primary associated files zijn?
            foreach (ItemFileAssoc association in associations)
            {
                ext = System.IO.Path.GetExtension(association.FileName);
                if ((ext == ".ipt") || (ext == ".iam"))
                {
                    iptiamfile = ServiceManager.DocumentService.GetFileById(association.CldFileId);
                    OnItemFileUpdate(new ItemFileUpdateEventArgs(item, iptiamfile.Name, iptiamfile.FileRev.Label));
                    return(iptiamfile);
                }
            }
            OnItemFileUpdate(new ItemFileUpdateEventArgs(item, "Not found", "-"));
            OnItemStatusUpdate(new ItemStatusUpdateEventArgs(item, "Failed"));
            return(null);
        }
コード例 #15
0
        /// <summary>
        /// Downloads file from Vault
        /// </summary>
        /// <returns>Array of bytes if successful</returns>
        public static byte[] DownloadFileStream(out string fileName)
        {
            fileName = string.Empty;
            try
            {
                Autodesk.Connectivity.WebServices.File file = SelectFilefromUI();
                fileName = file.Name;

                checkedoutfile = _connection.WebServiceManager.DocumentService.CheckoutFile
                                     (file.Id, CheckoutFileOptions.Master, Environment.MachineName, string.Empty, "Checking out file", out _);

                ByteArray dwldTckt  = _connection.WebServiceManager.DocumentService.GetDownloadTicketsByFileIds(new long[] { checkedoutfile.Id }).First();
                byte[]    filebytes = DownloadFileResource(dwldTckt, false);
                return(filebytes);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Select file from UI failed: " + ex.Message);
                return(null);
            }
        }
コード例 #16
0
ファイル: FileHelper.cs プロジェクト: 15831944/ZSharpHelpers
 public static File gefilebyfilePath(VDF.Vault.Currency.Connections.Connection connection, string filePath)
 {
     Autodesk.Connectivity.WebServices.File selectedFile = null;
     try
     {
         if (checkifFileExists(connection, filePath))
         {
             selectedFile = connection.WebServiceManager.DocumentService.FindLatestFilesByPaths(filePath.ToSingleArray()).First();
         }
         else
         {
             return(null);
         }
     }
     catch (SystemException ex)
     {
         Debug.Write(ex.ToString());
         //MessageBox.Show(ex.ToString());
     }
     return(selectedFile);
 }
コード例 #17
0
ファイル: FileHelper.cs プロジェクト: 15831944/ZSharpHelpers
        public static string downloadVaultFilebyID(VDF.Vault.Currency.Connections.Connection connection, string path, long selectedFileID)
        {
            try
            {
                using (WebServiceManager serviceManager = connection.WebServiceManager)
                {
                    Autodesk.Connectivity.WebServices.File localFile = serviceManager.DocumentService.GetFileById(selectedFileID);
                    var FileDownloadTicket            = serviceManager.DocumentService.GetDownloadTicketsByFileIds(new long[] { selectedFileID });
                    FilestoreService fileStoreService = serviceManager.FilestoreService;
                    var fileBytes = fileStoreService.DownloadFilePart(FileDownloadTicket[0].Bytes, 0, localFile.FileSize, false);
                    //MessageBox.Show(path + "\\" + localFile.Name);
                    System.IO.File.WriteAllBytes(path + "\\" + localFile.Name, fileBytes);


                    //Check if file exist
                    if (!System.IO.File.Exists(path + "\\" + localFile.Name))
                    {
                        //failedFiles.Add(file);
                        statusMess = "File Download Failed!";
                        ZGHCC.writeLog(statusMess);
                    }
                    else
                    {
                        statusMess = path + "\\" + localFile.Name;
                        //fileExt = System.IO.Path.GetExtension(localFile.Name);
                        ZGHCC.writeLog(statusMess);
                    }
                }

                //statusMess = "Success";
            }
            catch (SystemException ex)
            {
                statusMess = null;
                Debug.Write("\nError: " + ex.ToString());
                statusMess = "Error: \n" + ex.ToString();
            }
            return(statusMess);
            //Autodesk.Connectivity.WebServices.File localFile = serviceManager.DocumentService.GetFileById(file.Id);
        }
コード例 #18
0
        protected void AddFileToDownload(ADSK.File file, string filePath)
        {
            ChangeStatusMessage("Evaluating " + file.Name);

            // remove the read-only attribute
            if (System.IO.File.Exists(filePath))
            {
                System.IO.File.SetAttributes(filePath, FileAttributes.Normal);
            }

            FileIteration fileIter = new FileIteration(m_conn, file);

            if (m_useWorkingFolder)
            {
                m_aquireFilesSettings.AddFileToAcquire(fileIter, AcquireFilesSettings.AcquisitionOption.Download);
            }
            else
            {
                m_aquireFilesSettings.AddFileToAcquire(fileIter, AcquireFilesSettings.AcquisitionOption.Download,
                                                       new FilePathAbsolute(filePath));
            }
        }
コード例 #19
0
        public ACJE.JobOutcome Execute(ACJE.IJobProcessorServices context, ACJE.IJob job)
        {
            long fileMasterId = Convert.ToInt64(job.Params["FileMasterId"]);

            try
            {
                // Retrieve the file object from the server
                //
                ACW.File file = context.Connection.WebServiceManager.DocumentService.GetLatestFileByMasterId(fileMasterId);
                VDF.Vault.Currency.Entities.FileIteration fileIter =
                    context.Connection.FileManager.GetFilesByIterationIds(new long[] { file.Id }).First().Value;

                // Download and publish the file
                //
                Publish(fileIter, context.Connection);

                return(ACJE.JobOutcome.Success);
            }
            catch
            {
                return(ACJE.JobOutcome.Failure);
            }
        }
コード例 #20
0
        public static string downloadVaultFiles(VDF.Vault.Currency.Connections.Connection connection, string path, List <ISelection> filesColl)
        {
            try
            {
                //var settings = new VDF.Vault.Settings.AcquireFilesSettings(Global.variables.connection, updateFileReferences: false);
                //settings.LocalPath = new VDF.Currency.FolderPathAbsolute(Global.variables.fileStore);

                if (filesColl.Count > 0)
                {
                    foreach (var file in filesColl)
                    {
                        File selectedFile = null;
                        // Look of the File object.
                        if (file.TypeId == SelectionTypeId.File)
                        {
                            // our ISelection.Id is really a File.MasterId
                            selectedFile = connection.WebServiceManager.DocumentService.GetLatestFileByMasterId(file.Id);
                        }
                        else if (file.TypeId == SelectionTypeId.FileVersion)
                        {
                            // our ISelection.Id is really a File.Id
                            selectedFile = connection.WebServiceManager.DocumentService.GetFileById(file.Id);
                        }
                        if (selectedFile != null)
                        {
                            using (WebServiceManager serviceManager = connection.WebServiceManager)
                            {
                                Autodesk.Connectivity.WebServices.File localFile = serviceManager.DocumentService.GetFileById(selectedFile.Id);
                                var FileDownloadTicket            = serviceManager.DocumentService.GetDownloadTicketsByFileIds(new long[] { selectedFile.Id });
                                FilestoreService fileStoreService = serviceManager.FilestoreService;
                                var fileBytes = fileStoreService.DownloadFilePart(FileDownloadTicket[0].Bytes, 0, localFile.FileSize, false);
                                //MessageBox.Show(path + "\\" + selectedFile.Name);
                                System.IO.File.WriteAllBytes(path + "\\" + selectedFile.Name, fileBytes);


                                //Check if file exist
                                if (!System.IO.File.Exists(path + "\\" + selectedFile.Name))
                                {
                                    //failedFiles.Add(file);
                                    statusMess += "\n" + path + "\\" + selectedFile.Name + " - File Check Issue";
                                }
                                else
                                {
                                    statusMess += "\n" + path + "\\" + selectedFile.Name + " - Success";
                                }
                            }
                        }
                        //MessageBox.Show(String.Format("Hello World! The file {0} size is: {1} bytes", selectedFile.Name, selectedFile.FileSize));
                    }
                    statusMess = "Success";
                }
            }
            catch (SystemException ex)
            {
                statusMess = null;
                Debug.Write("\nError: " + ex.ToString());
                statusMess = "Error: \n" + ex.ToString();
            }
            return(statusMess);
            //Autodesk.Connectivity.WebServices.File localFile = serviceManager.DocumentService.GetFileById(file.Id);
        }
コード例 #21
0
        private void ConfigureThunderdome(string serverName, string vaultName, CommandItemEventArgs e)
        {
            Connection conn = e.Context.Application.Connection;

            if (!Util.IsAdmin(conn))
            {
                MessageBox.Show("Only administrators can use this function");
                return;
            }

            //string userFolder = m_mgr.KnowledgeVaultService.GetVaultOption(USER_FOLDER_OPTION);
            string          deployFolderPath = conn.WebServiceManager.KnowledgeVaultService.GetVaultOption(DEFAULT_FOLDER_OPTION);
            string          deploymentXml    = conn.WebServiceManager.KnowledgeVaultService.GetVaultOption(DEPLOYMENT_CONFIG_OPTION);
            DeploymentModel deploymentModel  = DeploymentModel.Load(deploymentXml);

            Configure    cfgDialog = new Configure(deployFolderPath, deploymentModel, vaultName, conn);
            DialogResult result    = cfgDialog.ShowDialog();

            if (result != DialogResult.OK)
            {
                return;
            }

            DeploymentModel deploymentModel2 = cfgDialog.GetSelectedDataModel();

            if (!deploymentModel2.Containers.Any())
            {
                return;
            }

            // zip up the files and upload to Vault
            string  tempFile = System.IO.Path.GetTempFileName();
            ZipFile zip      = ZipFile.Create(tempFile);

            zip.BeginUpdate();


            foreach (DeploymentContainer container in deploymentModel2.Containers)
            {
                foreach (DeploymentItem item in container.DeploymentItems)
                {
                    item.Zip(zip, container);
                }
            }

            zip.CommitUpdate();
            zip.Close();

            Folder deployFolder = cfgDialog.DeploymentFolder;

            conn.WebServiceManager.KnowledgeVaultService.SetVaultOption(DEFAULT_FOLDER_OPTION, deployFolder.FullName);

            Autodesk.Connectivity.WebServices.File vaultPackage = Util.AddOrUpdateFile(
                tempFile, PACKAGE_NAME, deployFolder, conn);

            System.IO.File.Delete(tempFile);

            // we just updated the package, so we are definately up to date.
            Settings   settings = Settings.Load();
            VaultEntry entry    = settings.GetOrCreateEntry(serverName, vaultName);

            entry.LastUpdate = vaultPackage.CkInDate;
            settings.Save();

            deploymentXml = deploymentModel2.ToXml();
            conn.WebServiceManager.KnowledgeVaultService.SetVaultOption(DEPLOYMENT_CONFIG_OPTION, deploymentXml);

            MessageBox.Show("Deployment Created");
            e.Context.ForceRefresh = true;
            e.Context.GoToLocation = new LocationContext(SelectionTypeId.File, deployFolder.FullName + "/" + PACKAGE_NAME);
            return;
        }
コード例 #22
0
        public ACJE.JobOutcome Execute(ACJE.IJobProcessorServices context, ACJE.IJob job)
        {
            long   EntityId = Convert.ToInt64(job.Params["EntityId"]);
            string logText  = "";
            string errText  = "";

            ACJE.JobOutcome jobOutComeStatus = ACJE.JobOutcome.Success;
            try
            {
                // Retrieve the file object from the server
                //
                ACW.File[] fileArray = new ACW.File[10];    // I hope there's never more than 11 files returned :(
                long[]     EntityIDArray = new long[1];
                string     logString = "", errString = "";

                EntityIDArray[0] = EntityId;
                try
                {
                    fileArray = context.Connection.WebServiceManager.DocumentService.GetLatestFilesByIds(EntityIDArray);
                }
                catch (Exception)
                {
                    // if the above call fails, we know the vault file that we want to process doesn't exist anymore
                    // so we don't worry about it and call it a success!
                    context.Log("No vault file found", ACJE.MessageType.eInformation);
                    return(ACJE.JobOutcome.Success);
                }
                context.Log("number of items in array: " + fileArray.Length + "\n\r", ACJE.MessageType.eInformation);


                VDF.Vault.Currency.Entities.FileIteration fileIter =
                    context.Connection.FileManager.GetFilesByIterationIds(new long[] { fileArray[0].Id }).First().Value;

                if (GetVaultCheckOutComment(fileIter, context.Connection) != "IM")
                {
                    // check for PDF files
                    if (PDFfileUpdate(fileIter, context.Connection, ref logString, ref errString))
                    {
                        logText += "Processing PDF File for " + fileIter.ToString() + "...\n";
                        logText += logString + "\n";  // information returned from FileUpdate
                        context.Log(logText, ACJE.MessageType.eInformation);
                        jobOutComeStatus = ACJE.JobOutcome.Success;
                    }
                    else
                    {
                        errText  = "Error in processing PDF File for " + fileIter.ToString();
                        errText += errString + "\n";  // information returned from FileUpdate
                        context.Log(errText, ACJE.MessageType.eError);
                        jobOutComeStatus = ACJE.JobOutcome.Failure;
                    }

                    // check for sym files
                    int symUpdateVal = processRadanFile(fileIter, false);
                    if (symUpdateVal == 1)
                    {
                        logText += "Moved Radan File for " + fileIter.ToString() + "...\n";
                        context.Log(logText, ACJE.MessageType.eInformation);
                        if (jobOutComeStatus != ACJE.JobOutcome.Failure)
                        {
                            jobOutComeStatus = ACJE.JobOutcome.Success;
                        }
                    }
                    else if (symUpdateVal == 0)
                    {
                        logText = "No Radan File moved for " + fileIter.ToString() + "...\n";
                        context.Log(logText, ACJE.MessageType.eInformation);
                        if (jobOutComeStatus != ACJE.JobOutcome.Failure)
                        {
                            jobOutComeStatus = ACJE.JobOutcome.Success;
                        }
                    }
                    else if (symUpdateVal == -1)
                    {
                        errText = "Error in processing Radan File for " + fileIter.ToString();
                        context.Log(errText, ACJE.MessageType.eError);
                        jobOutComeStatus = ACJE.JobOutcome.Failure;
                    }

                    return(jobOutComeStatus);
                }
                else
                {
                    logText = "Skipping over " + fileIter.ToString() + "because only item master properties were changed";
                    context.Log(logText, ACJE.MessageType.eInformation);
                    return(ACJE.JobOutcome.Success);
                }
            }
            catch
            {
                context.Log(logText, ACJE.MessageType.eError);
                return(ACJE.JobOutcome.Failure);
            }
        }
コード例 #23
0
        /// <summary>
        /// Find file by 1 to many search criteria as property/value pairs.
        /// Downloads the first file matching all search criterias; include many as required to get the unique file.
        /// Preset Search Operator Options: [Property] is (exactly) [Value]; multiple conditions link up using AND condition.
        /// Preset Download Options: Download Children (recursively) = Enabled, Enforce Overwrite = True
        /// </summary>
        /// <param name="conn">Current Vault Connection</param>
        /// <param name="SearchCriteria">Dictionary of property/value pairs</param>
        /// <returns>Local path/filename</returns>
        public string mGetFilebySearchCriteria(VDF.Vault.Currency.Connections.Connection conn, Dictionary <string, string> SearchCriteria)
        {
            AWS.PropDef[] mFilePropDefs = conn.WebServiceManager.PropertyService.GetPropertyDefinitionsByEntityClassId("FILE");
            //iterate mSearchcriteria to get property definitions and build AWS search criteria
            List <AWS.SrchCond> mSrchConds = new List <AWS.SrchCond>();
            int             i            = 0;
            List <AWS.File> totalResults = new List <AWS.File>();

            foreach (var item in SearchCriteria)
            {
                AWS.PropDef  mFilePropDef = mFilePropDefs.Single(n => n.DispName == item.Key);
                AWS.SrchCond mSearchCond  = new AWS.SrchCond();
                {
                    mSearchCond.PropDefId = mFilePropDef.Id;
                    mSearchCond.PropTyp   = AWS.PropertySearchType.SingleProperty;
                    mSearchCond.SrchOper  = 1; //equals
                    if (i == 0)
                    {
                        mSearchCond.SrchRule = AWS.SearchRuleType.May;
                    }
                    else
                    {
                        mSearchCond.SrchRule = AWS.SearchRuleType.Must;
                    }
                    mSearchCond.SrchTxt = item.Value;
                }
                mSrchConds.Add(mSearchCond);
                i++;
            }
            string bookmark = string.Empty;

            AWS.SrchStatus status = null;

            while (status == null || totalResults.Count < status.TotalHits)
            {
                AWS.File[] mSrchResults = conn.WebServiceManager.DocumentService.FindFilesBySearchConditions(
                    mSrchConds.ToArray(), null, null, false, true, ref bookmark, out status);
                if (mSrchResults != null)
                {
                    totalResults.AddRange(mSrchResults);
                }
                else
                {
                    break;
                }
            }
            //if results not empty
            if (totalResults.Count == 1)
            {
                AWS.File wsFile = totalResults.First <AWS.File>();
                VDF.Vault.Currency.Entities.FileIteration mFileIt = new VDF.Vault.Currency.Entities.FileIteration(conn, (wsFile));

                VDF.Vault.Settings.AcquireFilesSettings settings = new VDF.Vault.Settings.AcquireFilesSettings(conn);
                settings.DefaultAcquisitionOption = VCF.Vault.Settings.AcquireFilesSettings.AcquisitionOption.Download;
                settings.OptionsRelationshipGathering.FileRelationshipSettings.IncludeChildren        = true;
                settings.OptionsRelationshipGathering.FileRelationshipSettings.RecurseChildren        = true;
                settings.OptionsRelationshipGathering.FileRelationshipSettings.VersionGatheringOption = VDF.Vault.Currency.VersionGatheringOption.Latest;
                settings.OptionsRelationshipGathering.IncludeLinksSettings.IncludeLinks = false;
                VCF.Vault.Settings.AcquireFilesSettings.AcquireFileResolutionOptions mResOpt = new VCF.Vault.Settings.AcquireFilesSettings.AcquireFileResolutionOptions();
                mResOpt.OverwriteOption           = VCF.Vault.Settings.AcquireFilesSettings.AcquireFileResolutionOptions.OverwriteOptions.ForceOverwriteAll;
                mResOpt.SyncWithRemoteSiteSetting = VCF.Vault.Settings.AcquireFilesSettings.SyncWithRemoteSite.Always;
                settings.AddFileToAcquire(mFileIt, VDF.Vault.Settings.AcquireFilesSettings.AcquisitionOption.Download);
                VDF.Vault.Results.AcquireFilesResults results = conn.FileManager.AcquireFiles(settings);
                if (results != null)
                {
                    VDF.Vault.Results.FileAcquisitionResult mFilesDownloaded = results.FileResults.Last();
                    return(mFilesDownloaded.LocalPath.FullPath.ToString());
                }
                else
                {
                    return("FileNotFound");
                }
            }
            else
            {
                return("FileNotFound");
            }
        }
コード例 #24
0
        /*****************************************************************************************/
        public static Option <string> GetPropertyString(ADMC.Framework.Vault.Currency.Connections.Connection connection, AWS.File file, string propertyName)
        {
            Option <AWS.PropDef> propertyDefinition = GetPropertyDefinition(connection, propertyName);

            if (propertyDefinition.IsNone)
            {
                return(Option.None);
            }

            AWS.PropInst[] properties = connection.WebServiceManager.PropertyService.GetProperties("FILE", new long[] { file.Id }, new long[] { propertyDefinition.Get().Id });
            if (properties[0].Val == null)
            {
                return(Option.None);
            }

            return(properties[0].Val.ToString().AsOption());
        }
コード例 #25
0
        private bool ConvertFile(string NameOfPartToConvert, ref string ErrorMessage)
        {
            toolStripStatusLabel.Text = "";
            progressBar.Value         = 0;
            progressBar.PerformStep();
            string  selectedItemIptName = NameOfPartToConvert + ".ipt";
            string  errorMessage        = "";
            string  materialName        = "";
            string  partThickness       = "";
            string  topPattern          = "";
            string  partName            = "";
            string  partDescription     = "";
            string  partUnits           = "in";
            Boolean overWriteConfirm    = true;
            string  openProjectName     = "";
            string  openNestName        = "";

            try
            {
                openProjectName = radInterface.getOpenProjectName(ref errorMessage);

                string symFileName = symFolder + NameOfPartToConvert + ".sym";
                if (System.IO.File.Exists(symFileName))
                {
                    DialogResult      result;
                    MessageBoxButtons buttons = MessageBoxButtons.YesNo;
                    result = MessageBox.Show("The sym file already exists. Do you want to overwrite it?", "Confirm Overwrite", buttons);
                    if (result == DialogResult.Yes)
                    {
                        overWriteConfirm = true;
                    }
                    else
                    {
                        overWriteConfirm = false;
                        System.IO.File.SetLastWriteTimeUtc(symFileName, DateTime.UtcNow);
                    }
                }

                if (overWriteConfirm == true)
                {
                    Autodesk.Connectivity.WebServices.File    webServicesFile = selectedFiles.FirstOrDefault(sel => sel.Name == selectedItemIptName);
                    VDF.Vault.Currency.Entities.FileIteration fileIter        = new Vault.Currency.Entities.FileIteration(connection, webServicesFile);
                    PartToImport modifiedPart = new PartToImport();
                    string       filePath     = System.IO.Path.Combine(System.IO.Path.GetTempPath(), fileIter.EntityName);

                    PartToImport partToModify = PartsToImport.FirstOrDefault(sel => sel.name == NameOfPartToConvert);
                    int          index        = objectListView1.IndexOf(partToModify);
                    modifiedPart.name = PartsToImport[index].name;

                    partDescription   = GetERPDescriptionProperty(fileIter);
                    modifiedPart.desc = partDescription;

                    // remove old ipt from temp folder to ensure we will use the lastest version
                    if (System.IO.File.Exists(filePath))
                    {
                        System.IO.File.SetAttributes(filePath, FileAttributes.Normal);
                    }
                    System.IO.File.Delete(filePath);

                    radInterface.SaveNest(ref errorMessage);
                    openNestName = radInterface.getOpenNestName(ref errorMessage);

                    toolStripStatusLabel.Text = "Downloading File...";
                    DownloadFile(fileIter, filePath);
                    progressBar.PerformStep();

                    toolStripStatusLabel.Text = "Saving Radan Nest...";

                    if (!radInterface.SaveNest(ref errorMessage))
                    {
                        ErrorMessage = errorMessage;
                        toolStripStatusLabel.Text = errorMessage;
                        return(false);
                    }
                    else
                    {
                        progressBar.PerformStep();
                    }

                    toolStripStatusLabel.Text = "Opening 3D File...";
                    if (!radInterface.Open3DFileInRadan(filePath, "", ref errorMessage))
                    {
                        ErrorMessage = errorMessage;
                        toolStripStatusLabel.Text = errorMessage;
                        return(false);
                    }
                    else
                    {
                        progressBar.PerformStep();
                    }

                    toolStripStatusLabel.Text = "Unfolding 3D File...";
                    if (!radInterface.UnfoldActive3DFile(ref partName, ref materialName, ref partThickness, ref topPattern, ref errorMessage))
                    {
                        ErrorMessage = errorMessage;
                        toolStripStatusLabel.Text = errorMessage;
                        return(false);
                    }
                    else
                    {
                        progressBar.PerformStep();
                    }

                    toolStripStatusLabel.Text = "Saving Sym File...";
                    if (!radInterface.SavePart(topPattern, symFileName, ref errorMessage))
                    {
                        ErrorMessage = errorMessage;
                        toolStripStatusLabel.Text = errorMessage;
                        return(false);
                    }
                    else
                    {
                        progressBar.PerformStep();
                    }

                    toolStripStatusLabel.Text = "Setting Radan Attributes...";
                    if (!radInterface.InsertAttributes(symFileName, materialName, partThickness, partUnits, partDescription, ref errorMessage))
                    {
                        ErrorMessage = errorMessage;
                        toolStripStatusLabel.Text = errorMessage;
                        return(false);
                    }
                    else
                    {
                        progressBar.PerformStep();
                    }

                    toolStripStatusLabel.Text = "Done...";
                    double thickness = double.Parse(partThickness);

                    if (thickness <= 0.001)
                    {
                        toolStripStatusLabel.Text = "Part Thickness Could Not Be Calculated, Aborting Operation";
                        return(false);
                    }
                    else
                    {
                        modifiedPart.thickness    = thickness.ToString();
                        modifiedPart.materialType = materialName;
                        progressBar.PerformStep();
                    }

                    PartsToImport[index] = modifiedPart;

                    ShellFile shellFile  = ShellFile.FromFilePath(symFileName);
                    Bitmap    shellThumb = shellFile.Thumbnail.Bitmap;
                    this.picBoxSym.Image = ResizeImage(shellThumb, 115, 115);

                    if (openProjectName != "")
                    {
                        radInterface.LoadProject(openProjectName);
                    }

                    if (openNestName != "")
                    {
                        radInterface.openNest(openNestName, ref errorMessage);
                    }
                }
                return(true);
            }

            catch (Exception)
            {
                errorMessage = "Error in converting File";
                return(false);
            }
        }
コード例 #26
0
        /*****************************************************************************************/
        public static bool IsPlotDateBeforeCheckedInDate(ADSK.WebServicesTools.WebServiceManager webService, AWS.File file)
        {
            long plotDateId  = webService.PropertyService.GetPropertyDefinitionsByEntityClassId("FILE").First(p => p.DispName == "Date Exported").Id;
            long checkedInId = webService.PropertyService.GetPropertyDefinitionsByEntityClassId("FILE").First(p => p.DispName == "Checked In").Id;

            AWS.PropInst[]    props       = webService.PropertyService.GetProperties("FILE", new long[] { file.Id }, new long[] { checkedInId, plotDateId });
            DateTime          checkInDate = (DateTime)props[0].Val;
            Option <DateTime> plotDate    = Option.None;

            try
            { plotDate = ((DateTime)props[1].Val).AsOption(); }
            catch
            { plotDate = Option.None; }

            if ((plotDate.IsNone) || ((plotDate.IsSome) && ((DateTime.Compare(checkInDate.Subtract(new TimeSpan(0, 30, 0)), plotDate.Get()) > 0))))
            {
                return(true);
            }

            return(false);
        }
コード例 #27
0
        private List </*Tuple<ADSK.File, string, bool, bool>*/ VaultEagleLib.Model.DataStructures.DownloadItem> FindFilesChangedSinceLastSync(VDF.Vault.Currency.Connections.Connection connection, bool useLastSyncTime, DateTime lastSyncTime, string vaultRoot, int retries, NotifyIcon trayIcon, VaultEagleLib.SynchronizationItem[] items, Option <MCADCommon.LogCommon.DisposableFileLogger> logger)
        {
            string lastSyncTag = lastSyncTime.ToUniversalTime().ToString("MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture);

            logger.IfSomeDo(l => l.Trace("Fetching files with date modified after: " + lastSyncTag + "."));

            long modifiedId = connection.WebServiceManager.PropertyService.GetPropertyDefinitionsByEntityClassId("FILE").First(p => p.DispName == "Date Modified").Id;

            SrchCond filesCreatedAfterLastSyncTime = new SrchCond {
                SrchTxt = lastSyncTag, SrchRule = SearchRuleType.Must, SrchOper = 7, PropDefId = modifiedId, PropTyp = PropertySearchType.SingleProperty
            };


            // logger.Trace("Fetched: " + filesAndFolders.Count + " files before filtering.");

            //List<Tuple<ADSK.File, string, bool, bool>> fileAndPath = new List<Tuple<ADSK.File, string, bool, bool>>();
            List <VaultEagleLib.Model.DataStructures.DownloadItem> filesToDownload = new List <VaultEagleLib.Model.DataStructures.DownloadItem>();
            List <ADSK.File> addedFiles = new List <ADSK.File>();

            items = VaultEagleLib.SynchronizationItem.UpdateListWithTactonItems(items);
            List <string> Checked = new List <string>();
            int           i       = 0;

            trayIcon.Text = "0 of " + items.Count() + " download items to iterate over.";
            foreach (VaultEagleLib.SynchronizationItem item in items)
            {
                if (Checked.Contains(item.SearchPath.ToLower()))
                {
                    continue;
                }
                try
                {
                    Option <Folder> folder   = Option.None;
                    Option <string> fileName = Option.None;

                    if (!System.IO.Path.HasExtension(item.SearchPath))
                    {
                        try
                        {
                            folder = connection.WebServiceManager.DocumentService.GetFolderByPath(item.SearchPath).AsOption();
                        }
                        catch { }
                    }
                    else
                    {
                        try
                        {
                            if (item.SearchPath.Contains('.'))
                            {
                                int k = item.SearchPath.LastIndexOf('/');
                                if (k > 0 && connection.WebServiceManager.DocumentService.FindFoldersByPaths(new string[] { item.SearchPath.Substring(0, k) }).Count() > 0)
                                {
                                    folder   = connection.WebServiceManager.DocumentService.GetFolderByPath(item.SearchPath.Substring(0, k)).AsOption();
                                    fileName = item.SearchPath.Substring(k + 1).AsOption();
                                }
                            }
                        }
                        catch { }
                    }
                    if (folder.IsSome && folder.Get().Id > 0)
                    {
                        List <Tuple <FileFolder, Option <string> > > FileFolderAndComponentName = new List <Tuple <FileFolder, Option <string> > >();
                        List <FileFolder> filesAndFolders = new List <FileFolder>();
                        List <Folder>     folders         = new List <Folder>();
                        SrchStatus        status          = null;
                        string            bookmark        = string.Empty;
                        bool singleFile = false;
                        while (status == null || filesAndFolders.Count < status.TotalHits)
                        {
                            FileFolder[] results;
                            ADSK.File[]  files = connection.WebServiceManager.DocumentService.GetLatestFilesByFolderId(folder.Get().Id, false).Where(f => f.Name.Equals(fileName.Get(), StringComparison.InvariantCultureIgnoreCase)).ToArray();
                            if (fileName.IsSome && files.Count() > 0)
                            {
                                singleFile = true;
                                ADSK.File       file       = files.First();
                                ADSK.FileFolder fileFolder = new FileFolder();
                                fileFolder.File   = file;
                                fileFolder.Folder = folder.Get();
                                results           = new FileFolder[] { fileFolder };
                            }
                            else if (item.ComponentName.IsSome)
                            {
                                logger.IfSomeDo(l => l.Info("Could not find file: " + fileName + " for component: " + item.ComponentName.Get()));
                                break;
                            }
                            else if (item.Mirrors.Count() > 0 || !useLastSyncTime)
                            {
                                results = connection.WebServiceManager.DocumentService.FindFileFoldersBySearchConditions(new SrchCond[] { }, null, new long[] { folder.Get().Id }, item.Recursive, true, ref bookmark, out status);
                            }
                            else
                            {
                                results = connection.WebServiceManager.DocumentService.FindFileFoldersBySearchConditions(new SrchCond[] { filesCreatedAfterLastSyncTime }, null, new long[] { folder.Get().Id }, item.Recursive, true, ref bookmark, out status);
                            }


                            List <FileFolder> allChildren = new List <FileFolder>();
                            //**********************************************************************************************/
                            if (item.GetChildren)
                            {
                                foreach (FileFolder ff in results)
                                {
                                    foreach (ADSK.File childFile in MCADCommon.VaultCommon.FileOperations.GetAllChildren(ff.File.MasterId, new List <ADSK.File>(), connection))
                                    {
                                        FileFolder child = new FileFolder();

                                        child.File   = childFile;
                                        child.Folder = connection.WebServiceManager.DocumentService.GetFolderById(childFile.FolderId);
                                        allChildren.Add(child);
                                        Checked.Add((child.Folder.FullName + "/" + child.File.Name).ToLower());
                                    }
                                }
                            }

                            //***************************************************************************************************/

                            if (results != null)
                            {
                                filesAndFolders.AddRange(results);
                                FileFolderAndComponentName.AddRange(results.Select(r => new Tuple <FileFolder, Option <string> >(r, item.ComponentName)));
                            }
                            if (allChildren.Count > 0)
                            {
                                filesAndFolders.AddRange(allChildren);
                                FileFolderAndComponentName.AddRange(allChildren.Select(r => new Tuple <FileFolder, Option <string> >(r, item.ComponentName)));
                            }
                            Checked.Add(item.SearchPath.ToLower());
                            if (singleFile)
                            {
                                break;
                            }
                        }
                        status = null;
                        if (item.PatternsToSynchronize.Contains("/") || item.Mirrors.Count() > 0)
                        {
                            while (status == null || folders.Count < status.TotalHits)
                            {
                                Folder[] folderResults = connection.WebServiceManager.DocumentService.FindFoldersBySearchConditions(new SrchCond[] { }, null, new long[] { folder.Get().Id }, item.Recursive, ref bookmark, out status);

                                if (folderResults != null)
                                {
                                    folders.AddRange(folderResults);
                                }
                            }
                        }
                        FileFolderAndComponentName = FileFolderAndComponentName.OrderBy(f => f.Item1.Folder.FullName.Length).ToList();
                        FileFolderAndComponentName = FileFolderAndComponentName.Where(f => !f.Item1.File.Hidden).ToList();
                        filesToDownload.AddRange(item.GetFilesAndPathsForItem(connection, FileFolderAndComponentName, addedFiles, vaultRoot, item.GetChildren, retries));

                        if (item.PatternsToSynchronize.Contains("/"))
                        {
                            filesToDownload.AddRange(item.GetFoldersAndPathsForItem(folders, vaultRoot));
                        }

                        if (item.Mirrors.Count() > 0)
                        {
                            item.AddMirrorFolders(folders);
                        }

                        i++;
                        trayIcon.Text = i + " of " + items.Count() + " download items checked.";
                        // Console.WriteLine(i);
                    }
                    else
                    {
                        logger.IfSomeDo(l => l.Error("Incorrect input path: " + item.SearchPath + "."));
                    }
                }
                catch (Exception ex)
                {
                    logger.IfSomeDo(l => l.Error("Error with synchronization item: " + ex.Message + "."));
                }
            }
            //List<Tuple<ADSK.File, string, bool, bool>> filesAndPathsToDl = new List<Tuple<ADSK.File, string, bool, bool>>();
            List <VaultEagleLib.Model.DataStructures.DownloadItem> filesToDl = new List <VaultEagleLib.Model.DataStructures.DownloadItem>();

            /* filesAndPathsToDl = fileAndPath.Where(f => f.Item1 != null).ToList();
             * filesAndPathsToDl = filesAndPathsToDl.DistinctBy(f => f.Item1.MasterId).ToList();
             * filesAndPathsToDl.AddRange(fileAndPath.Where(f => f.Item1 == null).ToList()); */
            filesToDl = filesToDownload.Where(f => f is VaultEagleLib.Model.DataStructures.DownloadFile).ToList();
            filesToDl = filesToDl.DistinctBy(f => ((VaultEagleLib.Model.DataStructures.DownloadFile)f).File.MasterId).ToList();
            filesToDl.AddRange(filesToDownload.Where(f => !(f is VaultEagleLib.Model.DataStructures.DownloadFile)));

            return /*removeExcludedPaths*/ (filesToDl);//filesAndPathsToDl;
        }
コード例 #28
0
        /// <summary>
        /// List all children for a file.
        /// </summary>
        private void UpdateAssociationsTreeView()
        {
            m_associationsTreeView.Nodes.Clear();

            Vault.Currency.Entities.FileIteration selectedFile = m_model.SelectedContent.FirstOrDefault() as Vault.Currency.Entities.FileIteration;
            if (selectedFile == null)
            {
                return;
            }

            this.m_associationsTreeView.BeginUpdate();

            // get all parent and child information for the file
            ACW.FileAssocArray[] associationArrays = m_conn.WebServiceManager.DocumentService.GetFileAssociationsByIds(
                new long[] { selectedFile.EntityIterationId },
                ACW.FileAssociationTypeEnum.None, false,        // parent associations
                ACW.FileAssociationTypeEnum.Dependency, true,   // child associations
                false, true);

            if (associationArrays != null && associationArrays.Length > 0 &&
                associationArrays[0].FileAssocs != null && associationArrays[0].FileAssocs.Length > 0)
            {
                ACW.FileAssoc[] associations = associationArrays[0].FileAssocs;
                m_associationsTreeView.ShowLines = true;

                // organize the return values by the parent file
                Dictionary <long, List <Vault.Currency.Entities.FileIteration> > associationsByFile = new Dictionary <long, List <Vault.Currency.Entities.FileIteration> >();
                foreach (ACW.FileAssoc association in associations)
                {
                    ACW.File parent = association.ParFile;
                    if (associationsByFile.ContainsKey(parent.Id))
                    {
                        // parent is already in the hashtable, add an new child entry
                        List <Vault.Currency.Entities.FileIteration> list = associationsByFile[parent.Id];
                        list.Add(new Vault.Currency.Entities.FileIteration(m_conn, association.CldFile));
                    }
                    else
                    {
                        // add the parent to the hashtable.
                        List <Vault.Currency.Entities.FileIteration> list = new List <Vault.Currency.Entities.FileIteration>();
                        list.Add(new Vault.Currency.Entities.FileIteration(m_conn, association.CldFile));
                        associationsByFile.Add(parent.Id, list);
                    }
                }

                // construct the tree
                if (associationsByFile.ContainsKey(selectedFile.EntityIterationId))
                {
                    TreeNode rootNode = new TreeNode(selectedFile.EntityName);
                    rootNode.Tag = selectedFile;
                    m_associationsTreeView.Nodes.Add(rootNode);
                    AddChildAssociation(rootNode, associationsByFile);
                }
            }
            else
            {
                m_associationsTreeView.ShowLines = false;
                m_associationsTreeView.Nodes.Add("<< no children >>");
            }

            m_associationsTreeView.EndUpdate();
        }
コード例 #29
0
        private void ProcessItem(Item item, Autodesk.Connectivity.WebServices.File iptiamfile)
        {
            FilePath [] filepaths  = ServiceManager.DocumentService.FindFilePathsByNameAndChecksum(iptiamfile.Name, iptiamfile.Cksum);
            String      iptiampath = filepaths[0].Path.Replace("$", "C:/Vault WorkingFolder");

            String stepfilename = "C:/Vault WorkingFolder/Export Files/" + item.ItemNum + "-" + iptiamfile.FileRev.Label + ".stp";

            //checking if attachment exists..
            OnItemStatusUpdate(new ItemStatusUpdateEventArgs(item, "Checking attachments.."));
            Attmt[] atts = ServiceManager.ItemService.GetAttachmentsByItemId(item.Id);
            foreach (Attmt att in atts)
            {
                //getting file object of attachment..
                Autodesk.Connectivity.WebServices.File attmtfile = ServiceManager.DocumentService.GetFileById(att.FileId);
                //checking filename..
                if (attmtfile.Name == System.IO.Path.GetFileName(stepfilename))
                {
                    OnItemStatusUpdate(new ItemStatusUpdateEventArgs(item, "Step-file already attached"));
                    return;
                }
            }
            //no stepfile found as attachment
            //looking for step file in vault...
            OnItemStatusUpdate(new ItemStatusUpdateEventArgs(item, "Searching for step-file in vault.."));
            PropDef[] filePropDefs    = ServiceManager.PropertyService.GetPropertyDefinitionsByEntityClassId("FILE");
            PropDef   filenamePropDef = filePropDefs.Single(n => n.SysName == "Name");
            SrchCond  isFilename      = new SrchCond()
            {
                PropDefId = filenamePropDef.Id,
                PropTyp   = PropertySearchType.SingleProperty,
                SrchOper  = 3,
                SrchRule  = SearchRuleType.Must,
                SrchTxt   = System.IO.Path.GetFileName(stepfilename)
            };
            string     bookmark = string.Empty;
            SrchStatus status   = null;

            Autodesk.Connectivity.WebServices.File[] results = ServiceManager.DocumentService.FindFilesBySearchConditions(new SrchCond[] { isFilename }, null, null, false, true, ref bookmark, out status);

            Autodesk.Connectivity.WebServices.File newfile;

            if (results == null)
            {
                //no stepfile in vault, user must add
                OnItemStatusUpdate(new ItemStatusUpdateEventArgs(item, System.IO.Path.GetFileName(stepfilename) + " not found in vault"));
                return;



                /*
                 * //no stepfile in vault, downloading ipt and generating stepfile
                 * OnItemStatusUpdate(new ItemStatusUpdateEventArgs(item, "Retreiving files.."));
                 *
                 * ByteArray buffer;
                 * String fullpath;
                 * FilePathArray [] fparray = ServiceManager.DocumentService.GetLatestAssociatedFilePathsByMasterIds(new long [] {iptiamfile.MasterId}, FileAssociationTypeEnum.None, false, FileAssociationTypeEnum.Dependency, true, false, true, false);
                 * foreach (FilePath fp in fparray[0].FilePaths)
                 * {
                 *  fullpath = fp.Path.Replace("$", "C:/Vault WorkingFolder");
                 *  ServiceManager.DocumentService.DownloadFile(fp.File.Id, true, out buffer);
                 *  if (System.IO.File.Exists(fullpath) == true)
                 *  {
                 *      System.IO.File.SetAttributes(fullpath, FileAttributes.Normal);
                 *  }
                 *  System.IO.File.WriteAllBytes(fullpath, buffer.Bytes);
                 *  System.IO.File.SetAttributes(fullpath, FileAttributes.ReadOnly);
                 * }
                 *
                 * Inventor.Application m_inventorApp;
                 * OnItemStatusUpdate(new ItemStatusUpdateEventArgs(item, "Looking for Inventor.."));
                 * try //Try to get an active instance of Inventor
                 * {
                 *  try
                 *  {
                 *      m_inventorApp = System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application") as Inventor.Application;
                 *  }
                 *  catch
                 *  {
                 *      Type inventorAppType = System.Type.GetTypeFromProgID("Inventor.Application");
                 *
                 *      m_inventorApp = System.Activator.CreateInstance(inventorAppType) as Inventor.Application;
                 *
                 *      //Must be set visible explicitly
                 *      m_inventorApp.Visible = true;
                 *  }
                 * }
                 * catch
                 * {
                 *  OnItemStatusUpdate(new ItemStatusUpdateEventArgs(item, "couldn't create Inventor instance"));
                 *  return;
                 * }
                 * OnItemStatusUpdate(new ItemStatusUpdateEventArgs(item, "Opening file.."));
                 * _Document iptdocu = m_inventorApp.Documents.Open(iptiampath, true);
                 *
                 * //Inventor.ApprenticeServerComponent appserver;
                 * //appserver = new ApprenticeServerComponent();
                 * //Inventor.ApprenticeServerDocument appdocu;
                 * //appdocu = appserver.Open(iptiampath);
                 *
                 * OnItemStatusUpdate(new ItemStatusUpdateEventArgs(item, "Generating step-file.."));
                 *
                 * if (System.IO.File.Exists(stepfilename) == true)
                 * {
                 *  System.IO.File.SetAttributes(stepfilename, FileAttributes.Normal);
                 * }
                 *
                 * iptdocu.SaveAs(stepfilename, true);
                 *
                 * //FileSaveAs sa;
                 * //sa = appserver.FileSaveAs;
                 * //sa.AddFileToSave(appdocu, stepfilename);
                 * //sa.ExecuteSaveCopyAs();
                 *
                 * System.IO.File.SetAttributes(stepfilename, FileAttributes.ReadOnly);
                 *
                 * OnItemStatusUpdate(new ItemStatusUpdateEventArgs(item, "Closing part-file.."));
                 * iptdocu.Close(true);
                 * //appdocu.Close();
                 *
                 * //OnItemStatusUpdate(new ItemStatusUpdateEventArgs(item, "Deleting part-file.."));
                 * //System.IO.File.Delete(iptfilename);
                 *
                 * OnItemStatusUpdate(new ItemStatusUpdateEventArgs(item, "Adding step-file to vault.."));
                 * // add file to vault + attach
                 *
                 * Folder[] folders = ServiceManager.DocumentService.FindFoldersByPaths(new string[] { "$/Export Files" });
                 * long folderid = folders[0].Id;
                 * System.IO.FileInfo info = new FileInfo(stepfilename);
                 * buffer = new ByteArray();
                 * buffer.Bytes = System.IO.File.ReadAllBytes(stepfilename);
                 *
                 * //OnItemStatusUpdate(new ItemStatusUpdateEventArgs(item, "addfile"));
                 * try
                 * {
                 *  newfile = ServiceManager.DocumentService.AddFile(folderid, System.IO.Path.GetFileName(stepfilename), "Added by Martijns stepfileplugin", info.LastWriteTime, null, null, FileClassification.None, false, buffer);
                 * }
                 * catch (Exception ex)
                 * {
                 *  OnItemStatusUpdate(new ItemStatusUpdateEventArgs(item, "Failed"));
                 *  MessageBox.Show("Error: " + ex.Message);
                 *  return;
                 * }
                 * //1008 addfileexists
                 * //1009 addfile failed
                 */
            }
            else
            {
                if (results.Count() > 1)
                {
                    OnItemStatusUpdate(new ItemStatusUpdateEventArgs(item, "Failed"));
                    MessageBox.Show("Error: more then 1 file with the name " + System.IO.Path.GetFileName(stepfilename + " exist in vault!"));
                    return;
                }
                newfile = results[0];
            }
            //OnItemStatusUpdate(new ItemStatusUpdateEventArgs(item, "new attmt"));

            Attmt newattachment = new Attmt();

            newattachment.FileId = newfile.Id;
            newattachment.Pin    = false;

            //OnItemStatusUpdate(new ItemStatusUpdateEventArgs(item, "new edititem"));

            Array.Resize(ref atts, atts.Count() + 1);
            atts[atts.Count() - 1] = newattachment;

            Item edititem = ServiceManager.ItemService.EditItem(item.RevId);

            ServiceManager.ItemService.UpdateAndCommitItem(edititem, 0, false, null, null, null, atts, null, null, 2);

            OnItemStatusUpdate(new ItemStatusUpdateEventArgs(item, "Done"));
        }
コード例 #30
0
        public JobOutcome Execute(IJobProcessorServices context, IJob job)
        {
            try
            {
                Inventor.InventorServer mInv = context.InventorObject as InventorServer;

                #region validate execution rules

                //pick up this job's context
                mConnection = context.Connection;
                Autodesk.Connectivity.WebServicesTools.WebServiceManager mWsMgr = mConnection.WebServiceManager;
                long   mEntId    = Convert.ToInt64(job.Params["EntityId"]);
                string mEntClsId = job.Params["EntityClassId"];

                // only run the job for files; handle the scenario, that an item lifecycle transition accidently submitted the job
                if (mEntClsId != "FILE")
                {
                    context.Log(null, "This job type is for files only.");
                    return(JobOutcome.Failure);
                }

                // only run the job for ipt and iam file types,
                List <string> mFileExtensions = new List <string> {
                    ".ipt", ".iam", "idw", "dwg"
                };
                ACW.File mFile = mWsMgr.DocumentService.GetFileById(mEntId);
                if (!mFileExtensions.Any(n => mFile.Name.EndsWith(n)))
                {
                    context.Log(null, "Skipped Job execution as file type did not match iLogic enabled files (ipt, iam, idw/dwg");
                    return(JobOutcome.Success);
                }
                //run iLogic for Inventor DWG file types/skip AutoCAD DWG files
                ACW.PropDef[] mPropDefs = mWsMgr.PropertyService.GetPropertyDefinitionsByEntityClassId("FILE");
                ACW.PropDef   mPropDef  = null;
                ACW.PropInst  mPropInst = null;
                if (mFile.Name.EndsWith(".dwg"))
                {
                    mPropDef  = mPropDefs.Where(n => n.SysName == "Provider").FirstOrDefault();
                    mPropInst = (mWsMgr.PropertyService.GetPropertiesByEntityIds("FILE", new long[] { mFile.Id })).Where(n => n.PropDefId == mPropDef.Id).FirstOrDefault();
                    if (mPropInst.Val.ToString() != "Inventor DWG")
                    {
                        context.Log(null, "Skipped Job execution as DWG type did not match Inventor DWG");
                        return(JobOutcome.Success);
                    }
                }

                ApplicationAddIns mInvSrvAddIns = mInv.ApplicationAddIns;
                ApplicationAddIn  iLogicAddIn   = mInvSrvAddIns.ItemById["{3BDD8D79-2179-4B11-8A5A-257B1C0263AC}"];

                if (iLogicAddIn != null && iLogicAddIn.Activated != true)
                {
                    iLogicAddIn.Activate();
                }

                dynamic mAutomation = iLogicAddIn.Automation;

                if (mAutomation == null)
                {
                    Trace.WriteLine("iLogic-AddIn automation is not available; exiting job processing");
                    context.Log(null, "iLogic-AddIn automation is not available");
                    return(JobOutcome.Failure);
                }

                #endregion validate execution rules

                #region VaultInventorServer IPJ activation

                //override InventorServer default project settings by your Vault specific ones
                Inventor.DesignProjectManager mInvIpjManager;
                Inventor.DesignProject        mInvDfltProject, mInvVltProject;
                String   mIpjPath      = "";
                String   mWfPath       = "";
                String   mIpjLocalPath = "";
                ACW.File mIpj;
                VDF.Vault.Currency.Entities.FileIteration mIpjFileIter = null;

                //validate ipj setting, a single, enforced ipj is expected
                if (mWsMgr.DocumentService.GetEnforceWorkingFolder() && mWsMgr.DocumentService.GetEnforceInventorProjectFile())
                {
                    mIpjPath = mWsMgr.DocumentService.GetInventorProjectFileLocation();
                    mWfPath  = mWsMgr.DocumentService.GetRequiredWorkingFolderLocation();
                    //Set mWfPath to alternate temporary working folder if needed, e.g. to delete all files after job execution
                }
                else
                {
                    context.Log(null, "Job requires both settings enabled: 'Enforce Workingfolder' and 'Enforce Inventor Project'.");
                    return(JobOutcome.Failure);
                }
                //download and activate the Inventor Project file in VaultInventorServer
                mIpj = (mWsMgr.DocumentService.FindLatestFilesByPaths(new string[] { mIpjPath })).FirstOrDefault();

                try
                {
                    String[] mIpjFullFileName = mIpjPath.Split(new string[] { "/" }, StringSplitOptions.None);
                    String   mIpjFileName     = mIpjFullFileName.LastOrDefault();

                    //define download settings for the project file
                    VDF.Vault.Settings.AcquireFilesSettings mAcqrIpjSettings = new VDF.Vault.Settings.AcquireFilesSettings(mConnection);
                    mAcqrIpjSettings.LocalPath = new VDF.Currency.FolderPathAbsolute(mWfPath);
                    mIpjFileIter = new VDF.Vault.Currency.Entities.FileIteration(mConnection, mIpj);
                    mAcqrIpjSettings.AddFileToAcquire(mIpjFileIter, VDF.Vault.Settings.AcquireFilesSettings.AcquisitionOption.Download);

                    //download project file and get local path
                    VDF.Vault.Results.AcquireFilesResults   mDownLoadResult;
                    VDF.Vault.Results.FileAcquisitionResult fileAcquisitionResult;
                    mDownLoadResult       = mConnection.FileManager.AcquireFiles(mAcqrIpjSettings);
                    fileAcquisitionResult = mDownLoadResult.FileResults.FirstOrDefault();
                    mIpjLocalPath         = fileAcquisitionResult.LocalPath.FullPath;

                    //activate this Vault's ipj
                    mInvIpjManager  = mInv.DesignProjectManager;
                    mInvDfltProject = mInvIpjManager.ActiveDesignProject;
                    mInvVltProject  = mInvIpjManager.DesignProjects.AddExisting(mIpjLocalPath);
                    mInvVltProject.Activate();

                    //[Optionally:] get Inventor Design Data settings and download all related files ---------
                }
                catch
                {
                    context.Log(null, "Job was not able to activate Inventor project file. - Note: The ipj must not be checked out by another user.");
                    return(JobOutcome.Failure);
                }
                #endregion VaultInventorServer IPJ activation


                #region download source file(s)

                //build download options including DefaultAcquisitionOptions
                VDF.Vault.Currency.Entities.FileIteration mFileIteration    = new VDF.Vault.Currency.Entities.FileIteration(mConnection, mFile);
                VDF.Vault.Currency.Entities.FileIteration mNewFileIteration = null;
                VDF.Vault.Settings.AcquireFilesSettings   mAcqrFlsSettings;
                VDF.Vault.Results.AcquireFilesResults     mAcqrFlsResults2;
                VDF.Vault.Results.FileAcquisitionResult   mFileAcqsResult2;
                string mLocalFileFullName = "", mExt = "";

                if (mFileIteration.IsCheckedOut == true && mFileIteration.IsCheckedOutToCurrentUser == false)
                {
                    //exit the job, as the job user is not able to edit the file reserved to another user
                    mInvDfltProject.Activate();
                    context.Log(null, "Job stopped execution as the source file to process is checked-out by another user.");
                    return(JobOutcome.Failure);
                }
                //download only
                if (mFileIteration.IsCheckedOut == true && mFileIteration.IsCheckedOutToCurrentUser == true)
                {
                    mAcqrFlsSettings = CreateAcquireSettings(false);
                    mAcqrFlsSettings.AddFileToAcquire(mFileIteration, mAcqrFlsSettings.DefaultAcquisitionOption);
                    mAcqrFlsResults2   = this.mConnection.FileManager.AcquireFiles(mAcqrFlsSettings);
                    mNewFileIteration  = mFileIteration;
                    mFileAcqsResult2   = mAcqrFlsResults2.FileResults.Where(n => n.File.EntityName == mFileIteration.EntityName).FirstOrDefault();
                    mLocalFileFullName = mFileAcqsResult2.LocalPath.FullPath;
                    mExt = System.IO.Path.GetExtension(mLocalFileFullName);
                }
                //checkout and download
                if (mFileIteration.IsCheckedOut == false)
                {
                    try
                    {
                        mAcqrFlsSettings = CreateAcquireSettings(true); //checkout (don't checkout related children)
                        mAcqrFlsSettings.AddFileToAcquire(mFileIteration, mAcqrFlsSettings.DefaultAcquisitionOption);
                        mAcqrFlsResults2  = this.mConnection.FileManager.AcquireFiles(mAcqrFlsSettings);
                        mFileAcqsResult2  = mAcqrFlsResults2.FileResults.Where(n => n.File.EntityName == mFileIteration.EntityName).FirstOrDefault();
                        mNewFileIteration = mFileAcqsResult2.NewFileIteration;
                        mAcqrFlsSettings  = null;
                        mAcqrFlsSettings  = CreateAcquireSettings(false);//download (include related children)
                        mAcqrFlsSettings.AddFileToAcquire(mNewFileIteration, mAcqrFlsSettings.DefaultAcquisitionOption);
                        mAcqrFlsResults2   = this.mConnection.FileManager.AcquireFiles(mAcqrFlsSettings);
                        mLocalFileFullName = mFileAcqsResult2.LocalPath.FullPath;
                        mExt = System.IO.Path.GetExtension(mLocalFileFullName);
                    }
                    catch (Exception)
                    {
                        mInvDfltProject.Activate();
                        context.Log(null, "Job stopped execution as the source file to process did not download or check-out.");
                        return(JobOutcome.Failure);
                    }
                }

                #endregion download source file(s)

                #region capture dependencies
                //we need to return all relationships during later check-in
                List <ACW.FileAssocParam> mFileAssocParams = new List <ACW.FileAssocParam>();
                ACW.FileAssocArray        mFileAssocArray  = mWsMgr.DocumentService.GetLatestFileAssociationsByMasterIds(new long[] { mFile.MasterId },
                                                                                                                         ACW.FileAssociationTypeEnum.None, false, ACW.FileAssociationTypeEnum.All, false, false, false, true).FirstOrDefault();
                if (mFileAssocArray.FileAssocs != null)
                {
                    foreach (ACW.FileAssoc item in mFileAssocArray.FileAssocs)
                    {
                        ACW.FileAssocParam mFileAssocParam = new ACW.FileAssocParam();
                        mFileAssocParam.CldFileId         = item.CldFile.Id;
                        mFileAssocParam.ExpectedVaultPath = item.ExpectedVaultPath;
                        mFileAssocParam.RefId             = item.RefId;
                        mFileAssocParam.Source            = item.Source;
                        mFileAssocParam.Typ = item.Typ;
                        mFileAssocParams.Add(mFileAssocParam);
                    }
                }

                #endregion capture dependencies

                #region iLogic Configuration

                //avoid unplanned rule execution triggered by the document itself
                mAutomation.RulesOnEventsEnabled = false;
                mAutomation.RulesEnabled         = false;

                //set the iLogic Advanced Configuration Settings
                dynamic mFileOptions = mAutomation.FileOptions;
                mFileOptions.AddinDirectory = mSettings.iLogicAddinDLLs;
                //add the job extension app path and configured external rule directories to the FileOptions.ExternalRuleDirectories for iLogic
                List <string> mExtRuleDirs = new List <string>();
                mExtRuleDirs.Add(mAppPath);
                mExtRuleDirs.AddRange(mSettings.ExternalRuleDirectories.Split(',').ToList <string>());
                mFileOptions.ExternalRuleDirectories = mExtRuleDirs.ToArray();

                //enable iLogic logging
                dynamic mLogCtrl = mAutomation.LogControl;
                switch (mSettings.iLogicLogLevel)
                {
                case "None":
                    mLogCtrl.Level = 0;
                    break;

                case "Trace":
                    mLogCtrl.Level = 1;
                    break;

                case "Debug":
                    mLogCtrl.Level = 2;
                    break;

                case "Info":
                    mLogCtrl.Level = 3;
                    break;

                case "Warn":
                    mLogCtrl.Level = 4;
                    break;

                case "Error":
                    mLogCtrl.Level = 5;
                    break;

                case "Fatal":
                    mLogCtrl.Level = 6;
                    break;

                default:
                    mLogCtrl.Level = 5;
                    break;
                }

                //enable iLogic to save a log file for each job Id.
                string mILogicLogFileFullName = "";
                if (mLogCtrl.Level != 0)
                {
                    string mLogName = job.Id + "_" + mFile.Name + "_iLogicSampleJob.log";
                    System.IO.DirectoryInfo mLogDirInfo = new System.IO.DirectoryInfo(mSettings.iLogicLogDir);
                    if (mLogDirInfo.Exists == false)
                    {
                        mLogDirInfo = System.IO.Directory.CreateDirectory(mSettings.iLogicLogDir);
                    }
                    mILogicLogFileFullName = System.IO.Path.Combine(mLogDirInfo.FullName, mLogName);
                }



                //read rule execution settings
                string mVaultRule       = mSettings.VaultRuleFullFileName;
                string mExtRule         = mSettings.ExternalRuleName;
                string mExtRuleFullName = null;
                string mIntRulesOption  = mSettings.InternalRulesOption;

                if (mVaultRule != "")
                {
                    ACW.File mRuleFile = mWsMgr.DocumentService.FindLatestFilesByPaths(new string[] { mVaultRule }).FirstOrDefault();
                    //build download options including DefaultAcquisitionOptions
                    VDF.Vault.Currency.Entities.FileIteration mRuleFileIter = new VDF.Vault.Currency.Entities.FileIteration(mConnection, mRuleFile);

                    VDF.Vault.Settings.AcquireFilesSettings mAcqrRuleSettings = CreateAcquireSettings(false);

                    mAcqrRuleSettings.AddFileToAcquire(mRuleFileIter, mAcqrRuleSettings.DefaultAcquisitionOption);

                    //download
                    VDF.Vault.Results.AcquireFilesResults mAcqrRuleResults = this.mConnection.FileManager.AcquireFiles(mAcqrRuleSettings);
                    //pick-up the new file iteration in case of check-out
                    VDF.Vault.Results.FileAcquisitionResult mRuleAcqResult = mAcqrRuleResults.FileResults.Where(n => n.File.EntityName == mRuleFileIter.EntityName).FirstOrDefault();
                    if (mRuleAcqResult.LocalPath != null)
                    {
                        mExtRuleFullName = mRuleAcqResult.LocalPath.FullPath;
                        System.IO.FileInfo fileInfo = new System.IO.FileInfo(mExtRuleFullName);
                        if (fileInfo.Exists == false)
                        {
                            context.Log(null, "Job downloaded rule file but exited due to missing rule file: " + mExtRuleFullName + ".");
                            mConnection.FileManager.UndoCheckoutFile(mNewFileIteration);
                            return(JobOutcome.Failure);
                        }
                        else
                        {
                            mExtRule = fileInfo.Name;
                            if (!mExtRuleDirs.Any(n => fileInfo.DirectoryName.Equals(n)))
                            {
                                context.Log(null, "Job downloaded rule file but exited due to missing iLogic External Rule Directory configuration: Add the path"
                                            + fileInfo.DirectoryName + " to the list of External Rule Directories.");
                                mConnection.FileManager.UndoCheckoutFile(mNewFileIteration);
                                return(JobOutcome.Failure);
                            }
                        }
                    }
                    else
                    {
                        context.Log(null, "Job could not download configured rule file and exited. Compare the 'VaultRuleFullFileName' setting and available rule in Vault.");
                        return(JobOutcome.Failure);
                    }
                }

                #endregion iLogic Configuration

                #region Run iLogic Rule(s)

                //Open Inventor Document
                Document mDoc = mInv.Documents.Open(mLocalFileFullName);

                //use case  - apply external rule with arguments; additional Vault UDP, status or any information might fill rule arguments
                if (mExtRule != "")
                {
                    //required rule arguments to continue Vault interaction within the rule (iLogic-Vault library)
                    NameValueMap ruleArguments = mInv.TransientObjects.CreateNameValueMap();
                    ruleArguments.Add("ServerName", mConnection.Server);
                    ruleArguments.Add("VaultName", mConnection.Vault);
                    ruleArguments.Add("UserId", mConnection.UserID);
                    ruleArguments.Add("Ticket", mConnection.Ticket);

                    //additional rule arguments to build rule conditions evaluating Vault lifecycle information, properties, etc.
                    if (mSettings.PropagateProps == "True")
                    {
                        ACW.PropInst[] mSourcePropInsts = mWsMgr.PropertyService.GetPropertiesByEntityIds("FILE", new long[] { mFileIteration.EntityIterationId });
                        string         mPropDispName;
                        string         mThumbnailDispName = mPropDefs.Where(n => n.SysName == "Thumbnail").FirstOrDefault().DispName;
                        foreach (ACW.PropInst item in mSourcePropInsts)
                        {
                            mPropDispName = mPropDefs.Where(n => n.Id == item.PropDefId).FirstOrDefault().DispName;
                            //filter thumbnail property, as iLogic RuleArguments will fail reading it.
                            if (mPropDispName != mThumbnailDispName)
                            {
                                ruleArguments.Add(mPropDispName, item.Val);
                            }
                        }
                    }

                    //call external rule with arguments; return value = 0 in case of successful execution
                    mRuleSuccess = mAutomation.RunExternalRuleWithArguments(mDoc, mExtRule, ruleArguments);
                    if (mRuleSuccess != 0)
                    {
                        context.Log(null, "Job failed due to failure in external rule: " + mExtRule + ".");
                        mDoc.Close(true);
                        mConnection.FileManager.UndoCheckoutFile(mNewFileIteration);
                        mLogCtrl.SaveLogAs(mILogicLogFileFullName);
                        return(JobOutcome.Failure);
                    }
                    else
                    {
                        mAllRulesTextWrp = "External Rule: " + mExtRule;
                    }
                    mDoc.Save2(false);
                }


                //use case - run all, all active or filtered document rules
                dynamic        mDocRules    = mAutomation.Rules(mDoc);
                List <dynamic> mRulesToExec = new List <dynamic>();

                switch (mSettings.InternalRulesOption)
                {
                case "None":
                    break;

                case "Active":
                    if (mDocRules != null)
                    {
                        foreach (dynamic rule in mDocRules)
                        {
                            if (rule.IsActive == true)
                            {
                                mRulesToExec.Add(rule);
                            }
                        }
                    }
                    break;

                case "All":
                    if (mDocRules != null)
                    {
                        foreach (dynamic rule in mDocRules)
                        {
                            mRulesToExec.Add(rule);
                        }
                    }
                    break;

                default:
                    foreach (dynamic rule in mDocRules)
                    {
                        if (rule.Name.Contains(mSettings.InternalRulesOption))
                        {
                            mRulesToExec.Add(rule);
                        }
                    }
                    break;
                }
                if (mRulesToExec.Count >= 1)
                {
                    foreach (dynamic rule in mRulesToExec)
                    {
                        mRuleSuccess = mAutomation.RunRule(mDoc, rule.Name);
                        if (mRuleSuccess != 0)
                        {
                            context.Log(null, "Job failed due to failure in internal rule: " + rule.Name + ".");
                            mDoc.Close(true);
                            mConnection.FileManager.UndoCheckoutFile(mNewFileIteration);
                            mLogCtrl.SaveLogAs(mILogicLogFileFullName);
                            return(JobOutcome.Failure);
                        }
                        else
                        {
                            mAllRules.Add(rule.Name);
                        }
                    }
                }

                mDoc.Save2(false);
                mDoc.Close(true);
                mLogCtrl.SaveLogAs(mILogicLogFileFullName);

                if (mAllRules.Count > 0)
                {
                    mAllRulesTextWrp += "\n\r Internal Rule(s):";
                    foreach (string name in mAllRules)
                    {
                        mAllRulesTextWrp += "\r\n " + name;
                    }
                }

                #endregion Run iLogic Rules


                #region Check-in result

                // checkin new file version
                VDF.Currency.FilePathAbsolute vdfPath = new VDF.Currency.FilePathAbsolute(mLocalFileFullName);
                FileIteration mUploadedFile           = null;
                try
                {
                    if (mFileAssocParams.Count > 0)
                    {
                        mUploadedFile = mConnection.FileManager.CheckinFile(mNewFileIteration, "Created by Custom Job executing iLogic : " + mAllRulesTextWrp,
                                                                            false, mFileAssocParams.ToArray(), null, true, null, mFileIteration.FileClassification, false, vdfPath);
                    }
                    else
                    {
                        mUploadedFile = mConnection.FileManager.CheckinFile(mNewFileIteration, "Created by Custom Job executing iLogic : " + mAllRulesTextWrp,
                                                                            false, null, null, false, null, mFileIteration.FileClassification, false, vdfPath);
                    }
                }
                catch
                {
                    context.Log(null, "Job could not check-in updated file: " + mUploadedFile.EntityName + ".");
                    return(JobOutcome.Failure);
                }
                #endregion check-in result

                #region reset

                mInvDfltProject.Activate();
                //delete temporary working folder if imlemented here

                #endregion reset

                return(JobOutcome.Success);
            }
            catch (Exception ex)
            {
                context.Log(ex, "Job failed by unhandled exception: " + ex.ToString() + " ");
                return(JobOutcome.Failure);
            }
        }