Esempio n. 1
0
 /// <summary>
 /// 显示PDM视图
 /// </summary>
 private void ShowPDMInfo()
 {
     try
     {
         IEdmVault5 vault1 = new EdmVault5();
         vault = (IEdmVault11)vault1;
         EdmViewInfo[] Views = null;
         vault.GetVaultViews(out Views, false);
         VaultsComboBox.Items.Clear();
         this.lblUserName.Text = "";
         this.VaultsComboBox.Items.Add(Globals.VaultName);
         this.VaultsComboBox.Text = Globals.VaultName;
         this.lblVaultName.Text   = string.Format("PDM库:{0}({1})    ", Globals.VaultName, Globals.DbServerIP);
         //获取并显示PDM登录信息
         GetPDMLoginInfo();
         this.Text = Globals.DEF_PROGRAM_NAME + " UserId=" + Globals.UserID;//程序名称
     }
     catch (System.Runtime.InteropServices.COMException ex)
     {
         MessageBox.Show("HRESULT = 0x" + ex.ErrorCode.ToString("X") + " " + ex.Message);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Esempio n. 2
0
        //获取用户ID
        public static string GetLoginID()
        {
            IEdmVault5 vault5 = new EdmVault5();

            if (!vault5.IsLoggedIn)
            {
                vault5.LoginAuto(VaultName, new Control().Handle.ToInt32());
            }
            IEdmVault11 valut11 = (IEdmVault11)vault5;

            return(valut11.GetLoggedInWindowsUserID(VaultName).ToString());
        }
Esempio n. 3
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
        }