示例#1
0
        public void Button1_Click(System.Object sender, System.EventArgs e)
        {
            try
            {
                //Only create a new vault object
                //if one hasn't been created yet
                IEdmVault11 vault2 = null;
                if (vault1 == null)
                {
                    vault1 = new EdmVault5();
                }
                vault2 = (IEdmVault11)vault1;
                if (!vault1.IsLoggedIn)
                {
                    //Log into selected vault as the current user
                    vault1.LoginAuto(VaultsComboBox.Text, this.Handle.ToInt32());
                }

                serialNbrs = (IEdmSerNoGen7)vault2.CreateUtility(EdmUtility.EdmUtil_SerNoGen);
                string[] names = { };
                serialNbrs.GetSerialNumberNames(out names);
                string myMessage = "";
                myMessage = "Serial number names in selected vault: " + "\n ";
                int idx = 0;
                idx = (names.GetLowerBound(0));
                while (idx <= (names.GetUpperBound(0)))
                {
                    myMessage = myMessage + names[idx] + "\n";
                    idx       = idx + 1;
                }

                // Use this serial number generator
                aSerialNbrName = names[0];

                MessageBox.Show(myMessage);
            }
            catch (System.Runtime.InteropServices.COMException ex)
            {
                MessageBox.Show("HRESULT = 0x" + ex.ErrorCode.ToString("X") + " " + ex.Message);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void AddFileExecute()
        {
#if BlockPDM
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Multiselect = true;
            ofd.Filter      = "Files (*.dxf,*.Pdf)|*.dxf;*.pdf";
            if (ofd.ShowDialog() == true)
            {
                foreach (string fileName in ofd.FileNames)
                {
                    Files.Add(new FileDataViewModel(new Document(fileName)
                    {
                        FileId = 1, Description = "Test"
                    }));
                }
            }
#else
            IEdmVault11 vault = (IEdmVault11) new EdmVault5();
            EdmStrLst5  res   = vault.BrowseForFile(0, (int)EdmBrowseFlag.EdmBws_ForOpen + (int)EdmBrowseFlag.EdmBws_PermitVaultFiles,
                                                    "Select Files", "All Files (*.pdf,*.dxf,*.step)|*.pdf;*.dxf;*.step||", "", "", "Select Files");
            if (res != null)
            {
                IEdmPos5          pos   = res.GetHeadPosition();
                List <string>     paths = new List <string>();
                IEdmBatchListing4 bli   = vault.CreateUtility(EdmUtility.EdmUtil_BatchList);
                while (pos.IsNull)
                {
                    //paths.Add(res.GetNext(pos));
                    bli.AddFile(res.GetNext(pos), default(DateTime), 0, 0);
                }

                string         Names = "Description\nRevision";
                EdmListCol[]   cols  = null;
                EdmListFile2[] files = null;
                bli.CreateListEx(Names, (int)EdmCreateListExFlags.Edmclef_Nothing, ref cols, null);
                bli.GetFiles2(ref files);

                foreach (var file in files)
                {
                    var doc = new Document(file.mbsLockPath);
                    doc.FileId      = file.mlFileID;
                    doc.Version     = file.mlLatestVersion;
                    doc.Revision    = file.mbsRevisionName;
                    doc.FileState   = file.moCurrentState.mbsStateName;
                    doc.Description = (file.moColumnData as object[])?[0] as string ?? "Not found";
                    Files.Add(new FileDataViewModel(doc));
                }
            }

            //IEdmVault11 vault = (IEdmVault11)new EdmVault5();
            //EdmStrLst5 res = vault.BrowseForFile(0, (int)EdmBrowseFlag.EdmBws_ForOpen + (int)EdmBrowseFlag.EdmBws_PermitVaultFiles,
            //    "Select Files", "All Files (*.pdf,*.dxf,*.step)|*.pdf;*.dxf;*.step||", "", "", "Select Files");
            //if (res != null)
            //{
            //    IEdmPos5 pos = res.GetHeadPosition();
            //    List<string> paths = new List<string>();
            //    IEdmBatchListing4 bli = vault.CreateUtility(EdmUtility.EdmUtil_BatchList);
            //    while (pos.IsNull)
            //    {

            //        paths.Add(res.GetNext(pos));
            //        //bli.AddFile(res.GetNext(pos), default(DateTime), 0, 0);
            //    }

            //    string Names = "Description\nRevision";
            //    EdmListCol[] cols = null;
            //    EdmListFile2[] files = null;
            //    bli.CreateListEx(Names, (int)EdmCreateListExFlags.Edmclef_GetDrawings + (int)EdmCreateListExFlags.Edmclef_GetReferences + (int)EdmCreateListExFlags.Edmclef_ReturnReferences, ref cols, null);
            //    bli.GetFiles2(ref files);

            //    foreach (var file in files)
            //    {
            //        var doc = new Document(file.mbsLockPath);
            //        doc.FileId = file.mlFileID;
            //        doc.Version = file.mlLatestVersion;
            //        doc.Revision = file.mbsRevisionName;
            //        doc.FileState = file.moCurrentState.mbsStateName;
            //        doc.Description = (file.moColumnData as object[])?[0] as string ?? "Not found";
            //        Files.Add(new FileDataViewModel(doc));
            //    }

            //}
#endif
        }