//more efficient than using TryUnlockFile for checking in multiple files. private static FileCheckInResult UnlockFiles(IEdmVault5 vault, string[] filePaths) { try { IEdmVault7 vault7 = vault as IEdmVault7; IEdmBatchUnlock batchUnlocker = (IEdmBatchUnlock)vault7.CreateUtility(EdmUtility.EdmUtil_BatchUnlock); EdmSelItem[] selItems = new EdmSelItem[filePaths.Length]; for (int i = 0; i < filePaths.Length; ++i) { IEdmFile5 edmFile; IEdmFolder5 edmFolder; if (!GetFileFromPath(vault, filePaths[i], out edmFile, out edmFolder)) { return(FileCheckInResult.UNKNOWN_ERROR); } selItems[i].mlDocID = edmFile.ID; selItems[i].mlProjID = edmFolder.ID; } batchUnlocker.AddSelection(vault as EdmVault5, ref selItems); //这里必然有异常o(╥﹏╥)o batchUnlocker.CreateTree(0, (int)EdmUnlockBuildTreeFlags.Eubtf_MayUnlock); batchUnlocker.UnlockFiles(0); return(FileCheckInResult.OK); } catch (Exception ex) { return(FileCheckInResult.UNKNOWN_ERROR); } }
public string DetermineConfig(IEdmFile5 Part, IEdmVault7 vault, string partnumber) { string retval = "@"; EdmStrLst5 list = Part.GetConfigurations(); IEdmPos5 pos = list.GetHeadPosition(); Config_Select config = new Config_Select(vault, Part, partnumber); pos = list.GetHeadPosition(); for (int i = 0; i < list.Count; i++) { string itemtoadd = list.GetNext(pos); if (itemtoadd != "@") config.config_cbo.Items.Add(itemtoadd); } config.config_cbo.SelectedIndex = 0; config.ShowDialog(); retval = config.SelectedConfig; if (config.DialogResult == System.Windows.Forms.DialogResult.Cancel) return ""; return retval; }
public static bool Get(IEdmVault7 vault, List <Files.Info> files) { var status = false; Logger.Add($"Получение {files?.Count} файлов из PDM"); try { batchGetter = (IEdmBatchGet)vault.CreateUtility(EdmUtility.EdmUtil_BatchGet); foreach (var file in files) { try { batchGetter.AddSelectionEx((EdmVault5)vault, file.IdPDM, file.FolderID, file.CurrentVersion); } catch (Exception ex) { Logger.Add($"Ошибка при получении:{ex.Message} Path: {file.FullFilePath} IdPDM: {file.IdPDM} FolderID: {file.FolderID} Version: {file.CurrentVersion}"); } } if ((batchGetter != null)) { batchGetter.CreateTree(0, (int)EdmGetCmdFlags.Egcf_SkipUnlockedWritable); batchGetter.GetFiles(0, null); } } catch (COMException ex) { Logger.Add("ERROR BatchGet HRESULT = 0x" + ex.ErrorCode.ToString("X") + " " + ex.Message); } catch (Exception ex) { Logger.Add("ERROR BatchGet HRESULT = 0x" + ex.StackTrace + "\n" + ex.Message); } return(status); }
public static bool CheckDxfExistance(IEdmVault7 vault, int IdPDM, int CurrentVersion, string fileName) { var result = true; //Get configurations var fileEdm = (IEdmFile5)vault.GetObject(EdmObjectType.EdmObject_File, IdPDM); EdmStrLst5 cfgList = default(EdmStrLst5); cfgList = fileEdm.GetConfigurations(); string cfgName = null; IEdmPos5 pos = default(IEdmPos5); pos = cfgList.GetHeadPosition(); while (!pos.IsNull) { Exception exc; cfgName = cfgList.GetNext(pos); if (cfgName != "@") { var existDxf = Dxf.ExistDxf(IdPDM, CurrentVersion, cfgName, out exc); //Logger.Add("Проверка на DXF; \n IdPDM: " + IdPDM + "\n Name: " + fileName + "\n Version: " + CurrentVersion + "\n ConfigName: " + cfgName + "\n Exist: " + existDxf); if (!existDxf) { //return result = false; } } } return(result); }
public IEdmFile7 FindPartinVault(IEdmVault7 vault, string SearchPart, string Config) { string selected_config = Config; object partnum_val = ""; IEdmSearch5 Search = vault.CreateSearch(); Search.Clear(); Search.FileName = SearchPart; //Search.AddVariable("Number", SearchPart); //Search.AddVariable("Number", SearchPart); Search.FindFolders = false; Search.FindFiles = true; IEdmSearchResult5 Result = Search.GetFirstResult(); if (Result != null) { IEdmFile7 part = (IEdmFile7)vault.GetObject(EdmObjectType.EdmObject_File, Result.ID); return part; } else { Config = null; return null; } }
/// <summary> /// 设置文件卡自由变量的值(文件ID) /// </summary> /// <param name="_filePath">文件ID</param> /// <param name="_value">自由变量名称,变量值</param> /// <returns></returns> public static bool SetFileCardVariableValue(int _fileID, Dictionary <string, string> _value) { try { IEdmVault5 vault5 = new EdmVault5(); IEdmVault7 vault7 = (IEdmVault7)vault5; if (!vault5.IsLoggedIn) { vault5.Login(LogName, PWD, VaultName); } IEdmBatchUpdate2 update = default(IEdmBatchUpdate2); update = (IEdmBatchUpdate2)vault7.CreateUtility(EdmUtility.EdmUtil_BatchUpdate); IEdmVariableMgr5 variableMgr5 = (IEdmVariableMgr5)vault5; foreach (var key in _value.Keys) { //文件ID、变量ID、值、配置名称、 update.SetVar(_fileID, variableMgr5.GetVariable(key).ID, _value[key], "@", (int)EdmBatchFlags.EdmBatch_AllConfigs); } EdmBatchError2[] Errors = null; update.CommitUpdate(out Errors, null); return(true); } catch (Exception ex) { throw ex; } }
public static List <Files.Info> UpdateFileInfo(IEdmVault7 vault, List <Files.Info> listType) { var Fulllist = new List <Files.Info>(); foreach (var fileVar in listType) { var filePath = fileVar.FolderPath + "\\" + fileVar.ConvertFile; var rev = GetRevision(vault, fileVar.TaskType, filePath); string message; var udatedFile = new Files.Info { CurrentVersion = fileVar.CurrentVersion, FileName = fileVar.FileName, FolderPath = fileVar.FolderPath, FullFilePath = fileVar.FullFilePath, FolderID = fileVar.FolderID, IdPDM = fileVar.IdPDM, ConvertFile = fileVar.ConvertFile, Revision = rev, ExistEdrawing = fileVar.CurrentVersion.ToString() == rev, ExistCutList = ExportXmlSql.ExistXml(fileVar.FileName.ToUpper().Replace(".SLDPRT", ""), fileVar.CurrentVersion, out message), ExistDXF = CheckDxfExistance(vault, fileVar.IdPDM, fileVar.CurrentVersion, fileVar.FileName) }; Fulllist.Add(udatedFile); //Logger.Add($"FileName: {udatedFile.FileName} Edrw: {udatedFile.ExistEdrawing} Dxf: {udatedFile.ExistDXF} XML: {udatedFile.ExistCutList} Message: {message}"); } return(Fulllist); }
//Use IEdmBatchGet to check out several files, it is more efficient repeatedly calling LockFile. private static FileCheckOutResult LockFiles(IEdmVault5 vault, string[] filePaths, bool bLockReferenceFiles) { try { IEdmVault7 vault7 = vault as IEdmVault7; IEdmBatchGet batchGetter = vault7.CreateUtility(EdmUtility.EdmUtil_BatchGet); for (int i = 0; i < filePaths.Length; ++i) { IEdmFile5 edmFile; IEdmFolder5 edmFolder; if (!GetFileFromPath(vault, filePaths[i], out edmFile, out edmFolder)) { return(FileCheckOutResult.UNKNOWN_ERROR); } batchGetter.AddSelectionEx((EdmVault5)vault, edmFile.ID, edmFolder.ID, null); } int cmdFlag = bLockReferenceFiles ? (int)(EdmGetCmdFlags.Egcf_LockReferencedFilesToo | EdmGetCmdFlags.Egcf_Lock) : (int)EdmGetCmdFlags.Egcf_Lock; batchGetter.CreateTree(0, cmdFlag); batchGetter.GetFiles(0); return(FileCheckOutResult.OK); } catch (Exception ex) { return(FileCheckOutResult.UNKNOWN_ERROR); } }
public string DetermineConfig(IEdmFile5 Part, IEdmVault7 vault, EdmCmdData file) { string retval = "@"; EdmStrLst5 list = Part.GetConfigurations(); IEdmPos5 pos = list.GetHeadPosition(); Config_Select config = new Config_Select(vault, file); pos = list.GetHeadPosition(); for (int i = 0; i < list.Count; i++) { config.config_cbo.Items.Add(list.GetNext(pos)); } config.config_cbo.SelectedIndex = 0; config.ShowDialog(); if (config.DialogResult == System.Windows.Forms.DialogResult.Cancel) return ""; return retval; }
public Form1(IEdmFile7 file, IEdmVault7 vault) { File = file; Vault = vault; InitializeComponent(); TextBox(); GetConfiguration(); }
public Config_Select(IEdmVault7 vault, EdmCmdData file) { InitializeComponent(); this.SizeChanged += Config_Select_SizeChanged; Vault = vault; File = file; }
//, EdmCmdData file) public Config_Select(IEdmVault7 vault) { InitializeComponent(); this.SizeChanged += Config_Select_SizeChanged; Vault = vault; //File = file; //StartMethod = "file"; }
public static void UnLock(IEdmVault7 vault, List <Files.Info> files) { Logger.Add($"Начало регистрации {files?.Count} файлов."); try { ppoSelection = new EdmSelItem[files.Count]; batchUnlocker = (IEdmBatchUnlock)vault.CreateUtility(EdmUtility.EdmUtil_BatchUnlock); var i = 0; foreach (var file in files) { try { var filePath = file.FolderPath + "\\" + file.ConvertFile; fileNameErr = filePath; IEdmFolder5 folder = default(IEdmFolder5); aFile = vault.GetFileFromPath(filePath, out folder); aPos = aFile.GetFirstFolderPosition(); aFolder = aFile.GetNextFolder(aPos); ppoSelection[i] = new EdmSelItem(); ppoSelection[i].mlDocID = aFile.ID; ppoSelection[i].mlProjID = aFolder.ID; i = i + 1; } catch (Exception ex) { Logger.Add($"Ошибка при добавлении файла на регистрацию: {ex.Message} Path: {file.FullFilePath} IdPDM: {file.IdPDM} FolderID: {file.FolderID} Version: {file.CurrentVersion}"); } } // Add selections to the batch of files to check in batchUnlocker.AddSelection((EdmVault5)vault, ppoSelection); if ((batchUnlocker != null)) { batchUnlocker.CreateTree(0, (int)EdmUnlockBuildTreeFlags.Eubtf_ShowCloseAfterCheckinOption + (int)EdmUnlockBuildTreeFlags.Eubtf_MayUnlock); fileList = (IEdmSelectionList6)batchUnlocker.GetFileList((int)EdmUnlockFileListFlag.Euflf_GetUnlocked + (int)EdmUnlockFileListFlag.Euflf_GetUndoLocked + (int)EdmUnlockFileListFlag.Euflf_GetUnprocessed); batchUnlocker.UnlockFiles(0, null); } } catch (COMException ex) { Logger.Add("ERROR BatchUnLock файл: '" + fileNameErr + "', " + ex.StackTrace + " " + ex.Message); } catch (Exception ex) { Logger.Add("ERROR BatchUnLock: '" + fileNameErr + "', " + ex.StackTrace + " " + ex.Message); } Logger.Add($"Завершена регистрации {files?.Count} файлов."); }
public Config_Select(IEdmVault7 vault, IEdmFile5 part, string SearchPart) { InitializeComponent(); this.SizeChanged += Config_Select_SizeChanged; Vault = vault; Part = part; //SearchTerm = SearchPart; //StartMethod = "part"; }
public bool ConvertChunk(IEdmVault7 vault, List <Files.Info> filesInChunk) { Logger.Add(""); try { AddFilesToPdm(vault, Convert(swApp, filesInChunk)); return(true); } catch (Exception ex) { Logger.Add("Convert: " + ex.Message + "; " + ex.StackTrace); return(false); } }
/// <summary> /// 【5】为文件重命名 /// </summary> /// <param name="filepath">文件全名(包含路径)</param> /// <param name="newName">新名称</param> public static void ReName(string filepath, string newName) { IEdmVault5 vault1 = new EdmVault5(); vault1.Login(LogName, PWD, VaultName); IEdmVault7 vault2 = null; vault2 = (IEdmVault7)vault1; IEdmFile10 file = default(IEdmFile10); IEdmFolder5 ppoRetParentFolder; file = (IEdmFile11)vault2.GetFileFromPath(filepath, out ppoRetParentFolder); file.Rename(new Control().Handle.ToInt32(), newName); }
public EdmBomLayout[] GetBoom(string vaultName) { IEdmVault7 vault2 = null; vault2 = (IEdmVault9)edmVeult5; if (!edmVeult5.IsLoggedIn) { edmVeult5.LoginAuto(vaultName, 0); } IEdmBomMgr bomMgr = (IEdmBomMgr)vault2.CreateUtility(EdmUtility.EdmUtil_BomMgr); EdmBomLayout[] ppoRetLayouts = null; bomMgr.GetBomLayouts(out ppoRetLayouts); return(ppoRetLayouts); }
public void SelectFiles_Click(System.Object sender, System.EventArgs e) { try { File1List.Items.Clear(); IEdmVault7 vault2 = null; if (vault1 == null) { vault1 = new EdmVault5(); } vault2 = (IEdmVault7)vault1; if (!vault1.IsLoggedIn) { vault1.LoginAuto(VaultsComboBox.Text, this.Handle.ToInt32()); } //Set the initial directory in the Select File dialog OpenFileDialog1.InitialDirectory = vault1.RootFolderPath; //Show the Select File dialog System.Windows.Forms.DialogResult DialogResult; DialogResult = OpenFileDialog1.ShowDialog(); if (!(DialogResult == System.Windows.Forms.DialogResult.OK)) { // do nothing } else { IEdmFolder5 ppoRetParentFolder; foreach (string FileName in OpenFileDialog1.FileNames) { File1List.Items.Add(FileName); aFile = (IEdmFile7)vault1.GetFileFromPath(FileName, out ppoRetParentFolder); } } } catch (System.Runtime.InteropServices.COMException ex) { MessageBox.Show("HRESULT = 0x" + ex.ErrorCode.ToString("X") + " " + ex.Message); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// 【4.4】文件是否被检入,true为检出状态。false为检入状态 /// </summary> /// <param name="filepath">文件全名(包含路径)</param> /// <returns></returns> public static bool IsLock(string filepath) { IEdmVault5 vault1 = new EdmVault5(); vault1.Login(LogName, PWD, VaultName); IEdmVault7 vault2 = null; vault2 = (IEdmVault7)vault1; IEdmFile11 aFile = default(IEdmFile11); IEdmFolder5 ppoRetParentFolder; if (filepath.Length > 0) { aFile = (IEdmFile11)vault2.GetFileFromPath(filepath, out ppoRetParentFolder); } return(aFile.IsLocked); }
/// <summary> /// 【4.3】取消捡出指定文件 /// </summary> /// <param name="filepath">文件全名(包含路径)</param> public static void CancelCheckOut(string filepath) { IEdmVault5 vault1 = new EdmVault5(); vault1.Login(LogName, PWD, VaultName); IEdmVault7 vault2 = null; vault2 = (IEdmVault7)vault1; IEdmFile11 aFile = default(IEdmFile11); IEdmFolder5 ppoRetParentFolder; if (filepath.Length > 0) { aFile = (IEdmFile11)vault2.GetFileFromPath(filepath, out ppoRetParentFolder); aFile.UndoLockFile(new System.Windows.Forms.Control().Handle.ToInt32()); } }
/// <summary> /// 【2.1】根据路径获取ID /// </summary> /// <param name="filepath">文件路径(包含文件名)</param> /// <returns></returns> public static int GetFileID(string filepath) { IEdmVault5 vault1 = new EdmVault5(); vault1.Login(LogName, PWD, VaultName); IEdmVault7 vault2 = null; vault2 = (IEdmVault7)vault1; IEdmFile11 aFile = default(IEdmFile11); IEdmFolder5 ppoRetParentFolder; if (filepath.Length > 0) { aFile = (IEdmFile11)vault2.GetFileFromPath(filepath, out ppoRetParentFolder); //aFile.UnlockFile(new System.Windows.Forms.Control().Handle.ToInt32(), ""); } return(aFile.ID); }
public static void SetVariable(IEdmVault7 vault, List <Files.Info> files) { try { foreach (var fileVar in files) { var filePath = fileVar.FolderPath + "\\" + fileVar.ConvertFile; fileNameErr = filePath; IEdmFolder5 folder; aFile = vault.GetFileFromPath(filePath, out folder); var pEnumVar = (IEdmEnumeratorVariable8)aFile.GetEnumeratorVariable();; pEnumVar.SetVar("Revision", "", fileVar.CurrentVersion); } } catch (COMException ex) { Logger.Add("ERROR BatchSetVariable файл: " + fileNameErr + ", " + ex.Message); } }
/// <summary> /// 【6】pdm库内复制文件,返回pdm中文件全路径(包含文件名) /// </summary> /// <param name="oldFile">旧文件位置</param> /// <param name="newFolder">新文件夹位置</param> public static string CopyFile(string oldFile, string newFolder) { IEdmVault5 vault1 = new EdmVault5(); vault1.Login(LogName, PWD, VaultName); IEdmVault7 vault2 = null; vault2 = (IEdmVault7)vault1; IEdmFile10 file = default(IEdmFile10); IEdmFolder5 ppoRetParentFolder; file = (IEdmFile11)vault2.GetFileFromPath(oldFile, out ppoRetParentFolder); IEdmFolder5 destFolder1 = default(IEdmFolder5); destFolder1 = vault2.GetFolderFromPath(newFolder);//新文件夹位置 IEdmFolder8 destFolder = (IEdmFolder8)destFolder1; int FileID = 0; int copyFileStatus; FileID = destFolder.CopyFile2(file.ID, ppoRetParentFolder.ID, new Control().Handle.ToInt32(), out copyFileStatus, "", (int)EdmCopyFlag.EdmCpy_Simple); return(destFolder1.LocalPath + "\\" + file.Name.Substring(file.Name.LastIndexOf('\\') + 1)); }
public static void Delete(IEdmVault7 vault, List <Files.Info> files) { Logger.Add($"Удаление файлов из PDM"); EdmBatchDelErrInfo[] ppoDelErrors = null; try { var batchDeleter = (IEdmBatchDelete3)vault.CreateUtility(EdmUtility.EdmUtil_BatchDelete); foreach (var file in files) { if (!file.ExistEdrawing) { var filePath = file.FolderPath + "\\" + file.ConvertFile; // Add selected file to the batch try { batchDeleter.AddFileByPath(filePath); } catch (Exception ex) { Logger.Add($"Ошибка при удалении: {ex.Message} Path: {file.FullFilePath} IdPDM: {file.IdPDM} FolderID: {file.FolderID} Version: {file.CurrentVersion}"); } } } batchDeleter.ComputePermissions(true, null); var retVal = batchDeleter.CommitDelete(0, null); if ((!retVal)) { batchDeleter.GetCommitErrors(ppoDelErrors); } } catch (COMException ex) { Logger.Add("ERROR BatchDelete - " + ppoDelErrors + " - HRESULT = 0x" + ex.ErrorCode.ToString("X") + " " + ex.Message);//, 10001); } }
static string GetRevision(IEdmVault7 vault, int TaskType, string filePath) { var variable = ""; try { var aFolder = default(IEdmFolder5); aFile = vault.GetFileFromPath(filePath, out aFolder); object oVarRevision; if (aFile == null) { variable = "0"; } else { var pEnumVar = (IEdmEnumeratorVariable8)aFile.GetEnumeratorVariable(); pEnumVar.GetVar("Revision", "", out oVarRevision); if (oVarRevision == null) { variable = "0"; } else { variable = oVarRevision.ToString(); } } } catch (COMException ex) { Logger.Add("Batch.Get HRESULT = 0x" + ex.ErrorCode.ToString("X") + " " + ex.Message); } catch (Exception ex) { Logger.Add("Batch.Get Error " + ex.Message); } return(variable); }
///// <summary> ///// Download file in to local directory. ///// </summary> ///// <param name="dataModel"></param> //public string GetPathAndDownLoadFile(DataModel dataModel, string directoryPath) //{ // this.PDMInitialize(); // IEdmFolder5 srcFolder = null; // IEdmFile5 file = edmVault5.GetFileFromPath(dataModel.Path,out srcFolder); // IEdmVault7 vault2 = (IEdmVault7)this.edmVault5; // IEdmFolder5 edmFolder5 = vault2.GetFolderFromPath(directoryPath); // IEdmFolder8 edmFolder8 = (IEdmFolder8)edmFolder5; // int copyFileStatus; // edmFolder8.CopyFile2(file.ID, srcFolder.ID, 0, out copyFileStatus, "", (int)EdmCopyFlag.EdmCpy_Simple); // //var batchGetter = (IEdmBatchGet)(edmVault5 as IEdmVault7).CreateUtility(EdmUtility.EdmUtil_BatchGet); // // batchGetter.AddSelectionEx((EdmVault5)edmVault5, dataModel.Id, dataModel.FolderId, 0); // // if ((batchGetter != null)) // // { // // batchGetter.CreateTree(0, (int)EdmGetCmdFlags.Egcf_SkipUnlockedWritable); // // batchGetter.GetFiles(0, null); // // } // return null; //} /// <summary> /// Reference in to the components of assembly. /// </summary> /// <param name="file"></param> /// <param name="indent"></param> /// <param name="projName"></param> /// <returns></returns> private string AddReferences(IEdmReference5 file, long indent, ref string projName) { string filename = null; filename = filename + file.Name; const bool isTop = false; IEdmVault7 vault2 = null; if (edmVault5 == null) { edmVault5 = new EdmVault5(); } vault2 = (IEdmVault7)edmVault5; if (!edmVault5.IsLoggedIn) { edmVault5.LoginAuto(vaultname, 0); } IEdmPos5 pos = file.GetFirstChildPosition(projName, isTop, true, 0); IEdmFolder5 oFolder = null; while (!(pos.IsNull)) { IEdmReference5 @ref = file.GetNextChild(pos); var oFile = (IEdmFile5)edmVault5.GetFileFromPath(@ref.FoundPath, out oFolder); filename = filename + AddReferences(@ref, indent, ref projName); //MessageBox.Show(filename); // Последняя копия перечня в сборке oFile.GetFileCopy(0, "", @ref.FoundPath); } return(filename); }
public static void BatchGet(IEdmVault7 vault, List <AddinConvertTo.Classes.FilesData.TaskParam> files) { try { var batchGetter = (IEdmBatchGet)vault.CreateUtility(EdmUtility.EdmUtil_BatchGet); foreach (var taskVar in files) { //MessageBox.Show($"IdPDM - {taskVar.IdPDM}\n FolderID - {taskVar.FolderID}\n CurrentVersion - {taskVar.CurrentVersion}"); //batchGetter.AddSelectionEx((EdmVault5)vault, taskVar.IdPDM, taskVar.FolderID, taskVar.CurrentVersion); IEdmFolder5 ppoRetParentFolder; IEdmFile5 aFile; try { aFile = vault.GetFileFromPath(taskVar.FullFilePath, out ppoRetParentFolder); } catch (Exception ex) { //MessageBox.Show(ex.Message + "\n" + taskVar.FullFilePath, " Получение файла из PDM"); continue; } aFile = (IEdmFile5)vault.GetObject(EdmObjectType.EdmObject_File, taskVar.IdPDM); var aPos = aFile.GetFirstFolderPosition(); var aFolder = aFile.GetNextFolder(aPos); batchGetter.AddSelectionEx((EdmVault5)vault, taskVar.IdPDM, aFolder.ID, taskVar.CurrentVersion); } if ((batchGetter != null)) { batchGetter.CreateTree(0, (int)EdmGetCmdFlags.Egcf_SkipUnlockedWritable + (int)EdmGetCmdFlags.Egcf_RefreshFileListing); batchGetter.GetFiles(0, null); } } catch (Exception exception) { Логгер.Ошибка($"Message - {exception.Message}\nStackTrace - {exception.StackTrace}", null, "BatchUnLock", "SwEpdm"); //MessageBox.Show(ex.Message + "\n" + ex.StackTrace); } }
//private const string VaultName = @"Vents-PDM"; public void CheckPdmVault() { try { if (Vault1 == null) { Vault1 = new EdmVault5(); } Vault2 = (IEdmVault7)Vault1; var ok = Vault1.IsLoggedIn; if (!ok) { Vault1.LoginAuto(VaultName, 0); } } catch (Exception ex) { MessageBox.Show(ex.Message + @"; " + ex.StackTrace); } }
/// <summary> /// 【8】根据文件名称搜索路径,返回全部路径的集合,如果未搜索到返回null /// </summary> /// <param name="fileName">文件名称(不包含路径)</param> public static List <string> SearchPart(string fileName) { IEdmVault5 vault1 = new EdmVault5(); vault1.Login(LogName, PWD, VaultName); IEdmVault7 vault2 = null; vault2 = (IEdmVault7)vault1; IEdmSearch5 Search = (IEdmSearch5)vault2.CreateUtility(EdmUtility.EdmUtil_Search); Search.FileName = "%" + fileName + "%"; //模糊搜索 //Search.FileName = fileName;//命名搜索 IEdmSearchResult5 Result = Search.GetFirstResult(); //搜索第一个 List <string> lst = new List <string>(); //string filePath = string.Empty; while (Result != null) { lst.Add(Result.Path); Result = Search.GetNextResult();//搜索下一个 } return(lst); }
void CheckPdmVault() { try { if (_edmVault5 == null) { _edmVault5 = new EdmVault5(); } _edmVault7 = _edmVault5; var ok = _edmVault5.IsLoggedIn; if (!ok) { _edmVault5.LoginAuto("Vents-PDM", 0); } } catch (Exception) { // ignored } }
private void LoginToEPDM() { if (vault5 == null) { vault5 = new EdmVault5(); vault7 = (IEdmVault7)vault5; } if (!vault5.IsLoggedIn) { try { vault5.LoginAuto("Production Vault", this.Handle.ToInt32()); } catch { MessageBox.Show("The Production Vault is Currently Unavailable"); return; } } validUser = CheckUser(); }
public static void ClearLocalCache(IEdmVault7 vault, List <Files.Info> listType) { try { var ClearLocalCache = (IEdmClearLocalCache3)vault.CreateUtility(EdmUtility.EdmUtil_ClearLocalCache); ClearLocalCache.IgnoreToolboxFiles = true; //Declare and create the IEdmBatchListing object var BatchListing = (IEdmBatchListing)vault.CreateUtility(EdmUtility.EdmUtil_BatchList); foreach (var item in listType) { ClearLocalCache.AddFileByPath(item.FullFilePath); //((IEdmBatchListing2)BatchListing).AddFileCfg(KvPair.Key, DateTime.Now, (Convert.ToInt32(KvPair.Value)), "@", Convert.ToInt32(EdmListFileFlags.EdmList_Nothing)); } //Clear the local cache of the reference files ClearLocalCache.CommitClear(); } catch (COMException ex) { Logger.Add("ERROR ClearLocalCache файл: " + fileNameErr + " HRESULT = 0x" + ex.ErrorCode.ToString("X") + " " + ex.Message);//, 10001); } }
/// <summary> /// 【3】将文件添加到库中指定位置——导入,并返回pdm中文件全路径(包含文件名) /// </summary> /// <param name="FullName">要复制库外文件路径和名称</param> /// <param name="path">库中根目录下具体位置,如“\\03标准规范\\05技术通知单”</param> /// <returns></returns> public static string AddFile(string FullName, string path) { IEdmVault5 vault1 = new EdmVault5(); IEdmVault7 vault2 = (IEdmVault7)vault1; vault1.Login(LogName, PWD, VaultName);//使用管理员登录每个用户不同 // Add selected file to the root folder of the vault IEdmFolder5 Folder = default(IEdmFolder8); Folder = (IEdmFolder8)vault2.RootFolder; Folder = vault2.GetFolderFromPath(Folder.LocalPath + path); string name = FullName.Substring(FullName.LastIndexOf("\\") + 1); if (File.Exists(Folder.LocalPath + "\\" + name)) { MessageBox.Show("文件已经存在,请更改文件名称!", "提示信息"); return(""); } else { Folder.AddFile(new System.Windows.Forms.Control().Handle.ToInt32(), FullName, "", 0); } return(Folder.LocalPath + "\\" + name); }
static void CheckPdmVault() { try { if (Vault == null) { Vault = new EdmVault5(); } var ok = Vault.IsLoggedIn; if (!ok) { //vault.LoginAuto("Tets_debag", 0); Vault.LoginAuto("Vents-PDM", 0); } Vault8 = (IEdmVault8)Vault; } catch (Exception ex) { System.Windows.MessageBox.Show(ex.Message + "; " + ex.StackTrace); } }
public void GetVars_Click(System.Object sender, System.EventArgs e) { try { IEdmVault7 vault2 = null; if (vault1 == null) { vault1 = new EdmVault5(); } vault2 = (IEdmVault7)vault1; if (!vault1.IsLoggedIn) { //Log into selected vault as the current user vault1.LoginAuto(VaultsComboBox.Text, this.Handle.ToInt32()); } IEdmFile5 aFile = default(IEdmFile5); IEdmFolder5 ppoRetParentFolder = null; aFile = vault2.GetFileFromPath(ListBox.Items[0].ToString(), out ppoRetParentFolder); //Get card variables only from a file checked into the vault if (!aFile.IsLocked) { aFile.LockFile(vault2.RootFolderID, this.Handle.ToInt32(), (int)EdmLockFlag.EdmLock_Simple); IEdmEnumeratorVariable5 varEnum = default(IEdmEnumeratorVariable5); varEnum = aFile.GetEnumeratorVariable(); object[] valueList = null; varEnum.GetUpdateVars(aFile.LockedInFolderID, out valueList); int idx = 0; idx = Information.LBound(valueList); int upper = 0; upper = Information.UBound(valueList); string msg = null; msg = "Card variables for " + aFile.Name + " in configuration, @:" + Constants.vbLf + Constants.vbLf; IEdmVariableMgr5 varMgr = default(IEdmVariableMgr5); varMgr = (IEdmVariableMgr5)aFile.Vault; IEdmVariable5 var = default(IEdmVariable5); IEdmVariableValue6 value = default(IEdmVariableValue6); while (idx <= upper) { value = (IEdmVariableValue6)valueList[idx]; idx = idx + 1; var = varMgr.GetVariable(value.VariableID); msg = msg + value.VariableName + " = > " + value.GetValue("@").ToString() + Constants.vbLf; msg = msg + "EdmVariableFlags: " + var.Flags + ", EdmVariableType: " + var.VariableType + Constants.vbLf + Constants.vbLf; //msg = msg & "EdmVariableFlags: " & value.VariableFlags & ", EdmVariableType: " & value.VariableType & vbLf & vbLf } MessageBox.Show(msg); aFile.UndoLockFile(this.Handle.ToInt32()); } else { //User selected a checked-out file MessageBox.Show("Please select a checked-in file."); } } catch (System.Runtime.InteropServices.COMException ex) { MessageBox.Show("HRESULT = 0x" + ex.ErrorCode.ToString("X") + " " + ex.Message); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void AddBill(IEdmVault7 vault, EdmCmdData file,string selected_config, out string config) { config = null; IEdmEnumeratorVariable5 var; IEdmFile7 part = (IEdmFile7)vault.GetObject(EdmObjectType.EdmObject_File, file.mlObjectID1); string file_ext = file.mbsStrData1.Substring(file.mbsStrData1.LastIndexOf('.') + 1).ToUpper(); if (file_ext != "SLDDRW" || UpdateItemRef(file, part, vault)) { var = part.GetEnumeratorVariable(); selected_config = DetermineConfig(part, vault, file, ""); config = selected_config; } #region Drawing Bill if (file_ext == "SLDDRW") { config = "DRAWING"; BW.DoWork += BW_DoWorkDrawing; object[] args = new object[2]; args[0] = part; args[1] = vault; BW.RunWorkerAsync(args); BWForm.ShowDialog(); ProcessBill(vault, file); BW.DoWork -= BW_DoWorkDrawing; } #endregion else { if (selected_config == "") { config = null; return; } BW.DoWork += BW_DoWorkAssy; object[] args = new object[3]; args[0] = part; args[1] = vault; args[2] = selected_config; try { BW.RunWorkerAsync(args); } catch { if (BW.IsBusy == true) { BW.CancelAsync(); while (!BW.CancellationPending) { BW.RunWorkerAsync(args); } } } BWForm.ShowDialog(); ProcessBill(vault, file); BW.DoWork -= BW_DoWorkAssy; } }
public bool HaveUpToDateItemRef(EdmCmdData file,IEdmFile5 Part, IEdmVault7 vault) { bool retval = false; long Local = Part.GetLocalVersionNo(file.mlObjectID3); int Server = Part.CurrentVersion; if (Local == Server) retval = true; return retval; }
public bool PartExistsSW(IEdmVault7 vault, string SearchPart) { object partnum_val = ""; IEdmSearch5 Search = vault.CreateSearch(); Search.Clear(); //Search.FileName = SearchPart; Search.AddVariable("Number", SearchPart); Search.FindFolders = false; Search.FindFiles = true; IEdmSearchResult5 Result = Search.GetFirstResult(); if (Result != null) return true; else return false; }
public static void BatchGet(IEdmVault7 vault, List<AddinConvertTo.Classes.FilesData.TaskParam> files) { try { var batchGetter = (IEdmBatchGet)vault.CreateUtility(EdmUtility.EdmUtil_BatchGet); foreach (var taskVar in files) { //MessageBox.Show($"IdPDM - {taskVar.IdPDM}\n FolderID - {taskVar.FolderID}\n CurrentVersion - {taskVar.CurrentVersion}"); //batchGetter.AddSelectionEx((EdmVault5)vault, taskVar.IdPDM, taskVar.FolderID, taskVar.CurrentVersion); IEdmFolder5 ppoRetParentFolder; IEdmFile5 aFile; try { aFile = vault.GetFileFromPath(taskVar.FullFilePath, out ppoRetParentFolder); } catch (Exception ex) { //MessageBox.Show(ex.Message + "\n" + taskVar.FullFilePath, " Получение файла из PDM"); continue; } aFile = (IEdmFile5)vault.GetObject(EdmObjectType.EdmObject_File, taskVar.IdPDM); var aPos = aFile.GetFirstFolderPosition(); var aFolder = aFile.GetNextFolder(aPos); batchGetter.AddSelectionEx((EdmVault5)vault, taskVar.IdPDM, aFolder.ID, taskVar.CurrentVersion); } if ((batchGetter != null)) { batchGetter.CreateTree(0, (int)EdmGetCmdFlags.Egcf_SkipUnlockedWritable + (int)EdmGetCmdFlags.Egcf_RefreshFileListing); batchGetter.GetFiles(0, null); } } catch (Exception exception) { Логгер.Ошибка($"Message - {exception.Message}\nStackTrace - {exception.StackTrace}", null, "BatchUnLock", "SwEpdm"); //MessageBox.Show(ex.Message + "\n" + ex.StackTrace); } }
public bool CheckBill(List<string> BillNumbers, IEdmVault7 vault, EdmCmdData file) { for (int i = 0; i < BillNumbers.Count; i++) { bool exists = DataList.PartExists(BillNumbers[i]); if (!exists) { string Config; IEdmFile7 Part = FindPartinVault(vault, BillNumbers[i], out Config); if (Part != null) { try { GetItemInfo(file, vault, Part, ""); } catch (Exception ex) { MessageBox.Show(ex.Message + "\nAn error has occured with this item. Check its properties to ensure no errors and try again","Error!",MessageBoxButtons.OK,MessageBoxIcon.Error); } } else { DialogResult DR = MessageBox.Show("File not found in vault.\nDo you want to manually add this item?", "Part Not Found!", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (DR == DialogResult.Yes) { Item_Master IM = new Item_Master(); IM.ShowDialog(); } else return false; } } } return true; }
public DialogResult CheckOutPart(IEdmVault7 vault, EdmCmdData file) { object partnum_val; IEdmFile5 part = (IEdmFile5)vault.GetObject(EdmObjectType.EdmObject_File, file.mlObjectID1); IEdmEnumeratorVariable5 var = part.GetEnumeratorVariable(); string selected_config = DetermineConfig(part, vault, file, ""); var.GetVar("Number", selected_config, out partnum_val); if (selected_config != "") { CheckOut_Master CM = new CheckOut_Master(partnum_val.ToString()); CM.ShowDialog(); return CM.DialogResult; } else return DialogResult.Cancel; }
public DialogResult AddRevision(IEdmVault7 vault, EdmCmdData file, string selected_config) { object partnum_val; object rev_val; DialogResult RetVal = DialogResult.Cancel; IEdmFile5 part = (IEdmFile5)vault.GetObject(EdmObjectType.EdmObject_File, file.mlObjectID1); IEdmEnumeratorVariable5 var = part.GetEnumeratorVariable(); if (selected_config == null || selected_config == "") selected_config = DetermineConfig(part, vault, file, ""); if (selected_config != "") { var.GetVar("Number", selected_config, out partnum_val); var.GetVar("Revision", selected_config, out rev_val); if (rev_val == null) { MessageBox.Show("Item has not been completed and released. Please make certain that the item has a revision before attempting to add a revision in Epicor.", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { Revision_Master RM = new Revision_Master(partnum_val.ToString(), rev_val.ToString(), "", ""); RM.ShowDialog(); RetVal = RM.DialogResult; } } return RetVal; }
public void CalcMins(IEdmVault7 vault, EdmCmdData file, string selected_config) { IEdmEnumeratorVariable5 var; IEdmFile7 part = (IEdmFile7)vault.GetObject(EdmObjectType.EdmObject_File, file.mlObjectID1); string file_ext = file.mbsStrData1.Substring(file.mbsStrData1.LastIndexOf('.') + 1).ToUpper(); if (UpdateItemRef(file, part, vault)) { var = part.GetEnumeratorVariable(); selected_config = DetermineConfig(part, vault, file, ""); } if (selected_config != "") { BW.DoWork += BW_DoWorkCalc; object[] args = new object[3]; args[0] = part; args[1] = vault; args[2] = selected_config; BW.RunWorkerAsync(args); BWForm.ShowDialog(); foreach (BillItem item in Bill) { string Config = null; object val = null; IEdmFile7 Part = FindPartinVault(vault, item.ToString(), Config); EdmStrLst5 list = Part.GetConfigurations(); IEdmPos5 pos = list.GetHeadPosition(); Config = list.GetNext(pos); Config = list.GetNext(pos); if (Config == "PreviewCfg") Config = list.GetNext(pos); var = Part.GetEnumeratorVariable(); var.GetVar("HW Code", Config, out val); if (val != null) { if (val.ToString() == "HUCK") Mins[0] += double.Parse(item.Qty); if (val.ToString() == "TEC") Mins[1] += double.Parse(item.Qty); if (val.ToString() == "BOLT") Mins[2] += double.Parse(item.Qty); if (val.ToString() == "RIVET") Mins[3] += double.Parse(item.Qty); if (val.ToString() == "BAND") Mins[4] += double.Parse(item.Qty); if (val.ToString() == "HEAT") Mins[5] += double.Parse(item.Qty); if (val.ToString() == "SPRING") Mins[6] += double.Parse(item.Qty); if (val.ToString() == "ZHOOK") Mins[7] += double.Parse(item.Qty); } } BW.DoWork -= BW_DoWorkCalc; } }
public DialogResult AddOOM(IEdmVault7 vault, EdmCmdData file, string selected_config) { object partnum_val; object rev_val; IEdmFile5 part = (IEdmFile5)vault.GetObject(EdmObjectType.EdmObject_File, file.mlObjectID1); IEdmEnumeratorVariable5 var = part.GetEnumeratorVariable(); DialogResult RetVal = DialogResult.Cancel; if (selected_config == null || selected_config == "") selected_config = DetermineConfig(part, vault, file, ""); if (selected_config != "") { var.GetVar("Number", selected_config, out partnum_val); var.GetVar("Revision", selected_config, out rev_val); if (rev_val == null) { MessageBox.Show("Revision cannot be null. Check that custom properties are filled out in the selected configuration", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); return DialogResult.Cancel; } Operations_Master OM = new Operations_Master(partnum_val.ToString(), rev_val.ToString()); OM.ShowDialog(); RetVal = OM.DialogResult; } return RetVal; }
/// <summary> /// Syncs local version of a file with the current version in the vault /// </summary> /// <param name="Part"></param> /// <param name="vault"></param> /// <returns></returns> public bool UpdateItemRef(EdmCmdData file,IEdmFile5 Part, IEdmVault7 vault) { bool retval = false; if (!HaveUpToDateItemRef(file,Part, vault)) { DialogResult dr = MessageBox.Show("This requires that you get the latest version of this file. Continue?", "Warning!", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { Part.GetFileCopy(0, 0, 0, (int)EdmGetFlag.EdmGet_RefsVerLatest, ""); retval = true; } else retval = false; } else retval = true; return retval; }
//, List<string> BillNumbers, List<string> _BillQty, out List<string> BillQty) public void ProcessBill(IEdmVault7 vault, EdmCmdData file) { for (int i = 0; i < Bill.Count; i++) { if (DataList.PartExists(Bill[i].ToString())) { /*Part exists and we are good*/} else { if (PartExistsSW(vault, Bill[i].ToString())) { //Get it, Add it string Config = null; IEdmFile7 Part = FindPartinVault(vault, Bill[i].ToString(), out Config); DialogResult Dr = GetItemInfo(file, vault, Part, ""); if (Dr == DialogResult.Cancel) Bill.RemoveAt(i); } else { DialogResult Dr = MessageBox.Show(Bill[i].ToString() + " was not found in the vault/Epicor database. Do you want to manually add it?", "Missing Item!", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk); if (Dr == DialogResult.Yes) { //Blank item master Item_Master IM = new Item_Master(Bill[i].ToString(), "", 0); IM.ShowDialog(); if (IM.DialogResult == DialogResult.Cancel) Bill.RemoveAt(i); } else { //Remove from the bill to proceed Bill.RemoveAt(i); } } } } }
public bool HaveUpToDateItemRef(IEdmFile5 Part, IEdmVault7 vault) { bool retval = false; long Local = Part.GetLocalVersionNo(Part.GetLocalPath(0)); int Server = Part.CurrentVersion; if (Local == Server) retval = true; return retval; }
public string DetermineConfig(IEdmFile5 Part, IEdmVault7 vault,EdmCmdData file, string SearchTerm) { string retval = "@"; EdmStrLst5 list = Part.GetConfigurations(); IEdmPos5 pos = list.GetHeadPosition(); Config_Select config; if (SearchTerm != "") config = new Config_Select(vault, Part, SearchTerm); else config = new Config_Select(vault, file); for (int i = 0; i < list.Count; i++) { string name = list.GetNext(pos); if (name != "@") { object number; object area; object mass; IEdmEnumeratorVariable5 var = Part.GetEnumeratorVariable(); var.GetVar("Number", name, out number); var.GetVar("NetWeight", name, out mass); var.GetVar("SurfaceArea", name, out area); if (number != null && mass != null && area != null) { config.config_cbo.Items.Add(name); } } } config.config_cbo.SelectedIndex = 0; config.ShowDialog(); retval = config.SelectedConfig; if (config.DialogResult == System.Windows.Forms.DialogResult.Cancel) return ""; return retval; }
public DialogResult GetItemInfobyPath(IEdmVault7 vault, IEdmFile7 Part, string Path) { IEdmEnumeratorVariable5 var; string selected_config; object partnum_val; object desc_val; object weight_val; object product_val; object class_val; object type_val; object planner_val; if (UpdateItemRef(Part, vault, Path)) { var = Part.GetEnumeratorVariable(); decimal weight_fallback = 0; selected_config = DetermineConfig(Part, vault, null); var.GetVar("Number", selected_config, out partnum_val); var.GetVar("Description", selected_config, out desc_val); var.GetVar("Product", selected_config, out product_val); var.GetVar("Class", selected_config, out class_val); var.GetVar("Type", selected_config, out type_val); var.GetVar("Planner", selected_config, out planner_val); //Weight is typically @ config var.GetVar("NetWeight", selected_config, out weight_val); if (weight_val == null) var.GetVar("NetWeight", selected_config, out weight_val); if (weight_val != null) decimal.TryParse(weight_val.ToString(), out weight_fallback); if (partnum_val != null) { Epicor_Integration.Item_Master item = new Item_Master(partnum_val.ToString(), desc_val.ToString(), weight_fallback, product_val.ToString(), class_val.ToString(), type_val.ToString(), planner_val.ToString()); item.ShowDialog(); return item.DialogResult; } else { //Not necessary anymore //MessageBox.Show("Part number was a null value!\n\nEnsure that custom properties are completely filled out.", "Missing Properties!", MessageBoxButtons.OK, MessageBoxIcon.Hand); return DialogResult.Cancel; } } else return DialogResult.Cancel; }
void CheckPdmVault() { try { if (Vault1 == null) { Vault1 = new EdmVault5(); } Vault2 = (IEdmVault7)Vault1; var ok = Vault1.IsLoggedIn; if (!ok) { Vault1.LoginAuto("Vents-PDM", 0); } } catch (Exception ex) { MessageBox.Show(ex.Message + "; " + ex.StackTrace); } }
public void GetBOM_Click(System.Object sender, System.EventArgs e) { try { IEdmVault7 vault2 = null; if (vault1 == null) { vault1 = new EdmVault5(); } vault2 = (IEdmVault9)vault1; if (!vault1.IsLoggedIn) { vault1.LoginAuto(VaultsComboBox.Text, this.Handle.ToInt32()); } if (aFile != null) { // Get named BOMs and their versions for the selected file EdmBomInfo[] derivedBOMs = null; aFile.GetDerivedBOMs(out derivedBOMs); int arrSize = 0; EdmBomVersion[] ppoVersions = null; int i = 0; int j = 0; int id = 0; string str = ""; string verstr = ""; int verArrSize = 0; arrSize = derivedBOMs.Length; while (i < arrSize) { id = derivedBOMs[i].mlBomID; bom = (IEdmBom)vault2.GetObject(EdmObjectType.EdmObject_BOM, id); str = "Named BOM: " + derivedBOMs[i].mbsBomName + Constants.vbLf + "Check-out user: "******"Current state: " + bom.CurrentState.Name + Constants.vbLf + "Current version: " + bom.CurrentVersion + Constants.vbLf + "ID: " + bom.FileID + Constants.vbLf + "Is checked out: " + bom.IsCheckedOut; MessageBox.Show(str); bom.GetVersions(out ppoVersions); verArrSize = ppoVersions.Length; while (j < verArrSize) { verstr = "BOM version: " + Constants.vbLf + "Type as defined in EdmBomVersionType: " + ppoVersions[j].meType + Constants.vbLf + "Version number: " + ppoVersions[j].mlVersion + Constants.vbLf + "Date: " + ppoVersions[j].moDate + Constants.vbLf + "Label: " + ppoVersions[j].mbsTag + Constants.vbLf + "Comment: " + ppoVersions[j].mbsComment; MessageBox.Show(verstr); j = j + 1; } i = i + 1; } // Get a BOM view with the specified layout bomMgr = (IEdmBomMgr)vault2.CreateUtility(EdmUtility.EdmUtil_BomMgr); EdmBomLayout[] ppoRetLayouts = null; EdmBomLayout ppoRetLayout = default(EdmBomLayout); bomMgr.GetBomLayouts(out ppoRetLayouts); i = 0; arrSize = ppoRetLayouts.Length; str = ""; while (i < arrSize) { ppoRetLayout = ppoRetLayouts[i]; str = "BOM Layout " + i + ": " + ppoRetLayout.mbsLayoutName + Constants.vbLf + "ID: " + ppoRetLayout.mlLayoutID; if (ppoRetLayout.mbsLayoutName == "BOM") { bomView = aFile.GetComputedBOM(ppoRetLayout.mbsLayoutName, 0, "@", (int)EdmBomFlag.EdmBf_AsBuilt + (int)EdmBomFlag.EdmBf_ShowSelected); } MessageBox.Show(str); i = i + 1; } // Display BOM view row and column information object[] ppoRows = null; IEdmBomCell ppoRow = default(IEdmBomCell); bomView.GetRows(out ppoRows); i = 0; arrSize = ppoRows.Length; str = ""; EdmBomColumn[] ppoColumns = null; bomView.GetColumns(out ppoColumns); while (i < arrSize) { ppoRow = (IEdmBomCell)ppoRows[i]; str = "BOM Row " + i + ": " + Constants.vbLf + "Item ID: " + ppoRow.GetItemID() + Constants.vbLf + "Path name: " + ppoRow.GetPathName() + Constants.vbLf + "Tree level: " + ppoRow.GetTreeLevel() + Constants.vbLf + " Is locked? " + ppoRow.IsLocked(); MessageBox.Show(str); int js = 0; int ararSize = ppoColumns.Length; while (js < ararSize) { object poValue = null; object poComputedValue = null; string pbsConfiguration = ""; bool pbReadOnly = false; int plFocusNode = 0; ppoRow.GetVar(ppoColumns[js].mlVariableID, ppoColumns[js].meType, out poValue, out poComputedValue, out pbsConfiguration, out pbReadOnly); str = "BOM Column " + js + ": " + Constants.vbLf + "Header: " + ppoColumns[js].mbsCaption + Constants.vbLf + "Value " + poValue.ToString() + Constants.vbLf + "ComputeValue " + poComputedValue.ToString() + Constants.vbLf + "Config: " + pbsConfiguration + Constants.vbLf + "ReadOnly: " + pbReadOnly.ToString(); MessageBox.Show(str); js = js + 1; } i = i + 1; } //bomView.InsertRow((EdmBomCell)ppoRows[0], EdmBomInsertRowOption.EdmBomInsertRowOption_BelowRow, out ppoNewRow); // ppoNewRow.SetVar(ppoColumns[0].mlVariableID, ppoColumns[0].meType, "vault_name\\temp", "", EdmBomSetVarOption.EdmBomSetVarOption_Both, out errMsg); } } catch (System.Runtime.InteropServices.COMException ex) { MessageBox.Show("HRESULT = 0x" + ex.ErrorCode.ToString("X") + " " + ex.Message); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public DialogResult GetItemInfo(EdmCmdData file, IEdmVault7 vault, IEdmFile7 Part, string selected_config) { IEdmEnumeratorVariable5 var; object partnum_val; object desc_val = ""; object weight_val; object product_val; object class_val; object type_val; object planner_val; if (UpdateItemRef(file,Part, vault)) { try { var = Part.GetEnumeratorVariable(); decimal weight_fallback = 0; if (selected_config == "" || selected_config == null) selected_config = DetermineConfig(Part, vault, file, ""); if (selected_config != "") { var.GetVar("Number", selected_config, out partnum_val); if (partnum_val.ToString().Contains("201")) { DialogResult DR = MessageBox.Show("Part number identified as a frame. Do you want to use the Customer/Model instead of SolidWorks description custom property?", "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (DR == DialogResult.Yes) { object cust_val; var.GetVar("Customer", selected_config, out cust_val); object model_val; var.GetVar("Model", selected_config, out model_val); desc_val = "FRAME " + cust_val.ToString() + " " + model_val.ToString(); } else var.GetVar("Description", selected_config, out desc_val); } else var.GetVar("Description", selected_config, out desc_val); var.GetVar("Brand", selected_config, out planner_val); var.GetVar("Product", selected_config, out product_val); var.GetVar("Class", selected_config, out class_val); var.GetVar("Type", selected_config, out type_val); //Weight is typically @ config var.GetVar("NetWeight", selected_config, out weight_val); if (weight_val == null) var.GetVar("NetWeight", selected_config, out weight_val); if (weight_val != null) decimal.TryParse(weight_val.ToString(), out weight_fallback); if (product_val == null) product_val = ""; if (class_val == null) class_val = ""; if (desc_val == null) desc_val = ""; if (partnum_val != null) { Epicor_Integration.Item_Master item = new Item_Master(partnum_val.ToString(), desc_val.ToString(), weight_fallback, product_val.ToString(), class_val.ToString(), type_val.ToString(), planner_val.ToString()); item.ShowDialog(); return item.DialogResult; } else { //Not necessary anymore //MessageBox.Show("Part number was a null value!\n\nEnsure that custom properties are completely filled out.", "Missing Properties!", MessageBoxButtons.OK, MessageBoxIcon.Hand); return DialogResult.Cancel; } } else return DialogResult.Cancel; } catch (Exception ex) { MessageBox.Show(ex.Message + "\nPlease check the datacard to ensure that all fields are filled in the file.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); return DialogResult.Cancel; } } else return DialogResult.Cancel; }
internal static void BathGet(IEdmVault7 vault, List<AddinConvertTo.Classes.FilesData.TaskParam> list) { BatchGet(vault, list); }
public DialogResult GetItemInfo(IEdmVault7 vault, EdmCmdData file, string selected_config) { IEdmFile7 Part = (IEdmFile7)vault.GetObject(EdmObjectType.EdmObject_File, file.mlObjectID1); return GetItemInfo(file, vault, Part, selected_config); }
public IEdmFile7 FindPartinVault(IEdmVault7 vault, string SearchPart,out string Config) { EdmCmdData file; string selected_config = null; object partnum_val = ""; IEdmSearch5 Search = vault.CreateSearch(); Search.Clear(); //Search.FileName = SearchPart; Search.AddVariable("Number", SearchPart); Search.FindFolders = false; Search.FindFiles = true; IEdmSearchResult5 Result = Search.GetFirstResult(); if (Result != null) { IEdmFile7 part = (IEdmFile7)vault.GetObject(EdmObjectType.EdmObject_File, Result.ID); IEdmEnumeratorVariable5 var = part.GetEnumeratorVariable(); DialogResult DR = MessageBox.Show("A component not entered into Epicor has been located in the vault.\nThe system will attempt to select the correct configuration if necessary.\n\nSearch Part Number: " + SearchPart, "Warning!", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk); if (DR == DialogResult.OK) selected_config = DetermineConfig(part, vault, file_, SearchPart); else { Config = null; return null; } var.GetVar("Number", selected_config, out partnum_val); while (partnum_val.ToString() != SearchPart) { Result = Search.GetNextResult(); part = (IEdmFile7)vault.GetObject(EdmObjectType.EdmObject_File, Result.ID); var = part.GetEnumeratorVariable(); selected_config = DetermineConfig(part, vault, file_, SearchPart); var.GetVar("Number", selected_config, out partnum_val); } Config = selected_config; return part; } else { Config = null; return null; } }
public List<string> ProcessBill(IEdmVault7 vault, List<string> BillNumbers, List<string> _BillQty, out List<string> BillQty, string Path) { for (int i = 0; i < BillNumbers.Count; i++) { if (DataList.PartExists(BillNumbers[i])) { /*Part exists and we are good*/} else { if (PartExistsSW(vault, BillNumbers[i])) { //Get it, Add it string Config = null; IEdmFile7 Part = FindPartinVault(vault, BillNumbers[i], out Config); DialogResult Dr = GetItemInfobyPath(vault, Part, Path); if (Dr == DialogResult.Cancel) BillNumbers.RemoveAt(i); } else { DialogResult Dr = MessageBox.Show(BillNumbers[i] + " was not found in the vault/Epicor database. Do you want to manually add it?", "Missing Item!", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk); if (Dr == DialogResult.Yes) { //Blank item master Item_Master IM = new Item_Master(BillNumbers[i], "", 0); IM.ShowDialog(); if (IM.DialogResult == DialogResult.Cancel) BillNumbers.RemoveAt(i); } else { //Remove from the bill to proceed BillNumbers.RemoveAt(i); } } } } BillQty = _BillQty; return BillNumbers; }